From 8254e5576090e086ab25220df9edae024d45a9dd Mon Sep 17 00:00:00 2001 From: Jeffrey Seyfried Date: Thu, 9 Jun 2016 00:26:35 +0000 Subject: [PATCH 1/2] Avoid configuring interpolated items. --- src/libsyntax/config.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/libsyntax/config.rs b/src/libsyntax/config.rs index c164e89c52f38..41ad1611e3ec8 100644 --- a/src/libsyntax/config.rs +++ b/src/libsyntax/config.rs @@ -14,6 +14,7 @@ use feature_gate::GatedCfgAttr; use fold::Folder; use {ast, fold, attr}; use codemap::{Spanned, respan}; +use parse::token; use ptr::P; use util::small_vector::SmallVector; @@ -247,6 +248,12 @@ impl fold::Folder for T { self.configure(item).map(|item| fold::noop_fold_trait_item(item, self)) .unwrap_or(SmallVector::zero()) } + + fn fold_interpolated(&mut self, nt: token::Nonterminal) -> token::Nonterminal { + // Don't configure interpolated AST (c.f. #34171). + // Interpolated AST will get configured once the surrounding tokens are parsed. + nt + } } fn fold_expr(folder: &mut F, expr: P) -> P { From c751ec626da92a138f23327f3eaede30d5747bde Mon Sep 17 00:00:00 2001 From: Jeffrey Seyfried Date: Thu, 9 Jun 2016 00:29:51 +0000 Subject: [PATCH 2/2] Add regression test --- src/test/compile-fail/issue-34171.rs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 src/test/compile-fail/issue-34171.rs diff --git a/src/test/compile-fail/issue-34171.rs b/src/test/compile-fail/issue-34171.rs new file mode 100644 index 0000000000000..30dd34ae9a029 --- /dev/null +++ b/src/test/compile-fail/issue-34171.rs @@ -0,0 +1,21 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(rustc_attrs)] + +macro_rules! null { ($i:tt) => {} } +macro_rules! apply_null { + ($i:item) => { null! { $i } } +} + +#[rustc_error] +fn main() { //~ ERROR compilation successful + apply_null!(#[cfg(all())] fn f() {}); +}