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