@@ -1017,7 +1017,7 @@ pub struct ModuleData<'a> {
1017
1017
resolutions : RefCell < FxHashMap < ( Ident , Namespace ) , & ' a RefCell < NameResolution < ' a > > > > ,
1018
1018
legacy_macro_resolutions : RefCell < Vec < ( Ident , MacroKind , ParentScope < ' a > ,
1019
1019
Option < & ' a NameBinding < ' a > > ) > > ,
1020
- macro_resolutions : RefCell < Vec < ( Box < [ Ident ] > , Span ) > > ,
1020
+ macro_resolutions : RefCell < Vec < ( Vec < Segment > , ParentScope < ' a > , Span ) > > ,
1021
1021
builtin_attrs : RefCell < Vec < ( Ident , ParentScope < ' a > ) > > ,
1022
1022
1023
1023
// Macro invocations that can expand into items in this module.
@@ -1628,7 +1628,8 @@ impl<'a, 'crateloader> Resolver<'a, 'crateloader> {
1628
1628
let hir:: Path { ref segments, span, ref mut def } = * path;
1629
1629
let path: Vec < _ > = segments. iter ( ) . map ( |seg| seg. ident ) . collect ( ) ;
1630
1630
// 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 ) {
1632
1633
PathResult :: Module ( ModuleOrUniformRoot :: Module ( module) ) =>
1633
1634
* def = module. def ( ) . unwrap ( ) ,
1634
1635
PathResult :: NonModule ( path_res) if path_res. unresolved_segments ( ) == 0 =>
@@ -2472,10 +2473,10 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> {
2472
2473
new_id = Some ( def. def_id ( ) ) ;
2473
2474
let span = trait_ref. path . span ;
2474
2475
if let PathResult :: Module ( ModuleOrUniformRoot :: Module ( module) ) =
2475
- self . resolve_path (
2476
+ self . resolve_path_without_parent_scope (
2476
2477
None ,
2477
2478
& path,
2478
- None ,
2479
+ Some ( TypeNS ) ,
2479
2480
false ,
2480
2481
span,
2481
2482
CrateLint :: SimplePath ( trait_ref. ref_id ) ,
@@ -2993,8 +2994,9 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> {
2993
2994
( String :: new ( ) , "the crate root" . to_string ( ) )
2994
2995
} else {
2995
2996
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
+ ) {
2998
3000
PathResult :: Module ( ModuleOrUniformRoot :: Module ( module) ) =>
2999
3001
module. def ( ) ,
3000
3002
_ => None ,
@@ -3478,7 +3480,7 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> {
3478
3480
) ) ;
3479
3481
}
3480
3482
3481
- let result = match self . resolve_path (
3483
+ let result = match self . resolve_path_without_parent_scope (
3482
3484
None ,
3483
3485
& path,
3484
3486
Some ( ns) ,
@@ -3525,7 +3527,7 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> {
3525
3527
path[ 0 ] . name != keywords:: CrateRoot . name ( ) &&
3526
3528
path[ 0 ] . name != keywords:: DollarCrate . name ( ) {
3527
3529
let unqualified_result = {
3528
- match self . resolve_path (
3530
+ match self . resolve_path_without_parent_scope (
3529
3531
None ,
3530
3532
& [ * path. last ( ) . unwrap ( ) ] ,
3531
3533
Some ( ns) ,
@@ -3548,7 +3550,7 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> {
3548
3550
Some ( result)
3549
3551
}
3550
3552
3551
- fn resolve_path (
3553
+ fn resolve_path_without_parent_scope (
3552
3554
& mut self ,
3553
3555
base_module : Option < ModuleOrUniformRoot < ' a > > ,
3554
3556
path : & [ Ident ] ,
@@ -3557,12 +3559,15 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> {
3557
3559
path_span : Span ,
3558
3560
crate_lint : CrateLint ,
3559
3561
) -> 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 ) ) ;
3560
3565
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)
3563
3568
}
3564
3569
3565
- fn resolve_path_with_parent_scope (
3570
+ fn resolve_path (
3566
3571
& mut self ,
3567
3572
base_module : Option < ModuleOrUniformRoot < ' a > > ,
3568
3573
path : & [ Ident ] ,
@@ -3749,7 +3754,6 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> {
3749
3754
PathResult :: Module ( module. unwrap_or_else ( || {
3750
3755
span_bug ! ( path_span, "resolve_path: empty(?) path {:?} has no module" , path) ;
3751
3756
} ) )
3752
-
3753
3757
}
3754
3758
3755
3759
fn lint_if_path_starts_with_module (
@@ -4033,8 +4037,9 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> {
4033
4037
} else {
4034
4038
// Search in module.
4035
4039
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
+ ) {
4038
4043
if let ModuleOrUniformRoot :: Module ( module) = module {
4039
4044
add_module_candidates ( module, & mut names) ;
4040
4045
}
0 commit comments