@@ -4236,6 +4236,7 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> {
4236
4236
lookup_name : Name ,
4237
4237
namespace : Namespace ,
4238
4238
start_module : & ' a ModuleData < ' a > ,
4239
+ graph_root : bool ,
4239
4240
filter_fn : FilterFn )
4240
4241
-> Vec < ImportSuggestion >
4241
4242
where FilterFn : Fn ( Def ) -> bool
@@ -4262,17 +4263,14 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> {
4262
4263
if ident. name == lookup_name && ns == namespace {
4263
4264
if filter_fn ( name_binding. def ( ) ) {
4264
4265
// create the path
4265
- let mut segms = if self . session . rust_2018 ( ) && !in_module_is_extern {
4266
+ let mut segms = path_segments. clone ( ) ;
4267
+ if self . session . rust_2018 ( ) && !in_module_is_extern {
4266
4268
// crate-local absolute paths start with `crate::` in edition 2018
4267
4269
// FIXME: may also be stabilized for Rust 2015 (Issues #45477, #44660)
4268
- let mut full_segms = vec ! [
4269
- ast:: PathSegment :: from_ident( keywords:: Crate . ident( ) )
4270
- ] ;
4271
- full_segms. extend ( path_segments. clone ( ) ) ;
4272
- full_segms
4273
- } else {
4274
- path_segments. clone ( )
4275
- } ;
4270
+ if graph_root {
4271
+ segms. insert ( 0 , ast:: PathSegment :: from_ident ( keywords:: Crate . ident ( ) ) ) ;
4272
+ }
4273
+ }
4276
4274
4277
4275
segms. push ( ast:: PathSegment :: from_ident ( ident) ) ;
4278
4276
let path = Path {
@@ -4326,7 +4324,7 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> {
4326
4324
-> Vec < ImportSuggestion >
4327
4325
where FilterFn : Fn ( Def ) -> bool
4328
4326
{
4329
- self . lookup_import_candidates_from_module ( lookup_name, namespace, self . graph_root , filter_fn)
4327
+ self . lookup_import_candidates_from_module ( lookup_name, namespace, self . graph_root , true , filter_fn)
4330
4328
}
4331
4329
4332
4330
fn find_module ( & mut self ,
0 commit comments