This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 5 files changed +21
-8
lines changed
compiler/rustc_resolve/src
rfc-2126-extern-absolute-paths Expand file tree Collapse file tree 5 files changed +21
-8
lines changed Original file line number Diff line number Diff line change @@ -244,6 +244,13 @@ impl<'a> PathSource<'a> {
244244 // "function" here means "anything callable" rather than `DefKind::Fn`,
245245 // this is not precise but usually more helpful than just "value".
246246 Some ( ExprKind :: Call ( call_expr, _) ) => match & call_expr. kind {
247+ // the case of `::some_crate()`
248+ ExprKind :: Path ( _, path)
249+ if path. segments . len ( ) == 2
250+ && path. segments [ 0 ] . ident . name == kw:: PathRoot =>
251+ {
252+ "external crate"
253+ }
247254 ExprKind :: Path ( _, path) => {
248255 let mut msg = "function" ;
249256 if let Some ( segment) = path. segments . iter ( ) . last ( ) {
Original file line number Diff line number Diff line change @@ -2458,20 +2458,26 @@ impl<'a> Resolver<'a> {
24582458 ( format ! ( "use of undeclared crate or module `{}`" , ident) , None )
24592459 }
24602460 } else {
2461- let mut msg =
2462- format ! ( "could not find `{}` in `{}`" , ident, path[ i - 1 ] . ident) ;
2461+ let parent = path[ i - 1 ] . ident . name ;
2462+ let parent = if parent == kw:: PathRoot {
2463+ "crate root" . to_owned ( )
2464+ } else {
2465+ format ! ( "`{}`" , parent)
2466+ } ;
2467+
2468+ let mut msg = format ! ( "could not find `{}` in {}" , ident, parent) ;
24632469 if ns == TypeNS || ns == ValueNS {
24642470 let ns_to_try = if ns == TypeNS { ValueNS } else { TypeNS } ;
24652471 if let FindBindingResult :: Binding ( Ok ( binding) ) =
24662472 find_binding_in_ns ( self , ns_to_try)
24672473 {
24682474 let mut found = |what| {
24692475 msg = format ! (
2470- "expected {}, found {} `{}` in `{}` " ,
2476+ "expected {}, found {} `{}` in {} " ,
24712477 ns. descr( ) ,
24722478 what,
24732479 ident,
2474- path [ i - 1 ] . ident
2480+ parent
24752481 )
24762482 } ;
24772483 if binding. module ( ) . is_some ( ) {
Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ error[E0432]: unresolved import `E`
22 --> $DIR/edition-imports-virtual-2015-gated.rs:8:5
33 |
44LL | gen_gated!();
5- | ^^^^^^^^^^^^^ could not find `E` in `{{ root}}`
5+ | ^^^^^^^^^^^^^ could not find `E` in crate root
66 |
77 = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
88
Original file line number Diff line number Diff line change 22
33fn main ( ) {
44 let s = :: xcrate:: S ;
5- //~^ ERROR failed to resolve: could not find `xcrate` in `{{ root}}`
5+ //~^ ERROR failed to resolve: could not find `xcrate` in crate root
66}
Original file line number Diff line number Diff line change 1- error[E0433]: failed to resolve: could not find `xcrate` in `{{ root}}`
1+ error[E0433]: failed to resolve: could not find `xcrate` in crate root
22 --> $DIR/non-existent-2.rs:4:15
33 |
44LL | let s = ::xcrate::S;
5- | ^^^^^^ could not find `xcrate` in `{{ root}}`
5+ | ^^^^^^ could not find `xcrate` in crate root
66
77error: aborting due to previous error
88
You can’t perform that action at this time.
0 commit comments