From 011bef8a84cbfea2458293fd367065bb20a9e7b4 Mon Sep 17 00:00:00 2001 From: "Havvy (Ryan Scheel)" Date: Tue, 24 Nov 2020 17:37:15 -0800 Subject: Move src/test/ui/if-attrs to src/test/ui/expr/if/attrs --- src/test/ui/expr/if/attrs/bad-cfg.rs | 5 +++ src/test/ui/expr/if/attrs/bad-cfg.stderr | 8 +++++ src/test/ui/expr/if/attrs/builtin-if-attr.rs | 12 +++++++ src/test/ui/expr/if/attrs/cfg-false-if-attr.rs | 43 ++++++++++++++++++++++++ src/test/ui/expr/if/attrs/else-attrs.rs | 25 ++++++++++++++ src/test/ui/expr/if/attrs/else-attrs.stderr | 26 ++++++++++++++ src/test/ui/expr/if/attrs/gate-whole-expr.rs | 15 +++++++++ src/test/ui/expr/if/attrs/let-chains-attr.rs | 13 +++++++ src/test/ui/expr/if/attrs/let-chains-attr.stderr | 11 ++++++ src/test/ui/expr/if/attrs/stmt-expr-gated.rs | 6 ++++ src/test/ui/expr/if/attrs/stmt-expr-gated.stderr | 12 +++++++ src/test/ui/if-attrs/bad-cfg.rs | 5 --- src/test/ui/if-attrs/bad-cfg.stderr | 8 ----- src/test/ui/if-attrs/builtin-if-attr.rs | 12 ------- src/test/ui/if-attrs/cfg-false-if-attr.rs | 43 ------------------------ src/test/ui/if-attrs/else-attrs.rs | 25 -------------- src/test/ui/if-attrs/else-attrs.stderr | 26 -------------- src/test/ui/if-attrs/gate-whole-expr.rs | 15 --------- src/test/ui/if-attrs/let-chains-attr.rs | 13 ------- src/test/ui/if-attrs/let-chains-attr.stderr | 11 ------ src/test/ui/if-attrs/stmt-expr-gated.rs | 6 ---- src/test/ui/if-attrs/stmt-expr-gated.stderr | 12 ------- 22 files changed, 176 insertions(+), 176 deletions(-) create mode 100644 src/test/ui/expr/if/attrs/bad-cfg.rs create mode 100644 src/test/ui/expr/if/attrs/bad-cfg.stderr create mode 100644 src/test/ui/expr/if/attrs/builtin-if-attr.rs create mode 100644 src/test/ui/expr/if/attrs/cfg-false-if-attr.rs create mode 100644 src/test/ui/expr/if/attrs/else-attrs.rs create mode 100644 src/test/ui/expr/if/attrs/else-attrs.stderr create mode 100644 src/test/ui/expr/if/attrs/gate-whole-expr.rs create mode 100644 src/test/ui/expr/if/attrs/let-chains-attr.rs create mode 100644 src/test/ui/expr/if/attrs/let-chains-attr.stderr create mode 100644 src/test/ui/expr/if/attrs/stmt-expr-gated.rs create mode 100644 src/test/ui/expr/if/attrs/stmt-expr-gated.stderr delete mode 100644 src/test/ui/if-attrs/bad-cfg.rs delete mode 100644 src/test/ui/if-attrs/bad-cfg.stderr delete mode 100644 src/test/ui/if-attrs/builtin-if-attr.rs delete mode 100644 src/test/ui/if-attrs/cfg-false-if-attr.rs delete mode 100644 src/test/ui/if-attrs/else-attrs.rs delete mode 100644 src/test/ui/if-attrs/else-attrs.stderr delete mode 100644 src/test/ui/if-attrs/gate-whole-expr.rs delete mode 100644 src/test/ui/if-attrs/let-chains-attr.rs delete mode 100644 src/test/ui/if-attrs/let-chains-attr.stderr delete mode 100644 src/test/ui/if-attrs/stmt-expr-gated.rs delete mode 100644 src/test/ui/if-attrs/stmt-expr-gated.stderr (limited to 'src/test') diff --git a/src/test/ui/expr/if/attrs/bad-cfg.rs b/src/test/ui/expr/if/attrs/bad-cfg.rs new file mode 100644 index 00000000000..3f84929a00e --- /dev/null +++ b/src/test/ui/expr/if/attrs/bad-cfg.rs @@ -0,0 +1,5 @@ +#![feature(stmt_expr_attributes)] + +fn main() { + let _ = #[cfg(FALSE)] if true {}; //~ ERROR removing an expression +} diff --git a/src/test/ui/expr/if/attrs/bad-cfg.stderr b/src/test/ui/expr/if/attrs/bad-cfg.stderr new file mode 100644 index 00000000000..8a2890886a1 --- /dev/null +++ b/src/test/ui/expr/if/attrs/bad-cfg.stderr @@ -0,0 +1,8 @@ +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 + diff --git a/src/test/ui/expr/if/attrs/builtin-if-attr.rs b/src/test/ui/expr/if/attrs/builtin-if-attr.rs new file mode 100644 index 00000000000..7e290661501 --- /dev/null +++ b/src/test/ui/expr/if/attrs/builtin-if-attr.rs @@ -0,0 +1,12 @@ +// check-pass + +fn main() { + #[allow(unused_variables)] + if true { + let a = 1; + } else if false { + let b = 1; + } else { + let c = 1; + } +} diff --git a/src/test/ui/expr/if/attrs/cfg-false-if-attr.rs b/src/test/ui/expr/if/attrs/cfg-false-if-attr.rs new file mode 100644 index 00000000000..1f77a1bb342 --- /dev/null +++ b/src/test/ui/expr/if/attrs/cfg-false-if-attr.rs @@ -0,0 +1,43 @@ +// 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() {} diff --git a/src/test/ui/expr/if/attrs/else-attrs.rs b/src/test/ui/expr/if/attrs/else-attrs.rs new file mode 100644 index 00000000000..85da7cf6bb8 --- /dev/null +++ b/src/test/ui/expr/if/attrs/else-attrs.rs @@ -0,0 +1,25 @@ +#[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() { +} diff --git a/src/test/ui/expr/if/attrs/else-attrs.stderr b/src/test/ui/expr/if/attrs/else-attrs.stderr new file mode 100644 index 00000000000..2733377054d --- /dev/null +++ b/src/test/ui/expr/if/attrs/else-attrs.stderr @@ -0,0 +1,26 @@ +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 + diff --git a/src/test/ui/expr/if/attrs/gate-whole-expr.rs b/src/test/ui/expr/if/attrs/gate-whole-expr.rs new file mode 100644 index 00000000000..63772d54b53 --- /dev/null +++ b/src/test/ui/expr/if/attrs/gate-whole-expr.rs @@ -0,0 +1,15 @@ +// 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); +} diff --git a/src/test/ui/expr/if/attrs/let-chains-attr.rs b/src/test/ui/expr/if/attrs/let-chains-attr.rs new file mode 100644 index 00000000000..5237a9ff396 --- /dev/null +++ b/src/test/ui/expr/if/attrs/let-chains-attr.rs @@ -0,0 +1,13 @@ +// 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() {} diff --git a/src/test/ui/expr/if/attrs/let-chains-attr.stderr b/src/test/ui/expr/if/attrs/let-chains-attr.stderr new file mode 100644 index 00000000000..8b987471534 --- /dev/null +++ b/src/test/ui/expr/if/attrs/let-chains-attr.stderr @@ -0,0 +1,11 @@ +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 for more information + +warning: 1 warning emitted + diff --git a/src/test/ui/expr/if/attrs/stmt-expr-gated.rs b/src/test/ui/expr/if/attrs/stmt-expr-gated.rs new file mode 100644 index 00000000000..38599c8e67c --- /dev/null +++ b/src/test/ui/expr/if/attrs/stmt-expr-gated.rs @@ -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/expr/if/attrs/stmt-expr-gated.stderr b/src/test/ui/expr/if/attrs/stmt-expr-gated.stderr new file mode 100644 index 00000000000..47dac39a9ae --- /dev/null +++ b/src/test/ui/expr/if/attrs/stmt-expr-gated.stderr @@ -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 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`. diff --git a/src/test/ui/if-attrs/bad-cfg.rs b/src/test/ui/if-attrs/bad-cfg.rs deleted file mode 100644 index 3f84929a00e..00000000000 --- a/src/test/ui/if-attrs/bad-cfg.rs +++ /dev/null @@ -1,5 +0,0 @@ -#![feature(stmt_expr_attributes)] - -fn main() { - let _ = #[cfg(FALSE)] if true {}; //~ ERROR removing an expression -} diff --git a/src/test/ui/if-attrs/bad-cfg.stderr b/src/test/ui/if-attrs/bad-cfg.stderr deleted file mode 100644 index 8a2890886a1..00000000000 --- a/src/test/ui/if-attrs/bad-cfg.stderr +++ /dev/null @@ -1,8 +0,0 @@ -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 - diff --git a/src/test/ui/if-attrs/builtin-if-attr.rs b/src/test/ui/if-attrs/builtin-if-attr.rs deleted file mode 100644 index 7e290661501..00000000000 --- a/src/test/ui/if-attrs/builtin-if-attr.rs +++ /dev/null @@ -1,12 +0,0 @@ -// check-pass - -fn main() { - #[allow(unused_variables)] - if true { - let a = 1; - } else if false { - let b = 1; - } else { - let c = 1; - } -} diff --git a/src/test/ui/if-attrs/cfg-false-if-attr.rs b/src/test/ui/if-attrs/cfg-false-if-attr.rs deleted file mode 100644 index 1f77a1bb342..00000000000 --- a/src/test/ui/if-attrs/cfg-false-if-attr.rs +++ /dev/null @@ -1,43 +0,0 @@ -// 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() {} diff --git a/src/test/ui/if-attrs/else-attrs.rs b/src/test/ui/if-attrs/else-attrs.rs deleted file mode 100644 index 85da7cf6bb8..00000000000 --- a/src/test/ui/if-attrs/else-attrs.rs +++ /dev/null @@ -1,25 +0,0 @@ -#[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() { -} diff --git a/src/test/ui/if-attrs/else-attrs.stderr b/src/test/ui/if-attrs/else-attrs.stderr deleted file mode 100644 index 2733377054d..00000000000 --- a/src/test/ui/if-attrs/else-attrs.stderr +++ /dev/null @@ -1,26 +0,0 @@ -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 - diff --git a/src/test/ui/if-attrs/gate-whole-expr.rs b/src/test/ui/if-attrs/gate-whole-expr.rs deleted file mode 100644 index 63772d54b53..00000000000 --- a/src/test/ui/if-attrs/gate-whole-expr.rs +++ /dev/null @@ -1,15 +0,0 @@ -// 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); -} diff --git a/src/test/ui/if-attrs/let-chains-attr.rs b/src/test/ui/if-attrs/let-chains-attr.rs deleted file mode 100644 index 5237a9ff396..00000000000 --- a/src/test/ui/if-attrs/let-chains-attr.rs +++ /dev/null @@ -1,13 +0,0 @@ -// 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() {} diff --git a/src/test/ui/if-attrs/let-chains-attr.stderr b/src/test/ui/if-attrs/let-chains-attr.stderr deleted file mode 100644 index 8b987471534..00000000000 --- a/src/test/ui/if-attrs/let-chains-attr.stderr +++ /dev/null @@ -1,11 +0,0 @@ -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 for more information - -warning: 1 warning emitted - diff --git a/src/test/ui/if-attrs/stmt-expr-gated.rs b/src/test/ui/if-attrs/stmt-expr-gated.rs deleted file mode 100644 index 38599c8e67c..00000000000 --- a/src/test/ui/if-attrs/stmt-expr-gated.rs +++ /dev/null @@ -1,6 +0,0 @@ -fn main() { - let _ = #[deny(warnings)] if true { //~ ERROR attributes on expressions - } else if false { - } else { - }; -} diff --git a/src/test/ui/if-attrs/stmt-expr-gated.stderr b/src/test/ui/if-attrs/stmt-expr-gated.stderr deleted file mode 100644 index 47dac39a9ae..00000000000 --- a/src/test/ui/if-attrs/stmt-expr-gated.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0658]: attributes on expressions are experimental - --> $DIR/stmt-expr-gated.rs:2:13 - | -LL | let _ = #[deny(warnings)] if true { - | ^^^^^^^^^^^^^^^^^ - | - = note: see issue #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`. -- cgit 1.4.1-3-g733a5