about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2013-05-24 21:25:54 -0700
committerbors <bors@rust-lang.org>2013-05-24 21:25:54 -0700
commit0628c92540c467de03524fae7f7061065de2295c (patch)
tree3836100293ab9dbddc97acbaefe9f7b29b20bef7
parent5f90f1ca1d142dc408108a58e8ac48f10f2d719b (diff)
parentac6c15aecea4bb9a328cf8f80e1cbb9f0104d98b (diff)
downloadrust-0628c92540c467de03524fae7f7061065de2295c.tar.gz
rust-0628c92540c467de03524fae7f7061065de2295c.zip
auto merge of #6726 : alexcrichton/rust/filter-blocks, r=z0w0
Among other things, this suppresses a spurious unused import warning in the compiler right now.
-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;
+}