File tree 3 files changed +55
-1
lines changed
3 files changed +55
-1
lines changed Original file line number Diff line number Diff line change @@ -4125,7 +4125,18 @@ impl<'a> Resolver<'a> {
4125
4125
if ident. name == lookup_name && ns == namespace {
4126
4126
if filter_fn ( name_binding. def ( ) ) {
4127
4127
// create the path
4128
- let mut segms = path_segments. clone ( ) ;
4128
+ let mut segms = if self . session . rust_2018 ( ) && !in_module_is_extern {
4129
+ // crate-local absolute paths start with `crate::` in edition 2018
4130
+ // FIXME: may also be stabilized for Rust 2015 (Issues #45477, #44660)
4131
+ let mut full_segms = vec ! [
4132
+ ast:: PathSegment :: from_ident( keywords:: Crate . ident( ) )
4133
+ ] ;
4134
+ full_segms. extend ( path_segments. clone ( ) ) ;
4135
+ full_segms
4136
+ } else {
4137
+ path_segments. clone ( )
4138
+ } ;
4139
+
4129
4140
segms. push ( ast:: PathSegment :: from_ident ( ident) ) ;
4130
4141
let path = Path {
4131
4142
span : name_binding. span ,
Original file line number Diff line number Diff line change
1
+ // Copyright 2018 The Rust Project Developers. See the COPYRIGHT
2
+ // file at the top-level directory of this distribution and at
3
+ // http://rust-lang.org/COPYRIGHT.
4
+ //
5
+ // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6
+ // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7
+ // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8
+ // option. This file may not be copied, modified, or distributed
9
+ // except according to those terms.
10
+
11
+ // compile-flags: --edition 2018
12
+
13
+ // The local `use` suggestion should start with `crate::` (but the
14
+ // standard-library suggestions should not, obviously).
15
+
16
+ mod plumbing {
17
+ pub struct Drain ;
18
+ }
19
+
20
+ fn main ( ) {
21
+ let _d = Drain { } ;
22
+ //~^ ERROR cannot find struct, variant or union type `Drain` in this scope
23
+ }
Original file line number Diff line number Diff line change
1
+ error[E0422]: cannot find struct, variant or union type `Drain` in this scope
2
+ --> $DIR/issue-52202-use-suggestions.rs:21:14
3
+ |
4
+ LL | let _d = Drain {};
5
+ | ^^^^^ not found in this scope
6
+ help: possible candidates are found in other modules, you can import them into scope
7
+ |
8
+ LL | use crate::plumbing::Drain;
9
+ |
10
+ LL | use std::collections::binary_heap::Drain;
11
+ |
12
+ LL | use std::collections::hash_map::Drain;
13
+ |
14
+ LL | use std::collections::hash_set::Drain;
15
+ |
16
+ and 3 other candidates
17
+
18
+ error: aborting due to previous error
19
+
20
+ For more information about this error, try `rustc --explain E0422`.
You can’t perform that action at this time.
0 commit comments