From 82b49cd2000859c8208cf15a78441a72a3edc499 Mon Sep 17 00:00:00 2001 From: Jeffrey Seyfried Date: Sat, 21 May 2016 01:26:30 +0000 Subject: [PATCH] Refactor away `check_attributes` --- src/libsyntax/ext/expand.rs | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index c8272316c3c76..9bfeb81b74a97 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -69,16 +69,6 @@ impl_macro_generable! { "statement", .make_stmts, lift .fold_stmt, |_span| SmallVector::zero(); } -// this function is called to detect use of feature-gated or invalid attributes -// on macro invoations since they will not be detected after macro expansion -fn check_attributes(attrs: &[ast::Attribute], fld: &MacroExpander) { - for attr in attrs.iter() { - feature_gate::check_attribute(&attr, &fld.cx.parse_sess.span_diagnostic, - &fld.cx.parse_sess.codemap(), - &fld.cx.ecfg.features.unwrap()); - } -} - pub fn expand_expr(e: P, fld: &mut MacroExpander) -> P { let expr_span = e.span; return e.and_then(|ast::Expr {id, node, span, attrs}| match node { @@ -209,7 +199,13 @@ fn expand_mac_invoc(mac: ast::Mac, ident: Option, attrs: Vec(path: &ast::Path, ident: Option, tts: Vec, mark: Mrk, attrs: Vec, call_site: Span, fld: &'a mut MacroExpander) -> Option> { - check_attributes(&attrs, fld); + // Detect use of feature-gated or invalid attributes on macro invoations + // since they will not be detected after macro expansion. + for attr in attrs.iter() { + feature_gate::check_attribute(&attr, &fld.cx.parse_sess.span_diagnostic, + &fld.cx.parse_sess.codemap(), + &fld.cx.ecfg.features.unwrap()); + } if path.segments.len() > 1 { fld.cx.span_err(path.span, "expected macro name without module separators");