Skip to content

Commit ac6c15a

Browse files
committed
Actually filter view_items in blocks
1 parent b5ab101 commit ac6c15a

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

src/librustc/front/config.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,10 @@ fn fold_block(
136136
) -> ast::blk_ {
137137
let filtered_stmts =
138138
b.stmts.filter_mapped(|a| filter_stmt(cx, *a));
139+
let filtered_view_items =
140+
b.view_items.filter_mapped(|a| filter_view_item(cx, *a));
139141
ast::blk_ {
140-
view_items: /*bad*/copy b.view_items,
142+
view_items: vec::map(filtered_view_items, |x| fld.fold_view_item(*x)),
141143
stmts: vec::map(filtered_stmts, |x| fld.fold_stmt(*x)),
142144
expr: b.expr.map(|x| fld.fold_expr(*x)),
143145
id: b.id,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
fn main() {
12+
// Make sure that this view item is filtered out because otherwise it would
13+
// trigger a compilation error
14+
#[cfg(not_present)] use foo = bar;
15+
}

0 commit comments

Comments
 (0)