about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/libsyntax/config.rs2
-rw-r--r--src/test/compile-fail/cfg-non-opt-expr.rs2
2 files changed, 3 insertions, 1 deletions
diff --git a/src/libsyntax/config.rs b/src/libsyntax/config.rs
index 5ede9badd6b..f547726a6df 100644
--- a/src/libsyntax/config.rs
+++ b/src/libsyntax/config.rs
@@ -134,7 +134,7 @@ impl<'a> CfgFolder for StripUnconfigured<'a> {
     }
 
     fn visit_unremovable_expr(&mut self, expr: &ast::Expr) {
-        if let Some(attr) = expr.attrs().iter().find(|a| is_cfg(a)) {
+        if let Some(attr) = expr.attrs().iter().find(|a| is_cfg(a) || is_test_or_bench(a)) {
             let msg = "removing an expression is not supported in this position";
             self.diag.diag.span_err(attr.span, msg);
         }
diff --git a/src/test/compile-fail/cfg-non-opt-expr.rs b/src/test/compile-fail/cfg-non-opt-expr.rs
index b3ef3d72ca3..a4b24fa8b4b 100644
--- a/src/test/compile-fail/cfg-non-opt-expr.rs
+++ b/src/test/compile-fail/cfg-non-opt-expr.rs
@@ -17,4 +17,6 @@ fn main() {
     //~^ ERROR removing an expression is not supported in this position
     let _ = [1, 2, 3][#[cfg(unset)] 1];
     //~^ ERROR removing an expression is not supported in this position
+    let _ = #[test] ();
+    //~^ ERROR removing an expression is not supported in this position
 }