about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2013-05-24 17:29:54 -0500
committerAlex Crichton <alex@alexcrichton.com>2013-05-24 17:31:15 -0500
commitac6c15aecea4bb9a328cf8f80e1cbb9f0104d98b (patch)
tree1465a4cb7434bfb2172260859f6e8b4e87cc0c13
parentb5ab1012f1f5786f550e511ba1302a22c85fcd71 (diff)
downloadrust-ac6c15aecea4bb9a328cf8f80e1cbb9f0104d98b.tar.gz
rust-ac6c15aecea4bb9a328cf8f80e1cbb9f0104d98b.zip
Actually filter view_items in blocks
-rw-r--r--src/librustc/front/config.rs4
-rw-r--r--src/test/run-pass/filter-block-view-items.rs15
2 files changed, 18 insertions, 1 deletions
diff --git a/src/librustc/front/config.rs b/src/librustc/front/config.rs
index be2f5cf0f61..b295e7524cf 100644
--- a/src/librustc/front/config.rs
+++ b/src/librustc/front/config.rs
@@ -136,8 +136,10 @@ fn fold_block(
 ) -> ast::blk_ {
     let filtered_stmts =
         b.stmts.filter_mapped(|a| filter_stmt(cx, *a));
+    let filtered_view_items =
+        b.view_items.filter_mapped(|a| filter_view_item(cx, *a));
     ast::blk_ {
-        view_items: /*bad*/copy b.view_items,
+        view_items: vec::map(filtered_view_items, |x| fld.fold_view_item(*x)),
         stmts: vec::map(filtered_stmts, |x| fld.fold_stmt(*x)),
         expr: b.expr.map(|x| fld.fold_expr(*x)),
         id: b.id,
diff --git a/src/test/run-pass/filter-block-view-items.rs b/src/test/run-pass/filter-block-view-items.rs
new file mode 100644
index 00000000000..42861833717
--- /dev/null
+++ b/src/test/run-pass/filter-block-view-items.rs
@@ -0,0 +1,15 @@
+// Copyright 2013 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.
+
+fn main() {
+    // Make sure that this view item is filtered out because otherwise it would
+    // trigger a compilation error
+    #[cfg(not_present)] use foo = bar;
+}