Auto merge of #34172 - jseyfried:avoid_configuring_interpolated_ast, r=alexcrichton

Fix ICE regression caused by configuring interpolated AST

Fixes #34171.
r? @nrc
This commit is contained in:
bors 2016-06-10 16:55:30 -07:00 committed by GitHub
commit 0554abac63
2 changed files with 28 additions and 0 deletions

View File

@ -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<T: CfgFolder> 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<F: CfgFolder>(folder: &mut F, expr: P<ast::Expr>) -> P<ast::Expr> {

View File

@ -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 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, 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() {});
}