1
+ use crate :: ast;
2
+ use crate :: attr:: { self , TransparencyError } ;
1
3
use crate :: edition:: Edition ;
2
4
use crate :: ext:: base:: { DummyResult , ExtCtxt , MacResult , TTMacroExpander } ;
3
5
use crate :: ext:: base:: { SyntaxExtension , SyntaxExtensionKind } ;
@@ -15,7 +17,6 @@ use crate::parse::token::{self, NtTT, Token};
15
17
use crate :: parse:: { Directory , ParseSess } ;
16
18
use crate :: symbol:: { kw, sym, Symbol } ;
17
19
use crate :: tokenstream:: { DelimSpan , TokenStream , TokenTree } ;
18
- use crate :: { ast, attr, attr:: TransparencyError } ;
19
20
20
21
use errors:: { DiagnosticBuilder , FatalError } ;
21
22
use log:: debug;
@@ -290,6 +291,7 @@ pub fn compile(
290
291
def : & ast:: Item ,
291
292
edition : Edition ,
292
293
) -> SyntaxExtension {
294
+ let diag = & sess. span_diagnostic ;
293
295
let lhs_nm = ast:: Ident :: new ( sym:: lhs, def. span ) ;
294
296
let rhs_nm = ast:: Ident :: new ( sym:: rhs, def. span ) ;
295
297
let tt_spec = ast:: Ident :: new ( sym:: tt, def. span ) ;
@@ -423,71 +425,25 @@ pub fn compile(
423
425
let ( transparency, transparency_error) = attr:: find_transparency ( & def. attrs , body. legacy ) ;
424
426
match transparency_error {
425
427
Some ( TransparencyError :: UnknownTransparency ( value, span) ) =>
426
- sess. span_diagnostic . span_err (
427
- span, & format ! ( "unknown macro transparency: `{}`" , value)
428
- ) ,
428
+ diag. span_err ( span, & format ! ( "unknown macro transparency: `{}`" , value) ) ,
429
429
Some ( TransparencyError :: MultipleTransparencyAttrs ( old_span, new_span) ) =>
430
- sess. span_diagnostic . span_err (
431
- vec ! [ old_span, new_span] , "multiple macro transparency attributes"
432
- ) ,
430
+ diag. span_err ( vec ! [ old_span, new_span] , "multiple macro transparency attributes" ) ,
433
431
None => { }
434
432
}
435
433
436
434
let expander: Box < _ > = Box :: new ( MacroRulesMacroExpander {
437
435
name : def. ident , span : def. span , transparency, lhses, rhses, valid
438
436
} ) ;
439
437
440
- let allow_internal_unstable =
441
- attr:: find_by_name ( & def. attrs , sym:: allow_internal_unstable) . map ( |attr| {
442
- attr. meta_item_list ( )
443
- . map ( |list| {
444
- list. iter ( )
445
- . filter_map ( |it| {
446
- let name = it. ident ( ) . map ( |ident| ident. name ) ;
447
- if name. is_none ( ) {
448
- sess. span_diagnostic . span_err (
449
- it. span ( ) ,
450
- "allow internal unstable expects feature names" ,
451
- )
452
- }
453
- name
454
- } )
455
- . collect :: < Vec < Symbol > > ( )
456
- . into ( )
457
- } )
458
- . unwrap_or_else ( || {
459
- sess. span_diagnostic . span_warn (
460
- attr. span ,
461
- "allow_internal_unstable expects list of feature names. In the \
462
- future this will become a hard error. Please use `allow_internal_unstable(\
463
- foo, bar)` to only allow the `foo` and `bar` features",
464
- ) ;
465
- vec ! [ sym:: allow_internal_unstable_backcompat_hack] . into ( )
466
- } )
467
- } ) ;
468
-
469
- let mut local_inner_macros = false ;
470
- if let Some ( macro_export) = attr:: find_by_name ( & def. attrs , sym:: macro_export) {
471
- if let Some ( l) = macro_export. meta_item_list ( ) {
472
- local_inner_macros = attr:: list_contains_name ( & l, sym:: local_inner_macros) ;
473
- }
474
- }
475
-
476
- let is_builtin = attr:: contains_name ( & def. attrs , sym:: rustc_builtin_macro) ;
477
-
478
- SyntaxExtension {
479
- kind : SyntaxExtensionKind :: LegacyBang ( expander) ,
480
- span : def. span ,
481
- allow_internal_unstable,
482
- allow_internal_unsafe : attr:: contains_name ( & def. attrs , sym:: allow_internal_unsafe) ,
483
- local_inner_macros,
484
- stability : attr:: find_stability ( & sess, & def. attrs , def. span ) ,
485
- deprecation : attr:: find_deprecation ( & sess, & def. attrs , def. span ) ,
486
- helper_attrs : Vec :: new ( ) ,
438
+ SyntaxExtension :: new (
439
+ sess,
440
+ SyntaxExtensionKind :: LegacyBang ( expander) ,
441
+ def. span ,
442
+ Vec :: new ( ) ,
487
443
edition,
488
- is_builtin ,
489
- is_derive_copy : is_builtin && def. ident . name == sym :: Copy ,
490
- }
444
+ def . ident . name ,
445
+ & def. attrs ,
446
+ )
491
447
}
492
448
493
449
fn check_lhs_nt_follows (
0 commit comments