summaryrefslogtreecommitdiffstats
path: root/tests/ui/parser
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/parser')
-rw-r--r--tests/ui/parser/async-with-nonterminal-block.rs16
-rw-r--r--tests/ui/parser/generic-statics.rs4
-rw-r--r--tests/ui/parser/generic-statics.stderr8
-rw-r--r--tests/ui/parser/issues/issue-113203.rs7
-rw-r--r--tests/ui/parser/issues/issue-113203.stderr8
-rw-r--r--tests/ui/parser/issues/issue-114219.rs4
-rw-r--r--tests/ui/parser/issues/issue-114219.stderr8
-rw-r--r--tests/ui/parser/issues/issue-115780-pat-lt-bracket-in-macro-call.rs21
-rw-r--r--tests/ui/parser/issues/issue-22647.rs2
-rw-r--r--tests/ui/parser/issues/issue-22647.stderr9
-rw-r--r--tests/ui/parser/issues/issue-22712.rs2
-rw-r--r--tests/ui/parser/issues/issue-22712.stderr9
-rw-r--r--tests/ui/parser/issues/issue-70583-block-is-empty-2.rs8
-rw-r--r--tests/ui/parser/issues/issue-70583-block-is-empty-2.stderr3
-rw-r--r--tests/ui/parser/macro/macro-expand-to-field.rs70
-rw-r--r--tests/ui/parser/macro/macro-expand-to-field.stderr74
-rw-r--r--tests/ui/parser/macro/macro-expand-to-match-arm.rs18
-rw-r--r--tests/ui/parser/macro/macro-expand-to-match-arm.stderr10
-rw-r--r--tests/ui/parser/pat-lt-bracket-3.rs3
-rw-r--r--tests/ui/parser/pat-lt-bracket-3.stderr9
-rw-r--r--tests/ui/parser/pat-lt-bracket-4.rs2
-rw-r--r--tests/ui/parser/pat-lt-bracket-4.stderr9
-rw-r--r--tests/ui/parser/ternary_operator.rs69
-rw-r--r--tests/ui/parser/ternary_operator.stderr115
-rw-r--r--tests/ui/parser/trait-object-delimiters.rs4
-rw-r--r--tests/ui/parser/trait-object-delimiters.stderr12
-rw-r--r--tests/ui/parser/try-with-nonterminal-block.rs19
-rw-r--r--tests/ui/parser/type-alias-where-fixable.fixed28
-rw-r--r--tests/ui/parser/type-alias-where-fixable.rs28
-rw-r--r--tests/ui/parser/type-alias-where-fixable.stderr42
-rw-r--r--tests/ui/parser/type-alias-where.rs11
-rw-r--r--tests/ui/parser/type-alias-where.stderr18
32 files changed, 499 insertions, 151 deletions
diff --git a/tests/ui/parser/async-with-nonterminal-block.rs b/tests/ui/parser/async-with-nonterminal-block.rs
new file mode 100644
index 000000000..96015fd5d
--- /dev/null
+++ b/tests/ui/parser/async-with-nonterminal-block.rs
@@ -0,0 +1,16 @@
+// check-pass
+// edition:2021
+
+macro_rules! create_async {
+ ($body:block) => {
+ async $body
+ };
+}
+
+async fn other() {}
+
+fn main() {
+ let y = create_async! {{
+ other().await;
+ }};
+}
diff --git a/tests/ui/parser/generic-statics.rs b/tests/ui/parser/generic-statics.rs
new file mode 100644
index 000000000..2fb8781fd
--- /dev/null
+++ b/tests/ui/parser/generic-statics.rs
@@ -0,0 +1,4 @@
+static S<T>: i32 = 0;
+//~^ ERROR static items may not have generic parameters
+
+fn main() {}
diff --git a/tests/ui/parser/generic-statics.stderr b/tests/ui/parser/generic-statics.stderr
new file mode 100644
index 000000000..c757232b0
--- /dev/null
+++ b/tests/ui/parser/generic-statics.stderr
@@ -0,0 +1,8 @@
+error: static items may not have generic parameters
+ --> $DIR/generic-statics.rs:1:9
+ |
+LL | static S<T>: i32 = 0;
+ | ^^^
+
+error: aborting due to previous error
+
diff --git a/tests/ui/parser/issues/issue-113203.rs b/tests/ui/parser/issues/issue-113203.rs
new file mode 100644
index 000000000..1103251c1
--- /dev/null
+++ b/tests/ui/parser/issues/issue-113203.rs
@@ -0,0 +1,7 @@
+// Checks what happens when we attempt to use the await keyword as a prefix. Span
+// incorrectly emitted an `.await` in E0277 which does not exist
+// edition:2018
+fn main() {
+ await {}()
+ //~^ ERROR incorrect use of `await`
+}
diff --git a/tests/ui/parser/issues/issue-113203.stderr b/tests/ui/parser/issues/issue-113203.stderr
new file mode 100644
index 000000000..97304a89c
--- /dev/null
+++ b/tests/ui/parser/issues/issue-113203.stderr
@@ -0,0 +1,8 @@
+error: incorrect use of `await`
+ --> $DIR/issue-113203.rs:5:5
+ |
+LL | await {}()
+ | ^^^^^^^^ help: `await` is a postfix operation: `{}.await`
+
+error: aborting due to previous error
+
diff --git a/tests/ui/parser/issues/issue-114219.rs b/tests/ui/parser/issues/issue-114219.rs
new file mode 100644
index 000000000..332258b62
--- /dev/null
+++ b/tests/ui/parser/issues/issue-114219.rs
@@ -0,0 +1,4 @@
+fn main() {
+ async move {};
+ //~^ ERROR `async move` blocks are only allowed in Rust 2018 or later
+}
diff --git a/tests/ui/parser/issues/issue-114219.stderr b/tests/ui/parser/issues/issue-114219.stderr
new file mode 100644
index 000000000..90dcdc427
--- /dev/null
+++ b/tests/ui/parser/issues/issue-114219.stderr
@@ -0,0 +1,8 @@
+error: `async move` blocks are only allowed in Rust 2018 or later
+ --> $DIR/issue-114219.rs:2:5
+ |
+LL | async move {};
+ | ^^^^^^^^^^
+
+error: aborting due to previous error
+
diff --git a/tests/ui/parser/issues/issue-115780-pat-lt-bracket-in-macro-call.rs b/tests/ui/parser/issues/issue-115780-pat-lt-bracket-in-macro-call.rs
new file mode 100644
index 000000000..3421333b8
--- /dev/null
+++ b/tests/ui/parser/issues/issue-115780-pat-lt-bracket-in-macro-call.rs
@@ -0,0 +1,21 @@
+// Regression test for issue #115780.
+// Ensure that we don't emit a parse error for the token sequence `Ident "<" Ty` in pattern position
+// if we are inside a macro call since it can be valid input for a subsequent macro rule.
+// See also #103534.
+
+// check-pass
+
+macro_rules! mdo {
+ ($p: pat =<< $e: expr ; $( $t: tt )*) => {
+ $e.and_then(|$p| mdo! { $( $t )* })
+ };
+ (ret<$ty: ty> $e: expr;) => { Some::<$ty>($e) };
+}
+
+fn main() {
+ mdo! {
+ x_val =<< Some(0);
+ y_val =<< Some(1);
+ ret<(i32, i32)> (x_val, y_val);
+ };
+}
diff --git a/tests/ui/parser/issues/issue-22647.rs b/tests/ui/parser/issues/issue-22647.rs
index a68614106..163cbc69d 100644
--- a/tests/ui/parser/issues/issue-22647.rs
+++ b/tests/ui/parser/issues/issue-22647.rs
@@ -1,5 +1,5 @@
fn main() {
- let caller<F> = |f: F| //~ ERROR expected one of `:`, `;`, `=`, `@`, or `|`, found `<`
+ let caller<F> = |f: F| //~ ERROR generic args in patterns require the turbofish syntax
where F: Fn() -> i32
{
let x = f();
diff --git a/tests/ui/parser/issues/issue-22647.stderr b/tests/ui/parser/issues/issue-22647.stderr
index 89b454d19..585e70266 100644
--- a/tests/ui/parser/issues/issue-22647.stderr
+++ b/tests/ui/parser/issues/issue-22647.stderr
@@ -1,8 +1,13 @@
-error: expected one of `:`, `;`, `=`, `@`, or `|`, found `<`
+error: generic args in patterns require the turbofish syntax
--> $DIR/issue-22647.rs:2:15
|
LL | let caller<F> = |f: F|
- | ^ expected one of `:`, `;`, `=`, `@`, or `|`
+ | ^
+ |
+help: use `::<...>` instead of `<...>` to specify lifetime, type, or const arguments
+ |
+LL | let caller::<F> = |f: F|
+ | ++
error: aborting due to previous error
diff --git a/tests/ui/parser/issues/issue-22712.rs b/tests/ui/parser/issues/issue-22712.rs
index 774de9c7e..92b12b8e1 100644
--- a/tests/ui/parser/issues/issue-22712.rs
+++ b/tests/ui/parser/issues/issue-22712.rs
@@ -3,7 +3,7 @@ struct Foo<B> {
}
fn bar() {
- let Foo<Vec<u8>> //~ ERROR expected one of `:`, `;`, `=`, `@`, or `|`, found `<`
+ let Foo<Vec<u8>> //~ ERROR generic args in patterns require the turbofish syntax
}
fn main() {}
diff --git a/tests/ui/parser/issues/issue-22712.stderr b/tests/ui/parser/issues/issue-22712.stderr
index 30fabac65..7f9d99d8e 100644
--- a/tests/ui/parser/issues/issue-22712.stderr
+++ b/tests/ui/parser/issues/issue-22712.stderr
@@ -1,8 +1,13 @@
-error: expected one of `:`, `;`, `=`, `@`, or `|`, found `<`
+error: generic args in patterns require the turbofish syntax
--> $DIR/issue-22712.rs:6:12
|
LL | let Foo<Vec<u8>>
- | ^ expected one of `:`, `;`, `=`, `@`, or `|`
+ | ^
+ |
+help: use `::<...>` instead of `<...>` to specify lifetime, type, or const arguments
+ |
+LL | let Foo::<Vec<u8>>
+ | ++
error: aborting due to previous error
diff --git a/tests/ui/parser/issues/issue-70583-block-is-empty-2.rs b/tests/ui/parser/issues/issue-70583-block-is-empty-2.rs
index 80f53338a..92ff0ef64 100644
--- a/tests/ui/parser/issues/issue-70583-block-is-empty-2.rs
+++ b/tests/ui/parser/issues/issue-70583-block-is-empty-2.rs
@@ -6,9 +6,13 @@ pub enum ErrorHandled {
impl ErrorHandled {
pub fn assert_reported(self) {
match self {
+ //~^ NOTE this delimiter might not be properly closed...
ErrorHandled::Reported => {}}
- //^~ ERROR block is empty, you might have not meant to close it
+ //~^ NOTE block is empty, you might have not meant to close it
+ //~| NOTE as it matches this but it has different indentation
ErrorHandled::TooGeneric => panic!(),
}
}
-} //~ ERROR unexpected closing delimiter: `}`
+}
+//~^ ERROR unexpected closing delimiter: `}`
+//~| NOTE unexpected closing delimiter
diff --git a/tests/ui/parser/issues/issue-70583-block-is-empty-2.stderr b/tests/ui/parser/issues/issue-70583-block-is-empty-2.stderr
index 9ae94c701..c590e04bb 100644
--- a/tests/ui/parser/issues/issue-70583-block-is-empty-2.stderr
+++ b/tests/ui/parser/issues/issue-70583-block-is-empty-2.stderr
@@ -1,8 +1,9 @@
error: unexpected closing delimiter: `}`
- --> $DIR/issue-70583-block-is-empty-2.rs:14:1
+ --> $DIR/issue-70583-block-is-empty-2.rs:16:1
|
LL | match self {
| - this delimiter might not be properly closed...
+LL |
LL | ErrorHandled::Reported => {}}
| --- ...as it matches this but it has different indentation
| |
diff --git a/tests/ui/parser/macro/macro-expand-to-field.rs b/tests/ui/parser/macro/macro-expand-to-field.rs
new file mode 100644
index 000000000..155872f7a
--- /dev/null
+++ b/tests/ui/parser/macro/macro-expand-to-field.rs
@@ -0,0 +1,70 @@
+// compile-flags: --crate-type=lib
+
+macro_rules! field {
+ ($name:ident:$type:ty) => {
+ $name:$type
+ };
+}
+
+macro_rules! variant {
+ ($name:ident) => {
+ $name
+ }
+}
+
+struct Struct {
+ field!(bar:u128),
+ //~^ NOTE macros cannot expand to struct fields
+ //~| ERROR unexpected token: `!`
+ //~| NOTE unexpected token after this
+ a: u32,
+ b: u32,
+ field!(recovers:()), //~ NOTE macros cannot expand to struct fields
+ //~^ ERROR unexpected token: `!`
+ //~^^ NOTE unexpected token after this
+}
+
+enum EnumVariant {
+ variant!(whoops),
+ //~^ NOTE macros cannot expand to enum variants
+ //~| ERROR unexpected token: `!`
+ //~| NOTE unexpected token after this
+ U32,
+ F64,
+ variant!(recovers),
+ //~^ NOTE macros cannot expand to enum variants
+ //~| ERROR unexpected token: `!`
+ //~| NOTE unexpected token after this
+ Data {
+ field!(x:u32),
+ //~^ NOTE macros cannot expand to struct fields
+ //~| ERROR unexpected token: `!`
+ //~| NOTE unexpected token after this
+ }
+}
+
+enum EnumVariantField {
+ Named {
+ field!(oopsies:()),
+ //~^ NOTE macros cannot expand to struct fields
+ //~| ERROR unexpected token: `!`
+ //~| unexpected token after this
+ field!(oopsies2:()),
+ //~^ NOTE macros cannot expand to struct fields
+ //~| ERROR unexpected token: `!`
+ //~| unexpected token after this
+ },
+}
+
+union Union {
+ A: u32,
+ field!(oopsies:()),
+ //~^ NOTE macros cannot expand to union fields
+ //~| ERROR unexpected token: `!`
+ //~| unexpected token after this
+ B: u32,
+ field!(recovers:()),
+ //~^ NOTE macros cannot expand to union fields
+ //~| ERROR unexpected token: `!`
+ //~| unexpected token after this
+}
diff --git a/tests/ui/parser/macro/macro-expand-to-field.stderr b/tests/ui/parser/macro/macro-expand-to-field.stderr
new file mode 100644
index 000000000..adcd032f5
--- /dev/null
+++ b/tests/ui/parser/macro/macro-expand-to-field.stderr
@@ -0,0 +1,74 @@
+error: unexpected token: `!`
+ --> $DIR/macro-expand-to-field.rs:16:10
+ |
+LL | field!(bar:u128),
+ | ^ unexpected token after this
+ |
+ = note: macros cannot expand to struct fields
+
+error: unexpected token: `!`
+ --> $DIR/macro-expand-to-field.rs:22:10
+ |
+LL | field!(recovers:()),
+ | ^ unexpected token after this
+ |
+ = note: macros cannot expand to struct fields
+
+error: unexpected token: `!`
+ --> $DIR/macro-expand-to-field.rs:28:12
+ |
+LL | variant!(whoops),
+ | ^ unexpected token after this
+ |
+ = note: macros cannot expand to enum variants
+
+error: unexpected token: `!`
+ --> $DIR/macro-expand-to-field.rs:34:12
+ |
+LL | variant!(recovers),
+ | ^ unexpected token after this
+ |
+ = note: macros cannot expand to enum variants
+
+error: unexpected token: `!`
+ --> $DIR/macro-expand-to-field.rs:39:14
+ |
+LL | field!(x:u32),
+ | ^ unexpected token after this
+ |
+ = note: macros cannot expand to struct fields
+
+error: unexpected token: `!`
+ --> $DIR/macro-expand-to-field.rs:48:14
+ |
+LL | field!(oopsies:()),
+ | ^ unexpected token after this
+ |
+ = note: macros cannot expand to struct fields
+
+error: unexpected token: `!`
+ --> $DIR/macro-expand-to-field.rs:52:14
+ |
+LL | field!(oopsies2:()),
+ | ^ unexpected token after this
+ |
+ = note: macros cannot expand to struct fields
+
+error: unexpected token: `!`
+ --> $DIR/macro-expand-to-field.rs:61:10
+ |
+LL | field!(oopsies:()),
+ | ^ unexpected token after this
+ |
+ = note: macros cannot expand to union fields
+
+error: unexpected token: `!`
+ --> $DIR/macro-expand-to-field.rs:66:10
+ |
+LL | field!(recovers:()),
+ | ^ unexpected token after this
+ |
+ = note: macros cannot expand to union fields
+
+error: aborting due to 9 previous errors
+
diff --git a/tests/ui/parser/macro/macro-expand-to-match-arm.rs b/tests/ui/parser/macro/macro-expand-to-match-arm.rs
new file mode 100644
index 000000000..39d1d065e
--- /dev/null
+++ b/tests/ui/parser/macro/macro-expand-to-match-arm.rs
@@ -0,0 +1,18 @@
+macro_rules! arm {
+ ($pattern:pat => $block:block) => {
+ $pattern => $block
+ };
+}
+
+fn main() {
+ let x = Some(1);
+ match x {
+ Some(1) => {},
+ arm!(None => {}),
+ //~^ NOTE macros cannot expand to match arms
+ //~| ERROR unexpected `,` in pattern
+ // doesn't recover
+ Some(2) => {},
+ _ => {},
+ };
+}
diff --git a/tests/ui/parser/macro/macro-expand-to-match-arm.stderr b/tests/ui/parser/macro/macro-expand-to-match-arm.stderr
new file mode 100644
index 000000000..1a5f46968
--- /dev/null
+++ b/tests/ui/parser/macro/macro-expand-to-match-arm.stderr
@@ -0,0 +1,10 @@
+error: unexpected `,` in pattern
+ --> $DIR/macro-expand-to-match-arm.rs:11:25
+ |
+LL | arm!(None => {}),
+ | ^
+ |
+ = note: macros cannot expand to match arms
+
+error: aborting due to previous error
+
diff --git a/tests/ui/parser/pat-lt-bracket-3.rs b/tests/ui/parser/pat-lt-bracket-3.rs
index a8bdfd3fa..bd83fe8db 100644
--- a/tests/ui/parser/pat-lt-bracket-3.rs
+++ b/tests/ui/parser/pat-lt-bracket-3.rs
@@ -3,8 +3,7 @@ struct Foo<T>(T, T);
impl<T> Foo<T> {
fn foo(&self) {
match *self {
- Foo<T>(x, y) => {
- //~^ error: expected one of `=>`, `@`, `if`, or `|`, found `<`
+ Foo<T>(x, y) => { //~ ERROR generic args in patterns require the turbofish syntax
println!("Goodbye, World!")
}
}
diff --git a/tests/ui/parser/pat-lt-bracket-3.stderr b/tests/ui/parser/pat-lt-bracket-3.stderr
index bacf868e3..afdf1e9a5 100644
--- a/tests/ui/parser/pat-lt-bracket-3.stderr
+++ b/tests/ui/parser/pat-lt-bracket-3.stderr
@@ -1,8 +1,13 @@
-error: expected one of `=>`, `@`, `if`, or `|`, found `<`
+error: generic args in patterns require the turbofish syntax
--> $DIR/pat-lt-bracket-3.rs:6:16
|
LL | Foo<T>(x, y) => {
- | ^ expected one of `=>`, `@`, `if`, or `|`
+ | ^
+ |
+help: use `::<...>` instead of `<...>` to specify lifetime, type, or const arguments
+ |
+LL | Foo::<T>(x, y) => {
+ | ++
error: aborting due to previous error
diff --git a/tests/ui/parser/pat-lt-bracket-4.rs b/tests/ui/parser/pat-lt-bracket-4.rs
index de314f6c6..6d348b68c 100644
--- a/tests/ui/parser/pat-lt-bracket-4.rs
+++ b/tests/ui/parser/pat-lt-bracket-4.rs
@@ -5,7 +5,7 @@ enum BtNode {
fn main() {
let y = match 10 {
- Foo<T>::A(value) => value, //~ error: expected one of `=>`, `@`, `if`, or `|`, found `<`
+ Foo<T>::A(value) => value, //~ ERROR generic args in patterns require the turbofish syntax
Foo<T>::B => 7,
};
}
diff --git a/tests/ui/parser/pat-lt-bracket-4.stderr b/tests/ui/parser/pat-lt-bracket-4.stderr
index 911c276b9..b71a5ad93 100644
--- a/tests/ui/parser/pat-lt-bracket-4.stderr
+++ b/tests/ui/parser/pat-lt-bracket-4.stderr
@@ -1,8 +1,13 @@
-error: expected one of `=>`, `@`, `if`, or `|`, found `<`
+error: generic args in patterns require the turbofish syntax
--> $DIR/pat-lt-bracket-4.rs:8:12
|
LL | Foo<T>::A(value) => value,
- | ^ expected one of `=>`, `@`, `if`, or `|`
+ | ^
+ |
+help: use `::<...>` instead of `<...>` to specify lifetime, type, or const arguments
+ |
+LL | Foo::<T>::A(value) => value,
+ | ++
error: aborting due to previous error
diff --git a/tests/ui/parser/ternary_operator.rs b/tests/ui/parser/ternary_operator.rs
new file mode 100644
index 000000000..23d537e77
--- /dev/null
+++ b/tests/ui/parser/ternary_operator.rs
@@ -0,0 +1,69 @@
+// A good chunk of these errors aren't shown to the user, but are still
+// required in the test for it to pass.
+
+fn a() { //~ NOTE this function should return `Result` or `Option` to accept `?`
+ let x = 5 > 2 ? true : false;
+ //~^ ERROR Rust has no ternary operator
+ //~| HELP use an `if-else` expression instead
+ //~| ERROR the `?` operator can only be applied to values that implement `Try` [E0277]
+ //~| HELP the trait `Try` is not implemented for `{integer}`
+ //~| ERROR the `?` operator can only be used in a function that returns `Result` or `Option` (or another type that implements `FromResidual`) [E0277]
+ //~| HELP the trait `FromResidual<_>` is not implemented for `()`
+ //~| NOTE in this expansion of desugaring of operator `?`
+ //~| NOTE the `?` operator cannot be applied to type `{integer}`
+ //~| NOTE in this expansion of desugaring of operator `?`
+ //~| NOTE in this expansion of desugaring of operator `?`
+ //~| NOTE cannot use the `?` operator in a function that returns `()`
+ //~| NOTE in this expansion of desugaring of operator `?`
+}
+
+fn b() { //~ NOTE this function should return `Result` or `Option` to accept `?`
+ let x = 5 > 2 ? { true } : { false };
+ //~^ ERROR Rust has no ternary operator
+ //~| HELP use an `if-else` expression instead
+ //~| ERROR the `?` operator can only be applied to values that implement `Try` [E0277]
+ //~| HELP the trait `Try` is not implemented for `{integer}`
+ //~| ERROR the `?` operator can only be used in a function that returns `Result` or `Option` (or another type that implements `FromResidual`) [E0277]
+ //~| HELP the trait `FromResidual<_>` is not implemented for `()`
+ //~| NOTE in this expansion of desugaring of operator `?`
+ //~| NOTE the `?` operator cannot be applied to type `{integer}`
+ //~| NOTE in this expansion of desugaring of operator `?`
+ //~| NOTE in this expansion of desugaring of operator `?`
+ //~| NOTE cannot use the `?` operator in a function that returns `()`
+ //~| NOTE in this expansion of desugaring of operator `?`
+}
+
+fn c() { //~ NOTE this function should return `Result` or `Option` to accept `?`
+ let x = 5 > 2 ? f32::MAX : f32::MIN;
+ //~^ ERROR Rust has no ternary operator
+ //~| HELP use an `if-else` expression instead
+ //~| ERROR the `?` operator can only be applied to values that implement `Try` [E0277]
+ //~| HELP the trait `Try` is not implemented for `{integer}`
+ //~| ERROR the `?` operator can only be used in a function that returns `Result` or `Option` (or another type that implements `FromResidual`) [E0277]
+ //~| HELP the trait `FromResidual<_>` is not implemented for `()`
+ //~| NOTE in this expansion of desugaring of operator `?`
+ //~| NOTE the `?` operator cannot be applied to type `{integer}`
+ //~| NOTE in this expansion of desugaring of operator `?`
+ //~| NOTE in this expansion of desugaring of operator `?`
+ //~| NOTE cannot use the `?` operator in a function that returns `()`
+ //~| NOTE in this expansion of desugaring of operator `?`
+}
+
+fn main() { //~ NOTE this function should return `Result` or `Option` to accept `?`
+ let x = 5 > 2 ? { let x = vec![]: Vec<u16>; x } : { false };
+ //~^ ERROR Rust has no ternary operator
+ //~| HELP use an `if-else` expression instead
+ //~| ERROR expected one of `.`, `;`, `?`, `else`, or an operator, found `:`
+ //~| NOTE expected one of `.`, `;`, `?`, `else`, or an operator
+ //~| ERROR the `?` operator can only be applied to values that implement `Try` [E0277]
+ //~| HELP the trait `Try` is not implemented for `{integer}`
+ //~| ERROR the `?` operator can only be used in a function that returns `Result` or `Option` (or another type that implements `FromResidual`) [E0277]
+ //~| HELP the trait `FromResidual<_>` is not implemented for `()`
+ //~| NOTE type ascription syntax has been removed, see issue #101728 <https://github.com/rust-lang/rust/issues/101728>
+ //~| NOTE in this expansion of desugaring of operator `?`
+ //~| NOTE the `?` operator cannot be applied to type `{integer}`
+ //~| NOTE in this expansion of desugaring of operator `?`
+ //~| NOTE in this expansion of desugaring of operator `?`
+ //~| NOTE cannot use the `?` operator in a function that returns `()`
+ //~| NOTE in this expansion of desugaring of operator `?`
+}
diff --git a/tests/ui/parser/ternary_operator.stderr b/tests/ui/parser/ternary_operator.stderr
new file mode 100644
index 000000000..af9565bbe
--- /dev/null
+++ b/tests/ui/parser/ternary_operator.stderr
@@ -0,0 +1,115 @@
+error: Rust has no ternary operator
+ --> $DIR/ternary_operator.rs:5:19
+ |
+LL | let x = 5 > 2 ? true : false;
+ | ^^^^^^^^^^^^^^^
+ |
+ = help: use an `if-else` expression instead
+
+error: Rust has no ternary operator
+ --> $DIR/ternary_operator.rs:21:19
+ |
+LL | let x = 5 > 2 ? { true } : { false };
+ | ^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = help: use an `if-else` expression instead
+
+error: Rust has no ternary operator
+ --> $DIR/ternary_operator.rs:37:19
+ |
+LL | let x = 5 > 2 ? f32::MAX : f32::MIN;
+ | ^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = help: use an `if-else` expression instead
+
+error: expected one of `.`, `;`, `?`, `else`, or an operator, found `:`
+ --> $DIR/ternary_operator.rs:53:37
+ |
+LL | let x = 5 > 2 ? { let x = vec![]: Vec<u16>; x } : { false };
+ | ^ expected one of `.`, `;`, `?`, `else`, or an operator
+ |
+ = note: type ascription syntax has been removed, see issue #101728 <https://github.com/rust-lang/rust/issues/101728>
+
+error: Rust has no ternary operator
+ --> $DIR/ternary_operator.rs:53:19
+ |
+LL | let x = 5 > 2 ? { let x = vec![]: Vec<u16>; x } : { false };
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = help: use an `if-else` expression instead
+
+error[E0277]: the `?` operator can only be applied to values that implement `Try`
+ --> $DIR/ternary_operator.rs:5:17
+ |
+LL | let x = 5 > 2 ? true : false;
+ | ^^^ the `?` operator cannot be applied to type `{integer}`
+ |
+ = help: the trait `Try` is not implemented for `{integer}`
+
+error[E0277]: the `?` operator can only be used in a function that returns `Result` or `Option` (or another type that implements `FromResidual`)
+ --> $DIR/ternary_operator.rs:5:19
+ |
+LL | fn a() {
+ | ------ this function should return `Result` or `Option` to accept `?`
+LL | let x = 5 > 2 ? true : false;
+ | ^ cannot use the `?` operator in a function that returns `()`
+ |
+ = help: the trait `FromResidual<_>` is not implemented for `()`
+
+error[E0277]: the `?` operator can only be applied to values that implement `Try`
+ --> $DIR/ternary_operator.rs:21:17
+ |
+LL | let x = 5 > 2 ? { true } : { false };
+ | ^^^ the `?` operator cannot be applied to type `{integer}`
+ |
+ = help: the trait `Try` is not implemented for `{integer}`
+
+error[E0277]: the `?` operator can only be used in a function that returns `Result` or `Option` (or another type that implements `FromResidual`)
+ --> $DIR/ternary_operator.rs:21:19
+ |
+LL | fn b() {
+ | ------ this function should return `Result` or `Option` to accept `?`
+LL | let x = 5 > 2 ? { true } : { false };
+ | ^ cannot use the `?` operator in a function that returns `()`
+ |
+ = help: the trait `FromResidual<_>` is not implemented for `()`
+
+error[E0277]: the `?` operator can only be applied to values that implement `Try`
+ --> $DIR/ternary_operator.rs:37:17
+ |
+LL | let x = 5 > 2 ? f32::MAX : f32::MIN;
+ | ^^^ the `?` operator cannot be applied to type `{integer}`
+ |
+ = help: the trait `Try` is not implemented for `{integer}`
+
+error[E0277]: the `?` operator can only be used in a function that returns `Result` or `Option` (or another type that implements `FromResidual`)
+ --> $DIR/ternary_operator.rs:37:19
+ |
+LL | fn c() {
+ | ------ this function should return `Result` or `Option` to accept `?`
+LL | let x = 5 > 2 ? f32::MAX : f32::MIN;
+ | ^ cannot use the `?` operator in a function that returns `()`
+ |
+ = help: the trait `FromResidual<_>` is not implemented for `()`
+
+error[E0277]: the `?` operator can only be applied to values that implement `Try`
+ --> $DIR/ternary_operator.rs:53:17
+ |
+LL | let x = 5 > 2 ? { let x = vec![]: Vec<u16>; x } : { false };
+ | ^^^ the `?` operator cannot be applied to type `{integer}`
+ |
+ = help: the trait `Try` is not implemented for `{integer}`
+
+error[E0277]: the `?` operator can only be used in a function that returns `Result` or `Option` (or another type that implements `FromResidual`)
+ --> $DIR/ternary_operator.rs:53:19
+ |
+LL | fn main() {
+ | --------- this function should return `Result` or `Option` to accept `?`
+LL | let x = 5 > 2 ? { let x = vec![]: Vec<u16>; x } : { false };
+ | ^ cannot use the `?` operator in a function that returns `()`
+ |
+ = help: the trait `FromResidual<_>` is not implemented for `()`
+
+error: aborting due to 13 previous errors
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/tests/ui/parser/trait-object-delimiters.rs b/tests/ui/parser/trait-object-delimiters.rs
index c41cda187..e9b13defe 100644
--- a/tests/ui/parser/trait-object-delimiters.rs
+++ b/tests/ui/parser/trait-object-delimiters.rs
@@ -3,9 +3,9 @@
fn foo1(_: &dyn Drop + AsRef<str>) {} //~ ERROR ambiguous `+` in a type
//~^ ERROR only auto traits can be used as additional traits in a trait object
-fn foo2(_: &dyn (Drop + AsRef<str>)) {} //~ ERROR incorrect braces around trait bounds
+fn foo2(_: &dyn (Drop + AsRef<str>)) {} //~ ERROR incorrect parentheses around trait bounds
-fn foo2_no_space(_: &dyn(Drop + AsRef<str>)) {} //~ ERROR incorrect braces around trait bounds
+fn foo2_no_space(_: &dyn(Drop + AsRef<str>)) {} //~ ERROR incorrect parentheses around trait bounds
fn foo3(_: &dyn {Drop + AsRef<str>}) {} //~ ERROR expected parameter name, found `{`
//~^ ERROR expected one of `!`, `(`, `)`, `*`, `,`, `?`, `for`, `~`, lifetime, or path, found `{`
diff --git a/tests/ui/parser/trait-object-delimiters.stderr b/tests/ui/parser/trait-object-delimiters.stderr
index ccce3a805..519546750 100644
--- a/tests/ui/parser/trait-object-delimiters.stderr
+++ b/tests/ui/parser/trait-object-delimiters.stderr
@@ -4,28 +4,28 @@ error: ambiguous `+` in a type
LL | fn foo1(_: &dyn Drop + AsRef<str>) {}
| ^^^^^^^^^^^^^^^^^^^^^ help: use parentheses to disambiguate: `(dyn Drop + AsRef<str>)`
-error: incorrect braces around trait bounds
+error: incorrect parentheses around trait bounds
--> $DIR/trait-object-delimiters.rs:6:17
|
LL | fn foo2(_: &dyn (Drop + AsRef<str>)) {}
| ^ ^
|
-help: remove the parentheses
+help: fix the parentheses
|
LL - fn foo2(_: &dyn (Drop + AsRef<str>)) {}
-LL + fn foo2(_: &dyn Drop + AsRef<str>) {}
+LL + fn foo2(_: &(dyn Drop + AsRef<str>)) {}
|
-error: incorrect braces around trait bounds
+error: incorrect parentheses around trait bounds
--> $DIR/trait-object-delimiters.rs:8:25
|
LL | fn foo2_no_space(_: &dyn(Drop + AsRef<str>)) {}
| ^ ^
|
-help: remove the parentheses
+help: fix the parentheses
|
LL - fn foo2_no_space(_: &dyn(Drop + AsRef<str>)) {}
-LL + fn foo2_no_space(_: &dyn Drop + AsRef<str>) {}
+LL + fn foo2_no_space(_: &(dyn Drop + AsRef<str>)) {}
|
error: expected parameter name, found `{`
diff --git a/tests/ui/parser/try-with-nonterminal-block.rs b/tests/ui/parser/try-with-nonterminal-block.rs
new file mode 100644
index 000000000..2a9652f2e
--- /dev/null
+++ b/tests/ui/parser/try-with-nonterminal-block.rs
@@ -0,0 +1,19 @@
+// check-pass
+// edition:2021
+
+#![feature(try_blocks)]
+
+macro_rules! create_try {
+ ($body:block) => {
+ try $body
+ };
+}
+
+fn main() {
+ let x: Option<&str> = create_try! {{
+ None?;
+ "Hello world"
+ }};
+
+ println!("{x:?}");
+}
diff --git a/tests/ui/parser/type-alias-where-fixable.fixed b/tests/ui/parser/type-alias-where-fixable.fixed
deleted file mode 100644
index 2f47c0d91..000000000
--- a/tests/ui/parser/type-alias-where-fixable.fixed
+++ /dev/null
@@ -1,28 +0,0 @@
-// check-pass
-// run-rustfix
-
-trait Trait {
- // Fine.
- type Assoc where u32: Copy;
- // Fine.
- type Assoc2 where u32: Copy, i32: Copy;
-}
-
-impl Trait for u32 {
- // Not fine, suggests moving.
- type Assoc = () where u32: Copy;
- //~^ WARNING where clause not allowed here
- // Not fine, suggests moving `u32: Copy`
- type Assoc2 = () where i32: Copy, u32: Copy;
- //~^ WARNING where clause not allowed here
-}
-
-impl Trait for i32 {
- // Fine.
- type Assoc = () where u32: Copy;
- // Not fine, suggests moving both.
- type Assoc2 = () where u32: Copy, i32: Copy;
- //~^ WARNING where clause not allowed here
-}
-
-fn main() {}
diff --git a/tests/ui/parser/type-alias-where-fixable.rs b/tests/ui/parser/type-alias-where-fixable.rs
deleted file mode 100644
index b20aa9398..000000000
--- a/tests/ui/parser/type-alias-where-fixable.rs
+++ /dev/null
@@ -1,28 +0,0 @@
-// check-pass
-// run-rustfix
-
-trait Trait {
- // Fine.
- type Assoc where u32: Copy;
- // Fine.
- type Assoc2 where u32: Copy, i32: Copy;
-}
-
-impl Trait for u32 {
- // Not fine, suggests moving.
- type Assoc where u32: Copy = ();
- //~^ WARNING where clause not allowed here
- // Not fine, suggests moving `u32: Copy`
- type Assoc2 where u32: Copy = () where i32: Copy;
- //~^ WARNING where clause not allowed here
-}
-
-impl Trait for i32 {
- // Fine.
- type Assoc = () where u32: Copy;
- // Not fine, suggests moving both.
- type Assoc2 where u32: Copy, i32: Copy = ();
- //~^ WARNING where clause not allowed here
-}
-
-fn main() {}
diff --git a/tests/ui/parser/type-alias-where-fixable.stderr b/tests/ui/parser/type-alias-where-fixable.stderr
deleted file mode 100644
index f0acb388b..000000000
--- a/tests/ui/parser/type-alias-where-fixable.stderr
+++ /dev/null
@@ -1,42 +0,0 @@
-warning: where clause not allowed here
- --> $DIR/type-alias-where-fixable.rs:13:16
- |
-LL | type Assoc where u32: Copy = ();
- | ^^^^^^^^^^^^^^^
- |
- = note: see issue #89122 <https://github.com/rust-lang/rust/issues/89122> for more information
- = note: `#[warn(deprecated_where_clause_location)]` on by default
-help: move it to the end of the type declaration
- |
-LL - type Assoc where u32: Copy = ();
-LL + type Assoc = () where u32: Copy;
- |
-
-warning: where clause not allowed here
- --> $DIR/type-alias-where-fixable.rs:16:17
- |
-LL | type Assoc2 where u32: Copy = () where i32: Copy;
- | ^^^^^^^^^^^^^^^
- |
- = note: see issue #89122 <https://github.com/rust-lang/rust/issues/89122> for more information
-help: move it to the end of the type declaration
- |
-LL - type Assoc2 where u32: Copy = () where i32: Copy;
-LL + type Assoc2 = () where i32: Copy, u32: Copy;
- |
-
-warning: where clause not allowed here
- --> $DIR/type-alias-where-fixable.rs:24:17
- |
-LL | type Assoc2 where u32: Copy, i32: Copy = ();
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^
- |
- = note: see issue #89122 <https://github.com/rust-lang/rust/issues/89122> for more information
-help: move it to the end of the type declaration
- |
-LL - type Assoc2 where u32: Copy, i32: Copy = ();
-LL + type Assoc2 = () where u32: Copy, i32: Copy;
- |
-
-warning: 3 warnings emitted
-
diff --git a/tests/ui/parser/type-alias-where.rs b/tests/ui/parser/type-alias-where.rs
deleted file mode 100644
index 62e301cb4..000000000
--- a/tests/ui/parser/type-alias-where.rs
+++ /dev/null
@@ -1,11 +0,0 @@
-// check-fail
-
-// Fine, but lints as unused
-type Foo where u32: Copy = ();
-// Not fine.
-type Bar = () where u32: Copy;
-//~^ ERROR where clauses are not allowed
-type Baz = () where;
-//~^ ERROR where clauses are not allowed
-
-fn main() {}
diff --git a/tests/ui/parser/type-alias-where.stderr b/tests/ui/parser/type-alias-where.stderr
deleted file mode 100644
index fb8381792..000000000
--- a/tests/ui/parser/type-alias-where.stderr
+++ /dev/null
@@ -1,18 +0,0 @@
-error: where clauses are not allowed after the type for type aliases
- --> $DIR/type-alias-where.rs:6:15
- |
-LL | type Bar = () where u32: Copy;
- | ^^^^^^^^^^^^^^^
- |
- = note: see issue #89122 <https://github.com/rust-lang/rust/issues/89122> for more information
-
-error: where clauses are not allowed after the type for type aliases
- --> $DIR/type-alias-where.rs:8:15
- |
-LL | type Baz = () where;
- | ^^^^^
- |
- = note: see issue #89122 <https://github.com/rust-lang/rust/issues/89122> for more information
-
-error: aborting due to 2 previous errors
-