@@ -21,22 +21,18 @@ use rustc::hir::def_id::{DefId, CRATE_DEF_INDEX, DefIndex,
21
21
use rustc:: hir:: def:: { Def , NonMacroAttrKind } ;
22
22
use rustc:: hir:: map:: { self , DefCollector } ;
23
23
use rustc:: { ty, lint} ;
24
- use syntax:: ast:: { self , Name , Ident } ;
24
+ use syntax:: ast:: { self , Ident } ;
25
25
use syntax:: attr;
26
26
use syntax:: errors:: DiagnosticBuilder ;
27
27
use syntax:: ext:: base:: { self , Determinacy } ;
28
- use syntax:: ext:: base:: { MacroKind , SyntaxExtension , Resolver as SyntaxResolver } ;
28
+ use syntax:: ext:: base:: { MacroKind , SyntaxExtension } ;
29
29
use syntax:: ext:: expand:: { AstFragment , Invocation , InvocationKind } ;
30
30
use syntax:: ext:: hygiene:: { self , Mark } ;
31
31
use syntax:: ext:: tt:: macro_rules;
32
- use syntax:: feature_gate:: { self , feature_err, emit_feature_err, is_builtin_attr_name, GateIssue } ;
33
- use syntax:: feature_gate:: EXPLAIN_DERIVE_UNDERSCORE ;
32
+ use syntax:: feature_gate:: { feature_err, is_builtin_attr_name, GateIssue } ;
34
33
use syntax:: fold:: { self , Folder } ;
35
- use syntax:: parse:: parser:: PathStyle ;
36
- use syntax:: parse:: token:: { self , Token } ;
37
34
use syntax:: ptr:: P ;
38
35
use syntax:: symbol:: { Symbol , keywords} ;
39
- use syntax:: tokenstream:: { TokenStream , TokenTree , Delimited , DelimSpan } ;
40
36
use syntax:: util:: lev_distance:: find_best_match_for_name;
41
37
use syntax_pos:: { Span , DUMMY_SP } ;
42
38
use errors:: Applicability ;
@@ -194,10 +190,6 @@ impl<'a, 'crateloader: 'a> base::Resolver for Resolver<'a, 'crateloader> {
194
190
ret. into_iter ( ) . next ( ) . unwrap ( )
195
191
}
196
192
197
- fn is_whitelisted_legacy_custom_derive ( & self , name : Name ) -> bool {
198
- self . whitelisted_legacy_custom_derives . contains ( & name)
199
- }
200
-
201
193
fn visit_ast_fragment_with_placeholders ( & mut self , mark : Mark , fragment : & AstFragment ,
202
194
derives : & [ Mark ] ) {
203
195
let invocation = self . invocations [ & mark] ;
@@ -240,79 +232,6 @@ impl<'a, 'crateloader: 'a> base::Resolver for Resolver<'a, 'crateloader> {
240
232
ImportResolver { resolver : self } . resolve_imports ( )
241
233
}
242
234
243
- // Resolves attribute and derive legacy macros from `#![plugin(..)]`.
244
- fn find_legacy_attr_invoc ( & mut self , attrs : & mut Vec < ast:: Attribute > , allow_derive : bool )
245
- -> Option < ast:: Attribute > {
246
- if !allow_derive {
247
- return None ;
248
- }
249
-
250
- // Check for legacy derives
251
- for i in 0 ..attrs. len ( ) {
252
- let name = attrs[ i] . name ( ) ;
253
-
254
- if name == "derive" {
255
- let result = attrs[ i] . parse_list ( & self . session . parse_sess , |parser| {
256
- parser. parse_path_allowing_meta ( PathStyle :: Mod )
257
- } ) ;
258
-
259
- let mut traits = match result {
260
- Ok ( traits) => traits,
261
- Err ( mut e) => {
262
- e. cancel ( ) ;
263
- continue
264
- }
265
- } ;
266
-
267
- for j in 0 ..traits. len ( ) {
268
- if traits[ j] . segments . len ( ) > 1 {
269
- continue
270
- }
271
- let trait_name = traits[ j] . segments [ 0 ] . ident . name ;
272
- let legacy_name = Symbol :: intern ( & format ! ( "derive_{}" , trait_name) ) ;
273
- if !self . builtin_macros . contains_key ( & legacy_name) {
274
- continue
275
- }
276
- let span = traits. remove ( j) . span ;
277
- self . gate_legacy_custom_derive ( legacy_name, span) ;
278
- if traits. is_empty ( ) {
279
- attrs. remove ( i) ;
280
- } else {
281
- let mut tokens = Vec :: with_capacity ( traits. len ( ) - 1 ) ;
282
- for ( j, path) in traits. iter ( ) . enumerate ( ) {
283
- if j > 0 {
284
- tokens. push ( TokenTree :: Token ( attrs[ i] . span , Token :: Comma ) . into ( ) ) ;
285
- }
286
- tokens. reserve ( ( path. segments . len ( ) * 2 ) . saturating_sub ( 1 ) ) ;
287
- for ( k, segment) in path. segments . iter ( ) . enumerate ( ) {
288
- if k > 0 {
289
- tokens. push ( TokenTree :: Token ( path. span , Token :: ModSep ) . into ( ) ) ;
290
- }
291
- let tok = Token :: from_ast_ident ( segment. ident ) ;
292
- tokens. push ( TokenTree :: Token ( path. span , tok) . into ( ) ) ;
293
- }
294
- }
295
- let delim_span = DelimSpan :: from_single ( attrs[ i] . span ) ;
296
- attrs[ i] . tokens = TokenTree :: Delimited ( delim_span, Delimited {
297
- delim : token:: Paren ,
298
- tts : TokenStream :: concat ( tokens) . into ( ) ,
299
- } ) . into ( ) ;
300
- }
301
- return Some ( ast:: Attribute {
302
- path : ast:: Path :: from_ident ( Ident :: new ( legacy_name, span) ) ,
303
- tokens : TokenStream :: empty ( ) ,
304
- id : attr:: mk_attr_id ( ) ,
305
- style : ast:: AttrStyle :: Outer ,
306
- is_sugared_doc : false ,
307
- span,
308
- } ) ;
309
- }
310
- }
311
- }
312
-
313
- None
314
- }
315
-
316
235
fn resolve_macro_invocation ( & mut self , invoc : & Invocation , invoc_id : Mark , force : bool )
317
236
-> Result < Option < Lrc < SyntaxExtension > > , Determinacy > {
318
237
let ( path, kind, derives_in_scope, after_derive) = match invoc. kind {
@@ -430,11 +349,6 @@ impl<'a, 'cl> Resolver<'a, 'cl> {
430
349
feature_err ( & self . session . parse_sess , "rustc_attrs" , path. span ,
431
350
GateIssue :: Language , & msg) . emit ( ) ;
432
351
}
433
- } else if name. starts_with ( "derive_" ) {
434
- if !features. custom_derive {
435
- feature_err ( & self . session . parse_sess , "custom_derive" , path. span ,
436
- GateIssue :: Language , EXPLAIN_DERIVE_UNDERSCORE ) . emit ( ) ;
437
- }
438
352
} else if !features. custom_attribute {
439
353
let msg = format ! ( "The attribute `{}` is currently unknown to the \
440
354
compiler and may have meaning added to it in the \
@@ -1218,14 +1132,4 @@ impl<'a, 'cl> Resolver<'a, 'cl> {
1218
1132
self . define ( module, ident, MacroNS , ( def, vis, item. span , expansion) ) ;
1219
1133
}
1220
1134
}
1221
-
1222
- fn gate_legacy_custom_derive ( & mut self , name : Symbol , span : Span ) {
1223
- if !self . session . features_untracked ( ) . custom_derive {
1224
- let sess = & self . session . parse_sess ;
1225
- let explain = feature_gate:: EXPLAIN_CUSTOM_DERIVE ;
1226
- emit_feature_err ( sess, "custom_derive" , span, GateIssue :: Language , explain) ;
1227
- } else if !self . is_whitelisted_legacy_custom_derive ( name) {
1228
- self . session . span_warn ( span, feature_gate:: EXPLAIN_DEPR_CUSTOM_DERIVE ) ;
1229
- }
1230
- }
1231
1135
}
0 commit comments