]> git.lizzy.rs Git - rust.git/commitdiff
Test that stmt_expr_attrs properly gates if-attrs
authorAaron Hill <aa1ronham@gmail.com>
Wed, 19 Feb 2020 15:45:21 +0000 (10:45 -0500)
committerAaron Hill <aa1ronham@gmail.com>
Wed, 4 Mar 2020 21:43:13 +0000 (16:43 -0500)
src/test/ui/parser/if-attrs/stmt-expr-gated.rs [new file with mode: 0644]
src/test/ui/parser/if-attrs/stmt-expr-gated.stderr [new file with mode: 0644]

diff --git a/src/test/ui/parser/if-attrs/stmt-expr-gated.rs b/src/test/ui/parser/if-attrs/stmt-expr-gated.rs
new file mode 100644 (file)
index 0000000..38599c8
--- /dev/null
@@ -0,0 +1,6 @@
+fn main() {
+    let _ = #[deny(warnings)] if true { //~ ERROR attributes on expressions
+    } else if false {
+    } else {
+    };
+}
diff --git a/src/test/ui/parser/if-attrs/stmt-expr-gated.stderr b/src/test/ui/parser/if-attrs/stmt-expr-gated.stderr
new file mode 100644 (file)
index 0000000..47dac39
--- /dev/null
@@ -0,0 +1,12 @@
+error[E0658]: attributes on expressions are experimental
+  --> $DIR/stmt-expr-gated.rs:2:13
+   |
+LL |     let _ = #[deny(warnings)] if true {
+   |             ^^^^^^^^^^^^^^^^^
+   |
+   = note: see issue #15701 <https://github.com/rust-lang/rust/issues/15701> for more information
+   = help: add `#![feature(stmt_expr_attributes)]` to the crate attributes to enable
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0658`.