@@ -1166,7 +1166,6 @@ struct UseError<'a> {
1166
1166
struct AmbiguityError < ' a > {
1167
1167
span : Span ,
1168
1168
name : Name ,
1169
- lexical : bool ,
1170
1169
b1 : & ' a NameBinding < ' a > ,
1171
1170
b2 : & ' a NameBinding < ' a > ,
1172
1171
}
@@ -1816,7 +1815,7 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> {
1816
1815
NameBindingKind :: Import { .. } => false ,
1817
1816
NameBindingKind :: Ambiguity { b1, b2 } => {
1818
1817
self . ambiguity_errors . push ( AmbiguityError {
1819
- span, name : ident. name , lexical : false , b1, b2,
1818
+ span, name : ident. name , b1, b2,
1820
1819
} ) ;
1821
1820
true
1822
1821
}
@@ -4501,35 +4500,32 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> {
4501
4500
vis. is_accessible_from ( module. normal_ancestor_id , self )
4502
4501
}
4503
4502
4504
- fn report_ambiguity_error (
4505
- & self , name : Name , span : Span , _lexical : bool ,
4506
- def1 : Def , is_import1 : bool , is_glob1 : bool , from_expansion1 : bool , span1 : Span ,
4507
- def2 : Def , is_import2 : bool , _is_glob2 : bool , _from_expansion2 : bool , span2 : Span ,
4508
- ) {
4503
+ fn report_ambiguity_error ( & self , name : Name , span : Span , b1 : & NameBinding , b2 : & NameBinding ) {
4509
4504
let participle = |is_import : bool | if is_import { "imported" } else { "defined" } ;
4510
- let msg1 = format ! ( "`{}` could refer to the name {} here" , name, participle( is_import1) ) ;
4505
+ let msg1 =
4506
+ format ! ( "`{}` could refer to the name {} here" , name, participle( b1. is_import( ) ) ) ;
4511
4507
let msg2 =
4512
- format ! ( "`{}` could also refer to the name {} here" , name, participle( is_import2 ) ) ;
4513
- let note = if from_expansion1 {
4514
- Some ( if let Def :: Macro ( ..) = def1 {
4508
+ format ! ( "`{}` could also refer to the name {} here" , name, participle( b2 . is_import ( ) ) ) ;
4509
+ let note = if b1 . expansion != Mark :: root ( ) {
4510
+ Some ( if let Def :: Macro ( ..) = b1 . def ( ) {
4515
4511
format ! ( "macro-expanded {} do not shadow" ,
4516
- if is_import1 { "macro imports" } else { "macros" } )
4512
+ if b1 . is_import ( ) { "macro imports" } else { "macros" } )
4517
4513
} else {
4518
4514
format ! ( "macro-expanded {} do not shadow when used in a macro invocation path" ,
4519
- if is_import1 { "imports" } else { "items" } )
4515
+ if b1 . is_import ( ) { "imports" } else { "items" } )
4520
4516
} )
4521
- } else if is_glob1 {
4517
+ } else if b1 . is_glob_import ( ) {
4522
4518
Some ( format ! ( "consider adding an explicit import of `{}` to disambiguate" , name) )
4523
4519
} else {
4524
4520
None
4525
4521
} ;
4526
4522
4527
4523
let mut err = struct_span_err ! ( self . session, span, E0659 , "`{}` is ambiguous" , name) ;
4528
- err. span_note ( span1 , & msg1) ;
4529
- match def2 {
4530
- Def :: Macro ( ..) if span2 . is_dummy ( ) =>
4524
+ err. span_note ( b1 . span , & msg1) ;
4525
+ match b2 . def ( ) {
4526
+ Def :: Macro ( ..) if b2 . span . is_dummy ( ) =>
4531
4527
err. note ( & format ! ( "`{}` is also a builtin macro" , name) ) ,
4532
- _ => err. span_note ( span2 , & msg2) ,
4528
+ _ => err. span_note ( b2 . span , & msg2) ,
4533
4529
} ;
4534
4530
if let Some ( note) = note {
4535
4531
err. note ( & note) ;
@@ -4554,15 +4550,9 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> {
4554
4550
) ;
4555
4551
}
4556
4552
4557
- for & AmbiguityError { span, name, b1, b2, lexical } in & self . ambiguity_errors {
4553
+ for & AmbiguityError { span, name, b1, b2 } in & self . ambiguity_errors {
4558
4554
if reported_spans. insert ( span) {
4559
- self . report_ambiguity_error (
4560
- name, span, lexical,
4561
- b1. def ( ) , b1. is_import ( ) , b1. is_glob_import ( ) ,
4562
- b1. expansion != Mark :: root ( ) , b1. span ,
4563
- b2. def ( ) , b2. is_import ( ) , b2. is_glob_import ( ) ,
4564
- b2. expansion != Mark :: root ( ) , b2. span ,
4565
- ) ;
4555
+ self . report_ambiguity_error ( name, span, b1, b2) ;
4566
4556
}
4567
4557
}
4568
4558
@@ -4586,9 +4576,9 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> {
4586
4576
let mut reported_errors = FxHashSet ( ) ;
4587
4577
for binding in replace ( & mut self . disallowed_shadowing , Vec :: new ( ) ) {
4588
4578
if self . resolve_legacy_scope ( & binding. parent , binding. ident , false ) . is_some ( ) &&
4589
- reported_errors. insert ( ( binding. ident , binding. span ) ) {
4579
+ reported_errors. insert ( ( binding. ident , binding. binding . span ) ) {
4590
4580
let msg = format ! ( "`{}` is already in scope" , binding. ident) ;
4591
- self . session . struct_span_err ( binding. span , & msg)
4581
+ self . session . struct_span_err ( binding. binding . span , & msg)
4592
4582
. note ( "macro-expanded `macro_rules!`s may not shadow \
4593
4583
existing macros (see RFC 1560)")
4594
4584
. emit ( ) ;
0 commit comments