diff options
Diffstat (limited to 'tests/ui/parser')
26 files changed, 244 insertions, 43 deletions
diff --git a/tests/ui/parser/default-unmatched.stderr b/tests/ui/parser/default-unmatched.stderr index 331e003f6..de142411d 100644 --- a/tests/ui/parser/default-unmatched.stderr +++ b/tests/ui/parser/default-unmatched.stderr @@ -11,6 +11,8 @@ error: expected item, found reserved keyword `do` | LL | default do | ^^ expected item + | + = note: for a full list of items that can appear in modules, see <https://doc.rust-lang.org/reference/items.html> error: aborting due to 2 previous errors diff --git a/tests/ui/parser/expr-as-stmt.stderr b/tests/ui/parser/expr-as-stmt.stderr index 18c8b0b7c..76a83aa01 100644 --- a/tests/ui/parser/expr-as-stmt.stderr +++ b/tests/ui/parser/expr-as-stmt.stderr @@ -217,7 +217,7 @@ LL | { true } || { true } | ^^^^^^^^^^^ expected `bool`, found closure | = note: expected type `bool` - found closure `[closure@$DIR/expr-as-stmt.rs:51:14: 51:16]` + found closure `{closure@$DIR/expr-as-stmt.rs:51:14: 51:16}` help: parentheses are required to parse this as an expression | LL | ({ true }) || { true } diff --git a/tests/ui/parser/impl-parsing.stderr b/tests/ui/parser/impl-parsing.stderr index 755addf14..a57cc075c 100644 --- a/tests/ui/parser/impl-parsing.stderr +++ b/tests/ui/parser/impl-parsing.stderr @@ -35,6 +35,8 @@ error: expected item, found keyword `unsafe` | LL | default unsafe FAIL | ^^^^^^ expected item + | + = note: for a full list of items that can appear in modules, see <https://doc.rust-lang.org/reference/items.html> error: aborting due to 6 previous errors diff --git a/tests/ui/parser/issue-101477-enum.stderr b/tests/ui/parser/issue-101477-enum.stderr index 1edca391e..94130671f 100644 --- a/tests/ui/parser/issue-101477-enum.stderr +++ b/tests/ui/parser/issue-101477-enum.stderr @@ -11,6 +11,8 @@ error: expected item, found `==` | LL | B == 2 | ^^ expected item + | + = note: for a full list of items that can appear in modules, see <https://doc.rust-lang.org/reference/items.html> error: aborting due to 2 previous errors diff --git a/tests/ui/parser/issues/issue-113110-non-item-at-module-root.rs b/tests/ui/parser/issues/issue-113110-non-item-at-module-root.rs new file mode 100644 index 000000000..3b6f43043 --- /dev/null +++ b/tests/ui/parser/issues/issue-113110-non-item-at-module-root.rs @@ -0,0 +1 @@ + 5 //~ ERROR expected item, found `5` diff --git a/tests/ui/parser/issues/issue-113110-non-item-at-module-root.stderr b/tests/ui/parser/issues/issue-113110-non-item-at-module-root.stderr new file mode 100644 index 000000000..0789c4548 --- /dev/null +++ b/tests/ui/parser/issues/issue-113110-non-item-at-module-root.stderr @@ -0,0 +1,10 @@ +error: expected item, found `5` + --> $DIR/issue-113110-non-item-at-module-root.rs:1:2 + | +LL | 5 + | ^ expected item + | + = note: for a full list of items that can appear in modules, see <https://doc.rust-lang.org/reference/items.html> + +error: aborting due to previous error + diff --git a/tests/ui/parser/issues/issue-17904-2.stderr b/tests/ui/parser/issues/issue-17904-2.stderr index 9c7fdf6cc..7185a5e57 100644 --- a/tests/ui/parser/issues/issue-17904-2.stderr +++ b/tests/ui/parser/issues/issue-17904-2.stderr @@ -3,6 +3,8 @@ error: expected item, found keyword `where` | LL | struct Bar<T> { x: T } where T: Copy | ^^^^^ expected item + | + = note: for a full list of items that can appear in modules, see <https://doc.rust-lang.org/reference/items.html> error: aborting due to previous error diff --git a/tests/ui/parser/issues/issue-43196.stderr b/tests/ui/parser/issues/issue-43196.stderr index 4f7ed5cc6..15bbb158c 100644 --- a/tests/ui/parser/issues/issue-43196.stderr +++ b/tests/ui/parser/issues/issue-43196.stderr @@ -11,6 +11,8 @@ error: expected item, found `|` | LL | | | ^ expected item + | + = note: for a full list of items that can appear in modules, see <https://doc.rust-lang.org/reference/items.html> error: aborting due to 2 previous errors diff --git a/tests/ui/parser/issues/issue-62913.stderr b/tests/ui/parser/issues/issue-62913.stderr index 6f385e8dc..c33e46837 100644 --- a/tests/ui/parser/issues/issue-62913.stderr +++ b/tests/ui/parser/issues/issue-62913.stderr @@ -17,6 +17,8 @@ error: expected item, found `"\u\"` | LL | "\u\" | ^^^^^^ expected item + | + = note: for a full list of items that can appear in modules, see <https://doc.rust-lang.org/reference/items.html> error: aborting due to 3 previous errors diff --git a/tests/ui/parser/issues/issue-68890.stderr b/tests/ui/parser/issues/issue-68890.stderr index 2a3bf6b41..0d7b53a67 100644 --- a/tests/ui/parser/issues/issue-68890.stderr +++ b/tests/ui/parser/issues/issue-68890.stderr @@ -15,6 +15,8 @@ error: expected item, found `)` | LL | enum e{A((?'a a+?+l))} | ^ expected item + | + = note: for a full list of items that can appear in modules, see <https://doc.rust-lang.org/reference/items.html> error: aborting due to 3 previous errors diff --git a/tests/ui/parser/issues/issue-89388.stderr b/tests/ui/parser/issues/issue-89388.stderr index cf28bef0f..366d05c2d 100644 --- a/tests/ui/parser/issues/issue-89388.stderr +++ b/tests/ui/parser/issues/issue-89388.stderr @@ -2,7 +2,12 @@ error: missing angle brackets in associated item path --> $DIR/issue-89388.rs:5:24 | LL | let _ = option.map([_]::to_vec); - | ^^^^^^^^^^^ help: try: `<[_]>::to_vec` + | ^^^ + | +help: types that don't start with an identifier need to be surrounded with angle brackets in qualified paths + | +LL | let _ = option.map(<[_]>::to_vec); + | + + error: aborting due to previous error diff --git a/tests/ui/parser/issues/issue-98601-delimiter-error-1.rs b/tests/ui/parser/issues/issue-98601-delimiter-error-1.rs new file mode 100644 index 000000000..cfbbd014d --- /dev/null +++ b/tests/ui/parser/issues/issue-98601-delimiter-error-1.rs @@ -0,0 +1,9 @@ +fn foo() { + match 0 { + _ => {} + } + if foo + } +} //~ ERROR unexpected closing delimiter: `}` + +fn main() {} diff --git a/tests/ui/parser/issues/issue-98601-delimiter-error-1.stderr b/tests/ui/parser/issues/issue-98601-delimiter-error-1.stderr new file mode 100644 index 000000000..d568a4c58 --- /dev/null +++ b/tests/ui/parser/issues/issue-98601-delimiter-error-1.stderr @@ -0,0 +1,16 @@ +error: unexpected closing delimiter: `}` + --> $DIR/issue-98601-delimiter-error-1.rs:7:1 + | +LL | fn foo() { + | - this delimiter might not be properly closed... +LL | match 0 { +LL | _ => {} + | -- block is empty, you might have not meant to close it +... +LL | } + | - ...as it matches this but it has different indentation +LL | } + | ^ unexpected closing delimiter + +error: aborting due to previous error + diff --git a/tests/ui/parser/issues/issue-98601-delimiter-error-unexpected-close.rs b/tests/ui/parser/issues/issue-98601-delimiter-error-unexpected-close.rs new file mode 100644 index 000000000..254e816cf --- /dev/null +++ b/tests/ui/parser/issues/issue-98601-delimiter-error-unexpected-close.rs @@ -0,0 +1,5 @@ +fn main() { + todo!(); +} + +fn other(_: i32)) {} //~ ERROR unexpected closing delimiter: `)` diff --git a/tests/ui/parser/issues/issue-98601-delimiter-error-unexpected-close.stderr b/tests/ui/parser/issues/issue-98601-delimiter-error-unexpected-close.stderr new file mode 100644 index 000000000..81dd39bb7 --- /dev/null +++ b/tests/ui/parser/issues/issue-98601-delimiter-error-unexpected-close.stderr @@ -0,0 +1,14 @@ +error: unexpected closing delimiter: `)` + --> $DIR/issue-98601-delimiter-error-unexpected-close.rs:5:17 + | +LL | fn main() { + | - this opening brace... +LL | todo!(); +LL | } + | - ...matches this closing brace +LL | +LL | fn other(_: i32)) {} + | ^ unexpected closing delimiter + +error: aborting due to previous error + diff --git a/tests/ui/parser/keyword-union-as-identifier.rs b/tests/ui/parser/keyword-union-as-identifier.rs new file mode 100644 index 000000000..7062557d7 --- /dev/null +++ b/tests/ui/parser/keyword-union-as-identifier.rs @@ -0,0 +1,72 @@ +// check-pass + +#![allow(non_camel_case_types)] +#![allow(non_upper_case_globals)] + +mod union { + type union = i32; + + pub struct Bar { + pub union: union, + } + + pub fn union() -> Bar { + Bar { + union: 5 + } + } +} + +mod struct_union { + pub struct union { + pub union: u32 + } + static union: union = union { union: 0 }; + + impl union { + pub fn union<'union>() -> &'union union { + &union + } + } + impl union {} + trait Foo {} + impl Foo for union {} + trait Bar { + fn bar() {} + } + impl Bar for union {} +} + +mod union_union { + pub union union { + pub union: u32 + } + const union: union = union { union: 0 }; + impl union { + pub fn union() -> union { + union + } + } +} + +mod trait_union { + pub trait union { + fn union() {} + } + impl union for () {} +} + +macro_rules! ty { + ($ty:ty { $($field:ident:$field_ty:ty)* }) => {}; +} + +fn main() { + let union = union::union(); + let _ = union.union; + let _ = struct_union::union::union().union; + let union = union_union::union::union(); + let _ = unsafe { union.union }; + <() as trait_union::union>::union(); + ty!(union {}); + ty!(union { union: union }); +} diff --git a/tests/ui/parser/macro/macro-expand-to-field.rs b/tests/ui/parser/macro/macro-expand-to-field.rs index 155872f7a..533511ecf 100644 --- a/tests/ui/parser/macro/macro-expand-to-field.rs +++ b/tests/ui/parser/macro/macro-expand-to-field.rs @@ -1,5 +1,7 @@ // compile-flags: --crate-type=lib +// https://github.com/rust-lang/rust/issues/113766 + macro_rules! field { ($name:ident:$type:ty) => { $name:$type @@ -13,15 +15,14 @@ macro_rules! variant { } struct Struct { + //~^ NOTE while parsing this 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 + field!(recovers:()), } enum EnumVariant { @@ -35,7 +36,7 @@ enum EnumVariant { //~^ NOTE macros cannot expand to enum variants //~| ERROR unexpected token: `!` //~| NOTE unexpected token after this - Data { + Data { //~ NOTE while parsing this struct field!(x:u32), //~^ NOTE macros cannot expand to struct fields //~| ERROR unexpected token: `!` @@ -44,27 +45,35 @@ enum EnumVariant { } enum EnumVariantField { - Named { + Named { //~ NOTE while parsing this struct 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 { + //~^ NOTE while parsing this union A: u32, field!(oopsies:()), //~^ NOTE macros cannot expand to union fields //~| ERROR unexpected token: `!` - //~| unexpected token after this + //~| NOTE unexpected token after this B: u32, field!(recovers:()), - //~^ NOTE macros cannot expand to union fields +} + +// https://github.com/rust-lang/rust/issues/114636 + +#[derive(Debug)] +pub struct Lazy { + //~^ NOTE while parsing this struct + unreachable!() + //~^ NOTE macros cannot expand to struct fields //~| ERROR unexpected token: `!` - //~| unexpected token after this + //~| NOTE unexpected token after this } + +fn main() {} diff --git a/tests/ui/parser/macro/macro-expand-to-field.stderr b/tests/ui/parser/macro/macro-expand-to-field.stderr index adcd032f5..0bb718000 100644 --- a/tests/ui/parser/macro/macro-expand-to-field.stderr +++ b/tests/ui/parser/macro/macro-expand-to-field.stderr @@ -1,21 +1,16 @@ error: unexpected token: `!` - --> $DIR/macro-expand-to-field.rs:16:10 + --> $DIR/macro-expand-to-field.rs:19:10 | +LL | struct Struct { + | ------ while parsing this struct +LL | 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 + --> $DIR/macro-expand-to-field.rs:29:12 | LL | variant!(whoops), | ^ unexpected token after this @@ -23,7 +18,7 @@ LL | variant!(whoops), = note: macros cannot expand to enum variants error: unexpected token: `!` - --> $DIR/macro-expand-to-field.rs:34:12 + --> $DIR/macro-expand-to-field.rs:35:12 | LL | variant!(recovers), | ^ unexpected token after this @@ -31,44 +26,46 @@ LL | variant!(recovers), = note: macros cannot expand to enum variants error: unexpected token: `!` - --> $DIR/macro-expand-to-field.rs:39:14 + --> $DIR/macro-expand-to-field.rs:40:14 | +LL | Data { + | ---- while parsing this struct 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 + --> $DIR/macro-expand-to-field.rs:49:14 | +LL | Named { + | ----- while parsing this struct 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 + --> $DIR/macro-expand-to-field.rs:60:10 | +LL | union Union { + | ----- while parsing this union +... 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 + --> $DIR/macro-expand-to-field.rs:73:16 | -LL | field!(recovers:()), - | ^ unexpected token after this +LL | pub struct Lazy { + | ---- while parsing this struct +LL | +LL | unreachable!() + | ^ unexpected token after this | - = note: macros cannot expand to union fields + = note: macros cannot expand to struct fields -error: aborting due to 9 previous errors +error: aborting due to 7 previous errors diff --git a/tests/ui/parser/shebang/shebang-doc-comment.stderr b/tests/ui/parser/shebang/shebang-doc-comment.stderr index 2227d45ec..a36b2a2f7 100644 --- a/tests/ui/parser/shebang/shebang-doc-comment.stderr +++ b/tests/ui/parser/shebang/shebang-doc-comment.stderr @@ -3,6 +3,8 @@ error: expected item, found `[` | LL | [allow(unused_variables)] | ^ expected item + | + = note: for a full list of items that can appear in modules, see <https://doc.rust-lang.org/reference/items.html> error: aborting due to previous error diff --git a/tests/ui/parser/struct-literal-in-if.rs b/tests/ui/parser/struct-literal-in-if.rs index 2ce2c8f18..c4a253c3d 100644 --- a/tests/ui/parser/struct-literal-in-if.rs +++ b/tests/ui/parser/struct-literal-in-if.rs @@ -14,4 +14,9 @@ fn main() { }.hi() { println!("yo"); } + if let true = Foo { //~ ERROR struct literals are not allowed here + x: 3 + }.hi() { + println!("yo"); + } } diff --git a/tests/ui/parser/struct-literal-in-if.stderr b/tests/ui/parser/struct-literal-in-if.stderr index b5a9864bb..8b72469fc 100644 --- a/tests/ui/parser/struct-literal-in-if.stderr +++ b/tests/ui/parser/struct-literal-in-if.stderr @@ -14,5 +14,21 @@ LL | x: 3 LL ~ }).hi() { | -error: aborting due to previous error +error: struct literals are not allowed here + --> $DIR/struct-literal-in-if.rs:17:19 + | +LL | if let true = Foo { + | ___________________^ +LL | | x: 3 +LL | | }.hi() { + | |_____^ + | +help: surround the struct literal with parentheses + | +LL ~ if let true = (Foo { +LL | x: 3 +LL ~ }).hi() { + | + +error: aborting due to 2 previous errors diff --git a/tests/ui/parser/struct-literal-in-match-guard.rs b/tests/ui/parser/struct-literal-in-match-guard.rs index bf0551b5c..bbee60e28 100644 --- a/tests/ui/parser/struct-literal-in-match-guard.rs +++ b/tests/ui/parser/struct-literal-in-match-guard.rs @@ -3,6 +3,8 @@ // Unlike `if` condition, `match` guards accept struct literals. // This is detected in <https://github.com/rust-lang/rust/pull/74566#issuecomment-663613705>. +#![feature(if_let_guard)] + #[derive(PartialEq)] struct Foo { x: isize, @@ -11,6 +13,7 @@ struct Foo { fn foo(f: Foo) { match () { () if f == Foo { x: 42 } => {} + () if let Foo { x: 0.. } = Foo { x: 42 } => {} _ => {} } } diff --git a/tests/ui/parser/struct-literal-in-while.rs b/tests/ui/parser/struct-literal-in-while.rs index 5000ce85b..86931f788 100644 --- a/tests/ui/parser/struct-literal-in-while.rs +++ b/tests/ui/parser/struct-literal-in-while.rs @@ -14,4 +14,9 @@ fn main() { }.hi() { println!("yo"); } + while let true = Foo { //~ ERROR struct literals are not allowed here + x: 3 + }.hi() { + println!("yo"); + } } diff --git a/tests/ui/parser/struct-literal-in-while.stderr b/tests/ui/parser/struct-literal-in-while.stderr index 17e9277e0..13d003608 100644 --- a/tests/ui/parser/struct-literal-in-while.stderr +++ b/tests/ui/parser/struct-literal-in-while.stderr @@ -14,5 +14,21 @@ LL | x: 3 LL ~ }).hi() { | -error: aborting due to previous error +error: struct literals are not allowed here + --> $DIR/struct-literal-in-while.rs:17:22 + | +LL | while let true = Foo { + | ______________________^ +LL | | x: 3 +LL | | }.hi() { + | |_____^ + | +help: surround the struct literal with parentheses + | +LL ~ while let true = (Foo { +LL | x: 3 +LL ~ }).hi() { + | + +error: aborting due to 2 previous errors diff --git a/tests/ui/parser/struct-literal-restrictions-in-lamda.stderr b/tests/ui/parser/struct-literal-restrictions-in-lamda.stderr index 0852c7cb4..c715486e2 100644 --- a/tests/ui/parser/struct-literal-restrictions-in-lamda.stderr +++ b/tests/ui/parser/struct-literal-restrictions-in-lamda.stderr @@ -24,7 +24,7 @@ LL | | }.hi() { | |__________^ expected `bool`, found closure | = note: expected type `bool` - found closure `[closure@$DIR/struct-literal-restrictions-in-lamda.rs:12:11: 12:13]` + found closure `{closure@$DIR/struct-literal-restrictions-in-lamda.rs:12:11: 12:13}` help: use parentheses to call this closure | LL ~ while (|| Foo { diff --git a/tests/ui/parser/virtual-structs.stderr b/tests/ui/parser/virtual-structs.stderr index a5211d83f..268fc1057 100644 --- a/tests/ui/parser/virtual-structs.stderr +++ b/tests/ui/parser/virtual-structs.stderr @@ -3,6 +3,8 @@ error: expected item, found reserved keyword `virtual` | LL | virtual struct SuperStruct { | ^^^^^^^ expected item + | + = note: for a full list of items that can appear in modules, see <https://doc.rust-lang.org/reference/items.html> error: aborting due to previous error |