When using existing fn as module, don't claim it doesn't exist
Tweak wording of module not found in resolve, when the name exists but belongs to a non-`mod` item. Fix #81232.
This commit is contained in:
parent
6d069a0ac7
commit
890ce26213
3 changed files with 16 additions and 4 deletions
|
@ -2028,9 +2028,21 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
});
|
});
|
||||||
|
if let Ok(binding) = self.early_resolve_ident_in_lexical_scope(
|
||||||
|
ident,
|
||||||
|
ScopeSet::All(ValueNS),
|
||||||
|
parent_scope,
|
||||||
|
None,
|
||||||
|
false,
|
||||||
|
ignore_binding,
|
||||||
|
) {
|
||||||
|
let descr = binding.res().descr();
|
||||||
|
(format!("{descr} `{ident}` is not a crate or module"), suggestion)
|
||||||
|
} else {
|
||||||
(format!("use of undeclared crate or module `{ident}`"), suggestion)
|
(format!("use of undeclared crate or module `{ident}`"), suggestion)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Adds suggestions for a path that cannot be resolved.
|
/// Adds suggestions for a path that cannot be resolved.
|
||||||
pub(crate) fn make_path_suggestion(
|
pub(crate) fn make_path_suggestion(
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
use st::cell::Cell; //~ ERROR failed to resolve: use of undeclared crate or module `st`
|
use st::cell::Cell; //~ ERROR failed to resolve: use of undeclared crate or module `st`
|
||||||
|
|
||||||
mod bar {
|
mod bar {
|
||||||
pub fn bar() { bar::baz(); } //~ ERROR failed to resolve: use of undeclared crate or module `bar`
|
pub fn bar() { bar::baz(); } //~ ERROR failed to resolve: function `bar` is not a crate or module
|
||||||
|
|
||||||
fn baz() {}
|
fn baz() {}
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,11 +42,11 @@ LL - bar: st::cell::Cell<bool>
|
||||||
LL + bar: cell::Cell<bool>
|
LL + bar: cell::Cell<bool>
|
||||||
|
|
|
|
||||||
|
|
||||||
error[E0433]: failed to resolve: use of undeclared crate or module `bar`
|
error[E0433]: failed to resolve: function `bar` is not a crate or module
|
||||||
--> $DIR/crate-or-module-typo.rs:6:20
|
--> $DIR/crate-or-module-typo.rs:6:20
|
||||||
|
|
|
|
||||||
LL | pub fn bar() { bar::baz(); }
|
LL | pub fn bar() { bar::baz(); }
|
||||||
| ^^^ use of undeclared crate or module `bar`
|
| ^^^ function `bar` is not a crate or module
|
||||||
|
|
||||||
error: aborting due to 4 previous errors
|
error: aborting due to 4 previous errors
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue