--- /dev/null
+#![feature(stmt_expr_attributes)]
+
+fn main() {
+ let _ = #[cfg(FALSE)] if true {}; //~ ERROR removing an expression
+}
--- /dev/null
+error: removing an expression is not supported in this position
+ --> $DIR/bad-cfg.rs:4:13
+ |
+LL | let _ = #[cfg(FALSE)] if true {};
+ | ^^^^^^^^^^^^^
+
+error: aborting due to previous error
+
--- /dev/null
+// check-pass
+
+fn main() {
+ #[allow(unused_variables)]
+ if true {
+ let a = 1;
+ } else if false {
+ let b = 1;
+ } else {
+ let c = 1;
+ }
+}
--- /dev/null
+// check-pass
+
+#[cfg(FALSE)]
+fn simple_attr() {
+ #[attr] if true {}
+ #[allow_warnings] if true {}
+}
+
+#[cfg(FALSE)]
+fn if_else_chain() {
+ #[first_attr] if true {
+ } else if false {
+ } else {
+ }
+}
+
+#[cfg(FALSE)]
+fn if_let() {
+ #[attr] if let Some(_) = Some(true) {}
+}
+
+fn bar() {
+ #[cfg(FALSE)]
+ if true {
+ let x: () = true; // Should not error due to the #[cfg(FALSE)]
+ }
+
+ #[cfg_attr(not(unset_attr), cfg(FALSE))]
+ if true {
+ let a: () = true; // Should not error due to the applied #[cfg(FALSE)]
+ }
+}
+
+macro_rules! custom_macro {
+ ($expr:expr) => {}
+}
+
+custom_macro! {
+ #[attr] if true {}
+}
+
+
+fn main() {}
--- /dev/null
+#[cfg(FALSE)]
+fn if_else_parse_error() {
+ if true {
+ } #[attr] else if false { //~ ERROR expected
+ }
+}
+
+#[cfg(FALSE)]
+fn else_attr_ifparse_error() {
+ if true {
+ } else #[attr] if false { //~ ERROR outer attributes are not allowed
+ } else {
+ }
+}
+
+#[cfg(FALSE)]
+fn else_parse_error() {
+ if true {
+ } else if false {
+ } #[attr] else { //~ ERROR expected
+ }
+}
+
+fn main() {
+}
--- /dev/null
+error: expected expression, found keyword `else`
+ --> $DIR/else-attrs.rs:4:15
+ |
+LL | } #[attr] else if false {
+ | ^^^^ expected expression
+
+error: outer attributes are not allowed on `if` and `else` branches
+ --> $DIR/else-attrs.rs:11:12
+ |
+LL | } else #[attr] if false {
+ | _______----_^^^^^^^_-
+ | | | |
+ | | | help: remove the attributes
+ | | the branch belongs to this `else`
+LL | | } else {
+LL | | }
+ | |_____- the attributes are attached to this branch
+
+error: expected expression, found keyword `else`
+ --> $DIR/else-attrs.rs:20:15
+ |
+LL | } #[attr] else {
+ | ^^^^ expected expression
+
+error: aborting due to 3 previous errors
+
--- /dev/null
+// run-pass
+
+fn main() {
+ let x = 1;
+
+ #[cfg(FALSE)]
+ if false {
+ x = 2;
+ } else if true {
+ x = 3;
+ } else {
+ x = 4;
+ }
+ assert_eq!(x, 1);
+}
--- /dev/null
+// check-pass
+
+#![feature(let_chains)] //~ WARN the feature `let_chains` is incomplete
+
+#[cfg(FALSE)]
+fn foo() {
+ #[attr]
+ if let Some(_) = Some(true) && let Ok(_) = Ok(1) {
+ } else if let Some(false) = Some(true) {
+ }
+}
+
+fn main() {}
--- /dev/null
+warning: the feature `let_chains` is incomplete and may not be safe to use and/or cause compiler crashes
+ --> $DIR/let-chains-attr.rs:3:12
+ |
+LL | #![feature(let_chains)]
+ | ^^^^^^^^^^
+ |
+ = note: `#[warn(incomplete_features)]` on by default
+ = note: see issue #53667 <https://github.com/rust-lang/rust/issues/53667> for more information
+
+warning: 1 warning emitted
+
--- /dev/null
+fn main() {
+ let _ = #[deny(warnings)] if true { //~ ERROR attributes on expressions
+ } else if false {
+ } else {
+ };
+}
--- /dev/null
+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`.
+++ /dev/null
-#![feature(stmt_expr_attributes)]
-
-fn main() {
- let _ = #[cfg(FALSE)] if true {}; //~ ERROR removing an expression
-}
+++ /dev/null
-error: removing an expression is not supported in this position
- --> $DIR/bad-cfg.rs:4:13
- |
-LL | let _ = #[cfg(FALSE)] if true {};
- | ^^^^^^^^^^^^^
-
-error: aborting due to previous error
-
+++ /dev/null
-// check-pass
-
-fn main() {
- #[allow(unused_variables)]
- if true {
- let a = 1;
- } else if false {
- let b = 1;
- } else {
- let c = 1;
- }
-}
+++ /dev/null
-// check-pass
-
-#[cfg(FALSE)]
-fn simple_attr() {
- #[attr] if true {}
- #[allow_warnings] if true {}
-}
-
-#[cfg(FALSE)]
-fn if_else_chain() {
- #[first_attr] if true {
- } else if false {
- } else {
- }
-}
-
-#[cfg(FALSE)]
-fn if_let() {
- #[attr] if let Some(_) = Some(true) {}
-}
-
-fn bar() {
- #[cfg(FALSE)]
- if true {
- let x: () = true; // Should not error due to the #[cfg(FALSE)]
- }
-
- #[cfg_attr(not(unset_attr), cfg(FALSE))]
- if true {
- let a: () = true; // Should not error due to the applied #[cfg(FALSE)]
- }
-}
-
-macro_rules! custom_macro {
- ($expr:expr) => {}
-}
-
-custom_macro! {
- #[attr] if true {}
-}
-
-
-fn main() {}
+++ /dev/null
-#[cfg(FALSE)]
-fn if_else_parse_error() {
- if true {
- } #[attr] else if false { //~ ERROR expected
- }
-}
-
-#[cfg(FALSE)]
-fn else_attr_ifparse_error() {
- if true {
- } else #[attr] if false { //~ ERROR outer attributes are not allowed
- } else {
- }
-}
-
-#[cfg(FALSE)]
-fn else_parse_error() {
- if true {
- } else if false {
- } #[attr] else { //~ ERROR expected
- }
-}
-
-fn main() {
-}
+++ /dev/null
-error: expected expression, found keyword `else`
- --> $DIR/else-attrs.rs:4:15
- |
-LL | } #[attr] else if false {
- | ^^^^ expected expression
-
-error: outer attributes are not allowed on `if` and `else` branches
- --> $DIR/else-attrs.rs:11:12
- |
-LL | } else #[attr] if false {
- | _______----_^^^^^^^_-
- | | | |
- | | | help: remove the attributes
- | | the branch belongs to this `else`
-LL | | } else {
-LL | | }
- | |_____- the attributes are attached to this branch
-
-error: expected expression, found keyword `else`
- --> $DIR/else-attrs.rs:20:15
- |
-LL | } #[attr] else {
- | ^^^^ expected expression
-
-error: aborting due to 3 previous errors
-
+++ /dev/null
-// run-pass
-
-fn main() {
- let x = 1;
-
- #[cfg(FALSE)]
- if false {
- x = 2;
- } else if true {
- x = 3;
- } else {
- x = 4;
- }
- assert_eq!(x, 1);
-}
+++ /dev/null
-// check-pass
-
-#![feature(let_chains)] //~ WARN the feature `let_chains` is incomplete
-
-#[cfg(FALSE)]
-fn foo() {
- #[attr]
- if let Some(_) = Some(true) && let Ok(_) = Ok(1) {
- } else if let Some(false) = Some(true) {
- }
-}
-
-fn main() {}
+++ /dev/null
-warning: the feature `let_chains` is incomplete and may not be safe to use and/or cause compiler crashes
- --> $DIR/let-chains-attr.rs:3:12
- |
-LL | #![feature(let_chains)]
- | ^^^^^^^^^^
- |
- = note: `#[warn(incomplete_features)]` on by default
- = note: see issue #53667 <https://github.com/rust-lang/rust/issues/53667> for more information
-
-warning: 1 warning emitted
-
+++ /dev/null
-fn main() {
- let _ = #[deny(warnings)] if true { //~ ERROR attributes on expressions
- } else if false {
- } else {
- };
-}
+++ /dev/null
-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`.