From 5c7056c2ff2fcbfe8f06d83f6735c4a3348fcc14 Mon Sep 17 00:00:00 2001 From: GTimothy <22472919+GTimothy@users.noreply.github.com> Date: Wed, 6 May 2026 12:08:35 +0200 Subject: [PATCH 01/12] add case insensitive suggestion tests stdlib case insensitive tests Co-authored-by: Chris Simpkins additional insensitive import test --- .../case-insensitive-import.rs | 30 + .../case-insensitive-import.stderr | 71 ++ tests/ui/imports/case-insensitive/libstd.rs | 439 +++++++ .../ui/imports/case-insensitive/libstd.stderr | 1057 +++++++++++++++++ 4 files changed, 1597 insertions(+) create mode 100644 tests/ui/imports/case-insensitive/case-insensitive-import.rs create mode 100644 tests/ui/imports/case-insensitive/case-insensitive-import.stderr create mode 100644 tests/ui/imports/case-insensitive/libstd.rs create mode 100644 tests/ui/imports/case-insensitive/libstd.stderr diff --git a/tests/ui/imports/case-insensitive/case-insensitive-import.rs b/tests/ui/imports/case-insensitive/case-insensitive-import.rs new file mode 100644 index 0000000000000..eee380f2f07dc --- /dev/null +++ b/tests/ui/imports/case-insensitive/case-insensitive-import.rs @@ -0,0 +1,30 @@ +mod a{ + enum EnumAB{ + A, + B + } +} +mod b{ + fn enumab_not_in_scope()->enumab{ //~ ERROR + unimplemented!() + } + fn shutdown_not_in_scope()->Shutdown{ //~ ERROR + unimplemented!() + } + fn both_not_in_scope_and_capitalization()->both{ //~ ERROR + unimplemented!() + } + fn shutdown_both_not_in_scope_and_capitalization()->shutdown{ //~ ERROR + both //~ ERROR + } + fn both_missing_std()->std::net::Shutdown{ + net::shutdown::Both //~ ERROR + } + fn shutdown_capitalization()->std::net::Shutdown{ + std::net::shutdown::Both //~ ERROR + } + fn shutdown_and_both_missing_capitalization()->std::net::Shutdown{ + std::net::shutdown::both //~ ERROR + } +} +fn main(){} diff --git a/tests/ui/imports/case-insensitive/case-insensitive-import.stderr b/tests/ui/imports/case-insensitive/case-insensitive-import.stderr new file mode 100644 index 0000000000000..5d3fa1549b5cb --- /dev/null +++ b/tests/ui/imports/case-insensitive/case-insensitive-import.stderr @@ -0,0 +1,71 @@ +error[E0433]: cannot find module or crate `net` in this scope + --> $DIR/case-insensitive-import.rs:21:9 + | +LL | net::shutdown::Both + | ^^^ use of unresolved module or unlinked crate `net` + | + = help: you might be missing a crate named `net` + +error[E0433]: cannot find `shutdown` in `net` + --> $DIR/case-insensitive-import.rs:24:19 + | +LL | std::net::shutdown::Both + | ^^^^^^^^ could not find `shutdown` in `net` + | +help: an enum with a similar name exists (notice the capitalization) + | +LL - std::net::shutdown::Both +LL + std::net::Shutdown::Both + | + +error[E0433]: cannot find `shutdown` in `net` + --> $DIR/case-insensitive-import.rs:27:19 + | +LL | std::net::shutdown::both + | ^^^^^^^^ could not find `shutdown` in `net` + | +help: an enum with a similar name exists (notice the capitalization) + | +LL - std::net::shutdown::both +LL + std::net::Shutdown::both + | + +error[E0425]: cannot find type `enumab` in this scope + --> $DIR/case-insensitive-import.rs:8:31 + | +LL | fn enumab_not_in_scope()->enumab{ + | ^^^^^^ not found in this scope + +error[E0425]: cannot find type `Shutdown` in this scope + --> $DIR/case-insensitive-import.rs:11:33 + | +LL | fn shutdown_not_in_scope()->Shutdown{ + | ^^^^^^^^ not found in this scope + | +help: consider importing this enum + | +LL + use std::net::Shutdown; + | + +error[E0425]: cannot find type `both` in this scope + --> $DIR/case-insensitive-import.rs:14:48 + | +LL | fn both_not_in_scope_and_capitalization()->both{ + | ^^^^ not found in this scope + +error[E0425]: cannot find type `shutdown` in this scope + --> $DIR/case-insensitive-import.rs:17:57 + | +LL | fn shutdown_both_not_in_scope_and_capitalization()->shutdown{ + | ^^^^^^^^ not found in this scope + +error[E0425]: cannot find value `both` in this scope + --> $DIR/case-insensitive-import.rs:18:9 + | +LL | both + | ^^^^ not found in this scope + +error: aborting due to 8 previous errors + +Some errors have detailed explanations: E0425, E0433. +For more information about an error, try `rustc --explain E0425`. diff --git a/tests/ui/imports/case-insensitive/libstd.rs b/tests/ui/imports/case-insensitive/libstd.rs new file mode 100644 index 0000000000000..45463a5467cd9 --- /dev/null +++ b/tests/ui/imports/case-insensitive/libstd.rs @@ -0,0 +1,439 @@ +// checks case typos with libstd::alloc structs + +fn test_layout(_x: LayOut){} +//~^ ERROR: cannot find type `LayOut` in this scope +fn test_system(_x: system){} +//~^ ERROR: cannot find type `system` in this scope + +// checks case typos with libstd::any structs + +fn test_typeid(_x: Typeid){} +//~^ ERROR: cannot find type `Typeid` in this scope + +// checks case typos with libstd::ascii structs + +fn test_escapedefault(_x: Escapedefault){} +//~^ ERROR: cannot find type `Escapedefault` in this scope + +// checks case typos with libstd::cell structs + +fn test_cell(_x: cell<()>){} +//~^ ERROR: cannot find type `cell` in this scope + +// checks case typos with libstd::char structs + +fn test_decodeutf16(_x: DecodeUTF16<()>){} +//~^ ERROR: cannot find type `DecodeUTF16` in this scope + +fn test_escapeunicode(_x: Escapeunicode){} +//~^ ERROR: cannot find type `Escapeunicode` in this scope + +fn test_tolowercase(_x: Tolowercase){} +//~^ ERROR: cannot find type `Tolowercase` in this scope + +fn test_touppercase(_x: Touppercase){} +//~^ ERROR: cannot find type `Touppercase` in this scope + +// checks case typos with libstd::cmp structs + +fn test_reverse(_x: reverse<()>){} +//~^ ERROR: cannot find type `reverse` in this scope + +// checks case typos with libstd::collections structs + +fn test_btreemap(_x: BtreeMap<(), ()>){} +//~^ ERROR: cannot find type `BtreeMap` in this scope +fn test_btreeset(_x: BtreeSet<()>){} +//~^ ERROR: cannot find type `BtreeSet` in this scope +fn test_binaryheap(_x: Binaryheap<()>){} +//~^ ERROR: cannot find type `Binaryheap` in this scope +fn test_hashmap(_x: Hashmap){} +//~^ ERROR: cannot find type `Hashmap` in this scope +fn test_hashset(_x: Hashset<()>){} +//~^ ERROR: cannot find type `Hashset` in this scope +fn test_linkedlist(_x: Linkedlist<()>){} +//~^ ERROR: cannot find type `Linkedlist` in this scope +fn test_vecdeque(_x: Vecdeque<()>){} +//~^ ERROR: cannot find type `Vecdeque` in this scope + +// checks case typos with libstd::env structs + +fn test_args(_x: args){} +//~^ ERROR: cannot find type `args` in this scope +fn test_argsos(_x: Argsos){} +//~^ ERROR: cannot find type `Argsos` in this scope +fn test_splitpaths(_x: Splitpaths<'_>){} +//~^ ERROR: cannot find type `Splitpaths` in this scope +fn test_vars(_x: vars){} +//~^ ERROR: cannot find type `vars` in this scope +fn test_varsos(_x: Varsos){} +//~^ ERROR: cannot find type `Varsos` in this scope + +// checks case typos with libstd::ffi structs + +fn test_cstr(_x: cStr){} +//~^ ERROR: cannot find type `cStr` in this scope +fn test_osstr(_x: Osstr){} +//~^ ERROR: cannot find type `Osstr` in this scope +fn test_osstring(_x: Osstring){} +//~^ ERROR: cannot find type `Osstring` in this scope + +// checks case typos with libstd::fmt structs + +fn test_debuglist(_x: Debuglist){} +//~^ ERROR: cannot find type `Debuglist` in this scope +fn test_debugmap(_x: Debugmap){} +//~^ ERROR: cannot find type `Debugmap` in this scope +fn test_debugset(_x: Debugset){} +//~^ ERROR: cannot find type `Debugset` in this scope +fn test_debugstruct(_x: Debugstruct){} +//~^ ERROR: cannot find type `Debugstruct` in this scope +fn test_debugtuple(_x: Debugtuple){} +//~^ ERROR: cannot find type `Debugtuple` in this scope +fn test_fmter(mut _x: formatter){} +//~^ ERROR: cannot find type `formatter` in this scope + +// checks case typos with libstd::fs structs + +fn test_dirbuilder(_x: Dirbuilder){} +//~^ ERROR: cannot find type `Dirbuilder` in this scope +fn test_direntry(_x: Direntry){} +//~^ ERROR: cannot find type `Direntry` in this scope +fn test_filetype(_x: Filetype){} +//~^ ERROR: cannot find type `Filetype` in this scope +fn test_metadata(_x: MetaData){} +//~^ ERROR: cannot find type `MetaData` in this scope +fn test_openoptions(_x: Openoptions){} +//~^ ERROR: cannot find type `Openoptions` in this scope +fn test_permissions(_x: permissions){} +//~^ ERROR: cannot find type `permissions` in this scope +fn test_readdir(_x: Readdir){} +//~^ ERROR: cannot find type `Readdir` in this scope + +// checks case typos with libstd::hash structs + +fn test_buildhasherdefault(_x: BuildhasherDefault){} +//~^ ERROR: cannot find type `BuildhasherDefault` in this scope + +// checks case typos with libstd::io structs + +fn test_bufreader(_x: Bufreader<()>){} +//~^ ERROR: cannot find type `Bufreader` in this scope +fn test_bufwriter(_x: Bufwriter<()>){} +//~^ ERROR: cannot find type `Bufwriter` in this scope +fn test_bytes(_x: bytes<()>){} +//~^ ERROR: cannot find type `bytes` in this scope +fn test_chain(_x: chain<(), ()>){} +//~^ ERROR: cannot find type `chain` in this scope +fn test_cursor(_x: cursor<()>){} +//~^ ERROR: cannot find type `cursor` in this scope +fn test_empty(_x: empty){} +//~^ ERROR: cannot find type `empty` in this scope +fn test_ioslice(_x: Ioslice){} +//~^ ERROR: cannot find type `Ioslice` in this scope +fn test_ioslicemut(_x: IosliceMut){} +//~^ ERROR: cannot find type `IosliceMut` in this scope +fn test_linewriter(_x: Linewriter<()>){} +//~^ ERROR: cannot find type `Linewriter` in this scope +fn test_lines(_x: lines<()>){} +//~^ ERROR: cannot find type `lines` in this scope +fn test_repeat(_x: repeat){} +//~^ ERROR: cannot find type `repeat` in this scope +fn test_sink(_x: sink){} +//~^ ERROR: cannot find type `sink` in this scope +fn test_split(_x: split<()>){} +//~^ ERROR: cannot find type `split` in this scope +fn test_stderr(_x: StdErr){} +//~^ ERROR: cannot find type `StdErr` in this scope +fn test_stderrlock(_x: StdErrLock){} +//~^ ERROR: cannot find type `StdErrLock` in this scope +fn test_stdin(_x: StdIn){} +//~^ ERROR: cannot find type `StdIn` in this scope +fn test_stdinlock(_x: StdInLock){} +//~^ ERROR: cannot find type `StdInLock` in this scope +fn test_stdout(_x: StdOut){} +//~^ ERROR: cannot find type `StdOut` in this scope +fn test_stdoutlock(_x: StdOutLock){} +//~^ ERROR: cannot find type `StdOutLock` in this scope +fn test_take(_x: take){} +//~^ ERROR: cannot find type `take` in this scope + +// checks case typos with libstd::iter structs + +fn test_cloned(_x: cloned<(), ()>){} +//~^ ERROR: cannot find type `cloned` in this scope +fn test_copied(_x: copied<(), ()>){} +//~^ ERROR: cannot find type `copied` in this scope +fn test_cycle(_x: cycle<(), ()>){} +//~^ ERROR: cannot find type `cycle` in this scope +fn test_enumerate(_x: enumerate<(), ()>){} +//~^ ERROR: cannot find type `enumerate` in this scope +fn test_filter(_x: filter<(), ()>){} +//~^ ERROR: cannot find type `filter` in this scope +fn test_filtermap(_x: Filtermap<(), ()>){} +//~^ ERROR: cannot find type `Filtermap` in this scope +fn test_flatten(_x: flatten<()>){} +//~^ ERROR: cannot find type `flatten` in this scope +fn test_fromfn(_x: Fromfn<()>){} +//~^ ERROR: cannot find type `Fromfn` in this scope +fn test_fuse(_x: fuse<()>){} +//~^ ERROR: cannot find type `fuse` in this scope +fn test_inspect(_x: inspect<(), ()>){} +//~^ ERROR: cannot find type `inspect` in this scope +fn test_map(_x: map<(), ()>){} +//~^ ERROR: cannot find type `map` in this scope +fn test_once(_x: once<()>){} +//~^ ERROR: cannot find type `once` in this scope +fn test_oncewith(_x: Oncewith<()>){} +//~^ ERROR: cannot find type `Oncewith` in this scope +fn test_peekable(_x: peekable<()>){} +//~^ ERROR: cannot find type `peekable` in this scope +fn test_repeatwith(_x: Repeatwith<()>){} +//~^ ERROR: cannot find type `Repeatwith` in this scope +fn test_rev(_x: rev<()>){} +//~^ ERROR: cannot find type `rev` in this scope +fn test_scan(_x: scan<(), (), ()>){} +//~^ ERROR: cannot find type `scan` in this scope +fn test_skip(_x: skip<()>){} +//~^ ERROR: cannot find type `skip` in this scope +fn test_skipwhile(_x: Skipwhile<(), ()>){} +//~^ ERROR: cannot find type `Skipwhile` in this scope +fn test_stepby(_x: Stepby<()>){} +//~^ ERROR: cannot find type `Stepby` in this scope +fn test_successors(_x: successors<()>){} +//~^ ERROR: cannot find type `successors` in this scope +fn test_takewhile(_x: Takewhile<(), ()>){} +//~^ ERROR: cannot find type `Takewhile` in this scope +fn test_zip(_x: zip<(), ()>){} +//~^ ERROR: cannot find type `zip` in this scope + +// checks case typos with libstd::marker structs + +fn test_phantomdata(_x: Phantomdata){} +//~^ ERROR: cannot find type `Phantomdata` in this scope +fn test_phantompinned(_x: Phantompinned){} +//~^ ERROR: cannot find type `Phantompinned` in this scope + +// checks case typos with libstd::mem structs + +fn test_discriminant(_x: discriminant<()>){} +//~^ ERROR: cannot find type `discriminant` in this scope +fn test_manuallydrop(_x: Manuallydrop<()>){} +//~^ ERROR: cannot find type `Manuallydrop` in this scope + +// checks case typos with libstd::net structs + +fn test_incoming(_x: incoming){} +//~^ ERROR: cannot find type `incoming` in this scope +fn test_ipv4addr(_x: IPv4Addr){} +//~^ ERROR: cannot find type `IPv4Addr` in this scope +fn test_ipv6addr(_x: IPv6Addr){} +//~^ ERROR: cannot find type `IPv6Addr` in this scope +fn test_socketaddrv4(_x: SocketAddrv4){} +//~^ ERROR: cannot find type `SocketAddrv4` in this scope +fn test_socketaddrv6(_x: SocketAddrv6){} +//~^ ERROR: cannot find type `SocketAddrv6` in this scope +fn test_tcplistener(_x: TCPListener){} +//~^ ERROR: cannot find type `TCPListener` in this scope +fn test_tcpstream(_x: TCPStream){} +//~^ ERROR: cannot find type `TCPStream` in this scope +fn test_udpsocket(_x: UDPSocket){} +//~^ ERROR: cannot find type `UDPSocket` in this scope + +// checks case typos with libstd::num structs + +fn test_nonzeroi8(_x: NonZeroi8){} +//~^ ERROR: cannot find type `NonZeroi8` in this scope +fn test_nonzeroi16(_x: NonZeroi16){} +//~^ ERROR: cannot find type `NonZeroi16` in this scope +fn test_nonzeroi32(_x: NonZeroi32){} +//~^ ERROR: cannot find type `NonZeroi32` in this scope +fn test_nonzeroi64(_x: NonZeroi64){} +//~^ ERROR: cannot find type `NonZeroi64` in this scope +fn test_nonzeroi128(_x: NonZeroi128){} +//~^ ERROR: cannot find type `NonZeroi128` in this scope +fn test_nonzerou8(_x: NonZerou8){} +//~^ ERROR: cannot find type `NonZerou8` in this scope +fn test_nonzerou16(_x: NonZerou16){} +//~^ ERROR: cannot find type `NonZerou16` in this scope +fn test_nonzerou32(_x: NonZerou32){} +//~^ ERROR: cannot find type `NonZerou32` in this scope +fn test_nonzerou64(_x: NonZerou64){} +//~^ ERROR: cannot find type `NonZerou64` in this scope +fn test_nonzerou128(_x: NonZerou128){} +//~^ ERROR: cannot find type `NonZerou128` in this scope +fn test_nonzerousize(_x: NonzeroUsize){} +//~^ ERROR: cannot find type `NonzeroUsize` in this scope +fn test_wrapping(_x: wrapping){} +//~^ ERROR: cannot find type `wrapping` in this scope + +// checks case typos with libstd::ops structs + +fn test_range(_x: range<()>){} +//~^ ERROR: cannot find type `range` in this scope +fn test_rangefrom(_x: Rangefrom<()>){} +//~^ ERROR: cannot find type `Rangefrom` in this scope +fn test_rangefull(_x: Rangefull<()>){} +//~^ ERROR: cannot find type `Rangefull` in this scope +fn test_rangeinclusive(_x: Rangeinclusive<()>){} +//~^ ERROR: cannot find type `Rangeinclusive` in this scope +fn test_rangeto(_x: Rangeto<()>){} +//~^ ERROR: cannot find type `Rangeto` in this scope +fn test_rangetoinclusive(_x: RangetoInclusive<()>){} +//~^ ERROR: cannot find type `RangetoInclusive` in this scope + +// checks case typos with libstd::panic structs + +fn test_assertunwindsafe(_x: AssertUnwindsafe<()>){} +//~^ ERROR: cannot find type `AssertUnwindsafe` in this scope +fn test_location(_x: location<()>){} +//~^ ERROR: cannot find type `location` in this scope +fn test_panicinfo(_x: Panicinfo<()>){} +//~^ ERROR: cannot find type `Panicinfo` in this scope + +// checks case typos with libstd::path structs + +fn test_ancestors(_x: ancestors){} +//~^ ERROR: cannot find type `ancestors` in this scope +fn test_components(_x: components){} +//~^ ERROR: cannot find type `components` in this scope +fn test_pathbuf(_x: Pathbuf){} +//~^ ERROR: cannot find type `Pathbuf` in this scope +fn test_prefixcomponent(_x: Prefixcomponent){} +//~^ ERROR: cannot find type `Prefixcomponent` in this scope + +// checks case typos with libstd::pin structs + +fn test_pin(_x: pin<()>){} +//~^ ERROR: cannot find type `pin` in this scope + +// checks case typos with libstd::process structs + +fn test_child(_x: child){} +//~^ ERROR: cannot find type `child` in this scope +fn test_childstderr(_x: ChildStdErr){} +//~^ ERROR: cannot find type `ChildStdErr` in this scope +fn test_childstdin(_x: ChildStdIn){} +//~^ ERROR: cannot find type `ChildStdIn` in this scope +fn test_childstdout(_x: ChildStdOut){} +//~^ ERROR: cannot find type `ChildStdOut` in this scope +fn test_command(_x: command){} +//~^ ERROR: cannot find type `command` in this scope +fn test_exitstatus(_x: Exitstatus){} +//~^ ERROR: cannot find type `Exitstatus` in this scope +fn test_output(_x: output){} +//~^ ERROR: cannot find type `output` in this scope +fn test_stdio(_x: StdIo){} +//~^ ERROR: cannot find type `StdIo` in this scope + +// checks case typos with libstd::ptr structs + +fn test_nonnull(_x: Nonnull<()>){} +//~^ ERROR: cannot find type `Nonnull` in this scope + +// checks case typos with libstd::rc structs + +fn test_rc(_x: rc<()>){} +//~^ ERROR: cannot find type `rc` in this scope +fn test_weak(_x: weak<()>){} +//~^ ERROR: cannot find type `weak` in this scope + +// checks case typos with libstd::string structs + +fn test_drain(_x: drain){} +//~^ ERROR: cannot find type `drain` in this scope + +// checks case typos with libstd::str structs + +fn test_charindices(_x: Charindices){} +//~^ ERROR: cannot find type `Charindices` in this scope +fn test_chars(_x: chars){} +//~^ ERROR: cannot find type `chars` in this scope +fn test_encodeutf16(_x: EncodeUTF16){} +//~^ ERROR: cannot find type `EncodeUTF16` in this scope +fn test_matchindices(_x: Matchindices){} +//~^ ERROR: cannot find type `Matchindices` in this scope +fn test_rmatchindices(_x: RmatchIndices){} +//~^ ERROR: cannot find type `RmatchIndices` in this scope +fn test_rmatches(_x: Rmatches){} +//~^ ERROR: cannot find type `Rmatches` in this scope +fn test_rsplit(_x: Rsplit){} +//~^ ERROR: cannot find type `Rsplit` in this scope +fn test_rsplitn(_x: RSplitn){} +//~^ ERROR: cannot find type `RSplitn` in this scope +fn test_rsplitterminator(_x: RsplitTerminator){} +//~^ ERROR: cannot find type `RsplitTerminator` in this scope +fn test_splitasciiwhitespace(_x: SplitASCIIWhitespace){} +//~^ ERROR: cannot find type `SplitASCIIWhitespace` in this scope +fn test_splitn(_x: Splitn){} +//~^ ERROR: cannot find type `Splitn` in this scope +fn test_splitterminator(_x: Splitterminator){} +//~^ ERROR: cannot find type `Splitterminator` in this scope +fn test_splitwhitespace(_x: Splitwhitespace){} +//~^ ERROR: cannot find type `Splitwhitespace` in this scope + +// checks case typos with libstd::sync structs + +fn test_arc(_x: arc<()>){} +//~^ ERROR: cannot find type `arc` in this scope +fn test_barrier(_x: barrier<()>){} +//~^ ERROR: cannot find type `barrier` in this scope +fn test_barrierwaitresult(_x: BarrierwaitResult<()>){} +//~^ ERROR: cannot find type `BarrierwaitResult` in this scope +fn test_condvar(_x: CondVar<()>){} +//~^ ERROR: cannot find type `CondVar` in this scope +fn test_mutex(_x: mutex<()>){} +//~^ ERROR: cannot find type `mutex` in this scope +fn test_mutexguard(_x: Mutexguard<()>){} +//~^ ERROR: cannot find type `Mutexguard` in this scope +fn test_rwlock(_x: RWlock<()>){} +//~^ ERROR: cannot find type `RWlock` in this scope +fn test_rwlockreadguard(_x: RWlockReadGuard<()>){} +//~^ ERROR: cannot find type `RWlockReadGuard` in this scope +fn test_rwlockwriteguard(_x: RWlockWriteGuard<()>){} +//~^ ERROR: cannot find type `RWlockWriteGuard` in this scope +fn test_waittimeoutresult(_x: WaittimeoutResult<()>){} +//~^ ERROR: cannot find type `WaittimeoutResult` in this scope + +// checks case typos with libstd::task structs + +fn test_context(_x: context){} +//~^ ERROR: cannot find type `context` in this scope +fn test_rawwaker(_x: Rawwaker){} +//~^ ERROR: cannot find type `Rawwaker` in this scope +fn test_rawwakervtable(_x: RawwakerVTable){} +//~^ ERROR: cannot find type `RawwakerVTable` in this scope +fn test_waker(_x: waker){} +//~^ ERROR: cannot find type `waker` in this scope + +// checks case typos with libstd::thread structs + +fn test_builder(_x: builder){} +//~^ ERROR: cannot find type `builder` in this scope +fn test_joinhandle(_x: Joinhandle<()>){} +//~^ ERROR: cannot find type `Joinhandle` in this scope +fn test_localkey(_x: Localkey<()>){} +//~^ ERROR: cannot find type `Localkey` in this scope +fn test_thread(_x: thread){} +//~^ ERROR: cannot find type `thread` in this scope +fn test_threadid(_x: ThreadID){} +//~^ ERROR: cannot find type `ThreadID` in this scope + +// checks case typos with libstd::time structs + +fn test_duration(_x: duration){} +//~^ ERROR: cannot find type `duration` in this scope +fn test_instant(_x: instant){} +//~^ ERROR: cannot find type `instant` in this scope +fn test_systemtime(_x: Systemtime){} +//~^ ERROR: cannot find type `Systemtime` in this scope + +fn test_systemtime2(_x: SystemTime){} +//~^ ERROR: cannot find type `SystemTime` in this scope + +struct SystemTome{} +mod st{ + struct SystemTame{} +} + +fn main(){} diff --git a/tests/ui/imports/case-insensitive/libstd.stderr b/tests/ui/imports/case-insensitive/libstd.stderr new file mode 100644 index 0000000000000..633efb784bf56 --- /dev/null +++ b/tests/ui/imports/case-insensitive/libstd.stderr @@ -0,0 +1,1057 @@ +error[E0425]: cannot find type `LayOut` in this scope + --> $DIR/libstd.rs:3:20 + | +LL | fn test_layout(_x: LayOut){} + | ^^^^^^ not found in this scope + +error[E0425]: cannot find type `system` in this scope + --> $DIR/libstd.rs:5:20 + | +LL | fn test_system(_x: system){} + | ^^^^^^ not found in this scope + +error[E0425]: cannot find type `Typeid` in this scope + --> $DIR/libstd.rs:10:20 + | +LL | fn test_typeid(_x: Typeid){} + | ^^^^^^ not found in this scope + +error[E0425]: cannot find type `Escapedefault` in this scope + --> $DIR/libstd.rs:15:27 + | +LL | fn test_escapedefault(_x: Escapedefault){} + | ^^^^^^^^^^^^^ not found in this scope + +error[E0425]: cannot find type `cell` in this scope + --> $DIR/libstd.rs:20:18 + | +LL | fn test_cell(_x: cell<()>){} + | ^^^^ not found in this scope + +error[E0425]: cannot find type `DecodeUTF16` in this scope + --> $DIR/libstd.rs:25:25 + | +LL | fn test_decodeutf16(_x: DecodeUTF16<()>){} + | ^^^^^^^^^^^ not found in this scope + +error[E0425]: cannot find type `Escapeunicode` in this scope + --> $DIR/libstd.rs:28:27 + | +LL | fn test_escapeunicode(_x: Escapeunicode){} + | ^^^^^^^^^^^^^ not found in this scope + +error[E0425]: cannot find type `Tolowercase` in this scope + --> $DIR/libstd.rs:31:25 + | +LL | fn test_tolowercase(_x: Tolowercase){} + | ^^^^^^^^^^^ not found in this scope + +error[E0425]: cannot find type `Touppercase` in this scope + --> $DIR/libstd.rs:34:25 + | +LL | fn test_touppercase(_x: Touppercase){} + | ^^^^^^^^^^^ not found in this scope + +error[E0425]: cannot find type `reverse` in this scope + --> $DIR/libstd.rs:39:21 + | +LL | fn test_reverse(_x: reverse<()>){} + | ^^^^^^^ not found in this scope + +error[E0425]: cannot find type `BtreeMap` in this scope + --> $DIR/libstd.rs:44:22 + | +LL | fn test_btreemap(_x: BtreeMap<(), ()>){} + | ^^^^^^^^ not found in this scope + +error[E0425]: cannot find type `BtreeSet` in this scope + --> $DIR/libstd.rs:46:22 + | +LL | fn test_btreeset(_x: BtreeSet<()>){} + | ^^^^^^^^ not found in this scope + +error[E0425]: cannot find type `Binaryheap` in this scope + --> $DIR/libstd.rs:48:24 + | +LL | fn test_binaryheap(_x: Binaryheap<()>){} + | ^^^^^^^^^^ not found in this scope + +error[E0425]: cannot find type `Hashmap` in this scope + --> $DIR/libstd.rs:50:21 + | +LL | fn test_hashmap(_x: Hashmap){} + | ^^^^^^^ not found in this scope + +error[E0425]: cannot find type `Hashset` in this scope + --> $DIR/libstd.rs:52:21 + | +LL | fn test_hashset(_x: Hashset<()>){} + | ^^^^^^^ not found in this scope + +error[E0425]: cannot find type `Linkedlist` in this scope + --> $DIR/libstd.rs:54:24 + | +LL | fn test_linkedlist(_x: Linkedlist<()>){} + | ^^^^^^^^^^ not found in this scope + +error[E0425]: cannot find type `Vecdeque` in this scope + --> $DIR/libstd.rs:56:22 + | +LL | fn test_vecdeque(_x: Vecdeque<()>){} + | ^^^^^^^^ not found in this scope + +error[E0425]: cannot find type `args` in this scope + --> $DIR/libstd.rs:61:18 + | +LL | fn test_args(_x: args){} + | ^^^^ not found in this scope + +error[E0425]: cannot find type `Argsos` in this scope + --> $DIR/libstd.rs:63:20 + | +LL | fn test_argsos(_x: Argsos){} + | ^^^^^^ not found in this scope + +error[E0425]: cannot find type `Splitpaths` in this scope + --> $DIR/libstd.rs:65:24 + | +LL | fn test_splitpaths(_x: Splitpaths<'_>){} + | ^^^^^^^^^^ not found in this scope + +error[E0425]: cannot find type `vars` in this scope + --> $DIR/libstd.rs:67:18 + | +LL | fn test_vars(_x: vars){} + | ^^^^ not found in this scope + +error[E0425]: cannot find type `Varsos` in this scope + --> $DIR/libstd.rs:69:20 + | +LL | fn test_varsos(_x: Varsos){} + | ^^^^^^ not found in this scope + +error[E0425]: cannot find type `cStr` in this scope + --> $DIR/libstd.rs:74:18 + | +LL | fn test_cstr(_x: cStr){} + | ^^^^ not found in this scope + +error[E0425]: cannot find type `Osstr` in this scope + --> $DIR/libstd.rs:76:19 + | +LL | fn test_osstr(_x: Osstr){} + | ^^^^^ not found in this scope + +error[E0425]: cannot find type `Osstring` in this scope + --> $DIR/libstd.rs:78:22 + | +LL | fn test_osstring(_x: Osstring){} + | ^^^^^^^^ not found in this scope + +error[E0425]: cannot find type `Debuglist` in this scope + --> $DIR/libstd.rs:83:23 + | +LL | fn test_debuglist(_x: Debuglist){} + | ^^^^^^^^^ not found in this scope + +error[E0425]: cannot find type `Debugmap` in this scope + --> $DIR/libstd.rs:85:22 + | +LL | fn test_debugmap(_x: Debugmap){} + | ^^^^^^^^ not found in this scope + +error[E0425]: cannot find type `Debugset` in this scope + --> $DIR/libstd.rs:87:22 + | +LL | fn test_debugset(_x: Debugset){} + | ^^^^^^^^ not found in this scope + +error[E0425]: cannot find type `Debugstruct` in this scope + --> $DIR/libstd.rs:89:25 + | +LL | fn test_debugstruct(_x: Debugstruct){} + | ^^^^^^^^^^^ not found in this scope + +error[E0425]: cannot find type `Debugtuple` in this scope + --> $DIR/libstd.rs:91:24 + | +LL | fn test_debugtuple(_x: Debugtuple){} + | ^^^^^^^^^^ not found in this scope + +error[E0425]: cannot find type `formatter` in this scope + --> $DIR/libstd.rs:93:23 + | +LL | fn test_fmter(mut _x: formatter){} + | ^^^^^^^^^ not found in this scope + +error[E0425]: cannot find type `Dirbuilder` in this scope + --> $DIR/libstd.rs:98:24 + | +LL | fn test_dirbuilder(_x: Dirbuilder){} + | ^^^^^^^^^^ not found in this scope + +error[E0425]: cannot find type `Direntry` in this scope + --> $DIR/libstd.rs:100:22 + | +LL | fn test_direntry(_x: Direntry){} + | ^^^^^^^^ not found in this scope + +error[E0425]: cannot find type `Filetype` in this scope + --> $DIR/libstd.rs:102:22 + | +LL | fn test_filetype(_x: Filetype){} + | ^^^^^^^^ not found in this scope + +error[E0425]: cannot find type `MetaData` in this scope + --> $DIR/libstd.rs:104:22 + | +LL | fn test_metadata(_x: MetaData){} + | ^^^^^^^^ not found in this scope + +error[E0425]: cannot find type `Openoptions` in this scope + --> $DIR/libstd.rs:106:25 + | +LL | fn test_openoptions(_x: Openoptions){} + | ^^^^^^^^^^^ not found in this scope + +error[E0425]: cannot find type `permissions` in this scope + --> $DIR/libstd.rs:108:25 + | +LL | fn test_permissions(_x: permissions){} + | ^^^^^^^^^^^ not found in this scope + +error[E0425]: cannot find type `Readdir` in this scope + --> $DIR/libstd.rs:110:21 + | +LL | fn test_readdir(_x: Readdir){} + | ^^^^^^^ not found in this scope + +error[E0425]: cannot find type `BuildhasherDefault` in this scope + --> $DIR/libstd.rs:115:32 + | +LL | fn test_buildhasherdefault(_x: BuildhasherDefault){} + | ^^^^^^^^^^^^^^^^^^ not found in this scope + +error[E0425]: cannot find type `Bufreader` in this scope + --> $DIR/libstd.rs:120:23 + | +LL | fn test_bufreader(_x: Bufreader<()>){} + | ^^^^^^^^^ not found in this scope + +error[E0425]: cannot find type `Bufwriter` in this scope + --> $DIR/libstd.rs:122:23 + | +LL | fn test_bufwriter(_x: Bufwriter<()>){} + | ^^^^^^^^^ not found in this scope + +error[E0425]: cannot find type `bytes` in this scope + --> $DIR/libstd.rs:124:19 + | +LL | fn test_bytes(_x: bytes<()>){} + | ^^^^^ not found in this scope + +error[E0425]: cannot find type `chain` in this scope + --> $DIR/libstd.rs:126:19 + | +LL | fn test_chain(_x: chain<(), ()>){} + | ^^^^^ not found in this scope + +error[E0425]: cannot find type `cursor` in this scope + --> $DIR/libstd.rs:128:20 + | +LL | fn test_cursor(_x: cursor<()>){} + | ^^^^^^ not found in this scope + +error[E0425]: cannot find type `empty` in this scope + --> $DIR/libstd.rs:130:19 + | +LL | fn test_empty(_x: empty){} + | ^^^^^ not found in this scope + +error[E0425]: cannot find type `Ioslice` in this scope + --> $DIR/libstd.rs:132:21 + | +LL | fn test_ioslice(_x: Ioslice){} + | ^^^^^^^ not found in this scope + +error[E0425]: cannot find type `IosliceMut` in this scope + --> $DIR/libstd.rs:134:24 + | +LL | fn test_ioslicemut(_x: IosliceMut){} + | ^^^^^^^^^^ not found in this scope + +error[E0425]: cannot find type `Linewriter` in this scope + --> $DIR/libstd.rs:136:24 + | +LL | fn test_linewriter(_x: Linewriter<()>){} + | ^^^^^^^^^^ not found in this scope + +error[E0425]: cannot find type `lines` in this scope + --> $DIR/libstd.rs:138:19 + | +LL | fn test_lines(_x: lines<()>){} + | ^^^^^ not found in this scope + +error[E0425]: cannot find type `repeat` in this scope + --> $DIR/libstd.rs:140:20 + | +LL | fn test_repeat(_x: repeat){} + | ^^^^^^ not found in this scope + +error[E0425]: cannot find type `sink` in this scope + --> $DIR/libstd.rs:142:18 + | +LL | fn test_sink(_x: sink){} + | ^^^^ not found in this scope + +error[E0425]: cannot find type `split` in this scope + --> $DIR/libstd.rs:144:19 + | +LL | fn test_split(_x: split<()>){} + | ^^^^^ not found in this scope + +error[E0425]: cannot find type `StdErr` in this scope + --> $DIR/libstd.rs:146:20 + | +LL | fn test_stderr(_x: StdErr){} + | ^^^^^^ not found in this scope + +error[E0425]: cannot find type `StdErrLock` in this scope + --> $DIR/libstd.rs:148:24 + | +LL | fn test_stderrlock(_x: StdErrLock){} + | ^^^^^^^^^^ not found in this scope + +error[E0425]: cannot find type `StdIn` in this scope + --> $DIR/libstd.rs:150:19 + | +LL | fn test_stdin(_x: StdIn){} + | ^^^^^ not found in this scope + +error[E0425]: cannot find type `StdInLock` in this scope + --> $DIR/libstd.rs:152:23 + | +LL | fn test_stdinlock(_x: StdInLock){} + | ^^^^^^^^^ not found in this scope + +error[E0425]: cannot find type `StdOut` in this scope + --> $DIR/libstd.rs:154:20 + | +LL | fn test_stdout(_x: StdOut){} + | ^^^^^^ not found in this scope + +error[E0425]: cannot find type `StdOutLock` in this scope + --> $DIR/libstd.rs:156:24 + | +LL | fn test_stdoutlock(_x: StdOutLock){} + | ^^^^^^^^^^ not found in this scope + +error[E0425]: cannot find type `take` in this scope + --> $DIR/libstd.rs:158:18 + | +LL | fn test_take(_x: take){} + | ^^^^ not found in this scope + +error[E0425]: cannot find type `cloned` in this scope + --> $DIR/libstd.rs:163:20 + | +LL | fn test_cloned(_x: cloned<(), ()>){} + | ^^^^^^ + | + --> $SRC_DIR/core/src/clone.rs:LL:COL + | + = note: similarly named trait `Clone` defined here +help: a trait with a similar name exists + | +LL - fn test_cloned(_x: cloned<(), ()>){} +LL + fn test_cloned(_x: Clone<(), ()>){} + | + +error[E0425]: cannot find type `copied` in this scope + --> $DIR/libstd.rs:165:20 + | +LL | fn test_copied(_x: copied<(), ()>){} + | ^^^^^^ not found in this scope + +error[E0425]: cannot find type `cycle` in this scope + --> $DIR/libstd.rs:167:19 + | +LL | fn test_cycle(_x: cycle<(), ()>){} + | ^^^^^ not found in this scope + +error[E0425]: cannot find type `enumerate` in this scope + --> $DIR/libstd.rs:169:23 + | +LL | fn test_enumerate(_x: enumerate<(), ()>){} + | ^^^^^^^^^ not found in this scope + +error[E0425]: cannot find type `filter` in this scope + --> $DIR/libstd.rs:171:20 + | +LL | fn test_filter(_x: filter<(), ()>){} + | ^^^^^^ not found in this scope + +error[E0425]: cannot find type `Filtermap` in this scope + --> $DIR/libstd.rs:173:23 + | +LL | fn test_filtermap(_x: Filtermap<(), ()>){} + | ^^^^^^^^^ not found in this scope + +error[E0425]: cannot find type `flatten` in this scope + --> $DIR/libstd.rs:175:21 + | +LL | fn test_flatten(_x: flatten<()>){} + | ^^^^^^^ not found in this scope + +error[E0425]: cannot find type `Fromfn` in this scope + --> $DIR/libstd.rs:177:20 + | +LL | fn test_fromfn(_x: Fromfn<()>){} + | ^^^^^^ + | + --> $SRC_DIR/core/src/convert/mod.rs:LL:COL + | + = note: similarly named trait `From` defined here +help: a trait with a similar name exists + | +LL - fn test_fromfn(_x: Fromfn<()>){} +LL + fn test_fromfn(_x: From<()>){} + | + +error[E0425]: cannot find type `fuse` in this scope + --> $DIR/libstd.rs:179:18 + | +LL | fn test_fuse(_x: fuse<()>){} + | ^^^^ not found in this scope + +error[E0425]: cannot find type `inspect` in this scope + --> $DIR/libstd.rs:181:21 + | +LL | fn test_inspect(_x: inspect<(), ()>){} + | ^^^^^^^ not found in this scope + +error[E0425]: cannot find type `map` in this scope + --> $DIR/libstd.rs:183:17 + | +LL | fn test_map(_x: map<(), ()>){} + | ^^^ not found in this scope + +error[E0425]: cannot find type `once` in this scope + --> $DIR/libstd.rs:185:18 + | +LL | fn test_once(_x: once<()>){} + | ^^^^ not found in this scope + +error[E0425]: cannot find type `Oncewith` in this scope + --> $DIR/libstd.rs:187:22 + | +LL | fn test_oncewith(_x: Oncewith<()>){} + | ^^^^^^^^ not found in this scope + +error[E0425]: cannot find type `peekable` in this scope + --> $DIR/libstd.rs:189:22 + | +LL | fn test_peekable(_x: peekable<()>){} + | ^^^^^^^^ not found in this scope + +error[E0425]: cannot find type `Repeatwith` in this scope + --> $DIR/libstd.rs:191:24 + | +LL | fn test_repeatwith(_x: Repeatwith<()>){} + | ^^^^^^^^^^ not found in this scope + +error[E0425]: cannot find type `rev` in this scope + --> $DIR/libstd.rs:193:17 + | +LL | fn test_rev(_x: rev<()>){} + | ^^^ not found in this scope + +error[E0425]: cannot find type `scan` in this scope + --> $DIR/libstd.rs:195:18 + | +LL | fn test_scan(_x: scan<(), (), ()>){} + | ^^^^ not found in this scope + +error[E0425]: cannot find type `skip` in this scope + --> $DIR/libstd.rs:197:18 + | +LL | fn test_skip(_x: skip<()>){} + | ^^^^ not found in this scope + +error[E0425]: cannot find type `Skipwhile` in this scope + --> $DIR/libstd.rs:199:23 + | +LL | fn test_skipwhile(_x: Skipwhile<(), ()>){} + | ^^^^^^^^^ not found in this scope + +error[E0425]: cannot find type `Stepby` in this scope + --> $DIR/libstd.rs:201:20 + | +LL | fn test_stepby(_x: Stepby<()>){} + | ^^^^^^ not found in this scope + +error[E0425]: cannot find type `successors` in this scope + --> $DIR/libstd.rs:203:24 + | +LL | fn test_successors(_x: successors<()>){} + | ^^^^^^^^^^ not found in this scope + +error[E0425]: cannot find type `Takewhile` in this scope + --> $DIR/libstd.rs:205:23 + | +LL | fn test_takewhile(_x: Takewhile<(), ()>){} + | ^^^^^^^^^ not found in this scope + +error[E0425]: cannot find type `zip` in this scope + --> $DIR/libstd.rs:207:17 + | +LL | fn test_zip(_x: zip<(), ()>){} + | ^^^ not found in this scope + +error[E0425]: cannot find type `Phantomdata` in this scope + --> $DIR/libstd.rs:212:25 + | +LL | fn test_phantomdata(_x: Phantomdata){} + | ^^^^^^^^^^^ not found in this scope + +error[E0425]: cannot find type `Phantompinned` in this scope + --> $DIR/libstd.rs:214:27 + | +LL | fn test_phantompinned(_x: Phantompinned){} + | ^^^^^^^^^^^^^ not found in this scope + +error[E0425]: cannot find type `discriminant` in this scope + --> $DIR/libstd.rs:219:26 + | +LL | fn test_discriminant(_x: discriminant<()>){} + | ^^^^^^^^^^^^ not found in this scope + +error[E0425]: cannot find type `Manuallydrop` in this scope + --> $DIR/libstd.rs:221:26 + | +LL | fn test_manuallydrop(_x: Manuallydrop<()>){} + | ^^^^^^^^^^^^ not found in this scope + +error[E0425]: cannot find type `incoming` in this scope + --> $DIR/libstd.rs:226:22 + | +LL | fn test_incoming(_x: incoming){} + | ^^^^^^^^ not found in this scope + +error[E0425]: cannot find type `IPv4Addr` in this scope + --> $DIR/libstd.rs:228:22 + | +LL | fn test_ipv4addr(_x: IPv4Addr){} + | ^^^^^^^^ not found in this scope + +error[E0425]: cannot find type `IPv6Addr` in this scope + --> $DIR/libstd.rs:230:22 + | +LL | fn test_ipv6addr(_x: IPv6Addr){} + | ^^^^^^^^ not found in this scope + +error[E0425]: cannot find type `SocketAddrv4` in this scope + --> $DIR/libstd.rs:232:26 + | +LL | fn test_socketaddrv4(_x: SocketAddrv4){} + | ^^^^^^^^^^^^ not found in this scope + +error[E0425]: cannot find type `SocketAddrv6` in this scope + --> $DIR/libstd.rs:234:26 + | +LL | fn test_socketaddrv6(_x: SocketAddrv6){} + | ^^^^^^^^^^^^ not found in this scope + +error[E0425]: cannot find type `TCPListener` in this scope + --> $DIR/libstd.rs:236:25 + | +LL | fn test_tcplistener(_x: TCPListener){} + | ^^^^^^^^^^^ not found in this scope + +error[E0425]: cannot find type `TCPStream` in this scope + --> $DIR/libstd.rs:238:23 + | +LL | fn test_tcpstream(_x: TCPStream){} + | ^^^^^^^^^ not found in this scope + +error[E0425]: cannot find type `UDPSocket` in this scope + --> $DIR/libstd.rs:240:23 + | +LL | fn test_udpsocket(_x: UDPSocket){} + | ^^^^^^^^^ not found in this scope + +error[E0425]: cannot find type `NonZeroi8` in this scope + --> $DIR/libstd.rs:245:23 + | +LL | fn test_nonzeroi8(_x: NonZeroi8){} + | ^^^^^^^^^ not found in this scope + +error[E0425]: cannot find type `NonZeroi16` in this scope + --> $DIR/libstd.rs:247:24 + | +LL | fn test_nonzeroi16(_x: NonZeroi16){} + | ^^^^^^^^^^ not found in this scope + +error[E0425]: cannot find type `NonZeroi32` in this scope + --> $DIR/libstd.rs:249:24 + | +LL | fn test_nonzeroi32(_x: NonZeroi32){} + | ^^^^^^^^^^ not found in this scope + +error[E0425]: cannot find type `NonZeroi64` in this scope + --> $DIR/libstd.rs:251:24 + | +LL | fn test_nonzeroi64(_x: NonZeroi64){} + | ^^^^^^^^^^ not found in this scope + +error[E0425]: cannot find type `NonZeroi128` in this scope + --> $DIR/libstd.rs:253:25 + | +LL | fn test_nonzeroi128(_x: NonZeroi128){} + | ^^^^^^^^^^^ not found in this scope + +error[E0425]: cannot find type `NonZerou8` in this scope + --> $DIR/libstd.rs:255:23 + | +LL | fn test_nonzerou8(_x: NonZerou8){} + | ^^^^^^^^^ not found in this scope + +error[E0425]: cannot find type `NonZerou16` in this scope + --> $DIR/libstd.rs:257:24 + | +LL | fn test_nonzerou16(_x: NonZerou16){} + | ^^^^^^^^^^ not found in this scope + +error[E0425]: cannot find type `NonZerou32` in this scope + --> $DIR/libstd.rs:259:24 + | +LL | fn test_nonzerou32(_x: NonZerou32){} + | ^^^^^^^^^^ not found in this scope + +error[E0425]: cannot find type `NonZerou64` in this scope + --> $DIR/libstd.rs:261:24 + | +LL | fn test_nonzerou64(_x: NonZerou64){} + | ^^^^^^^^^^ not found in this scope + +error[E0425]: cannot find type `NonZerou128` in this scope + --> $DIR/libstd.rs:263:25 + | +LL | fn test_nonzerou128(_x: NonZerou128){} + | ^^^^^^^^^^^ not found in this scope + +error[E0425]: cannot find type `NonzeroUsize` in this scope + --> $DIR/libstd.rs:265:26 + | +LL | fn test_nonzerousize(_x: NonzeroUsize){} + | ^^^^^^^^^^^^ not found in this scope + +error[E0425]: cannot find type `wrapping` in this scope + --> $DIR/libstd.rs:267:22 + | +LL | fn test_wrapping(_x: wrapping){} + | ^^^^^^^^ not found in this scope + +error[E0425]: cannot find type `range` in this scope + --> $DIR/libstd.rs:272:19 + | +LL | fn test_range(_x: range<()>){} + | ^^^^^ not found in this scope + +error[E0425]: cannot find type `Rangefrom` in this scope + --> $DIR/libstd.rs:274:23 + | +LL | fn test_rangefrom(_x: Rangefrom<()>){} + | ^^^^^^^^^ not found in this scope + +error[E0425]: cannot find type `Rangefull` in this scope + --> $DIR/libstd.rs:276:23 + | +LL | fn test_rangefull(_x: Rangefull<()>){} + | ^^^^^^^^^ not found in this scope + +error[E0425]: cannot find type `Rangeinclusive` in this scope + --> $DIR/libstd.rs:278:28 + | +LL | fn test_rangeinclusive(_x: Rangeinclusive<()>){} + | ^^^^^^^^^^^^^^ not found in this scope + +error[E0425]: cannot find type `Rangeto` in this scope + --> $DIR/libstd.rs:280:21 + | +LL | fn test_rangeto(_x: Rangeto<()>){} + | ^^^^^^^ not found in this scope + +error[E0425]: cannot find type `RangetoInclusive` in this scope + --> $DIR/libstd.rs:282:30 + | +LL | fn test_rangetoinclusive(_x: RangetoInclusive<()>){} + | ^^^^^^^^^^^^^^^^ not found in this scope + +error[E0425]: cannot find type `AssertUnwindsafe` in this scope + --> $DIR/libstd.rs:287:30 + | +LL | fn test_assertunwindsafe(_x: AssertUnwindsafe<()>){} + | ^^^^^^^^^^^^^^^^ not found in this scope + +error[E0425]: cannot find type `location` in this scope + --> $DIR/libstd.rs:289:22 + | +LL | fn test_location(_x: location<()>){} + | ^^^^^^^^ not found in this scope + +error[E0425]: cannot find type `Panicinfo` in this scope + --> $DIR/libstd.rs:291:23 + | +LL | fn test_panicinfo(_x: Panicinfo<()>){} + | ^^^^^^^^^ not found in this scope + +error[E0425]: cannot find type `ancestors` in this scope + --> $DIR/libstd.rs:296:23 + | +LL | fn test_ancestors(_x: ancestors){} + | ^^^^^^^^^ not found in this scope + +error[E0425]: cannot find type `components` in this scope + --> $DIR/libstd.rs:298:24 + | +LL | fn test_components(_x: components){} + | ^^^^^^^^^^ not found in this scope + +error[E0425]: cannot find type `Pathbuf` in this scope + --> $DIR/libstd.rs:300:21 + | +LL | fn test_pathbuf(_x: Pathbuf){} + | ^^^^^^^ not found in this scope + +error[E0425]: cannot find type `Prefixcomponent` in this scope + --> $DIR/libstd.rs:302:29 + | +LL | fn test_prefixcomponent(_x: Prefixcomponent){} + | ^^^^^^^^^^^^^^^ not found in this scope + +error[E0425]: cannot find type `pin` in this scope + --> $DIR/libstd.rs:307:17 + | +LL | fn test_pin(_x: pin<()>){} + | ^^^ not found in this scope + +error[E0425]: cannot find type `child` in this scope + --> $DIR/libstd.rs:312:19 + | +LL | fn test_child(_x: child){} + | ^^^^^ not found in this scope + +error[E0425]: cannot find type `ChildStdErr` in this scope + --> $DIR/libstd.rs:314:25 + | +LL | fn test_childstderr(_x: ChildStdErr){} + | ^^^^^^^^^^^ not found in this scope + +error[E0425]: cannot find type `ChildStdIn` in this scope + --> $DIR/libstd.rs:316:24 + | +LL | fn test_childstdin(_x: ChildStdIn){} + | ^^^^^^^^^^ not found in this scope + +error[E0425]: cannot find type `ChildStdOut` in this scope + --> $DIR/libstd.rs:318:25 + | +LL | fn test_childstdout(_x: ChildStdOut){} + | ^^^^^^^^^^^ not found in this scope + +error[E0425]: cannot find type `command` in this scope + --> $DIR/libstd.rs:320:21 + | +LL | fn test_command(_x: command){} + | ^^^^^^^ not found in this scope + +error[E0425]: cannot find type `Exitstatus` in this scope + --> $DIR/libstd.rs:322:24 + | +LL | fn test_exitstatus(_x: Exitstatus){} + | ^^^^^^^^^^ not found in this scope + +error[E0425]: cannot find type `output` in this scope + --> $DIR/libstd.rs:324:20 + | +LL | fn test_output(_x: output){} + | ^^^^^^ not found in this scope + +error[E0425]: cannot find type `StdIo` in this scope + --> $DIR/libstd.rs:326:19 + | +LL | fn test_stdio(_x: StdIo){} + | ^^^^^ not found in this scope + +error[E0425]: cannot find type `Nonnull` in this scope + --> $DIR/libstd.rs:331:21 + | +LL | fn test_nonnull(_x: Nonnull<()>){} + | ^^^^^^^ not found in this scope + +error[E0425]: cannot find type `rc` in this scope + --> $DIR/libstd.rs:336:16 + | +LL | fn test_rc(_x: rc<()>){} + | ^^ not found in this scope + +error[E0425]: cannot find type `weak` in this scope + --> $DIR/libstd.rs:338:18 + | +LL | fn test_weak(_x: weak<()>){} + | ^^^^ not found in this scope + +error[E0425]: cannot find type `drain` in this scope + --> $DIR/libstd.rs:343:19 + | +LL | fn test_drain(_x: drain){} + | ^^^^^ not found in this scope + +error[E0425]: cannot find type `Charindices` in this scope + --> $DIR/libstd.rs:348:25 + | +LL | fn test_charindices(_x: Charindices){} + | ^^^^^^^^^^^ not found in this scope + +error[E0425]: cannot find type `chars` in this scope + --> $DIR/libstd.rs:350:19 + | +LL | fn test_chars(_x: chars){} + | ^^^^^ + | +help: a builtin type with a similar name exists + | +LL - fn test_chars(_x: chars){} +LL + fn test_chars(_x: char){} + | + +error[E0425]: cannot find type `EncodeUTF16` in this scope + --> $DIR/libstd.rs:352:25 + | +LL | fn test_encodeutf16(_x: EncodeUTF16){} + | ^^^^^^^^^^^ not found in this scope + +error[E0425]: cannot find type `Matchindices` in this scope + --> $DIR/libstd.rs:354:26 + | +LL | fn test_matchindices(_x: Matchindices){} + | ^^^^^^^^^^^^ not found in this scope + +error[E0425]: cannot find type `RmatchIndices` in this scope + --> $DIR/libstd.rs:356:27 + | +LL | fn test_rmatchindices(_x: RmatchIndices){} + | ^^^^^^^^^^^^^ not found in this scope + +error[E0425]: cannot find type `Rmatches` in this scope + --> $DIR/libstd.rs:358:22 + | +LL | fn test_rmatches(_x: Rmatches){} + | ^^^^^^^^ not found in this scope + +error[E0425]: cannot find type `Rsplit` in this scope + --> $DIR/libstd.rs:360:20 + | +LL | fn test_rsplit(_x: Rsplit){} + | ^^^^^^ not found in this scope + +error[E0425]: cannot find type `RSplitn` in this scope + --> $DIR/libstd.rs:362:21 + | +LL | fn test_rsplitn(_x: RSplitn){} + | ^^^^^^^ not found in this scope + +error[E0425]: cannot find type `RsplitTerminator` in this scope + --> $DIR/libstd.rs:364:30 + | +LL | fn test_rsplitterminator(_x: RsplitTerminator){} + | ^^^^^^^^^^^^^^^^ not found in this scope + +error[E0425]: cannot find type `SplitASCIIWhitespace` in this scope + --> $DIR/libstd.rs:366:34 + | +LL | fn test_splitasciiwhitespace(_x: SplitASCIIWhitespace){} + | ^^^^^^^^^^^^^^^^^^^^ not found in this scope + +error[E0425]: cannot find type `Splitn` in this scope + --> $DIR/libstd.rs:368:20 + | +LL | fn test_splitn(_x: Splitn){} + | ^^^^^^ not found in this scope + +error[E0425]: cannot find type `Splitterminator` in this scope + --> $DIR/libstd.rs:370:29 + | +LL | fn test_splitterminator(_x: Splitterminator){} + | ^^^^^^^^^^^^^^^ not found in this scope + +error[E0425]: cannot find type `Splitwhitespace` in this scope + --> $DIR/libstd.rs:372:29 + | +LL | fn test_splitwhitespace(_x: Splitwhitespace){} + | ^^^^^^^^^^^^^^^ not found in this scope + +error[E0425]: cannot find type `arc` in this scope + --> $DIR/libstd.rs:377:17 + | +LL | fn test_arc(_x: arc<()>){} + | ^^^ not found in this scope + +error[E0425]: cannot find type `barrier` in this scope + --> $DIR/libstd.rs:379:21 + | +LL | fn test_barrier(_x: barrier<()>){} + | ^^^^^^^ not found in this scope + +error[E0425]: cannot find type `BarrierwaitResult` in this scope + --> $DIR/libstd.rs:381:31 + | +LL | fn test_barrierwaitresult(_x: BarrierwaitResult<()>){} + | ^^^^^^^^^^^^^^^^^ not found in this scope + +error[E0425]: cannot find type `CondVar` in this scope + --> $DIR/libstd.rs:383:21 + | +LL | fn test_condvar(_x: CondVar<()>){} + | ^^^^^^^ not found in this scope + +error[E0425]: cannot find type `mutex` in this scope + --> $DIR/libstd.rs:385:19 + | +LL | fn test_mutex(_x: mutex<()>){} + | ^^^^^ not found in this scope + +error[E0425]: cannot find type `Mutexguard` in this scope + --> $DIR/libstd.rs:387:24 + | +LL | fn test_mutexguard(_x: Mutexguard<()>){} + | ^^^^^^^^^^ not found in this scope + +error[E0425]: cannot find type `RWlock` in this scope + --> $DIR/libstd.rs:389:20 + | +LL | fn test_rwlock(_x: RWlock<()>){} + | ^^^^^^ not found in this scope + +error[E0425]: cannot find type `RWlockReadGuard` in this scope + --> $DIR/libstd.rs:391:29 + | +LL | fn test_rwlockreadguard(_x: RWlockReadGuard<()>){} + | ^^^^^^^^^^^^^^^ not found in this scope + +error[E0425]: cannot find type `RWlockWriteGuard` in this scope + --> $DIR/libstd.rs:393:30 + | +LL | fn test_rwlockwriteguard(_x: RWlockWriteGuard<()>){} + | ^^^^^^^^^^^^^^^^ not found in this scope + +error[E0425]: cannot find type `WaittimeoutResult` in this scope + --> $DIR/libstd.rs:395:31 + | +LL | fn test_waittimeoutresult(_x: WaittimeoutResult<()>){} + | ^^^^^^^^^^^^^^^^^ not found in this scope + +error[E0425]: cannot find type `context` in this scope + --> $DIR/libstd.rs:400:21 + | +LL | fn test_context(_x: context){} + | ^^^^^^^ not found in this scope + +error[E0425]: cannot find type `Rawwaker` in this scope + --> $DIR/libstd.rs:402:22 + | +LL | fn test_rawwaker(_x: Rawwaker){} + | ^^^^^^^^ not found in this scope + +error[E0425]: cannot find type `RawwakerVTable` in this scope + --> $DIR/libstd.rs:404:28 + | +LL | fn test_rawwakervtable(_x: RawwakerVTable){} + | ^^^^^^^^^^^^^^ not found in this scope + +error[E0425]: cannot find type `waker` in this scope + --> $DIR/libstd.rs:406:19 + | +LL | fn test_waker(_x: waker){} + | ^^^^^ not found in this scope + +error[E0425]: cannot find type `builder` in this scope + --> $DIR/libstd.rs:411:21 + | +LL | fn test_builder(_x: builder){} + | ^^^^^^^ not found in this scope + +error[E0425]: cannot find type `Joinhandle` in this scope + --> $DIR/libstd.rs:413:24 + | +LL | fn test_joinhandle(_x: Joinhandle<()>){} + | ^^^^^^^^^^ not found in this scope + +error[E0425]: cannot find type `Localkey` in this scope + --> $DIR/libstd.rs:415:22 + | +LL | fn test_localkey(_x: Localkey<()>){} + | ^^^^^^^^ not found in this scope + +error[E0425]: cannot find type `thread` in this scope + --> $DIR/libstd.rs:417:20 + | +LL | fn test_thread(_x: thread){} + | ^^^^^^ not found in this scope + +error[E0425]: cannot find type `ThreadID` in this scope + --> $DIR/libstd.rs:419:22 + | +LL | fn test_threadid(_x: ThreadID){} + | ^^^^^^^^ not found in this scope + +error[E0425]: cannot find type `duration` in this scope + --> $DIR/libstd.rs:424:22 + | +LL | fn test_duration(_x: duration){} + | ^^^^^^^^ not found in this scope + +error[E0425]: cannot find type `instant` in this scope + --> $DIR/libstd.rs:426:21 + | +LL | fn test_instant(_x: instant){} + | ^^^^^^^ not found in this scope + +error[E0425]: cannot find type `Systemtime` in this scope + --> $DIR/libstd.rs:428:24 + | +LL | fn test_systemtime(_x: Systemtime){} + | ^^^^^^^^^^ +... +LL | struct SystemTome{} + | ----------------- similarly named struct `SystemTome` defined here + | +help: a struct with a similar name exists + | +LL - fn test_systemtime(_x: Systemtime){} +LL + fn test_systemtime(_x: SystemTome){} + | + +error[E0425]: cannot find type `SystemTime` in this scope + --> $DIR/libstd.rs:431:25 + | +LL | fn test_systemtime2(_x: SystemTime){} + | ^^^^^^^^^^ +... +LL | struct SystemTome{} + | ----------------- similarly named struct `SystemTome` defined here + | +help: a struct with a similar name exists + | +LL - fn test_systemtime2(_x: SystemTime){} +LL + fn test_systemtime2(_x: SystemTome){} + | +help: consider importing this struct + | +LL + use std::time::SystemTime; + | + +error: aborting due to 168 previous errors + +For more information about this error, try `rustc --explain E0425`. From 082a2ab33b2e80bacc549e676bdcd647561ab0b9 Mon Sep 17 00:00:00 2001 From: GTimothy <22472919+GTimothy@users.noreply.github.com> Date: Wed, 6 May 2026 12:14:06 +0200 Subject: [PATCH 02/12] suggest imports with different casing adds a is_exact_match field to ImportSuggestion use is_exact_match field to customize help message suggest imports with different casing only suggest modules if the following segment matches something in scope of the suggestion rebase: fix compilation error after rebase fix: use error code const directly --- .../rustc_resolve/src/diagnostics/impls.rs | 77 ++++++++++++--- .../rustc_resolve/src/late/diagnostics.rs | 98 +++++++++++++++++-- 2 files changed, 155 insertions(+), 20 deletions(-) diff --git a/compiler/rustc_resolve/src/diagnostics/impls.rs b/compiler/rustc_resolve/src/diagnostics/impls.rs index 9fa762c87ef3e..9319c1fd2e726 100644 --- a/compiler/rustc_resolve/src/diagnostics/impls.rs +++ b/compiler/rustc_resolve/src/diagnostics/impls.rs @@ -122,6 +122,7 @@ pub(crate) struct ImportSuggestion { /// An extra note that should be issued if this item is suggested pub note: Option, pub is_stable: bool, + pub is_exact_match: bool, } /// Adjust the impl span so that just the `impl` keyword is taken by removing @@ -1590,16 +1591,18 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { } } - fn lookup_import_candidates_from_module( + fn lookup_import_candidates_from_module( &self, lookup_ident: Ident, namespace: Namespace, parent_scope: &ParentScope<'ra>, start_module: Module<'ra>, crate_path: ThinVec, + ident_filter_fn: IdentFilterFn, filter_fn: FilterFn, ) -> Vec where + IdentFilterFn: Fn(Ident, Ident) -> bool, FilterFn: Fn(Res) -> bool, { let mut candidates = Vec::new(); @@ -1671,7 +1674,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { // collect results based on the filter function // avoid suggesting anything from the same module in which we are resolving // avoid suggesting anything with a hygienic name - if ident.name == lookup_ident.name + if ident_filter_fn(ident.orig(orig_ident_span), lookup_ident) && ns == namespace && in_module != parent_scope.module && ident.ctxt.is_root() @@ -1751,6 +1754,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { note, via_import, is_stable, + is_exact_match: ident.name == lookup_ident.name, }); } } @@ -1827,6 +1831,8 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { /// /// N.B., the method does not look into imports, but this is not a problem, /// since we report the definitions (thus, the de-aliased imports). + /// + /// The method is implemented in `lookup_import_candidates_impl`. The `_impl` method allows applying a different filter function on the ident than the exact match function used by default here. pub(crate) fn lookup_import_candidates( &self, lookup_ident: Ident, @@ -1836,6 +1842,28 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { ) -> Vec where FilterFn: Fn(Res) -> bool, + { + self.lookup_import_candidates_impl( + lookup_ident, + namespace, + parent_scope, + |ident: Ident, lookup_ident: Ident| ident.name == lookup_ident.name, + filter_fn, + ) + } + + /// The actual impl of the `lookup_import_candidates function`. + pub(crate) fn lookup_import_candidates_impl( + &self, + lookup_ident: Ident, + namespace: Namespace, + parent_scope: &ParentScope<'ra>, + ident_filter_fn: IdentFilterFn, + filter_fn: FilterFn, + ) -> Vec + where + IdentFilterFn: Fn(Ident, Ident) -> bool, + FilterFn: Fn(Res) -> bool, { let crate_path = thin_vec![ast::PathSegment::from_ident(Ident::with_dummy_span(kw::Crate))]; let mut suggestions = self.lookup_import_candidates_from_module( @@ -1844,6 +1872,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { parent_scope, self.graph_root.to_module(), crate_path, + &ident_filter_fn, &filter_fn, ); @@ -1898,6 +1927,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { parent_scope, crate_root, crate_path, + &ident_filter_fn, &filter_fn, )); } @@ -3899,7 +3929,7 @@ pub(crate) fn import_candidates( ); } -type PathString<'a> = (String, &'a str, Option, &'a Option, bool); +type PathString<'a> = (String, &'a str, Option, &'a Option, bool, bool); /// When an entity with a given name is not available in scope, we search for /// entities with that name in all crates. This method allows outputting the @@ -3935,6 +3965,7 @@ fn show_candidates( c.did.and_then(|did| Some(tcx.source_span(did.as_local()?))), &c.note, c.via_import, + c.is_exact_match, )) } } else { @@ -3944,6 +3975,7 @@ fn show_candidates( c.did.and_then(|did| Some(tcx.source_span(did.as_local()?))), &c.note, c.via_import, + c.is_exact_match, )) } }); @@ -3975,9 +4007,10 @@ fn show_candidates( if !accessible_path_strings.is_empty() { let (determiner, kind, s, name, through) = - if let [(name, descr, _, _, via_import)] = &accessible_path_strings[..] { + if let [(name, descr, _, _, via_import, is_exact_match)] = &accessible_path_strings[..] + { ( - "this", + if *is_exact_match { "this" } else { "this similarly named" }, *descr, "", format!(" `{name}`"), @@ -3988,12 +4021,24 @@ fn show_candidates( // instead of the more generic "items". let kinds = accessible_path_strings .iter() - .map(|(_, descr, _, _, _)| *descr) + .map(|(_, descr, _, _, _, _)| *descr) .collect::>(); let kind = if let Some(kind) = kinds.get_only() { kind } else { "item" }; let s = if kind.ends_with('s') { "es" } else { "s" }; + // we should only suggest case insensitive suggestion if no case sensitive match was found, + // so all the suggestion should have the same is_exact_match value. - ("one of these", kind, s, String::new(), "") + ( + if accessible_path_strings[0].5 { + "one of these" + } else { + "one of these similarly named" + }, + kind, + s, + String::new(), + "", + ) }; let instead = if let Instead::Yes = instead { " instead" } else { "" }; @@ -4087,9 +4132,12 @@ fn show_candidates( { let prefix = if let DiagMode::Pattern = mode { "you might have meant to match on " } else { "" }; - if let [(name, descr, source_span, note, _)] = &inaccessible_path_strings[..] { + if let [(name, descr, source_span, note, _, is_exact_match)] = + &inaccessible_path_strings[..] + { let msg = format!( - "{prefix}{descr} `{name}`{} exists but is inaccessible", + "{prefix}{}{descr} `{name}`{} exists but is inaccessible", + if *is_exact_match { "" } else { "similarly named " }, if let DiagMode::Pattern = mode { ", which" } else { "" } ); @@ -4107,17 +4155,20 @@ fn show_candidates( } else { let descr = inaccessible_path_strings .iter() - .map(|&(_, descr, _, _, _)| descr) + .map(|&(_, descr, _, _, _, _)| descr) .all_equal_value() .unwrap_or("item"); let plural_descr = if descr.ends_with('s') { format!("{descr}es") } else { format!("{descr}s") }; - - let mut msg = format!("{prefix}these {plural_descr} exist but are inaccessible"); + let are_exact_matches = inaccessible_path_strings[0].5; + let mut msg = format!( + "{prefix}these {}{plural_descr} exist but are inaccessible", + if are_exact_matches { "" } else { "similarly named " }, + ); let mut has_colon = false; let mut spans = Vec::new(); - for (name, _, source_span, _, _) in &inaccessible_path_strings { + for (name, _, source_span, _, _, _) in &inaccessible_path_strings { if let Some(source_span) = source_span { let span = tcx.sess.source_map().guess_head_span(*source_span); spans.push((name, span)); diff --git a/compiler/rustc_resolve/src/late/diagnostics.rs b/compiler/rustc_resolve/src/late/diagnostics.rs index b126272583692..4a65c9a7bf571 100644 --- a/compiler/rustc_resolve/src/late/diagnostics.rs +++ b/compiler/rustc_resolve/src/late/diagnostics.rs @@ -15,8 +15,8 @@ use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexMap, FxIndexSet}; use rustc_data_structures::unord::UnordItems; use rustc_errors::codes::*; use rustc_errors::{ - Applicability, Diag, Diagnostic, ErrorGuaranteed, MultiSpan, SuggestionStyle, pluralize, - struct_span_code_err, + Applicability, Diag, Diagnostic, ErrorGuaranteed, MultiSpan, SuggestionStyle, Suggestions, + pluralize, struct_span_code_err, }; use rustc_hir as hir; use rustc_hir::attrs::diagnostic::{CustomDiagnostic, FormatArgs}; @@ -760,6 +760,7 @@ impl<'ast, 'ra, 'tcx> LateResolutionVisitor<'_, 'ast, 'ra, 'tcx> { }; let (found, suggested_candidates, mut candidates) = self.try_lookup_name_relaxed( + true, &mut err, source, path, @@ -788,11 +789,35 @@ impl<'ast, 'ra, 'tcx> LateResolutionVisitor<'_, 'ast, 'ra, 'tcx> { suggested_candidates, ); + self.err_code_special_cases(&mut err, source, path, span); + + let no_suggestion = match &err.suggestions { + Suggestions::Enabled(suggestions) => suggestions.is_empty(), + Suggestions::Sealed(suggestions) => suggestions.is_empty(), + Suggestions::Disabled => false, + }; + if let Some(E0425) = err.code + && candidates.is_empty() + && no_suggestion + { + candidates = self + .try_lookup_name_relaxed( + false, + &mut err, + source, + path, + following_seg, + span, + res, + &base_error, + ) + .2; + } + if fallback { // Fallback label. err.span_label(base_error.span, base_error.fallback_label); } - self.err_code_special_cases(&mut err, source, path, span); let module = base_error.module.unwrap_or_else(|| CRATE_DEF_ID.to_def_id()); self.r.find_cfg_stripped(&mut err, &path.last().unwrap().ident.name, module); @@ -916,6 +941,7 @@ impl<'ast, 'ra, 'tcx> LateResolutionVisitor<'_, 'ast, 'ra, 'tcx> { fn try_lookup_name_relaxed( &mut self, + case_sensitive: bool, // a subset of the tests are run when false err: &mut Diag<'_>, source: PathSource<'_, '_, '_>, path: &[Segment], @@ -935,16 +961,70 @@ impl<'ast, 'ra, 'tcx> LateResolutionVisitor<'_, 'ast, 'ra, 'tcx> { let mut suggested_candidates = FxHashSet::default(); // Try to lookup name in more relaxed fashion for better error reporting. let ident = path.last().unwrap().ident; - let is_expected = &|res| source.is_expected(res); + // we do not suggest alternative capitalizations if only one letter, too many constants can match and it become noisy. + if !case_sensitive && ident.as_str().len() < 2 { + return (false, suggested_candidates, Vec::new()); + } + + let ident_filter = &|ident: Ident, ident_lookup: Ident| { + if case_sensitive { + ident.name == ident_lookup.name + } else { + ident.name.as_str().to_lowercase() == ident_lookup.name.as_str().to_lowercase() + } + }; + let is_expected = &|res| { + if case_sensitive { + source.is_expected(res) + } else { + if following_seg.is_none() { + source.is_expected(res) + } else { + matches!(res, Res::Def(DefKind::Mod, _)) //fixme(GTimothy):check that this is + // necessary/correct + } + } + }; let ns = source.namespace(); let is_enum_variant = &|res| matches!(res, Res::Def(DefKind::Variant, _)); let path_str = Segment::names_to_string(path); let ident_span = path.last().map_or(span, |ident| ident.ident.span); let mut candidates = self .r - .lookup_import_candidates(ident, ns, &self.parent_scope, is_expected) + .lookup_import_candidates_impl(ident, ns, &self.parent_scope, ident_filter, is_expected) .into_iter() .filter(|ImportSuggestion { did, .. }| { + if !case_sensitive { + // If there's a following segment, only keep modules that contain it + if let Some(following) = following_seg { + let Some(did) = did else { return false }; + let Some(module) = self.r.get_module(*did) else { return false }; + let mut found = false; + module.for_each_child(self.r, |_, ident, _, _, _| { + if ident.name == following.ident.name { + found = true; + } + }); + if !found { + return false; + } + } + + // Filter out items that are in the prelude + if let Some(prelude) = self.r.prelude { + if let Some(suggestion_did) = did { + let mut is_in_prelude = false; + prelude.for_each_child(self.r, |_, _, _, _, decl| { + if decl.res().opt_def_id() == Some(*suggestion_did) { + is_in_prelude = true; + } + }); + if is_in_prelude { + return false; + } + } + } + } match (did, res.and_then(|res| res.opt_def_id())) { (Some(suggestion_did), Some(actual_did)) => *suggestion_did != actual_did, _ => true, @@ -963,6 +1043,9 @@ impl<'ast, 'ra, 'tcx> LateResolutionVisitor<'_, 'ast, 'ra, 'tcx> { // Put them back if we have no more candidates to suggest... candidates = intrinsic_candidates; } + if !case_sensitive { + return (false, suggested_candidates, candidates); + } let crate_def_id = CRATE_DEF_ID.to_def_id(); if candidates.is_empty() && is_expected(Res::Def(DefKind::Enum, crate_def_id)) { let mut enum_candidates: Vec<_> = self @@ -1153,7 +1236,6 @@ impl<'ast, 'ra, 'tcx> LateResolutionVisitor<'_, 'ast, 'ra, 'tcx> { } } } - if candidates.is_empty() { candidates = self.smart_resolve_partial_mod_path_errors(path, following_seg); } @@ -3088,7 +3170,8 @@ impl<'ast, 'ra, 'tcx> LateResolutionVisitor<'_, 'ast, 'ra, 'tcx> { path_segments.push(ast::PathSegment::from_ident(ident.orig(orig_ident_span))); let doc_visible = doc_visible && (module_def_id.is_local() || !r.tcx.is_doc_hidden(module_def_id)); - if module_def_id == def_id { + let is_exact_match = module_def_id == def_id; + if is_exact_match { let path = Path { span: name_binding.span, segments: path_segments }; result = Some(( r.expect_module(module_def_id), @@ -3101,6 +3184,7 @@ impl<'ast, 'ra, 'tcx> LateResolutionVisitor<'_, 'ast, 'ra, 'tcx> { note: None, via_import: false, is_stable: true, + is_exact_match, }, )); } else { From c051a58d35ddec904c19ee57b4fba35d4be38d5d Mon Sep 17 00:00:00 2001 From: GTimothy <22472919+GTimothy@users.noreply.github.com> Date: Sun, 16 Aug 2026 16:29:14 +0200 Subject: [PATCH 03/12] bless tests --- tests/ui/cast/cast-errors-issue-43825.stderr | 7 + .../unevaluated-const-ice-119731.stderr | 19 +- tests/ui/coroutine/layout-error.stderr | 5 + .../case-insensitive-import.stderr | 16 + .../ui/imports/case-insensitive/libstd.stderr | 888 +++++++++++++++++- .../ui/parser/raw/raw-literal-keywords.stderr | 10 + ...n-with-missing-fields-resolve-error.stderr | 5 + .../export-fully-qualified-2018.stderr | 4 + .../ui/resolve/export-fully-qualified.stderr | 4 + .../resolve/resolve-assoc-suggestions.stderr | 7 + .../resolve-speculative-adjustment.stderr | 5 + .../suggestions/crate-or-module-typo.stderr | 17 +- 12 files changed, 974 insertions(+), 13 deletions(-) diff --git a/tests/ui/cast/cast-errors-issue-43825.stderr b/tests/ui/cast/cast-errors-issue-43825.stderr index 658d5ddbb611c..d0dea3a776371 100644 --- a/tests/ui/cast/cast-errors-issue-43825.stderr +++ b/tests/ui/cast/cast-errors-issue-43825.stderr @@ -3,6 +3,13 @@ error[E0425]: cannot find value `error` in this scope | LL | let error = error; | ^^^^^ not found in this scope + | +help: consider importing one of these similarly named items + | +LL + use std::fmt::Error; + | +LL + use std::fs::TryLockError::Error; + | error: aborting due to 1 previous error diff --git a/tests/ui/const-generics/generic_const_exprs/unevaluated-const-ice-119731.stderr b/tests/ui/const-generics/generic_const_exprs/unevaluated-const-ice-119731.stderr index 022074181cecd..8969a4001245f 100644 --- a/tests/ui/const-generics/generic_const_exprs/unevaluated-const-ice-119731.stderr +++ b/tests/ui/const-generics/generic_const_exprs/unevaluated-const-ice-119731.stderr @@ -10,6 +10,19 @@ LL - pub use v20::{v13, v17}; LL + pub use v20::{v11, v17}; | +error[E0425]: cannot find function `v6` in this scope + --> $DIR/unevaluated-const-ice-119731.rs:13:35 + | +LL | const v0: [[usize; v4]; v4] = v6(v8); + | ^^ not found in this scope + | +help: consider importing one of these similarly named tuple variants + | +LL + use std::net::IpAddr::V6; + | +LL + use std::net::SocketAddr::V6; + | + error[E0425]: cannot find value `v8` in this scope --> $DIR/unevaluated-const-ice-119731.rs:13:38 | @@ -87,12 +100,6 @@ help: add `#![feature(min_adt_const_params)]` to the crate attributes to enable LL + #![feature(min_adt_const_params)] | -error[E0425]: cannot find function `v6` in this scope - --> $DIR/unevaluated-const-ice-119731.rs:13:35 - | -LL | const v0: [[usize; v4]; v4] = v6(v8); - | ^^ not found in this scope - error: maximum number of nodes exceeded in constant v20::v17::::{constant#0} --> $DIR/unevaluated-const-ice-119731.rs:28:37 | diff --git a/tests/ui/coroutine/layout-error.stderr b/tests/ui/coroutine/layout-error.stderr index f3b3843de898c..63ce820f3027c 100644 --- a/tests/ui/coroutine/layout-error.stderr +++ b/tests/ui/coroutine/layout-error.stderr @@ -3,6 +3,11 @@ error[E0425]: cannot find value `Foo` in this scope | LL | let a = Foo; | ^^^ not found in this scope + | +help: consider importing this similarly named function + | +LL + use crate::foo; + | error: aborting due to 1 previous error diff --git a/tests/ui/imports/case-insensitive/case-insensitive-import.stderr b/tests/ui/imports/case-insensitive/case-insensitive-import.stderr index 5d3fa1549b5cb..2f30802babc5d 100644 --- a/tests/ui/imports/case-insensitive/case-insensitive-import.stderr +++ b/tests/ui/imports/case-insensitive/case-insensitive-import.stderr @@ -35,6 +35,12 @@ error[E0425]: cannot find type `enumab` in this scope | LL | fn enumab_not_in_scope()->enumab{ | ^^^^^^ not found in this scope + | +note: similarly named enum `a::EnumAB` exists but is inaccessible + --> $DIR/case-insensitive-import.rs:2:5 + | +LL | enum EnumAB{ + | ^^^^^^^^^^^ not accessible error[E0425]: cannot find type `Shutdown` in this scope --> $DIR/case-insensitive-import.rs:11:33 @@ -58,12 +64,22 @@ error[E0425]: cannot find type `shutdown` in this scope | LL | fn shutdown_both_not_in_scope_and_capitalization()->shutdown{ | ^^^^^^^^ not found in this scope + | +help: consider importing this similarly named enum + | +LL + use std::net::Shutdown; + | error[E0425]: cannot find value `both` in this scope --> $DIR/case-insensitive-import.rs:18:9 | LL | both | ^^^^ not found in this scope + | +help: consider importing this similarly named unit variant + | +LL + use std::net::Shutdown::Both; + | error: aborting due to 8 previous errors diff --git a/tests/ui/imports/case-insensitive/libstd.stderr b/tests/ui/imports/case-insensitive/libstd.stderr index 633efb784bf56..7cf3b5a604f9a 100644 --- a/tests/ui/imports/case-insensitive/libstd.stderr +++ b/tests/ui/imports/case-insensitive/libstd.stderr @@ -3,354 +3,677 @@ error[E0425]: cannot find type `LayOut` in this scope | LL | fn test_layout(_x: LayOut){} | ^^^^^^ not found in this scope + | +help: consider importing this similarly named struct + | +LL + use std::alloc::Layout; + | error[E0425]: cannot find type `system` in this scope --> $DIR/libstd.rs:5:20 | LL | fn test_system(_x: system){} | ^^^^^^ not found in this scope + | +help: consider importing this similarly named struct + | +LL + use std::alloc::System; + | error[E0425]: cannot find type `Typeid` in this scope --> $DIR/libstd.rs:10:20 | LL | fn test_typeid(_x: Typeid){} | ^^^^^^ not found in this scope + | +help: consider importing this similarly named struct + | +LL + use std::any::TypeId; + | error[E0425]: cannot find type `Escapedefault` in this scope --> $DIR/libstd.rs:15:27 | LL | fn test_escapedefault(_x: Escapedefault){} | ^^^^^^^^^^^^^ not found in this scope + | +help: consider importing one of these similarly named structs + | +LL + use std::ascii::EscapeDefault; + | +LL + use std::char::EscapeDefault; + | +LL + use std::str::EscapeDefault; + | error[E0425]: cannot find type `cell` in this scope --> $DIR/libstd.rs:20:18 | LL | fn test_cell(_x: cell<()>){} | ^^^^ not found in this scope + | +help: consider importing this similarly named struct + | +LL + use std::cell::Cell; + | error[E0425]: cannot find type `DecodeUTF16` in this scope --> $DIR/libstd.rs:25:25 | LL | fn test_decodeutf16(_x: DecodeUTF16<()>){} | ^^^^^^^^^^^ not found in this scope + | +help: consider importing this similarly named struct + | +LL + use std::char::DecodeUtf16; + | error[E0425]: cannot find type `Escapeunicode` in this scope --> $DIR/libstd.rs:28:27 | LL | fn test_escapeunicode(_x: Escapeunicode){} | ^^^^^^^^^^^^^ not found in this scope + | +help: consider importing one of these similarly named structs + | +LL + use std::char::EscapeUnicode; + | +LL + use std::str::EscapeUnicode; + | error[E0425]: cannot find type `Tolowercase` in this scope --> $DIR/libstd.rs:31:25 | LL | fn test_tolowercase(_x: Tolowercase){} | ^^^^^^^^^^^ not found in this scope + | +help: consider importing this similarly named struct + | +LL + use std::char::ToLowercase; + | error[E0425]: cannot find type `Touppercase` in this scope --> $DIR/libstd.rs:34:25 | LL | fn test_touppercase(_x: Touppercase){} | ^^^^^^^^^^^ not found in this scope + | +help: consider importing this similarly named struct + | +LL + use std::char::ToUppercase; + | error[E0425]: cannot find type `reverse` in this scope --> $DIR/libstd.rs:39:21 | LL | fn test_reverse(_x: reverse<()>){} | ^^^^^^^ not found in this scope + | +help: consider importing this similarly named struct + | +LL + use std::cmp::Reverse; + | error[E0425]: cannot find type `BtreeMap` in this scope --> $DIR/libstd.rs:44:22 | LL | fn test_btreemap(_x: BtreeMap<(), ()>){} | ^^^^^^^^ not found in this scope + | +help: consider importing this similarly named struct + | +LL + use std::collections::BTreeMap; + | error[E0425]: cannot find type `BtreeSet` in this scope --> $DIR/libstd.rs:46:22 | LL | fn test_btreeset(_x: BtreeSet<()>){} | ^^^^^^^^ not found in this scope + | +help: consider importing this similarly named struct + | +LL + use std::collections::BTreeSet; + | error[E0425]: cannot find type `Binaryheap` in this scope --> $DIR/libstd.rs:48:24 | LL | fn test_binaryheap(_x: Binaryheap<()>){} | ^^^^^^^^^^ not found in this scope + | +help: consider importing this similarly named struct + | +LL + use std::collections::BinaryHeap; + | error[E0425]: cannot find type `Hashmap` in this scope --> $DIR/libstd.rs:50:21 | LL | fn test_hashmap(_x: Hashmap){} | ^^^^^^^ not found in this scope + | +help: consider importing this similarly named struct + | +LL + use std::collections::HashMap; + | error[E0425]: cannot find type `Hashset` in this scope --> $DIR/libstd.rs:52:21 | LL | fn test_hashset(_x: Hashset<()>){} | ^^^^^^^ not found in this scope + | +help: consider importing this similarly named struct + | +LL + use std::collections::HashSet; + | error[E0425]: cannot find type `Linkedlist` in this scope --> $DIR/libstd.rs:54:24 | LL | fn test_linkedlist(_x: Linkedlist<()>){} | ^^^^^^^^^^ not found in this scope + | +help: consider importing this similarly named struct + | +LL + use std::collections::LinkedList; + | error[E0425]: cannot find type `Vecdeque` in this scope --> $DIR/libstd.rs:56:22 | LL | fn test_vecdeque(_x: Vecdeque<()>){} | ^^^^^^^^ not found in this scope + | +help: consider importing this similarly named struct + | +LL + use std::collections::VecDeque; + | error[E0425]: cannot find type `args` in this scope --> $DIR/libstd.rs:61:18 | LL | fn test_args(_x: args){} | ^^^^ not found in this scope + | +help: consider importing this similarly named struct + | +LL + use std::env::Args; + | error[E0425]: cannot find type `Argsos` in this scope --> $DIR/libstd.rs:63:20 | LL | fn test_argsos(_x: Argsos){} | ^^^^^^ not found in this scope + | +help: consider importing this similarly named struct + | +LL + use std::env::ArgsOs; + | error[E0425]: cannot find type `Splitpaths` in this scope --> $DIR/libstd.rs:65:24 | LL | fn test_splitpaths(_x: Splitpaths<'_>){} | ^^^^^^^^^^ not found in this scope + | +help: consider importing this similarly named struct + | +LL + use std::env::SplitPaths; + | error[E0425]: cannot find type `vars` in this scope --> $DIR/libstd.rs:67:18 | LL | fn test_vars(_x: vars){} | ^^^^ not found in this scope + | +help: consider importing this similarly named struct + | +LL + use std::env::Vars; + | error[E0425]: cannot find type `Varsos` in this scope --> $DIR/libstd.rs:69:20 | LL | fn test_varsos(_x: Varsos){} | ^^^^^^ not found in this scope + | +help: consider importing this similarly named struct + | +LL + use std::env::VarsOs; + | error[E0425]: cannot find type `cStr` in this scope --> $DIR/libstd.rs:74:18 | LL | fn test_cstr(_x: cStr){} | ^^^^ not found in this scope + | +help: consider importing this similarly named struct + | +LL + use std::ffi::CStr; + | error[E0425]: cannot find type `Osstr` in this scope --> $DIR/libstd.rs:76:19 | LL | fn test_osstr(_x: Osstr){} | ^^^^^ not found in this scope + | +help: consider importing this similarly named struct + | +LL + use std::ffi::OsStr; + | error[E0425]: cannot find type `Osstring` in this scope --> $DIR/libstd.rs:78:22 | LL | fn test_osstring(_x: Osstring){} | ^^^^^^^^ not found in this scope + | +help: consider importing this similarly named struct + | +LL + use std::ffi::OsString; + | error[E0425]: cannot find type `Debuglist` in this scope --> $DIR/libstd.rs:83:23 | LL | fn test_debuglist(_x: Debuglist){} | ^^^^^^^^^ not found in this scope + | +help: consider importing this similarly named struct + | +LL + use std::fmt::DebugList; + | error[E0425]: cannot find type `Debugmap` in this scope --> $DIR/libstd.rs:85:22 | LL | fn test_debugmap(_x: Debugmap){} | ^^^^^^^^ not found in this scope + | +help: consider importing this similarly named struct + | +LL + use std::fmt::DebugMap; + | error[E0425]: cannot find type `Debugset` in this scope --> $DIR/libstd.rs:87:22 | LL | fn test_debugset(_x: Debugset){} | ^^^^^^^^ not found in this scope + | +help: consider importing this similarly named struct + | +LL + use std::fmt::DebugSet; + | error[E0425]: cannot find type `Debugstruct` in this scope --> $DIR/libstd.rs:89:25 | LL | fn test_debugstruct(_x: Debugstruct){} | ^^^^^^^^^^^ not found in this scope + | +help: consider importing this similarly named struct + | +LL + use std::fmt::DebugStruct; + | error[E0425]: cannot find type `Debugtuple` in this scope --> $DIR/libstd.rs:91:24 | LL | fn test_debugtuple(_x: Debugtuple){} | ^^^^^^^^^^ not found in this scope + | +help: consider importing this similarly named struct + | +LL + use std::fmt::DebugTuple; + | error[E0425]: cannot find type `formatter` in this scope --> $DIR/libstd.rs:93:23 | LL | fn test_fmter(mut _x: formatter){} | ^^^^^^^^^ not found in this scope + | +help: consider importing this similarly named struct + | +LL + use std::fmt::Formatter; + | error[E0425]: cannot find type `Dirbuilder` in this scope --> $DIR/libstd.rs:98:24 | LL | fn test_dirbuilder(_x: Dirbuilder){} | ^^^^^^^^^^ not found in this scope + | +help: consider importing this similarly named struct + | +LL + use std::fs::DirBuilder; + | error[E0425]: cannot find type `Direntry` in this scope --> $DIR/libstd.rs:100:22 | LL | fn test_direntry(_x: Direntry){} | ^^^^^^^^ not found in this scope + | +help: consider importing this similarly named struct + | +LL + use std::fs::DirEntry; + | error[E0425]: cannot find type `Filetype` in this scope --> $DIR/libstd.rs:102:22 | LL | fn test_filetype(_x: Filetype){} | ^^^^^^^^ not found in this scope + | +help: consider importing this similarly named struct + | +LL + use std::fs::FileType; + | error[E0425]: cannot find type `MetaData` in this scope --> $DIR/libstd.rs:104:22 | LL | fn test_metadata(_x: MetaData){} | ^^^^^^^^ not found in this scope + | +help: consider importing this similarly named struct + | +LL + use std::fs::Metadata; + | error[E0425]: cannot find type `Openoptions` in this scope --> $DIR/libstd.rs:106:25 | LL | fn test_openoptions(_x: Openoptions){} | ^^^^^^^^^^^ not found in this scope + | +help: consider importing this similarly named struct + | +LL + use std::fs::OpenOptions; + | error[E0425]: cannot find type `permissions` in this scope --> $DIR/libstd.rs:108:25 | LL | fn test_permissions(_x: permissions){} | ^^^^^^^^^^^ not found in this scope + | +help: consider importing this similarly named struct + | +LL + use std::fs::Permissions; + | error[E0425]: cannot find type `Readdir` in this scope --> $DIR/libstd.rs:110:21 | LL | fn test_readdir(_x: Readdir){} | ^^^^^^^ not found in this scope + | +help: consider importing this similarly named struct + | +LL + use std::fs::ReadDir; + | error[E0425]: cannot find type `BuildhasherDefault` in this scope --> $DIR/libstd.rs:115:32 | LL | fn test_buildhasherdefault(_x: BuildhasherDefault){} | ^^^^^^^^^^^^^^^^^^ not found in this scope + | +help: consider importing this similarly named struct + | +LL + use std::hash::BuildHasherDefault; + | error[E0425]: cannot find type `Bufreader` in this scope --> $DIR/libstd.rs:120:23 | LL | fn test_bufreader(_x: Bufreader<()>){} | ^^^^^^^^^ not found in this scope + | +help: consider importing this similarly named struct + | +LL + use std::io::BufReader; + | error[E0425]: cannot find type `Bufwriter` in this scope --> $DIR/libstd.rs:122:23 | LL | fn test_bufwriter(_x: Bufwriter<()>){} | ^^^^^^^^^ not found in this scope + | +help: consider importing this similarly named struct + | +LL + use std::io::BufWriter; + | error[E0425]: cannot find type `bytes` in this scope --> $DIR/libstd.rs:124:19 | LL | fn test_bytes(_x: bytes<()>){} | ^^^^^ not found in this scope + | +help: consider importing one of these similarly named structs + | +LL + use std::io::Bytes; + | +LL + use std::str::Bytes; + | error[E0425]: cannot find type `chain` in this scope --> $DIR/libstd.rs:126:19 | LL | fn test_chain(_x: chain<(), ()>){} | ^^^^^ not found in this scope + | +help: consider importing one of these similarly named structs + | +LL + use std::io::Chain; + | +LL + use std::iter::Chain; + | error[E0425]: cannot find type `cursor` in this scope --> $DIR/libstd.rs:128:20 | LL | fn test_cursor(_x: cursor<()>){} | ^^^^^^ not found in this scope + | +help: consider importing one of these similarly named structs + | +LL + use std::collections::btree_map::Cursor; + | +LL + use std::collections::btree_set::Cursor; + | +LL + use std::collections::linked_list::Cursor; + | +LL + use std::io::Cursor; + | error[E0425]: cannot find type `empty` in this scope --> $DIR/libstd.rs:130:19 | LL | fn test_empty(_x: empty){} | ^^^^^ not found in this scope + | +help: consider importing one of these similarly named structs + | +LL + use std::io::Empty; + | +LL + use std::iter::Empty; + | error[E0425]: cannot find type `Ioslice` in this scope --> $DIR/libstd.rs:132:21 | LL | fn test_ioslice(_x: Ioslice){} | ^^^^^^^ not found in this scope + | +help: consider importing this similarly named struct + | +LL + use std::io::IoSlice; + | error[E0425]: cannot find type `IosliceMut` in this scope --> $DIR/libstd.rs:134:24 | LL | fn test_ioslicemut(_x: IosliceMut){} | ^^^^^^^^^^ not found in this scope + | +help: consider importing this similarly named struct + | +LL + use std::io::IoSliceMut; + | error[E0425]: cannot find type `Linewriter` in this scope --> $DIR/libstd.rs:136:24 | LL | fn test_linewriter(_x: Linewriter<()>){} | ^^^^^^^^^^ not found in this scope + | +help: consider importing this similarly named struct + | +LL + use std::io::LineWriter; + | error[E0425]: cannot find type `lines` in this scope --> $DIR/libstd.rs:138:19 | LL | fn test_lines(_x: lines<()>){} | ^^^^^ not found in this scope + | +help: consider importing one of these similarly named structs + | +LL + use std::io::Lines; + | +LL + use std::str::Lines; + | error[E0425]: cannot find type `repeat` in this scope --> $DIR/libstd.rs:140:20 | LL | fn test_repeat(_x: repeat){} | ^^^^^^ not found in this scope + | +help: consider importing one of these similarly named structs + | +LL + use std::io::Repeat; + | +LL + use std::iter::Repeat; + | error[E0425]: cannot find type `sink` in this scope --> $DIR/libstd.rs:142:18 | LL | fn test_sink(_x: sink){} | ^^^^ not found in this scope + | +help: consider importing this similarly named struct + | +LL + use std::io::Sink; + | error[E0425]: cannot find type `split` in this scope --> $DIR/libstd.rs:144:19 | LL | fn test_split(_x: split<()>){} | ^^^^^ not found in this scope + | +help: consider importing one of these similarly named structs + | +LL + use std::io::Split; + | +LL + use std::slice::Split; + | +LL + use std::str::Split; + | error[E0425]: cannot find type `StdErr` in this scope --> $DIR/libstd.rs:146:20 | LL | fn test_stderr(_x: StdErr){} | ^^^^^^ not found in this scope + | +help: consider importing this similarly named struct + | +LL + use std::io::Stderr; + | error[E0425]: cannot find type `StdErrLock` in this scope --> $DIR/libstd.rs:148:24 | LL | fn test_stderrlock(_x: StdErrLock){} | ^^^^^^^^^^ not found in this scope + | +help: consider importing this similarly named struct + | +LL + use std::io::StderrLock; + | error[E0425]: cannot find type `StdIn` in this scope --> $DIR/libstd.rs:150:19 | LL | fn test_stdin(_x: StdIn){} | ^^^^^ not found in this scope + | +help: consider importing this similarly named struct + | +LL + use std::io::Stdin; + | error[E0425]: cannot find type `StdInLock` in this scope --> $DIR/libstd.rs:152:23 | LL | fn test_stdinlock(_x: StdInLock){} | ^^^^^^^^^ not found in this scope + | +help: consider importing this similarly named struct + | +LL + use std::io::StdinLock; + | error[E0425]: cannot find type `StdOut` in this scope --> $DIR/libstd.rs:154:20 | LL | fn test_stdout(_x: StdOut){} | ^^^^^^ not found in this scope + | +help: consider importing this similarly named struct + | +LL + use std::io::Stdout; + | error[E0425]: cannot find type `StdOutLock` in this scope --> $DIR/libstd.rs:156:24 | LL | fn test_stdoutlock(_x: StdOutLock){} | ^^^^^^^^^^ not found in this scope + | +help: consider importing this similarly named struct + | +LL + use std::io::StdoutLock; + | error[E0425]: cannot find type `take` in this scope --> $DIR/libstd.rs:158:18 | LL | fn test_take(_x: take){} | ^^^^ not found in this scope + | +help: consider importing one of these similarly named structs + | +LL + use std::io::Take; + | +LL + use std::iter::Take; + | error[E0425]: cannot find type `cloned` in this scope --> $DIR/libstd.rs:163:20 @@ -372,36 +695,66 @@ error[E0425]: cannot find type `copied` in this scope | LL | fn test_copied(_x: copied<(), ()>){} | ^^^^^^ not found in this scope + | +help: consider importing this similarly named struct + | +LL + use std::iter::Copied; + | error[E0425]: cannot find type `cycle` in this scope --> $DIR/libstd.rs:167:19 | LL | fn test_cycle(_x: cycle<(), ()>){} | ^^^^^ not found in this scope + | +help: consider importing this similarly named struct + | +LL + use std::iter::Cycle; + | error[E0425]: cannot find type `enumerate` in this scope --> $DIR/libstd.rs:169:23 | LL | fn test_enumerate(_x: enumerate<(), ()>){} | ^^^^^^^^^ not found in this scope + | +help: consider importing this similarly named struct + | +LL + use std::iter::Enumerate; + | error[E0425]: cannot find type `filter` in this scope --> $DIR/libstd.rs:171:20 | LL | fn test_filter(_x: filter<(), ()>){} | ^^^^^^ not found in this scope + | +help: consider importing this similarly named struct + | +LL + use std::iter::Filter; + | error[E0425]: cannot find type `Filtermap` in this scope --> $DIR/libstd.rs:173:23 | LL | fn test_filtermap(_x: Filtermap<(), ()>){} | ^^^^^^^^^ not found in this scope + | +help: consider importing this similarly named struct + | +LL + use std::iter::FilterMap; + | error[E0425]: cannot find type `flatten` in this scope --> $DIR/libstd.rs:175:21 | LL | fn test_flatten(_x: flatten<()>){} | ^^^^^^^ not found in this scope + | +help: consider importing this similarly named struct + | +LL + use std::iter::Flatten; + | error[E0425]: cannot find type `Fromfn` in this scope --> $DIR/libstd.rs:177:20 @@ -423,396 +776,751 @@ error[E0425]: cannot find type `fuse` in this scope | LL | fn test_fuse(_x: fuse<()>){} | ^^^^ not found in this scope + | +help: consider importing this similarly named struct + | +LL + use std::iter::Fuse; + | error[E0425]: cannot find type `inspect` in this scope --> $DIR/libstd.rs:181:21 | LL | fn test_inspect(_x: inspect<(), ()>){} | ^^^^^^^ not found in this scope + | +help: consider importing this similarly named struct + | +LL + use std::iter::Inspect; + | error[E0425]: cannot find type `map` in this scope --> $DIR/libstd.rs:183:17 | LL | fn test_map(_x: map<(), ()>){} | ^^^ not found in this scope + | +help: consider importing this similarly named struct + | +LL + use std::iter::Map; + | error[E0425]: cannot find type `once` in this scope --> $DIR/libstd.rs:185:18 | LL | fn test_once(_x: once<()>){} | ^^^^ not found in this scope + | +help: consider importing one of these similarly named structs + | +LL + use std::iter::Once; + | +LL + use std::sync::Once; + | error[E0425]: cannot find type `Oncewith` in this scope --> $DIR/libstd.rs:187:22 | LL | fn test_oncewith(_x: Oncewith<()>){} | ^^^^^^^^ not found in this scope + | +help: consider importing this similarly named struct + | +LL + use std::iter::OnceWith; + | error[E0425]: cannot find type `peekable` in this scope --> $DIR/libstd.rs:189:22 | LL | fn test_peekable(_x: peekable<()>){} | ^^^^^^^^ not found in this scope + | +help: consider importing this similarly named struct + | +LL + use std::iter::Peekable; + | error[E0425]: cannot find type `Repeatwith` in this scope --> $DIR/libstd.rs:191:24 | LL | fn test_repeatwith(_x: Repeatwith<()>){} | ^^^^^^^^^^ not found in this scope + | +help: consider importing this similarly named struct + | +LL + use std::iter::RepeatWith; + | error[E0425]: cannot find type `rev` in this scope --> $DIR/libstd.rs:193:17 | LL | fn test_rev(_x: rev<()>){} | ^^^ not found in this scope + | +help: consider importing this similarly named struct + | +LL + use std::iter::Rev; + | error[E0425]: cannot find type `scan` in this scope --> $DIR/libstd.rs:195:18 | LL | fn test_scan(_x: scan<(), (), ()>){} | ^^^^ not found in this scope + | +help: consider importing this similarly named struct + | +LL + use std::iter::Scan; + | error[E0425]: cannot find type `skip` in this scope --> $DIR/libstd.rs:197:18 | LL | fn test_skip(_x: skip<()>){} | ^^^^ not found in this scope + | +help: consider importing this similarly named struct + | +LL + use std::iter::Skip; + | error[E0425]: cannot find type `Skipwhile` in this scope --> $DIR/libstd.rs:199:23 | LL | fn test_skipwhile(_x: Skipwhile<(), ()>){} | ^^^^^^^^^ not found in this scope + | +help: consider importing this similarly named struct + | +LL + use std::iter::SkipWhile; + | error[E0425]: cannot find type `Stepby` in this scope --> $DIR/libstd.rs:201:20 | LL | fn test_stepby(_x: Stepby<()>){} | ^^^^^^ not found in this scope + | +help: consider importing this similarly named struct + | +LL + use std::iter::StepBy; + | error[E0425]: cannot find type `successors` in this scope --> $DIR/libstd.rs:203:24 | LL | fn test_successors(_x: successors<()>){} | ^^^^^^^^^^ not found in this scope + | +help: consider importing this similarly named struct + | +LL + use std::iter::Successors; + | error[E0425]: cannot find type `Takewhile` in this scope --> $DIR/libstd.rs:205:23 | LL | fn test_takewhile(_x: Takewhile<(), ()>){} | ^^^^^^^^^ not found in this scope + | +help: consider importing this similarly named struct + | +LL + use std::iter::TakeWhile; + | error[E0425]: cannot find type `zip` in this scope --> $DIR/libstd.rs:207:17 | LL | fn test_zip(_x: zip<(), ()>){} | ^^^ not found in this scope + | +help: consider importing this similarly named struct + | +LL + use std::iter::Zip; + | error[E0425]: cannot find type `Phantomdata` in this scope --> $DIR/libstd.rs:212:25 | LL | fn test_phantomdata(_x: Phantomdata){} | ^^^^^^^^^^^ not found in this scope - + | +help: consider importing this similarly named struct + | +LL + use std::marker::PhantomData; + | + error[E0425]: cannot find type `Phantompinned` in this scope --> $DIR/libstd.rs:214:27 | LL | fn test_phantompinned(_x: Phantompinned){} | ^^^^^^^^^^^^^ not found in this scope + | +help: consider importing this similarly named struct + | +LL + use std::marker::PhantomPinned; + | error[E0425]: cannot find type `discriminant` in this scope --> $DIR/libstd.rs:219:26 | LL | fn test_discriminant(_x: discriminant<()>){} | ^^^^^^^^^^^^ not found in this scope + | +help: consider importing this similarly named struct + | +LL + use std::mem::Discriminant; + | error[E0425]: cannot find type `Manuallydrop` in this scope --> $DIR/libstd.rs:221:26 | LL | fn test_manuallydrop(_x: Manuallydrop<()>){} | ^^^^^^^^^^^^ not found in this scope + | +help: consider importing this similarly named struct + | +LL + use std::mem::ManuallyDrop; + | error[E0425]: cannot find type `incoming` in this scope --> $DIR/libstd.rs:226:22 | LL | fn test_incoming(_x: incoming){} | ^^^^^^^^ not found in this scope + | +help: consider importing one of these similarly named structs + | +LL + use std::net::Incoming; + | +LL + use std::os::unix::net::Incoming; + | error[E0425]: cannot find type `IPv4Addr` in this scope --> $DIR/libstd.rs:228:22 | LL | fn test_ipv4addr(_x: IPv4Addr){} | ^^^^^^^^ not found in this scope + | +help: consider importing this similarly named struct + | +LL + use std::net::Ipv4Addr; + | error[E0425]: cannot find type `IPv6Addr` in this scope --> $DIR/libstd.rs:230:22 | LL | fn test_ipv6addr(_x: IPv6Addr){} | ^^^^^^^^ not found in this scope + | +help: consider importing this similarly named struct + | +LL + use std::net::Ipv6Addr; + | error[E0425]: cannot find type `SocketAddrv4` in this scope --> $DIR/libstd.rs:232:26 | LL | fn test_socketaddrv4(_x: SocketAddrv4){} | ^^^^^^^^^^^^ not found in this scope + | +help: consider importing this similarly named struct + | +LL + use std::net::SocketAddrV4; + | error[E0425]: cannot find type `SocketAddrv6` in this scope --> $DIR/libstd.rs:234:26 | LL | fn test_socketaddrv6(_x: SocketAddrv6){} | ^^^^^^^^^^^^ not found in this scope + | +help: consider importing this similarly named struct + | +LL + use std::net::SocketAddrV6; + | error[E0425]: cannot find type `TCPListener` in this scope --> $DIR/libstd.rs:236:25 | LL | fn test_tcplistener(_x: TCPListener){} | ^^^^^^^^^^^ not found in this scope + | +help: consider importing this similarly named struct + | +LL + use std::net::TcpListener; + | error[E0425]: cannot find type `TCPStream` in this scope --> $DIR/libstd.rs:238:23 | LL | fn test_tcpstream(_x: TCPStream){} | ^^^^^^^^^ not found in this scope + | +help: consider importing this similarly named struct + | +LL + use std::net::TcpStream; + | error[E0425]: cannot find type `UDPSocket` in this scope --> $DIR/libstd.rs:240:23 | LL | fn test_udpsocket(_x: UDPSocket){} | ^^^^^^^^^ not found in this scope + | +help: consider importing this similarly named struct + | +LL + use std::net::UdpSocket; + | error[E0425]: cannot find type `NonZeroi8` in this scope --> $DIR/libstd.rs:245:23 | LL | fn test_nonzeroi8(_x: NonZeroi8){} | ^^^^^^^^^ not found in this scope + | +help: consider importing this similarly named type alias + | +LL + use std::num::NonZeroI8; + | error[E0425]: cannot find type `NonZeroi16` in this scope --> $DIR/libstd.rs:247:24 | LL | fn test_nonzeroi16(_x: NonZeroi16){} | ^^^^^^^^^^ not found in this scope + | +help: consider importing this similarly named type alias + | +LL + use std::num::NonZeroI16; + | error[E0425]: cannot find type `NonZeroi32` in this scope --> $DIR/libstd.rs:249:24 | LL | fn test_nonzeroi32(_x: NonZeroi32){} | ^^^^^^^^^^ not found in this scope + | +help: consider importing this similarly named type alias + | +LL + use std::num::NonZeroI32; + | error[E0425]: cannot find type `NonZeroi64` in this scope --> $DIR/libstd.rs:251:24 | LL | fn test_nonzeroi64(_x: NonZeroi64){} | ^^^^^^^^^^ not found in this scope + | +help: consider importing this similarly named type alias + | +LL + use std::num::NonZeroI64; + | error[E0425]: cannot find type `NonZeroi128` in this scope --> $DIR/libstd.rs:253:25 | LL | fn test_nonzeroi128(_x: NonZeroi128){} | ^^^^^^^^^^^ not found in this scope + | +help: consider importing this similarly named type alias + | +LL + use std::num::NonZeroI128; + | error[E0425]: cannot find type `NonZerou8` in this scope --> $DIR/libstd.rs:255:23 | LL | fn test_nonzerou8(_x: NonZerou8){} | ^^^^^^^^^ not found in this scope + | +help: consider importing this similarly named type alias + | +LL + use std::num::NonZeroU8; + | error[E0425]: cannot find type `NonZerou16` in this scope --> $DIR/libstd.rs:257:24 | LL | fn test_nonzerou16(_x: NonZerou16){} | ^^^^^^^^^^ not found in this scope + | +help: consider importing this similarly named type alias + | +LL + use std::num::NonZeroU16; + | error[E0425]: cannot find type `NonZerou32` in this scope --> $DIR/libstd.rs:259:24 | LL | fn test_nonzerou32(_x: NonZerou32){} | ^^^^^^^^^^ not found in this scope + | +help: consider importing this similarly named type alias + | +LL + use std::num::NonZeroU32; + | error[E0425]: cannot find type `NonZerou64` in this scope --> $DIR/libstd.rs:261:24 | LL | fn test_nonzerou64(_x: NonZerou64){} | ^^^^^^^^^^ not found in this scope + | +help: consider importing this similarly named type alias + | +LL + use std::num::NonZeroU64; + | error[E0425]: cannot find type `NonZerou128` in this scope --> $DIR/libstd.rs:263:25 | LL | fn test_nonzerou128(_x: NonZerou128){} | ^^^^^^^^^^^ not found in this scope + | +help: consider importing this similarly named type alias + | +LL + use std::num::NonZeroU128; + | error[E0425]: cannot find type `NonzeroUsize` in this scope --> $DIR/libstd.rs:265:26 | LL | fn test_nonzerousize(_x: NonzeroUsize){} | ^^^^^^^^^^^^ not found in this scope + | +help: consider importing this similarly named type alias + | +LL + use std::num::NonZeroUsize; + | error[E0425]: cannot find type `wrapping` in this scope --> $DIR/libstd.rs:267:22 | LL | fn test_wrapping(_x: wrapping){} | ^^^^^^^^ not found in this scope + | +help: consider importing this similarly named struct + | +LL + use std::num::Wrapping; + | error[E0425]: cannot find type `range` in this scope --> $DIR/libstd.rs:272:19 | LL | fn test_range(_x: range<()>){} | ^^^^^ not found in this scope + | +help: consider importing one of these similarly named structs + | +LL + use std::collections::btree_map::Range; + | +LL + use std::collections::btree_set::Range; + | +LL + use std::range::Range; + | +LL + use std::range::legacy::Range; + | error[E0425]: cannot find type `Rangefrom` in this scope --> $DIR/libstd.rs:274:23 | LL | fn test_rangefrom(_x: Rangefrom<()>){} | ^^^^^^^^^ not found in this scope + | +help: consider importing one of these similarly named structs + | +LL + use std::range::RangeFrom; + | +LL + use std::range::legacy::RangeFrom; + | error[E0425]: cannot find type `Rangefull` in this scope --> $DIR/libstd.rs:276:23 | LL | fn test_rangefull(_x: Rangefull<()>){} | ^^^^^^^^^ not found in this scope + | +help: consider importing this similarly named struct + | +LL + use std::range::RangeFull; + | error[E0425]: cannot find type `Rangeinclusive` in this scope --> $DIR/libstd.rs:278:28 | LL | fn test_rangeinclusive(_x: Rangeinclusive<()>){} | ^^^^^^^^^^^^^^ not found in this scope + | +help: consider importing one of these similarly named structs + | +LL + use std::range::RangeInclusive; + | +LL + use std::range::legacy::RangeInclusive; + | error[E0425]: cannot find type `Rangeto` in this scope --> $DIR/libstd.rs:280:21 | LL | fn test_rangeto(_x: Rangeto<()>){} | ^^^^^^^ not found in this scope + | +help: consider importing this similarly named struct + | +LL + use std::range::RangeTo; + | error[E0425]: cannot find type `RangetoInclusive` in this scope --> $DIR/libstd.rs:282:30 | LL | fn test_rangetoinclusive(_x: RangetoInclusive<()>){} | ^^^^^^^^^^^^^^^^ not found in this scope + | +help: consider importing one of these similarly named structs + | +LL + use std::range::RangeToInclusive; + | +LL + use std::range::legacy::RangeToInclusive; + | error[E0425]: cannot find type `AssertUnwindsafe` in this scope --> $DIR/libstd.rs:287:30 | LL | fn test_assertunwindsafe(_x: AssertUnwindsafe<()>){} | ^^^^^^^^^^^^^^^^ not found in this scope + | +help: consider importing this similarly named struct + | +LL + use std::panic::AssertUnwindSafe; + | error[E0425]: cannot find type `location` in this scope --> $DIR/libstd.rs:289:22 | LL | fn test_location(_x: location<()>){} | ^^^^^^^^ not found in this scope + | +help: consider importing this similarly named struct + | +LL + use std::panic::Location; + | error[E0425]: cannot find type `Panicinfo` in this scope --> $DIR/libstd.rs:291:23 | LL | fn test_panicinfo(_x: Panicinfo<()>){} | ^^^^^^^^^ not found in this scope + | +help: consider importing this similarly named type alias + | +LL + use std::panic::PanicInfo; + | error[E0425]: cannot find type `ancestors` in this scope --> $DIR/libstd.rs:296:23 | LL | fn test_ancestors(_x: ancestors){} | ^^^^^^^^^ not found in this scope + | +help: consider importing this similarly named struct + | +LL + use std::path::Ancestors; + | error[E0425]: cannot find type `components` in this scope --> $DIR/libstd.rs:298:24 | LL | fn test_components(_x: components){} | ^^^^^^^^^^ not found in this scope + | +help: consider importing this similarly named struct + | +LL + use std::path::Components; + | error[E0425]: cannot find type `Pathbuf` in this scope --> $DIR/libstd.rs:300:21 | LL | fn test_pathbuf(_x: Pathbuf){} | ^^^^^^^ not found in this scope + | +help: consider importing this similarly named struct + | +LL + use std::path::PathBuf; + | error[E0425]: cannot find type `Prefixcomponent` in this scope --> $DIR/libstd.rs:302:29 | LL | fn test_prefixcomponent(_x: Prefixcomponent){} | ^^^^^^^^^^^^^^^ not found in this scope + | +help: consider importing this similarly named struct + | +LL + use std::path::PrefixComponent; + | error[E0425]: cannot find type `pin` in this scope --> $DIR/libstd.rs:307:17 | LL | fn test_pin(_x: pin<()>){} | ^^^ not found in this scope + | +help: consider importing this similarly named struct + | +LL + use std::pin::Pin; + | error[E0425]: cannot find type `child` in this scope --> $DIR/libstd.rs:312:19 | LL | fn test_child(_x: child){} | ^^^^^ not found in this scope + | +help: consider importing this similarly named struct + | +LL + use std::process::Child; + | error[E0425]: cannot find type `ChildStdErr` in this scope --> $DIR/libstd.rs:314:25 | LL | fn test_childstderr(_x: ChildStdErr){} | ^^^^^^^^^^^ not found in this scope + | +help: consider importing this similarly named struct + | +LL + use std::process::ChildStderr; + | error[E0425]: cannot find type `ChildStdIn` in this scope --> $DIR/libstd.rs:316:24 | LL | fn test_childstdin(_x: ChildStdIn){} | ^^^^^^^^^^ not found in this scope + | +help: consider importing this similarly named struct + | +LL + use std::process::ChildStdin; + | error[E0425]: cannot find type `ChildStdOut` in this scope --> $DIR/libstd.rs:318:25 | LL | fn test_childstdout(_x: ChildStdOut){} | ^^^^^^^^^^^ not found in this scope + | +help: consider importing this similarly named struct + | +LL + use std::process::ChildStdout; + | error[E0425]: cannot find type `command` in this scope --> $DIR/libstd.rs:320:21 | LL | fn test_command(_x: command){} | ^^^^^^^ not found in this scope + | +help: consider importing this similarly named struct + | +LL + use std::process::Command; + | error[E0425]: cannot find type `Exitstatus` in this scope --> $DIR/libstd.rs:322:24 | LL | fn test_exitstatus(_x: Exitstatus){} | ^^^^^^^^^^ not found in this scope + | +help: consider importing this similarly named struct + | +LL + use std::process::ExitStatus; + | error[E0425]: cannot find type `output` in this scope --> $DIR/libstd.rs:324:20 | LL | fn test_output(_x: output){} | ^^^^^^ not found in this scope + | +help: consider importing this similarly named struct + | +LL + use std::process::Output; + | error[E0425]: cannot find type `StdIo` in this scope --> $DIR/libstd.rs:326:19 | LL | fn test_stdio(_x: StdIo){} | ^^^^^ not found in this scope + | +help: consider importing this similarly named struct + | +LL + use std::process::Stdio; + | error[E0425]: cannot find type `Nonnull` in this scope --> $DIR/libstd.rs:331:21 | LL | fn test_nonnull(_x: Nonnull<()>){} | ^^^^^^^ not found in this scope + | +help: consider importing this similarly named struct + | +LL + use std::ptr::NonNull; + | error[E0425]: cannot find type `rc` in this scope --> $DIR/libstd.rs:336:16 | LL | fn test_rc(_x: rc<()>){} | ^^ not found in this scope + | +help: consider importing this similarly named struct + | +LL + use std::rc::Rc; + | error[E0425]: cannot find type `weak` in this scope --> $DIR/libstd.rs:338:18 | LL | fn test_weak(_x: weak<()>){} | ^^^^ not found in this scope + | +help: consider importing one of these similarly named structs + | +LL + use std::rc::Weak; + | +LL + use std::sync::Weak; + | error[E0425]: cannot find type `drain` in this scope --> $DIR/libstd.rs:343:19 | LL | fn test_drain(_x: drain){} | ^^^^^ not found in this scope + | +help: consider importing one of these similarly named structs + | +LL + use std::collections::binary_heap::Drain; + | +LL + use std::collections::hash_map::Drain; + | +LL + use std::collections::hash_set::Drain; + | +LL + use std::collections::vec_deque::Drain; + | + = and 2 other candidates error[E0425]: cannot find type `Charindices` in this scope --> $DIR/libstd.rs:348:25 | LL | fn test_charindices(_x: Charindices){} | ^^^^^^^^^^^ not found in this scope + | +help: consider importing this similarly named struct + | +LL + use std::str::CharIndices; + | error[E0425]: cannot find type `chars` in this scope --> $DIR/libstd.rs:350:19 @@ -831,192 +1539,370 @@ error[E0425]: cannot find type `EncodeUTF16` in this scope | LL | fn test_encodeutf16(_x: EncodeUTF16){} | ^^^^^^^^^^^ not found in this scope + | +help: consider importing this similarly named struct + | +LL + use std::str::EncodeUtf16; + | error[E0425]: cannot find type `Matchindices` in this scope --> $DIR/libstd.rs:354:26 | LL | fn test_matchindices(_x: Matchindices){} | ^^^^^^^^^^^^ not found in this scope + | +help: consider importing this similarly named struct + | +LL + use std::str::MatchIndices; + | error[E0425]: cannot find type `RmatchIndices` in this scope --> $DIR/libstd.rs:356:27 | LL | fn test_rmatchindices(_x: RmatchIndices){} | ^^^^^^^^^^^^^ not found in this scope + | +help: consider importing this similarly named struct + | +LL + use std::str::RMatchIndices; + | error[E0425]: cannot find type `Rmatches` in this scope --> $DIR/libstd.rs:358:22 | LL | fn test_rmatches(_x: Rmatches){} | ^^^^^^^^ not found in this scope + | +help: consider importing this similarly named struct + | +LL + use std::str::RMatches; + | error[E0425]: cannot find type `Rsplit` in this scope --> $DIR/libstd.rs:360:20 | LL | fn test_rsplit(_x: Rsplit){} | ^^^^^^ not found in this scope + | +help: consider importing one of these similarly named structs + | +LL + use std::slice::RSplit; + | +LL + use std::str::RSplit; + | error[E0425]: cannot find type `RSplitn` in this scope --> $DIR/libstd.rs:362:21 | LL | fn test_rsplitn(_x: RSplitn){} | ^^^^^^^ not found in this scope + | +help: consider importing one of these similarly named structs + | +LL + use std::slice::RSplitN; + | +LL + use std::str::RSplitN; + | error[E0425]: cannot find type `RsplitTerminator` in this scope --> $DIR/libstd.rs:364:30 | LL | fn test_rsplitterminator(_x: RsplitTerminator){} | ^^^^^^^^^^^^^^^^ not found in this scope + | +help: consider importing this similarly named struct + | +LL + use std::str::RSplitTerminator; + | error[E0425]: cannot find type `SplitASCIIWhitespace` in this scope --> $DIR/libstd.rs:366:34 | LL | fn test_splitasciiwhitespace(_x: SplitASCIIWhitespace){} | ^^^^^^^^^^^^^^^^^^^^ not found in this scope + | +help: consider importing this similarly named struct + | +LL + use std::str::SplitAsciiWhitespace; + | error[E0425]: cannot find type `Splitn` in this scope --> $DIR/libstd.rs:368:20 | LL | fn test_splitn(_x: Splitn){} | ^^^^^^ not found in this scope + | +help: consider importing one of these similarly named structs + | +LL + use std::slice::SplitN; + | +LL + use std::str::SplitN; + | error[E0425]: cannot find type `Splitterminator` in this scope --> $DIR/libstd.rs:370:29 | LL | fn test_splitterminator(_x: Splitterminator){} | ^^^^^^^^^^^^^^^ not found in this scope + | +help: consider importing this similarly named struct + | +LL + use std::str::SplitTerminator; + | error[E0425]: cannot find type `Splitwhitespace` in this scope --> $DIR/libstd.rs:372:29 | LL | fn test_splitwhitespace(_x: Splitwhitespace){} | ^^^^^^^^^^^^^^^ not found in this scope + | +help: consider importing this similarly named struct + | +LL + use std::str::SplitWhitespace; + | error[E0425]: cannot find type `arc` in this scope --> $DIR/libstd.rs:377:17 | LL | fn test_arc(_x: arc<()>){} | ^^^ not found in this scope + | +help: consider importing this similarly named struct + | +LL + use std::sync::Arc; + | error[E0425]: cannot find type `barrier` in this scope --> $DIR/libstd.rs:379:21 | LL | fn test_barrier(_x: barrier<()>){} | ^^^^^^^ not found in this scope + | +help: consider importing this similarly named struct + | +LL + use std::sync::Barrier; + | error[E0425]: cannot find type `BarrierwaitResult` in this scope --> $DIR/libstd.rs:381:31 | LL | fn test_barrierwaitresult(_x: BarrierwaitResult<()>){} | ^^^^^^^^^^^^^^^^^ not found in this scope + | +help: consider importing this similarly named struct + | +LL + use std::sync::BarrierWaitResult; + | error[E0425]: cannot find type `CondVar` in this scope --> $DIR/libstd.rs:383:21 | LL | fn test_condvar(_x: CondVar<()>){} | ^^^^^^^ not found in this scope + | +help: consider importing one of these similarly named structs + | +LL + use std::sync::Condvar; + | +LL + use std::sync::nonpoison::Condvar; + | error[E0425]: cannot find type `mutex` in this scope --> $DIR/libstd.rs:385:19 | LL | fn test_mutex(_x: mutex<()>){} | ^^^^^ not found in this scope + | +help: consider importing one of these similarly named structs + | +LL + use std::sync::Mutex; + | +LL + use std::sync::nonpoison::Mutex; + | error[E0425]: cannot find type `Mutexguard` in this scope --> $DIR/libstd.rs:387:24 | LL | fn test_mutexguard(_x: Mutexguard<()>){} | ^^^^^^^^^^ not found in this scope + | +help: consider importing one of these similarly named structs + | +LL + use std::sync::MutexGuard; + | +LL + use std::sync::nonpoison::MutexGuard; + | error[E0425]: cannot find type `RWlock` in this scope --> $DIR/libstd.rs:389:20 | LL | fn test_rwlock(_x: RWlock<()>){} | ^^^^^^ not found in this scope + | +help: consider importing one of these similarly named structs + | +LL + use std::sync::RwLock; + | +LL + use std::sync::nonpoison::RwLock; + | error[E0425]: cannot find type `RWlockReadGuard` in this scope --> $DIR/libstd.rs:391:29 | LL | fn test_rwlockreadguard(_x: RWlockReadGuard<()>){} | ^^^^^^^^^^^^^^^ not found in this scope + | +help: consider importing one of these similarly named structs + | +LL + use std::sync::RwLockReadGuard; + | +LL + use std::sync::nonpoison::RwLockReadGuard; + | error[E0425]: cannot find type `RWlockWriteGuard` in this scope --> $DIR/libstd.rs:393:30 | LL | fn test_rwlockwriteguard(_x: RWlockWriteGuard<()>){} | ^^^^^^^^^^^^^^^^ not found in this scope + | +help: consider importing one of these similarly named structs + | +LL + use std::sync::RwLockWriteGuard; + | +LL + use std::sync::nonpoison::RwLockWriteGuard; + | error[E0425]: cannot find type `WaittimeoutResult` in this scope --> $DIR/libstd.rs:395:31 | LL | fn test_waittimeoutresult(_x: WaittimeoutResult<()>){} | ^^^^^^^^^^^^^^^^^ not found in this scope + | +help: consider importing this similarly named struct + | +LL + use std::sync::WaitTimeoutResult; + | error[E0425]: cannot find type `context` in this scope --> $DIR/libstd.rs:400:21 | LL | fn test_context(_x: context){} | ^^^^^^^ not found in this scope + | +help: consider importing this similarly named struct + | +LL + use std::task::Context; + | error[E0425]: cannot find type `Rawwaker` in this scope --> $DIR/libstd.rs:402:22 | LL | fn test_rawwaker(_x: Rawwaker){} | ^^^^^^^^ not found in this scope + | +help: consider importing this similarly named struct + | +LL + use std::task::RawWaker; + | error[E0425]: cannot find type `RawwakerVTable` in this scope --> $DIR/libstd.rs:404:28 | LL | fn test_rawwakervtable(_x: RawwakerVTable){} | ^^^^^^^^^^^^^^ not found in this scope + | +help: consider importing this similarly named struct + | +LL + use std::task::RawWakerVTable; + | error[E0425]: cannot find type `waker` in this scope --> $DIR/libstd.rs:406:19 | LL | fn test_waker(_x: waker){} | ^^^^^ not found in this scope + | +help: consider importing this similarly named struct + | +LL + use std::task::Waker; + | error[E0425]: cannot find type `builder` in this scope --> $DIR/libstd.rs:411:21 | LL | fn test_builder(_x: builder){} | ^^^^^^^ not found in this scope + | +help: consider importing this similarly named struct + | +LL + use std::thread::Builder; + | error[E0425]: cannot find type `Joinhandle` in this scope --> $DIR/libstd.rs:413:24 | LL | fn test_joinhandle(_x: Joinhandle<()>){} | ^^^^^^^^^^ not found in this scope + | +help: consider importing this similarly named struct + | +LL + use std::thread::JoinHandle; + | error[E0425]: cannot find type `Localkey` in this scope --> $DIR/libstd.rs:415:22 | LL | fn test_localkey(_x: Localkey<()>){} | ^^^^^^^^ not found in this scope + | +help: consider importing this similarly named struct + | +LL + use std::thread::LocalKey; + | error[E0425]: cannot find type `thread` in this scope --> $DIR/libstd.rs:417:20 | LL | fn test_thread(_x: thread){} | ^^^^^^ not found in this scope + | +help: consider importing this similarly named struct + | +LL + use std::thread::Thread; + | error[E0425]: cannot find type `ThreadID` in this scope --> $DIR/libstd.rs:419:22 | LL | fn test_threadid(_x: ThreadID){} | ^^^^^^^^ not found in this scope + | +help: consider importing this similarly named struct + | +LL + use std::thread::ThreadId; + | error[E0425]: cannot find type `duration` in this scope --> $DIR/libstd.rs:424:22 | LL | fn test_duration(_x: duration){} | ^^^^^^^^ not found in this scope + | +help: consider importing this similarly named struct + | +LL + use std::time::Duration; + | error[E0425]: cannot find type `instant` in this scope --> $DIR/libstd.rs:426:21 | LL | fn test_instant(_x: instant){} | ^^^^^^^ not found in this scope + | +help: consider importing this similarly named struct + | +LL + use std::time::Instant; + | error[E0425]: cannot find type `Systemtime` in this scope --> $DIR/libstd.rs:428:24 diff --git a/tests/ui/parser/raw/raw-literal-keywords.stderr b/tests/ui/parser/raw/raw-literal-keywords.stderr index f7b6c894a90fe..7c7322d12d338 100644 --- a/tests/ui/parser/raw/raw-literal-keywords.stderr +++ b/tests/ui/parser/raw/raw-literal-keywords.stderr @@ -27,12 +27,22 @@ error[E0425]: cannot find value `r#struct` in this scope | LL | let _ = r#struct; | ^^^^^^^^ not found in this scope + | +help: consider importing this similarly named tuple variant + | +LL + use std::mem::type_info::TypeKind::Struct; + | error[E0425]: cannot find value `union` in this scope --> $DIR/raw-literal-keywords.rs:22:13 | LL | let _ = r#union; | ^^^^^^^ not found in this scope + | +help: consider importing this similarly named tuple variant + | +LL + use std::mem::type_info::TypeKind::Union; + | error: aborting due to 6 previous errors diff --git a/tests/ui/pattern/struct-pattern-with-missing-fields-resolve-error.stderr b/tests/ui/pattern/struct-pattern-with-missing-fields-resolve-error.stderr index b8c6f1d867a19..1c8c7ec634e2a 100644 --- a/tests/ui/pattern/struct-pattern-with-missing-fields-resolve-error.stderr +++ b/tests/ui/pattern/struct-pattern-with-missing-fields-resolve-error.stderr @@ -13,6 +13,11 @@ LL | if let Website { url, .. } = website { | ------------------- this pattern doesn't include `title`, which is available in `Website` LL | println!("[{}]({})", title, url); | ^^^^^ not found in this scope + | +help: consider importing this similarly named unit variant + | +LL + use std::char::CharCase::Title; + | error[E0425]: cannot find value `a` in this scope --> $DIR/struct-pattern-with-missing-fields-resolve-error.rs:28:20 diff --git a/tests/ui/resolve/export-fully-qualified-2018.stderr b/tests/ui/resolve/export-fully-qualified-2018.stderr index 25c9e6fbdab96..1246d51a7fca1 100644 --- a/tests/ui/resolve/export-fully-qualified-2018.stderr +++ b/tests/ui/resolve/export-fully-qualified-2018.stderr @@ -5,6 +5,10 @@ LL | pub fn bar() { foo::baz(); } | ^^^ use of unresolved module or unlinked crate `foo` | = help: you might be missing a crate named `foo` +help: consider importing this module + | +LL + use crate::foo; + | error: aborting due to 1 previous error diff --git a/tests/ui/resolve/export-fully-qualified.stderr b/tests/ui/resolve/export-fully-qualified.stderr index f8433dcfb8924..c9514d34b8d0f 100644 --- a/tests/ui/resolve/export-fully-qualified.stderr +++ b/tests/ui/resolve/export-fully-qualified.stderr @@ -5,6 +5,10 @@ LL | pub fn bar() { foo::baz(); } | ^^^ use of unresolved module or unlinked crate `foo` | = help: you might be missing a crate named `foo` +help: consider importing this module + | +LL + use foo; + | error: aborting due to 1 previous error diff --git a/tests/ui/resolve/resolve-assoc-suggestions.stderr b/tests/ui/resolve/resolve-assoc-suggestions.stderr index e6311962884f1..37fccacec69e9 100644 --- a/tests/ui/resolve/resolve-assoc-suggestions.stderr +++ b/tests/ui/resolve/resolve-assoc-suggestions.stderr @@ -3,6 +3,13 @@ error[E0425]: cannot find type `field` in this scope | LL | let _: field; | ^^^^^ not found in this scope + | +help: consider importing one of these similarly named items + | +LL + use std::field::Field; + | +LL + use std::mem::type_info::Field; + | error[E0531]: cannot find tuple struct or tuple variant `field` in this scope --> $DIR/resolve-assoc-suggestions.rs:18:13 diff --git a/tests/ui/resolve/resolve-speculative-adjustment.stderr b/tests/ui/resolve/resolve-speculative-adjustment.stderr index fb15472bdae8d..e03d0cb2088ab 100644 --- a/tests/ui/resolve/resolve-speculative-adjustment.stderr +++ b/tests/ui/resolve/resolve-speculative-adjustment.stderr @@ -3,6 +3,11 @@ error[E0425]: cannot find value `field` in this scope | LL | field; | ^^^^^ not found in this scope + | +help: consider importing this similarly named function + | +LL + use std::intrinsics::mir::Field; + | error[E0425]: cannot find value `field` in this scope --> $DIR/resolve-speculative-adjustment.rs:23:9 diff --git a/tests/ui/suggestions/crate-or-module-typo.stderr b/tests/ui/suggestions/crate-or-module-typo.stderr index 49ac1c89ab52a..59d6c64b1b934 100644 --- a/tests/ui/suggestions/crate-or-module-typo.stderr +++ b/tests/ui/suggestions/crate-or-module-typo.stderr @@ -21,6 +21,17 @@ LL - use bas::bar; LL + use bar::bar; | +error[E0433]: cannot find module or crate `bar` in this scope + --> $DIR/crate-or-module-typo.rs:6:20 + | +LL | pub fn bar() { bar::baz(); } + | ^^^ function `bar` is not a crate or module + | +help: consider importing this module + | +LL + use crate::bar; + | + error[E0433]: cannot find module or crate `st` in this scope --> $DIR/crate-or-module-typo.rs:14:10 | @@ -41,12 +52,6 @@ LL - bar: st::cell::Cell LL + bar: cell::Cell | -error[E0433]: cannot find module or crate `bar` in this scope - --> $DIR/crate-or-module-typo.rs:6:20 - | -LL | pub fn bar() { bar::baz(); } - | ^^^ function `bar` is not a crate or module - error: aborting due to 4 previous errors Some errors have detailed explanations: E0432, E0433. From 1a3cb1fb0bff062b2686ac45640443ed965ed773 Mon Sep 17 00:00:00 2001 From: GTimothy <22472919+GTimothy@users.noreply.github.com> Date: Mon, 14 Sep 2026 16:22:55 +0200 Subject: [PATCH 04/12] add test with callee (433 err) --- tests/ui/imports/case-insensitive/libstd.rs | 5 ++++- tests/ui/imports/case-insensitive/libstd.stderr | 11 +++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/tests/ui/imports/case-insensitive/libstd.rs b/tests/ui/imports/case-insensitive/libstd.rs index 45463a5467cd9..48a9b3e50d661 100644 --- a/tests/ui/imports/case-insensitive/libstd.rs +++ b/tests/ui/imports/case-insensitive/libstd.rs @@ -436,4 +436,7 @@ mod st{ struct SystemTame{} } -fn main(){} +fn main(){ + let _ = Hashmap::new(); + //~^ ERROR: cannot find type `Hashmap` in this scope +} diff --git a/tests/ui/imports/case-insensitive/libstd.stderr b/tests/ui/imports/case-insensitive/libstd.stderr index 7cf3b5a604f9a..295dc144d0099 100644 --- a/tests/ui/imports/case-insensitive/libstd.stderr +++ b/tests/ui/imports/case-insensitive/libstd.stderr @@ -1938,6 +1938,13 @@ help: consider importing this struct LL + use std::time::SystemTime; | -error: aborting due to 168 previous errors +error[E0433]: cannot find type `Hashmap` in this scope + --> $DIR/libstd.rs:440:13 + | +LL | let _ = Hashmap::new(); + | ^^^^^^^ use of undeclared type `Hashmap` + +error: aborting due to 169 previous errors -For more information about this error, try `rustc --explain E0425`. +Some errors have detailed explanations: E0425, E0433. +For more information about an error, try `rustc --explain E0425`. From 1a9555bf3fbe44dd6bb9c8df61bec7b97c2d0f28 Mon Sep 17 00:00:00 2001 From: GTimothy <22472919+GTimothy@users.noreply.github.com> Date: Mon, 14 Sep 2026 16:30:49 +0200 Subject: [PATCH 05/12] unneeded 1046 --- compiler/rustc_resolve/src/late/diagnostics.rs | 3 --- 1 file changed, 3 deletions(-) diff --git a/compiler/rustc_resolve/src/late/diagnostics.rs b/compiler/rustc_resolve/src/late/diagnostics.rs index 4a65c9a7bf571..c66196d0e1c5b 100644 --- a/compiler/rustc_resolve/src/late/diagnostics.rs +++ b/compiler/rustc_resolve/src/late/diagnostics.rs @@ -1043,9 +1043,6 @@ impl<'ast, 'ra, 'tcx> LateResolutionVisitor<'_, 'ast, 'ra, 'tcx> { // Put them back if we have no more candidates to suggest... candidates = intrinsic_candidates; } - if !case_sensitive { - return (false, suggested_candidates, candidates); - } let crate_def_id = CRATE_DEF_ID.to_def_id(); if candidates.is_empty() && is_expected(Res::Def(DefKind::Enum, crate_def_id)) { let mut enum_candidates: Vec<_> = self From eaeb719af2515b37be9f24530c7c42106b3373b9 Mon Sep 17 00:00:00 2001 From: GTimothy <22472919+GTimothy@users.noreply.github.com> Date: Mon, 14 Sep 2026 16:26:36 +0200 Subject: [PATCH 06/12] unneeded 997 --- .../rustc_resolve/src/late/diagnostics.rs | 31 ---------------- .../target-expr-removal-defs-inside.stderr | 36 +++++++++++++++++++ ...-param-decl-on-type-instead-of-impl.stderr | 19 +++++++--- 3 files changed, 50 insertions(+), 36 deletions(-) diff --git a/compiler/rustc_resolve/src/late/diagnostics.rs b/compiler/rustc_resolve/src/late/diagnostics.rs index c66196d0e1c5b..a9ee0576e8aa3 100644 --- a/compiler/rustc_resolve/src/late/diagnostics.rs +++ b/compiler/rustc_resolve/src/late/diagnostics.rs @@ -994,37 +994,6 @@ impl<'ast, 'ra, 'tcx> LateResolutionVisitor<'_, 'ast, 'ra, 'tcx> { .lookup_import_candidates_impl(ident, ns, &self.parent_scope, ident_filter, is_expected) .into_iter() .filter(|ImportSuggestion { did, .. }| { - if !case_sensitive { - // If there's a following segment, only keep modules that contain it - if let Some(following) = following_seg { - let Some(did) = did else { return false }; - let Some(module) = self.r.get_module(*did) else { return false }; - let mut found = false; - module.for_each_child(self.r, |_, ident, _, _, _| { - if ident.name == following.ident.name { - found = true; - } - }); - if !found { - return false; - } - } - - // Filter out items that are in the prelude - if let Some(prelude) = self.r.prelude { - if let Some(suggestion_did) = did { - let mut is_in_prelude = false; - prelude.for_each_child(self.r, |_, _, _, _, decl| { - if decl.res().opt_def_id() == Some(*suggestion_did) { - is_in_prelude = true; - } - }); - if is_in_prelude { - return false; - } - } - } - } match (did, res.and_then(|res| res.opt_def_id())) { (Some(suggestion_did), Some(actual_did)) => *suggestion_did != actual_did, _ => true, diff --git a/tests/ui/delegation/target-expr-removal-defs-inside.stderr b/tests/ui/delegation/target-expr-removal-defs-inside.stderr index eb3540801adea..b264050f8a4c1 100644 --- a/tests/ui/delegation/target-expr-removal-defs-inside.stderr +++ b/tests/ui/delegation/target-expr-removal-defs-inside.stderr @@ -5,6 +5,15 @@ LL | some::path::<{ fn foo() {} }>::xd(); | ^^^^ use of unresolved module or unlinked crate `some` | = help: you might be missing a crate named `some` +help: consider importing this module + | +LL + use std::path; + | +help: if you import `path`, refer to it directly + | +LL - some::path::<{ fn foo() {} }>::xd(); +LL + path::<{ fn foo() {} }>::xd(); + | error[E0433]: cannot find module or crate `some` in this scope --> $DIR/target-expr-removal-defs-inside.rs:49:5 @@ -14,6 +23,15 @@ LL | some::path::<{ fn foo() {} }>::xd(); | = help: you might be missing a crate named `some` = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` +help: consider importing this module + | +LL + use std::path; + | +help: if you import `path`, refer to it directly + | +LL - some::path::<{ fn foo() {} }>::xd(); +LL + path::<{ fn foo() {} }>::xd(); + | error[E0433]: cannot find module or crate `some` in this scope --> $DIR/target-expr-removal-defs-inside.rs:49:5 @@ -23,6 +41,15 @@ LL | some::path::<{ fn foo() {} }>::xd(); | = help: you might be missing a crate named `some` = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` +help: consider importing this module + | +LL + use std::path; + | +help: if you import `path`, refer to it directly + | +LL - some::path::<{ fn foo() {} }>::xd(); +LL + path::<{ fn foo() {} }>::xd(); + | error[E0433]: cannot find module or crate `some` in this scope --> $DIR/target-expr-removal-defs-inside.rs:49:5 @@ -32,6 +59,15 @@ LL | some::path::<{ fn foo() {} }>::xd(); | = help: you might be missing a crate named `some` = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` +help: consider importing this module + | +LL + use std::path; + | +help: if you import `path`, refer to it directly + | +LL - some::path::<{ fn foo() {} }>::xd(); +LL + path::<{ fn foo() {} }>::xd(); + | error: attempted to delete delegation's target expression that contains definitions inside --> $DIR/target-expr-removal-defs-inside.rs:16:24 diff --git a/tests/ui/parser/const-param-decl-on-type-instead-of-impl.stderr b/tests/ui/parser/const-param-decl-on-type-instead-of-impl.stderr index 7aba69a0cf5a0..14527ec2ce007 100644 --- a/tests/ui/parser/const-param-decl-on-type-instead-of-impl.stderr +++ b/tests/ui/parser/const-param-decl-on-type-instead-of-impl.stderr @@ -22,6 +22,12 @@ error: unexpected `const` parameter declaration LL | path::path::Struct::() | ^^^^^^^^^^^^^^ expected a `const` expression, not a parameter declaration +error[E0425]: cannot find type `T` in this scope + --> $DIR/const-param-decl-on-type-instead-of-impl.rs:8:15 + | +LL | fn banana(a: >::BAR) {} + | ^ not found in this scope + error[E0433]: cannot find module or crate `path` in this scope --> $DIR/const-param-decl-on-type-instead-of-impl.rs:12:5 | @@ -29,12 +35,15 @@ LL | path::path::Struct::() | ^^^^ use of unresolved module or unlinked crate `path` | = help: you might be missing a crate named `path` - -error[E0425]: cannot find type `T` in this scope - --> $DIR/const-param-decl-on-type-instead-of-impl.rs:8:15 +help: consider importing this module + | +LL + use std::path; + | +help: if you import `path`, refer to it directly + | +LL - path::path::Struct::() +LL + path::Struct::() | -LL | fn banana(a: >::BAR) {} - | ^ not found in this scope error[E0308]: mismatched types --> $DIR/const-param-decl-on-type-instead-of-impl.rs:5:17 From c81069aab0c880ae9e503ee6eb55ab90945fa669 Mon Sep 17 00:00:00 2001 From: GTimothy <22472919+GTimothy@users.noreply.github.com> Date: Sat, 19 Sep 2026 14:47:12 +0200 Subject: [PATCH 07/12] unneeded 976 --- .../rustc_resolve/src/late/diagnostics.rs | 13 +------- tests/ui/delegation/bad-resolve.rs | 5 ++-- tests/ui/delegation/bad-resolve.stderr | 30 ++++++++++++++----- .../target-expr-removal-defs-inside.stderr | 16 +++++----- .../case-insensitive-import.stderr | 25 +++++++++++----- .../ui/imports/case-insensitive/libstd.stderr | 5 ++++ ...-param-decl-on-type-instead-of-impl.stderr | 4 +-- .../export-fully-qualified-2018.stderr | 4 --- .../ui/resolve/export-fully-qualified.stderr | 4 --- .../suggestions/crate-or-module-typo.stderr | 17 ++++------- 10 files changed, 65 insertions(+), 58 deletions(-) diff --git a/compiler/rustc_resolve/src/late/diagnostics.rs b/compiler/rustc_resolve/src/late/diagnostics.rs index a9ee0576e8aa3..5991d63c6bbd3 100644 --- a/compiler/rustc_resolve/src/late/diagnostics.rs +++ b/compiler/rustc_resolve/src/late/diagnostics.rs @@ -973,18 +973,7 @@ impl<'ast, 'ra, 'tcx> LateResolutionVisitor<'_, 'ast, 'ra, 'tcx> { ident.name.as_str().to_lowercase() == ident_lookup.name.as_str().to_lowercase() } }; - let is_expected = &|res| { - if case_sensitive { - source.is_expected(res) - } else { - if following_seg.is_none() { - source.is_expected(res) - } else { - matches!(res, Res::Def(DefKind::Mod, _)) //fixme(GTimothy):check that this is - // necessary/correct - } - } - }; + let is_expected = &|res| source.is_expected(res); let ns = source.namespace(); let is_enum_variant = &|res| matches!(res, Res::Def(DefKind::Variant, _)); let path_str = Segment::names_to_string(path); diff --git a/tests/ui/delegation/bad-resolve.rs b/tests/ui/delegation/bad-resolve.rs index eb31c20081461..d312ad14c8143 100644 --- a/tests/ui/delegation/bad-resolve.rs +++ b/tests/ui/delegation/bad-resolve.rs @@ -41,7 +41,8 @@ impl Trait for S { mod prefix {} reuse unresolved_prefix::{a, b, c}; //~ ERROR cannot find module or crate `unresolved_prefix` -reuse prefix::{self, super, crate}; //~ ERROR `crate` in paths can only be used in start position -//~^ ERROR cannot find function `self` in module `prefix` +reuse prefix::{self, super, crate}; //~ ERROR `super` in paths can only be used in start position +//~^ ERROR `crate` in paths can only be used in start position +//~^^ ERROR cannot find function `self` in module `prefix` fn main() {} diff --git a/tests/ui/delegation/bad-resolve.stderr b/tests/ui/delegation/bad-resolve.stderr index 1e787c224e8b3..d9135bb83c178 100644 --- a/tests/ui/delegation/bad-resolve.stderr +++ b/tests/ui/delegation/bad-resolve.stderr @@ -92,6 +92,28 @@ LL | reuse prefix::{self, super, crate}; | = note: a module named `prefix::self` exists in another namespace +error[E0433]: `super` in paths can only be used in start position + --> $DIR/bad-resolve.rs:44:22 + | +LL | reuse prefix::{self, super, crate}; + | ^^^^^ can only be used in path start position + | +help: consider importing this similarly named enum + | +LL + use std::path::Prefix; + | + +error[E0433]: `crate` in paths can only be used in start position + --> $DIR/bad-resolve.rs:44:29 + | +LL | reuse prefix::{self, super, crate}; + | ^^^^^ can only be used in path start position + | +help: consider importing this similarly named enum + | +LL + use std::path::Prefix; + | + error[E0186]: method `foo` has a `&self` declaration in the trait, but not in the impl --> $DIR/bad-resolve.rs:34:11 | @@ -118,13 +140,7 @@ LL | reuse unresolved_prefix::{a, b, c}; | = help: you might be missing a crate named `unresolved_prefix` -error[E0433]: `crate` in paths can only be used in start position - --> $DIR/bad-resolve.rs:44:29 - | -LL | reuse prefix::{self, super, crate}; - | ^^^^^ can only be used in path start position - -error: aborting due to 14 previous errors +error: aborting due to 15 previous errors Some errors have detailed explanations: E0046, E0186, E0324, E0407, E0423, E0425, E0433, E0575, E0576. For more information about an error, try `rustc --explain E0046`. diff --git a/tests/ui/delegation/target-expr-removal-defs-inside.stderr b/tests/ui/delegation/target-expr-removal-defs-inside.stderr index b264050f8a4c1..a6f00d7aeb564 100644 --- a/tests/ui/delegation/target-expr-removal-defs-inside.stderr +++ b/tests/ui/delegation/target-expr-removal-defs-inside.stderr @@ -5,9 +5,9 @@ LL | some::path::<{ fn foo() {} }>::xd(); | ^^^^ use of unresolved module or unlinked crate `some` | = help: you might be missing a crate named `some` -help: consider importing this module +help: consider importing this similarly named struct | -LL + use std::path; +LL + use std::path::Path; | help: if you import `path`, refer to it directly | @@ -23,9 +23,9 @@ LL | some::path::<{ fn foo() {} }>::xd(); | = help: you might be missing a crate named `some` = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -help: consider importing this module +help: consider importing this similarly named struct | -LL + use std::path; +LL + use std::path::Path; | help: if you import `path`, refer to it directly | @@ -41,9 +41,9 @@ LL | some::path::<{ fn foo() {} }>::xd(); | = help: you might be missing a crate named `some` = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -help: consider importing this module +help: consider importing this similarly named struct | -LL + use std::path; +LL + use std::path::Path; | help: if you import `path`, refer to it directly | @@ -59,9 +59,9 @@ LL | some::path::<{ fn foo() {} }>::xd(); | = help: you might be missing a crate named `some` = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -help: consider importing this module +help: consider importing this similarly named struct | -LL + use std::path; +LL + use std::path::Path; | help: if you import `path`, refer to it directly | diff --git a/tests/ui/imports/case-insensitive/case-insensitive-import.stderr b/tests/ui/imports/case-insensitive/case-insensitive-import.stderr index 2f30802babc5d..6e0177f269b9c 100644 --- a/tests/ui/imports/case-insensitive/case-insensitive-import.stderr +++ b/tests/ui/imports/case-insensitive/case-insensitive-import.stderr @@ -1,11 +1,3 @@ -error[E0433]: cannot find module or crate `net` in this scope - --> $DIR/case-insensitive-import.rs:21:9 - | -LL | net::shutdown::Both - | ^^^ use of unresolved module or unlinked crate `net` - | - = help: you might be missing a crate named `net` - error[E0433]: cannot find `shutdown` in `net` --> $DIR/case-insensitive-import.rs:24:19 | @@ -81,6 +73,23 @@ help: consider importing this similarly named unit variant LL + use std::net::Shutdown::Both; | +error[E0433]: cannot find module or crate `net` in this scope + --> $DIR/case-insensitive-import.rs:21:9 + | +LL | net::shutdown::Both + | ^^^ use of unresolved module or unlinked crate `net` + | + = help: you might be missing a crate named `net` +help: consider importing this similarly named enum + | +LL + use std::net::Shutdown; + | +help: if you import `shutdown`, refer to it directly + | +LL - net::shutdown::Both +LL + shutdown::Both + | + error: aborting due to 8 previous errors Some errors have detailed explanations: E0425, E0433. diff --git a/tests/ui/imports/case-insensitive/libstd.stderr b/tests/ui/imports/case-insensitive/libstd.stderr index 295dc144d0099..53e9675596afe 100644 --- a/tests/ui/imports/case-insensitive/libstd.stderr +++ b/tests/ui/imports/case-insensitive/libstd.stderr @@ -1943,6 +1943,11 @@ error[E0433]: cannot find type `Hashmap` in this scope | LL | let _ = Hashmap::new(); | ^^^^^^^ use of undeclared type `Hashmap` + | +help: consider importing this similarly named struct + | +LL + use std::collections::HashMap; + | error: aborting due to 169 previous errors diff --git a/tests/ui/parser/const-param-decl-on-type-instead-of-impl.stderr b/tests/ui/parser/const-param-decl-on-type-instead-of-impl.stderr index 14527ec2ce007..39e48b023f764 100644 --- a/tests/ui/parser/const-param-decl-on-type-instead-of-impl.stderr +++ b/tests/ui/parser/const-param-decl-on-type-instead-of-impl.stderr @@ -35,9 +35,9 @@ LL | path::path::Struct::() | ^^^^ use of unresolved module or unlinked crate `path` | = help: you might be missing a crate named `path` -help: consider importing this module +help: consider importing this similarly named struct | -LL + use std::path; +LL + use std::path::Path; | help: if you import `path`, refer to it directly | diff --git a/tests/ui/resolve/export-fully-qualified-2018.stderr b/tests/ui/resolve/export-fully-qualified-2018.stderr index 1246d51a7fca1..25c9e6fbdab96 100644 --- a/tests/ui/resolve/export-fully-qualified-2018.stderr +++ b/tests/ui/resolve/export-fully-qualified-2018.stderr @@ -5,10 +5,6 @@ LL | pub fn bar() { foo::baz(); } | ^^^ use of unresolved module or unlinked crate `foo` | = help: you might be missing a crate named `foo` -help: consider importing this module - | -LL + use crate::foo; - | error: aborting due to 1 previous error diff --git a/tests/ui/resolve/export-fully-qualified.stderr b/tests/ui/resolve/export-fully-qualified.stderr index c9514d34b8d0f..f8433dcfb8924 100644 --- a/tests/ui/resolve/export-fully-qualified.stderr +++ b/tests/ui/resolve/export-fully-qualified.stderr @@ -5,10 +5,6 @@ LL | pub fn bar() { foo::baz(); } | ^^^ use of unresolved module or unlinked crate `foo` | = help: you might be missing a crate named `foo` -help: consider importing this module - | -LL + use foo; - | error: aborting due to 1 previous error diff --git a/tests/ui/suggestions/crate-or-module-typo.stderr b/tests/ui/suggestions/crate-or-module-typo.stderr index 59d6c64b1b934..49ac1c89ab52a 100644 --- a/tests/ui/suggestions/crate-or-module-typo.stderr +++ b/tests/ui/suggestions/crate-or-module-typo.stderr @@ -21,17 +21,6 @@ LL - use bas::bar; LL + use bar::bar; | -error[E0433]: cannot find module or crate `bar` in this scope - --> $DIR/crate-or-module-typo.rs:6:20 - | -LL | pub fn bar() { bar::baz(); } - | ^^^ function `bar` is not a crate or module - | -help: consider importing this module - | -LL + use crate::bar; - | - error[E0433]: cannot find module or crate `st` in this scope --> $DIR/crate-or-module-typo.rs:14:10 | @@ -52,6 +41,12 @@ LL - bar: st::cell::Cell LL + bar: cell::Cell | +error[E0433]: cannot find module or crate `bar` in this scope + --> $DIR/crate-or-module-typo.rs:6:20 + | +LL | pub fn bar() { bar::baz(); } + | ^^^ function `bar` is not a crate or module + error: aborting due to 4 previous errors Some errors have detailed explanations: E0432, E0433. From 7c6c44d451387a09543e5d7932cc392b5f0e423f Mon Sep 17 00:00:00 2001 From: GTimothy <22472919+GTimothy@users.noreply.github.com> Date: Sat, 19 Sep 2026 15:02:20 +0200 Subject: [PATCH 08/12] remove temporary is_exact_match variable --- compiler/rustc_resolve/src/late/diagnostics.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/compiler/rustc_resolve/src/late/diagnostics.rs b/compiler/rustc_resolve/src/late/diagnostics.rs index 5991d63c6bbd3..8728d45207290 100644 --- a/compiler/rustc_resolve/src/late/diagnostics.rs +++ b/compiler/rustc_resolve/src/late/diagnostics.rs @@ -3125,8 +3125,7 @@ impl<'ast, 'ra, 'tcx> LateResolutionVisitor<'_, 'ast, 'ra, 'tcx> { path_segments.push(ast::PathSegment::from_ident(ident.orig(orig_ident_span))); let doc_visible = doc_visible && (module_def_id.is_local() || !r.tcx.is_doc_hidden(module_def_id)); - let is_exact_match = module_def_id == def_id; - if is_exact_match { + if module_def_id == def_id { let path = Path { span: name_binding.span, segments: path_segments }; result = Some(( r.expect_module(module_def_id), @@ -3139,7 +3138,7 @@ impl<'ast, 'ra, 'tcx> LateResolutionVisitor<'_, 'ast, 'ra, 'tcx> { note: None, via_import: false, is_stable: true, - is_exact_match, + is_exact_match: module_def_id == def_id, }, )); } else { From e2fafc0802a54311f4797a74162ad3270c9ccc0b Mon Sep 17 00:00:00 2001 From: GTimothy <22472919+GTimothy@users.noreply.github.com> Date: Sat, 19 Sep 2026 15:28:55 +0200 Subject: [PATCH 09/12] exact_matched instead of is_exact_match --- compiler/rustc_resolve/src/diagnostics/impls.rs | 8 ++++---- compiler/rustc_resolve/src/late/diagnostics.rs | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/compiler/rustc_resolve/src/diagnostics/impls.rs b/compiler/rustc_resolve/src/diagnostics/impls.rs index 9319c1fd2e726..f3da3980e9261 100644 --- a/compiler/rustc_resolve/src/diagnostics/impls.rs +++ b/compiler/rustc_resolve/src/diagnostics/impls.rs @@ -122,7 +122,7 @@ pub(crate) struct ImportSuggestion { /// An extra note that should be issued if this item is suggested pub note: Option, pub is_stable: bool, - pub is_exact_match: bool, + pub exact_matched: bool, } /// Adjust the impl span so that just the `impl` keyword is taken by removing @@ -1754,7 +1754,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { note, via_import, is_stable, - is_exact_match: ident.name == lookup_ident.name, + exact_matched: ident.name == lookup_ident.name, }); } } @@ -3965,7 +3965,7 @@ fn show_candidates( c.did.and_then(|did| Some(tcx.source_span(did.as_local()?))), &c.note, c.via_import, - c.is_exact_match, + c.exact_matched, )) } } else { @@ -3975,7 +3975,7 @@ fn show_candidates( c.did.and_then(|did| Some(tcx.source_span(did.as_local()?))), &c.note, c.via_import, - c.is_exact_match, + c.exact_matched, )) } }); diff --git a/compiler/rustc_resolve/src/late/diagnostics.rs b/compiler/rustc_resolve/src/late/diagnostics.rs index 8728d45207290..83f8793a0d618 100644 --- a/compiler/rustc_resolve/src/late/diagnostics.rs +++ b/compiler/rustc_resolve/src/late/diagnostics.rs @@ -3138,7 +3138,7 @@ impl<'ast, 'ra, 'tcx> LateResolutionVisitor<'_, 'ast, 'ra, 'tcx> { note: None, via_import: false, is_stable: true, - is_exact_match: module_def_id == def_id, + exact_matched: module_def_id == def_id, }, )); } else { From 2256696cf95b981e4facd7a39b9920467c2923d9 Mon Sep 17 00:00:00 2001 From: GTimothy <22472919+GTimothy@users.noreply.github.com> Date: Wed, 23 Sep 2026 17:00:15 +0200 Subject: [PATCH 10/12] undo unnecessary removal L1156 --- compiler/rustc_resolve/src/late/diagnostics.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/compiler/rustc_resolve/src/late/diagnostics.rs b/compiler/rustc_resolve/src/late/diagnostics.rs index 83f8793a0d618..b76f2c2b8c56c 100644 --- a/compiler/rustc_resolve/src/late/diagnostics.rs +++ b/compiler/rustc_resolve/src/late/diagnostics.rs @@ -1191,6 +1191,7 @@ impl<'ast, 'ra, 'tcx> LateResolutionVisitor<'_, 'ast, 'ra, 'tcx> { } } } + if candidates.is_empty() { candidates = self.smart_resolve_partial_mod_path_errors(path, following_seg); } From 9bf7d910cc1d092dae37cd9e947f212b192f7368 Mon Sep 17 00:00:00 2001 From: GTimothy <22472919+GTimothy@users.noreply.github.com> Date: Wed, 23 Sep 2026 18:22:11 +0200 Subject: [PATCH 11/12] turning now 6 fields long PathString into a Struct --- .../rustc_resolve/src/diagnostics/impls.rs | 127 ++++++++++-------- 1 file changed, 74 insertions(+), 53 deletions(-) diff --git a/compiler/rustc_resolve/src/diagnostics/impls.rs b/compiler/rustc_resolve/src/diagnostics/impls.rs index f3da3980e9261..3b250177f6579 100644 --- a/compiler/rustc_resolve/src/diagnostics/impls.rs +++ b/compiler/rustc_resolve/src/diagnostics/impls.rs @@ -3929,7 +3929,15 @@ pub(crate) fn import_candidates( ); } -type PathString<'a> = (String, &'a str, Option, &'a Option, bool, bool); +// type PathString<'a> = (String, &'a str, Option, &'a Option, bool, bool); +struct PathString<'a> { + path: String, + descr: &'a str, + span: Option, + note: &'a Option, + via_import: bool, + exact_matched: bool, +} /// When an entity with a given name is not available in scope, we search for /// entities with that name in all crates. This method allows outputting the @@ -3955,42 +3963,54 @@ fn show_candidates( let mut accessible_path_strings: Vec> = Vec::new(); let mut inaccessible_path_strings: Vec> = Vec::new(); - candidates.iter().for_each(|c| { - if c.accessible { - // Don't suggest `#[doc(hidden)]` items from other crates - if c.doc_visible { - accessible_path_strings.push(( - pprust::path_to_string(&c.path), - c.descr, - c.did.and_then(|did| Some(tcx.source_span(did.as_local()?))), - &c.note, - c.via_import, - c.exact_matched, - )) + candidates.iter().for_each( + |ImportSuggestion { + did, + descr, + path, + accessible, + doc_visible, + via_import, + note, + is_stable: _, + exact_matched, + }| { + if *accessible { + // Don't suggest `#[doc(hidden)]` items from other crates + if *doc_visible { + accessible_path_strings.push(PathString { + path: pprust::path_to_string(path), + descr, + span: did.and_then(|did| Some(tcx.source_span(did.as_local()?))), + note, + via_import: *via_import, + exact_matched: *exact_matched, + }) + } + } else { + inaccessible_path_strings.push(PathString { + path: pprust::path_to_string(path), + descr, + span: did.and_then(|did| Some(tcx.source_span(did.as_local()?))), + note, + via_import: *via_import, + exact_matched: *exact_matched, + }) } - } else { - inaccessible_path_strings.push(( - pprust::path_to_string(&c.path), - c.descr, - c.did.and_then(|did| Some(tcx.source_span(did.as_local()?))), - &c.note, - c.via_import, - c.exact_matched, - )) - } - }); + }, + ); // we want consistent results across executions, but candidates are produced // by iterating through a hash map, so make sure they are ordered: for path_strings in [&mut accessible_path_strings, &mut inaccessible_path_strings] { - path_strings.sort_by(|a, b| a.0.cmp(&b.0)); - path_strings.dedup_by(|a, b| a.0 == b.0); + path_strings.sort_by(|a, b| a.path.cmp(&b.path)); + path_strings.dedup_by(|a, b| a.path == b.path); let core_path_strings = - path_strings.extract_if(.., |p| p.0.starts_with("core::")).collect::>(); + path_strings.extract_if(.., |p| p.path.starts_with("core::")).collect::>(); let std_path_strings = - path_strings.extract_if(.., |p| p.0.starts_with("std::")).collect::>(); + path_strings.extract_if(.., |p| p.path.starts_with("std::")).collect::>(); let foreign_crate_path_strings = - path_strings.extract_if(.., |p| !p.0.starts_with("crate::")).collect::>(); + path_strings.extract_if(.., |p| !p.path.starts_with("crate::")).collect::>(); // We list the `crate` local paths first. // Then we list the `std`/`core` paths. @@ -4007,13 +4027,14 @@ fn show_candidates( if !accessible_path_strings.is_empty() { let (determiner, kind, s, name, through) = - if let [(name, descr, _, _, via_import, is_exact_match)] = &accessible_path_strings[..] + if let [PathString { path, descr, via_import, exact_matched, .. }] = + &accessible_path_strings[..] { ( - if *is_exact_match { "this" } else { "this similarly named" }, + if *exact_matched { "this" } else { "this similarly named" }, *descr, "", - format!(" `{name}`"), + format!(" `{path}`"), if *via_import { " through its public re-export" } else { "" }, ) } else { @@ -4021,15 +4042,15 @@ fn show_candidates( // instead of the more generic "items". let kinds = accessible_path_strings .iter() - .map(|(_, descr, _, _, _, _)| *descr) + .map(|PathString { descr, .. }| *descr) .collect::>(); let kind = if let Some(kind) = kinds.get_only() { kind } else { "item" }; let s = if kind.ends_with('s') { "es" } else { "s" }; // we should only suggest case insensitive suggestion if no case sensitive match was found, - // so all the suggestion should have the same is_exact_match value. + // so all the suggestion should have the same exact_matched value. ( - if accessible_path_strings[0].5 { + if accessible_path_strings[0].exact_matched { "one of these" } else { "one of these similarly named" @@ -4051,7 +4072,7 @@ fn show_candidates( format!("consider importing {determiner} {kind}{s}{through}{instead}") }; - for note in accessible_path_strings.iter().flat_map(|cand| cand.3.as_ref()) { + for note in accessible_path_strings.iter().flat_map(|cand| cand.note.as_ref()) { err.note(note.clone()); } @@ -4060,7 +4081,7 @@ fn show_candidates( for candidate in accessible_path_strings { msg.push('\n'); - msg.push_str(&candidate.0); + msg.push_str(&candidate.path); } }; @@ -4070,7 +4091,7 @@ fn show_candidates( err.span_suggestions( span, msg, - accessible_path_strings.into_iter().map(|a| a.0), + accessible_path_strings.into_iter().map(|a| a.path), Applicability::MaybeIncorrect, ); return true; @@ -4088,8 +4109,8 @@ fn show_candidates( } else { "" }; - candidate.0 = - format!("{add_use}{}{append}{trailing}{additional_newline}", candidate.0); + candidate.path = + format!("{add_use}{}{append}{trailing}{additional_newline}", candidate.path); } match mode { @@ -4101,7 +4122,7 @@ fn show_candidates( err.span_suggestions_with_style( span, msg, - accessible_path_strings.into_iter().map(|a| a.0), + accessible_path_strings.into_iter().map(|a| a.path), Applicability::MaybeIncorrect, SuggestionStyle::ShowAlways, ); @@ -4132,16 +4153,16 @@ fn show_candidates( { let prefix = if let DiagMode::Pattern = mode { "you might have meant to match on " } else { "" }; - if let [(name, descr, source_span, note, _, is_exact_match)] = + if let [PathString { path, descr, span, note, exact_matched, .. }] = &inaccessible_path_strings[..] { let msg = format!( - "{prefix}{}{descr} `{name}`{} exists but is inaccessible", - if *is_exact_match { "" } else { "similarly named " }, + "{prefix}{}{descr} `{path}`{} exists but is inaccessible", + if *exact_matched { "" } else { "similarly named " }, if let DiagMode::Pattern = mode { ", which" } else { "" } ); - if let Some(source_span) = source_span { + if let Some(source_span) = span { let span = tcx.sess.source_map().guess_head_span(*source_span); let mut multi_span = MultiSpan::from_span(span); multi_span.push_span_label(span, "not accessible"); @@ -4155,12 +4176,12 @@ fn show_candidates( } else { let descr = inaccessible_path_strings .iter() - .map(|&(_, descr, _, _, _, _)| descr) + .map(|PathString { descr, .. }| *descr) .all_equal_value() .unwrap_or("item"); let plural_descr = if descr.ends_with('s') { format!("{descr}es") } else { format!("{descr}s") }; - let are_exact_matches = inaccessible_path_strings[0].5; + let are_exact_matches = inaccessible_path_strings[0].exact_matched; let mut msg = format!( "{prefix}these {}{plural_descr} exist but are inaccessible", if are_exact_matches { "" } else { "similarly named " }, @@ -4168,17 +4189,17 @@ fn show_candidates( let mut has_colon = false; let mut spans = Vec::new(); - for (name, _, source_span, _, _, _) in &inaccessible_path_strings { - if let Some(source_span) = source_span { - let span = tcx.sess.source_map().guess_head_span(*source_span); - spans.push((name, span)); + for PathString { path, span, .. } in &inaccessible_path_strings { + if let Some(span) = span { + let span = tcx.sess.source_map().guess_head_span(*span); + spans.push((path, span)); } else { if !has_colon { msg.push(':'); has_colon = true; } msg.push('\n'); - msg.push_str(name); + msg.push_str(path); } } @@ -4187,7 +4208,7 @@ fn show_candidates( multi_span.push_span_label(span, format!("`{name}`: not accessible")); } - for note in inaccessible_path_strings.iter().flat_map(|cand| cand.3.as_ref()) { + for note in inaccessible_path_strings.iter().flat_map(|cand| cand.note.as_ref()) { err.note(note.clone()); } From 3f34fcbbd6b2f323a7525a3b94974e72549c648c Mon Sep 17 00:00:00 2001 From: GTimothy <22472919+GTimothy@users.noreply.github.com> Date: Thu, 24 Sep 2026 17:49:16 +0200 Subject: [PATCH 12/12] use a CaseSensitive enum, delete IdentFilterFn, delete lookup_import_candidates_impl --- .../rustc_resolve/src/diagnostics/impls.rs | 79 ++++++++++--------- compiler/rustc_resolve/src/imports.rs | 10 ++- compiler/rustc_resolve/src/late.rs | 6 ++ .../rustc_resolve/src/late/diagnostics.rs | 35 ++++---- 4 files changed, 75 insertions(+), 55 deletions(-) diff --git a/compiler/rustc_resolve/src/diagnostics/impls.rs b/compiler/rustc_resolve/src/diagnostics/impls.rs index 3b250177f6579..15ba02835f484 100644 --- a/compiler/rustc_resolve/src/diagnostics/impls.rs +++ b/compiler/rustc_resolve/src/diagnostics/impls.rs @@ -50,7 +50,7 @@ use crate::diagnostics::{ }; use crate::hygiene::Macros20NormalizedSyntaxContext; use crate::imports::{Import, ImportKind, UnresolvedImportError, import_path_to_string}; -use crate::late::{DiagMetadata, PatternSource, Rib}; +use crate::late::{CaseSensitive, DiagMetadata, PatternSource, Rib}; use crate::{ AmbiguityError, AmbiguityKind, AmbiguityWarning, BindingError, BindingKey, Decl, DeclKind, DelayedVisResolutionError, Finalize, ForwardGenericParamBanReason, HasGenericParams, IdentKey, @@ -998,6 +998,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { ) ) }, + CaseSensitive::Yes, ); if import_suggestions.is_empty() && !suggested_typo { @@ -1591,18 +1592,17 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { } } - fn lookup_import_candidates_from_module( + fn lookup_import_candidates_from_module( &self, lookup_ident: Ident, namespace: Namespace, parent_scope: &ParentScope<'ra>, start_module: Module<'ra>, crate_path: ThinVec, - ident_filter_fn: IdentFilterFn, + case_sensitive: CaseSensitive, filter_fn: FilterFn, ) -> Vec where - IdentFilterFn: Fn(Ident, Ident) -> bool, FilterFn: Fn(Res) -> bool, { let mut candidates = Vec::new(); @@ -1671,10 +1671,20 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { let child_doc_visible = doc_visible && did.is_none_or(|did| did.is_local() || !this.tcx.is_doc_hidden(did)); + let (ident_matched, exact_matched) = if let CaseSensitive::Yes = case_sensitive { + (ident.name == lookup_ident.name, true) + } else { + ( + ident.name.as_str().to_lowercase() + == lookup_ident.name.as_str().to_lowercase(), + false, + ) + }; + // collect results based on the filter function // avoid suggesting anything from the same module in which we are resolving // avoid suggesting anything with a hygienic name - if ident_filter_fn(ident.orig(orig_ident_span), lookup_ident) + if ident_matched && ns == namespace && in_module != parent_scope.module && ident.ctxt.is_root() @@ -1754,7 +1764,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { note, via_import, is_stable, - exact_matched: ident.name == lookup_ident.name, + exact_matched, }); } } @@ -1839,40 +1849,20 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { namespace: Namespace, parent_scope: &ParentScope<'ra>, filter_fn: FilterFn, + case_sensitive: CaseSensitive, ) -> Vec where FilterFn: Fn(Res) -> bool, - { - self.lookup_import_candidates_impl( - lookup_ident, - namespace, - parent_scope, - |ident: Ident, lookup_ident: Ident| ident.name == lookup_ident.name, - filter_fn, - ) - } - - /// The actual impl of the `lookup_import_candidates function`. - pub(crate) fn lookup_import_candidates_impl( - &self, - lookup_ident: Ident, - namespace: Namespace, - parent_scope: &ParentScope<'ra>, - ident_filter_fn: IdentFilterFn, - filter_fn: FilterFn, - ) -> Vec - where - IdentFilterFn: Fn(Ident, Ident) -> bool, - FilterFn: Fn(Res) -> bool, { let crate_path = thin_vec![ast::PathSegment::from_ident(Ident::with_dummy_span(kw::Crate))]; + let mut suggestions = self.lookup_import_candidates_from_module( lookup_ident, namespace, parent_scope, self.graph_root.to_module(), crate_path, - &ident_filter_fn, + case_sensitive, &filter_fn, ); @@ -1927,7 +1917,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { parent_scope, crate_root, crate_path, - &ident_filter_fn, + case_sensitive, &filter_fn, )); } @@ -1962,8 +1952,13 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { self.detect_derive_attribute(err, ident, parent_scope, sugg_span); } - let import_suggestions = - self.lookup_import_candidates(ident, Namespace::MacroNS, parent_scope, is_expected); + let import_suggestions = self.lookup_import_candidates( + ident, + Namespace::MacroNS, + parent_scope, + is_expected, + CaseSensitive::Yes, + ); let (span, found_use) = match parent_scope.module.nearest_parent_mod_node_id() { DUMMY_NODE_ID => (None, FoundUse::No), node_id => UsePlacementFinder::check(krate, node_id), @@ -2105,10 +2100,13 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { // Not in scope: check if the name refers to a trait importable from elsewhere. if macro_kind == MacroKind::Derive { - let trait_candidates = - self.lookup_import_candidates(ident, TypeNS, parent_scope, |res| { - matches!(res, Res::Def(DefKind::Trait, _)) - }); + let trait_candidates = self.lookup_import_candidates( + ident, + TypeNS, + parent_scope, + |res| matches!(res, Res::Def(DefKind::Trait, _)), + CaseSensitive::Yes, + ); let mut seen = FxHashSet::default(); for candidate in &trait_candidates { if let Some(def_id) = candidate.did @@ -2610,6 +2608,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { this_res.ns().unwrap_or(Namespace::TypeNS), &parent_scope, &|res: Res| res == this_res, + CaseSensitive::Yes, ); // Shorten candidate paths using `super::` or `self::` when possible. for suggestion in &mut import_suggestions { @@ -3018,7 +3017,13 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { if module_def_id == Some(CRATE_DEF_ID.to_def_id()) { let is_mod = |res| matches!(res, Res::Def(DefKind::Mod, _)); - let mut candidates = self.lookup_import_candidates(ident, TypeNS, parent_scope, is_mod); + let mut candidates = self.lookup_import_candidates( + ident, + TypeNS, + parent_scope, + is_mod, + CaseSensitive::Yes, + ); candidates .sort_by_cached_key(|c| (c.path.segments.len(), pprust::path_to_string(&c.path))); if let Some(candidate) = candidates.get(0) { diff --git a/compiler/rustc_resolve/src/imports.rs b/compiler/rustc_resolve/src/imports.rs index 499f9ea297362..cdd3b12011f8b 100644 --- a/compiler/rustc_resolve/src/imports.rs +++ b/compiler/rustc_resolve/src/imports.rs @@ -32,6 +32,7 @@ use crate::diagnostics::{ CannotGlobImportAllCrates, ConsiderAddingMacroExport, ConsiderMarkingAsPub, ConsiderMarkingAsPubCrate, }; +use crate::late::CaseSensitive; use crate::ref_mut::{CmCell, CmRefCell}; use crate::{ AmbiguityError, BindingKey, Decl, DeclData, DeclKind, Determinacy, Finalize, IdentKey, @@ -1571,8 +1572,13 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { } }; - let parent_suggestion = - self.lookup_import_candidates(ident, TypeNS, &import.parent_scope, |_| true); + let parent_suggestion = self.lookup_import_candidates( + ident, + TypeNS, + &import.parent_scope, + |_| true, + CaseSensitive::Yes, + ); Some(UnresolvedImportError { span: import.span, diff --git a/compiler/rustc_resolve/src/late.rs b/compiler/rustc_resolve/src/late.rs index c21d3653a13be..03260877a6e64 100644 --- a/compiler/rustc_resolve/src/late.rs +++ b/compiler/rustc_resolve/src/late.rs @@ -837,6 +837,12 @@ struct LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { use_injections: Vec>, } +#[derive(Copy, Clone, Debug)] +pub(crate) enum CaseSensitive { + Yes, + No, +} + impl<'ra, 'tcx> AsRef> for LateResolutionVisitor<'_, '_, 'ra, 'tcx> { fn as_ref(&self) -> &Resolver<'ra, 'tcx> { &self.r diff --git a/compiler/rustc_resolve/src/late/diagnostics.rs b/compiler/rustc_resolve/src/late/diagnostics.rs index b76f2c2b8c56c..e6690a810a6f6 100644 --- a/compiler/rustc_resolve/src/late/diagnostics.rs +++ b/compiler/rustc_resolve/src/late/diagnostics.rs @@ -35,8 +35,8 @@ use tracing::debug; use super::NoConstantGenericsReason; use crate::diagnostics::impls::{ImportSuggestion, LabelSuggestion, TypoSuggestion}; use crate::late::{ - AliasPossibility, LateResolutionVisitor, LifetimeBinderKind, LifetimeRes, LifetimeRibKind, - LifetimeUseSet, QSelf, RibKind, + AliasPossibility, CaseSensitive, LateResolutionVisitor, LifetimeBinderKind, LifetimeRes, + LifetimeRibKind, LifetimeUseSet, QSelf, RibKind, }; use crate::ty::fast_reject::SimplifiedType; use crate::{ @@ -636,6 +636,7 @@ impl<'ast, 'ra, 'tcx> LateResolutionVisitor<'_, 'ast, 'ra, 'tcx> { Namespace::TypeNS, &self.parent_scope, &|res: Res| matches!(res, Res::Def(DefKind::Mod, _)), + CaseSensitive::Yes, ); // double check next seg is valid candidates @@ -760,7 +761,7 @@ impl<'ast, 'ra, 'tcx> LateResolutionVisitor<'_, 'ast, 'ra, 'tcx> { }; let (found, suggested_candidates, mut candidates) = self.try_lookup_name_relaxed( - true, + CaseSensitive::Yes, &mut err, source, path, @@ -802,7 +803,7 @@ impl<'ast, 'ra, 'tcx> LateResolutionVisitor<'_, 'ast, 'ra, 'tcx> { { candidates = self .try_lookup_name_relaxed( - false, + CaseSensitive::No, &mut err, source, path, @@ -941,7 +942,7 @@ impl<'ast, 'ra, 'tcx> LateResolutionVisitor<'_, 'ast, 'ra, 'tcx> { fn try_lookup_name_relaxed( &mut self, - case_sensitive: bool, // a subset of the tests are run when false + case_sensitive: CaseSensitive, // a subset of the tests are run when false err: &mut Diag<'_>, source: PathSource<'_, '_, '_>, path: &[Segment], @@ -961,18 +962,13 @@ impl<'ast, 'ra, 'tcx> LateResolutionVisitor<'_, 'ast, 'ra, 'tcx> { let mut suggested_candidates = FxHashSet::default(); // Try to lookup name in more relaxed fashion for better error reporting. let ident = path.last().unwrap().ident; - // we do not suggest alternative capitalizations if only one letter, too many constants can match and it become noisy. - if !case_sensitive && ident.as_str().len() < 2 { + // we do not suggest alternative casing if only one letter, too many constants can match and it becomes noisy. + if let CaseSensitive::No = case_sensitive + && ident.as_str().len() < 2 + { return (false, suggested_candidates, Vec::new()); } - let ident_filter = &|ident: Ident, ident_lookup: Ident| { - if case_sensitive { - ident.name == ident_lookup.name - } else { - ident.name.as_str().to_lowercase() == ident_lookup.name.as_str().to_lowercase() - } - }; let is_expected = &|res| source.is_expected(res); let ns = source.namespace(); let is_enum_variant = &|res| matches!(res, Res::Def(DefKind::Variant, _)); @@ -980,7 +976,7 @@ impl<'ast, 'ra, 'tcx> LateResolutionVisitor<'_, 'ast, 'ra, 'tcx> { let ident_span = path.last().map_or(span, |ident| ident.ident.span); let mut candidates = self .r - .lookup_import_candidates_impl(ident, ns, &self.parent_scope, ident_filter, is_expected) + .lookup_import_candidates(ident, ns, &self.parent_scope, is_expected, case_sensitive) .into_iter() .filter(|ImportSuggestion { did, .. }| { match (did, res.and_then(|res| res.opt_def_id())) { @@ -1005,7 +1001,13 @@ impl<'ast, 'ra, 'tcx> LateResolutionVisitor<'_, 'ast, 'ra, 'tcx> { if candidates.is_empty() && is_expected(Res::Def(DefKind::Enum, crate_def_id)) { let mut enum_candidates: Vec<_> = self .r - .lookup_import_candidates(ident, ns, &self.parent_scope, is_enum_variant) + .lookup_import_candidates( + ident, + ns, + &self.parent_scope, + is_enum_variant, + CaseSensitive::Yes, + ) .into_iter() .map(|suggestion| import_candidate_to_enum_paths(&suggestion)) .filter(|(_, enum_ty_path)| !enum_ty_path.starts_with("std::prelude::")) @@ -2749,6 +2751,7 @@ impl<'ast, 'ra, 'tcx> LateResolutionVisitor<'_, 'ast, 'ra, 'tcx> { Namespace::TypeNS, &self.parent_scope, &|res: Res| matches!(res, Res::Def(DefKind::Trait, _)), + CaseSensitive::Yes, ) .iter() .filter_map(|candidate| candidate.did)