diff options
| author | Mazdak Farrokhzad <twingoow@gmail.com> | 2020-03-07 17:16:29 +0100 |
|---|---|---|
| committer | Mazdak Farrokhzad <twingoow@gmail.com> | 2020-03-10 08:55:18 +0100 |
| commit | 458383dd337f276d091fa2de81bb7c1d31dde5fa (patch) | |
| tree | 064c57b7be465e8364441365612d52d8bcc084ea /src/test/ui/parser | |
| parent | ba3ae46de972f3e70319c25a5da69378454cb88d (diff) | |
| download | rust-458383dd337f276d091fa2de81bb7c1d31dde5fa.tar.gz rust-458383dd337f276d091fa2de81bb7c1d31dde5fa.zip | |
parse_if_expr: recover on attributes
Diffstat (limited to 'src/test/ui/parser')
| -rw-r--r-- | src/test/ui/parser/attr-stmt-expr-attr-bad.rs | 16 | ||||
| -rw-r--r-- | src/test/ui/parser/attr-stmt-expr-attr-bad.stderr | 68 | ||||
| -rw-r--r-- | src/test/ui/parser/doc-comment-in-if-statement.rs | 2 | ||||
| -rw-r--r-- | src/test/ui/parser/doc-comment-in-if-statement.stderr | 8 |
4 files changed, 49 insertions, 45 deletions
diff --git a/src/test/ui/parser/attr-stmt-expr-attr-bad.rs b/src/test/ui/parser/attr-stmt-expr-attr-bad.rs index f3980a59648..09f494bdc2f 100644 --- a/src/test/ui/parser/attr-stmt-expr-attr-bad.rs +++ b/src/test/ui/parser/attr-stmt-expr-attr-bad.rs @@ -39,35 +39,35 @@ fn main() {} #[cfg(FALSE)] fn e() { let _ = #[attr] &mut #![attr] 0; } //~^ ERROR an inner attribute is not permitted in this context #[cfg(FALSE)] fn e() { let _ = if 0 #[attr] {}; } -//~^ ERROR expected `{`, found `#` +//~^ ERROR outer attributes are not allowed on `if` #[cfg(FALSE)] fn e() { let _ = if 0 {#![attr]}; } //~^ ERROR an inner attribute is not permitted in this context #[cfg(FALSE)] fn e() { let _ = if 0 {} #[attr] else {}; } //~^ ERROR expected one of #[cfg(FALSE)] fn e() { let _ = if 0 {} else #[attr] {}; } -//~^ ERROR expected `{`, found `#` +//~^ ERROR outer attributes are not allowed on `if` #[cfg(FALSE)] fn e() { let _ = if 0 {} else {#![attr]}; } //~^ ERROR an inner attribute is not permitted in this context #[cfg(FALSE)] fn e() { let _ = if 0 {} else #[attr] if 0 {}; } -//~^ ERROR expected `{`, found `#` +//~^ ERROR outer attributes are not allowed on `if` #[cfg(FALSE)] fn e() { let _ = if 0 {} else if 0 #[attr] {}; } -//~^ ERROR expected `{`, found `#` +//~^ ERROR outer attributes are not allowed on `if` #[cfg(FALSE)] fn e() { let _ = if 0 {} else if 0 {#![attr]}; } //~^ ERROR an inner attribute is not permitted in this context #[cfg(FALSE)] fn e() { let _ = if let _ = 0 #[attr] {}; } -//~^ ERROR expected `{`, found `#` +//~^ ERROR outer attributes are not allowed on `if` #[cfg(FALSE)] fn e() { let _ = if let _ = 0 {#![attr]}; } //~^ ERROR an inner attribute is not permitted in this context #[cfg(FALSE)] fn e() { let _ = if let _ = 0 {} #[attr] else {}; } //~^ ERROR expected one of #[cfg(FALSE)] fn e() { let _ = if let _ = 0 {} else #[attr] {}; } -//~^ ERROR expected `{`, found `#` +//~^ ERROR outer attributes are not allowed on `if` #[cfg(FALSE)] fn e() { let _ = if let _ = 0 {} else {#![attr]}; } //~^ ERROR an inner attribute is not permitted in this context #[cfg(FALSE)] fn e() { let _ = if let _ = 0 {} else #[attr] if let _ = 0 {}; } -//~^ ERROR expected `{`, found `#` +//~^ ERROR outer attributes are not allowed on `if` #[cfg(FALSE)] fn e() { let _ = if let _ = 0 {} else if let _ = 0 #[attr] {}; } -//~^ ERROR expected `{`, found `#` +//~^ ERROR outer attributes are not allowed on `if` #[cfg(FALSE)] fn e() { let _ = if let _ = 0 {} else if let _ = 0 {#![attr]}; } //~^ ERROR an inner attribute is not permitted in this context diff --git a/src/test/ui/parser/attr-stmt-expr-attr-bad.stderr b/src/test/ui/parser/attr-stmt-expr-attr-bad.stderr index af490150913..6dfe7aad6ea 100644 --- a/src/test/ui/parser/attr-stmt-expr-attr-bad.stderr +++ b/src/test/ui/parser/attr-stmt-expr-attr-bad.stderr @@ -136,14 +136,14 @@ LL | #[cfg(FALSE)] fn e() { let _ = #[attr] &mut #![attr] 0; } | = note: inner attributes, like `#![no_std]`, annotate the item enclosing them, and are usually found at the beginning of source files. Outer attributes, like `#[test]`, annotate the item following them. -error: expected `{`, found `#` +error: outer attributes are not allowed on `if` and `else` branches --> $DIR/attr-stmt-expr-attr-bad.rs:41:37 | LL | #[cfg(FALSE)] fn e() { let _ = if 0 #[attr] {}; } - | -- ^ -- help: try placing this code inside a block: `{ {} }` + | -- ^^^^^^^ -- the attributes are attached to this branch | | | - | | expected `{` - | this `if` expression has a condition, but no block + | | help: remove the attributes + | the branch belongs to this `if` error: an inner attribute is not permitted in this context --> $DIR/attr-stmt-expr-attr-bad.rs:43:38 @@ -159,13 +159,14 @@ error: expected one of `.`, `;`, `?`, `else`, or an operator, found `#` LL | #[cfg(FALSE)] fn e() { let _ = if 0 {} #[attr] else {}; } | ^ expected one of `.`, `;`, `?`, `else`, or an operator -error: expected `{`, found `#` +error: outer attributes are not allowed on `if` and `else` branches --> $DIR/attr-stmt-expr-attr-bad.rs:47:45 | LL | #[cfg(FALSE)] fn e() { let _ = if 0 {} else #[attr] {}; } - | ^ -- help: try placing this code inside a block: `{ {} }` - | | - | expected `{` + | ---- ^^^^^^^ -- the attributes are attached to this branch + | | | + | | help: remove the attributes + | the branch belongs to this `else` error: an inner attribute is not permitted in this context --> $DIR/attr-stmt-expr-attr-bad.rs:49:46 @@ -175,22 +176,23 @@ LL | #[cfg(FALSE)] fn e() { let _ = if 0 {} else {#![attr]}; } | = note: inner attributes, like `#![no_std]`, annotate the item enclosing them, and are usually found at the beginning of source files. Outer attributes, like `#[test]`, annotate the item following them. -error: expected `{`, found `#` +error: outer attributes are not allowed on `if` and `else` branches --> $DIR/attr-stmt-expr-attr-bad.rs:51:45 | LL | #[cfg(FALSE)] fn e() { let _ = if 0 {} else #[attr] if 0 {}; } - | ^ ------- help: try placing this code inside a block: `{ if 0 {} }` - | | - | expected `{` + | ---- ^^^^^^^ ------- the attributes are attached to this branch + | | | + | | help: remove the attributes + | the branch belongs to this `else` -error: expected `{`, found `#` +error: outer attributes are not allowed on `if` and `else` branches --> $DIR/attr-stmt-expr-attr-bad.rs:53:50 | LL | #[cfg(FALSE)] fn e() { let _ = if 0 {} else if 0 #[attr] {}; } - | -- ^ -- help: try placing this code inside a block: `{ {} }` + | -- ^^^^^^^ -- the attributes are attached to this branch | | | - | | expected `{` - | this `if` expression has a condition, but no block + | | help: remove the attributes + | the branch belongs to this `if` error: an inner attribute is not permitted in this context --> $DIR/attr-stmt-expr-attr-bad.rs:55:51 @@ -200,14 +202,14 @@ LL | #[cfg(FALSE)] fn e() { let _ = if 0 {} else if 0 {#![attr]}; } | = note: inner attributes, like `#![no_std]`, annotate the item enclosing them, and are usually found at the beginning of source files. Outer attributes, like `#[test]`, annotate the item following them. -error: expected `{`, found `#` +error: outer attributes are not allowed on `if` and `else` branches --> $DIR/attr-stmt-expr-attr-bad.rs:57:45 | LL | #[cfg(FALSE)] fn e() { let _ = if let _ = 0 #[attr] {}; } - | -- ^ -- help: try placing this code inside a block: `{ {} }` + | -- ^^^^^^^ -- the attributes are attached to this branch | | | - | | expected `{` - | this `if` expression has a condition, but no block + | | help: remove the attributes + | the branch belongs to this `if` error: an inner attribute is not permitted in this context --> $DIR/attr-stmt-expr-attr-bad.rs:59:46 @@ -223,13 +225,14 @@ error: expected one of `.`, `;`, `?`, `else`, or an operator, found `#` LL | #[cfg(FALSE)] fn e() { let _ = if let _ = 0 {} #[attr] else {}; } | ^ expected one of `.`, `;`, `?`, `else`, or an operator -error: expected `{`, found `#` +error: outer attributes are not allowed on `if` and `else` branches --> $DIR/attr-stmt-expr-attr-bad.rs:63:53 | LL | #[cfg(FALSE)] fn e() { let _ = if let _ = 0 {} else #[attr] {}; } - | ^ -- help: try placing this code inside a block: `{ {} }` - | | - | expected `{` + | ---- ^^^^^^^ -- the attributes are attached to this branch + | | | + | | help: remove the attributes + | the branch belongs to this `else` error: an inner attribute is not permitted in this context --> $DIR/attr-stmt-expr-attr-bad.rs:65:54 @@ -239,22 +242,23 @@ LL | #[cfg(FALSE)] fn e() { let _ = if let _ = 0 {} else {#![attr]}; } | = note: inner attributes, like `#![no_std]`, annotate the item enclosing them, and are usually found at the beginning of source files. Outer attributes, like `#[test]`, annotate the item following them. -error: expected `{`, found `#` +error: outer attributes are not allowed on `if` and `else` branches --> $DIR/attr-stmt-expr-attr-bad.rs:67:53 | LL | #[cfg(FALSE)] fn e() { let _ = if let _ = 0 {} else #[attr] if let _ = 0 {}; } - | ^ --------------- help: try placing this code inside a block: `{ if let _ = 0 {} }` - | | - | expected `{` + | ---- ^^^^^^^ --------------- the attributes are attached to this branch + | | | + | | help: remove the attributes + | the branch belongs to this `else` -error: expected `{`, found `#` +error: outer attributes are not allowed on `if` and `else` branches --> $DIR/attr-stmt-expr-attr-bad.rs:69:66 | LL | #[cfg(FALSE)] fn e() { let _ = if let _ = 0 {} else if let _ = 0 #[attr] {}; } - | -- ^ -- help: try placing this code inside a block: `{ {} }` + | -- ^^^^^^^ -- the attributes are attached to this branch | | | - | | expected `{` - | this `if` expression has a condition, but no block + | | help: remove the attributes + | the branch belongs to this `if` error: an inner attribute is not permitted in this context --> $DIR/attr-stmt-expr-attr-bad.rs:71:67 diff --git a/src/test/ui/parser/doc-comment-in-if-statement.rs b/src/test/ui/parser/doc-comment-in-if-statement.rs index 69b174b4cb3..343eac1b81f 100644 --- a/src/test/ui/parser/doc-comment-in-if-statement.rs +++ b/src/test/ui/parser/doc-comment-in-if-statement.rs @@ -1,5 +1,5 @@ fn main() { if true /*!*/ {} - //~^ ERROR expected `{`, found doc comment `/*!*/` + //~^ ERROR outer attributes are not allowed on //~| ERROR expected outer doc comment } diff --git a/src/test/ui/parser/doc-comment-in-if-statement.stderr b/src/test/ui/parser/doc-comment-in-if-statement.stderr index 1fe3735daf0..af21b78733f 100644 --- a/src/test/ui/parser/doc-comment-in-if-statement.stderr +++ b/src/test/ui/parser/doc-comment-in-if-statement.stderr @@ -6,14 +6,14 @@ LL | if true /*!*/ {} | = note: inner doc comments like this (starting with `//!` or `/*!`) can only appear before items -error: expected `{`, found doc comment `/*!*/` +error: outer attributes are not allowed on `if` and `else` branches --> $DIR/doc-comment-in-if-statement.rs:2:13 | LL | if true /*!*/ {} - | -- ^^^^^ -- help: try placing this code inside a block: `{ {} }` + | -- ^^^^^ -- the attributes are attached to this branch | | | - | | expected `{` - | this `if` expression has a condition, but no block + | | help: remove the attributes + | the branch belongs to this `if` error: aborting due to 2 previous errors |
