@@ -1100,6 +1100,7 @@ impl<'a> fmt::Debug for ModuleData<'a> {
1100
1100
pub struct NameBinding < ' a > {
1101
1101
kind : NameBindingKind < ' a > ,
1102
1102
expansion : Mark ,
1103
+ is_macro_export : bool ,
1103
1104
span : Span ,
1104
1105
vis : ty:: Visibility ,
1105
1106
}
@@ -1141,12 +1142,20 @@ struct UseError<'a> {
1141
1142
better : bool ,
1142
1143
}
1143
1144
1145
+ #[ derive( Clone , Copy , Debug ) ]
1146
+ enum AmbiguityErrorKind {
1147
+ RecordUse ,
1148
+ ResolveLexical ,
1149
+ ResolveInModule ,
1150
+ }
1151
+
1144
1152
struct AmbiguityError < ' a > {
1145
1153
span : Span ,
1146
1154
name : Name ,
1147
1155
lexical : bool ,
1148
1156
b1 : & ' a NameBinding < ' a > ,
1149
1157
b2 : & ' a NameBinding < ' a > ,
1158
+ kind : AmbiguityErrorKind ,
1150
1159
}
1151
1160
1152
1161
impl < ' a > NameBinding < ' a > {
@@ -1393,7 +1402,6 @@ pub struct Resolver<'a> {
1393
1402
macro_map : FxHashMap < DefId , Lrc < SyntaxExtension > > ,
1394
1403
macro_defs : FxHashMap < Mark , DefId > ,
1395
1404
local_macro_def_scopes : FxHashMap < NodeId , Module < ' a > > ,
1396
- macro_exports : Vec < Export > ,
1397
1405
pub whitelisted_legacy_custom_derives : Vec < Name > ,
1398
1406
pub found_unresolved_macro : bool ,
1399
1407
@@ -1426,6 +1434,9 @@ pub struct Resolver<'a> {
1426
1434
1427
1435
/// Only supposed to be used by rustdoc, otherwise should be false.
1428
1436
pub ignore_extern_prelude_feature : bool ,
1437
+
1438
+ /// Macro invocations in the whole crate that can expand into a `#[macro_export] macro_rules`.
1439
+ unresolved_invocations_macro_export : FxHashSet < Mark > ,
1429
1440
}
1430
1441
1431
1442
/// Nothing really interesting here, it just provides memory for the rest of the crate.
@@ -1703,6 +1714,7 @@ impl<'a> Resolver<'a> {
1703
1714
expansion : Mark :: root ( ) ,
1704
1715
span : DUMMY_SP ,
1705
1716
vis : ty:: Visibility :: Public ,
1717
+ is_macro_export : false ,
1706
1718
} ) ,
1707
1719
1708
1720
crate_loader,
@@ -1711,7 +1723,6 @@ impl<'a> Resolver<'a> {
1711
1723
all_macros : FxHashMap ( ) ,
1712
1724
lexical_macro_resolutions : Vec :: new ( ) ,
1713
1725
macro_map : FxHashMap ( ) ,
1714
- macro_exports : Vec :: new ( ) ,
1715
1726
invocations,
1716
1727
macro_defs,
1717
1728
local_macro_def_scopes : FxHashMap ( ) ,
@@ -1726,6 +1737,7 @@ impl<'a> Resolver<'a> {
1726
1737
current_type_ascription : Vec :: new ( ) ,
1727
1738
injected_crate : None ,
1728
1739
ignore_extern_prelude_feature : false ,
1740
+ unresolved_invocations_macro_export : FxHashSet ( ) ,
1729
1741
}
1730
1742
}
1731
1743
@@ -1797,6 +1809,7 @@ impl<'a> Resolver<'a> {
1797
1809
NameBindingKind :: Ambiguity { b1, b2 } => {
1798
1810
self . ambiguity_errors . push ( AmbiguityError {
1799
1811
span, name : ident. name , lexical : false , b1, b2,
1812
+ kind : AmbiguityErrorKind :: RecordUse
1800
1813
} ) ;
1801
1814
true
1802
1815
}
@@ -1957,7 +1970,6 @@ impl<'a> Resolver<'a> {
1957
1970
module : Module < ' a > ,
1958
1971
mut ident : Ident ,
1959
1972
ns : Namespace ,
1960
- ignore_unresolved_invocations : bool ,
1961
1973
record_used : bool ,
1962
1974
span : Span )
1963
1975
-> Result < & ' a NameBinding < ' a > , Determinacy > {
@@ -1967,7 +1979,7 @@ impl<'a> Resolver<'a> {
1967
1979
self . current_module = self . macro_def_scope ( def) ;
1968
1980
}
1969
1981
let result = self . resolve_ident_in_module_unadjusted (
1970
- module, ident, ns, ignore_unresolved_invocations , record_used, span,
1982
+ module, ident, ns, false , record_used, span,
1971
1983
) ;
1972
1984
self . current_module = orig_current_module;
1973
1985
result
@@ -2460,7 +2472,7 @@ impl<'a> Resolver<'a> {
2460
2472
// If there is a TraitRef in scope for an impl, then the method must be in the
2461
2473
// trait.
2462
2474
if let Some ( ( module, _) ) = self . current_trait_ref {
2463
- if self . resolve_ident_in_module ( module, ident, ns, false , false , span) . is_err ( ) {
2475
+ if self . resolve_ident_in_module ( module, ident, ns, false , span) . is_err ( ) {
2464
2476
let path = & self . current_trait_ref . as_ref ( ) . unwrap ( ) . 1 . path ;
2465
2477
resolve_error ( self , span, err ( ident. name , & path_names_to_string ( path) ) ) ;
2466
2478
}
@@ -3410,7 +3422,7 @@ impl<'a> Resolver<'a> {
3410
3422
}
3411
3423
3412
3424
let binding = if let Some ( module) = module {
3413
- self . resolve_ident_in_module ( module, ident, ns, false , record_used, path_span)
3425
+ self . resolve_ident_in_module ( module, ident, ns, record_used, path_span)
3414
3426
} else if opt_ns == Some ( MacroNS ) {
3415
3427
self . resolve_lexical_macro_path_segment ( ident, ns, record_used, path_span)
3416
3428
. map ( MacroBinding :: binding)
@@ -3704,7 +3716,7 @@ impl<'a> Resolver<'a> {
3704
3716
// Look for associated items in the current trait.
3705
3717
if let Some ( ( module, _) ) = self . current_trait_ref {
3706
3718
if let Ok ( binding) =
3707
- self . resolve_ident_in_module ( module, ident, ns, false , false , module. span ) {
3719
+ self . resolve_ident_in_module ( module, ident, ns, false , module. span ) {
3708
3720
let def = binding. def ( ) ;
3709
3721
if filter_fn ( def) {
3710
3722
return Some ( if self . has_self . contains ( & def. def_id ( ) ) {
@@ -4017,7 +4029,7 @@ impl<'a> Resolver<'a> {
4017
4029
let mut found_traits = Vec :: new ( ) ;
4018
4030
// Look for the current trait.
4019
4031
if let Some ( ( module, _) ) = self . current_trait_ref {
4020
- if self . resolve_ident_in_module ( module, ident, ns, false , false , module. span ) . is_ok ( ) {
4032
+ if self . resolve_ident_in_module ( module, ident, ns, false , module. span ) . is_ok ( ) {
4021
4033
let def_id = module. def_id ( ) . unwrap ( ) ;
4022
4034
found_traits. push ( TraitCandidate { def_id : def_id, import_id : None } ) ;
4023
4035
}
@@ -4290,7 +4302,7 @@ impl<'a> Resolver<'a> {
4290
4302
self . report_proc_macro_import ( krate) ;
4291
4303
let mut reported_spans = FxHashSet ( ) ;
4292
4304
4293
- for & AmbiguityError { span, name, b1, b2, lexical } in & self . ambiguity_errors {
4305
+ for & AmbiguityError { span, name, b1, b2, lexical, kind } in & self . ambiguity_errors {
4294
4306
if !reported_spans. insert ( span) { continue }
4295
4307
let participle = |binding : & NameBinding | {
4296
4308
if binding. is_import ( ) { "imported" } else { "defined" }
@@ -4307,7 +4319,8 @@ impl<'a> Resolver<'a> {
4307
4319
if b1. is_import( ) { "imports" } else { "items" } )
4308
4320
} ;
4309
4321
4310
- let mut err = struct_span_err ! ( self . session, span, E0659 , "`{}` is ambiguous" , name) ;
4322
+ let mut err = struct_span_err ! ( self . session, span, E0659 ,
4323
+ "`{}` is ambiguous {:?}" , name, kind) ;
4311
4324
err. span_note ( b1. span , & msg1) ;
4312
4325
match b2. def ( ) {
4313
4326
Def :: Macro ( ..) if b2. span . is_dummy ( ) =>
0 commit comments