@@ -21,22 +21,18 @@ use rustc::hir::def_id::{DefId, CRATE_DEF_INDEX, DefIndex,
2121use rustc:: hir:: def:: { Def , NonMacroAttrKind } ;
2222use rustc:: hir:: map:: { self , DefCollector } ;
2323use rustc:: { ty, lint} ;
24- use syntax:: ast:: { self , Name , Ident } ;
24+ use syntax:: ast:: { self , Ident } ;
2525use syntax:: attr;
2626use syntax:: errors:: DiagnosticBuilder ;
2727use syntax:: ext:: base:: { self , Determinacy } ;
28- use syntax:: ext:: base:: { MacroKind , SyntaxExtension , Resolver as SyntaxResolver } ;
28+ use syntax:: ext:: base:: { MacroKind , SyntaxExtension } ;
2929use syntax:: ext:: expand:: { AstFragment , Invocation , InvocationKind } ;
3030use syntax:: ext:: hygiene:: { self , Mark } ;
3131use 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 } ;
3433use syntax:: fold:: { self , Folder } ;
35- use syntax:: parse:: parser:: PathStyle ;
36- use syntax:: parse:: token:: { self , Token } ;
3734use syntax:: ptr:: P ;
3835use syntax:: symbol:: { Symbol , keywords} ;
39- use syntax:: tokenstream:: { TokenStream , TokenTree , Delimited , DelimSpan } ;
4036use syntax:: util:: lev_distance:: find_best_match_for_name;
4137use syntax_pos:: { Span , DUMMY_SP } ;
4238use errors:: Applicability ;
@@ -194,10 +190,6 @@ impl<'a, 'crateloader: 'a> base::Resolver for Resolver<'a, 'crateloader> {
194190 ret. into_iter ( ) . next ( ) . unwrap ( )
195191 }
196192
197- fn is_whitelisted_legacy_custom_derive ( & self , name : Name ) -> bool {
198- self . whitelisted_legacy_custom_derives . contains ( & name)
199- }
200-
201193 fn visit_ast_fragment_with_placeholders ( & mut self , mark : Mark , fragment : & AstFragment ,
202194 derives : & [ Mark ] ) {
203195 let invocation = self . invocations [ & mark] ;
@@ -240,79 +232,6 @@ impl<'a, 'crateloader: 'a> base::Resolver for Resolver<'a, 'crateloader> {
240232 ImportResolver { resolver : self } . resolve_imports ( )
241233 }
242234
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-
316235 fn resolve_macro_invocation ( & mut self , invoc : & Invocation , invoc_id : Mark , force : bool )
317236 -> Result < Option < Lrc < SyntaxExtension > > , Determinacy > {
318237 let ( path, kind, derives_in_scope, after_derive) = match invoc. kind {
@@ -430,11 +349,6 @@ impl<'a, 'cl> Resolver<'a, 'cl> {
430349 feature_err ( & self . session . parse_sess , "rustc_attrs" , path. span ,
431350 GateIssue :: Language , & msg) . emit ( ) ;
432351 }
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- }
438352 } else if !features. custom_attribute {
439353 let msg = format ! ( "The attribute `{}` is currently unknown to the \
440354 compiler and may have meaning added to it in the \
@@ -1218,14 +1132,4 @@ impl<'a, 'cl> Resolver<'a, 'cl> {
12181132 self . define ( module, ident, MacroNS , ( def, vis, item. span , expansion) ) ;
12191133 }
12201134 }
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- }
12311135}
0 commit comments