@@ -1017,7 +1017,7 @@ pub struct ModuleData<'a> {
10171017 resolutions : RefCell < FxHashMap < ( Ident , Namespace ) , & ' a RefCell < NameResolution < ' a > > > > ,
10181018 legacy_macro_resolutions : RefCell < Vec < ( Ident , MacroKind , ParentScope < ' a > ,
10191019 Option < & ' a NameBinding < ' a > > ) > > ,
1020- macro_resolutions : RefCell < Vec < ( Box < [ Ident ] > , Span ) > > ,
1020+ macro_resolutions : RefCell < Vec < ( Vec < Segment > , ParentScope < ' a > , Span ) > > ,
10211021 builtin_attrs : RefCell < Vec < ( Ident , ParentScope < ' a > ) > > ,
10221022
10231023 // Macro invocations that can expand into items in this module.
@@ -1628,7 +1628,8 @@ impl<'a, 'crateloader> Resolver<'a, 'crateloader> {
16281628 let hir:: Path { ref segments, span, ref mut def } = * path;
16291629 let path: Vec < _ > = segments. iter ( ) . map ( |seg| seg. ident ) . collect ( ) ;
16301630 // FIXME (Manishearth): Intra doc links won't get warned of epoch changes
1631- match self . resolve_path ( None , & path, Some ( namespace) , true , span, CrateLint :: No ) {
1631+ match self . resolve_path_without_parent_scope ( None , & path, Some ( namespace) , true , span,
1632+ CrateLint :: No ) {
16321633 PathResult :: Module ( ModuleOrUniformRoot :: Module ( module) ) =>
16331634 * def = module. def ( ) . unwrap ( ) ,
16341635 PathResult :: NonModule ( path_res) if path_res. unresolved_segments ( ) == 0 =>
@@ -2472,10 +2473,10 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> {
24722473 new_id = Some ( def. def_id ( ) ) ;
24732474 let span = trait_ref. path . span ;
24742475 if let PathResult :: Module ( ModuleOrUniformRoot :: Module ( module) ) =
2475- self . resolve_path (
2476+ self . resolve_path_without_parent_scope (
24762477 None ,
24772478 & path,
2478- None ,
2479+ Some ( TypeNS ) ,
24792480 false ,
24802481 span,
24812482 CrateLint :: SimplePath ( trait_ref. ref_id ) ,
@@ -2993,8 +2994,9 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> {
29932994 ( String :: new ( ) , "the crate root" . to_string ( ) )
29942995 } else {
29952996 let mod_path = & path[ ..path. len ( ) - 1 ] ;
2996- let mod_prefix = match this. resolve_path ( None , mod_path, Some ( TypeNS ) ,
2997- false , span, CrateLint :: No ) {
2997+ let mod_prefix = match this. resolve_path_without_parent_scope (
2998+ None , mod_path, Some ( TypeNS ) , false , span, CrateLint :: No
2999+ ) {
29983000 PathResult :: Module ( ModuleOrUniformRoot :: Module ( module) ) =>
29993001 module. def ( ) ,
30003002 _ => None ,
@@ -3478,7 +3480,7 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> {
34783480 ) ) ;
34793481 }
34803482
3481- let result = match self . resolve_path (
3483+ let result = match self . resolve_path_without_parent_scope (
34823484 None ,
34833485 & path,
34843486 Some ( ns) ,
@@ -3525,7 +3527,7 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> {
35253527 path[ 0 ] . name != keywords:: CrateRoot . name ( ) &&
35263528 path[ 0 ] . name != keywords:: DollarCrate . name ( ) {
35273529 let unqualified_result = {
3528- match self . resolve_path (
3530+ match self . resolve_path_without_parent_scope (
35293531 None ,
35303532 & [ * path. last ( ) . unwrap ( ) ] ,
35313533 Some ( ns) ,
@@ -3548,7 +3550,7 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> {
35483550 Some ( result)
35493551 }
35503552
3551- fn resolve_path (
3553+ fn resolve_path_without_parent_scope (
35523554 & mut self ,
35533555 base_module : Option < ModuleOrUniformRoot < ' a > > ,
35543556 path : & [ Ident ] ,
@@ -3557,12 +3559,15 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> {
35573559 path_span : Span ,
35583560 crate_lint : CrateLint ,
35593561 ) -> PathResult < ' a > {
3562+ // Macro and import paths must have full parent scope available during resolution,
3563+ // other paths will do okay with parent module alone.
3564+ assert ! ( opt_ns != None && opt_ns != Some ( MacroNS ) ) ;
35603565 let parent_scope = ParentScope { module : self . current_module , ..self . dummy_parent_scope ( ) } ;
3561- self . resolve_path_with_parent_scope ( base_module, path, opt_ns, & parent_scope,
3562- record_used, path_span, crate_lint)
3566+ self . resolve_path ( base_module, path, opt_ns, & parent_scope,
3567+ record_used, path_span, crate_lint)
35633568 }
35643569
3565- fn resolve_path_with_parent_scope (
3570+ fn resolve_path (
35663571 & mut self ,
35673572 base_module : Option < ModuleOrUniformRoot < ' a > > ,
35683573 path : & [ Ident ] ,
@@ -3749,7 +3754,6 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> {
37493754 PathResult :: Module ( module. unwrap_or_else ( || {
37503755 span_bug ! ( path_span, "resolve_path: empty(?) path {:?} has no module" , path) ;
37513756 } ) )
3752-
37533757 }
37543758
37553759 fn lint_if_path_starts_with_module (
@@ -4033,8 +4037,9 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> {
40334037 } else {
40344038 // Search in module.
40354039 let mod_path = & path[ ..path. len ( ) - 1 ] ;
4036- if let PathResult :: Module ( module) = self . resolve_path ( None , mod_path, Some ( TypeNS ) ,
4037- false , span, CrateLint :: No ) {
4040+ if let PathResult :: Module ( module) = self . resolve_path_without_parent_scope (
4041+ None , mod_path, Some ( TypeNS ) , false , span, CrateLint :: No
4042+ ) {
40384043 if let ModuleOrUniformRoot :: Module ( module) = module {
40394044 add_module_candidates ( module, & mut names) ;
40404045 }
0 commit comments