@@ -1225,12 +1225,10 @@ enum NameBindingKind<'a> {
1225
1225
binding : & ' a NameBinding < ' a > ,
1226
1226
directive : & ' a ImportDirective < ' a > ,
1227
1227
used : Cell < bool > ,
1228
- legacy_self_import : bool ,
1229
1228
} ,
1230
1229
Ambiguity {
1231
1230
b1 : & ' a NameBinding < ' a > ,
1232
1231
b2 : & ' a NameBinding < ' a > ,
1233
- legacy : bool ,
1234
1232
}
1235
1233
}
1236
1234
@@ -1252,15 +1250,13 @@ struct AmbiguityError<'a> {
1252
1250
lexical : bool ,
1253
1251
b1 : & ' a NameBinding < ' a > ,
1254
1252
b2 : & ' a NameBinding < ' a > ,
1255
- legacy : bool ,
1256
1253
}
1257
1254
1258
1255
impl < ' a > NameBinding < ' a > {
1259
1256
fn module ( & self ) -> Option < Module < ' a > > {
1260
1257
match self . kind {
1261
1258
NameBindingKind :: Module ( module) => Some ( module) ,
1262
1259
NameBindingKind :: Import { binding, .. } => binding. module ( ) ,
1263
- NameBindingKind :: Ambiguity { legacy : true , b1, .. } => b1. module ( ) ,
1264
1260
_ => None ,
1265
1261
}
1266
1262
}
@@ -1270,7 +1266,6 @@ impl<'a> NameBinding<'a> {
1270
1266
NameBindingKind :: Def ( def) => def,
1271
1267
NameBindingKind :: Module ( module) => module. def ( ) . unwrap ( ) ,
1272
1268
NameBindingKind :: Import { binding, .. } => binding. def ( ) ,
1273
- NameBindingKind :: Ambiguity { legacy : true , b1, .. } => b1. def ( ) ,
1274
1269
NameBindingKind :: Ambiguity { .. } => Def :: Err ,
1275
1270
}
1276
1271
}
@@ -1853,27 +1848,20 @@ impl<'a> Resolver<'a> {
1853
1848
fn record_use ( & mut self , ident : Ident , ns : Namespace , binding : & ' a NameBinding < ' a > , span : Span )
1854
1849
-> bool /* true if an error was reported */ {
1855
1850
match binding. kind {
1856
- NameBindingKind :: Import { directive, binding, ref used, legacy_self_import }
1851
+ NameBindingKind :: Import { directive, binding, ref used }
1857
1852
if !used. get ( ) => {
1858
1853
used. set ( true ) ;
1859
1854
directive. used . set ( true ) ;
1860
- if legacy_self_import {
1861
- self . warn_legacy_self_import ( directive) ;
1862
- return false ;
1863
- }
1864
1855
self . used_imports . insert ( ( directive. id , ns) ) ;
1865
1856
self . add_to_glob_map ( directive. id , ident) ;
1866
1857
self . record_use ( ident, ns, binding, span)
1867
1858
}
1868
1859
NameBindingKind :: Import { .. } => false ,
1869
- NameBindingKind :: Ambiguity { b1, b2, legacy } => {
1860
+ NameBindingKind :: Ambiguity { b1, b2 } => {
1870
1861
self . ambiguity_errors . push ( AmbiguityError {
1871
- span : span , name : ident. name , lexical : false , b1 : b1 , b2 : b2 , legacy ,
1862
+ span, name : ident. name , lexical : false , b1, b2,
1872
1863
} ) ;
1873
- if legacy {
1874
- self . record_use ( ident, ns, b1, span) ;
1875
- }
1876
- !legacy
1864
+ true
1877
1865
}
1878
1866
_ => false
1879
1867
}
@@ -4074,7 +4062,7 @@ impl<'a> Resolver<'a> {
4074
4062
self . report_proc_macro_import ( krate) ;
4075
4063
let mut reported_spans = FxHashSet ( ) ;
4076
4064
4077
- for & AmbiguityError { span, name, b1, b2, lexical, legacy } in & self . ambiguity_errors {
4065
+ for & AmbiguityError { span, name, b1, b2, lexical } in & self . ambiguity_errors {
4078
4066
if !reported_spans. insert ( span) { continue }
4079
4067
let participle = |binding : & NameBinding | {
4080
4068
if binding. is_import ( ) { "imported" } else { "defined" }
@@ -4090,27 +4078,15 @@ impl<'a> Resolver<'a> {
4090
4078
format ! ( "macro-expanded {} do not shadow when used in a macro invocation path" ,
4091
4079
if b1. is_import( ) { "imports" } else { "items" } )
4092
4080
} ;
4093
- if legacy {
4094
- let id = match b2. kind {
4095
- NameBindingKind :: Import { directive, .. } => directive. id ,
4096
- _ => unreachable ! ( ) ,
4097
- } ;
4098
- let mut span = MultiSpan :: from_span ( span) ;
4099
- span. push_span_label ( b1. span , msg1) ;
4100
- span. push_span_label ( b2. span , msg2) ;
4101
- let msg = format ! ( "`{}` is ambiguous" , name) ;
4102
- self . session . buffer_lint ( lint:: builtin:: LEGACY_IMPORTS , id, span, & msg) ;
4103
- } else {
4104
- let mut err =
4105
- struct_span_err ! ( self . session, span, E0659 , "`{}` is ambiguous" , name) ;
4106
- err. span_note ( b1. span , & msg1) ;
4107
- match b2. def ( ) {
4108
- Def :: Macro ( ..) if b2. span == DUMMY_SP =>
4109
- err. note ( & format ! ( "`{}` is also a builtin macro" , name) ) ,
4110
- _ => err. span_note ( b2. span , & msg2) ,
4111
- } ;
4112
- err. note ( & note) . emit ( ) ;
4113
- }
4081
+
4082
+ let mut err = struct_span_err ! ( self . session, span, E0659 , "`{}` is ambiguous" , name) ;
4083
+ err. span_note ( b1. span , & msg1) ;
4084
+ match b2. def ( ) {
4085
+ Def :: Macro ( ..) if b2. span == DUMMY_SP =>
4086
+ err. note ( & format ! ( "`{}` is also a builtin macro" , name) ) ,
4087
+ _ => err. span_note ( b2. span , & msg2) ,
4088
+ } ;
4089
+ err. note ( & note) . emit ( ) ;
4114
4090
}
4115
4091
4116
4092
for & PrivacyError ( span, name, binding) in & self . privacy_errors {
@@ -4261,12 +4237,6 @@ impl<'a> Resolver<'a> {
4261
4237
self . name_already_seen . insert ( name, span) ;
4262
4238
}
4263
4239
4264
- fn warn_legacy_self_import ( & self , directive : & ' a ImportDirective < ' a > ) {
4265
- let ( id, span) = ( directive. id , directive. span ) ;
4266
- let msg = "`self` no longer imports values" ;
4267
- self . session . buffer_lint ( lint:: builtin:: LEGACY_IMPORTS , id, span, msg) ;
4268
- }
4269
-
4270
4240
fn check_proc_macro_attrs ( & mut self , attrs : & [ ast:: Attribute ] ) {
4271
4241
if self . proc_macro_enabled { return ; }
4272
4242
0 commit comments