diff options
| author | bors <bors@rust-lang.org> | 2023-12-03 03:05:17 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2023-12-03 03:05:17 +0000 |
| commit | 225e36cff9809948d6567ab16f75d7b087ea83a7 (patch) | |
| tree | dcd6c7732158c8cc0578399b68c3f941ac960e59 /tests/ui/parser/issues | |
| parent | 1ca8b71cff69b0c48e40ceb66d01b9f8d30b2492 (diff) | |
| parent | 5ff428c1ff81a635628a2b67c96999b6098f3fa8 (diff) | |
| download | rust-225e36cff9809948d6567ab16f75d7b087ea83a7.tar.gz rust-225e36cff9809948d6567ab16f75d7b087ea83a7.zip | |
Auto merge of #118542 - chenyukang:yukang-fix-parser-ice-118531, r=cjgillot
Fix parser ICE from attrs Fixes #118531, Fixes #118530.
Diffstat (limited to 'tests/ui/parser/issues')
| -rw-r--r-- | tests/ui/parser/issues/issue-118530-ice.rs | 15 | ||||
| -rw-r--r-- | tests/ui/parser/issues/issue-118530-ice.stderr | 43 | ||||
| -rw-r--r-- | tests/ui/parser/issues/issue-118531-ice.rs | 10 | ||||
| -rw-r--r-- | tests/ui/parser/issues/issue-118531-ice.stderr | 38 |
4 files changed, 106 insertions, 0 deletions
diff --git a/tests/ui/parser/issues/issue-118530-ice.rs b/tests/ui/parser/issues/issue-118530-ice.rs new file mode 100644 index 00000000000..e758e5af4d9 --- /dev/null +++ b/tests/ui/parser/issues/issue-118530-ice.rs @@ -0,0 +1,15 @@ +fn bar() -> String { + #[cfg] + [1, 2, 3].iter() //~ ERROR expected `;`, found `#` + #[feature] + attr::fn bar() -> String { //~ ERROR expected identifier, found keyword `fn` + //~^ ERROR expected one of `.`, `;`, `?`, `}`, or an operator, found `->` + //~| ERROR expected `;`, found `bar` + #[attr] + [1, 2, 3].iter().map().collect::<String>() + #[attr] + +}() +} + +fn main() { } diff --git a/tests/ui/parser/issues/issue-118530-ice.stderr b/tests/ui/parser/issues/issue-118530-ice.stderr new file mode 100644 index 00000000000..ef573fb7ba3 --- /dev/null +++ b/tests/ui/parser/issues/issue-118530-ice.stderr @@ -0,0 +1,43 @@ +error: expected `;`, found `#` + --> $DIR/issue-118530-ice.rs:3:21 + | +LL | #[cfg] + | ------ only `;` terminated statements or tail expressions are allowed after this attribute +LL | [1, 2, 3].iter() + | ^ expected `;` here +LL | #[feature] + | - unexpected token + | +help: add `;` here + | +LL | [1, 2, 3].iter(); + | + +help: alternatively, consider surrounding the expression with a block + | +LL | { [1, 2, 3].iter() } + | + + + +error: expected identifier, found keyword `fn` + --> $DIR/issue-118530-ice.rs:5:11 + | +LL | attr::fn bar() -> String { + | ^^ expected identifier, found keyword + +error: expected `;`, found `bar` + --> $DIR/issue-118530-ice.rs:5:13 + | +LL | #[feature] + | ---------- only `;` terminated statements or tail expressions are allowed after this attribute +LL | attr::fn bar() -> String { + | ^--- unexpected token + | | + | help: add `;` here + +error: expected one of `.`, `;`, `?`, `}`, or an operator, found `->` + --> $DIR/issue-118530-ice.rs:5:20 + | +LL | attr::fn bar() -> String { + | ^^ expected one of `.`, `;`, `?`, `}`, or an operator + +error: aborting due to 4 previous errors + diff --git a/tests/ui/parser/issues/issue-118531-ice.rs b/tests/ui/parser/issues/issue-118531-ice.rs new file mode 100644 index 00000000000..24794f06052 --- /dev/null +++ b/tests/ui/parser/issues/issue-118531-ice.rs @@ -0,0 +1,10 @@ +fn bar() -> String { + #[cfg(feature = )] + [1, 2, 3].iter().map().collect::<String>() //~ ERROR expected `;`, found `#` + + #[attr] //~ ERROR attributes on expressions are experimental [E0658] + //~^ ERROR cannot find attribute `attr` in this scope + String::new() +} + +fn main() { } diff --git a/tests/ui/parser/issues/issue-118531-ice.stderr b/tests/ui/parser/issues/issue-118531-ice.stderr new file mode 100644 index 00000000000..a32292dcb0d --- /dev/null +++ b/tests/ui/parser/issues/issue-118531-ice.stderr @@ -0,0 +1,38 @@ +error: expected `;`, found `#` + --> $DIR/issue-118531-ice.rs:3:47 + | +LL | #[cfg(feature = )] + | ------------------ only `;` terminated statements or tail expressions are allowed after this attribute +LL | [1, 2, 3].iter().map().collect::<String>() + | ^ expected `;` here +LL | +LL | #[attr] + | - unexpected token + | +help: add `;` here + | +LL | [1, 2, 3].iter().map().collect::<String>(); + | + +help: alternatively, consider surrounding the expression with a block + | +LL | { [1, 2, 3].iter().map().collect::<String>() } + | + + + +error[E0658]: attributes on expressions are experimental + --> $DIR/issue-118531-ice.rs:5:5 + | +LL | #[attr] + | ^^^^^^^ + | + = 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: cannot find attribute `attr` in this scope + --> $DIR/issue-118531-ice.rs:5:7 + | +LL | #[attr] + | ^^^^ + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0658`. |
