@@ -1164,8 +1164,7 @@ struct UseError<'a> {
1164
1164
}
1165
1165
1166
1166
struct AmbiguityError < ' a > {
1167
- span : Span ,
1168
- name : Name ,
1167
+ ident : Ident ,
1169
1168
b1 : & ' a NameBinding < ' a > ,
1170
1169
b2 : & ' a NameBinding < ' a > ,
1171
1170
}
@@ -1818,7 +1817,7 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> {
1818
1817
self . arenas . alloc_module ( module)
1819
1818
}
1820
1819
1821
- fn record_use ( & mut self , ident : Ident , ns : Namespace , binding : & ' a NameBinding < ' a > , span : Span )
1820
+ fn record_use ( & mut self , ident : Ident , ns : Namespace , binding : & ' a NameBinding < ' a > )
1822
1821
-> bool /* true if an error was reported */ {
1823
1822
match binding. kind {
1824
1823
NameBindingKind :: Import { directive, binding, ref used }
@@ -1827,13 +1826,11 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> {
1827
1826
directive. used . set ( true ) ;
1828
1827
self . used_imports . insert ( ( directive. id , ns) ) ;
1829
1828
self . add_to_glob_map ( directive. id , ident) ;
1830
- self . record_use ( ident, ns, binding, span )
1829
+ self . record_use ( ident, ns, binding)
1831
1830
}
1832
1831
NameBindingKind :: Import { .. } => false ,
1833
1832
NameBindingKind :: Ambiguity { b1, b2 } => {
1834
- self . ambiguity_errors . push ( AmbiguityError {
1835
- span, name : ident. name , b1, b2,
1836
- } ) ;
1833
+ self . ambiguity_errors . push ( AmbiguityError { ident, b1, b2 } ) ;
1837
1834
true
1838
1835
}
1839
1836
_ => false
@@ -2853,7 +2850,7 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> {
2853
2850
Def :: Const ( ..) if is_syntactic_ambiguity => {
2854
2851
// Disambiguate in favor of a unit struct/variant
2855
2852
// or constant pattern.
2856
- self . record_use ( ident, ValueNS , binding. unwrap ( ) , ident . span ) ;
2853
+ self . record_use ( ident, ValueNS , binding. unwrap ( ) ) ;
2857
2854
Some ( PathResolution :: new ( def) )
2858
2855
}
2859
2856
Def :: StructCtor ( ..) | Def :: VariantCtor ( ..) |
@@ -4532,12 +4529,12 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> {
4532
4529
vis. is_accessible_from ( module. normal_ancestor_id , self )
4533
4530
}
4534
4531
4535
- fn report_ambiguity_error ( & self , name : Name , span : Span , b1 : & NameBinding , b2 : & NameBinding ) {
4532
+ fn report_ambiguity_error ( & self , ident : Ident , b1 : & NameBinding , b2 : & NameBinding ) {
4536
4533
let participle = |is_import : bool | if is_import { "imported" } else { "defined" } ;
4537
4534
let msg1 =
4538
- format ! ( "`{}` could refer to the name {} here" , name , participle( b1. is_import( ) ) ) ;
4535
+ format ! ( "`{}` could refer to the name {} here" , ident , participle( b1. is_import( ) ) ) ;
4539
4536
let msg2 =
4540
- format ! ( "`{}` could also refer to the name {} here" , name , participle( b2. is_import( ) ) ) ;
4537
+ format ! ( "`{}` could also refer to the name {} here" , ident , participle( b2. is_import( ) ) ) ;
4541
4538
let note = if b1. expansion != Mark :: root ( ) {
4542
4539
Some ( if let Def :: Macro ( ..) = b1. def ( ) {
4543
4540
format ! ( "macro-expanded {} do not shadow" ,
@@ -4547,16 +4544,17 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> {
4547
4544
if b1. is_import( ) { "imports" } else { "items" } )
4548
4545
} )
4549
4546
} else if b1. is_glob_import ( ) {
4550
- Some ( format ! ( "consider adding an explicit import of `{}` to disambiguate" , name ) )
4547
+ Some ( format ! ( "consider adding an explicit import of `{}` to disambiguate" , ident ) )
4551
4548
} else {
4552
4549
None
4553
4550
} ;
4554
4551
4555
- let mut err = struct_span_err ! ( self . session, span, E0659 , "`{}` is ambiguous" , name) ;
4552
+ let mut err = struct_span_err ! ( self . session, ident. span, E0659 , "`{}` is ambiguous" , ident) ;
4553
+ err. span_label ( ident. span , "ambiguous name" ) ;
4556
4554
err. span_note ( b1. span , & msg1) ;
4557
4555
match b2. def ( ) {
4558
4556
Def :: Macro ( ..) if b2. span . is_dummy ( ) =>
4559
- err. note ( & format ! ( "`{}` is also a builtin macro" , name ) ) ,
4557
+ err. note ( & format ! ( "`{}` is also a builtin macro" , ident ) ) ,
4560
4558
_ => err. span_note ( b2. span , & msg2) ,
4561
4559
} ;
4562
4560
if let Some ( note) = note {
@@ -4581,9 +4579,9 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> {
4581
4579
) ;
4582
4580
}
4583
4581
4584
- for & AmbiguityError { span , name , b1, b2 } in & self . ambiguity_errors {
4585
- if reported_spans. insert ( span) {
4586
- self . report_ambiguity_error ( name , span , b1, b2) ;
4582
+ for & AmbiguityError { ident , b1, b2 } in & self . ambiguity_errors {
4583
+ if reported_spans. insert ( ident . span ) {
4584
+ self . report_ambiguity_error ( ident , b1, b2) ;
4587
4585
}
4588
4586
}
4589
4587
0 commit comments