@@ -1224,12 +1224,10 @@ enum NameBindingKind<'a> {
1224
1224
binding : & ' a NameBinding < ' a > ,
1225
1225
directive : & ' a ImportDirective < ' a > ,
1226
1226
used : Cell < bool > ,
1227
- legacy_self_import : bool ,
1228
1227
} ,
1229
1228
Ambiguity {
1230
1229
b1 : & ' a NameBinding < ' a > ,
1231
1230
b2 : & ' a NameBinding < ' a > ,
1232
- legacy : bool ,
1233
1231
}
1234
1232
}
1235
1233
@@ -1251,15 +1249,13 @@ struct AmbiguityError<'a> {
1251
1249
lexical : bool ,
1252
1250
b1 : & ' a NameBinding < ' a > ,
1253
1251
b2 : & ' a NameBinding < ' a > ,
1254
- legacy : bool ,
1255
1252
}
1256
1253
1257
1254
impl < ' a > NameBinding < ' a > {
1258
1255
fn module ( & self ) -> Option < Module < ' a > > {
1259
1256
match self . kind {
1260
1257
NameBindingKind :: Module ( module) => Some ( module) ,
1261
1258
NameBindingKind :: Import { binding, .. } => binding. module ( ) ,
1262
- NameBindingKind :: Ambiguity { legacy : true , b1, .. } => b1. module ( ) ,
1263
1259
_ => None ,
1264
1260
}
1265
1261
}
@@ -1269,7 +1265,6 @@ impl<'a> NameBinding<'a> {
1269
1265
NameBindingKind :: Def ( def) => def,
1270
1266
NameBindingKind :: Module ( module) => module. def ( ) . unwrap ( ) ,
1271
1267
NameBindingKind :: Import { binding, .. } => binding. def ( ) ,
1272
- NameBindingKind :: Ambiguity { legacy : true , b1, .. } => b1. def ( ) ,
1273
1268
NameBindingKind :: Ambiguity { .. } => Def :: Err ,
1274
1269
}
1275
1270
}
@@ -1852,27 +1847,20 @@ impl<'a> Resolver<'a> {
1852
1847
fn record_use ( & mut self , ident : Ident , ns : Namespace , binding : & ' a NameBinding < ' a > , span : Span )
1853
1848
-> bool /* true if an error was reported */ {
1854
1849
match binding. kind {
1855
- NameBindingKind :: Import { directive, binding, ref used, legacy_self_import }
1850
+ NameBindingKind :: Import { directive, binding, ref used }
1856
1851
if !used. get ( ) => {
1857
1852
used. set ( true ) ;
1858
1853
directive. used . set ( true ) ;
1859
- if legacy_self_import {
1860
- self . warn_legacy_self_import ( directive) ;
1861
- return false ;
1862
- }
1863
1854
self . used_imports . insert ( ( directive. id , ns) ) ;
1864
1855
self . add_to_glob_map ( directive. id , ident) ;
1865
1856
self . record_use ( ident, ns, binding, span)
1866
1857
}
1867
1858
NameBindingKind :: Import { .. } => false ,
1868
- NameBindingKind :: Ambiguity { b1, b2, legacy } => {
1859
+ NameBindingKind :: Ambiguity { b1, b2 } => {
1869
1860
self . ambiguity_errors . push ( AmbiguityError {
1870
- span : span , name : ident. name , lexical : false , b1 : b1 , b2 : b2 , legacy ,
1861
+ span, name : ident. name , lexical : false , b1, b2,
1871
1862
} ) ;
1872
- if legacy {
1873
- self . record_use ( ident, ns, b1, span) ;
1874
- }
1875
- !legacy
1863
+ true
1876
1864
}
1877
1865
_ => false
1878
1866
}
@@ -4128,7 +4116,7 @@ impl<'a> Resolver<'a> {
4128
4116
self . report_proc_macro_import ( krate) ;
4129
4117
let mut reported_spans = FxHashSet ( ) ;
4130
4118
4131
- for & AmbiguityError { span, name, b1, b2, lexical, legacy } in & self . ambiguity_errors {
4119
+ for & AmbiguityError { span, name, b1, b2, lexical } in & self . ambiguity_errors {
4132
4120
if !reported_spans. insert ( span) { continue }
4133
4121
let participle = |binding : & NameBinding | {
4134
4122
if binding. is_import ( ) { "imported" } else { "defined" }
@@ -4144,27 +4132,15 @@ impl<'a> Resolver<'a> {
4144
4132
format ! ( "macro-expanded {} do not shadow when used in a macro invocation path" ,
4145
4133
if b1. is_import( ) { "imports" } else { "items" } )
4146
4134
} ;
4147
- if legacy {
4148
- let id = match b2. kind {
4149
- NameBindingKind :: Import { directive, .. } => directive. id ,
4150
- _ => unreachable ! ( ) ,
4151
- } ;
4152
- let mut span = MultiSpan :: from_span ( span) ;
4153
- span. push_span_label ( b1. span , msg1) ;
4154
- span. push_span_label ( b2. span , msg2) ;
4155
- let msg = format ! ( "`{}` is ambiguous" , name) ;
4156
- self . session . buffer_lint ( lint:: builtin:: LEGACY_IMPORTS , id, span, & msg) ;
4157
- } else {
4158
- let mut err =
4159
- struct_span_err ! ( self . session, span, E0659 , "`{}` is ambiguous" , name) ;
4160
- err. span_note ( b1. span , & msg1) ;
4161
- match b2. def ( ) {
4162
- Def :: Macro ( ..) if b2. span == DUMMY_SP =>
4163
- err. note ( & format ! ( "`{}` is also a builtin macro" , name) ) ,
4164
- _ => err. span_note ( b2. span , & msg2) ,
4165
- } ;
4166
- err. note ( & note) . emit ( ) ;
4167
- }
4135
+
4136
+ let mut err = struct_span_err ! ( self . session, span, E0659 , "`{}` is ambiguous" , name) ;
4137
+ err. span_note ( b1. span , & msg1) ;
4138
+ match b2. def ( ) {
4139
+ Def :: Macro ( ..) if b2. span == DUMMY_SP =>
4140
+ err. note ( & format ! ( "`{}` is also a builtin macro" , name) ) ,
4141
+ _ => err. span_note ( b2. span , & msg2) ,
4142
+ } ;
4143
+ err. note ( & note) . emit ( ) ;
4168
4144
}
4169
4145
4170
4146
for & PrivacyError ( span, name, binding) in & self . privacy_errors {
@@ -4315,12 +4291,6 @@ impl<'a> Resolver<'a> {
4315
4291
self . name_already_seen . insert ( name, span) ;
4316
4292
}
4317
4293
4318
- fn warn_legacy_self_import ( & self , directive : & ' a ImportDirective < ' a > ) {
4319
- let ( id, span) = ( directive. id , directive. span ) ;
4320
- let msg = "`self` no longer imports values" ;
4321
- self . session . buffer_lint ( lint:: builtin:: LEGACY_IMPORTS , id, span, msg) ;
4322
- }
4323
-
4324
4294
fn check_proc_macro_attrs ( & mut self , attrs : & [ ast:: Attribute ] ) {
4325
4295
if self . proc_macro_enabled { return ; }
4326
4296
0 commit comments