diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:19:03 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:19:03 +0000 |
commit | 64d98f8ee037282c35007b64c2649055c56af1db (patch) | |
tree | 5492bcf97fce41ee1c0b1cc2add283f3e66cdab0 /tests/ui/parser/issues | |
parent | Adding debian version 1.67.1+dfsg1-1. (diff) | |
download | rustc-64d98f8ee037282c35007b64c2649055c56af1db.tar.xz rustc-64d98f8ee037282c35007b64c2649055c56af1db.zip |
Merging upstream version 1.68.2+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/ui/parser/issues')
340 files changed, 6315 insertions, 0 deletions
diff --git a/tests/ui/parser/issues/auxiliary/issue-21146-inc.rs b/tests/ui/parser/issues/auxiliary/issue-21146-inc.rs new file mode 100644 index 000000000..32a3b9dcc --- /dev/null +++ b/tests/ui/parser/issues/auxiliary/issue-21146-inc.rs @@ -0,0 +1,3 @@ +// include file for issue-21146.rs + +parse_error diff --git a/tests/ui/parser/issues/auxiliary/issue-89971-outer-attr-following-inner-attr-ice.rs b/tests/ui/parser/issues/auxiliary/issue-89971-outer-attr-following-inner-attr-ice.rs new file mode 100644 index 000000000..e5604b816 --- /dev/null +++ b/tests/ui/parser/issues/auxiliary/issue-89971-outer-attr-following-inner-attr-ice.rs @@ -0,0 +1,13 @@ +// force-host +// no-prefer-dynamic + +#![crate_type = "proc-macro"] + +extern crate proc_macro; + +use proc_macro::TokenStream; + +#[proc_macro_derive(ICE)] +pub fn derive(_: TokenStream) -> TokenStream { + r#"#[allow(missing_docs)] struct X { }"#.parse().unwrap() +} diff --git a/tests/ui/parser/issues/auxiliary/issue-94340-inc.rs b/tests/ui/parser/issues/auxiliary/issue-94340-inc.rs new file mode 100644 index 000000000..9429e5143 --- /dev/null +++ b/tests/ui/parser/issues/auxiliary/issue-94340-inc.rs @@ -0,0 +1,3 @@ +// include file for issue-94340.rs +#![deny(rust_2018_idioms)] +#![deny(unused_must_use)] diff --git a/tests/ui/parser/issues/issue-101540.rs b/tests/ui/parser/issues/issue-101540.rs new file mode 100644 index 000000000..328ec6f90 --- /dev/null +++ b/tests/ui/parser/issues/issue-101540.rs @@ -0,0 +1,7 @@ +struct S1 { + struct S2 { + //~^ ERROR structs are not allowed in struct definitions + } +} + +fn main() {} diff --git a/tests/ui/parser/issues/issue-101540.stderr b/tests/ui/parser/issues/issue-101540.stderr new file mode 100644 index 000000000..8af887050 --- /dev/null +++ b/tests/ui/parser/issues/issue-101540.stderr @@ -0,0 +1,12 @@ +error: structs are not allowed in struct definitions + --> $DIR/issue-101540.rs:2:5 + | +LL | struct S1 { + | -- while parsing this struct +LL | struct S2 { + | ^^^^^^^^^ + | + = help: consider creating a new `struct` definition instead of nesting + +error: aborting due to previous error + diff --git a/tests/ui/parser/issues/issue-102182-impl-trait-recover.rs b/tests/ui/parser/issues/issue-102182-impl-trait-recover.rs new file mode 100644 index 000000000..4bfc676d6 --- /dev/null +++ b/tests/ui/parser/issues/issue-102182-impl-trait-recover.rs @@ -0,0 +1,3 @@ +fn foo<T: impl Trait>() {} +//~^ ERROR expected trait bound, found `impl Trait` type +fn main() {} diff --git a/tests/ui/parser/issues/issue-102182-impl-trait-recover.stderr b/tests/ui/parser/issues/issue-102182-impl-trait-recover.stderr new file mode 100644 index 000000000..52b6ae5df --- /dev/null +++ b/tests/ui/parser/issues/issue-102182-impl-trait-recover.stderr @@ -0,0 +1,14 @@ +error: expected trait bound, found `impl Trait` type + --> $DIR/issue-102182-impl-trait-recover.rs:1:11 + | +LL | fn foo<T: impl Trait>() {} + | ^^^^^^^^^^ not a trait + | +help: use the trait bounds directly + | +LL - fn foo<T: impl Trait>() {} +LL + fn foo<T: Trait>() {} + | + +error: aborting due to previous error + diff --git a/tests/ui/parser/issues/issue-10392-2.fixed b/tests/ui/parser/issues/issue-10392-2.fixed new file mode 100644 index 000000000..3386fac17 --- /dev/null +++ b/tests/ui/parser/issues/issue-10392-2.fixed @@ -0,0 +1,9 @@ +// run-rustfix + +pub struct A { pub foo: isize } + +fn a() -> A { panic!() } + +fn main() { + let A { .. } = a(); //~ ERROR: expected `}` +} diff --git a/tests/ui/parser/issues/issue-10392-2.rs b/tests/ui/parser/issues/issue-10392-2.rs new file mode 100644 index 000000000..30628ae31 --- /dev/null +++ b/tests/ui/parser/issues/issue-10392-2.rs @@ -0,0 +1,9 @@ +// run-rustfix + +pub struct A { pub foo: isize } + +fn a() -> A { panic!() } + +fn main() { + let A { .., } = a(); //~ ERROR: expected `}` +} diff --git a/tests/ui/parser/issues/issue-10392-2.stderr b/tests/ui/parser/issues/issue-10392-2.stderr new file mode 100644 index 000000000..4154ecfeb --- /dev/null +++ b/tests/ui/parser/issues/issue-10392-2.stderr @@ -0,0 +1,12 @@ +error: expected `}`, found `,` + --> $DIR/issue-10392-2.rs:8:15 + | +LL | let A { .., } = a(); + | --^ + | | | + | | expected `}` + | | help: remove this comma + | `..` must be at the end and cannot have a trailing comma + +error: aborting due to previous error + diff --git a/tests/ui/parser/issues/issue-10392.rs b/tests/ui/parser/issues/issue-10392.rs new file mode 100644 index 000000000..5b0c2fc2b --- /dev/null +++ b/tests/ui/parser/issues/issue-10392.rs @@ -0,0 +1,7 @@ +struct A { foo: isize } + +fn a() -> A { panic!() } + +fn main() { + let A { , } = a(); //~ ERROR expected ident +} diff --git a/tests/ui/parser/issues/issue-10392.stderr b/tests/ui/parser/issues/issue-10392.stderr new file mode 100644 index 000000000..438ea67d3 --- /dev/null +++ b/tests/ui/parser/issues/issue-10392.stderr @@ -0,0 +1,10 @@ +error: expected identifier, found `,` + --> $DIR/issue-10392.rs:6:13 + | +LL | let A { , } = a(); + | - ^ expected identifier + | | + | while parsing the fields for this pattern + +error: aborting due to previous error + diff --git a/tests/ui/parser/issues/issue-104088.rs b/tests/ui/parser/issues/issue-104088.rs new file mode 100644 index 000000000..5f794fe2d --- /dev/null +++ b/tests/ui/parser/issues/issue-104088.rs @@ -0,0 +1,26 @@ +fn test() { + if let 123 = 123 { println!("yes"); } +} + +fn test_2() { + let 1x = 123; + //~^ ERROR expected identifier, found number literal +} + +fn test_3() { + let 2x: i32 = 123; + //~^ ERROR expected identifier, found number literal +} + +fn test_4() { + if let 2e1 = 123 { + //~^ ERROR mismatched types + } +} + +fn test_5() { + let 23name = 123; + //~^ ERROR expected identifier, found number literal +} + +fn main() {} diff --git a/tests/ui/parser/issues/issue-104088.stderr b/tests/ui/parser/issues/issue-104088.stderr new file mode 100644 index 000000000..ff4b4bdb6 --- /dev/null +++ b/tests/ui/parser/issues/issue-104088.stderr @@ -0,0 +1,29 @@ +error: expected identifier, found number literal + --> $DIR/issue-104088.rs:6:9 + | +LL | let 1x = 123; + | ^^ identifiers cannot start with a number + +error: expected identifier, found number literal + --> $DIR/issue-104088.rs:11:9 + | +LL | let 2x: i32 = 123; + | ^^ identifiers cannot start with a number + +error: expected identifier, found number literal + --> $DIR/issue-104088.rs:22:9 + | +LL | let 23name = 123; + | ^^^^^^ identifiers cannot start with a number + +error[E0308]: mismatched types + --> $DIR/issue-104088.rs:16:12 + | +LL | if let 2e1 = 123 { + | ^^^ --- this expression has type `{integer}` + | | + | expected integer, found floating-point number + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/parser/issues/issue-10636-1.rs b/tests/ui/parser/issues/issue-10636-1.rs new file mode 100644 index 000000000..77c6072d6 --- /dev/null +++ b/tests/ui/parser/issues/issue-10636-1.rs @@ -0,0 +1,8 @@ +struct Obj { + //~^ NOTE: unclosed delimiter + member: usize +) +//~^ ERROR mismatched closing delimiter +//~| NOTE mismatched closing delimiter + +fn main() {} diff --git a/tests/ui/parser/issues/issue-10636-1.stderr b/tests/ui/parser/issues/issue-10636-1.stderr new file mode 100644 index 000000000..1e6294ebe --- /dev/null +++ b/tests/ui/parser/issues/issue-10636-1.stderr @@ -0,0 +1,11 @@ +error: mismatched closing delimiter: `)` + --> $DIR/issue-10636-1.rs:1:12 + | +LL | struct Obj { + | ^ unclosed delimiter +... +LL | ) + | ^ mismatched closing delimiter + +error: aborting due to previous error + diff --git a/tests/ui/parser/issues/issue-10636-2.rs b/tests/ui/parser/issues/issue-10636-2.rs new file mode 100644 index 000000000..6fb63639d --- /dev/null +++ b/tests/ui/parser/issues/issue-10636-2.rs @@ -0,0 +1,11 @@ +// FIXME(31528) we emit a bunch of silly errors here due to continuing past the +// first one. This would be easy-ish to address by better recovery in tokenisation. + +pub fn trace_option(option: Option<isize>) { + option.map(|some| 42; + //~^ ERROR: expected one of + +} +//~^ ERROR: expected expression, found `)` + +fn main() {} diff --git a/tests/ui/parser/issues/issue-10636-2.stderr b/tests/ui/parser/issues/issue-10636-2.stderr new file mode 100644 index 000000000..d4f2da9e3 --- /dev/null +++ b/tests/ui/parser/issues/issue-10636-2.stderr @@ -0,0 +1,16 @@ +error: expected one of `)`, `,`, `.`, `?`, or an operator, found `;` + --> $DIR/issue-10636-2.rs:5:15 + | +LL | option.map(|some| 42; + | ^ ^ help: `)` may belong here + | | + | unclosed delimiter + +error: expected expression, found `)` + --> $DIR/issue-10636-2.rs:8:1 + | +LL | } + | ^ expected expression + +error: aborting due to 2 previous errors + diff --git a/tests/ui/parser/issues/issue-13483.rs b/tests/ui/parser/issues/issue-13483.rs new file mode 100644 index 000000000..4e32fcab3 --- /dev/null +++ b/tests/ui/parser/issues/issue-13483.rs @@ -0,0 +1,17 @@ +fn main() { + if true { + } else if { + //~^ ERROR missing condition for `if` expression + } else { + } +} + +fn foo() { + if true { + } else if { + //~^ ERROR missing condition for `if` expression + } + bar(); +} + +fn bar() {} diff --git a/tests/ui/parser/issues/issue-13483.stderr b/tests/ui/parser/issues/issue-13483.stderr new file mode 100644 index 000000000..f5534090f --- /dev/null +++ b/tests/ui/parser/issues/issue-13483.stderr @@ -0,0 +1,18 @@ +error: missing condition for `if` expression + --> $DIR/issue-13483.rs:3:14 + | +LL | } else if { + | ^- if this block is the condition of the `if` expression, then it must be followed by another block + | | + | expected condition here + +error: missing condition for `if` expression + --> $DIR/issue-13483.rs:11:14 + | +LL | } else if { + | ^- if this block is the condition of the `if` expression, then it must be followed by another block + | | + | expected condition here + +error: aborting due to 2 previous errors + diff --git a/tests/ui/parser/issues/issue-14303-fncall.full.stderr b/tests/ui/parser/issues/issue-14303-fncall.full.stderr new file mode 100644 index 000000000..0c152516a --- /dev/null +++ b/tests/ui/parser/issues/issue-14303-fncall.full.stderr @@ -0,0 +1,9 @@ +error[E0747]: type provided when a lifetime was expected + --> $DIR/issue-14303-fncall.rs:15:26 + | +LL | .collect::<Vec<S<_, 'a>>>(); + | ^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0747`. diff --git a/tests/ui/parser/issues/issue-14303-fncall.generic_arg.stderr b/tests/ui/parser/issues/issue-14303-fncall.generic_arg.stderr new file mode 100644 index 000000000..571815776 --- /dev/null +++ b/tests/ui/parser/issues/issue-14303-fncall.generic_arg.stderr @@ -0,0 +1,9 @@ +error[E0747]: inferred provided when a lifetime was expected + --> $DIR/issue-14303-fncall.rs:15:26 + | +LL | .collect::<Vec<S<_, 'a>>>(); + | ^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0747`. diff --git a/tests/ui/parser/issues/issue-14303-fncall.rs b/tests/ui/parser/issues/issue-14303-fncall.rs new file mode 100644 index 000000000..afc4959f1 --- /dev/null +++ b/tests/ui/parser/issues/issue-14303-fncall.rs @@ -0,0 +1,20 @@ +// revisions: full generic_arg +// can't run rustfix because it doesn't handle multipart suggestions correctly +// we need the above to avoid ast borrowck failure in recovered code +#![cfg_attr(generic_arg, feature(generic_arg_infer))] + + +struct S<'a, T> { + a: &'a T, + b: &'a T, +} + +fn foo<'a, 'b>(start: &'a usize, end: &'a usize) { + let _x = (*start..*end) + .map(|x| S { a: start, b: end }) + .collect::<Vec<S<_, 'a>>>(); + //[generic_arg]~^ ERROR inferred provided when a lifetime was expected + //[full]~^^ ERROR type provided when a lifetime was expected +} + +fn main() {} diff --git a/tests/ui/parser/issues/issue-14303.rs b/tests/ui/parser/issues/issue-14303.rs new file mode 100644 index 000000000..82850d77a --- /dev/null +++ b/tests/ui/parser/issues/issue-14303.rs @@ -0,0 +1,33 @@ +enum Enum<'a, T, 'b> { +//~^ ERROR lifetime parameters must be declared prior to type and const parameters + A(&'a &'b T) +} + +struct Struct<'a, T, 'b> { +//~^ ERROR lifetime parameters must be declared prior to type and const parameters + x: &'a &'b T +} + +trait Trait<'a, T, 'b> {} +//~^ ERROR lifetime parameters must be declared prior to type and const parameters + +fn foo<'a, T, 'b>(x: &'a T) {} +//~^ ERROR lifetime parameters must be declared prior to type and const parameters + +struct Y<T>(T); +impl<'a, T, 'b> Y<T> {} +//~^ ERROR lifetime parameters must be declared prior to type and const parameters + +mod bar { + pub struct X<'a, 'b, 'c, T> { + a: &'a str, + b: &'b str, + c: &'c str, + t: T, + } +} + +fn bar<'a, 'b, 'c, T>(x: bar::X<'a, T, 'b, 'c>) {} +//~^ ERROR type provided when a lifetime was expected + +fn main() {} diff --git a/tests/ui/parser/issues/issue-14303.stderr b/tests/ui/parser/issues/issue-14303.stderr new file mode 100644 index 000000000..f121107c0 --- /dev/null +++ b/tests/ui/parser/issues/issue-14303.stderr @@ -0,0 +1,39 @@ +error: lifetime parameters must be declared prior to type and const parameters + --> $DIR/issue-14303.rs:1:18 + | +LL | enum Enum<'a, T, 'b> { + | --------^^- help: reorder the parameters: lifetimes, then consts and types: `<'a, 'b, T>` + +error: lifetime parameters must be declared prior to type and const parameters + --> $DIR/issue-14303.rs:6:22 + | +LL | struct Struct<'a, T, 'b> { + | --------^^- help: reorder the parameters: lifetimes, then consts and types: `<'a, 'b, T>` + +error: lifetime parameters must be declared prior to type and const parameters + --> $DIR/issue-14303.rs:11:20 + | +LL | trait Trait<'a, T, 'b> {} + | --------^^- help: reorder the parameters: lifetimes, then consts and types: `<'a, 'b, T>` + +error: lifetime parameters must be declared prior to type and const parameters + --> $DIR/issue-14303.rs:14:15 + | +LL | fn foo<'a, T, 'b>(x: &'a T) {} + | --------^^- help: reorder the parameters: lifetimes, then consts and types: `<'a, 'b, T>` + +error: lifetime parameters must be declared prior to type and const parameters + --> $DIR/issue-14303.rs:18:13 + | +LL | impl<'a, T, 'b> Y<T> {} + | --------^^- help: reorder the parameters: lifetimes, then consts and types: `<'a, 'b, T>` + +error[E0747]: type provided when a lifetime was expected + --> $DIR/issue-14303.rs:30:37 + | +LL | fn bar<'a, 'b, 'c, T>(x: bar::X<'a, T, 'b, 'c>) {} + | ^ + +error: aborting due to 6 previous errors + +For more information about this error, try `rustc --explain E0747`. diff --git a/tests/ui/parser/issues/issue-15914.rs b/tests/ui/parser/issues/issue-15914.rs new file mode 100644 index 000000000..4a5606af6 --- /dev/null +++ b/tests/ui/parser/issues/issue-15914.rs @@ -0,0 +1,4 @@ +fn main() { + let ref + (); //~ ERROR expected identifier, found `(` +} diff --git a/tests/ui/parser/issues/issue-15914.stderr b/tests/ui/parser/issues/issue-15914.stderr new file mode 100644 index 000000000..ea26453f8 --- /dev/null +++ b/tests/ui/parser/issues/issue-15914.stderr @@ -0,0 +1,8 @@ +error: expected identifier, found `(` + --> $DIR/issue-15914.rs:3:9 + | +LL | (); + | ^ expected identifier + +error: aborting due to previous error + diff --git a/tests/ui/parser/issues/issue-15980.rs b/tests/ui/parser/issues/issue-15980.rs new file mode 100644 index 000000000..87faa7d5f --- /dev/null +++ b/tests/ui/parser/issues/issue-15980.rs @@ -0,0 +1,17 @@ +use std::io; + +fn main(){ + let x: io::Result<()> = Ok(()); + match x { + Err(ref e) if e.kind == io::EndOfFile { + //~^ NOTE while parsing this struct + return + //~^ ERROR expected identifier, found keyword `return` + //~| NOTE expected identifier, found keyword + } + //~^ NOTE expected one of `.`, `=>`, `?`, or an operator + _ => {} + //~^ ERROR expected one of `.`, `=>`, `?`, or an operator, found reserved identifier `_` + //~| NOTE unexpected token + } +} diff --git a/tests/ui/parser/issues/issue-15980.stderr b/tests/ui/parser/issues/issue-15980.stderr new file mode 100644 index 000000000..c59c81119 --- /dev/null +++ b/tests/ui/parser/issues/issue-15980.stderr @@ -0,0 +1,25 @@ +error: expected identifier, found keyword `return` + --> $DIR/issue-15980.rs:8:13 + | +LL | Err(ref e) if e.kind == io::EndOfFile { + | ------------- while parsing this struct +LL | +LL | return + | ^^^^^^ expected identifier, found keyword + | +help: escape `return` to use it as an identifier + | +LL | r#return + | ++ + +error: expected one of `.`, `=>`, `?`, or an operator, found reserved identifier `_` + --> $DIR/issue-15980.rs:13:9 + | +LL | } + | - expected one of `.`, `=>`, `?`, or an operator +LL | +LL | _ => {} + | ^ unexpected token + +error: aborting due to 2 previous errors + diff --git a/tests/ui/parser/issues/issue-1655.rs b/tests/ui/parser/issues/issue-1655.rs new file mode 100644 index 000000000..e9fc6f153 --- /dev/null +++ b/tests/ui/parser/issues/issue-1655.rs @@ -0,0 +1,10 @@ +mod blade_runner { + #vec[doc( //~ ERROR expected one of `!` or `[`, found `vec` + brief = "Blade Runner is probably the best movie ever", + desc = "I like that in the world of Blade Runner it is always + raining, and that it's always night time. And Aliens + was also a really good movie. + + Alien 3 was crap though." + )] +} diff --git a/tests/ui/parser/issues/issue-1655.stderr b/tests/ui/parser/issues/issue-1655.stderr new file mode 100644 index 000000000..0c390a0ec --- /dev/null +++ b/tests/ui/parser/issues/issue-1655.stderr @@ -0,0 +1,8 @@ +error: expected one of `!` or `[`, found `vec` + --> $DIR/issue-1655.rs:2:6 + | +LL | #vec[doc( + | ^^^ expected one of `!` or `[` + +error: aborting due to previous error + diff --git a/tests/ui/parser/issues/issue-17718-const-mut.rs b/tests/ui/parser/issues/issue-17718-const-mut.rs new file mode 100644 index 000000000..795a8c763 --- /dev/null +++ b/tests/ui/parser/issues/issue-17718-const-mut.rs @@ -0,0 +1,7 @@ +const +mut //~ ERROR: const globals cannot be mutable +//~^^ HELP you might want to declare a static instead +FOO: usize = 3; + +fn main() { +} diff --git a/tests/ui/parser/issues/issue-17718-const-mut.stderr b/tests/ui/parser/issues/issue-17718-const-mut.stderr new file mode 100644 index 000000000..8251ce999 --- /dev/null +++ b/tests/ui/parser/issues/issue-17718-const-mut.stderr @@ -0,0 +1,10 @@ +error: const globals cannot be mutable + --> $DIR/issue-17718-const-mut.rs:2:1 + | +LL | const + | ----- help: you might want to declare a static instead: `static` +LL | mut + | ^^^ cannot be mutable + +error: aborting due to previous error + diff --git a/tests/ui/parser/issues/issue-17904-2.rs b/tests/ui/parser/issues/issue-17904-2.rs new file mode 100644 index 000000000..186a955c3 --- /dev/null +++ b/tests/ui/parser/issues/issue-17904-2.rs @@ -0,0 +1,3 @@ +struct Bar<T> { x: T } where T: Copy //~ ERROR expected item, found keyword `where` + +fn main() {} diff --git a/tests/ui/parser/issues/issue-17904-2.stderr b/tests/ui/parser/issues/issue-17904-2.stderr new file mode 100644 index 000000000..9c7fdf6cc --- /dev/null +++ b/tests/ui/parser/issues/issue-17904-2.stderr @@ -0,0 +1,8 @@ +error: expected item, found keyword `where` + --> $DIR/issue-17904-2.rs:1:24 + | +LL | struct Bar<T> { x: T } where T: Copy + | ^^^^^ expected item + +error: aborting due to previous error + diff --git a/tests/ui/parser/issues/issue-17904.rs b/tests/ui/parser/issues/issue-17904.rs new file mode 100644 index 000000000..020fb41c2 --- /dev/null +++ b/tests/ui/parser/issues/issue-17904.rs @@ -0,0 +1,8 @@ +// compile-flags: -Zparse-only + +struct Baz<U> where U: Eq(U); //This is parsed as the new Fn* style parenthesis syntax. +struct Baz<U> where U: Eq(U) -> R; // Notice this parses as well. +struct Baz<U>(U) where U: Eq; // This rightfully signals no error as well. +struct Foo<T> where T: Copy, (T); //~ ERROR where clauses are not allowed before tuple struct bodies + +fn main() {} diff --git a/tests/ui/parser/issues/issue-17904.stderr b/tests/ui/parser/issues/issue-17904.stderr new file mode 100644 index 000000000..aa343975d --- /dev/null +++ b/tests/ui/parser/issues/issue-17904.stderr @@ -0,0 +1,17 @@ +error: where clauses are not allowed before tuple struct bodies + --> $DIR/issue-17904.rs:6:15 + | +LL | struct Foo<T> where T: Copy, (T); + | --- ^^^^^^^^^^^^^^ --- the struct body + | | | + | | unexpected where clause + | while parsing this tuple struct + | +help: move the body before the where clause + | +LL - struct Foo<T> where T: Copy, (T); +LL + struct Foo<T>(T) where T: Copy; + | + +error: aborting due to previous error + diff --git a/tests/ui/parser/issues/issue-1802-1.rs b/tests/ui/parser/issues/issue-1802-1.rs new file mode 100644 index 000000000..3c34b0d8f --- /dev/null +++ b/tests/ui/parser/issues/issue-1802-1.rs @@ -0,0 +1,7 @@ +fn log(a: i32, b: i32) {} + +fn main() { + let error = 42; + log(error, 0b); + //~^ ERROR no valid digits found for number +} diff --git a/tests/ui/parser/issues/issue-1802-1.stderr b/tests/ui/parser/issues/issue-1802-1.stderr new file mode 100644 index 000000000..954cc0bee --- /dev/null +++ b/tests/ui/parser/issues/issue-1802-1.stderr @@ -0,0 +1,9 @@ +error[E0768]: no valid digits found for number + --> $DIR/issue-1802-1.rs:5:16 + | +LL | log(error, 0b); + | ^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0768`. diff --git a/tests/ui/parser/issues/issue-1802-2.rs b/tests/ui/parser/issues/issue-1802-2.rs new file mode 100644 index 000000000..3c34b0d8f --- /dev/null +++ b/tests/ui/parser/issues/issue-1802-2.rs @@ -0,0 +1,7 @@ +fn log(a: i32, b: i32) {} + +fn main() { + let error = 42; + log(error, 0b); + //~^ ERROR no valid digits found for number +} diff --git a/tests/ui/parser/issues/issue-1802-2.stderr b/tests/ui/parser/issues/issue-1802-2.stderr new file mode 100644 index 000000000..49043d07b --- /dev/null +++ b/tests/ui/parser/issues/issue-1802-2.stderr @@ -0,0 +1,9 @@ +error[E0768]: no valid digits found for number + --> $DIR/issue-1802-2.rs:5:16 + | +LL | log(error, 0b); + | ^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0768`. diff --git a/tests/ui/parser/issues/issue-19096.rs b/tests/ui/parser/issues/issue-19096.rs new file mode 100644 index 000000000..c5bfd10ee --- /dev/null +++ b/tests/ui/parser/issues/issue-19096.rs @@ -0,0 +1,10 @@ +fn main() { // we don't complain about the return type being `{integer}` + let t = (42, 42); + t.0::<isize>; //~ ERROR expected one of `.`, `;`, `?`, `}`, or an operator, found `::` +} + +fn foo() -> usize { // we don't complain about the return type being unit + let t = (42, 42); + t.0::<isize>; //~ ERROR expected one of `.`, `;`, `?`, `}`, or an operator, found `::` + 42; +} diff --git a/tests/ui/parser/issues/issue-19096.stderr b/tests/ui/parser/issues/issue-19096.stderr new file mode 100644 index 000000000..4df7f878b --- /dev/null +++ b/tests/ui/parser/issues/issue-19096.stderr @@ -0,0 +1,14 @@ +error: expected one of `.`, `;`, `?`, `}`, or an operator, found `::` + --> $DIR/issue-19096.rs:3:8 + | +LL | t.0::<isize>; + | ^^ expected one of `.`, `;`, `?`, `}`, or an operator + +error: expected one of `.`, `;`, `?`, `}`, or an operator, found `::` + --> $DIR/issue-19096.rs:8:8 + | +LL | t.0::<isize>; + | ^^ expected one of `.`, `;`, `?`, `}`, or an operator + +error: aborting due to 2 previous errors + diff --git a/tests/ui/parser/issues/issue-19398.rs b/tests/ui/parser/issues/issue-19398.rs new file mode 100644 index 000000000..46eb320a1 --- /dev/null +++ b/tests/ui/parser/issues/issue-19398.rs @@ -0,0 +1,6 @@ +trait T { + extern "Rust" unsafe fn foo(); + //~^ ERROR expected `{`, found keyword `unsafe` +} + +fn main() {} diff --git a/tests/ui/parser/issues/issue-19398.stderr b/tests/ui/parser/issues/issue-19398.stderr new file mode 100644 index 000000000..1da00960a --- /dev/null +++ b/tests/ui/parser/issues/issue-19398.stderr @@ -0,0 +1,13 @@ +error: expected `{`, found keyword `unsafe` + --> $DIR/issue-19398.rs:2:19 + | +LL | trait T { + | - while parsing this item list starting here +LL | extern "Rust" unsafe fn foo(); + | ^^^^^^ expected `{` +LL | +LL | } + | - the item list ends here + +error: aborting due to previous error + diff --git a/tests/ui/parser/issues/issue-20616-1.rs b/tests/ui/parser/issues/issue-20616-1.rs new file mode 100644 index 000000000..49e9cb310 --- /dev/null +++ b/tests/ui/parser/issues/issue-20616-1.rs @@ -0,0 +1,36 @@ +// We need all these 9 issue-20616-N.rs files +// because we can only catch one parsing error at a time + + + +type Type_1_<'a, T> = &'a T; + + +type Type_1<'a T> = &'a T; //~ error: expected one of `,`, `:`, or `>`, found `T` + + +//type Type_2 = Type_1_<'static ()>; // error: expected `,` or `>` after lifetime name, found `(` + + +//type Type_3<T> = Box<T,,>; // error: expected type, found `,` + + +//type Type_4<T> = Type_1_<'static,, T>; // error: expected type, found `,` + + +type Type_5_<'a> = Type_1_<'a, ()>; + + +//type Type_5<'a> = Type_1_<'a, (),,>; // error: expected type, found `,` + + +//type Type_6 = Type_5_<'a,,>; // error: expected type, found `,` + + +//type Type_7 = Box<(),,>; // error: expected type, found `,` + + +//type Type_8<'a,,> = &'a (); // error: expected ident, found `,` + + +//type Type_9<T,,> = Box<T>; // error: expected ident, found `,` diff --git a/tests/ui/parser/issues/issue-20616-1.stderr b/tests/ui/parser/issues/issue-20616-1.stderr new file mode 100644 index 000000000..816046237 --- /dev/null +++ b/tests/ui/parser/issues/issue-20616-1.stderr @@ -0,0 +1,8 @@ +error: expected one of `,`, `:`, or `>`, found `T` + --> $DIR/issue-20616-1.rs:9:16 + | +LL | type Type_1<'a T> = &'a T; + | ^ expected one of `,`, `:`, or `>` + +error: aborting due to previous error + diff --git a/tests/ui/parser/issues/issue-20616-2.rs b/tests/ui/parser/issues/issue-20616-2.rs new file mode 100644 index 000000000..2f2c6903a --- /dev/null +++ b/tests/ui/parser/issues/issue-20616-2.rs @@ -0,0 +1,36 @@ +// We need all these 9 issue-20616-N.rs files +// because we can only catch one parsing error at a time + + + +type Type_1_<'a, T> = &'a T; + + +//type Type_1<'a T> = &'a T; // error: expected `,` or `>` after lifetime name, found `T` + + +type Type_2 = Type_1_<'static ()>; //~ error: expected one of `,` or `>`, found `(` + + +//type Type_3<T> = Box<T,,>; // error: expected type, found `,` + + +//type Type_4<T> = Type_1_<'static,, T>; // error: expected type, found `,` + + +type Type_5_<'a> = Type_1_<'a, ()>; + + +//type Type_5<'a> = Type_1_<'a, (),,>; // error: expected type, found `,` + + +//type Type_6 = Type_5_<'a,,>; // error: expected type, found `,` + + +//type Type_7 = Box<(),,>; // error: expected type, found `,` + + +//type Type_8<'a,,> = &'a (); // error: expected ident, found `,` + + +//type Type_9<T,,> = Box<T>; // error: expected ident, found `,` diff --git a/tests/ui/parser/issues/issue-20616-2.stderr b/tests/ui/parser/issues/issue-20616-2.stderr new file mode 100644 index 000000000..42059685c --- /dev/null +++ b/tests/ui/parser/issues/issue-20616-2.stderr @@ -0,0 +1,13 @@ +error: expected one of `,` or `>`, found `(` + --> $DIR/issue-20616-2.rs:12:31 + | +LL | type Type_2 = Type_1_<'static ()>; + | ^ expected one of `,` or `>` + | +help: you might have meant to end the type parameters here + | +LL | type Type_2 = Type_1_<'static> ()>; + | + + +error: aborting due to previous error + diff --git a/tests/ui/parser/issues/issue-20616-3.rs b/tests/ui/parser/issues/issue-20616-3.rs new file mode 100644 index 000000000..b2371051c --- /dev/null +++ b/tests/ui/parser/issues/issue-20616-3.rs @@ -0,0 +1,35 @@ +// We need all these 9 issue-20616-N.rs files +// because we can only catch one parsing error at a time + +type Type_1_<'a, T> = &'a T; + + +//type Type_1<'a T> = &'a T; // error: expected `,` or `>` after lifetime name, found `T` + + +//type Type_2 = Type_1_<'static ()>; // error: expected `,` or `>` after lifetime name, found `(` + + +type Type_3<T> = Box<T,,>; +//~^ error: expected one of `>`, a const expression, lifetime, or type, found `,` + + +//type Type_4<T> = Type_1_<'static,, T>; // error: expected type, found `,` + + +type Type_5_<'a> = Type_1_<'a, ()>; + + +//type Type_5<'a> = Type_1_<'a, (),,>; // error: expected type, found `,` + + +//type Type_6 = Type_5_<'a,,>; // error: expected type, found `,` + + +//type Type_7 = Box<(),,>; // error: expected type, found `,` + + +//type Type_8<'a,,> = &'a (); // error: expected ident, found `,` + + +//type Type_9<T,,> = Box<T>; // error: expected ident, found `,` diff --git a/tests/ui/parser/issues/issue-20616-3.stderr b/tests/ui/parser/issues/issue-20616-3.stderr new file mode 100644 index 000000000..dbff116e5 --- /dev/null +++ b/tests/ui/parser/issues/issue-20616-3.stderr @@ -0,0 +1,13 @@ +error: expected one of `>`, a const expression, lifetime, or type, found `,` + --> $DIR/issue-20616-3.rs:13:24 + | +LL | type Type_3<T> = Box<T,,>; + | ^ expected one of `>`, a const expression, lifetime, or type + | +help: you might have meant to end the type parameters here + | +LL | type Type_3<T> = Box<T>,,>; + | + + +error: aborting due to previous error + diff --git a/tests/ui/parser/issues/issue-20616-4.rs b/tests/ui/parser/issues/issue-20616-4.rs new file mode 100644 index 000000000..a71f47ca4 --- /dev/null +++ b/tests/ui/parser/issues/issue-20616-4.rs @@ -0,0 +1,35 @@ +// We need all these 9 issue-20616-N.rs files +// because we can only catch one parsing error at a time + +type Type_1_<'a, T> = &'a T; + + +//type Type_1<'a T> = &'a T; // error: expected `,` or `>` after lifetime name, found `T` + + +//type Type_2 = Type_1_<'static ()>; // error: expected `,` or `>` after lifetime name, found `(` + + +//type Type_3<T> = Box<T,,>; // error: expected type, found `,` + + +type Type_4<T> = Type_1_<'static,, T>; +//~^ error: expected one of `>`, a const expression, lifetime, or type, found `,` + + +type Type_5_<'a> = Type_1_<'a, ()>; + + +//type Type_5<'a> = Type_1_<'a, (),,>; // error: expected type, found `,` + + +//type Type_6 = Type_5_<'a,,>; // error: expected type, found `,` + + +//type Type_7 = Box<(),,>; // error: expected type, found `,` + + +//type Type_8<'a,,> = &'a (); // error: expected ident, found `,` + + +//type Type_9<T,,> = Box<T>; // error: expected ident, found `,` diff --git a/tests/ui/parser/issues/issue-20616-4.stderr b/tests/ui/parser/issues/issue-20616-4.stderr new file mode 100644 index 000000000..48a06e00b --- /dev/null +++ b/tests/ui/parser/issues/issue-20616-4.stderr @@ -0,0 +1,13 @@ +error: expected one of `>`, a const expression, lifetime, or type, found `,` + --> $DIR/issue-20616-4.rs:16:34 + | +LL | type Type_4<T> = Type_1_<'static,, T>; + | ^ expected one of `>`, a const expression, lifetime, or type + | +help: you might have meant to end the type parameters here + | +LL | type Type_4<T> = Type_1_<'static>,, T>; + | + + +error: aborting due to previous error + diff --git a/tests/ui/parser/issues/issue-20616-5.rs b/tests/ui/parser/issues/issue-20616-5.rs new file mode 100644 index 000000000..b96d09d59 --- /dev/null +++ b/tests/ui/parser/issues/issue-20616-5.rs @@ -0,0 +1,35 @@ +// We need all these 9 issue-20616-N.rs files +// because we can only catch one parsing error at a time + +type Type_1_<'a, T> = &'a T; + + +//type Type_1<'a T> = &'a T; // error: expected `,` or `>` after lifetime name, found `T` + + +//type Type_2 = Type_1_<'static ()>; // error: expected `,` or `>` after lifetime name, found `(` + + +//type Type_3<T> = Box<T,,>; // error: expected type, found `,` + + +//type Type_4<T> = Type_1_<'static,, T>; // error: expected type, found `,` + + +type Type_5_<'a> = Type_1_<'a, ()>; + + +type Type_5<'a> = Type_1_<'a, (),,>; +//~^ error: expected one of `>`, a const expression, lifetime, or type, found `,` + + +//type Type_6 = Type_5_<'a,,>; // error: expected type, found `,` + + +//type Type_7 = Box<(),,>; // error: expected type, found `,` + + +//type Type_8<'a,,> = &'a (); // error: expected ident, found `,` + + +//type Type_9<T,,> = Box<T>; // error: expected ident, found `,` diff --git a/tests/ui/parser/issues/issue-20616-5.stderr b/tests/ui/parser/issues/issue-20616-5.stderr new file mode 100644 index 000000000..84bee2ad1 --- /dev/null +++ b/tests/ui/parser/issues/issue-20616-5.stderr @@ -0,0 +1,13 @@ +error: expected one of `>`, a const expression, lifetime, or type, found `,` + --> $DIR/issue-20616-5.rs:22:34 + | +LL | type Type_5<'a> = Type_1_<'a, (),,>; + | ^ expected one of `>`, a const expression, lifetime, or type + | +help: you might have meant to end the type parameters here + | +LL | type Type_5<'a> = Type_1_<'a, ()>,,>; + | + + +error: aborting due to previous error + diff --git a/tests/ui/parser/issues/issue-20616-6.rs b/tests/ui/parser/issues/issue-20616-6.rs new file mode 100644 index 000000000..a2c45ecec --- /dev/null +++ b/tests/ui/parser/issues/issue-20616-6.rs @@ -0,0 +1,35 @@ +// We need all these 9 issue-20616-N.rs files +// because we can only catch one parsing error at a time + +type Type_1_<'a, T> = &'a T; + + +//type Type_1<'a T> = &'a T; // error: expected `,` or `>` after lifetime name, found `T` + + +//type Type_2 = Type_1_<'static ()>; // error: expected `,` or `>` after lifetime name, found `(` + + +//type Type_3<T> = Box<T,,>; // error: expected type, found `,` + + +//type Type_4<T> = Type_1_<'static,, T>; // error: expected type, found `,` + + +type Type_5_<'a> = Type_1_<'a, ()>; + + +//type Type_5<'a> = Type_1_<'a, (),,>; // error: expected type, found `,` + + +type Type_6 = Type_5_<'a,,>; +//~^ error: expected one of `>`, a const expression, lifetime, or type, found `,` + + +//type Type_7 = Box<(),,>; // error: expected type, found `,` + + +//type Type_8<'a,,> = &'a (); // error: expected ident, found `,` + + +//type Type_9<T,,> = Box<T>; // error: expected ident, found `,` diff --git a/tests/ui/parser/issues/issue-20616-6.stderr b/tests/ui/parser/issues/issue-20616-6.stderr new file mode 100644 index 000000000..67de41b97 --- /dev/null +++ b/tests/ui/parser/issues/issue-20616-6.stderr @@ -0,0 +1,13 @@ +error: expected one of `>`, a const expression, lifetime, or type, found `,` + --> $DIR/issue-20616-6.rs:25:26 + | +LL | type Type_6 = Type_5_<'a,,>; + | ^ expected one of `>`, a const expression, lifetime, or type + | +help: you might have meant to end the type parameters here + | +LL | type Type_6 = Type_5_<'a>,,>; + | + + +error: aborting due to previous error + diff --git a/tests/ui/parser/issues/issue-20616-7.rs b/tests/ui/parser/issues/issue-20616-7.rs new file mode 100644 index 000000000..67209c02a --- /dev/null +++ b/tests/ui/parser/issues/issue-20616-7.rs @@ -0,0 +1,35 @@ +// We need all these 9 issue-20616-N.rs files +// because we can only catch one parsing error at a time + +type Type_1_<'a, T> = &'a T; + + +//type Type_1<'a T> = &'a T; // error: expected `,` or `>` after lifetime name, found `T` + + +//type Type_2 = Type_1_<'static ()>; // error: expected `,` or `>` after lifetime name, found `(` + + +//type Type_3<T> = Box<T,,>; // error: expected type, found `,` + + +//type Type_4<T> = Type_1_<'static,, T>; // error: expected type, found `,` + + +type Type_5_<'a> = Type_1_<'a, ()>; + + +//type Type_5<'a> = Type_1_<'a, (),,>; // error: expected type, found `,` + + +//type Type_6 = Type_5_<'a,,>; // error: expected type, found `,` + + +type Type_7 = Box<(),,>; +//~^ error: expected one of `>`, a const expression, lifetime, or type, found `,` + + +//type Type_8<'a,,> = &'a (); // error: expected ident, found `,` + + +//type Type_9<T,,> = Box<T>; // error: expected ident, found `,` diff --git a/tests/ui/parser/issues/issue-20616-7.stderr b/tests/ui/parser/issues/issue-20616-7.stderr new file mode 100644 index 000000000..3b8e07fa0 --- /dev/null +++ b/tests/ui/parser/issues/issue-20616-7.stderr @@ -0,0 +1,13 @@ +error: expected one of `>`, a const expression, lifetime, or type, found `,` + --> $DIR/issue-20616-7.rs:28:22 + | +LL | type Type_7 = Box<(),,>; + | ^ expected one of `>`, a const expression, lifetime, or type + | +help: you might have meant to end the type parameters here + | +LL | type Type_7 = Box<()>,,>; + | + + +error: aborting due to previous error + diff --git a/tests/ui/parser/issues/issue-20616-8.rs b/tests/ui/parser/issues/issue-20616-8.rs new file mode 100644 index 000000000..3ceb58d12 --- /dev/null +++ b/tests/ui/parser/issues/issue-20616-8.rs @@ -0,0 +1,35 @@ +// We need all these 9 issue-20616-N.rs files +// because we can only catch one parsing error at a time + +type Type_1_<'a, T> = &'a T; + + +//type Type_1<'a T> = &'a T; // error: expected `,` or `>` after lifetime name, found `T` + + +//type Type_2 = Type_1_<'static ()>; // error: expected `,` or `>` after lifetime name, found `(` + + +//type Type_3<T> = Box<T,,>; // error: expected type, found `,` + + +//type Type_4<T> = Type_1_<'static,, T>; // error: expected type, found `,` + + +type Type_5_<'a> = Type_1_<'a, ()>; + + +//type Type_5<'a> = Type_1_<'a, (),,>; // error: expected type, found `,` + + +//type Type_6 = Type_5_<'a,,>; // error: expected type, found `,` + + +//type Type_7 = Box<(),,>; // error: expected type, found `,` + + +type Type_8<'a,,> = &'a (); +//~^ error: expected one of `#`, `>`, `const`, identifier, or lifetime, found `,` + + +//type Type_9<T,,> = Box<T>; // error: expected identifier, found `,` diff --git a/tests/ui/parser/issues/issue-20616-8.stderr b/tests/ui/parser/issues/issue-20616-8.stderr new file mode 100644 index 000000000..e9f37e50f --- /dev/null +++ b/tests/ui/parser/issues/issue-20616-8.stderr @@ -0,0 +1,8 @@ +error: expected one of `#`, `>`, `const`, identifier, or lifetime, found `,` + --> $DIR/issue-20616-8.rs:31:16 + | +LL | type Type_8<'a,,> = &'a (); + | ^ expected one of `#`, `>`, `const`, identifier, or lifetime + +error: aborting due to previous error + diff --git a/tests/ui/parser/issues/issue-20616-9.rs b/tests/ui/parser/issues/issue-20616-9.rs new file mode 100644 index 000000000..7f8428448 --- /dev/null +++ b/tests/ui/parser/issues/issue-20616-9.rs @@ -0,0 +1,35 @@ +// We need all these 9 issue-20616-N.rs files +// because we can only catch one parsing error at a time + +type Type_1_<'a, T> = &'a T; + + +//type Type_1<'a T> = &'a T; // error: expected `,` or `>` after lifetime name, found `T` + + +//type Type_2 = Type_1_<'static ()>; // error: expected `,` or `>` after lifetime name, found `(` + + +//type Type_3<T> = Box<T,,>; // error: expected type, found `,` + + +//type Type_4<T> = Type_1_<'static,, T>; // error: expected type, found `,` + + +type Type_5_<'a> = Type_1_<'a, ()>; + + +//type Type_5<'a> = Type_1_<'a, (),,>; // error: expected type, found `,` + + +//type Type_6 = Type_5_<'a,,>; // error: expected type, found `,` + + +//type Type_7 = Box<(),,>; // error: expected type, found `,` + + +//type Type_8<'a,,> = &'a (); // error: expected identifier, found `,` + + +type Type_9<T,,> = Box<T>; +//~^ error: expected one of `#`, `>`, `const`, identifier, or lifetime, found `,` diff --git a/tests/ui/parser/issues/issue-20616-9.stderr b/tests/ui/parser/issues/issue-20616-9.stderr new file mode 100644 index 000000000..dc309d1bc --- /dev/null +++ b/tests/ui/parser/issues/issue-20616-9.stderr @@ -0,0 +1,8 @@ +error: expected one of `#`, `>`, `const`, identifier, or lifetime, found `,` + --> $DIR/issue-20616-9.rs:34:15 + | +LL | type Type_9<T,,> = Box<T>; + | ^ expected one of `#`, `>`, `const`, identifier, or lifetime + +error: aborting due to previous error + diff --git a/tests/ui/parser/issues/issue-20711-2.rs b/tests/ui/parser/issues/issue-20711-2.rs new file mode 100644 index 000000000..168c7e761 --- /dev/null +++ b/tests/ui/parser/issues/issue-20711-2.rs @@ -0,0 +1,10 @@ +struct Foo; + +impl Foo { + fn foo() {} + + #[stable(feature = "rust1", since = "1.0.0")] + //~^ ERROR expected item after attributes +} + +fn main() {} diff --git a/tests/ui/parser/issues/issue-20711-2.stderr b/tests/ui/parser/issues/issue-20711-2.stderr new file mode 100644 index 000000000..12b18bbc5 --- /dev/null +++ b/tests/ui/parser/issues/issue-20711-2.stderr @@ -0,0 +1,14 @@ +error: expected item after attributes + --> $DIR/issue-20711-2.rs:6:5 + | +LL | impl Foo { + | - while parsing this item list starting here +... +LL | #[stable(feature = "rust1", since = "1.0.0")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | +LL | } + | - the item list ends here + +error: aborting due to previous error + diff --git a/tests/ui/parser/issues/issue-20711.rs b/tests/ui/parser/issues/issue-20711.rs new file mode 100644 index 000000000..020bb79d6 --- /dev/null +++ b/tests/ui/parser/issues/issue-20711.rs @@ -0,0 +1,8 @@ +struct Foo; + +impl Foo { + #[stable(feature = "rust1", since = "1.0.0")] + //~^ ERROR expected item after attributes +} + +fn main() {} diff --git a/tests/ui/parser/issues/issue-20711.stderr b/tests/ui/parser/issues/issue-20711.stderr new file mode 100644 index 000000000..4af4b22be --- /dev/null +++ b/tests/ui/parser/issues/issue-20711.stderr @@ -0,0 +1,13 @@ +error: expected item after attributes + --> $DIR/issue-20711.rs:4:5 + | +LL | impl Foo { + | - while parsing this item list starting here +LL | #[stable(feature = "rust1", since = "1.0.0")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | +LL | } + | - the item list ends here + +error: aborting due to previous error + diff --git a/tests/ui/parser/issues/issue-21146.rs b/tests/ui/parser/issues/issue-21146.rs new file mode 100644 index 000000000..19eaffc3e --- /dev/null +++ b/tests/ui/parser/issues/issue-21146.rs @@ -0,0 +1,3 @@ +// error-pattern: expected one of `!` or `::`, found `<eof>` +include!("auxiliary/issue-21146-inc.rs"); +fn main() {} diff --git a/tests/ui/parser/issues/issue-21146.stderr b/tests/ui/parser/issues/issue-21146.stderr new file mode 100644 index 000000000..c71fda3d6 --- /dev/null +++ b/tests/ui/parser/issues/issue-21146.stderr @@ -0,0 +1,8 @@ +error: expected one of `!` or `::`, found `<eof>` + --> $DIR/auxiliary/issue-21146-inc.rs:3:1 + | +LL | parse_error + | ^^^^^^^^^^^ expected one of `!` or `::` + +error: aborting due to previous error + diff --git a/tests/ui/parser/issues/issue-21153.rs b/tests/ui/parser/issues/issue-21153.rs new file mode 100644 index 000000000..bf5fdb1f3 --- /dev/null +++ b/tests/ui/parser/issues/issue-21153.rs @@ -0,0 +1,6 @@ +trait MyTrait<T>: Iterator { + Item = T; + //~^ ERROR expected one of `!` or `::`, found `=` +} + +fn main() {} diff --git a/tests/ui/parser/issues/issue-21153.stderr b/tests/ui/parser/issues/issue-21153.stderr new file mode 100644 index 000000000..cbfa9ded3 --- /dev/null +++ b/tests/ui/parser/issues/issue-21153.stderr @@ -0,0 +1,13 @@ +error: expected one of `!` or `::`, found `=` + --> $DIR/issue-21153.rs:2:10 + | +LL | trait MyTrait<T>: Iterator { + | - while parsing this item list starting here +LL | Item = T; + | ^ expected one of `!` or `::` +LL | +LL | } + | - the item list ends here + +error: aborting due to previous error + diff --git a/tests/ui/parser/issues/issue-21475.rs b/tests/ui/parser/issues/issue-21475.rs new file mode 100644 index 000000000..b028fcae0 --- /dev/null +++ b/tests/ui/parser/issues/issue-21475.rs @@ -0,0 +1,19 @@ +// run-pass +#![allow(unused_imports, overlapping_range_endpoints)] +// pretty-expanded FIXME #23616 + +use m::{START, END}; + +fn main() { + match 42 { + m::START..=m::END => {}, + 0..=m::END => {}, + m::START..=59 => {}, + _ => {}, + } +} + +mod m { + pub const START: u32 = 4; + pub const END: u32 = 14; +} diff --git a/tests/ui/parser/issues/issue-22647.rs b/tests/ui/parser/issues/issue-22647.rs new file mode 100644 index 000000000..a68614106 --- /dev/null +++ b/tests/ui/parser/issues/issue-22647.rs @@ -0,0 +1,15 @@ +fn main() { + let caller<F> = |f: F| //~ ERROR expected one of `:`, `;`, `=`, `@`, or `|`, found `<` + where F: Fn() -> i32 + { + let x = f(); + println!("Y {}",x); + return x; + }; + + caller(bar_handler); +} + +fn bar_handler() -> i32 { + 5 +} diff --git a/tests/ui/parser/issues/issue-22647.stderr b/tests/ui/parser/issues/issue-22647.stderr new file mode 100644 index 000000000..89b454d19 --- /dev/null +++ b/tests/ui/parser/issues/issue-22647.stderr @@ -0,0 +1,8 @@ +error: expected one of `:`, `;`, `=`, `@`, or `|`, found `<` + --> $DIR/issue-22647.rs:2:15 + | +LL | let caller<F> = |f: F| + | ^ expected one of `:`, `;`, `=`, `@`, or `|` + +error: aborting due to previous error + diff --git a/tests/ui/parser/issues/issue-22712.rs b/tests/ui/parser/issues/issue-22712.rs new file mode 100644 index 000000000..774de9c7e --- /dev/null +++ b/tests/ui/parser/issues/issue-22712.rs @@ -0,0 +1,9 @@ +struct Foo<B> { + buffer: B +} + +fn bar() { + let Foo<Vec<u8>> //~ ERROR expected one of `:`, `;`, `=`, `@`, or `|`, found `<` +} + +fn main() {} diff --git a/tests/ui/parser/issues/issue-22712.stderr b/tests/ui/parser/issues/issue-22712.stderr new file mode 100644 index 000000000..30fabac65 --- /dev/null +++ b/tests/ui/parser/issues/issue-22712.stderr @@ -0,0 +1,8 @@ +error: expected one of `:`, `;`, `=`, `@`, or `|`, found `<` + --> $DIR/issue-22712.rs:6:12 + | +LL | let Foo<Vec<u8>> + | ^ expected one of `:`, `;`, `=`, `@`, or `|` + +error: aborting due to previous error + diff --git a/tests/ui/parser/issues/issue-2354-1.rs b/tests/ui/parser/issues/issue-2354-1.rs new file mode 100644 index 000000000..996cf1bcb --- /dev/null +++ b/tests/ui/parser/issues/issue-2354-1.rs @@ -0,0 +1 @@ +static foo: isize = 2; } //~ ERROR unexpected closing delimiter: diff --git a/tests/ui/parser/issues/issue-2354-1.stderr b/tests/ui/parser/issues/issue-2354-1.stderr new file mode 100644 index 000000000..7ea0f2a98 --- /dev/null +++ b/tests/ui/parser/issues/issue-2354-1.stderr @@ -0,0 +1,8 @@ +error: unexpected closing delimiter: `}` + --> $DIR/issue-2354-1.rs:1:24 + | +LL | static foo: isize = 2; } + | ^ unexpected closing delimiter + +error: aborting due to previous error + diff --git a/tests/ui/parser/issues/issue-2354.rs b/tests/ui/parser/issues/issue-2354.rs new file mode 100644 index 000000000..c422040cb --- /dev/null +++ b/tests/ui/parser/issues/issue-2354.rs @@ -0,0 +1,15 @@ +fn foo() { //~ NOTE unclosed delimiter + match Some(10) { + //~^ NOTE this delimiter might not be properly closed... + Some(y) => { panic!(); } + None => { panic!(); } +} +//~^ NOTE ...as it matches this but it has different indentation + +fn bar() { + let mut i = 0; + while (i < 1000) {} +} + +fn main() {} +//~ ERROR this file contains an unclosed delimiter diff --git a/tests/ui/parser/issues/issue-2354.stderr b/tests/ui/parser/issues/issue-2354.stderr new file mode 100644 index 000000000..b89ed3958 --- /dev/null +++ b/tests/ui/parser/issues/issue-2354.stderr @@ -0,0 +1,16 @@ +error: this file contains an unclosed delimiter + --> $DIR/issue-2354.rs:15:52 + | +LL | fn foo() { + | - unclosed delimiter +LL | match Some(10) { + | - this delimiter might not be properly closed... +... +LL | } + | - ...as it matches this but it has different indentation +... +LL | + | ^ + +error: aborting due to previous error + diff --git a/tests/ui/parser/issues/issue-23620-invalid-escapes.rs b/tests/ui/parser/issues/issue-23620-invalid-escapes.rs new file mode 100644 index 000000000..c1355f0d6 --- /dev/null +++ b/tests/ui/parser/issues/issue-23620-invalid-escapes.rs @@ -0,0 +1,34 @@ +fn main() { + let _ = b"\u{a66e}"; + //~^ ERROR unicode escape in byte string + + let _ = b'\u{a66e}'; + //~^ ERROR unicode escape in byte string + + let _ = b'\u'; + //~^ ERROR incorrect unicode escape sequence + + let _ = b'\x5'; + //~^ ERROR numeric character escape is too short + + let _ = b'\xxy'; + //~^ ERROR invalid character in numeric character escape: `x` + + let _ = '\x5'; + //~^ ERROR numeric character escape is too short + + let _ = '\xxy'; + //~^ ERROR invalid character in numeric character escape: `x` + + let _ = b"\u{a4a4} \xf \u"; + //~^ ERROR unicode escape in byte string + //~^^ ERROR invalid character in numeric character escape: ` ` + //~^^^ ERROR incorrect unicode escape sequence + + let _ = "\xf \u"; + //~^ ERROR invalid character in numeric character escape: ` ` + //~^^ ERROR incorrect unicode escape sequence + + let _ = "\u8f"; + //~^ ERROR incorrect unicode escape sequence +} diff --git a/tests/ui/parser/issues/issue-23620-invalid-escapes.stderr b/tests/ui/parser/issues/issue-23620-invalid-escapes.stderr new file mode 100644 index 000000000..88d97c795 --- /dev/null +++ b/tests/ui/parser/issues/issue-23620-invalid-escapes.stderr @@ -0,0 +1,94 @@ +error: unicode escape in byte string + --> $DIR/issue-23620-invalid-escapes.rs:2:15 + | +LL | let _ = b"\u{a66e}"; + | ^^^^^^^^ unicode escape in byte string + | + = help: unicode escape sequences cannot be used as a byte or in a byte string + +error: unicode escape in byte string + --> $DIR/issue-23620-invalid-escapes.rs:5:15 + | +LL | let _ = b'\u{a66e}'; + | ^^^^^^^^ unicode escape in byte string + | + = help: unicode escape sequences cannot be used as a byte or in a byte string + +error: incorrect unicode escape sequence + --> $DIR/issue-23620-invalid-escapes.rs:8:15 + | +LL | let _ = b'\u'; + | ^^ incorrect unicode escape sequence + | + = help: format of unicode escape sequences is `\u{...}` + +error: numeric character escape is too short + --> $DIR/issue-23620-invalid-escapes.rs:11:15 + | +LL | let _ = b'\x5'; + | ^^^ + +error: invalid character in numeric character escape: `x` + --> $DIR/issue-23620-invalid-escapes.rs:14:17 + | +LL | let _ = b'\xxy'; + | ^ invalid character in numeric character escape + +error: numeric character escape is too short + --> $DIR/issue-23620-invalid-escapes.rs:17:14 + | +LL | let _ = '\x5'; + | ^^^ + +error: invalid character in numeric character escape: `x` + --> $DIR/issue-23620-invalid-escapes.rs:20:16 + | +LL | let _ = '\xxy'; + | ^ invalid character in numeric character escape + +error: unicode escape in byte string + --> $DIR/issue-23620-invalid-escapes.rs:23:15 + | +LL | let _ = b"\u{a4a4} \xf \u"; + | ^^^^^^^^ unicode escape in byte string + | + = help: unicode escape sequences cannot be used as a byte or in a byte string + +error: invalid character in numeric character escape: ` ` + --> $DIR/issue-23620-invalid-escapes.rs:23:27 + | +LL | let _ = b"\u{a4a4} \xf \u"; + | ^ invalid character in numeric character escape + +error: incorrect unicode escape sequence + --> $DIR/issue-23620-invalid-escapes.rs:23:28 + | +LL | let _ = b"\u{a4a4} \xf \u"; + | ^^ incorrect unicode escape sequence + | + = help: format of unicode escape sequences is `\u{...}` + +error: invalid character in numeric character escape: ` ` + --> $DIR/issue-23620-invalid-escapes.rs:28:17 + | +LL | let _ = "\xf \u"; + | ^ invalid character in numeric character escape + +error: incorrect unicode escape sequence + --> $DIR/issue-23620-invalid-escapes.rs:28:18 + | +LL | let _ = "\xf \u"; + | ^^ incorrect unicode escape sequence + | + = help: format of unicode escape sequences is `\u{...}` + +error: incorrect unicode escape sequence + --> $DIR/issue-23620-invalid-escapes.rs:32:14 + | +LL | let _ = "\u8f"; + | ^^^- + | | + | help: format of unicode escape sequences uses braces: `\u{8f}` + +error: aborting due to 13 previous errors + diff --git a/tests/ui/parser/issues/issue-24197.rs b/tests/ui/parser/issues/issue-24197.rs new file mode 100644 index 000000000..aaf513746 --- /dev/null +++ b/tests/ui/parser/issues/issue-24197.rs @@ -0,0 +1,3 @@ +fn main() { + let buf[0] = 0; //~ ERROR expected one of `:`, `;`, `=`, `@`, or `|`, found `[` +} diff --git a/tests/ui/parser/issues/issue-24197.stderr b/tests/ui/parser/issues/issue-24197.stderr new file mode 100644 index 000000000..fd7015ccd --- /dev/null +++ b/tests/ui/parser/issues/issue-24197.stderr @@ -0,0 +1,8 @@ +error: expected one of `:`, `;`, `=`, `@`, or `|`, found `[` + --> $DIR/issue-24197.rs:2:12 + | +LL | let buf[0] = 0; + | ^ expected one of `:`, `;`, `=`, `@`, or `|` + +error: aborting due to previous error + diff --git a/tests/ui/parser/issues/issue-24375.rs b/tests/ui/parser/issues/issue-24375.rs new file mode 100644 index 000000000..1d128d33e --- /dev/null +++ b/tests/ui/parser/issues/issue-24375.rs @@ -0,0 +1,9 @@ +static tmp : [&'static str; 2] = ["hello", "he"]; + +fn main() { + let z = "hello"; + match z { + tmp[0] => {} //~ ERROR expected one of `=>`, `@`, `if`, or `|`, found `[` + _ => {} + } +} diff --git a/tests/ui/parser/issues/issue-24375.stderr b/tests/ui/parser/issues/issue-24375.stderr new file mode 100644 index 000000000..7aed88768 --- /dev/null +++ b/tests/ui/parser/issues/issue-24375.stderr @@ -0,0 +1,8 @@ +error: expected one of `=>`, `@`, `if`, or `|`, found `[` + --> $DIR/issue-24375.rs:6:12 + | +LL | tmp[0] => {} + | ^ expected one of `=>`, `@`, `if`, or `|` + +error: aborting due to previous error + diff --git a/tests/ui/parser/issues/issue-24780.rs b/tests/ui/parser/issues/issue-24780.rs new file mode 100644 index 000000000..017521f57 --- /dev/null +++ b/tests/ui/parser/issues/issue-24780.rs @@ -0,0 +1,9 @@ +// Verify that '>' is not both expected and found at the same time, as it used +// to happen in #24780. For example, following should be an error: +// expected one of ..., `>`, ... found `>`. + +fn foo() -> Vec<usize>> { //~ ERROR expected one of `!`, `+`, `::`, `where`, or `{`, found `>` + Vec::new() +} + +fn main() {} diff --git a/tests/ui/parser/issues/issue-24780.stderr b/tests/ui/parser/issues/issue-24780.stderr new file mode 100644 index 000000000..d9470191b --- /dev/null +++ b/tests/ui/parser/issues/issue-24780.stderr @@ -0,0 +1,8 @@ +error: expected one of `!`, `+`, `::`, `where`, or `{`, found `>` + --> $DIR/issue-24780.rs:5:23 + | +LL | fn foo() -> Vec<usize>> { + | ^ expected one of `!`, `+`, `::`, `where`, or `{` + +error: aborting due to previous error + diff --git a/tests/ui/parser/issues/issue-27255.rs b/tests/ui/parser/issues/issue-27255.rs new file mode 100644 index 000000000..d619688e1 --- /dev/null +++ b/tests/ui/parser/issues/issue-27255.rs @@ -0,0 +1,10 @@ +trait A {} + +impl A .. {} +//~^ ERROR missing `for` in a trait impl +//~| ERROR `impl Trait for .. {}` is an obsolete syntax + +impl A usize {} +//~^ ERROR missing `for` in a trait impl + +fn main() {} diff --git a/tests/ui/parser/issues/issue-27255.stderr b/tests/ui/parser/issues/issue-27255.stderr new file mode 100644 index 000000000..391a23556 --- /dev/null +++ b/tests/ui/parser/issues/issue-27255.stderr @@ -0,0 +1,22 @@ +error: missing `for` in a trait impl + --> $DIR/issue-27255.rs:3:7 + | +LL | impl A .. {} + | ^ help: add `for` here + +error: missing `for` in a trait impl + --> $DIR/issue-27255.rs:7:7 + | +LL | impl A usize {} + | ^^^^^^ help: add `for` here + +error: `impl Trait for .. {}` is an obsolete syntax + --> $DIR/issue-27255.rs:3:1 + | +LL | impl A .. {} + | ^^^^^^^^^^^^ + | + = help: use `auto trait Trait {}` instead + +error: aborting due to 3 previous errors + diff --git a/tests/ui/parser/issues/issue-30318.fixed b/tests/ui/parser/issues/issue-30318.fixed new file mode 100644 index 000000000..71fc82172 --- /dev/null +++ b/tests/ui/parser/issues/issue-30318.fixed @@ -0,0 +1,27 @@ +// run-rustfix +#![allow(unused)] +fn foo() { } + +/// Misplaced comment... +//~^ ERROR expected outer doc comment +fn bar() { } //~ NOTE the inner doc comment doesn't annotate this function + +#[test] //~ ERROR an inner attribute is not permitted in this context +fn baz() { } //~ NOTE the inner attribute doesn't annotate this function +//~^^ NOTE inner attributes, like `#![no_std]`, annotate the item enclosing them, and are usually + +/** Misplaced comment... */ +//~^ ERROR expected outer doc comment +fn bat() { } //~ NOTE the inner doc comment doesn't annotate this function + +fn main() { } + +// Misplaced comment... +//~^ ERROR expected outer doc comment +//~| NOTE inner doc comments like this (starting with `//!` or `/*!`) can only appear before items +//~| NOTE other attributes here +/* Misplaced comment... */ +//~^ ERROR expected outer doc comment +//~| NOTE this doc comment doesn't document anything +//~| ERROR expected item after doc comment +//~| NOTE inner doc comments like this (starting with `//!` or `/*!`) can only appear before items diff --git a/tests/ui/parser/issues/issue-30318.rs b/tests/ui/parser/issues/issue-30318.rs new file mode 100644 index 000000000..465dca2ff --- /dev/null +++ b/tests/ui/parser/issues/issue-30318.rs @@ -0,0 +1,27 @@ +// run-rustfix +#![allow(unused)] +fn foo() { } + +//! Misplaced comment... +//~^ ERROR expected outer doc comment +fn bar() { } //~ NOTE the inner doc comment doesn't annotate this function + +#![test] //~ ERROR an inner attribute is not permitted in this context +fn baz() { } //~ NOTE the inner attribute doesn't annotate this function +//~^^ NOTE inner attributes, like `#![no_std]`, annotate the item enclosing them, and are usually + +/*! Misplaced comment... */ +//~^ ERROR expected outer doc comment +fn bat() { } //~ NOTE the inner doc comment doesn't annotate this function + +fn main() { } + +//! Misplaced comment... +//~^ ERROR expected outer doc comment +//~| NOTE inner doc comments like this (starting with `//!` or `/*!`) can only appear before items +//~| NOTE other attributes here +/*! Misplaced comment... */ +//~^ ERROR expected outer doc comment +//~| NOTE this doc comment doesn't document anything +//~| ERROR expected item after doc comment +//~| NOTE inner doc comments like this (starting with `//!` or `/*!`) can only appear before items diff --git a/tests/ui/parser/issues/issue-30318.stderr b/tests/ui/parser/issues/issue-30318.stderr new file mode 100644 index 000000000..c441a92ab --- /dev/null +++ b/tests/ui/parser/issues/issue-30318.stderr @@ -0,0 +1,81 @@ +error[E0753]: expected outer doc comment + --> $DIR/issue-30318.rs:5:1 + | +LL | //! Misplaced comment... + | ^^^^^^^^^^^^^^^^^^^^^^^^ +LL | +LL | fn bar() { } + | ------------ the inner doc comment doesn't annotate this function + | +help: to annotate the function, change the doc comment from inner to outer style + | +LL | /// Misplaced comment... + | ~ + +error: an inner attribute is not permitted in this context + --> $DIR/issue-30318.rs:9:1 + | +LL | #![test] + | ^^^^^^^^ +LL | fn baz() { } + | ------------ the inner attribute doesn't annotate this function + | + = note: inner attributes, like `#![no_std]`, annotate the item enclosing them, and are usually found at the beginning of source files +help: to annotate the function, change the attribute from inner to outer style + | +LL - #![test] +LL + #[test] + | + +error[E0753]: expected outer doc comment + --> $DIR/issue-30318.rs:13:1 + | +LL | /*! Misplaced comment... */ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | +LL | fn bat() { } + | ------------ the inner doc comment doesn't annotate this function + | +help: to annotate the function, change the doc comment from inner to outer style + | +LL | /** Misplaced comment... */ + | ~ + +error[E0753]: expected outer doc comment + --> $DIR/issue-30318.rs:19:1 + | +LL | //! Misplaced comment... + | ^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: inner doc comments like this (starting with `//!` or `/*!`) can only appear before items +help: you might have meant to write a regular comment + | +LL - //! Misplaced comment... +LL + // Misplaced comment... + | + +error[E0753]: expected outer doc comment + --> $DIR/issue-30318.rs:23:1 + | +LL | /*! Misplaced comment... */ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: inner doc comments like this (starting with `//!` or `/*!`) can only appear before items +help: you might have meant to write a regular comment + | +LL - /*! Misplaced comment... */ +LL + /* Misplaced comment... */ + | + +error: expected item after doc comment + --> $DIR/issue-30318.rs:23:1 + | +LL | //! Misplaced comment... + | ------------------------ other attributes here +... +LL | /*! Misplaced comment... */ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ this doc comment doesn't document anything + +error: aborting due to 6 previous errors + +For more information about this error, try `rustc --explain E0753`. diff --git a/tests/ui/parser/issues/issue-3036.fixed b/tests/ui/parser/issues/issue-3036.fixed new file mode 100644 index 000000000..e5d5622e6 --- /dev/null +++ b/tests/ui/parser/issues/issue-3036.fixed @@ -0,0 +1,7 @@ +// run-rustfix + +// Testing that semicolon tokens are printed correctly in errors + +fn main() { + let _x = 3; //~ ERROR: expected `;` +} diff --git a/tests/ui/parser/issues/issue-3036.rs b/tests/ui/parser/issues/issue-3036.rs new file mode 100644 index 000000000..2f76fb99b --- /dev/null +++ b/tests/ui/parser/issues/issue-3036.rs @@ -0,0 +1,7 @@ +// run-rustfix + +// Testing that semicolon tokens are printed correctly in errors + +fn main() { + let _x = 3 //~ ERROR: expected `;` +} diff --git a/tests/ui/parser/issues/issue-3036.stderr b/tests/ui/parser/issues/issue-3036.stderr new file mode 100644 index 000000000..e02223931 --- /dev/null +++ b/tests/ui/parser/issues/issue-3036.stderr @@ -0,0 +1,10 @@ +error: expected `;`, found `}` + --> $DIR/issue-3036.rs:6:15 + | +LL | let _x = 3 + | ^ help: add `;` here +LL | } + | - unexpected token + +error: aborting due to previous error + diff --git a/tests/ui/parser/issues/issue-31804.rs b/tests/ui/parser/issues/issue-31804.rs new file mode 100644 index 000000000..d056b77cf --- /dev/null +++ b/tests/ui/parser/issues/issue-31804.rs @@ -0,0 +1,6 @@ +// Test that error recovery in the parser to an EOF does not give an infinite +// spew of errors. + +fn main() { + let +} //~ ERROR expected pattern, found `}` diff --git a/tests/ui/parser/issues/issue-31804.stderr b/tests/ui/parser/issues/issue-31804.stderr new file mode 100644 index 000000000..76e68b0b3 --- /dev/null +++ b/tests/ui/parser/issues/issue-31804.stderr @@ -0,0 +1,8 @@ +error: expected pattern, found `}` + --> $DIR/issue-31804.rs:6:1 + | +LL | } + | ^ expected pattern + +error: aborting due to previous error + diff --git a/tests/ui/parser/issues/issue-32214.rs b/tests/ui/parser/issues/issue-32214.rs new file mode 100644 index 000000000..1379eeb58 --- /dev/null +++ b/tests/ui/parser/issues/issue-32214.rs @@ -0,0 +1,6 @@ +trait Trait<T> { type Item; } + +pub fn test<W, I: Trait<Item=(), W> >() {} +//~^ ERROR generic arguments must come before the first constraint + +fn main() { } diff --git a/tests/ui/parser/issues/issue-32214.stderr b/tests/ui/parser/issues/issue-32214.stderr new file mode 100644 index 000000000..d0a9b5299 --- /dev/null +++ b/tests/ui/parser/issues/issue-32214.stderr @@ -0,0 +1,15 @@ +error: generic arguments must come before the first constraint + --> $DIR/issue-32214.rs:3:34 + | +LL | pub fn test<W, I: Trait<Item=(), W> >() {} + | ------- ^ generic argument + | | + | constraint + | +help: move the constraint after the generic argument + | +LL | pub fn test<W, I: Trait<W, Item = ()> >() {} + | ~~~~~~~~~~~~~~ + +error: aborting due to previous error + diff --git a/tests/ui/parser/issues/issue-32446.rs b/tests/ui/parser/issues/issue-32446.rs new file mode 100644 index 000000000..53e519a72 --- /dev/null +++ b/tests/ui/parser/issues/issue-32446.rs @@ -0,0 +1,4 @@ +fn main() {} + +// This used to end up in an infite loop trying to bump past EOF. +trait T { ... } //~ ERROR diff --git a/tests/ui/parser/issues/issue-32446.stderr b/tests/ui/parser/issues/issue-32446.stderr new file mode 100644 index 000000000..7515369aa --- /dev/null +++ b/tests/ui/parser/issues/issue-32446.stderr @@ -0,0 +1,11 @@ +error: non-item in item list + --> $DIR/issue-32446.rs:4:11 + | +LL | trait T { ... } + | - ^^^ - item list ends here + | | | + | | non-item starts here + | item list starts here + +error: aborting due to previous error + diff --git a/tests/ui/parser/issues/issue-32501.rs b/tests/ui/parser/issues/issue-32501.rs new file mode 100644 index 000000000..500242030 --- /dev/null +++ b/tests/ui/parser/issues/issue-32501.rs @@ -0,0 +1,9 @@ +fn main() { + let a = 0; + let _b = 0; + let _ = 0; + let mut b = 0; + let mut _b = 0; + let mut _ = 0; + //~^ ERROR `mut` must be followed by a named binding +} diff --git a/tests/ui/parser/issues/issue-32501.stderr b/tests/ui/parser/issues/issue-32501.stderr new file mode 100644 index 000000000..d53302449 --- /dev/null +++ b/tests/ui/parser/issues/issue-32501.stderr @@ -0,0 +1,10 @@ +error: `mut` must be followed by a named binding + --> $DIR/issue-32501.rs:7:9 + | +LL | let mut _ = 0; + | ^^^^^ help: remove the `mut` prefix: `_` + | + = note: `mut` may be followed by `variable` and `variable @ pattern` + +error: aborting due to previous error + diff --git a/tests/ui/parser/issues/issue-32505.rs b/tests/ui/parser/issues/issue-32505.rs new file mode 100644 index 000000000..f31c00e5c --- /dev/null +++ b/tests/ui/parser/issues/issue-32505.rs @@ -0,0 +1,5 @@ +pub fn test() { + foo(|_|) //~ ERROR expected expression, found `)` +} + +fn main() { } diff --git a/tests/ui/parser/issues/issue-32505.stderr b/tests/ui/parser/issues/issue-32505.stderr new file mode 100644 index 000000000..cdd779a93 --- /dev/null +++ b/tests/ui/parser/issues/issue-32505.stderr @@ -0,0 +1,8 @@ +error: expected expression, found `)` + --> $DIR/issue-32505.rs:2:12 + | +LL | foo(|_|) + | ^ expected expression + +error: aborting due to previous error + diff --git a/tests/ui/parser/issues/issue-33262.rs b/tests/ui/parser/issues/issue-33262.rs new file mode 100644 index 000000000..3a612f95c --- /dev/null +++ b/tests/ui/parser/issues/issue-33262.rs @@ -0,0 +1,6 @@ +// Issue #33262 + +pub fn main() { + for i in 0..a as { } + //~^ ERROR expected type, found `{` +} diff --git a/tests/ui/parser/issues/issue-33262.stderr b/tests/ui/parser/issues/issue-33262.stderr new file mode 100644 index 000000000..2aff32839 --- /dev/null +++ b/tests/ui/parser/issues/issue-33262.stderr @@ -0,0 +1,8 @@ +error: expected type, found `{` + --> $DIR/issue-33262.rs:4:22 + | +LL | for i in 0..a as { } + | ^ expected type + +error: aborting due to previous error + diff --git a/tests/ui/parser/issues/issue-33413.rs b/tests/ui/parser/issues/issue-33413.rs new file mode 100644 index 000000000..7291732ce --- /dev/null +++ b/tests/ui/parser/issues/issue-33413.rs @@ -0,0 +1,9 @@ +struct S; + +impl S { + fn f(*, a: u8) -> u8 {} + //~^ ERROR expected parameter name, found `*` + //~| ERROR mismatched types +} + +fn main() {} diff --git a/tests/ui/parser/issues/issue-33413.stderr b/tests/ui/parser/issues/issue-33413.stderr new file mode 100644 index 000000000..b7250f3b0 --- /dev/null +++ b/tests/ui/parser/issues/issue-33413.stderr @@ -0,0 +1,22 @@ +error: expected parameter name, found `*` + --> $DIR/issue-33413.rs:4:10 + | +LL | fn f(*, a: u8) -> u8 {} + | ^ expected parameter name + +error[E0308]: mismatched types + --> $DIR/issue-33413.rs:4:23 + | +LL | fn f(*, a: u8) -> u8 {} + | - ^^ expected `u8`, found `()` + | | + | implicitly returns `()` as its body has no tail or `return` expression + | +help: consider returning the local binding `a` + | +LL | fn f(*, a: u8) -> u8 { a } + | + + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/parser/issues/issue-33418.fixed b/tests/ui/parser/issues/issue-33418.fixed new file mode 100644 index 000000000..ed885ae14 --- /dev/null +++ b/tests/ui/parser/issues/issue-33418.fixed @@ -0,0 +1,19 @@ +// run-rustfix + +trait Tr {} +//~^ ERROR negative bounds are not supported +trait Tr2: SuperA {} +//~^ ERROR negative bounds are not supported +trait Tr3: SuperB {} +//~^ ERROR negative bounds are not supported +trait Tr4: SuperB + SuperD {} +//~^ ERROR negative bounds are not supported +trait Tr5 {} +//~^ ERROR negative bounds are not supported + +trait SuperA {} +trait SuperB {} +trait SuperC {} +trait SuperD {} + +fn main() {} diff --git a/tests/ui/parser/issues/issue-33418.rs b/tests/ui/parser/issues/issue-33418.rs new file mode 100644 index 000000000..9934284ab --- /dev/null +++ b/tests/ui/parser/issues/issue-33418.rs @@ -0,0 +1,21 @@ +// run-rustfix + +trait Tr: !SuperA {} +//~^ ERROR negative bounds are not supported +trait Tr2: SuperA + !SuperB {} +//~^ ERROR negative bounds are not supported +trait Tr3: !SuperA + SuperB {} +//~^ ERROR negative bounds are not supported +trait Tr4: !SuperA + SuperB + + !SuperC + SuperD {} +//~^ ERROR negative bounds are not supported +trait Tr5: !SuperA + + !SuperB {} +//~^ ERROR negative bounds are not supported + +trait SuperA {} +trait SuperB {} +trait SuperC {} +trait SuperD {} + +fn main() {} diff --git a/tests/ui/parser/issues/issue-33418.stderr b/tests/ui/parser/issues/issue-33418.stderr new file mode 100644 index 000000000..9a8733e89 --- /dev/null +++ b/tests/ui/parser/issues/issue-33418.stderr @@ -0,0 +1,36 @@ +error: negative bounds are not supported + --> $DIR/issue-33418.rs:3:9 + | +LL | trait Tr: !SuperA {} + | ^^^^^^^^^ negative bounds are not supported + +error: negative bounds are not supported + --> $DIR/issue-33418.rs:5:19 + | +LL | trait Tr2: SuperA + !SuperB {} + | ^^^^^^^^^ negative bounds are not supported + +error: negative bounds are not supported + --> $DIR/issue-33418.rs:7:10 + | +LL | trait Tr3: !SuperA + SuperB {} + | ^^^^^^^^^ negative bounds are not supported + +error: negative bounds are not supported + --> $DIR/issue-33418.rs:9:10 + | +LL | trait Tr4: !SuperA + SuperB + | ^^^^^^^^^ +LL | + !SuperC + SuperD {} + | ^^^^^^^^^ negative bounds are not supported + +error: negative bounds are not supported + --> $DIR/issue-33418.rs:12:10 + | +LL | trait Tr5: !SuperA + | ^^^^^^^^^ +LL | + !SuperB {} + | ^^^^^^^^^ negative bounds are not supported + +error: aborting due to 5 previous errors + diff --git a/tests/ui/parser/issues/issue-33455.rs b/tests/ui/parser/issues/issue-33455.rs new file mode 100644 index 000000000..6dff63f5c --- /dev/null +++ b/tests/ui/parser/issues/issue-33455.rs @@ -0,0 +1 @@ +use foo.bar; //~ ERROR expected one of `::`, `;`, or `as`, found `.` diff --git a/tests/ui/parser/issues/issue-33455.stderr b/tests/ui/parser/issues/issue-33455.stderr new file mode 100644 index 000000000..c535ef23b --- /dev/null +++ b/tests/ui/parser/issues/issue-33455.stderr @@ -0,0 +1,8 @@ +error: expected one of `::`, `;`, or `as`, found `.` + --> $DIR/issue-33455.rs:1:8 + | +LL | use foo.bar; + | ^ expected one of `::`, `;`, or `as` + +error: aborting due to previous error + diff --git a/tests/ui/parser/issues/issue-34222-1.rs b/tests/ui/parser/issues/issue-34222-1.rs new file mode 100644 index 000000000..d36dddc97 --- /dev/null +++ b/tests/ui/parser/issues/issue-34222-1.rs @@ -0,0 +1,3 @@ +fn main() { + /// comment //~ ERROR found a documentation comment that doesn't document anything +} diff --git a/tests/ui/parser/issues/issue-34222-1.stderr b/tests/ui/parser/issues/issue-34222-1.stderr new file mode 100644 index 000000000..b451484ba --- /dev/null +++ b/tests/ui/parser/issues/issue-34222-1.stderr @@ -0,0 +1,11 @@ +error[E0585]: found a documentation comment that doesn't document anything + --> $DIR/issue-34222-1.rs:2:5 + | +LL | /// comment + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: doc comments must come before what they document, if a comment was intended use `//` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0585`. diff --git a/tests/ui/parser/issues/issue-34255-1.rs b/tests/ui/parser/issues/issue-34255-1.rs new file mode 100644 index 000000000..c70cd8b50 --- /dev/null +++ b/tests/ui/parser/issues/issue-34255-1.rs @@ -0,0 +1,10 @@ +enum Test { + Drill { + field: i32, + } +} + +fn main() { + Test::Drill(field: 42); + //~^ ERROR invalid `struct` delimiters or `fn` call arguments +} diff --git a/tests/ui/parser/issues/issue-34255-1.stderr b/tests/ui/parser/issues/issue-34255-1.stderr new file mode 100644 index 000000000..0e2b0d62e --- /dev/null +++ b/tests/ui/parser/issues/issue-34255-1.stderr @@ -0,0 +1,18 @@ +error: invalid `struct` delimiters or `fn` call arguments + --> $DIR/issue-34255-1.rs:8:5 + | +LL | Test::Drill(field: 42); + | ^^^^^^^^^^^^^^^^^^^^^^ + | +help: if `Test::Drill` is a struct, use braces as delimiters + | +LL | Test::Drill { field: 42 }; + | ~ ~ +help: if `Test::Drill` is a function, use the arguments directly + | +LL - Test::Drill(field: 42); +LL + Test::Drill(42); + | + +error: aborting due to previous error + diff --git a/tests/ui/parser/issues/issue-35813-postfix-after-cast.rs b/tests/ui/parser/issues/issue-35813-postfix-after-cast.rs new file mode 100644 index 000000000..7bd4b3a16 --- /dev/null +++ b/tests/ui/parser/issues/issue-35813-postfix-after-cast.rs @@ -0,0 +1,171 @@ +// edition:2018 +#![crate_type = "lib"] +#![feature(type_ascription)] +use std::future::Future; +use std::pin::Pin; + +// This tests the parser for "x as Y[z]". It errors, but we want to give useful +// errors and parse such that further code gives useful errors. +pub fn index_after_as_cast() { + vec![1, 2, 3] as Vec<i32>[0]; + //~^ ERROR: cast cannot be followed by indexing + vec![1, 2, 3]: Vec<i32>[0]; + //~^ ERROR: type ascription cannot be followed by indexing +} + +pub fn index_after_cast_to_index() { + (&[0]) as &[i32][0]; + //~^ ERROR: cast cannot be followed by indexing + (&[0i32]): &[i32; 1][0]; + //~^ ERROR: type ascription cannot be followed by indexing +} + +pub fn cast_after_cast() { + if 5u64 as i32 as u16 == 0u16 { + + } + if 5u64: u64: u64 == 0u64 { + + } + let _ = 5u64: u64: u64 as u8 as i8 == 9i8; + let _ = 0i32: i32: i32; + let _ = 0 as i32: i32; + let _ = 0i32: i32 as i32; + let _ = 0 as i32 as i32; + let _ = 0i32: i32: i32 as u32 as i32; +} + +pub fn cast_cast_method_call() { + let _ = 0i32: i32: i32.count_ones(); + //~^ ERROR: type ascription cannot be followed by a method call + let _ = 0 as i32: i32.count_ones(); + //~^ ERROR: type ascription cannot be followed by a method call + let _ = 0i32: i32 as i32.count_ones(); + //~^ ERROR: cast cannot be followed by a method call + let _ = 0 as i32 as i32.count_ones(); + //~^ ERROR: cast cannot be followed by a method call + let _ = 0i32: i32: i32 as u32 as i32.count_ones(); + //~^ ERROR: cast cannot be followed by a method call + let _ = 0i32: i32.count_ones(): u32; + //~^ ERROR: type ascription cannot be followed by a method call + let _ = 0 as i32.count_ones(): u32; + //~^ ERROR: cast cannot be followed by a method call + let _ = 0i32: i32.count_ones() as u32; + //~^ ERROR: type ascription cannot be followed by a method call + let _ = 0 as i32.count_ones() as u32; + //~^ ERROR: cast cannot be followed by a method call + let _ = 0i32: i32: i32.count_ones() as u32 as i32; + //~^ ERROR: type ascription cannot be followed by a method call +} + +pub fn multiline_error() { + let _ = 0 + as i32 + .count_ones(); + //~^^^ ERROR: cast cannot be followed by a method call +} + +// this tests that the precedence for `!x as Y.Z` is still what we expect +pub fn precedence() { + let x: i32 = &vec![1, 2, 3] as &Vec<i32>[0]; + //~^ ERROR: cast cannot be followed by indexing +} + +pub fn method_calls() { + 0 as i32.max(0); + //~^ ERROR: cast cannot be followed by a method call + 0: i32.max(0); + //~^ ERROR: type ascription cannot be followed by a method call +} + +pub fn complex() { + let _ = format!( + "{} and {}", + if true { 33 } else { 44 } as i32.max(0), + //~^ ERROR: cast cannot be followed by a method call + if true { 33 } else { 44 }: i32.max(0) + //~^ ERROR: type ascription cannot be followed by a method call + ); +} + +pub fn in_condition() { + if 5u64 as i32.max(0) == 0 { + //~^ ERROR: cast cannot be followed by a method call + } + if 5u64: u64.max(0) == 0 { + //~^ ERROR: type ascription cannot be followed by a method call + } +} + +pub fn inside_block() { + let _ = if true { + 5u64 as u32.max(0) == 0 + //~^ ERROR: cast cannot be followed by a method call + } else { false }; + let _ = if true { + 5u64: u64.max(0) == 0 + //~^ ERROR: type ascription cannot be followed by a method call + } else { false }; +} + +static bar: &[i32] = &(&[1,2,3] as &[i32][0..1]); +//~^ ERROR: cast cannot be followed by indexing + +static bar2: &[i32] = &(&[1i32,2,3]: &[i32; 3][0..1]); +//~^ ERROR: type ascription cannot be followed by indexing + + +pub fn cast_then_try() -> Result<u64,u64> { + Err(0u64) as Result<u64,u64>?; + //~^ ERROR: cast cannot be followed by `?` + Err(0u64): Result<u64,u64>?; + //~^ ERROR: type ascription cannot be followed by `?` + Ok(1) +} + + +pub fn cast_then_call() { + type F = fn(u8); + // type ascription won't actually do [unique drop fn type] -> fn(u8) casts. + let drop_ptr = drop as fn(u8); + drop as F(); + //~^ ERROR: parenthesized type parameters may only be used with a `Fn` trait [E0214] + drop_ptr: F(); + //~^ ERROR: parenthesized type parameters may only be used with a `Fn` trait [E0214] +} + +pub fn cast_to_fn_should_work() { + let drop_ptr = drop as fn(u8); + drop as fn(u8); + drop_ptr: fn(u8); +} + +pub fn parens_after_cast_error() { + let drop_ptr = drop as fn(u8); + drop as fn(u8)(0); + //~^ ERROR: cast cannot be followed by a function call + drop_ptr: fn(u8)(0); + //~^ ERROR: type ascription cannot be followed by a function call +} + +pub async fn cast_then_await() { + Box::pin(noop()) as Pin<Box<dyn Future<Output = ()>>>.await; + //~^ ERROR: cast cannot be followed by `.await` + + Box::pin(noop()): Pin<Box<_>>.await; + //~^ ERROR: type ascription cannot be followed by `.await` +} + +pub async fn noop() {} + +#[derive(Default)] +pub struct Foo { + pub bar: u32, +} + +pub fn struct_field() { + Foo::default() as Foo.bar; + //~^ ERROR: cannot be followed by a field access + Foo::default(): Foo.bar; + //~^ ERROR: type ascription cannot be followed by a field access +} diff --git a/tests/ui/parser/issues/issue-35813-postfix-after-cast.stderr b/tests/ui/parser/issues/issue-35813-postfix-after-cast.stderr new file mode 100644 index 000000000..0c328bde2 --- /dev/null +++ b/tests/ui/parser/issues/issue-35813-postfix-after-cast.stderr @@ -0,0 +1,472 @@ +error: cast cannot be followed by indexing + --> $DIR/issue-35813-postfix-after-cast.rs:10:5 + | +LL | vec![1, 2, 3] as Vec<i32>[0]; + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: try surrounding the expression in parentheses + | +LL | (vec![1, 2, 3] as Vec<i32>)[0]; + | + + + +error: type ascription cannot be followed by indexing + --> $DIR/issue-35813-postfix-after-cast.rs:12:5 + | +LL | vec![1, 2, 3]: Vec<i32>[0]; + | ^^^^^^^^^^^^^^^^^^^^^^^ + | +help: try surrounding the expression in parentheses + | +LL | (vec![1, 2, 3]: Vec<i32>)[0]; + | + + +help: alternatively, remove the type ascription + | +LL - vec![1, 2, 3]: Vec<i32>[0]; +LL + vec![1, 2, 3][0]; + | + +error: cast cannot be followed by indexing + --> $DIR/issue-35813-postfix-after-cast.rs:17:5 + | +LL | (&[0]) as &[i32][0]; + | ^^^^^^^^^^^^^^^^ + | +help: try surrounding the expression in parentheses + | +LL | ((&[0]) as &[i32])[0]; + | + + + +error: type ascription cannot be followed by indexing + --> $DIR/issue-35813-postfix-after-cast.rs:19:5 + | +LL | (&[0i32]): &[i32; 1][0]; + | ^^^^^^^^^^^^^^^^^^^^ + | +help: try surrounding the expression in parentheses + | +LL | ((&[0i32]): &[i32; 1])[0]; + | + + +help: alternatively, remove the type ascription + | +LL - (&[0i32]): &[i32; 1][0]; +LL + (&[0i32])[0]; + | + +error: type ascription cannot be followed by a method call + --> $DIR/issue-35813-postfix-after-cast.rs:39:13 + | +LL | let _ = 0i32: i32: i32.count_ones(); + | ^^^^^^^^^^^^^^ + | +help: try surrounding the expression in parentheses + | +LL | let _ = (0i32: i32: i32).count_ones(); + | + + +help: alternatively, remove the type ascription + | +LL - let _ = 0i32: i32: i32.count_ones(); +LL + let _ = 0i32: i32.count_ones(); + | + +error: type ascription cannot be followed by a method call + --> $DIR/issue-35813-postfix-after-cast.rs:41:13 + | +LL | let _ = 0 as i32: i32.count_ones(); + | ^^^^^^^^^^^^^ + | +help: try surrounding the expression in parentheses + | +LL | let _ = (0 as i32: i32).count_ones(); + | + + +help: alternatively, remove the type ascription + | +LL - let _ = 0 as i32: i32.count_ones(); +LL + let _ = 0 as i32.count_ones(); + | + +error: cast cannot be followed by a method call + --> $DIR/issue-35813-postfix-after-cast.rs:43:13 + | +LL | let _ = 0i32: i32 as i32.count_ones(); + | ^^^^^^^^^^^^^^^^ + | +help: try surrounding the expression in parentheses + | +LL | let _ = (0i32: i32 as i32).count_ones(); + | + + + +error: cast cannot be followed by a method call + --> $DIR/issue-35813-postfix-after-cast.rs:45:13 + | +LL | let _ = 0 as i32 as i32.count_ones(); + | ^^^^^^^^^^^^^^^ + | +help: try surrounding the expression in parentheses + | +LL | let _ = (0 as i32 as i32).count_ones(); + | + + + +error: cast cannot be followed by a method call + --> $DIR/issue-35813-postfix-after-cast.rs:47:13 + | +LL | let _ = 0i32: i32: i32 as u32 as i32.count_ones(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: try surrounding the expression in parentheses + | +LL | let _ = (0i32: i32: i32 as u32 as i32).count_ones(); + | + + + +error: type ascription cannot be followed by a method call + --> $DIR/issue-35813-postfix-after-cast.rs:49:13 + | +LL | let _ = 0i32: i32.count_ones(): u32; + | ^^^^^^^^^ + | +help: try surrounding the expression in parentheses + | +LL | let _ = (0i32: i32).count_ones(): u32; + | + + +help: alternatively, remove the type ascription + | +LL - let _ = 0i32: i32.count_ones(): u32; +LL + let _ = 0i32.count_ones(): u32; + | + +error: cast cannot be followed by a method call + --> $DIR/issue-35813-postfix-after-cast.rs:51:13 + | +LL | let _ = 0 as i32.count_ones(): u32; + | ^^^^^^^^ + | +help: try surrounding the expression in parentheses + | +LL | let _ = (0 as i32).count_ones(): u32; + | + + + +error: type ascription cannot be followed by a method call + --> $DIR/issue-35813-postfix-after-cast.rs:53:13 + | +LL | let _ = 0i32: i32.count_ones() as u32; + | ^^^^^^^^^ + | +help: try surrounding the expression in parentheses + | +LL | let _ = (0i32: i32).count_ones() as u32; + | + + +help: alternatively, remove the type ascription + | +LL - let _ = 0i32: i32.count_ones() as u32; +LL + let _ = 0i32.count_ones() as u32; + | + +error: cast cannot be followed by a method call + --> $DIR/issue-35813-postfix-after-cast.rs:55:13 + | +LL | let _ = 0 as i32.count_ones() as u32; + | ^^^^^^^^ + | +help: try surrounding the expression in parentheses + | +LL | let _ = (0 as i32).count_ones() as u32; + | + + + +error: type ascription cannot be followed by a method call + --> $DIR/issue-35813-postfix-after-cast.rs:57:13 + | +LL | let _ = 0i32: i32: i32.count_ones() as u32 as i32; + | ^^^^^^^^^^^^^^ + | +help: try surrounding the expression in parentheses + | +LL | let _ = (0i32: i32: i32).count_ones() as u32 as i32; + | + + +help: alternatively, remove the type ascription + | +LL - let _ = 0i32: i32: i32.count_ones() as u32 as i32; +LL + let _ = 0i32: i32.count_ones() as u32 as i32; + | + +error: cast cannot be followed by a method call + --> $DIR/issue-35813-postfix-after-cast.rs:62:13 + | +LL | let _ = 0 + | _____________^ +LL | | as i32 + | |______________^ + | +help: try surrounding the expression in parentheses + | +LL ~ let _ = (0 +LL ~ as i32) + | + +error: cast cannot be followed by indexing + --> $DIR/issue-35813-postfix-after-cast.rs:70:18 + | +LL | let x: i32 = &vec![1, 2, 3] as &Vec<i32>[0]; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: try surrounding the expression in parentheses + | +LL | let x: i32 = (&vec![1, 2, 3] as &Vec<i32>)[0]; + | + + + +error: cast cannot be followed by a method call + --> $DIR/issue-35813-postfix-after-cast.rs:75:5 + | +LL | 0 as i32.max(0); + | ^^^^^^^^ + | +help: try surrounding the expression in parentheses + | +LL | (0 as i32).max(0); + | + + + +error: type ascription cannot be followed by a method call + --> $DIR/issue-35813-postfix-after-cast.rs:77:5 + | +LL | 0: i32.max(0); + | ^^^^^^ + | +help: try surrounding the expression in parentheses + | +LL | (0: i32).max(0); + | + + +help: alternatively, remove the type ascription + | +LL - 0: i32.max(0); +LL + 0.max(0); + | + +error: cast cannot be followed by a method call + --> $DIR/issue-35813-postfix-after-cast.rs:92:8 + | +LL | if 5u64 as i32.max(0) == 0 { + | ^^^^^^^^^^^ + | +help: try surrounding the expression in parentheses + | +LL | if (5u64 as i32).max(0) == 0 { + | + + + +error: type ascription cannot be followed by a method call + --> $DIR/issue-35813-postfix-after-cast.rs:95:8 + | +LL | if 5u64: u64.max(0) == 0 { + | ^^^^^^^^^ + | +help: try surrounding the expression in parentheses + | +LL | if (5u64: u64).max(0) == 0 { + | + + +help: alternatively, remove the type ascription + | +LL - if 5u64: u64.max(0) == 0 { +LL + if 5u64.max(0) == 0 { + | + +error: cast cannot be followed by a method call + --> $DIR/issue-35813-postfix-after-cast.rs:102:9 + | +LL | 5u64 as u32.max(0) == 0 + | ^^^^^^^^^^^ + | +help: try surrounding the expression in parentheses + | +LL | (5u64 as u32).max(0) == 0 + | + + + +error: type ascription cannot be followed by a method call + --> $DIR/issue-35813-postfix-after-cast.rs:106:9 + | +LL | 5u64: u64.max(0) == 0 + | ^^^^^^^^^ + | +help: try surrounding the expression in parentheses + | +LL | (5u64: u64).max(0) == 0 + | + + +help: alternatively, remove the type ascription + | +LL - 5u64: u64.max(0) == 0 +LL + 5u64.max(0) == 0 + | + +error: cast cannot be followed by indexing + --> $DIR/issue-35813-postfix-after-cast.rs:111:24 + | +LL | static bar: &[i32] = &(&[1,2,3] as &[i32][0..1]); + | ^^^^^^^^^^^^^^^^^^ + | +help: try surrounding the expression in parentheses + | +LL | static bar: &[i32] = &((&[1,2,3] as &[i32])[0..1]); + | + + + +error: type ascription cannot be followed by indexing + --> $DIR/issue-35813-postfix-after-cast.rs:114:25 + | +LL | static bar2: &[i32] = &(&[1i32,2,3]: &[i32; 3][0..1]); + | ^^^^^^^^^^^^^^^^^^^^^^ + | +help: try surrounding the expression in parentheses + | +LL | static bar2: &[i32] = &((&[1i32,2,3]: &[i32; 3])[0..1]); + | + + +help: alternatively, remove the type ascription + | +LL - static bar2: &[i32] = &(&[1i32,2,3]: &[i32; 3][0..1]); +LL + static bar2: &[i32] = &(&[1i32,2,3][0..1]); + | + +error: cast cannot be followed by `?` + --> $DIR/issue-35813-postfix-after-cast.rs:119:5 + | +LL | Err(0u64) as Result<u64,u64>?; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: try surrounding the expression in parentheses + | +LL | (Err(0u64) as Result<u64,u64>)?; + | + + + +error: type ascription cannot be followed by `?` + --> $DIR/issue-35813-postfix-after-cast.rs:121:5 + | +LL | Err(0u64): Result<u64,u64>?; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: try surrounding the expression in parentheses + | +LL | (Err(0u64): Result<u64,u64>)?; + | + + +help: alternatively, remove the type ascription + | +LL - Err(0u64): Result<u64,u64>?; +LL + Err(0u64)?; + | + +error: cast cannot be followed by a function call + --> $DIR/issue-35813-postfix-after-cast.rs:145:5 + | +LL | drop as fn(u8)(0); + | ^^^^^^^^^^^^^^ + | +help: try surrounding the expression in parentheses + | +LL | (drop as fn(u8))(0); + | + + + +error: type ascription cannot be followed by a function call + --> $DIR/issue-35813-postfix-after-cast.rs:147:5 + | +LL | drop_ptr: fn(u8)(0); + | ^^^^^^^^^^^^^^^^ + | +help: try surrounding the expression in parentheses + | +LL | (drop_ptr: fn(u8))(0); + | + + +help: alternatively, remove the type ascription + | +LL - drop_ptr: fn(u8)(0); +LL + drop_ptr(0); + | + +error: cast cannot be followed by `.await` + --> $DIR/issue-35813-postfix-after-cast.rs:152:5 + | +LL | Box::pin(noop()) as Pin<Box<dyn Future<Output = ()>>>.await; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: try surrounding the expression in parentheses + | +LL | (Box::pin(noop()) as Pin<Box<dyn Future<Output = ()>>>).await; + | + + + +error: type ascription cannot be followed by `.await` + --> $DIR/issue-35813-postfix-after-cast.rs:155:5 + | +LL | Box::pin(noop()): Pin<Box<_>>.await; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: try surrounding the expression in parentheses + | +LL | (Box::pin(noop()): Pin<Box<_>>).await; + | + + +help: alternatively, remove the type ascription + | +LL - Box::pin(noop()): Pin<Box<_>>.await; +LL + Box::pin(noop()).await; + | + +error: cast cannot be followed by a field access + --> $DIR/issue-35813-postfix-after-cast.rs:167:5 + | +LL | Foo::default() as Foo.bar; + | ^^^^^^^^^^^^^^^^^^^^^ + | +help: try surrounding the expression in parentheses + | +LL | (Foo::default() as Foo).bar; + | + + + +error: type ascription cannot be followed by a field access + --> $DIR/issue-35813-postfix-after-cast.rs:169:5 + | +LL | Foo::default(): Foo.bar; + | ^^^^^^^^^^^^^^^^^^^ + | +help: try surrounding the expression in parentheses + | +LL | (Foo::default(): Foo).bar; + | + + +help: alternatively, remove the type ascription + | +LL - Foo::default(): Foo.bar; +LL + Foo::default().bar; + | + +error: cast cannot be followed by a method call + --> $DIR/issue-35813-postfix-after-cast.rs:84:9 + | +LL | if true { 33 } else { 44 } as i32.max(0), + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: try surrounding the expression in parentheses + | +LL | (if true { 33 } else { 44 } as i32).max(0), + | + + + +error: type ascription cannot be followed by a method call + --> $DIR/issue-35813-postfix-after-cast.rs:86:9 + | +LL | if true { 33 } else { 44 }: i32.max(0) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: try surrounding the expression in parentheses + | +LL | (if true { 33 } else { 44 }: i32).max(0) + | + + +help: alternatively, remove the type ascription + | +LL - if true { 33 } else { 44 }: i32.max(0) +LL + if true { 33 } else { 44 }.max(0) + | + +error[E0214]: parenthesized type parameters may only be used with a `Fn` trait + --> $DIR/issue-35813-postfix-after-cast.rs:131:13 + | +LL | drop as F(); + | ^^^ only `Fn` traits may use parentheses + +error[E0214]: parenthesized type parameters may only be used with a `Fn` trait + --> $DIR/issue-35813-postfix-after-cast.rs:133:15 + | +LL | drop_ptr: F(); + | ^^^ only `Fn` traits may use parentheses + +error: aborting due to 36 previous errors + +For more information about this error, try `rustc --explain E0214`. diff --git a/tests/ui/parser/issues/issue-41155.rs b/tests/ui/parser/issues/issue-41155.rs new file mode 100644 index 000000000..5a7488e6f --- /dev/null +++ b/tests/ui/parser/issues/issue-41155.rs @@ -0,0 +1,7 @@ +struct S; + +impl S { + pub //~ ERROR visibility `pub` is not followed by an item +} //~ ERROR non-item in item list + +fn main() {} diff --git a/tests/ui/parser/issues/issue-41155.stderr b/tests/ui/parser/issues/issue-41155.stderr new file mode 100644 index 000000000..8491afae2 --- /dev/null +++ b/tests/ui/parser/issues/issue-41155.stderr @@ -0,0 +1,22 @@ +error: visibility `pub` is not followed by an item + --> $DIR/issue-41155.rs:4:5 + | +LL | pub + | ^^^ the visibility + | + = help: you likely meant to define an item, e.g., `pub fn foo() {}` + +error: non-item in item list + --> $DIR/issue-41155.rs:5:1 + | +LL | impl S { + | - item list starts here +LL | pub +LL | } + | ^ + | | + | non-item starts here + | item list ends here + +error: aborting due to 2 previous errors + diff --git a/tests/ui/parser/issues/issue-43196.rs b/tests/ui/parser/issues/issue-43196.rs new file mode 100644 index 000000000..0eefa01ce --- /dev/null +++ b/tests/ui/parser/issues/issue-43196.rs @@ -0,0 +1,6 @@ +fn main() { + | +} +//~^ ERROR expected `|`, found `}` +| +//~^ ERROR expected item, found `|` diff --git a/tests/ui/parser/issues/issue-43196.stderr b/tests/ui/parser/issues/issue-43196.stderr new file mode 100644 index 000000000..4f7ed5cc6 --- /dev/null +++ b/tests/ui/parser/issues/issue-43196.stderr @@ -0,0 +1,16 @@ +error: expected `|`, found `}` + --> $DIR/issue-43196.rs:3:1 + | +LL | | + | - expected `|` +LL | } + | ^ unexpected token + +error: expected item, found `|` + --> $DIR/issue-43196.rs:5:1 + | +LL | | + | ^ expected item + +error: aborting due to 2 previous errors + diff --git a/tests/ui/parser/issues/issue-43692.rs b/tests/ui/parser/issues/issue-43692.rs new file mode 100644 index 000000000..baf8bafb8 --- /dev/null +++ b/tests/ui/parser/issues/issue-43692.rs @@ -0,0 +1,3 @@ +fn main() { + '\u{_10FFFF}'; //~ ERROR invalid start of unicode escape +} diff --git a/tests/ui/parser/issues/issue-43692.stderr b/tests/ui/parser/issues/issue-43692.stderr new file mode 100644 index 000000000..baf998035 --- /dev/null +++ b/tests/ui/parser/issues/issue-43692.stderr @@ -0,0 +1,8 @@ +error: invalid start of unicode escape: `_` + --> $DIR/issue-43692.rs:2:9 + | +LL | '\u{_10FFFF}'; + | ^ invalid start of unicode escape + +error: aborting due to previous error + diff --git a/tests/ui/parser/issues/issue-44021.rs b/tests/ui/parser/issues/issue-44021.rs new file mode 100644 index 000000000..0b9558cc9 --- /dev/null +++ b/tests/ui/parser/issues/issue-44021.rs @@ -0,0 +1,6 @@ +struct MyStruct; +impl MyStruct { + fn f() {|x, y} //~ ERROR expected one of `:`, `@`, or `|`, found `}` +} + +fn main() {} diff --git a/tests/ui/parser/issues/issue-44021.stderr b/tests/ui/parser/issues/issue-44021.stderr new file mode 100644 index 000000000..b888cd989 --- /dev/null +++ b/tests/ui/parser/issues/issue-44021.stderr @@ -0,0 +1,8 @@ +error: expected one of `:`, `@`, or `|`, found `}` + --> $DIR/issue-44021.rs:3:18 + | +LL | fn f() {|x, y} + | ^ expected one of `:`, `@`, or `|` + +error: aborting due to previous error + diff --git a/tests/ui/parser/issues/issue-44406.rs b/tests/ui/parser/issues/issue-44406.rs new file mode 100644 index 000000000..a5b7e83a0 --- /dev/null +++ b/tests/ui/parser/issues/issue-44406.rs @@ -0,0 +1,10 @@ +macro_rules! foo { + ($rest: tt) => { + bar(baz: $rest) //~ ERROR invalid `struct` delimiters or `fn` call arguments + } +} + +fn main() { + foo!(true); + //~^ ERROR expected identifier, found keyword +} diff --git a/tests/ui/parser/issues/issue-44406.stderr b/tests/ui/parser/issues/issue-44406.stderr new file mode 100644 index 000000000..1f0c1ea4c --- /dev/null +++ b/tests/ui/parser/issues/issue-44406.stderr @@ -0,0 +1,33 @@ +error: expected identifier, found keyword `true` + --> $DIR/issue-44406.rs:8:10 + | +LL | foo!(true); + | ^^^^ expected identifier, found keyword + | +help: escape `true` to use it as an identifier + | +LL | foo!(r#true); + | ++ + +error: invalid `struct` delimiters or `fn` call arguments + --> $DIR/issue-44406.rs:3:9 + | +LL | bar(baz: $rest) + | ^^^^^^^^^^^^^^^ +... +LL | foo!(true); + | ---------- in this macro invocation + | + = note: this error originates in the macro `foo` (in Nightly builds, run with -Z macro-backtrace for more info) +help: if `bar` is a struct, use braces as delimiters + | +LL | bar { } + | ~ +help: if `bar` is a function, use the arguments directly + | +LL - bar(baz: $rest) +LL + bar(: $rest) + | + +error: aborting due to 2 previous errors + diff --git a/tests/ui/parser/issues/issue-45296.rs b/tests/ui/parser/issues/issue-45296.rs new file mode 100644 index 000000000..d3a97e89f --- /dev/null +++ b/tests/ui/parser/issues/issue-45296.rs @@ -0,0 +1,6 @@ +fn main() { + let unused = (); + + #![allow(unused_variables)] //~ ERROR not permitted in this context + fn foo() {} +} diff --git a/tests/ui/parser/issues/issue-45296.stderr b/tests/ui/parser/issues/issue-45296.stderr new file mode 100644 index 000000000..081a72054 --- /dev/null +++ b/tests/ui/parser/issues/issue-45296.stderr @@ -0,0 +1,17 @@ +error: an inner attribute is not permitted in this context + --> $DIR/issue-45296.rs:4:5 + | +LL | #![allow(unused_variables)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | fn foo() {} + | ----------- the inner attribute doesn't annotate this function + | + = note: inner attributes, like `#![no_std]`, annotate the item enclosing them, and are usually found at the beginning of source files +help: to annotate the function, change the attribute from inner to outer style + | +LL - #![allow(unused_variables)] +LL + #[allow(unused_variables)] + | + +error: aborting due to previous error + diff --git a/tests/ui/parser/issues/issue-46186.fixed b/tests/ui/parser/issues/issue-46186.fixed new file mode 100644 index 000000000..2cb5a4996 --- /dev/null +++ b/tests/ui/parser/issues/issue-46186.fixed @@ -0,0 +1,8 @@ +// run-rustfix + +pub struct Struct { + pub a: usize, +} +//~^ ERROR expected item, found `;` + +fn main() {} diff --git a/tests/ui/parser/issues/issue-46186.rs b/tests/ui/parser/issues/issue-46186.rs new file mode 100644 index 000000000..84cad38c5 --- /dev/null +++ b/tests/ui/parser/issues/issue-46186.rs @@ -0,0 +1,8 @@ +// run-rustfix + +pub struct Struct { + pub a: usize, +}; +//~^ ERROR expected item, found `;` + +fn main() {} diff --git a/tests/ui/parser/issues/issue-46186.stderr b/tests/ui/parser/issues/issue-46186.stderr new file mode 100644 index 000000000..0766c8a33 --- /dev/null +++ b/tests/ui/parser/issues/issue-46186.stderr @@ -0,0 +1,10 @@ +error: expected item, found `;` + --> $DIR/issue-46186.rs:5:2 + | +LL | }; + | ^ help: remove this semicolon + | + = help: braced struct declarations are not followed by a semicolon + +error: aborting due to previous error + diff --git a/tests/ui/parser/issues/issue-48137-macros-cannot-interpolate-impl-items-bad-variants.rs b/tests/ui/parser/issues/issue-48137-macros-cannot-interpolate-impl-items-bad-variants.rs new file mode 100644 index 000000000..48a679b2d --- /dev/null +++ b/tests/ui/parser/issues/issue-48137-macros-cannot-interpolate-impl-items-bad-variants.rs @@ -0,0 +1,44 @@ +fn main() {} + +macro_rules! expand_to_enum { + () => { + enum BadE {} + //~^ ERROR enum is not supported in `trait`s or `impl`s + //~| ERROR enum is not supported in `trait`s or `impl`s + //~| ERROR enum is not supported in `extern` blocks + }; +} + +macro_rules! mac_impl { + ($($i:item)*) => { + struct S; + impl S { $($i)* } + } +} + +mac_impl! { + struct BadS; //~ ERROR struct is not supported in `trait`s or `impl`s + expand_to_enum!(); +} + +macro_rules! mac_trait { + ($($i:item)*) => { + trait T { $($i)* } + } +} + +mac_trait! { + struct BadS; //~ ERROR struct is not supported in `trait`s or `impl`s + expand_to_enum!(); +} + +macro_rules! mac_extern { + ($($i:item)*) => { + extern "C" { $($i)* } + } +} + +mac_extern! { + struct BadS; //~ ERROR struct is not supported in `extern` blocks + expand_to_enum!(); +} diff --git a/tests/ui/parser/issues/issue-48137-macros-cannot-interpolate-impl-items-bad-variants.stderr b/tests/ui/parser/issues/issue-48137-macros-cannot-interpolate-impl-items-bad-variants.stderr new file mode 100644 index 000000000..fdef8ff6d --- /dev/null +++ b/tests/ui/parser/issues/issue-48137-macros-cannot-interpolate-impl-items-bad-variants.stderr @@ -0,0 +1,62 @@ +error: struct is not supported in `trait`s or `impl`s + --> $DIR/issue-48137-macros-cannot-interpolate-impl-items-bad-variants.rs:20:5 + | +LL | struct BadS; + | ^^^^^^^^^^^^ + | + = help: consider moving the struct out to a nearby module scope + +error: enum is not supported in `trait`s or `impl`s + --> $DIR/issue-48137-macros-cannot-interpolate-impl-items-bad-variants.rs:5:9 + | +LL | enum BadE {} + | ^^^^^^^^^ +... +LL | expand_to_enum!(); + | ----------------- in this macro invocation + | + = help: consider moving the enum out to a nearby module scope + = note: this error originates in the macro `expand_to_enum` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: struct is not supported in `trait`s or `impl`s + --> $DIR/issue-48137-macros-cannot-interpolate-impl-items-bad-variants.rs:31:5 + | +LL | struct BadS; + | ^^^^^^^^^^^^ + | + = help: consider moving the struct out to a nearby module scope + +error: enum is not supported in `trait`s or `impl`s + --> $DIR/issue-48137-macros-cannot-interpolate-impl-items-bad-variants.rs:5:9 + | +LL | enum BadE {} + | ^^^^^^^^^ +... +LL | expand_to_enum!(); + | ----------------- in this macro invocation + | + = help: consider moving the enum out to a nearby module scope + = note: this error originates in the macro `expand_to_enum` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: struct is not supported in `extern` blocks + --> $DIR/issue-48137-macros-cannot-interpolate-impl-items-bad-variants.rs:42:5 + | +LL | struct BadS; + | ^^^^^^^^^^^^ + | + = help: consider moving the struct out to a nearby module scope + +error: enum is not supported in `extern` blocks + --> $DIR/issue-48137-macros-cannot-interpolate-impl-items-bad-variants.rs:5:9 + | +LL | enum BadE {} + | ^^^^^^^^^ +... +LL | expand_to_enum!(); + | ----------------- in this macro invocation + | + = help: consider moving the enum out to a nearby module scope + = note: this error originates in the macro `expand_to_enum` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to 6 previous errors + diff --git a/tests/ui/parser/issues/issue-48137-macros-cannot-interpolate-impl-items.rs b/tests/ui/parser/issues/issue-48137-macros-cannot-interpolate-impl-items.rs new file mode 100644 index 000000000..8592f8a72 --- /dev/null +++ b/tests/ui/parser/issues/issue-48137-macros-cannot-interpolate-impl-items.rs @@ -0,0 +1,34 @@ +// check-pass + +fn main() {} + +macro_rules! mac_impl { + ($i:item) => { + struct S; + impl S { $i } + } +} + +mac_impl! { + fn foo() {} +} + +macro_rules! mac_trait { + ($i:item) => { + trait T { $i } + } +} + +mac_trait! { + fn foo() {} +} + +macro_rules! mac_extern { + ($i:item) => { + extern "C" { $i } + } +} + +mac_extern! { + fn foo(); +} diff --git a/tests/ui/parser/issues/issue-48508-aux.rs b/tests/ui/parser/issues/issue-48508-aux.rs new file mode 100644 index 000000000..ebdc70a04 --- /dev/null +++ b/tests/ui/parser/issues/issue-48508-aux.rs @@ -0,0 +1,7 @@ +// run-pass +// ignore-test Not a test. Used by issue-48508.rs + +pub fn other() -> f64 { + let µ = 1.0; + µ +} diff --git a/tests/ui/parser/issues/issue-48508.rs b/tests/ui/parser/issues/issue-48508.rs new file mode 100644 index 000000000..37d04c5d6 --- /dev/null +++ b/tests/ui/parser/issues/issue-48508.rs @@ -0,0 +1,20 @@ +// run-pass +// Regression test for issue #48508: +// +// Confusion between global and local file offsets caused incorrect handling of multibyte character +// spans when compiling multiple files. One visible effect was an ICE generating debug information +// when a multibyte character is at the end of a scope. The problematic code is actually in +// issue-48508-aux.rs + +// compile-flags:-g +// ignore-pretty issue #37195 +// ignore-asmjs wasm2js does not support source maps yet + +#![allow(uncommon_codepoints)] + +#[path = "issue-48508-aux.rs"] +mod other_file; + +fn main() { + other_file::other(); +} diff --git a/tests/ui/parser/issues/issue-48636.fixed b/tests/ui/parser/issues/issue-48636.fixed new file mode 100644 index 000000000..87c19a32d --- /dev/null +++ b/tests/ui/parser/issues/issue-48636.fixed @@ -0,0 +1,12 @@ +// run-rustfix + +#![allow(dead_code)] + +struct S { + x: u8, + /// The ID of the parent core + y: u8, +} +//~^^^ ERROR found a documentation comment that doesn't document anything + +fn main() {} diff --git a/tests/ui/parser/issues/issue-48636.rs b/tests/ui/parser/issues/issue-48636.rs new file mode 100644 index 000000000..8610dc2f7 --- /dev/null +++ b/tests/ui/parser/issues/issue-48636.rs @@ -0,0 +1,12 @@ +// run-rustfix + +#![allow(dead_code)] + +struct S { + x: u8 + /// The ID of the parent core + y: u8, +} +//~^^^ ERROR found a documentation comment that doesn't document anything + +fn main() {} diff --git a/tests/ui/parser/issues/issue-48636.stderr b/tests/ui/parser/issues/issue-48636.stderr new file mode 100644 index 000000000..6177870d1 --- /dev/null +++ b/tests/ui/parser/issues/issue-48636.stderr @@ -0,0 +1,15 @@ +error[E0585]: found a documentation comment that doesn't document anything + --> $DIR/issue-48636.rs:7:5 + | +LL | struct S { + | - while parsing this struct +LL | x: u8 + | - help: missing comma here: `,` +LL | /// The ID of the parent core + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: doc comments must come before what they document, if a comment was intended use `//` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0585`. diff --git a/tests/ui/parser/issues/issue-49040.rs b/tests/ui/parser/issues/issue-49040.rs new file mode 100644 index 000000000..b7a541dd6 --- /dev/null +++ b/tests/ui/parser/issues/issue-49040.rs @@ -0,0 +1,3 @@ +#![allow(unused_variables)]; //~ ERROR expected item, found `;` +//~^ ERROR `main` function +fn foo() {} diff --git a/tests/ui/parser/issues/issue-49040.stderr b/tests/ui/parser/issues/issue-49040.stderr new file mode 100644 index 000000000..8af7838c7 --- /dev/null +++ b/tests/ui/parser/issues/issue-49040.stderr @@ -0,0 +1,15 @@ +error: expected item, found `;` + --> $DIR/issue-49040.rs:1:28 + | +LL | #![allow(unused_variables)]; + | ^ help: remove this semicolon + +error[E0601]: `main` function not found in crate `issue_49040` + --> $DIR/issue-49040.rs:1:29 + | +LL | #![allow(unused_variables)]; + | ^ consider adding a `main` function to `$DIR/issue-49040.rs` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0601`. diff --git a/tests/ui/parser/issues/issue-51602.rs b/tests/ui/parser/issues/issue-51602.rs new file mode 100644 index 000000000..0e96ca914 --- /dev/null +++ b/tests/ui/parser/issues/issue-51602.rs @@ -0,0 +1,6 @@ +fn main(){ + if i in 1..10 { +//~^ ERROR expected `{`, found keyword `in` + break; + } +} diff --git a/tests/ui/parser/issues/issue-51602.stderr b/tests/ui/parser/issues/issue-51602.stderr new file mode 100644 index 000000000..4a5653fdb --- /dev/null +++ b/tests/ui/parser/issues/issue-51602.stderr @@ -0,0 +1,14 @@ +error: expected `{`, found keyword `in` + --> $DIR/issue-51602.rs:2:10 + | +LL | if i in 1..10 { + | ^^ expected `{` + | +note: the `if` expression is missing a block after this condition + --> $DIR/issue-51602.rs:2:8 + | +LL | if i in 1..10 { + | ^ + +error: aborting due to previous error + diff --git a/tests/ui/parser/issues/issue-52496.rs b/tests/ui/parser/issues/issue-52496.rs new file mode 100644 index 000000000..05461f8b8 --- /dev/null +++ b/tests/ui/parser/issues/issue-52496.rs @@ -0,0 +1,12 @@ +struct Foo { bar: f64, baz: i64, bat: i64 } + +fn main() { + let _ = Foo { bar: .5, baz: 42 }; + //~^ ERROR float literals must have an integer part + //~| ERROR missing field `bat` in initializer of `Foo` + let bar = 1.5f32; + let _ = Foo { bar.into(), bat: -1, . }; + //~^ ERROR expected one of + //~| ERROR missing fields `bar` and `baz` in initializer of `Foo` + //~| ERROR expected identifier, found `.` +} diff --git a/tests/ui/parser/issues/issue-52496.stderr b/tests/ui/parser/issues/issue-52496.stderr new file mode 100644 index 000000000..77335c64c --- /dev/null +++ b/tests/ui/parser/issues/issue-52496.stderr @@ -0,0 +1,38 @@ +error: float literals must have an integer part + --> $DIR/issue-52496.rs:4:24 + | +LL | let _ = Foo { bar: .5, baz: 42 }; + | ^^ help: must have an integer part: `0.5` + +error: expected one of `,`, `:`, or `}`, found `.` + --> $DIR/issue-52496.rs:8:22 + | +LL | let _ = Foo { bar.into(), bat: -1, . }; + | --- - ^ expected one of `,`, `:`, or `}` + | | | + | | help: try naming a field: `bar:` + | while parsing this struct + +error: expected identifier, found `.` + --> $DIR/issue-52496.rs:8:40 + | +LL | let _ = Foo { bar.into(), bat: -1, . }; + | --- ^ expected identifier + | | + | while parsing this struct + +error[E0063]: missing field `bat` in initializer of `Foo` + --> $DIR/issue-52496.rs:4:13 + | +LL | let _ = Foo { bar: .5, baz: 42 }; + | ^^^ missing `bat` + +error[E0063]: missing fields `bar` and `baz` in initializer of `Foo` + --> $DIR/issue-52496.rs:8:13 + | +LL | let _ = Foo { bar.into(), bat: -1, . }; + | ^^^ missing `bar` and `baz` + +error: aborting due to 5 previous errors + +For more information about this error, try `rustc --explain E0063`. diff --git a/tests/ui/parser/issues/issue-54521-1.rs b/tests/ui/parser/issues/issue-54521-1.rs new file mode 100644 index 000000000..8a682ef0a --- /dev/null +++ b/tests/ui/parser/issues/issue-54521-1.rs @@ -0,0 +1,16 @@ +// check-pass + +// This test checks that the `remove extra angle brackets` error doesn't happen for some +// potential edge-cases.. + +struct X { + len: u32, +} + +fn main() { + let x = X { len: 3 }; + + let _ = x.len > (3); + + let _ = x.len >> (3); +} diff --git a/tests/ui/parser/issues/issue-54521-2.fixed b/tests/ui/parser/issues/issue-54521-2.fixed new file mode 100644 index 000000000..a91c4fe43 --- /dev/null +++ b/tests/ui/parser/issues/issue-54521-2.fixed @@ -0,0 +1,22 @@ +// run-rustfix + +// This test checks that the following error is emitted and the suggestion works: +// +// ``` +// let _ = Vec::<usize>>>::new(); +// ^^ help: remove extra angle brackets +// ``` + +fn main() { + let _ = Vec::<usize>::new(); + //~^ ERROR unmatched angle bracket + + let _ = Vec::<usize>::new(); + //~^ ERROR unmatched angle bracket + + let _ = Vec::<usize>::new(); + //~^ ERROR unmatched angle bracket + + let _ = Vec::<usize>::new(); + //~^ ERROR unmatched angle bracket +} diff --git a/tests/ui/parser/issues/issue-54521-2.rs b/tests/ui/parser/issues/issue-54521-2.rs new file mode 100644 index 000000000..3639aac87 --- /dev/null +++ b/tests/ui/parser/issues/issue-54521-2.rs @@ -0,0 +1,22 @@ +// run-rustfix + +// This test checks that the following error is emitted and the suggestion works: +// +// ``` +// let _ = Vec::<usize>>>::new(); +// ^^ help: remove extra angle brackets +// ``` + +fn main() { + let _ = Vec::<usize>>>>>::new(); + //~^ ERROR unmatched angle bracket + + let _ = Vec::<usize>>>>::new(); + //~^ ERROR unmatched angle bracket + + let _ = Vec::<usize>>>::new(); + //~^ ERROR unmatched angle bracket + + let _ = Vec::<usize>>::new(); + //~^ ERROR unmatched angle bracket +} diff --git a/tests/ui/parser/issues/issue-54521-2.stderr b/tests/ui/parser/issues/issue-54521-2.stderr new file mode 100644 index 000000000..9556b83b7 --- /dev/null +++ b/tests/ui/parser/issues/issue-54521-2.stderr @@ -0,0 +1,26 @@ +error: unmatched angle brackets + --> $DIR/issue-54521-2.rs:11:25 + | +LL | let _ = Vec::<usize>>>>>::new(); + | ^^^^ help: remove extra angle brackets + +error: unmatched angle brackets + --> $DIR/issue-54521-2.rs:14:25 + | +LL | let _ = Vec::<usize>>>>::new(); + | ^^^ help: remove extra angle brackets + +error: unmatched angle brackets + --> $DIR/issue-54521-2.rs:17:25 + | +LL | let _ = Vec::<usize>>>::new(); + | ^^ help: remove extra angle brackets + +error: unmatched angle bracket + --> $DIR/issue-54521-2.rs:20:25 + | +LL | let _ = Vec::<usize>>::new(); + | ^ help: remove extra angle bracket + +error: aborting due to 4 previous errors + diff --git a/tests/ui/parser/issues/issue-54521-3.fixed b/tests/ui/parser/issues/issue-54521-3.fixed new file mode 100644 index 000000000..84ab6866c --- /dev/null +++ b/tests/ui/parser/issues/issue-54521-3.fixed @@ -0,0 +1,22 @@ +// run-rustfix + +// This test checks that the following error is emitted and the suggestion works: +// +// ``` +// let _ = vec![1, 2, 3].into_iter().collect::<Vec<usize>>>>(); +// ^^ help: remove extra angle brackets +// ``` + +fn main() { + let _ = vec![1, 2, 3].into_iter().collect::<Vec<usize>>(); + //~^ ERROR unmatched angle bracket + + let _ = vec![1, 2, 3].into_iter().collect::<Vec<usize>>(); + //~^ ERROR unmatched angle bracket + + let _ = vec![1, 2, 3].into_iter().collect::<Vec<usize>>(); + //~^ ERROR unmatched angle bracket + + let _ = vec![1, 2, 3].into_iter().collect::<Vec<usize>>(); + //~^ ERROR unmatched angle bracket +} diff --git a/tests/ui/parser/issues/issue-54521-3.rs b/tests/ui/parser/issues/issue-54521-3.rs new file mode 100644 index 000000000..f1d685041 --- /dev/null +++ b/tests/ui/parser/issues/issue-54521-3.rs @@ -0,0 +1,22 @@ +// run-rustfix + +// This test checks that the following error is emitted and the suggestion works: +// +// ``` +// let _ = vec![1, 2, 3].into_iter().collect::<Vec<usize>>>>(); +// ^^ help: remove extra angle brackets +// ``` + +fn main() { + let _ = vec![1, 2, 3].into_iter().collect::<Vec<usize>>>>>>(); + //~^ ERROR unmatched angle bracket + + let _ = vec![1, 2, 3].into_iter().collect::<Vec<usize>>>>>(); + //~^ ERROR unmatched angle bracket + + let _ = vec![1, 2, 3].into_iter().collect::<Vec<usize>>>>(); + //~^ ERROR unmatched angle bracket + + let _ = vec![1, 2, 3].into_iter().collect::<Vec<usize>>>(); + //~^ ERROR unmatched angle bracket +} diff --git a/tests/ui/parser/issues/issue-54521-3.stderr b/tests/ui/parser/issues/issue-54521-3.stderr new file mode 100644 index 000000000..0f23dd621 --- /dev/null +++ b/tests/ui/parser/issues/issue-54521-3.stderr @@ -0,0 +1,26 @@ +error: unmatched angle brackets + --> $DIR/issue-54521-3.rs:11:60 + | +LL | let _ = vec![1, 2, 3].into_iter().collect::<Vec<usize>>>>>>(); + | ^^^^ help: remove extra angle brackets + +error: unmatched angle brackets + --> $DIR/issue-54521-3.rs:14:60 + | +LL | let _ = vec![1, 2, 3].into_iter().collect::<Vec<usize>>>>>(); + | ^^^ help: remove extra angle brackets + +error: unmatched angle brackets + --> $DIR/issue-54521-3.rs:17:60 + | +LL | let _ = vec![1, 2, 3].into_iter().collect::<Vec<usize>>>>(); + | ^^ help: remove extra angle brackets + +error: unmatched angle bracket + --> $DIR/issue-54521-3.rs:20:60 + | +LL | let _ = vec![1, 2, 3].into_iter().collect::<Vec<usize>>>(); + | ^ help: remove extra angle bracket + +error: aborting due to 4 previous errors + diff --git a/tests/ui/parser/issues/issue-5544-a.rs b/tests/ui/parser/issues/issue-5544-a.rs new file mode 100644 index 000000000..3c239c73b --- /dev/null +++ b/tests/ui/parser/issues/issue-5544-a.rs @@ -0,0 +1,4 @@ +fn main() { + let __isize = 340282366920938463463374607431768211456; // 2^128 + //~^ ERROR integer literal is too large +} diff --git a/tests/ui/parser/issues/issue-5544-a.stderr b/tests/ui/parser/issues/issue-5544-a.stderr new file mode 100644 index 000000000..6e68c7585 --- /dev/null +++ b/tests/ui/parser/issues/issue-5544-a.stderr @@ -0,0 +1,10 @@ +error: integer literal is too large + --> $DIR/issue-5544-a.rs:2:19 + | +LL | let __isize = 340282366920938463463374607431768211456; // 2^128 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: value exceeds limit of `340282366920938463463374607431768211455` + +error: aborting due to previous error + diff --git a/tests/ui/parser/issues/issue-5544-b.rs b/tests/ui/parser/issues/issue-5544-b.rs new file mode 100644 index 000000000..93f2ff271 --- /dev/null +++ b/tests/ui/parser/issues/issue-5544-b.rs @@ -0,0 +1,4 @@ +fn main() { + let __isize = 0xffff_ffff_ffff_ffff_ffff_ffff_ffff_ffff_ff; + //~^ ERROR integer literal is too large +} diff --git a/tests/ui/parser/issues/issue-5544-b.stderr b/tests/ui/parser/issues/issue-5544-b.stderr new file mode 100644 index 000000000..5d0e76d5d --- /dev/null +++ b/tests/ui/parser/issues/issue-5544-b.stderr @@ -0,0 +1,10 @@ +error: integer literal is too large + --> $DIR/issue-5544-b.rs:2:19 + | +LL | let __isize = 0xffff_ffff_ffff_ffff_ffff_ffff_ffff_ffff_ff; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: value exceeds limit of `0xffffffffffffffffffffffffffffffff` + +error: aborting due to previous error + diff --git a/tests/ui/parser/issues/issue-56031.rs b/tests/ui/parser/issues/issue-56031.rs new file mode 100644 index 000000000..b68f56814 --- /dev/null +++ b/tests/ui/parser/issues/issue-56031.rs @@ -0,0 +1,6 @@ +struct T; + +impl for T {} +//~^ ERROR missing trait in a trait impl + +fn main() {} diff --git a/tests/ui/parser/issues/issue-56031.stderr b/tests/ui/parser/issues/issue-56031.stderr new file mode 100644 index 000000000..2fa05dd2d --- /dev/null +++ b/tests/ui/parser/issues/issue-56031.stderr @@ -0,0 +1,18 @@ +error: missing trait in a trait impl + --> $DIR/issue-56031.rs:3:5 + | +LL | impl for T {} + | ^ + | +help: add a trait here + | +LL | impl Trait for T {} + | +++++ +help: for an inherent impl, drop this `for` + | +LL - impl for T {} +LL + impl T {} + | + +error: aborting due to previous error + diff --git a/tests/ui/parser/issues/issue-57198.rs b/tests/ui/parser/issues/issue-57198.rs new file mode 100644 index 000000000..714a46cbc --- /dev/null +++ b/tests/ui/parser/issues/issue-57198.rs @@ -0,0 +1,8 @@ +mod m { + pub fn r#for() {} +} + +fn main() { + m::for(); + //~^ ERROR expected identifier, found keyword `for` +} diff --git a/tests/ui/parser/issues/issue-57198.stderr b/tests/ui/parser/issues/issue-57198.stderr new file mode 100644 index 000000000..dd70b4022 --- /dev/null +++ b/tests/ui/parser/issues/issue-57198.stderr @@ -0,0 +1,13 @@ +error: expected identifier, found keyword `for` + --> $DIR/issue-57198.rs:6:8 + | +LL | m::for(); + | ^^^ expected identifier, found keyword + | +help: escape `for` to use it as an identifier + | +LL | m::r#for(); + | ++ + +error: aborting due to previous error + diff --git a/tests/ui/parser/issues/issue-57684.fixed b/tests/ui/parser/issues/issue-57684.fixed new file mode 100644 index 000000000..4a432206d --- /dev/null +++ b/tests/ui/parser/issues/issue-57684.fixed @@ -0,0 +1,37 @@ +// run-rustfix + +#![allow(warnings)] + +// This test checks that the following error is emitted when a `=` character is used to initialize +// a struct field when a `:` is expected. +// +// ``` +// error: struct fields are initialized with a colon +// --> $DIR/issue-57684.rs:12:20 +// | +// LL | let _ = X { f1 = 5 }; +// | ^ help: replace equals symbol with a colon: `:` +// ``` + +struct X { + f1: i32, +} + +struct Y { + f1: i32, + f2: i32, + f3: i32, +} + +fn main() { + let _ = X { f1: 5 }; + //~^ ERROR expected `:`, found `=` + + let f3 = 3; + let _ = Y { + f1: 5, + //~^ ERROR expected `:`, found `=` + f2: 4, + f3, + }; +} diff --git a/tests/ui/parser/issues/issue-57684.rs b/tests/ui/parser/issues/issue-57684.rs new file mode 100644 index 000000000..7a62785e3 --- /dev/null +++ b/tests/ui/parser/issues/issue-57684.rs @@ -0,0 +1,37 @@ +// run-rustfix + +#![allow(warnings)] + +// This test checks that the following error is emitted when a `=` character is used to initialize +// a struct field when a `:` is expected. +// +// ``` +// error: struct fields are initialized with a colon +// --> $DIR/issue-57684.rs:12:20 +// | +// LL | let _ = X { f1 = 5 }; +// | ^ help: replace equals symbol with a colon: `:` +// ``` + +struct X { + f1: i32, +} + +struct Y { + f1: i32, + f2: i32, + f3: i32, +} + +fn main() { + let _ = X { f1 = 5 }; + //~^ ERROR expected `:`, found `=` + + let f3 = 3; + let _ = Y { + f1 = 5, + //~^ ERROR expected `:`, found `=` + f2: 4, + f3, + }; +} diff --git a/tests/ui/parser/issues/issue-57684.stderr b/tests/ui/parser/issues/issue-57684.stderr new file mode 100644 index 000000000..514bbffde --- /dev/null +++ b/tests/ui/parser/issues/issue-57684.stderr @@ -0,0 +1,18 @@ +error: expected `:`, found `=` + --> $DIR/issue-57684.rs:27:20 + | +LL | let _ = X { f1 = 5 }; + | -^ + | | + | help: replace equals symbol with a colon: `:` + +error: expected `:`, found `=` + --> $DIR/issue-57684.rs:32:12 + | +LL | f1 = 5, + | -^ + | | + | help: replace equals symbol with a colon: `:` + +error: aborting due to 2 previous errors + diff --git a/tests/ui/parser/issues/issue-57819.fixed b/tests/ui/parser/issues/issue-57819.fixed new file mode 100644 index 000000000..3fab21db2 --- /dev/null +++ b/tests/ui/parser/issues/issue-57819.fixed @@ -0,0 +1,47 @@ +// run-rustfix + +#![allow(warnings)] + +// This test checks that the following error is emitted and the suggestion works: +// +// ``` +// let _ = vec![1, 2, 3].into_iter().collect::<<<Vec<usize>>(); +// ^^ help: remove extra angle brackets +// ``` + +trait Foo { + type Output; +} + +fn foo<T: Foo>() { + // More complex cases with more than one correct leading `<` character: + + bar::<<T as Foo>::Output>(); + //~^ ERROR unmatched angle bracket + + bar::<<T as Foo>::Output>(); + //~^ ERROR unmatched angle bracket + + bar::<<T as Foo>::Output>(); + //~^ ERROR unmatched angle bracket + + bar::<<T as Foo>::Output>(); +} + +fn bar<T>() {} + +fn main() { + let _ = vec![1, 2, 3].into_iter().collect::<Vec<usize>>(); + //~^ ERROR unmatched angle bracket + + let _ = vec![1, 2, 3].into_iter().collect::<Vec<usize>>(); + //~^ ERROR unmatched angle bracket + + let _ = vec![1, 2, 3].into_iter().collect::<Vec<usize>>(); + //~^ ERROR unmatched angle bracket + + let _ = vec![1, 2, 3].into_iter().collect::<Vec<usize>>(); + //~^ ERROR unmatched angle bracket + + let _ = vec![1, 2, 3].into_iter().collect::<Vec<usize>>(); +} diff --git a/tests/ui/parser/issues/issue-57819.rs b/tests/ui/parser/issues/issue-57819.rs new file mode 100644 index 000000000..5cafbf439 --- /dev/null +++ b/tests/ui/parser/issues/issue-57819.rs @@ -0,0 +1,47 @@ +// run-rustfix + +#![allow(warnings)] + +// This test checks that the following error is emitted and the suggestion works: +// +// ``` +// let _ = vec![1, 2, 3].into_iter().collect::<<<Vec<usize>>(); +// ^^ help: remove extra angle brackets +// ``` + +trait Foo { + type Output; +} + +fn foo<T: Foo>() { + // More complex cases with more than one correct leading `<` character: + + bar::<<<<<T as Foo>::Output>(); + //~^ ERROR unmatched angle bracket + + bar::<<<<T as Foo>::Output>(); + //~^ ERROR unmatched angle bracket + + bar::<<<T as Foo>::Output>(); + //~^ ERROR unmatched angle bracket + + bar::<<T as Foo>::Output>(); +} + +fn bar<T>() {} + +fn main() { + let _ = vec![1, 2, 3].into_iter().collect::<<<<<Vec<usize>>(); + //~^ ERROR unmatched angle bracket + + let _ = vec![1, 2, 3].into_iter().collect::<<<<Vec<usize>>(); + //~^ ERROR unmatched angle bracket + + let _ = vec![1, 2, 3].into_iter().collect::<<<Vec<usize>>(); + //~^ ERROR unmatched angle bracket + + let _ = vec![1, 2, 3].into_iter().collect::<<Vec<usize>>(); + //~^ ERROR unmatched angle bracket + + let _ = vec![1, 2, 3].into_iter().collect::<Vec<usize>>(); +} diff --git a/tests/ui/parser/issues/issue-57819.stderr b/tests/ui/parser/issues/issue-57819.stderr new file mode 100644 index 000000000..493e9835b --- /dev/null +++ b/tests/ui/parser/issues/issue-57819.stderr @@ -0,0 +1,44 @@ +error: unmatched angle brackets + --> $DIR/issue-57819.rs:19:10 + | +LL | bar::<<<<<T as Foo>::Output>(); + | ^^^ help: remove extra angle brackets + +error: unmatched angle brackets + --> $DIR/issue-57819.rs:22:10 + | +LL | bar::<<<<T as Foo>::Output>(); + | ^^ help: remove extra angle brackets + +error: unmatched angle bracket + --> $DIR/issue-57819.rs:25:10 + | +LL | bar::<<<T as Foo>::Output>(); + | ^ help: remove extra angle bracket + +error: unmatched angle brackets + --> $DIR/issue-57819.rs:34:48 + | +LL | let _ = vec![1, 2, 3].into_iter().collect::<<<<<Vec<usize>>(); + | ^^^^ help: remove extra angle brackets + +error: unmatched angle brackets + --> $DIR/issue-57819.rs:37:48 + | +LL | let _ = vec![1, 2, 3].into_iter().collect::<<<<Vec<usize>>(); + | ^^^ help: remove extra angle brackets + +error: unmatched angle brackets + --> $DIR/issue-57819.rs:40:48 + | +LL | let _ = vec![1, 2, 3].into_iter().collect::<<<Vec<usize>>(); + | ^^ help: remove extra angle brackets + +error: unmatched angle bracket + --> $DIR/issue-57819.rs:43:48 + | +LL | let _ = vec![1, 2, 3].into_iter().collect::<<Vec<usize>>(); + | ^ help: remove extra angle bracket + +error: aborting due to 7 previous errors + diff --git a/tests/ui/parser/issues/issue-5806.rs b/tests/ui/parser/issues/issue-5806.rs new file mode 100644 index 000000000..b694642a9 --- /dev/null +++ b/tests/ui/parser/issues/issue-5806.rs @@ -0,0 +1,7 @@ +// normalize-stderr-test: "parser:.*\(" -> "parser: $$ACCESS_DENIED_MSG (" +// normalize-stderr-test: "os error \d+" -> "os error $$ACCESS_DENIED_CODE" + +#[path = "../parser"] +mod foo; //~ ERROR couldn't read + +fn main() {} diff --git a/tests/ui/parser/issues/issue-5806.stderr b/tests/ui/parser/issues/issue-5806.stderr new file mode 100644 index 000000000..bdb5c91ff --- /dev/null +++ b/tests/ui/parser/issues/issue-5806.stderr @@ -0,0 +1,8 @@ +error: couldn't read $DIR/../parser: $ACCESS_DENIED_MSG (os error $ACCESS_DENIED_CODE) + --> $DIR/issue-5806.rs:5:1 + | +LL | mod foo; + | ^^^^^^^^ + +error: aborting due to previous error + diff --git a/tests/ui/parser/issues/issue-58094-missing-right-square-bracket.rs b/tests/ui/parser/issues/issue-58094-missing-right-square-bracket.rs new file mode 100644 index 000000000..25699f9fe --- /dev/null +++ b/tests/ui/parser/issues/issue-58094-missing-right-square-bracket.rs @@ -0,0 +1,4 @@ +// Fixed in #66054. +// ignore-tidy-trailing-newlines +// error-pattern: aborting due to 2 previous errors +#[Ѕ
\ No newline at end of file diff --git a/tests/ui/parser/issues/issue-58094-missing-right-square-bracket.stderr b/tests/ui/parser/issues/issue-58094-missing-right-square-bracket.stderr new file mode 100644 index 000000000..8a44ee761 --- /dev/null +++ b/tests/ui/parser/issues/issue-58094-missing-right-square-bracket.stderr @@ -0,0 +1,16 @@ +error: this file contains an unclosed delimiter + --> $DIR/issue-58094-missing-right-square-bracket.rs:4:4 + | +LL | #[Ѕ + | - ^ + | | + | unclosed delimiter + +error: expected item after attributes + --> $DIR/issue-58094-missing-right-square-bracket.rs:4:1 + | +LL | #[Ѕ + | ^^^ + +error: aborting due to 2 previous errors + diff --git a/tests/ui/parser/issues/issue-58856-1.rs b/tests/ui/parser/issues/issue-58856-1.rs new file mode 100644 index 000000000..ea80eb871 --- /dev/null +++ b/tests/ui/parser/issues/issue-58856-1.rs @@ -0,0 +1,8 @@ +impl A { + //~^ ERROR cannot find type `A` in this scope + fn b(self> + //~^ ERROR expected one of `)`, `,`, or `:`, found `>` + //~| ERROR expected one of `->`, `where`, or `{`, found `>` +} + +fn main() {} diff --git a/tests/ui/parser/issues/issue-58856-1.stderr b/tests/ui/parser/issues/issue-58856-1.stderr new file mode 100644 index 000000000..96151f3fe --- /dev/null +++ b/tests/ui/parser/issues/issue-58856-1.stderr @@ -0,0 +1,29 @@ +error: expected one of `)`, `,`, or `:`, found `>` + --> $DIR/issue-58856-1.rs:3:9 + | +LL | fn b(self> + | ^ ^ help: `)` may belong here + | | + | unclosed delimiter + +error: expected one of `->`, `where`, or `{`, found `>` + --> $DIR/issue-58856-1.rs:3:14 + | +LL | impl A { + | - while parsing this item list starting here +LL | +LL | fn b(self> + | ^ expected one of `->`, `where`, or `{` +... +LL | } + | - the item list ends here + +error[E0412]: cannot find type `A` in this scope + --> $DIR/issue-58856-1.rs:1:6 + | +LL | impl A { + | ^ not found in this scope + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0412`. diff --git a/tests/ui/parser/issues/issue-58856-2.rs b/tests/ui/parser/issues/issue-58856-2.rs new file mode 100644 index 000000000..9356d57b0 --- /dev/null +++ b/tests/ui/parser/issues/issue-58856-2.rs @@ -0,0 +1,14 @@ +struct Empty; + +trait Howness {} + +impl Howness for () { + fn how_are_you(&self -> Empty { + //~^ ERROR expected one of `)` or `,`, found `->` + //~| ERROR method `how_are_you` is not a member of trait `Howness` + Empty + } +} +//~^ ERROR non-item in item list + +fn main() {} diff --git a/tests/ui/parser/issues/issue-58856-2.stderr b/tests/ui/parser/issues/issue-58856-2.stderr new file mode 100644 index 000000000..627dd3890 --- /dev/null +++ b/tests/ui/parser/issues/issue-58856-2.stderr @@ -0,0 +1,34 @@ +error: expected one of `)` or `,`, found `->` + --> $DIR/issue-58856-2.rs:6:19 + | +LL | fn how_are_you(&self -> Empty { + | ^ -^^ + | | | + | | help: `)` may belong here + | unclosed delimiter + +error: non-item in item list + --> $DIR/issue-58856-2.rs:11:1 + | +LL | impl Howness for () { + | - item list starts here +... +LL | } + | ^ + | | + | non-item starts here + | item list ends here + +error[E0407]: method `how_are_you` is not a member of trait `Howness` + --> $DIR/issue-58856-2.rs:6:5 + | +LL | / fn how_are_you(&self -> Empty { +LL | | +LL | | +LL | | Empty +LL | | } + | |_____^ not a member of trait `Howness` + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0407`. diff --git a/tests/ui/parser/issues/issue-59418.rs b/tests/ui/parser/issues/issue-59418.rs new file mode 100644 index 000000000..0fa191d4a --- /dev/null +++ b/tests/ui/parser/issues/issue-59418.rs @@ -0,0 +1,18 @@ +struct X(i32,i32,i32); + +fn main() { + let a = X(1, 2, 3); + let b = a.1suffix; + //~^ ERROR suffixes on a tuple index are invalid + println!("{}", b); + let c = (1, 2, 3); + let d = c.1suffix; + //~^ ERROR suffixes on a tuple index are invalid + println!("{}", d); + let s = X { 0suffix: 0, 1: 1, 2: 2 }; + //~^ ERROR suffixes on a tuple index are invalid + match s { + X { 0suffix: _, .. } => {} + //~^ ERROR suffixes on a tuple index are invalid + } +} diff --git a/tests/ui/parser/issues/issue-59418.stderr b/tests/ui/parser/issues/issue-59418.stderr new file mode 100644 index 000000000..347051e9f --- /dev/null +++ b/tests/ui/parser/issues/issue-59418.stderr @@ -0,0 +1,26 @@ +error: suffixes on a tuple index are invalid + --> $DIR/issue-59418.rs:5:15 + | +LL | let b = a.1suffix; + | ^^^^^^^ invalid suffix `suffix` + +error: suffixes on a tuple index are invalid + --> $DIR/issue-59418.rs:9:15 + | +LL | let d = c.1suffix; + | ^^^^^^^ invalid suffix `suffix` + +error: suffixes on a tuple index are invalid + --> $DIR/issue-59418.rs:12:17 + | +LL | let s = X { 0suffix: 0, 1: 1, 2: 2 }; + | ^^^^^^^ invalid suffix `suffix` + +error: suffixes on a tuple index are invalid + --> $DIR/issue-59418.rs:15:13 + | +LL | X { 0suffix: _, .. } => {} + | ^^^^^^^ invalid suffix `suffix` + +error: aborting due to 4 previous errors + diff --git a/tests/ui/parser/issues/issue-60075.rs b/tests/ui/parser/issues/issue-60075.rs new file mode 100644 index 000000000..e89d78ee8 --- /dev/null +++ b/tests/ui/parser/issues/issue-60075.rs @@ -0,0 +1,11 @@ +fn main() {} + +trait T { + fn qux() -> Option<usize> { + let _ = if true { + }); +//~^ ERROR non-item in item list +//~| ERROR mismatched closing delimiter: `)` +//~| ERROR expected one of `.`, `;` + Some(4) + } diff --git a/tests/ui/parser/issues/issue-60075.stderr b/tests/ui/parser/issues/issue-60075.stderr new file mode 100644 index 000000000..210ef700c --- /dev/null +++ b/tests/ui/parser/issues/issue-60075.stderr @@ -0,0 +1,29 @@ +error: expected one of `.`, `;`, `?`, `else`, or an operator, found `}` + --> $DIR/issue-60075.rs:6:10 + | +LL | }); + | ^ expected one of `.`, `;`, `?`, `else`, or an operator + +error: non-item in item list + --> $DIR/issue-60075.rs:6:11 + | +LL | trait T { + | - item list starts here +... +LL | }); + | ^ non-item starts here +... +LL | } + | - item list ends here + +error: mismatched closing delimiter: `)` + --> $DIR/issue-60075.rs:4:31 + | +LL | fn qux() -> Option<usize> { + | ^ unclosed delimiter +LL | let _ = if true { +LL | }); + | ^ mismatched closing delimiter + +error: aborting due to 3 previous errors + diff --git a/tests/ui/parser/issues/issue-62524.rs b/tests/ui/parser/issues/issue-62524.rs new file mode 100644 index 000000000..5259dfe2e --- /dev/null +++ b/tests/ui/parser/issues/issue-62524.rs @@ -0,0 +1,6 @@ +// ignore-tidy-trailing-newlines +// error-pattern: aborting due to 3 previous errors +#![allow(uncommon_codepoints)] + +y![ +Ϥ,
\ No newline at end of file diff --git a/tests/ui/parser/issues/issue-62524.stderr b/tests/ui/parser/issues/issue-62524.stderr new file mode 100644 index 000000000..55eed0402 --- /dev/null +++ b/tests/ui/parser/issues/issue-62524.stderr @@ -0,0 +1,33 @@ +error: this file contains an unclosed delimiter + --> $DIR/issue-62524.rs:6:3 + | +LL | y![ + | - unclosed delimiter +LL | Ϥ, + | ^ + +error: macros that expand to items must be delimited with braces or followed by a semicolon + --> $DIR/issue-62524.rs:5:3 + | +LL | y![ + | ___^ +LL | | Ϥ, + | |__^ + | +help: change the delimiters to curly braces + | +LL | y! { /* items */ } + | ~~~~~~~~~~~~~~~ +help: add a semicolon + | +LL | Ϥ,; + | + + +error: cannot find macro `y` in this scope + --> $DIR/issue-62524.rs:5:1 + | +LL | y![ + | ^ + +error: aborting due to 3 previous errors + diff --git a/tests/ui/parser/issues/issue-62546.rs b/tests/ui/parser/issues/issue-62546.rs new file mode 100644 index 000000000..f06b65058 --- /dev/null +++ b/tests/ui/parser/issues/issue-62546.rs @@ -0,0 +1,3 @@ +pub t(# +//~^ ERROR missing `fn` or `struct` for function or struct definition +//~ ERROR this file contains an unclosed delimiter diff --git a/tests/ui/parser/issues/issue-62546.stderr b/tests/ui/parser/issues/issue-62546.stderr new file mode 100644 index 000000000..32c61391e --- /dev/null +++ b/tests/ui/parser/issues/issue-62546.stderr @@ -0,0 +1,17 @@ +error: this file contains an unclosed delimiter + --> $DIR/issue-62546.rs:3:52 + | +LL | pub t(# + | - unclosed delimiter +LL | +LL | + | ^ + +error: missing `fn` or `struct` for function or struct definition + --> $DIR/issue-62546.rs:1:4 + | +LL | pub t(# + | ---^- help: if you meant to call a macro, try: `t!` + +error: aborting due to 2 previous errors + diff --git a/tests/ui/parser/issues/issue-62554.rs b/tests/ui/parser/issues/issue-62554.rs new file mode 100644 index 000000000..cfd02183c --- /dev/null +++ b/tests/ui/parser/issues/issue-62554.rs @@ -0,0 +1,6 @@ +// error-pattern:this file contains an unclosed delimiter +// error-pattern:xpected `{`, found `macro_rules` + +fn main() {} + +fn foo(u: u8) { if u8 macro_rules! u8 { (u6) => { fn uuuuuuuuuuu() { use s loo mod u8 { diff --git a/tests/ui/parser/issues/issue-62554.stderr b/tests/ui/parser/issues/issue-62554.stderr new file mode 100644 index 000000000..9e62572e3 --- /dev/null +++ b/tests/ui/parser/issues/issue-62554.stderr @@ -0,0 +1,73 @@ +error: this file contains an unclosed delimiter + --> $DIR/issue-62554.rs:6:89 + | +LL | fn foo(u: u8) { if u8 macro_rules! u8 { (u6) => { fn uuuuuuuuuuu() { use s loo mod u8 { + | - - - - - ^ + | | | | | | + | | | | | unclosed delimiter + | | | | unclosed delimiter + | | | unclosed delimiter + | unclosed delimiter unclosed delimiter + +error: this file contains an unclosed delimiter + --> $DIR/issue-62554.rs:6:89 + | +LL | fn foo(u: u8) { if u8 macro_rules! u8 { (u6) => { fn uuuuuuuuuuu() { use s loo mod u8 { + | - - - - - ^ + | | | | | | + | | | | | unclosed delimiter + | | | | unclosed delimiter + | | | unclosed delimiter + | unclosed delimiter unclosed delimiter + +error: this file contains an unclosed delimiter + --> $DIR/issue-62554.rs:6:89 + | +LL | fn foo(u: u8) { if u8 macro_rules! u8 { (u6) => { fn uuuuuuuuuuu() { use s loo mod u8 { + | - - - - - ^ + | | | | | | + | | | | | unclosed delimiter + | | | | unclosed delimiter + | | | unclosed delimiter + | unclosed delimiter unclosed delimiter + +error: this file contains an unclosed delimiter + --> $DIR/issue-62554.rs:6:89 + | +LL | fn foo(u: u8) { if u8 macro_rules! u8 { (u6) => { fn uuuuuuuuuuu() { use s loo mod u8 { + | - - - - - ^ + | | | | | | + | | | | | unclosed delimiter + | | | | unclosed delimiter + | | | unclosed delimiter + | unclosed delimiter unclosed delimiter + +error: this file contains an unclosed delimiter + --> $DIR/issue-62554.rs:6:89 + | +LL | fn foo(u: u8) { if u8 macro_rules! u8 { (u6) => { fn uuuuuuuuuuu() { use s loo mod u8 { + | - - - - - ^ + | | | | | | + | | | | | unclosed delimiter + | | | | unclosed delimiter + | | | unclosed delimiter + | unclosed delimiter unclosed delimiter + +error: expected `{`, found `macro_rules` + --> $DIR/issue-62554.rs:6:23 + | +LL | fn foo(u: u8) { if u8 macro_rules! u8 { (u6) => { fn uuuuuuuuuuu() { use s loo mod u8 { + | ^^^^^^^^^^^ expected `{` + | +note: the `if` expression is missing a block after this condition + --> $DIR/issue-62554.rs:6:20 + | +LL | fn foo(u: u8) { if u8 macro_rules! u8 { (u6) => { fn uuuuuuuuuuu() { use s loo mod u8 { + | ^^ +help: try placing this code inside a block + | +LL | fn foo(u: u8) { if u8 { macro_rules! u8 { (u6) => { fn uuuuuuuuuuu() { use s loo mod u8 { } + | + + + +error: aborting due to 6 previous errors + diff --git a/tests/ui/parser/issues/issue-62660.rs b/tests/ui/parser/issues/issue-62660.rs new file mode 100644 index 000000000..33c8a9fa3 --- /dev/null +++ b/tests/ui/parser/issues/issue-62660.rs @@ -0,0 +1,11 @@ +// Regression test for issue #62660: if a receiver's type does not +// successfully parse, emit the correct error instead of ICE-ing the compiler. + +struct Foo; + +impl Foo { + pub fn foo(_: i32, self: Box<Self) {} + //~^ ERROR expected one of `!`, `(`, `+`, `,`, `::`, `<`, or `>`, found `)` +} + +fn main() {} diff --git a/tests/ui/parser/issues/issue-62660.stderr b/tests/ui/parser/issues/issue-62660.stderr new file mode 100644 index 000000000..14c0bdcb1 --- /dev/null +++ b/tests/ui/parser/issues/issue-62660.stderr @@ -0,0 +1,13 @@ +error: expected one of `!`, `(`, `+`, `,`, `::`, `<`, or `>`, found `)` + --> $DIR/issue-62660.rs:7:38 + | +LL | pub fn foo(_: i32, self: Box<Self) {} + | ^ expected one of 7 possible tokens + | +help: you might have meant to end the type parameters here + | +LL | pub fn foo(_: i32, self: Box<Self>) {} + | + + +error: aborting due to previous error + diff --git a/tests/ui/parser/issues/issue-62881.rs b/tests/ui/parser/issues/issue-62881.rs new file mode 100644 index 000000000..b9204595f --- /dev/null +++ b/tests/ui/parser/issues/issue-62881.rs @@ -0,0 +1,6 @@ +fn main() {} + +fn f() -> isize { fn f() -> isize {} pub f< +//~^ ERROR missing `fn` or `struct` for function or struct definition +//~| ERROR mismatched types +//~ ERROR this file contains an unclosed delimiter diff --git a/tests/ui/parser/issues/issue-62881.stderr b/tests/ui/parser/issues/issue-62881.stderr new file mode 100644 index 000000000..87be69baa --- /dev/null +++ b/tests/ui/parser/issues/issue-62881.stderr @@ -0,0 +1,26 @@ +error: this file contains an unclosed delimiter + --> $DIR/issue-62881.rs:6:52 + | +LL | fn f() -> isize { fn f() -> isize {} pub f< + | - unclosed delimiter +... +LL | + | ^ + +error: missing `fn` or `struct` for function or struct definition + --> $DIR/issue-62881.rs:3:41 + | +LL | fn f() -> isize { fn f() -> isize {} pub f< + | ^ + +error[E0308]: mismatched types + --> $DIR/issue-62881.rs:3:29 + | +LL | fn f() -> isize { fn f() -> isize {} pub f< + | - ^^^^^ expected `isize`, found `()` + | | + | implicitly returns `()` as its body has no tail or `return` expression + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/parser/issues/issue-62894.rs b/tests/ui/parser/issues/issue-62894.rs new file mode 100644 index 000000000..b9c0bf834 --- /dev/null +++ b/tests/ui/parser/issues/issue-62894.rs @@ -0,0 +1,7 @@ +// Regression test for #62894, shouldn't crash. +// error-pattern: this file contains an unclosed delimiter +// error-pattern: expected one of `(`, `[`, or `{`, found keyword `fn` + +fn f() { assert_eq!(f(), (), assert_eq!(assert_eq! + +fn main() {} diff --git a/tests/ui/parser/issues/issue-62894.stderr b/tests/ui/parser/issues/issue-62894.stderr new file mode 100644 index 000000000..07a203bf4 --- /dev/null +++ b/tests/ui/parser/issues/issue-62894.stderr @@ -0,0 +1,50 @@ +error: this file contains an unclosed delimiter + --> $DIR/issue-62894.rs:7:14 + | +LL | fn f() { assert_eq!(f(), (), assert_eq!(assert_eq! + | - - - unclosed delimiter + | | | + | | unclosed delimiter + | unclosed delimiter +LL | +LL | fn main() {} + | ^ + +error: this file contains an unclosed delimiter + --> $DIR/issue-62894.rs:7:14 + | +LL | fn f() { assert_eq!(f(), (), assert_eq!(assert_eq! + | - - - unclosed delimiter + | | | + | | unclosed delimiter + | unclosed delimiter +LL | +LL | fn main() {} + | ^ + +error: this file contains an unclosed delimiter + --> $DIR/issue-62894.rs:7:14 + | +LL | fn f() { assert_eq!(f(), (), assert_eq!(assert_eq! + | - - - unclosed delimiter + | | | + | | unclosed delimiter + | unclosed delimiter +LL | +LL | fn main() {} + | ^ + +error: expected one of `(`, `[`, or `{`, found keyword `fn` + --> $DIR/issue-62894.rs:7:1 + | +LL | fn f() { assert_eq!(f(), (), assert_eq!(assert_eq! + | - expected one of `(`, `[`, or `{` +LL | +LL | fn main() {} + | ^^ unexpected token + --> $SRC_DIR/core/src/macros/mod.rs:LL:COL + | + = note: while parsing argument for this `expr` macro fragment + +error: aborting due to 4 previous errors + diff --git a/tests/ui/parser/issues/issue-62895.rs b/tests/ui/parser/issues/issue-62895.rs new file mode 100644 index 000000000..53f17405d --- /dev/null +++ b/tests/ui/parser/issues/issue-62895.rs @@ -0,0 +1,11 @@ +fn main() {} + +fn v() -> isize { //~ ERROR mismatched types +mod _ { //~ ERROR expected identifier +pub fn g() -> isizee { //~ ERROR cannot find type `isizee` in this scope +mod _ { //~ ERROR expected identifier +pub g() -> is //~ ERROR missing `fn` for function definition +(), w20); +} +(), w20); //~ ERROR expected item, found `;` +} diff --git a/tests/ui/parser/issues/issue-62895.stderr b/tests/ui/parser/issues/issue-62895.stderr new file mode 100644 index 000000000..2e7e500f4 --- /dev/null +++ b/tests/ui/parser/issues/issue-62895.stderr @@ -0,0 +1,47 @@ +error: expected identifier, found reserved identifier `_` + --> $DIR/issue-62895.rs:4:5 + | +LL | mod _ { + | ^ expected identifier, found reserved identifier + +error: expected identifier, found reserved identifier `_` + --> $DIR/issue-62895.rs:6:5 + | +LL | mod _ { + | ^ expected identifier, found reserved identifier + +error: missing `fn` for function definition + --> $DIR/issue-62895.rs:7:4 + | +LL | pub g() -> is + | ^^^^ + | +help: add `fn` here to parse `g` as a public function + | +LL | pub fn g() -> is + | ++ + +error: expected item, found `;` + --> $DIR/issue-62895.rs:10:9 + | +LL | (), w20); + | ^ help: remove this semicolon + +error[E0412]: cannot find type `isizee` in this scope + --> $DIR/issue-62895.rs:5:15 + | +LL | pub fn g() -> isizee { + | ^^^^^^ help: a builtin type with a similar name exists: `isize` + +error[E0308]: mismatched types + --> $DIR/issue-62895.rs:3:11 + | +LL | fn v() -> isize { + | - ^^^^^ expected `isize`, found `()` + | | + | implicitly returns `()` as its body has no tail or `return` expression + +error: aborting due to 6 previous errors + +Some errors have detailed explanations: E0308, E0412. +For more information about an error, try `rustc --explain E0308`. diff --git a/tests/ui/parser/issues/issue-62913.rs b/tests/ui/parser/issues/issue-62913.rs new file mode 100644 index 000000000..0db06f636 --- /dev/null +++ b/tests/ui/parser/issues/issue-62913.rs @@ -0,0 +1,4 @@ +"\u\\" +//~^ ERROR incorrect unicode escape sequence +//~| ERROR invalid trailing slash in literal +//~| ERROR expected item, found `"\u\\"` diff --git a/tests/ui/parser/issues/issue-62913.stderr b/tests/ui/parser/issues/issue-62913.stderr new file mode 100644 index 000000000..6f385e8dc --- /dev/null +++ b/tests/ui/parser/issues/issue-62913.stderr @@ -0,0 +1,22 @@ +error: incorrect unicode escape sequence + --> $DIR/issue-62913.rs:1:2 + | +LL | "\u\" + | ^^^ incorrect unicode escape sequence + | + = help: format of unicode escape sequences is `\u{...}` + +error: invalid trailing slash in literal + --> $DIR/issue-62913.rs:1:5 + | +LL | "\u\" + | ^ invalid trailing slash in literal + +error: expected item, found `"\u\"` + --> $DIR/issue-62913.rs:1:1 + | +LL | "\u\" + | ^^^^^^ expected item + +error: aborting due to 3 previous errors + diff --git a/tests/ui/parser/issues/issue-62973.rs b/tests/ui/parser/issues/issue-62973.rs new file mode 100644 index 000000000..1c5d0c6f8 --- /dev/null +++ b/tests/ui/parser/issues/issue-62973.rs @@ -0,0 +1,8 @@ +// ignore-tidy-trailing-newlines +// error-pattern: aborting due to 7 previous errors + +fn main() {} + +fn p() { match s { v, E { [) {) } + + diff --git a/tests/ui/parser/issues/issue-62973.stderr b/tests/ui/parser/issues/issue-62973.stderr new file mode 100644 index 000000000..4737bc718 --- /dev/null +++ b/tests/ui/parser/issues/issue-62973.stderr @@ -0,0 +1,83 @@ +error: this file contains an unclosed delimiter + --> $DIR/issue-62973.rs:8:2 + | +LL | fn p() { match s { v, E { [) {) } + | - - unclosed delimiter + | | + | unclosed delimiter +LL | +LL | + | ^ + +error: this file contains an unclosed delimiter + --> $DIR/issue-62973.rs:8:2 + | +LL | fn p() { match s { v, E { [) {) } + | - - unclosed delimiter + | | + | unclosed delimiter +LL | +LL | + | ^ + +error: expected one of `,`, `:`, or `}`, found `{` + --> $DIR/issue-62973.rs:6:8 + | +LL | fn p() { match s { v, E { [) {) } + | ^ - ^ expected one of `,`, `:`, or `}` + | | | + | | while parsing this struct + | unclosed delimiter + | +help: `}` may belong here + | +LL | fn p() { match s { v, E} { [) {) } + | + +help: try naming a field + | +LL | fn p() { match s { v, E: E { [) {) } + | ++ + +error: struct literals are not allowed here + --> $DIR/issue-62973.rs:6:16 + | +LL | fn p() { match s { v, E { [) {) } + | ________________^ +LL | | +LL | | + | |_^ + | +help: surround the struct literal with parentheses + | +LL ~ fn p() { match (s { v, E { [) {) } +LL | +LL ~ ) + | + +error: expected one of `.`, `?`, `{`, or an operator, found `}` + --> $DIR/issue-62973.rs:8:2 + | +LL | fn p() { match s { v, E { [) {) } + | ----- while parsing this `match` expression +LL | +LL | + | ^ expected one of `.`, `?`, `{`, or an operator + +error: mismatched closing delimiter: `)` + --> $DIR/issue-62973.rs:6:27 + | +LL | fn p() { match s { v, E { [) {) } + | ^^ mismatched closing delimiter + | | + | unclosed delimiter + +error: mismatched closing delimiter: `)` + --> $DIR/issue-62973.rs:6:30 + | +LL | fn p() { match s { v, E { [) {) } + | ^^ mismatched closing delimiter + | | + | unclosed delimiter + +error: aborting due to 7 previous errors + diff --git a/tests/ui/parser/issues/issue-63115-range-pat-interpolated.rs b/tests/ui/parser/issues/issue-63115-range-pat-interpolated.rs new file mode 100644 index 000000000..b6e5091b6 --- /dev/null +++ b/tests/ui/parser/issues/issue-63115-range-pat-interpolated.rs @@ -0,0 +1,21 @@ +// check-pass + +#![feature(exclusive_range_pattern)] + +#![allow(ellipsis_inclusive_range_patterns)] + +fn main() { + macro_rules! mac_expr { + ($e:expr) => { + if let 2...$e = 3 {} + if let 2..=$e = 3 {} + if let 2..$e = 3 {} + if let ..$e = 3 {} + if let ..=$e = 3 {} + if let $e.. = 5 {} + if let $e..5 = 4 {} + if let $e..=5 = 4 {} + } + } + mac_expr!(4); +} diff --git a/tests/ui/parser/issues/issue-63116.rs b/tests/ui/parser/issues/issue-63116.rs new file mode 100644 index 000000000..430bc1d71 --- /dev/null +++ b/tests/ui/parser/issues/issue-63116.rs @@ -0,0 +1,3 @@ +// fixed by #66361 +// error-pattern: aborting due to 3 previous errors +impl W <s(f;Y(;] diff --git a/tests/ui/parser/issues/issue-63116.stderr b/tests/ui/parser/issues/issue-63116.stderr new file mode 100644 index 000000000..cfdd99d14 --- /dev/null +++ b/tests/ui/parser/issues/issue-63116.stderr @@ -0,0 +1,24 @@ +error: this file contains an unclosed delimiter + --> $DIR/issue-63116.rs:3:18 + | +LL | impl W <s(f;Y(;] + | - ^ + | | + | unclosed delimiter + +error: expected one of `!`, `(`, `)`, `+`, `,`, `::`, or `<`, found `;` + --> $DIR/issue-63116.rs:3:12 + | +LL | impl W <s(f;Y(;] + | ^ expected one of 7 possible tokens + +error: mismatched closing delimiter: `]` + --> $DIR/issue-63116.rs:3:14 + | +LL | impl W <s(f;Y(;] + | ^ ^ mismatched closing delimiter + | | + | unclosed delimiter + +error: aborting due to 3 previous errors + diff --git a/tests/ui/parser/issues/issue-63135.rs b/tests/ui/parser/issues/issue-63135.rs new file mode 100644 index 000000000..a5a8de854 --- /dev/null +++ b/tests/ui/parser/issues/issue-63135.rs @@ -0,0 +1,3 @@ +// error-pattern: aborting due to 5 previous errors + +fn i(n{...,f # diff --git a/tests/ui/parser/issues/issue-63135.stderr b/tests/ui/parser/issues/issue-63135.stderr new file mode 100644 index 000000000..80e9ac5be --- /dev/null +++ b/tests/ui/parser/issues/issue-63135.stderr @@ -0,0 +1,43 @@ +error: this file contains an unclosed delimiter + --> $DIR/issue-63135.rs:3:16 + | +LL | fn i(n{...,f # + | - - ^ + | | | + | | unclosed delimiter + | unclosed delimiter + +error: this file contains an unclosed delimiter + --> $DIR/issue-63135.rs:3:16 + | +LL | fn i(n{...,f # + | - - ^ + | | | + | | unclosed delimiter + | unclosed delimiter + +error: expected field pattern, found `...` + --> $DIR/issue-63135.rs:3:8 + | +LL | fn i(n{...,f # + | ^^^ help: to omit remaining fields, use one fewer `.`: `..` + +error: expected `}`, found `,` + --> $DIR/issue-63135.rs:3:11 + | +LL | fn i(n{...,f # + | ---^ + | | | + | | expected `}` + | `..` must be at the end and cannot have a trailing comma + +error: expected one of `!` or `[`, found `}` + --> $DIR/issue-63135.rs:3:16 + | +LL | fn i(n{...,f # + | - ^ expected one of `!` or `[` + | | + | while parsing the fields for this pattern + +error: aborting due to 5 previous errors + diff --git a/tests/ui/parser/issues/issue-64732.rs b/tests/ui/parser/issues/issue-64732.rs new file mode 100644 index 000000000..2db51ea60 --- /dev/null +++ b/tests/ui/parser/issues/issue-64732.rs @@ -0,0 +1,9 @@ +#![allow(unused)] +fn main() { + let _foo = b'hello\0'; + //~^ ERROR character literal may only contain one codepoint + //~| HELP if you meant to write a byte string literal, use double quotes + let _bar = 'hello'; + //~^ ERROR character literal may only contain one codepoint + //~| HELP if you meant to write a `str` literal, use double quotes +} diff --git a/tests/ui/parser/issues/issue-64732.stderr b/tests/ui/parser/issues/issue-64732.stderr new file mode 100644 index 000000000..804625493 --- /dev/null +++ b/tests/ui/parser/issues/issue-64732.stderr @@ -0,0 +1,24 @@ +error: character literal may only contain one codepoint + --> $DIR/issue-64732.rs:3:16 + | +LL | let _foo = b'hello\0'; + | ^^^^^^^^^^ + | +help: if you meant to write a byte string literal, use double quotes + | +LL | let _foo = b"hello\0"; + | ~~~~~~~~~~ + +error: character literal may only contain one codepoint + --> $DIR/issue-64732.rs:6:16 + | +LL | let _bar = 'hello'; + | ^^^^^^^ + | +help: if you meant to write a `str` literal, use double quotes + | +LL | let _bar = "hello"; + | ~~~~~~~ + +error: aborting due to 2 previous errors + diff --git a/tests/ui/parser/issues/issue-65041-empty-vis-matcher-in-enum.rs b/tests/ui/parser/issues/issue-65041-empty-vis-matcher-in-enum.rs new file mode 100644 index 000000000..ef89e31d8 --- /dev/null +++ b/tests/ui/parser/issues/issue-65041-empty-vis-matcher-in-enum.rs @@ -0,0 +1,28 @@ +// check-pass + +// Here we check that a `:vis` macro matcher subsititued for the empty visibility +// (`VisibilityKind::Inherited`) is accepted when used before an enum variant. + +fn main() {} + +macro_rules! mac_variant { + ($vis:vis MARKER) => { + enum Enum { + $vis Unit, + + $vis Tuple(u8, u16), + + $vis Struct { f: u8 }, + } + } +} + +mac_variant!(MARKER); + +// We also accept visibilities on variants syntactically but not semantically. +#[cfg(FALSE)] +enum E { + pub U, + pub(crate) T(u8), + pub(super) T { f: String } +} diff --git a/tests/ui/parser/issues/issue-65041-empty-vis-matcher-in-trait.rs b/tests/ui/parser/issues/issue-65041-empty-vis-matcher-in-trait.rs new file mode 100644 index 000000000..b08767b21 --- /dev/null +++ b/tests/ui/parser/issues/issue-65041-empty-vis-matcher-in-trait.rs @@ -0,0 +1,28 @@ +// check-pass + +// Here we check that a `:vis` macro matcher subsititued for the empty visibility +// (`VisibilityKind::Inherited`) is accepted when used before an item in a trait. + +fn main() {} + +macro_rules! mac_in_trait { + ($vis:vis MARKER) => { + $vis fn beta() {} + + $vis const GAMMA: u8; + + $vis type Delta; + } +} + +trait Alpha { + mac_in_trait!(MARKER); +} + +// We also accept visibilities on items in traits syntactically but not semantically. +#[cfg(FALSE)] +trait Foo { + pub fn bar(); + pub(crate) type baz; + pub(super) const QUUX: u8; +} diff --git a/tests/ui/parser/issues/issue-65122-mac-invoc-in-mut-patterns.rs b/tests/ui/parser/issues/issue-65122-mac-invoc-in-mut-patterns.rs new file mode 100644 index 000000000..30f3781bf --- /dev/null +++ b/tests/ui/parser/issues/issue-65122-mac-invoc-in-mut-patterns.rs @@ -0,0 +1,26 @@ +// Regression test; used to ICE with 'visit_mac_call disabled by default' due to a +// `MutVisitor` in `fn make_all_value_bindings_mutable` (`parse/parser/pat.rs`). + +macro_rules! mac1 { + ($eval:expr) => { + let mut $eval = (); + //~^ ERROR `mut` must be followed by a named binding + }; +} + +macro_rules! mac2 { + ($eval:pat) => { + let mut $eval = (); + //~^ ERROR `mut` must be followed by a named binding + //~| ERROR expected identifier, found `does_not_exist!()` + }; +} + +fn foo() { + mac1! { does_not_exist!() } + //~^ ERROR cannot find macro `does_not_exist` in this scope + mac2! { does_not_exist!() } + //~^ ERROR cannot find macro `does_not_exist` in this scope +} + +fn main() {} diff --git a/tests/ui/parser/issues/issue-65122-mac-invoc-in-mut-patterns.stderr b/tests/ui/parser/issues/issue-65122-mac-invoc-in-mut-patterns.stderr new file mode 100644 index 000000000..8c032e588 --- /dev/null +++ b/tests/ui/parser/issues/issue-65122-mac-invoc-in-mut-patterns.stderr @@ -0,0 +1,49 @@ +error: `mut` must be followed by a named binding + --> $DIR/issue-65122-mac-invoc-in-mut-patterns.rs:6:13 + | +LL | let mut $eval = (); + | ^^^^^^^^^ help: remove the `mut` prefix: `does_not_exist!()` +... +LL | mac1! { does_not_exist!() } + | --------------------------- in this macro invocation + | + = note: `mut` may be followed by `variable` and `variable @ pattern` + = note: this error originates in the macro `mac1` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: expected identifier, found `does_not_exist!()` + --> $DIR/issue-65122-mac-invoc-in-mut-patterns.rs:13:17 + | +LL | let mut $eval = (); + | ^^^^^ expected identifier +... +LL | mac2! { does_not_exist!() } + | --------------------------- in this macro invocation + | + = note: this error originates in the macro `mac2` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: `mut` must be followed by a named binding + --> $DIR/issue-65122-mac-invoc-in-mut-patterns.rs:13:13 + | +LL | let mut $eval = (); + | ^^^ help: remove the `mut` prefix: `does_not_exist!()` +... +LL | mac2! { does_not_exist!() } + | --------------------------- in this macro invocation + | + = note: `mut` may be followed by `variable` and `variable @ pattern` + = note: this error originates in the macro `mac2` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: cannot find macro `does_not_exist` in this scope + --> $DIR/issue-65122-mac-invoc-in-mut-patterns.rs:22:13 + | +LL | mac2! { does_not_exist!() } + | ^^^^^^^^^^^^^^ + +error: cannot find macro `does_not_exist` in this scope + --> $DIR/issue-65122-mac-invoc-in-mut-patterns.rs:20:13 + | +LL | mac1! { does_not_exist!() } + | ^^^^^^^^^^^^^^ + +error: aborting due to 5 previous errors + diff --git a/tests/ui/parser/issues/issue-65257-invalid-var-decl-recovery.rs b/tests/ui/parser/issues/issue-65257-invalid-var-decl-recovery.rs new file mode 100644 index 000000000..c1826f8ca --- /dev/null +++ b/tests/ui/parser/issues/issue-65257-invalid-var-decl-recovery.rs @@ -0,0 +1,21 @@ +fn main() { + auto n = 0;//~ ERROR invalid variable declaration + //~^ HELP write `let` instead of `auto` to introduce a new variable + auto m;//~ ERROR invalid variable declaration + //~^ HELP write `let` instead of `auto` to introduce a new variable + m = 0; + + var n = 0;//~ ERROR invalid variable declaration + //~^ HELP write `let` instead of `var` to introduce a new variable + var m;//~ ERROR invalid variable declaration + //~^ HELP write `let` instead of `var` to introduce a new variable + m = 0; + + mut n = 0;//~ ERROR invalid variable declaration + //~^ HELP missing keyword + mut var;//~ ERROR invalid variable declaration + //~^ HELP missing keyword + var = 0; + + let _recovery_witness: () = 0; //~ ERROR mismatched types +} diff --git a/tests/ui/parser/issues/issue-65257-invalid-var-decl-recovery.stderr b/tests/ui/parser/issues/issue-65257-invalid-var-decl-recovery.stderr new file mode 100644 index 000000000..0a88dd2c4 --- /dev/null +++ b/tests/ui/parser/issues/issue-65257-invalid-var-decl-recovery.stderr @@ -0,0 +1,67 @@ +error: invalid variable declaration + --> $DIR/issue-65257-invalid-var-decl-recovery.rs:2:5 + | +LL | auto n = 0; + | ^^^^ + | +help: write `let` instead of `auto` to introduce a new variable + | +LL | let n = 0; + | ~~~ + +error: invalid variable declaration + --> $DIR/issue-65257-invalid-var-decl-recovery.rs:4:5 + | +LL | auto m; + | ^^^^ + | +help: write `let` instead of `auto` to introduce a new variable + | +LL | let m; + | ~~~ + +error: invalid variable declaration + --> $DIR/issue-65257-invalid-var-decl-recovery.rs:8:5 + | +LL | var n = 0; + | ^^^ + | +help: write `let` instead of `var` to introduce a new variable + | +LL | let n = 0; + | ~~~ + +error: invalid variable declaration + --> $DIR/issue-65257-invalid-var-decl-recovery.rs:10:5 + | +LL | var m; + | ^^^ + | +help: write `let` instead of `var` to introduce a new variable + | +LL | let m; + | ~~~ + +error: invalid variable declaration + --> $DIR/issue-65257-invalid-var-decl-recovery.rs:14:5 + | +LL | mut n = 0; + | ^^^ help: missing keyword: `let mut` + +error: invalid variable declaration + --> $DIR/issue-65257-invalid-var-decl-recovery.rs:16:5 + | +LL | mut var; + | ^^^ help: missing keyword: `let mut` + +error[E0308]: mismatched types + --> $DIR/issue-65257-invalid-var-decl-recovery.rs:20:33 + | +LL | let _recovery_witness: () = 0; + | -- ^ expected `()`, found integer + | | + | expected due to this + +error: aborting due to 7 previous errors + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/parser/issues/issue-65846-rollback-gating-failing-matcher.rs b/tests/ui/parser/issues/issue-65846-rollback-gating-failing-matcher.rs new file mode 100644 index 000000000..76c07bbfd --- /dev/null +++ b/tests/ui/parser/issues/issue-65846-rollback-gating-failing-matcher.rs @@ -0,0 +1,15 @@ +// run-pass + +// Test that failing macro matchers will not cause pre-expansion errors +// even though they use a feature that is pre-expansion gated. + +#[allow(unused_macro_rules)] +macro_rules! m { + ($e:expr) => { 0 }; // This fails on the input below due to `, foo`. + ($e:expr,) => { 1 }; // This also fails to match due to `foo`. + (box $e:expr, foo) => { 2 }; // Successful matcher, we should get `2`. +} + +fn main() { + assert_eq!(2, m!(box 42, foo)); +} diff --git a/tests/ui/parser/issues/issue-6610.rs b/tests/ui/parser/issues/issue-6610.rs new file mode 100644 index 000000000..9ed5a6122 --- /dev/null +++ b/tests/ui/parser/issues/issue-6610.rs @@ -0,0 +1,3 @@ +trait Foo { fn a() } //~ ERROR expected one of `->`, `;`, `where`, or `{`, found `}` + +fn main() {} diff --git a/tests/ui/parser/issues/issue-6610.stderr b/tests/ui/parser/issues/issue-6610.stderr new file mode 100644 index 000000000..4a3bc7525 --- /dev/null +++ b/tests/ui/parser/issues/issue-6610.stderr @@ -0,0 +1,10 @@ +error: expected one of `->`, `;`, `where`, or `{`, found `}` + --> $DIR/issue-6610.rs:1:20 + | +LL | trait Foo { fn a() } + | - ^ expected one of `->`, `;`, `where`, or `{` + | | + | while parsing this `fn` + +error: aborting due to previous error + diff --git a/tests/ui/parser/issues/issue-66357-unexpected-unreachable.rs b/tests/ui/parser/issues/issue-66357-unexpected-unreachable.rs new file mode 100644 index 000000000..aed428bfc --- /dev/null +++ b/tests/ui/parser/issues/issue-66357-unexpected-unreachable.rs @@ -0,0 +1,14 @@ +// The problem in #66357 was that the call trace: +// +// - parse_fn_block_decl +// - expect_or +// - unexpected +// - expect_one_of +// - expected_one_of_not_found +// - recover_closing_delimiter +// +// ended up bubbling up `Ok(true)` to `unexpected` which then used `unreachable!()`. + +fn f() { |[](* } +//~^ ERROR expected one of `,` or `:`, found `(` +//~| ERROR expected one of `&`, `(`, `)`, `-`, `...`, `..=`, `..`, `[`, `_`, `box`, `mut`, `ref`, `|`, identifier, or path, found `*` diff --git a/tests/ui/parser/issues/issue-66357-unexpected-unreachable.stderr b/tests/ui/parser/issues/issue-66357-unexpected-unreachable.stderr new file mode 100644 index 000000000..6cbab855c --- /dev/null +++ b/tests/ui/parser/issues/issue-66357-unexpected-unreachable.stderr @@ -0,0 +1,16 @@ +error: expected one of `,` or `:`, found `(` + --> $DIR/issue-66357-unexpected-unreachable.rs:12:13 + | +LL | fn f() { |[](* } + | ^ expected one of `,` or `:` + +error: expected one of `&`, `(`, `)`, `-`, `...`, `..=`, `..`, `[`, `_`, `box`, `mut`, `ref`, `|`, identifier, or path, found `*` + --> $DIR/issue-66357-unexpected-unreachable.rs:12:13 + | +LL | fn f() { |[](* } + | ^^ help: `)` may belong here + | | + | unclosed delimiter + +error: aborting due to 2 previous errors + diff --git a/tests/ui/parser/issues/issue-66473.rs b/tests/ui/parser/issues/issue-66473.rs Binary files differnew file mode 100644 index 000000000..9db4521bb --- /dev/null +++ b/tests/ui/parser/issues/issue-66473.rs diff --git a/tests/ui/parser/issues/issue-66473.stderr b/tests/ui/parser/issues/issue-66473.stderr Binary files differnew file mode 100644 index 000000000..0e8b0a5da --- /dev/null +++ b/tests/ui/parser/issues/issue-66473.stderr diff --git a/tests/ui/parser/issues/issue-67146-negative-outlives-bound-syntactic-fail.fixed b/tests/ui/parser/issues/issue-67146-negative-outlives-bound-syntactic-fail.fixed new file mode 100644 index 000000000..95019b278 --- /dev/null +++ b/tests/ui/parser/issues/issue-67146-negative-outlives-bound-syntactic-fail.fixed @@ -0,0 +1,14 @@ +// run-rustfix + +// In this regression test for #67146, we check that the +// negative outlives bound `!'a` is rejected by the parser. +// This regression was first introduced in PR #57364. + +fn main() {} + +pub fn f1<T>() {} +//~^ ERROR negative bounds are not supported +pub fn f2<'a, T: Ord>() {} +//~^ ERROR negative bounds are not supported +pub fn f3<'a, T: Ord>() {} +//~^ ERROR negative bounds are not supported diff --git a/tests/ui/parser/issues/issue-67146-negative-outlives-bound-syntactic-fail.rs b/tests/ui/parser/issues/issue-67146-negative-outlives-bound-syntactic-fail.rs new file mode 100644 index 000000000..82f54f8fa --- /dev/null +++ b/tests/ui/parser/issues/issue-67146-negative-outlives-bound-syntactic-fail.rs @@ -0,0 +1,14 @@ +// run-rustfix + +// In this regression test for #67146, we check that the +// negative outlives bound `!'a` is rejected by the parser. +// This regression was first introduced in PR #57364. + +fn main() {} + +pub fn f1<T: !'static>() {} +//~^ ERROR negative bounds are not supported +pub fn f2<'a, T: Ord + !'a>() {} +//~^ ERROR negative bounds are not supported +pub fn f3<'a, T: !'a + Ord>() {} +//~^ ERROR negative bounds are not supported diff --git a/tests/ui/parser/issues/issue-67146-negative-outlives-bound-syntactic-fail.stderr b/tests/ui/parser/issues/issue-67146-negative-outlives-bound-syntactic-fail.stderr new file mode 100644 index 000000000..a4a422948 --- /dev/null +++ b/tests/ui/parser/issues/issue-67146-negative-outlives-bound-syntactic-fail.stderr @@ -0,0 +1,20 @@ +error: negative bounds are not supported + --> $DIR/issue-67146-negative-outlives-bound-syntactic-fail.rs:9:12 + | +LL | pub fn f1<T: !'static>() {} + | ^^^^^^^^^^ negative bounds are not supported + +error: negative bounds are not supported + --> $DIR/issue-67146-negative-outlives-bound-syntactic-fail.rs:11:22 + | +LL | pub fn f2<'a, T: Ord + !'a>() {} + | ^^^^^ negative bounds are not supported + +error: negative bounds are not supported + --> $DIR/issue-67146-negative-outlives-bound-syntactic-fail.rs:13:16 + | +LL | pub fn f3<'a, T: !'a + Ord>() {} + | ^^^^^ negative bounds are not supported + +error: aborting due to 3 previous errors + diff --git a/tests/ui/parser/issues/issue-67377-invalid-syntax-in-enum-discriminant.rs b/tests/ui/parser/issues/issue-67377-invalid-syntax-in-enum-discriminant.rs new file mode 100644 index 000000000..87222ef4b --- /dev/null +++ b/tests/ui/parser/issues/issue-67377-invalid-syntax-in-enum-discriminant.rs @@ -0,0 +1,35 @@ +mod a { + use std::marker::PhantomData; + + enum Bug { + V = [PhantomData; { [ () ].len() ].len() as isize, + //~^ ERROR mismatched closing delimiter: `]` + //~| ERROR mismatched closing delimiter: `]` + //~| ERROR mismatched closing delimiter: `]` + //~| ERROR mismatched closing delimiter: `]` + } +} + +mod b { + enum Bug { + V = [Vec::new; { [].len() ].len() as isize, + //~^ ERROR mismatched closing delimiter: `]` + //~| ERROR mismatched closing delimiter: `]` + //~| ERROR mismatched closing delimiter: `]` + //~| ERROR mismatched closing delimiter: `]` + //~| ERROR type annotations needed + } +} + +mod c { + enum Bug { + V = [Vec::new; { [0].len() ].len() as isize, + //~^ ERROR mismatched closing delimiter: `]` + //~| ERROR mismatched closing delimiter: `]` + //~| ERROR mismatched closing delimiter: `]` + //~| ERROR mismatched closing delimiter: `]` + //~| ERROR type annotations needed + } +} + +fn main() {} diff --git a/tests/ui/parser/issues/issue-67377-invalid-syntax-in-enum-discriminant.stderr b/tests/ui/parser/issues/issue-67377-invalid-syntax-in-enum-discriminant.stderr new file mode 100644 index 000000000..a00f37ed6 --- /dev/null +++ b/tests/ui/parser/issues/issue-67377-invalid-syntax-in-enum-discriminant.stderr @@ -0,0 +1,128 @@ +error: mismatched closing delimiter: `]` + --> $DIR/issue-67377-invalid-syntax-in-enum-discriminant.rs:5:27 + | +LL | V = [PhantomData; { [ () ].len() ].len() as isize, + | - ^ ^ mismatched closing delimiter + | | | + | | unclosed delimiter + | closing delimiter possibly meant for this + +error: mismatched closing delimiter: `]` + --> $DIR/issue-67377-invalid-syntax-in-enum-discriminant.rs:15:24 + | +LL | V = [Vec::new; { [].len() ].len() as isize, + | - ^ ^ mismatched closing delimiter + | | | + | | unclosed delimiter + | closing delimiter possibly meant for this + +error: mismatched closing delimiter: `]` + --> $DIR/issue-67377-invalid-syntax-in-enum-discriminant.rs:26:24 + | +LL | V = [Vec::new; { [0].len() ].len() as isize, + | - ^ ^ mismatched closing delimiter + | | | + | | unclosed delimiter + | closing delimiter possibly meant for this + +error: mismatched closing delimiter: `]` + --> $DIR/issue-67377-invalid-syntax-in-enum-discriminant.rs:5:27 + | +LL | V = [PhantomData; { [ () ].len() ].len() as isize, + | - ^ ^ mismatched closing delimiter + | | | + | | unclosed delimiter + | closing delimiter possibly meant for this + +error: mismatched closing delimiter: `]` + --> $DIR/issue-67377-invalid-syntax-in-enum-discriminant.rs:15:24 + | +LL | V = [Vec::new; { [].len() ].len() as isize, + | - ^ ^ mismatched closing delimiter + | | | + | | unclosed delimiter + | closing delimiter possibly meant for this + +error: mismatched closing delimiter: `]` + --> $DIR/issue-67377-invalid-syntax-in-enum-discriminant.rs:26:24 + | +LL | V = [Vec::new; { [0].len() ].len() as isize, + | - ^ ^ mismatched closing delimiter + | | | + | | unclosed delimiter + | closing delimiter possibly meant for this + +error: mismatched closing delimiter: `]` + --> $DIR/issue-67377-invalid-syntax-in-enum-discriminant.rs:5:27 + | +LL | V = [PhantomData; { [ () ].len() ].len() as isize, + | - ^ ^ mismatched closing delimiter + | | | + | | unclosed delimiter + | closing delimiter possibly meant for this + +error: mismatched closing delimiter: `]` + --> $DIR/issue-67377-invalid-syntax-in-enum-discriminant.rs:15:24 + | +LL | V = [Vec::new; { [].len() ].len() as isize, + | - ^ ^ mismatched closing delimiter + | | | + | | unclosed delimiter + | closing delimiter possibly meant for this + +error: mismatched closing delimiter: `]` + --> $DIR/issue-67377-invalid-syntax-in-enum-discriminant.rs:26:24 + | +LL | V = [Vec::new; { [0].len() ].len() as isize, + | - ^ ^ mismatched closing delimiter + | | | + | | unclosed delimiter + | closing delimiter possibly meant for this + +error: mismatched closing delimiter: `]` + --> $DIR/issue-67377-invalid-syntax-in-enum-discriminant.rs:5:27 + | +LL | V = [PhantomData; { [ () ].len() ].len() as isize, + | - ^ ^ mismatched closing delimiter + | | | + | | unclosed delimiter + | closing delimiter possibly meant for this + +error: mismatched closing delimiter: `]` + --> $DIR/issue-67377-invalid-syntax-in-enum-discriminant.rs:15:24 + | +LL | V = [Vec::new; { [].len() ].len() as isize, + | - ^ ^ mismatched closing delimiter + | | | + | | unclosed delimiter + | closing delimiter possibly meant for this + +error: mismatched closing delimiter: `]` + --> $DIR/issue-67377-invalid-syntax-in-enum-discriminant.rs:26:24 + | +LL | V = [Vec::new; { [0].len() ].len() as isize, + | - ^ ^ mismatched closing delimiter + | | | + | | unclosed delimiter + | closing delimiter possibly meant for this + +error[E0282]: type annotations needed + --> $DIR/issue-67377-invalid-syntax-in-enum-discriminant.rs:15:26 + | +LL | V = [Vec::new; { [].len() ].len() as isize, + | ^^ cannot infer type for type parameter `T` + +error[E0282]: type annotations needed + --> $DIR/issue-67377-invalid-syntax-in-enum-discriminant.rs:26:14 + | +LL | V = [Vec::new; { [0].len() ].len() as isize, + | ^^^^^^^^ cannot infer type of the type parameter `T` declared on the struct `Vec` + | +help: consider specifying the generic argument + | +LL | V = [Vec::<T>::new; { [0].len() ].len() as isize, + | +++++ + +error: aborting due to 14 previous errors + +For more information about this error, try `rustc --explain E0282`. diff --git a/tests/ui/parser/issues/issue-68000-unicode-ident-after-missing-comma.rs b/tests/ui/parser/issues/issue-68000-unicode-ident-after-missing-comma.rs new file mode 100644 index 000000000..3c49a5a97 --- /dev/null +++ b/tests/ui/parser/issues/issue-68000-unicode-ident-after-missing-comma.rs @@ -0,0 +1,6 @@ +pub struct Foo { + pub bar: Vec<i32>ö + //~^ ERROR expected `,`, or `}`, found `ö` +} //~ ERROR expected `:`, found `}` + +fn main() {} diff --git a/tests/ui/parser/issues/issue-68000-unicode-ident-after-missing-comma.stderr b/tests/ui/parser/issues/issue-68000-unicode-ident-after-missing-comma.stderr new file mode 100644 index 000000000..adabb6859 --- /dev/null +++ b/tests/ui/parser/issues/issue-68000-unicode-ident-after-missing-comma.stderr @@ -0,0 +1,19 @@ +error: expected `,`, or `}`, found `ö` + --> $DIR/issue-68000-unicode-ident-after-missing-comma.rs:2:22 + | +LL | pub bar: Vec<i32>ö + | ^ help: try adding a comma: `,` + +error: expected `:`, found `}` + --> $DIR/issue-68000-unicode-ident-after-missing-comma.rs:4:1 + | +LL | pub struct Foo { + | --- while parsing this struct +LL | pub bar: Vec<i32>ö + | - expected `:` +LL | +LL | } + | ^ unexpected token + +error: aborting due to 2 previous errors + diff --git a/tests/ui/parser/issues/issue-68629.rs b/tests/ui/parser/issues/issue-68629.rs Binary files differnew file mode 100644 index 000000000..672a31f12 --- /dev/null +++ b/tests/ui/parser/issues/issue-68629.rs diff --git a/tests/ui/parser/issues/issue-68629.stderr b/tests/ui/parser/issues/issue-68629.stderr Binary files differnew file mode 100644 index 000000000..43a903e6c --- /dev/null +++ b/tests/ui/parser/issues/issue-68629.stderr diff --git a/tests/ui/parser/issues/issue-68730.rs b/tests/ui/parser/issues/issue-68730.rs Binary files differnew file mode 100644 index 000000000..20e18b4bc --- /dev/null +++ b/tests/ui/parser/issues/issue-68730.rs diff --git a/tests/ui/parser/issues/issue-68730.stderr b/tests/ui/parser/issues/issue-68730.stderr Binary files differnew file mode 100644 index 000000000..5bca5bbeb --- /dev/null +++ b/tests/ui/parser/issues/issue-68730.stderr diff --git a/tests/ui/parser/issues/issue-68788-in-trait-item-propagation.rs b/tests/ui/parser/issues/issue-68788-in-trait-item-propagation.rs new file mode 100644 index 000000000..7c3dd1d5a --- /dev/null +++ b/tests/ui/parser/issues/issue-68788-in-trait-item-propagation.rs @@ -0,0 +1,21 @@ +// Make sure we don't propagate restrictions on trait impl items to items inside them. + +// check-pass +// edition:2018 + +fn main() {} + +trait X { + fn foo(); +} + +impl X for () { + fn foo() { + struct S; + impl S { + pub const X: u8 = 0; + pub const fn bar() {} + async fn qux() {} + } + } +} diff --git a/tests/ui/parser/issues/issue-68890-2.rs b/tests/ui/parser/issues/issue-68890-2.rs new file mode 100644 index 000000000..29c123521 --- /dev/null +++ b/tests/ui/parser/issues/issue-68890-2.rs @@ -0,0 +1,5 @@ +fn main() {} + +type X<'a> = (?'a) +; +//~^ ERROR `?` may only modify trait bounds, not lifetime bounds +//~| ERROR at least one trait is required for an object type diff --git a/tests/ui/parser/issues/issue-68890-2.stderr b/tests/ui/parser/issues/issue-68890-2.stderr new file mode 100644 index 000000000..d9fb7beeb --- /dev/null +++ b/tests/ui/parser/issues/issue-68890-2.stderr @@ -0,0 +1,15 @@ +error: `?` may only modify trait bounds, not lifetime bounds + --> $DIR/issue-68890-2.rs:3:15 + | +LL | type X<'a> = (?'a) +; + | ^ + +error[E0224]: at least one trait is required for an object type + --> $DIR/issue-68890-2.rs:3:14 + | +LL | type X<'a> = (?'a) +; + | ^^^^^^^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0224`. diff --git a/tests/ui/parser/issues/issue-68890.rs b/tests/ui/parser/issues/issue-68890.rs new file mode 100644 index 000000000..bab4ed7f8 --- /dev/null +++ b/tests/ui/parser/issues/issue-68890.rs @@ -0,0 +1,4 @@ +enum e{A((?'a a+?+l))} +//~^ ERROR `?` may only modify trait bounds, not lifetime bounds +//~| ERROR expected one of `)`, `+`, or `,` +//~| ERROR expected item, found `)` diff --git a/tests/ui/parser/issues/issue-68890.stderr b/tests/ui/parser/issues/issue-68890.stderr new file mode 100644 index 000000000..2a3bf6b41 --- /dev/null +++ b/tests/ui/parser/issues/issue-68890.stderr @@ -0,0 +1,20 @@ +error: `?` may only modify trait bounds, not lifetime bounds + --> $DIR/issue-68890.rs:1:11 + | +LL | enum e{A((?'a a+?+l))} + | ^ + +error: expected one of `)`, `+`, or `,`, found `a` + --> $DIR/issue-68890.rs:1:15 + | +LL | enum e{A((?'a a+?+l))} + | ^ expected one of `)`, `+`, or `,` + +error: expected item, found `)` + --> $DIR/issue-68890.rs:1:21 + | +LL | enum e{A((?'a a+?+l))} + | ^ expected item + +error: aborting due to 3 previous errors + diff --git a/tests/ui/parser/issues/issue-70050-ntliteral-accepts-negated-lit.rs b/tests/ui/parser/issues/issue-70050-ntliteral-accepts-negated-lit.rs new file mode 100644 index 000000000..aca9d9eb0 --- /dev/null +++ b/tests/ui/parser/issues/issue-70050-ntliteral-accepts-negated-lit.rs @@ -0,0 +1,16 @@ +// check-pass + +macro_rules! foo { + ($a:literal) => { + bar!($a) + }; +} + +macro_rules! bar { + ($b:literal) => {}; +} + +fn main() { + foo!(-2); + bar!(-2); +} diff --git a/tests/ui/parser/issues/issue-70388-recover-dotdotdot-rest-pat.rs b/tests/ui/parser/issues/issue-70388-recover-dotdotdot-rest-pat.rs new file mode 100644 index 000000000..ca8abd78c --- /dev/null +++ b/tests/ui/parser/issues/issue-70388-recover-dotdotdot-rest-pat.rs @@ -0,0 +1,7 @@ +struct Foo(i32); + +fn main() { + let Foo(...) = Foo(0); //~ ERROR unexpected `...` + let [_, ..., _] = [0, 1]; //~ ERROR unexpected `...` + let _recovery_witness: () = 0; //~ ERROR mismatched types +} diff --git a/tests/ui/parser/issues/issue-70388-recover-dotdotdot-rest-pat.stderr b/tests/ui/parser/issues/issue-70388-recover-dotdotdot-rest-pat.stderr new file mode 100644 index 000000000..4961e8fc0 --- /dev/null +++ b/tests/ui/parser/issues/issue-70388-recover-dotdotdot-rest-pat.stderr @@ -0,0 +1,29 @@ +error: unexpected `...` + --> $DIR/issue-70388-recover-dotdotdot-rest-pat.rs:4:13 + | +LL | let Foo(...) = Foo(0); + | ^^^ + | | + | not a valid pattern + | help: for a rest pattern, use `..` instead of `...` + +error: unexpected `...` + --> $DIR/issue-70388-recover-dotdotdot-rest-pat.rs:5:13 + | +LL | let [_, ..., _] = [0, 1]; + | ^^^ + | | + | not a valid pattern + | help: for a rest pattern, use `..` instead of `...` + +error[E0308]: mismatched types + --> $DIR/issue-70388-recover-dotdotdot-rest-pat.rs:6:33 + | +LL | let _recovery_witness: () = 0; + | -- ^ expected `()`, found integer + | | + | expected due to this + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/parser/issues/issue-70388-without-witness.fixed b/tests/ui/parser/issues/issue-70388-without-witness.fixed new file mode 100644 index 000000000..8d981405e --- /dev/null +++ b/tests/ui/parser/issues/issue-70388-without-witness.fixed @@ -0,0 +1,9 @@ +// run-rustfix +// This is for checking if we can apply suggestions as-is. + +pub struct Foo(#[allow(unused_tuple_struct_fields)] i32); + +fn main() { + let Foo(..) = Foo(0); //~ ERROR unexpected `...` + let [_, .., _] = [0, 1]; //~ ERROR unexpected `...` +} diff --git a/tests/ui/parser/issues/issue-70388-without-witness.rs b/tests/ui/parser/issues/issue-70388-without-witness.rs new file mode 100644 index 000000000..bf3607308 --- /dev/null +++ b/tests/ui/parser/issues/issue-70388-without-witness.rs @@ -0,0 +1,9 @@ +// run-rustfix +// This is for checking if we can apply suggestions as-is. + +pub struct Foo(#[allow(unused_tuple_struct_fields)] i32); + +fn main() { + let Foo(...) = Foo(0); //~ ERROR unexpected `...` + let [_, ..., _] = [0, 1]; //~ ERROR unexpected `...` +} diff --git a/tests/ui/parser/issues/issue-70388-without-witness.stderr b/tests/ui/parser/issues/issue-70388-without-witness.stderr new file mode 100644 index 000000000..b750ad4c6 --- /dev/null +++ b/tests/ui/parser/issues/issue-70388-without-witness.stderr @@ -0,0 +1,20 @@ +error: unexpected `...` + --> $DIR/issue-70388-without-witness.rs:7:13 + | +LL | let Foo(...) = Foo(0); + | ^^^ + | | + | not a valid pattern + | help: for a rest pattern, use `..` instead of `...` + +error: unexpected `...` + --> $DIR/issue-70388-without-witness.rs:8:13 + | +LL | let [_, ..., _] = [0, 1]; + | ^^^ + | | + | not a valid pattern + | help: for a rest pattern, use `..` instead of `...` + +error: aborting due to 2 previous errors + diff --git a/tests/ui/parser/issues/issue-70549-resolve-after-recovered-self-ctor.rs b/tests/ui/parser/issues/issue-70549-resolve-after-recovered-self-ctor.rs new file mode 100644 index 000000000..aeccd0d9f --- /dev/null +++ b/tests/ui/parser/issues/issue-70549-resolve-after-recovered-self-ctor.rs @@ -0,0 +1,18 @@ +struct S {} + +impl S { + fn foo(&mur Self) {} + //~^ ERROR expected identifier, found keyword `Self` + //~| ERROR expected one of `:`, `@` + //~| ERROR the `Self` constructor can only be used with + fn bar(&'static mur Self) {} + //~^ ERROR unexpected lifetime + //~| ERROR expected identifier, found keyword `Self` + //~| ERROR expected one of `:`, `@` + //~| ERROR the `Self` constructor can only be used with + + fn baz(&mur Self @ _) {} + //~^ ERROR expected one of `:`, `@` +} + +fn main() {} diff --git a/tests/ui/parser/issues/issue-70549-resolve-after-recovered-self-ctor.stderr b/tests/ui/parser/issues/issue-70549-resolve-after-recovered-self-ctor.stderr new file mode 100644 index 000000000..421f14540 --- /dev/null +++ b/tests/ui/parser/issues/issue-70549-resolve-after-recovered-self-ctor.stderr @@ -0,0 +1,56 @@ +error: expected identifier, found keyword `Self` + --> $DIR/issue-70549-resolve-after-recovered-self-ctor.rs:4:17 + | +LL | fn foo(&mur Self) {} + | ^^^^ expected identifier, found keyword + +error: expected one of `:`, `@`, or `|`, found keyword `Self` + --> $DIR/issue-70549-resolve-after-recovered-self-ctor.rs:4:17 + | +LL | fn foo(&mur Self) {} + | -----^^^^ + | | | + | | expected one of `:`, `@`, or `|` + | help: declare the type after the parameter binding: `<identifier>: <type>` + +error: unexpected lifetime `'static` in pattern + --> $DIR/issue-70549-resolve-after-recovered-self-ctor.rs:8:13 + | +LL | fn bar(&'static mur Self) {} + | ^^^^^^^ help: remove the lifetime + +error: expected identifier, found keyword `Self` + --> $DIR/issue-70549-resolve-after-recovered-self-ctor.rs:8:25 + | +LL | fn bar(&'static mur Self) {} + | ^^^^ expected identifier, found keyword + +error: expected one of `:`, `@`, or `|`, found keyword `Self` + --> $DIR/issue-70549-resolve-after-recovered-self-ctor.rs:8:25 + | +LL | fn bar(&'static mur Self) {} + | -------------^^^^ + | | | + | | expected one of `:`, `@`, or `|` + | help: declare the type after the parameter binding: `<identifier>: <type>` + +error: expected one of `:`, `@`, or `|`, found keyword `Self` + --> $DIR/issue-70549-resolve-after-recovered-self-ctor.rs:14:17 + | +LL | fn baz(&mur Self @ _) {} + | ^^^^ expected one of `:`, `@`, or `|` + +error: the `Self` constructor can only be used with tuple or unit structs + --> $DIR/issue-70549-resolve-after-recovered-self-ctor.rs:4:17 + | +LL | fn foo(&mur Self) {} + | ^^^^ help: use curly brackets: `Self { /* fields */ }` + +error: the `Self` constructor can only be used with tuple or unit structs + --> $DIR/issue-70549-resolve-after-recovered-self-ctor.rs:8:25 + | +LL | fn bar(&'static mur Self) {} + | ^^^^ help: use curly brackets: `Self { /* fields */ }` + +error: aborting due to 8 previous errors + diff --git a/tests/ui/parser/issues/issue-70552-ascription-in-parens-after-call.rs b/tests/ui/parser/issues/issue-70552-ascription-in-parens-after-call.rs new file mode 100644 index 000000000..9b6dd7db4 --- /dev/null +++ b/tests/ui/parser/issues/issue-70552-ascription-in-parens-after-call.rs @@ -0,0 +1,3 @@ +fn main() { + expr as fun()(:); //~ ERROR expected expression +} diff --git a/tests/ui/parser/issues/issue-70552-ascription-in-parens-after-call.stderr b/tests/ui/parser/issues/issue-70552-ascription-in-parens-after-call.stderr new file mode 100644 index 000000000..f03c92e1b --- /dev/null +++ b/tests/ui/parser/issues/issue-70552-ascription-in-parens-after-call.stderr @@ -0,0 +1,8 @@ +error: expected expression, found `:` + --> $DIR/issue-70552-ascription-in-parens-after-call.rs:2:19 + | +LL | expr as fun()(:); + | ^ expected expression + +error: aborting due to previous error + diff --git a/tests/ui/parser/issues/issue-70583-block-is-empty-1.rs b/tests/ui/parser/issues/issue-70583-block-is-empty-1.rs new file mode 100644 index 000000000..f560f68f6 --- /dev/null +++ b/tests/ui/parser/issues/issue-70583-block-is-empty-1.rs @@ -0,0 +1,20 @@ +pub enum ErrorHandled { + Reported, + TooGeneric, +} + +impl ErrorHandled { + pub fn assert_reported(self) { + match self { + ErrorHandled::Reported => {} + ErrorHandled::TooGeneric => panic!(), + } + } +} + +fn struct_generic(x: Vec<i32>) { + for v in x { + println!("{}", v); + } + } +} //~ ERROR unexpected closing delimiter: `}` diff --git a/tests/ui/parser/issues/issue-70583-block-is-empty-1.stderr b/tests/ui/parser/issues/issue-70583-block-is-empty-1.stderr new file mode 100644 index 000000000..39bf113ef --- /dev/null +++ b/tests/ui/parser/issues/issue-70583-block-is-empty-1.stderr @@ -0,0 +1,13 @@ +error: unexpected closing delimiter: `}` + --> $DIR/issue-70583-block-is-empty-1.rs:20:1 + | +LL | fn struct_generic(x: Vec<i32>) { + | - this opening brace... +... +LL | } + | - ...matches this closing brace +LL | } + | ^ unexpected closing delimiter + +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 new file mode 100644 index 000000000..80f53338a --- /dev/null +++ b/tests/ui/parser/issues/issue-70583-block-is-empty-2.rs @@ -0,0 +1,14 @@ +pub enum ErrorHandled { + Reported, + TooGeneric, +} + +impl ErrorHandled { + pub fn assert_reported(self) { + match self { + ErrorHandled::Reported => {}} + //^~ ERROR block is empty, you might have not meant to close it + ErrorHandled::TooGeneric => panic!(), + } + } +} //~ ERROR 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 new file mode 100644 index 000000000..5d37b2164 --- /dev/null +++ b/tests/ui/parser/issues/issue-70583-block-is-empty-2.stderr @@ -0,0 +1,11 @@ +error: unexpected closing delimiter: `}` + --> $DIR/issue-70583-block-is-empty-2.rs:14:1 + | +LL | ErrorHandled::Reported => {}} + | -- block is empty, you might have not meant to close it +... +LL | } + | ^ unexpected closing delimiter + +error: aborting due to previous error + diff --git a/tests/ui/parser/issues/issue-7222.rs b/tests/ui/parser/issues/issue-7222.rs new file mode 100644 index 000000000..649073166 --- /dev/null +++ b/tests/ui/parser/issues/issue-7222.rs @@ -0,0 +1,12 @@ +// run-pass +// pretty-expanded FIXME #23616 +#![allow(illegal_floating_point_literal_pattern)] // FIXME #41620 + +pub fn main() { + const FOO: f64 = 10.0; + + match 0.0 { + 0.0 ..= FOO => (), + _ => () + } +} diff --git a/tests/ui/parser/issues/issue-72253.rs b/tests/ui/parser/issues/issue-72253.rs new file mode 100644 index 000000000..1446a796f --- /dev/null +++ b/tests/ui/parser/issues/issue-72253.rs @@ -0,0 +1,6 @@ +fn main() { + let a = std::process::Command::new("echo") + .arg("1") + ,arg("2") //~ ERROR expected one of `.`, `;`, `?`, `else`, or an operator, found `,` + .output(); +} diff --git a/tests/ui/parser/issues/issue-72253.stderr b/tests/ui/parser/issues/issue-72253.stderr new file mode 100644 index 000000000..477fa09f4 --- /dev/null +++ b/tests/ui/parser/issues/issue-72253.stderr @@ -0,0 +1,10 @@ +error: expected one of `.`, `;`, `?`, `else`, or an operator, found `,` + --> $DIR/issue-72253.rs:4:9 + | +LL | .arg("1") + | - expected one of `.`, `;`, `?`, `else`, or an operator +LL | ,arg("2") + | ^ unexpected token + +error: aborting due to previous error + diff --git a/tests/ui/parser/issues/issue-72373.rs b/tests/ui/parser/issues/issue-72373.rs new file mode 100644 index 000000000..4da6061c2 --- /dev/null +++ b/tests/ui/parser/issues/issue-72373.rs @@ -0,0 +1,9 @@ +fn foo(c: &[u32], n: u32) -> u32 { + match *c { + [h, ..] if h > n => 0, + [h, ..] if h == n => 1, + [h, ref ts..] => foo(c, n - h) + foo(ts, n), + //~^ ERROR expected one of `,`, `@`, `]`, or `|`, found `..` + [] => 0, + } +} diff --git a/tests/ui/parser/issues/issue-72373.stderr b/tests/ui/parser/issues/issue-72373.stderr new file mode 100644 index 000000000..0bb99a01e --- /dev/null +++ b/tests/ui/parser/issues/issue-72373.stderr @@ -0,0 +1,13 @@ +error: expected one of `,`, `@`, `]`, or `|`, found `..` + --> $DIR/issue-72373.rs:5:19 + | +LL | [h, ref ts..] => foo(c, n - h) + foo(ts, n), + | ^^ expected one of `,`, `@`, `]`, or `|` + | +help: if you meant to bind the contents of the rest of the array pattern into `ts`, use `@` + | +LL | [h, ref ts @ ..] => foo(c, n - h) + foo(ts, n), + | + + +error: aborting due to previous error + diff --git a/tests/ui/parser/issues/issue-73568-lifetime-after-mut.rs b/tests/ui/parser/issues/issue-73568-lifetime-after-mut.rs new file mode 100644 index 000000000..5f731f8db --- /dev/null +++ b/tests/ui/parser/issues/issue-73568-lifetime-after-mut.rs @@ -0,0 +1,19 @@ +#![crate_type="lib"] +fn x<'a>(x: &mut 'a i32){} //~ ERROR lifetime must precede `mut` + +macro_rules! mac { + ($lt:lifetime) => { + fn w<$lt>(w: &mut $lt i32) {} + //~^ ERROR lifetime must precede `mut` + } +} + +mac!('a); + +// avoid false positives +fn y<'a>(y: &mut 'a + Send) { + //~^ ERROR expected a path on the left-hand side of `+`, not `&mut 'a` + //~| ERROR at least one trait is required for an object type + let z = y as &mut 'a + Send; + //~^ ERROR expected value, found trait `Send` +} diff --git a/tests/ui/parser/issues/issue-73568-lifetime-after-mut.stderr b/tests/ui/parser/issues/issue-73568-lifetime-after-mut.stderr new file mode 100644 index 000000000..799bc16bd --- /dev/null +++ b/tests/ui/parser/issues/issue-73568-lifetime-after-mut.stderr @@ -0,0 +1,39 @@ +error: lifetime must precede `mut` + --> $DIR/issue-73568-lifetime-after-mut.rs:2:13 + | +LL | fn x<'a>(x: &mut 'a i32){} + | ^^^^^^^ help: place the lifetime before `mut`: `&'a mut` + +error[E0178]: expected a path on the left-hand side of `+`, not `&mut 'a` + --> $DIR/issue-73568-lifetime-after-mut.rs:14:13 + | +LL | fn y<'a>(y: &mut 'a + Send) { + | ^^^^^^^^^^^^^^ help: try adding parentheses: `&mut ('a + Send)` + +error: lifetime must precede `mut` + --> $DIR/issue-73568-lifetime-after-mut.rs:6:22 + | +LL | fn w<$lt>(w: &mut $lt i32) {} + | ^^^^^^^^ help: place the lifetime before `mut`: `&$lt mut` +... +LL | mac!('a); + | -------- in this macro invocation + | + = note: this error originates in the macro `mac` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0423]: expected value, found trait `Send` + --> $DIR/issue-73568-lifetime-after-mut.rs:17:28 + | +LL | let z = y as &mut 'a + Send; + | ^^^^ not a value + +error[E0224]: at least one trait is required for an object type + --> $DIR/issue-73568-lifetime-after-mut.rs:14:18 + | +LL | fn y<'a>(y: &mut 'a + Send) { + | ^^ + +error: aborting due to 5 previous errors + +Some errors have detailed explanations: E0178, E0224, E0423. +For more information about an error, try `rustc --explain E0178`. diff --git a/tests/ui/parser/issues/issue-75599.rs b/tests/ui/parser/issues/issue-75599.rs new file mode 100644 index 000000000..0857676e4 --- /dev/null +++ b/tests/ui/parser/issues/issue-75599.rs @@ -0,0 +1,24 @@ +// check-pass +#![allow(non_upper_case_globals)] + +const or: usize = 1; +const and: usize = 2; + +mod or { + pub const X: usize = 3; +} + +mod and { + pub const X: usize = 4; +} + +fn main() { + match 0 { + 0 => {} + or => {} + and => {} + or::X => {} + and::X => {} + _ => {} + } +} diff --git a/tests/ui/parser/issues/issue-76437-async.rs b/tests/ui/parser/issues/issue-76437-async.rs new file mode 100644 index 000000000..84ee3dd21 --- /dev/null +++ b/tests/ui/parser/issues/issue-76437-async.rs @@ -0,0 +1,7 @@ +// edition:2018 + +mod t { + async pub fn t() {} + //~^ ERROR expected one of `extern`, `fn`, or `unsafe`, found keyword `pub` + //~| HELP visibility `pub` must come before `async` +} diff --git a/tests/ui/parser/issues/issue-76437-async.stderr b/tests/ui/parser/issues/issue-76437-async.stderr new file mode 100644 index 000000000..2c9c2a8cf --- /dev/null +++ b/tests/ui/parser/issues/issue-76437-async.stderr @@ -0,0 +1,11 @@ +error: expected one of `extern`, `fn`, or `unsafe`, found keyword `pub` + --> $DIR/issue-76437-async.rs:4:11 + | +LL | async pub fn t() {} + | ------^^^ + | | | + | | expected one of `extern`, `fn`, or `unsafe` + | help: visibility `pub` must come before `async`: `pub async` + +error: aborting due to previous error + diff --git a/tests/ui/parser/issues/issue-76437-const-async-unsafe.rs b/tests/ui/parser/issues/issue-76437-const-async-unsafe.rs new file mode 100644 index 000000000..f1e06e4ad --- /dev/null +++ b/tests/ui/parser/issues/issue-76437-const-async-unsafe.rs @@ -0,0 +1,7 @@ +// edition:2018 + +mod t { + const async unsafe pub fn t() {} + //~^ ERROR expected one of `extern` or `fn`, found keyword `pub` + //~| HELP visibility `pub` must come before `const async unsafe` +} diff --git a/tests/ui/parser/issues/issue-76437-const-async-unsafe.stderr b/tests/ui/parser/issues/issue-76437-const-async-unsafe.stderr new file mode 100644 index 000000000..2e91beda1 --- /dev/null +++ b/tests/ui/parser/issues/issue-76437-const-async-unsafe.stderr @@ -0,0 +1,11 @@ +error: expected one of `extern` or `fn`, found keyword `pub` + --> $DIR/issue-76437-const-async-unsafe.rs:4:24 + | +LL | const async unsafe pub fn t() {} + | -------------------^^^ + | | | + | | expected one of `extern` or `fn` + | help: visibility `pub` must come before `const async unsafe`: `pub const async unsafe` + +error: aborting due to previous error + diff --git a/tests/ui/parser/issues/issue-76437-const-async.rs b/tests/ui/parser/issues/issue-76437-const-async.rs new file mode 100644 index 000000000..3c789fdcd --- /dev/null +++ b/tests/ui/parser/issues/issue-76437-const-async.rs @@ -0,0 +1,7 @@ +// edition:2018 + +mod t { + const async pub fn t() {} + //~^ ERROR expected one of `extern`, `fn`, or `unsafe`, found keyword `pub` + //~| HELP visibility `pub` must come before `const async` +} diff --git a/tests/ui/parser/issues/issue-76437-const-async.stderr b/tests/ui/parser/issues/issue-76437-const-async.stderr new file mode 100644 index 000000000..21b96c14d --- /dev/null +++ b/tests/ui/parser/issues/issue-76437-const-async.stderr @@ -0,0 +1,11 @@ +error: expected one of `extern`, `fn`, or `unsafe`, found keyword `pub` + --> $DIR/issue-76437-const-async.rs:4:17 + | +LL | const async pub fn t() {} + | ------------^^^ + | | | + | | expected one of `extern`, `fn`, or `unsafe` + | help: visibility `pub` must come before `const async`: `pub const async` + +error: aborting due to previous error + diff --git a/tests/ui/parser/issues/issue-76437-const.rs b/tests/ui/parser/issues/issue-76437-const.rs new file mode 100644 index 000000000..d3815a523 --- /dev/null +++ b/tests/ui/parser/issues/issue-76437-const.rs @@ -0,0 +1,7 @@ +// edition:2018 + +mod t { + const pub fn t() {} + //~^ ERROR expected one of `async`, `extern`, `fn`, or `unsafe`, found keyword `pub` + //~| HELP visibility `pub` must come before `const` +} diff --git a/tests/ui/parser/issues/issue-76437-const.stderr b/tests/ui/parser/issues/issue-76437-const.stderr new file mode 100644 index 000000000..cf80d9a90 --- /dev/null +++ b/tests/ui/parser/issues/issue-76437-const.stderr @@ -0,0 +1,11 @@ +error: expected one of `async`, `extern`, `fn`, or `unsafe`, found keyword `pub` + --> $DIR/issue-76437-const.rs:4:11 + | +LL | const pub fn t() {} + | ------^^^ + | | | + | | expected one of `async`, `extern`, `fn`, or `unsafe` + | help: visibility `pub` must come before `const`: `pub const` + +error: aborting due to previous error + diff --git a/tests/ui/parser/issues/issue-76437-pub-crate-unsafe.rs b/tests/ui/parser/issues/issue-76437-pub-crate-unsafe.rs new file mode 100644 index 000000000..daa1d1207 --- /dev/null +++ b/tests/ui/parser/issues/issue-76437-pub-crate-unsafe.rs @@ -0,0 +1,7 @@ +// edition:2018 + +mod t { + unsafe pub(crate) fn t() {} + //~^ ERROR expected one of `extern` or `fn`, found keyword `pub` + //~| HELP visibility `pub(crate)` must come before `unsafe` +} diff --git a/tests/ui/parser/issues/issue-76437-pub-crate-unsafe.stderr b/tests/ui/parser/issues/issue-76437-pub-crate-unsafe.stderr new file mode 100644 index 000000000..fa8f13721 --- /dev/null +++ b/tests/ui/parser/issues/issue-76437-pub-crate-unsafe.stderr @@ -0,0 +1,11 @@ +error: expected one of `extern` or `fn`, found keyword `pub` + --> $DIR/issue-76437-pub-crate-unsafe.rs:4:12 + | +LL | unsafe pub(crate) fn t() {} + | -------^^^------- + | | | + | | expected one of `extern` or `fn` + | help: visibility `pub(crate)` must come before `unsafe`: `pub(crate) unsafe` + +error: aborting due to previous error + diff --git a/tests/ui/parser/issues/issue-76437-unsafe.rs b/tests/ui/parser/issues/issue-76437-unsafe.rs new file mode 100644 index 000000000..785a79a79 --- /dev/null +++ b/tests/ui/parser/issues/issue-76437-unsafe.rs @@ -0,0 +1,7 @@ +// edition:2018 + +mod t { + unsafe pub fn t() {} + //~^ ERROR expected one of `extern` or `fn`, found keyword `pub` + //~| HELP visibility `pub` must come before `unsafe` +} diff --git a/tests/ui/parser/issues/issue-76437-unsafe.stderr b/tests/ui/parser/issues/issue-76437-unsafe.stderr new file mode 100644 index 000000000..c63292ef8 --- /dev/null +++ b/tests/ui/parser/issues/issue-76437-unsafe.stderr @@ -0,0 +1,11 @@ +error: expected one of `extern` or `fn`, found keyword `pub` + --> $DIR/issue-76437-unsafe.rs:4:12 + | +LL | unsafe pub fn t() {} + | -------^^^ + | | | + | | expected one of `extern` or `fn` + | help: visibility `pub` must come before `unsafe`: `pub unsafe` + +error: aborting due to previous error + diff --git a/tests/ui/parser/issues/issue-76597.fixed b/tests/ui/parser/issues/issue-76597.fixed new file mode 100644 index 000000000..2d7a30b83 --- /dev/null +++ b/tests/ui/parser/issues/issue-76597.fixed @@ -0,0 +1,11 @@ +// run-rustfix + +#![allow(dead_code)] +#![allow(unused_variables)] +fn f( + x: u8, + y: u8, +) {} +//~^^ ERROR: expected one of `!`, `(`, `)`, `+`, `,`, `::`, or `<`, found `y` + +fn main() {} diff --git a/tests/ui/parser/issues/issue-76597.rs b/tests/ui/parser/issues/issue-76597.rs new file mode 100644 index 000000000..521b9c64b --- /dev/null +++ b/tests/ui/parser/issues/issue-76597.rs @@ -0,0 +1,11 @@ +// run-rustfix + +#![allow(dead_code)] +#![allow(unused_variables)] +fn f( + x: u8 + y: u8, +) {} +//~^^ ERROR: expected one of `!`, `(`, `)`, `+`, `,`, `::`, or `<`, found `y` + +fn main() {} diff --git a/tests/ui/parser/issues/issue-76597.stderr b/tests/ui/parser/issues/issue-76597.stderr new file mode 100644 index 000000000..50b23329f --- /dev/null +++ b/tests/ui/parser/issues/issue-76597.stderr @@ -0,0 +1,13 @@ +error: expected one of `!`, `(`, `)`, `+`, `,`, `::`, or `<`, found `y` + --> $DIR/issue-76597.rs:7:38 + | +LL | ... x: u8 + | - + | | + | expected one of 7 possible tokens + | help: missing `,` +LL | ... y: u8, + | ^ unexpected token + +error: aborting due to previous error + diff --git a/tests/ui/parser/issues/issue-7970b.rs b/tests/ui/parser/issues/issue-7970b.rs new file mode 100644 index 000000000..1c4abce39 --- /dev/null +++ b/tests/ui/parser/issues/issue-7970b.rs @@ -0,0 +1,4 @@ +fn main() {} + +macro_rules! test {} +//~^ ERROR unexpected end of macro invocation diff --git a/tests/ui/parser/issues/issue-7970b.stderr b/tests/ui/parser/issues/issue-7970b.stderr new file mode 100644 index 000000000..a62226a8a --- /dev/null +++ b/tests/ui/parser/issues/issue-7970b.stderr @@ -0,0 +1,8 @@ +error: unexpected end of macro invocation + --> $DIR/issue-7970b.rs:3:1 + | +LL | macro_rules! test {} + | ^^^^^^^^^^^^^^^^^^^^ missing tokens in macro arguments + +error: aborting due to previous error + diff --git a/tests/ui/parser/issues/issue-81806.rs b/tests/ui/parser/issues/issue-81806.rs new file mode 100644 index 000000000..ca86788df --- /dev/null +++ b/tests/ui/parser/issues/issue-81806.rs @@ -0,0 +1,5 @@ +trait T { const +impl //~ ERROR: expected identifier, found keyword `impl` +} + +fn main() {} diff --git a/tests/ui/parser/issues/issue-81806.stderr b/tests/ui/parser/issues/issue-81806.stderr new file mode 100644 index 000000000..40873388d --- /dev/null +++ b/tests/ui/parser/issues/issue-81806.stderr @@ -0,0 +1,17 @@ +error: expected identifier, found keyword `impl` + --> $DIR/issue-81806.rs:2:1 + | +LL | trait T { const + | - while parsing this item list starting here +LL | impl + | ^^^^ expected identifier, found keyword +LL | } + | - the item list ends here + | +help: escape `impl` to use it as an identifier + | +LL | r#impl + | ++ + +error: aborting due to previous error + diff --git a/tests/ui/parser/issues/issue-83639.rs b/tests/ui/parser/issues/issue-83639.rs new file mode 100644 index 000000000..6ddbedfa0 --- /dev/null +++ b/tests/ui/parser/issues/issue-83639.rs @@ -0,0 +1,6 @@ +// check-fail +// ignore-tidy-tab + +fn main() { + """ " //~ ERROR +} diff --git a/tests/ui/parser/issues/issue-83639.stderr b/tests/ui/parser/issues/issue-83639.stderr new file mode 100644 index 000000000..4c10df191 --- /dev/null +++ b/tests/ui/parser/issues/issue-83639.stderr @@ -0,0 +1,8 @@ +error: expected one of `.`, `;`, `?`, `}`, or an operator, found `" "` + --> $DIR/issue-83639.rs:5:7 + | +LL | """ " + | ^^^^^^ expected one of `.`, `;`, `?`, `}`, or an operator + +error: aborting due to previous error + diff --git a/tests/ui/parser/issues/issue-84104.rs b/tests/ui/parser/issues/issue-84104.rs new file mode 100644 index 000000000..998949b94 --- /dev/null +++ b/tests/ui/parser/issues/issue-84104.rs @@ -0,0 +1,3 @@ +// error-pattern: this file contains an unclosed delimiter +// error-pattern: expected one of +#[i=i::<ښܖ< diff --git a/tests/ui/parser/issues/issue-84104.stderr b/tests/ui/parser/issues/issue-84104.stderr new file mode 100644 index 000000000..aff31f2c9 --- /dev/null +++ b/tests/ui/parser/issues/issue-84104.stderr @@ -0,0 +1,16 @@ +error: this file contains an unclosed delimiter + --> $DIR/issue-84104.rs:3:13 + | +LL | #[i=i::<ښܖ< + | - ^ + | | + | unclosed delimiter + +error: expected one of `>`, a const expression, lifetime, or type, found `]` + --> $DIR/issue-84104.rs:3:13 + | +LL | #[i=i::<ښܖ< + | ^ expected one of `>`, a const expression, lifetime, or type + +error: aborting due to 2 previous errors + diff --git a/tests/ui/parser/issues/issue-84117.rs b/tests/ui/parser/issues/issue-84117.rs new file mode 100644 index 000000000..c9ebf1335 --- /dev/null +++ b/tests/ui/parser/issues/issue-84117.rs @@ -0,0 +1,9 @@ +fn main() { + let outer_local:e_outer<&str, { let inner_local:e_inner<&str, } + //~^ ERROR expected one of `>`, a const expression + //~| ERROR expected one of `>`, a const expression, lifetime, or type, found `}` + //~| ERROR expected one of `!`, `.`, `::`, `;`, `?`, `else`, `{`, or an operator, found `,` + //~| ERROR expected one of `!`, `.`, `::`, `;`, `?`, `else`, `{`, or an operator, found `,` + //~| ERROR expected one of `!`, `.`, `::`, `;`, `?`, `else`, `{`, or an operator, found `,` +} +//~^ ERROR expected one of `,` or `>`, found `}` diff --git a/tests/ui/parser/issues/issue-84117.stderr b/tests/ui/parser/issues/issue-84117.stderr new file mode 100644 index 000000000..237bc11bd --- /dev/null +++ b/tests/ui/parser/issues/issue-84117.stderr @@ -0,0 +1,72 @@ +error: expected one of `>`, a const expression, lifetime, or type, found `}` + --> $DIR/issue-84117.rs:2:67 + | +LL | let outer_local:e_outer<&str, { let inner_local:e_inner<&str, } + | ----------- ^ expected one of `>`, a const expression, lifetime, or type + | | + | while parsing the type for `inner_local` + | +help: you might have meant to end the type parameters here + | +LL | let outer_local:e_outer<&str, { let inner_local:e_inner<&str>, } + | + +help: use `=` if you meant to assign + | +LL | let outer_local:e_outer<&str, { let inner_local =e_inner<&str, } + | ~ + +error: expected one of `!`, `.`, `::`, `;`, `?`, `else`, `{`, or an operator, found `,` + --> $DIR/issue-84117.rs:2:65 + | +LL | let outer_local:e_outer<&str, { let inner_local:e_inner<&str, } + | ^ expected one of 8 possible tokens + +error: expected one of `,` or `>`, found `}` + --> $DIR/issue-84117.rs:8:1 + | +LL | let outer_local:e_outer<&str, { let inner_local:e_inner<&str, } + | ----------- while parsing the type for `outer_local` - expected one of `,` or `>` +... +LL | } + | ^ unexpected token + | +help: you might have meant to end the type parameters here + | +LL | let outer_local:e_outer<&str, { let inner_local:e_inner<&str, }> + | + +help: use `=` if you meant to assign + | +LL | let outer_local =e_outer<&str, { let inner_local:e_inner<&str, } + | ~ + +error: expected one of `>`, a const expression, lifetime, or type, found `}` + --> $DIR/issue-84117.rs:2:67 + | +LL | let outer_local:e_outer<&str, { let inner_local:e_inner<&str, } + | ----------- ^ expected one of `>`, a const expression, lifetime, or type + | | + | while parsing the type for `inner_local` + | +help: you might have meant to end the type parameters here + | +LL | let outer_local:e_outer<&str, { let inner_local:e_inner<&str>, } + | + +help: use `=` if you meant to assign + | +LL | let outer_local:e_outer<&str, { let inner_local =e_inner<&str, } + | ~ + +error: expected one of `!`, `.`, `::`, `;`, `?`, `else`, `{`, or an operator, found `,` + --> $DIR/issue-84117.rs:2:65 + | +LL | let outer_local:e_outer<&str, { let inner_local:e_inner<&str, } + | ^ expected one of 8 possible tokens + +error: expected one of `!`, `.`, `::`, `;`, `?`, `else`, `{`, or an operator, found `,` + --> $DIR/issue-84117.rs:2:33 + | +LL | let outer_local:e_outer<&str, { let inner_local:e_inner<&str, } + | ^ expected one of 8 possible tokens + +error: aborting due to 6 previous errors + diff --git a/tests/ui/parser/issues/issue-84148-1.rs b/tests/ui/parser/issues/issue-84148-1.rs new file mode 100644 index 000000000..9fa8086c2 --- /dev/null +++ b/tests/ui/parser/issues/issue-84148-1.rs @@ -0,0 +1,3 @@ +fn f(t:for<>t?) +//~^ ERROR: expected one of +//~| ERROR: invalid `?` in type diff --git a/tests/ui/parser/issues/issue-84148-1.stderr b/tests/ui/parser/issues/issue-84148-1.stderr new file mode 100644 index 000000000..9261067c2 --- /dev/null +++ b/tests/ui/parser/issues/issue-84148-1.stderr @@ -0,0 +1,19 @@ +error: invalid `?` in type + --> $DIR/issue-84148-1.rs:1:14 + | +LL | fn f(t:for<>t?) + | ^ `?` is only allowed on expressions, not types + | +help: if you meant to express that the type might not contain a value, use the `Option` wrapper type + | +LL | fn f(t:Option<for<>t>) + | +++++++ ~ + +error: expected one of `->`, `where`, or `{`, found `<eof>` + --> $DIR/issue-84148-1.rs:1:15 + | +LL | fn f(t:for<>t?) + | ^ expected one of `->`, `where`, or `{` + +error: aborting due to 2 previous errors + diff --git a/tests/ui/parser/issues/issue-84148-2.rs b/tests/ui/parser/issues/issue-84148-2.rs new file mode 100644 index 000000000..2f6a7facf --- /dev/null +++ b/tests/ui/parser/issues/issue-84148-2.rs @@ -0,0 +1,3 @@ +// error-pattern: this file contains an unclosed delimiter +// error-pattern: invalid `?` in type +fn f(t:for<>t? diff --git a/tests/ui/parser/issues/issue-84148-2.stderr b/tests/ui/parser/issues/issue-84148-2.stderr new file mode 100644 index 000000000..71d543f9b --- /dev/null +++ b/tests/ui/parser/issues/issue-84148-2.stderr @@ -0,0 +1,27 @@ +error: this file contains an unclosed delimiter + --> $DIR/issue-84148-2.rs:3:16 + | +LL | fn f(t:for<>t? + | - ^ + | | + | unclosed delimiter + +error: invalid `?` in type + --> $DIR/issue-84148-2.rs:3:14 + | +LL | fn f(t:for<>t? + | ^ `?` is only allowed on expressions, not types + | +help: if you meant to express that the type might not contain a value, use the `Option` wrapper type + | +LL | fn f(t:Option<for<>t> + | +++++++ ~ + +error: expected one of `->`, `where`, or `{`, found `<eof>` + --> $DIR/issue-84148-2.rs:3:16 + | +LL | fn f(t:for<>t? + | ^ expected one of `->`, `where`, or `{` + +error: aborting due to 3 previous errors + diff --git a/tests/ui/parser/issues/issue-8537.rs b/tests/ui/parser/issues/issue-8537.rs new file mode 100644 index 000000000..9d0cbce6c --- /dev/null +++ b/tests/ui/parser/issues/issue-8537.rs @@ -0,0 +1,5 @@ +pub extern + "invalid-ab_isize" //~ ERROR invalid ABI +fn foo() {} + +fn main() {} diff --git a/tests/ui/parser/issues/issue-8537.stderr b/tests/ui/parser/issues/issue-8537.stderr new file mode 100644 index 000000000..523cc9dc5 --- /dev/null +++ b/tests/ui/parser/issues/issue-8537.stderr @@ -0,0 +1,11 @@ +error[E0703]: invalid ABI: found `invalid-ab_isize` + --> $DIR/issue-8537.rs:2:3 + | +LL | "invalid-ab_isize" + | ^^^^^^^^^^^^^^^^^^ invalid ABI + | + = note: invoke `rustc --print=calling-conventions` for a full list of supported calling conventions. + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0703`. diff --git a/tests/ui/parser/issues/issue-86895.rs b/tests/ui/parser/issues/issue-86895.rs new file mode 100644 index 000000000..4cd098431 --- /dev/null +++ b/tests/ui/parser/issues/issue-86895.rs @@ -0,0 +1,3 @@ +const pub () {} +//~^ ERROR expected one of `async`, `extern`, `fn`, or `unsafe` +pub fn main() {} diff --git a/tests/ui/parser/issues/issue-86895.stderr b/tests/ui/parser/issues/issue-86895.stderr new file mode 100644 index 000000000..575d857c0 --- /dev/null +++ b/tests/ui/parser/issues/issue-86895.stderr @@ -0,0 +1,8 @@ +error: expected one of `async`, `extern`, `fn`, or `unsafe`, found keyword `pub` + --> $DIR/issue-86895.rs:1:7 + | +LL | const pub () {} + | ^^^ expected one of `async`, `extern`, `fn`, or `unsafe` + +error: aborting due to previous error + diff --git a/tests/ui/parser/issues/issue-87086-colon-path-sep.rs b/tests/ui/parser/issues/issue-87086-colon-path-sep.rs new file mode 100644 index 000000000..0b7b67496 --- /dev/null +++ b/tests/ui/parser/issues/issue-87086-colon-path-sep.rs @@ -0,0 +1,79 @@ +// Tests that a suggestion is issued if the user wrote a colon instead of +// a path separator in a match arm. + +mod qux { + pub enum Foo { + Bar, + Baz, + } +} + +use qux::Foo; + +fn f() -> Foo { Foo::Bar } + +fn g1() { + match f() { + Foo:Bar => {} + //~^ ERROR: expected one of + //~| HELP: maybe write a path separator here + _ => {} + } + match f() { + qux::Foo:Bar => {} + //~^ ERROR: expected one of + //~| HELP: maybe write a path separator here + _ => {} + } + match f() { + qux:Foo::Baz => {} + //~^ ERROR: expected one of + //~| HELP: maybe write a path separator here + _ => {} + } + match f() { + qux: Foo::Baz if true => {} + //~^ ERROR: expected one of + //~| HELP: maybe write a path separator here + _ => {} + } + if let Foo:Bar = f() { + //~^ ERROR: expected one of + //~| HELP: maybe write a path separator here + } +} + +fn g1_neg() { + match f() { + ref qux: Foo::Baz => {} + //~^ ERROR: expected one of + //~| HELP: maybe write a path separator here + _ => {} + } +} + +fn g2_neg() { + match f() { + mut qux: Foo::Baz => {} + //~^ ERROR: expected one of + //~| HELP: maybe write a path separator here + _ => {} + } +} + +fn main() { + let myfoo = Foo::Bar; + match myfoo { + Foo::Bar => {} + Foo:Bar::Baz => {} + //~^ ERROR: expected one of + //~| HELP: maybe write a path separator here + //~| ERROR: failed to resolve: `Bar` is a variant, not a module + } + match myfoo { + Foo::Bar => {} + Foo:Bar => {} + //~^ ERROR: expected one of + //~| HELP: maybe write a path separator here + } +} diff --git a/tests/ui/parser/issues/issue-87086-colon-path-sep.stderr b/tests/ui/parser/issues/issue-87086-colon-path-sep.stderr new file mode 100644 index 000000000..2050a16be --- /dev/null +++ b/tests/ui/parser/issues/issue-87086-colon-path-sep.stderr @@ -0,0 +1,90 @@ +error: expected one of `@` or `|`, found `:` + --> $DIR/issue-87086-colon-path-sep.rs:17:12 + | +LL | Foo:Bar => {} + | ^ + | | + | expected one of `@` or `|` + | help: maybe write a path separator here: `::` + +error: expected one of `!`, `(`, `...`, `..=`, `..`, `::`, `{`, or `|`, found `:` + --> $DIR/issue-87086-colon-path-sep.rs:23:17 + | +LL | qux::Foo:Bar => {} + | ^ + | | + | expected one of 8 possible tokens + | help: maybe write a path separator here: `::` + +error: expected one of `@` or `|`, found `:` + --> $DIR/issue-87086-colon-path-sep.rs:29:12 + | +LL | qux:Foo::Baz => {} + | ^ + | | + | expected one of `@` or `|` + | help: maybe write a path separator here: `::` + +error: expected one of `@` or `|`, found `:` + --> $DIR/issue-87086-colon-path-sep.rs:35:12 + | +LL | qux: Foo::Baz if true => {} + | ^ + | | + | expected one of `@` or `|` + | help: maybe write a path separator here: `::` + +error: expected one of `@` or `|`, found `:` + --> $DIR/issue-87086-colon-path-sep.rs:40:15 + | +LL | if let Foo:Bar = f() { + | ^ + | | + | expected one of `@` or `|` + | help: maybe write a path separator here: `::` + +error: expected one of `@` or `|`, found `:` + --> $DIR/issue-87086-colon-path-sep.rs:48:16 + | +LL | ref qux: Foo::Baz => {} + | ^ + | | + | expected one of `@` or `|` + | help: maybe write a path separator here: `::` + +error: expected one of `@` or `|`, found `:` + --> $DIR/issue-87086-colon-path-sep.rs:57:16 + | +LL | mut qux: Foo::Baz => {} + | ^ + | | + | expected one of `@` or `|` + | help: maybe write a path separator here: `::` + +error: expected one of `@` or `|`, found `:` + --> $DIR/issue-87086-colon-path-sep.rs:68:12 + | +LL | Foo:Bar::Baz => {} + | ^ + | | + | expected one of `@` or `|` + | help: maybe write a path separator here: `::` + +error: expected one of `@` or `|`, found `:` + --> $DIR/issue-87086-colon-path-sep.rs:75:12 + | +LL | Foo:Bar => {} + | ^ + | | + | expected one of `@` or `|` + | help: maybe write a path separator here: `::` + +error[E0433]: failed to resolve: `Bar` is a variant, not a module + --> $DIR/issue-87086-colon-path-sep.rs:68:13 + | +LL | Foo:Bar::Baz => {} + | ^^^ `Bar` is a variant, not a module + +error: aborting due to 10 previous errors + +For more information about this error, try `rustc --explain E0433`. diff --git a/tests/ui/parser/issues/issue-87197-missing-semicolon.fixed b/tests/ui/parser/issues/issue-87197-missing-semicolon.fixed new file mode 100644 index 000000000..53f071db7 --- /dev/null +++ b/tests/ui/parser/issues/issue-87197-missing-semicolon.fixed @@ -0,0 +1,10 @@ +// run-rustfix +// Parser should know when a semicolon is missing. +// https://github.com/rust-lang/rust/issues/87197 + +fn main() { + let x = 100; //~ ERROR: expected `;` + println!("{}", x); //~ ERROR: expected `;` + let y = 200; //~ ERROR: expected `;` + println!("{}", y); +} diff --git a/tests/ui/parser/issues/issue-87197-missing-semicolon.rs b/tests/ui/parser/issues/issue-87197-missing-semicolon.rs new file mode 100644 index 000000000..db0edf452 --- /dev/null +++ b/tests/ui/parser/issues/issue-87197-missing-semicolon.rs @@ -0,0 +1,10 @@ +// run-rustfix +// Parser should know when a semicolon is missing. +// https://github.com/rust-lang/rust/issues/87197 + +fn main() { + let x = 100 //~ ERROR: expected `;` + println!("{}", x) //~ ERROR: expected `;` + let y = 200 //~ ERROR: expected `;` + println!("{}", y); +} diff --git a/tests/ui/parser/issues/issue-87197-missing-semicolon.stderr b/tests/ui/parser/issues/issue-87197-missing-semicolon.stderr new file mode 100644 index 000000000..57772de1e --- /dev/null +++ b/tests/ui/parser/issues/issue-87197-missing-semicolon.stderr @@ -0,0 +1,26 @@ +error: expected `;`, found `println` + --> $DIR/issue-87197-missing-semicolon.rs:6:16 + | +LL | let x = 100 + | ^ help: add `;` here +LL | println!("{}", x) + | ------- unexpected token + +error: expected `;`, found keyword `let` + --> $DIR/issue-87197-missing-semicolon.rs:7:22 + | +LL | println!("{}", x) + | ^ help: add `;` here +LL | let y = 200 + | --- unexpected token + +error: expected `;`, found `println` + --> $DIR/issue-87197-missing-semicolon.rs:8:16 + | +LL | let y = 200 + | ^ help: add `;` here +LL | println!("{}", y); + | ------- unexpected token + +error: aborting due to 3 previous errors + diff --git a/tests/ui/parser/issues/issue-87217-keyword-order/const-async-const.rs b/tests/ui/parser/issues/issue-87217-keyword-order/const-async-const.rs new file mode 100644 index 000000000..df0cd5439 --- /dev/null +++ b/tests/ui/parser/issues/issue-87217-keyword-order/const-async-const.rs @@ -0,0 +1,9 @@ +// edition:2018 + +// Test that even when `const` is already present, the proposed fix is to remove the second `const` + +const async const fn test() {} +//~^ ERROR expected one of `extern`, `fn`, or `unsafe`, found keyword `const` +//~| NOTE expected one of `extern`, `fn`, or `unsafe` +//~| HELP `const` already used earlier, remove this one +//~| NOTE `const` first seen here diff --git a/tests/ui/parser/issues/issue-87217-keyword-order/const-async-const.stderr b/tests/ui/parser/issues/issue-87217-keyword-order/const-async-const.stderr new file mode 100644 index 000000000..977c6ebfe --- /dev/null +++ b/tests/ui/parser/issues/issue-87217-keyword-order/const-async-const.stderr @@ -0,0 +1,17 @@ +error: expected one of `extern`, `fn`, or `unsafe`, found keyword `const` + --> $DIR/const-async-const.rs:5:13 + | +LL | const async const fn test() {} + | ^^^^^ + | | + | expected one of `extern`, `fn`, or `unsafe` + | help: `const` already used earlier, remove this one + | +note: `const` first seen here + --> $DIR/const-async-const.rs:5:1 + | +LL | const async const fn test() {} + | ^^^^^ + +error: aborting due to previous error + diff --git a/tests/ui/parser/issues/issue-87217-keyword-order/several-kw-jump.rs b/tests/ui/parser/issues/issue-87217-keyword-order/several-kw-jump.rs new file mode 100644 index 000000000..bbebc99e9 --- /dev/null +++ b/tests/ui/parser/issues/issue-87217-keyword-order/several-kw-jump.rs @@ -0,0 +1,14 @@ +// edition:2018 + +// There is an order to respect for keywords before a function: +// `<visibility>, const, async, unsafe, extern, "<ABI>"` +// +// This test ensures the compiler is helpful about them being misplaced. +// Visibilities are tested elsewhere. + +async unsafe const fn test() {} +//~^ ERROR expected one of `extern` or `fn`, found keyword `const` +//~| NOTE expected one of `extern` or `fn` +//~| HELP `const` must come before `async unsafe` +//~| SUGGESTION const async unsafe +//~| NOTE keyword order for functions declaration is `pub`, `default`, `const`, `async`, `unsafe`, `extern` diff --git a/tests/ui/parser/issues/issue-87217-keyword-order/several-kw-jump.stderr b/tests/ui/parser/issues/issue-87217-keyword-order/several-kw-jump.stderr new file mode 100644 index 000000000..f455caba1 --- /dev/null +++ b/tests/ui/parser/issues/issue-87217-keyword-order/several-kw-jump.stderr @@ -0,0 +1,13 @@ +error: expected one of `extern` or `fn`, found keyword `const` + --> $DIR/several-kw-jump.rs:9:14 + | +LL | async unsafe const fn test() {} + | -------------^^^^^ + | | | + | | expected one of `extern` or `fn` + | help: `const` must come before `async unsafe`: `const async unsafe` + | + = note: keyword order for functions declaration is `pub`, `default`, `const`, `async`, `unsafe`, `extern` + +error: aborting due to previous error + diff --git a/tests/ui/parser/issues/issue-87217-keyword-order/wrong-async.rs b/tests/ui/parser/issues/issue-87217-keyword-order/wrong-async.rs new file mode 100644 index 000000000..4ff4cf5c8 --- /dev/null +++ b/tests/ui/parser/issues/issue-87217-keyword-order/wrong-async.rs @@ -0,0 +1,14 @@ +// edition:2018 + +// There is an order to respect for keywords before a function: +// `<visibility>, const, async, unsafe, extern, "<ABI>"` +// +// This test ensures the compiler is helpful about them being misplaced. +// Visibilities are tested elsewhere. + +unsafe async fn test() {} +//~^ ERROR expected one of `extern` or `fn`, found keyword `async` +//~| NOTE expected one of `extern` or `fn` +//~| HELP `async` must come before `unsafe` +//~| SUGGESTION async unsafe +//~| NOTE keyword order for functions declaration is `pub`, `default`, `const`, `async`, `unsafe`, `extern` diff --git a/tests/ui/parser/issues/issue-87217-keyword-order/wrong-async.stderr b/tests/ui/parser/issues/issue-87217-keyword-order/wrong-async.stderr new file mode 100644 index 000000000..e9eb14bf0 --- /dev/null +++ b/tests/ui/parser/issues/issue-87217-keyword-order/wrong-async.stderr @@ -0,0 +1,13 @@ +error: expected one of `extern` or `fn`, found keyword `async` + --> $DIR/wrong-async.rs:9:8 + | +LL | unsafe async fn test() {} + | -------^^^^^ + | | | + | | expected one of `extern` or `fn` + | help: `async` must come before `unsafe`: `async unsafe` + | + = note: keyword order for functions declaration is `pub`, `default`, `const`, `async`, `unsafe`, `extern` + +error: aborting due to previous error + diff --git a/tests/ui/parser/issues/issue-87217-keyword-order/wrong-const.rs b/tests/ui/parser/issues/issue-87217-keyword-order/wrong-const.rs new file mode 100644 index 000000000..2f5fbc513 --- /dev/null +++ b/tests/ui/parser/issues/issue-87217-keyword-order/wrong-const.rs @@ -0,0 +1,14 @@ +// edition:2018 + +// There is an order to respect for keywords before a function: +// `<visibility>, const, async, unsafe, extern, "<ABI>"` +// +// This test ensures the compiler is helpful about them being misplaced. +// Visibilities are tested elsewhere. + +unsafe const fn test() {} +//~^ ERROR expected one of `extern` or `fn`, found keyword `const` +//~| NOTE expected one of `extern` or `fn` +//~| HELP `const` must come before `unsafe` +//~| SUGGESTION const unsafe +//~| NOTE keyword order for functions declaration is `pub`, `default`, `const`, `async`, `unsafe`, `extern` diff --git a/tests/ui/parser/issues/issue-87217-keyword-order/wrong-const.stderr b/tests/ui/parser/issues/issue-87217-keyword-order/wrong-const.stderr new file mode 100644 index 000000000..0d2bc3472 --- /dev/null +++ b/tests/ui/parser/issues/issue-87217-keyword-order/wrong-const.stderr @@ -0,0 +1,13 @@ +error: expected one of `extern` or `fn`, found keyword `const` + --> $DIR/wrong-const.rs:9:8 + | +LL | unsafe const fn test() {} + | -------^^^^^ + | | | + | | expected one of `extern` or `fn` + | help: `const` must come before `unsafe`: `const unsafe` + | + = note: keyword order for functions declaration is `pub`, `default`, `const`, `async`, `unsafe`, `extern` + +error: aborting due to previous error + diff --git a/tests/ui/parser/issues/issue-87217-keyword-order/wrong-unsafe.rs b/tests/ui/parser/issues/issue-87217-keyword-order/wrong-unsafe.rs new file mode 100644 index 000000000..df2412e3e --- /dev/null +++ b/tests/ui/parser/issues/issue-87217-keyword-order/wrong-unsafe.rs @@ -0,0 +1,14 @@ +// edition:2018 + +// There is an order to respect for keywords before a function: +// `<visibility>, const, async, unsafe, extern, "<ABI>"` +// +// This test ensures the compiler is helpful about them being misplaced. +// Visibilities are tested elsewhere. + +extern unsafe fn test() {} +//~^ ERROR expected `fn`, found keyword `unsafe` +//~| NOTE expected `fn` +//~| HELP `unsafe` must come before `extern` +//~| SUGGESTION unsafe extern +//~| NOTE keyword order for functions declaration is `pub`, `default`, `const`, `async`, `unsafe`, `extern` diff --git a/tests/ui/parser/issues/issue-87217-keyword-order/wrong-unsafe.stderr b/tests/ui/parser/issues/issue-87217-keyword-order/wrong-unsafe.stderr new file mode 100644 index 000000000..4224713cc --- /dev/null +++ b/tests/ui/parser/issues/issue-87217-keyword-order/wrong-unsafe.stderr @@ -0,0 +1,13 @@ +error: expected `fn`, found keyword `unsafe` + --> $DIR/wrong-unsafe.rs:9:8 + | +LL | extern unsafe fn test() {} + | -------^^^^^^ + | | | + | | expected `fn` + | help: `unsafe` must come before `extern`: `unsafe extern` + | + = note: keyword order for functions declaration is `pub`, `default`, `const`, `async`, `unsafe`, `extern` + +error: aborting due to previous error + diff --git a/tests/ui/parser/issues/issue-87635.rs b/tests/ui/parser/issues/issue-87635.rs new file mode 100644 index 000000000..f70a87fb0 --- /dev/null +++ b/tests/ui/parser/issues/issue-87635.rs @@ -0,0 +1,9 @@ +struct Foo {} + +impl Foo { + pub fn bar() + //~^ ERROR: associated function in `impl` without body +} +//~^ERROR expected one of `->`, `where`, or `{`, found `}` + +fn main() {} diff --git a/tests/ui/parser/issues/issue-87635.stderr b/tests/ui/parser/issues/issue-87635.stderr new file mode 100644 index 000000000..1d459f1b9 --- /dev/null +++ b/tests/ui/parser/issues/issue-87635.stderr @@ -0,0 +1,19 @@ +error: expected one of `->`, `where`, or `{`, found `}` + --> $DIR/issue-87635.rs:6:1 + | +LL | pub fn bar() + | --- - expected one of `->`, `where`, or `{` + | | + | while parsing this `fn` +LL | +LL | } + | ^ unexpected token + +error: associated function in `impl` without body + --> $DIR/issue-87635.rs:4:5 + | +LL | pub fn bar() + | ^^^^^^^^^^^^- help: provide a definition for the function: `{ <body> }` + +error: aborting due to 2 previous errors + diff --git a/tests/ui/parser/issues/issue-87812-path.rs b/tests/ui/parser/issues/issue-87812-path.rs new file mode 100644 index 000000000..b88780876 --- /dev/null +++ b/tests/ui/parser/issues/issue-87812-path.rs @@ -0,0 +1,11 @@ +macro_rules! foo { + ( $f:path ) => {{ + let _: usize = $f; //~ERROR + }}; +} + +struct Baz; + +fn main() { + foo!(Baz); +} diff --git a/tests/ui/parser/issues/issue-87812-path.stderr b/tests/ui/parser/issues/issue-87812-path.stderr new file mode 100644 index 000000000..f8ee05175 --- /dev/null +++ b/tests/ui/parser/issues/issue-87812-path.stderr @@ -0,0 +1,16 @@ +error[E0308]: mismatched types + --> $DIR/issue-87812-path.rs:3:24 + | +LL | let _: usize = $f; + | ----- ^^ expected `usize`, found struct `Baz` + | | + | expected due to this +... +LL | foo!(Baz); + | --------- in this macro invocation + | + = note: this error originates in the macro `foo` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/parser/issues/issue-87812.rs b/tests/ui/parser/issues/issue-87812.rs new file mode 100644 index 000000000..0ba87b995 --- /dev/null +++ b/tests/ui/parser/issues/issue-87812.rs @@ -0,0 +1,13 @@ +#![deny(break_with_label_and_loop)] + +macro_rules! foo { + ( $f:block ) => { + '_l: loop { + break '_l $f; //~ERROR + } + }; +} + +fn main() { + let x = foo!({ 3 }); +} diff --git a/tests/ui/parser/issues/issue-87812.stderr b/tests/ui/parser/issues/issue-87812.stderr new file mode 100644 index 000000000..d61ee23a5 --- /dev/null +++ b/tests/ui/parser/issues/issue-87812.stderr @@ -0,0 +1,22 @@ +error: this labeled break expression is easy to confuse with an unlabeled break with a labeled value expression + --> $DIR/issue-87812.rs:6:13 + | +LL | break '_l $f; + | ^^^^^^^^^^^^ +... +LL | let x = foo!({ 3 }); + | ----------- in this macro invocation + | +note: the lint level is defined here + --> $DIR/issue-87812.rs:1:9 + | +LL | #![deny(break_with_label_and_loop)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: this error originates in the macro `foo` (in Nightly builds, run with -Z macro-backtrace for more info) +help: wrap this expression in parentheses + | +LL | break '_l ($f); + | + + + +error: aborting due to previous error + diff --git a/tests/ui/parser/issues/issue-88276-unary-plus.fixed b/tests/ui/parser/issues/issue-88276-unary-plus.fixed new file mode 100644 index 000000000..25b7c340f --- /dev/null +++ b/tests/ui/parser/issues/issue-88276-unary-plus.fixed @@ -0,0 +1,8 @@ +// run-rustfix +#[allow(unused_parens)] +fn main() { + let _ = 1; //~ ERROR leading `+` is not supported + let _ = (1.0 + 2.0) * 3.0; //~ ERROR leading `+` is not supported + //~| ERROR leading `+` is not supported + let _ = [3, 4+6]; //~ ERROR leading `+` is not supported +} diff --git a/tests/ui/parser/issues/issue-88276-unary-plus.rs b/tests/ui/parser/issues/issue-88276-unary-plus.rs new file mode 100644 index 000000000..11b2e9d60 --- /dev/null +++ b/tests/ui/parser/issues/issue-88276-unary-plus.rs @@ -0,0 +1,8 @@ +// run-rustfix +#[allow(unused_parens)] +fn main() { + let _ = +1; //~ ERROR leading `+` is not supported + let _ = (1.0 + +2.0) * +3.0; //~ ERROR leading `+` is not supported + //~| ERROR leading `+` is not supported + let _ = [+3, 4+6]; //~ ERROR leading `+` is not supported +} diff --git a/tests/ui/parser/issues/issue-88276-unary-plus.stderr b/tests/ui/parser/issues/issue-88276-unary-plus.stderr new file mode 100644 index 000000000..363e08201 --- /dev/null +++ b/tests/ui/parser/issues/issue-88276-unary-plus.stderr @@ -0,0 +1,50 @@ +error: leading `+` is not supported + --> $DIR/issue-88276-unary-plus.rs:4:13 + | +LL | let _ = +1; + | ^ unexpected `+` + | +help: try removing the `+` + | +LL - let _ = +1; +LL + let _ = 1; + | + +error: leading `+` is not supported + --> $DIR/issue-88276-unary-plus.rs:5:20 + | +LL | let _ = (1.0 + +2.0) * +3.0; + | ^ unexpected `+` + | +help: try removing the `+` + | +LL - let _ = (1.0 + +2.0) * +3.0; +LL + let _ = (1.0 + 2.0) * +3.0; + | + +error: leading `+` is not supported + --> $DIR/issue-88276-unary-plus.rs:5:28 + | +LL | let _ = (1.0 + +2.0) * +3.0; + | ^ unexpected `+` + | +help: try removing the `+` + | +LL - let _ = (1.0 + +2.0) * +3.0; +LL + let _ = (1.0 + +2.0) * 3.0; + | + +error: leading `+` is not supported + --> $DIR/issue-88276-unary-plus.rs:7:14 + | +LL | let _ = [+3, 4+6]; + | ^ unexpected `+` + | +help: try removing the `+` + | +LL - let _ = [+3, 4+6]; +LL + let _ = [3, 4+6]; + | + +error: aborting due to 4 previous errors + diff --git a/tests/ui/parser/issues/issue-88583-union-as-ident.rs b/tests/ui/parser/issues/issue-88583-union-as-ident.rs new file mode 100644 index 000000000..b3d66d46b --- /dev/null +++ b/tests/ui/parser/issues/issue-88583-union-as-ident.rs @@ -0,0 +1,15 @@ +// check-pass + +#![allow(non_camel_case_types)] + +struct union; + +impl union { + pub fn new() -> Self { + union { } + } +} + +fn main() { + let _u = union::new(); +} diff --git a/tests/ui/parser/issues/issue-88770.rs b/tests/ui/parser/issues/issue-88770.rs new file mode 100644 index 000000000..bb69951c7 --- /dev/null +++ b/tests/ui/parser/issues/issue-88770.rs @@ -0,0 +1,11 @@ +// Regression test for the ICE described in #88770. + +// error-pattern:this file contains an unclosed delimiter +// error-pattern:expected one of +// error-pattern:missing `in` in `for` loop +// error-pattern:expected one of `!`, `)`, `,`, `.`, `::`, `;`, `?`, `{`, or an operator, found `e` + +fn m(){print!("",(c for&g +u +e +e diff --git a/tests/ui/parser/issues/issue-88770.stderr b/tests/ui/parser/issues/issue-88770.stderr new file mode 100644 index 000000000..4e3a21613 --- /dev/null +++ b/tests/ui/parser/issues/issue-88770.stderr @@ -0,0 +1,60 @@ +error: this file contains an unclosed delimiter + --> $DIR/issue-88770.rs:11:3 + | +LL | fn m(){print!("",(c for&g + | - - - unclosed delimiter + | | | + | | unclosed delimiter + | unclosed delimiter +... +LL | e + | ^ + +error: this file contains an unclosed delimiter + --> $DIR/issue-88770.rs:11:3 + | +LL | fn m(){print!("",(c for&g + | - - - unclosed delimiter + | | | + | | unclosed delimiter + | unclosed delimiter +... +LL | e + | ^ + +error: this file contains an unclosed delimiter + --> $DIR/issue-88770.rs:11:3 + | +LL | fn m(){print!("",(c for&g + | - - - unclosed delimiter + | | | + | | unclosed delimiter + | unclosed delimiter +... +LL | e + | ^ + +error: missing `in` in `for` loop + --> $DIR/issue-88770.rs:8:26 + | +LL | fn m(){print!("",(c for&g + | __________________________^ +LL | | u + | |_ help: try adding `in` here + +error: expected one of `!`, `)`, `,`, `.`, `::`, `?`, `{`, or an operator, found keyword `for` + --> $DIR/issue-88770.rs:8:21 + | +LL | fn m(){print!("",(c for&g + | ^^^ expected one of 8 possible tokens + +error: expected one of `!`, `)`, `,`, `.`, `::`, `;`, `?`, `{`, or an operator, found `e` + --> $DIR/issue-88770.rs:11:1 + | +LL | e + | - expected one of 9 possible tokens +LL | e + | ^ unexpected token + +error: aborting due to 6 previous errors + diff --git a/tests/ui/parser/issues/issue-88818.rs b/tests/ui/parser/issues/issue-88818.rs new file mode 100644 index 000000000..b9233ca83 --- /dev/null +++ b/tests/ui/parser/issues/issue-88818.rs @@ -0,0 +1,10 @@ +// Regression test for #88818 (improve error message for missing trait +// in `impl for X`). + +struct S { } +impl for S { } +//~^ ERROR: missing trait in a trait impl +//~| HELP: add a trait here +//~| HELP: for an inherent impl, drop this `for` + +fn main() {} diff --git a/tests/ui/parser/issues/issue-88818.stderr b/tests/ui/parser/issues/issue-88818.stderr new file mode 100644 index 000000000..6e624c5a2 --- /dev/null +++ b/tests/ui/parser/issues/issue-88818.stderr @@ -0,0 +1,18 @@ +error: missing trait in a trait impl + --> $DIR/issue-88818.rs:5:5 + | +LL | impl for S { } + | ^ + | +help: add a trait here + | +LL | impl Trait for S { } + | +++++ +help: for an inherent impl, drop this `for` + | +LL - impl for S { } +LL + impl S { } + | + +error: aborting due to previous error + diff --git a/tests/ui/parser/issues/issue-89388.rs b/tests/ui/parser/issues/issue-89388.rs new file mode 100644 index 000000000..9153c071e --- /dev/null +++ b/tests/ui/parser/issues/issue-89388.rs @@ -0,0 +1,7 @@ +// Regression test for #89388. + +fn main() { + let option: Option<&[u8]> = Some(b"..."); + let _ = option.map([_]::to_vec); + //~^ ERROR: missing angle brackets in associated item path +} diff --git a/tests/ui/parser/issues/issue-89388.stderr b/tests/ui/parser/issues/issue-89388.stderr new file mode 100644 index 000000000..cf28bef0f --- /dev/null +++ b/tests/ui/parser/issues/issue-89388.stderr @@ -0,0 +1,8 @@ +error: missing angle brackets in associated item path + --> $DIR/issue-89388.rs:5:24 + | +LL | let _ = option.map([_]::to_vec); + | ^^^^^^^^^^^ help: try: `<[_]>::to_vec` + +error: aborting due to previous error + diff --git a/tests/ui/parser/issues/issue-89396.fixed b/tests/ui/parser/issues/issue-89396.fixed new file mode 100644 index 000000000..823ad8cd1 --- /dev/null +++ b/tests/ui/parser/issues/issue-89396.fixed @@ -0,0 +1,16 @@ +// Regression test for issue #89396: Try to recover from a +// `=>` -> `=` or `->` typo in a match arm. + +// run-rustfix + +fn main() { + let opt = Some(42); + let _ = match opt { + Some(_) => true, + //~^ ERROR: expected one of + //~| HELP: try using a fat arrow here + None => false, + //~^ ERROR: expected one of + //~| HELP: try using a fat arrow here + }; +} diff --git a/tests/ui/parser/issues/issue-89396.rs b/tests/ui/parser/issues/issue-89396.rs new file mode 100644 index 000000000..f1d9efa52 --- /dev/null +++ b/tests/ui/parser/issues/issue-89396.rs @@ -0,0 +1,16 @@ +// Regression test for issue #89396: Try to recover from a +// `=>` -> `=` or `->` typo in a match arm. + +// run-rustfix + +fn main() { + let opt = Some(42); + let _ = match opt { + Some(_) = true, + //~^ ERROR: expected one of + //~| HELP: try using a fat arrow here + None -> false, + //~^ ERROR: expected one of + //~| HELP: try using a fat arrow here + }; +} diff --git a/tests/ui/parser/issues/issue-89396.stderr b/tests/ui/parser/issues/issue-89396.stderr new file mode 100644 index 000000000..504420574 --- /dev/null +++ b/tests/ui/parser/issues/issue-89396.stderr @@ -0,0 +1,20 @@ +error: expected one of `=>`, `if`, or `|`, found `=` + --> $DIR/issue-89396.rs:9:17 + | +LL | Some(_) = true, + | ^ + | | + | expected one of `=>`, `if`, or `|` + | help: try using a fat arrow here: `=>` + +error: expected one of `=>`, `@`, `if`, or `|`, found `->` + --> $DIR/issue-89396.rs:12:14 + | +LL | None -> false, + | ^^ + | | + | expected one of `=>`, `@`, `if`, or `|` + | help: try using a fat arrow here: `=>` + +error: aborting due to 2 previous errors + diff --git a/tests/ui/parser/issues/issue-89574.rs b/tests/ui/parser/issues/issue-89574.rs new file mode 100644 index 000000000..0a477f1aa --- /dev/null +++ b/tests/ui/parser/issues/issue-89574.rs @@ -0,0 +1,4 @@ +fn main() { + const EMPTY_ARRAY = []; + //~^ missing type for `const` item +} diff --git a/tests/ui/parser/issues/issue-89574.stderr b/tests/ui/parser/issues/issue-89574.stderr new file mode 100644 index 000000000..fb1312c78 --- /dev/null +++ b/tests/ui/parser/issues/issue-89574.stderr @@ -0,0 +1,8 @@ +error: missing type for `const` item + --> $DIR/issue-89574.rs:2:22 + | +LL | const EMPTY_ARRAY = []; + | ^ help: provide a type for the item: `: <type>` + +error: aborting due to previous error + diff --git a/tests/ui/parser/issues/issue-89971-outer-attr-following-inner-attr-ice.rs b/tests/ui/parser/issues/issue-89971-outer-attr-following-inner-attr-ice.rs new file mode 100644 index 000000000..fe67d9822 --- /dev/null +++ b/tests/ui/parser/issues/issue-89971-outer-attr-following-inner-attr-ice.rs @@ -0,0 +1,15 @@ +// aux-build:issue-89971-outer-attr-following-inner-attr-ice.rs + +#[macro_use] +extern crate issue_89971_outer_attr_following_inner_attr_ice; + +fn main() { + Mew(); + X {}; +} + +#![deny(missing_docs)] +//~^ ERROR an inner attribute is not permitted in this context +#[derive(ICE)] +#[deny(missing_docs)] +struct Mew(); diff --git a/tests/ui/parser/issues/issue-89971-outer-attr-following-inner-attr-ice.stderr b/tests/ui/parser/issues/issue-89971-outer-attr-following-inner-attr-ice.stderr new file mode 100644 index 000000000..a5ee24445 --- /dev/null +++ b/tests/ui/parser/issues/issue-89971-outer-attr-following-inner-attr-ice.stderr @@ -0,0 +1,18 @@ +error: an inner attribute is not permitted in this context + --> $DIR/issue-89971-outer-attr-following-inner-attr-ice.rs:11:1 + | +LL | #![deny(missing_docs)] + | ^^^^^^^^^^^^^^^^^^^^^^ +... +LL | struct Mew(); + | ------------- the inner attribute doesn't annotate this struct + | + = note: inner attributes, like `#![no_std]`, annotate the item enclosing them, and are usually found at the beginning of source files +help: to annotate the struct, change the attribute from inner to outer style + | +LL - #![deny(missing_docs)] +LL + #[deny(missing_docs)] + | + +error: aborting due to previous error + diff --git a/tests/ui/parser/issues/issue-90993.rs b/tests/ui/parser/issues/issue-90993.rs new file mode 100644 index 000000000..40e6fc748 --- /dev/null +++ b/tests/ui/parser/issues/issue-90993.rs @@ -0,0 +1,6 @@ +fn main() { + ...=. + //~^ ERROR: unexpected token: `...` + //~| ERROR: unexpected `=` after inclusive range + //~| ERROR: expected one of `-`, `;`, `}`, or path, found `.` +} diff --git a/tests/ui/parser/issues/issue-90993.stderr b/tests/ui/parser/issues/issue-90993.stderr new file mode 100644 index 000000000..ab6bce410 --- /dev/null +++ b/tests/ui/parser/issues/issue-90993.stderr @@ -0,0 +1,31 @@ +error: unexpected token: `...` + --> $DIR/issue-90993.rs:2:5 + | +LL | ...=. + | ^^^ + | +help: use `..` for an exclusive range + | +LL | ..=. + | ~~ +help: or `..=` for an inclusive range + | +LL | ..==. + | ~~~ + +error: unexpected `=` after inclusive range + --> $DIR/issue-90993.rs:2:5 + | +LL | ...=. + | ^^^^ help: use `..=` instead + | + = note: inclusive ranges end with a single equals sign (`..=`) + +error: expected one of `-`, `;`, `}`, or path, found `.` + --> $DIR/issue-90993.rs:2:9 + | +LL | ...=. + | ^ expected one of `-`, `;`, `}`, or path + +error: aborting due to 3 previous errors + diff --git a/tests/ui/parser/issues/issue-91461.rs b/tests/ui/parser/issues/issue-91461.rs new file mode 100644 index 000000000..3e3c411c4 --- /dev/null +++ b/tests/ui/parser/issues/issue-91461.rs @@ -0,0 +1,6 @@ +fn main() { + a(_:b:,) + //~^ ERROR: expected identifier, found reserved identifier `_` + //~| ERROR: expected type, found `,` + //~| ERROR: expected type, found `,` +} diff --git a/tests/ui/parser/issues/issue-91461.stderr b/tests/ui/parser/issues/issue-91461.stderr new file mode 100644 index 000000000..94fcf1721 --- /dev/null +++ b/tests/ui/parser/issues/issue-91461.stderr @@ -0,0 +1,31 @@ +error: expected identifier, found reserved identifier `_` + --> $DIR/issue-91461.rs:2:7 + | +LL | a(_:b:,) + | ^ expected identifier, found reserved identifier + +error: expected type, found `,` + --> $DIR/issue-91461.rs:2:11 + | +LL | a(_:b:,) + | - -^ expected type + | | | + | | tried to parse a type due to this type ascription + | while parsing this struct + | + = note: `#![feature(type_ascription)]` lets you annotate an expression with a type: `<expr>: <type>` + = note: see issue #23416 <https://github.com/rust-lang/rust/issues/23416> for more information + +error: expected type, found `,` + --> $DIR/issue-91461.rs:2:11 + | +LL | a(_:b:,) + | -^ expected type + | | + | tried to parse a type due to this type ascription + | + = note: `#![feature(type_ascription)]` lets you annotate an expression with a type: `<expr>: <type>` + = note: see issue #23416 <https://github.com/rust-lang/rust/issues/23416> for more information + +error: aborting due to 3 previous errors + diff --git a/tests/ui/parser/issues/issue-93282.rs b/tests/ui/parser/issues/issue-93282.rs new file mode 100644 index 000000000..274245f1a --- /dev/null +++ b/tests/ui/parser/issues/issue-93282.rs @@ -0,0 +1,16 @@ +fn main() { + f<'a,> + //~^ ERROR expected + //~| ERROR expected +} + +fn bar(a: usize, b: usize) -> usize { + a + b +} + +fn foo() { + let x = 1; + bar('y, x); + //~^ ERROR expected + //~| ERROR mismatched types +} diff --git a/tests/ui/parser/issues/issue-93282.stderr b/tests/ui/parser/issues/issue-93282.stderr new file mode 100644 index 000000000..c6140bb82 --- /dev/null +++ b/tests/ui/parser/issues/issue-93282.stderr @@ -0,0 +1,50 @@ +error: expected `while`, `for`, `loop` or `{` after a label + --> $DIR/issue-93282.rs:2:9 + | +LL | f<'a,> + | ^ expected `while`, `for`, `loop` or `{` after a label + | +help: add `'` to close the char literal + | +LL | f<'a',> + | + + +error: expected one of `.`, `:`, `;`, `?`, `for`, `loop`, `while`, `}`, or an operator, found `,` + --> $DIR/issue-93282.rs:2:9 + | +LL | f<'a,> + | ^ expected one of 9 possible tokens + | +help: use `::<...>` instead of `<...>` to specify lifetime, type, or const arguments + | +LL | f::<'a,> + | ++ + +error: expected `while`, `for`, `loop` or `{` after a label + --> $DIR/issue-93282.rs:13:11 + | +LL | bar('y, x); + | ^ expected `while`, `for`, `loop` or `{` after a label + | +help: add `'` to close the char literal + | +LL | bar('y', x); + | + + +error[E0308]: mismatched types + --> $DIR/issue-93282.rs:13:9 + | +LL | bar('y, x); + | --- ^^ expected `usize`, found `char` + | | + | arguments to this function are incorrect + | +note: function defined here + --> $DIR/issue-93282.rs:7:4 + | +LL | fn bar(a: usize, b: usize) -> usize { + | ^^^ -------- + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/parser/issues/issue-93867.rs b/tests/ui/parser/issues/issue-93867.rs new file mode 100644 index 000000000..507447923 --- /dev/null +++ b/tests/ui/parser/issues/issue-93867.rs @@ -0,0 +1,10 @@ +pub struct Entry<'a, K, V> { + k: &'a mut K, + v: V, +} + +pub fn entry<'a, K, V>() -> Entry<'a K, V> { +// ^ missing comma +//~^^ expected one of `,` or `>`, found `K` + unimplemented!() +} diff --git a/tests/ui/parser/issues/issue-93867.stderr b/tests/ui/parser/issues/issue-93867.stderr new file mode 100644 index 000000000..ee0cb4efd --- /dev/null +++ b/tests/ui/parser/issues/issue-93867.stderr @@ -0,0 +1,13 @@ +error: expected one of `,` or `>`, found `K` + --> $DIR/issue-93867.rs:6:38 + | +LL | pub fn entry<'a, K, V>() -> Entry<'a K, V> { + | ^ expected one of `,` or `>` + | +help: you might have meant to end the type parameters here + | +LL | pub fn entry<'a, K, V>() -> Entry<'a> K, V> { + | + + +error: aborting due to previous error + diff --git a/tests/ui/parser/issues/issue-94340.rs b/tests/ui/parser/issues/issue-94340.rs new file mode 100644 index 000000000..d0fb84a68 --- /dev/null +++ b/tests/ui/parser/issues/issue-94340.rs @@ -0,0 +1,8 @@ +// Make sure that unexpected inner attributes are not labeled as outer ones in diagnostics when +// trying to parse an item and that they are subsequently ignored not triggering confusing extra +// diagnostics like "expected item after attributes" which is not true for `include!` which can +// include empty files. + +include!("auxiliary/issue-94340-inc.rs"); + +fn main() {} diff --git a/tests/ui/parser/issues/issue-94340.stderr b/tests/ui/parser/issues/issue-94340.stderr new file mode 100644 index 000000000..9fd7c38a8 --- /dev/null +++ b/tests/ui/parser/issues/issue-94340.stderr @@ -0,0 +1,20 @@ +error: an inner attribute is not permitted in this context + --> $DIR/auxiliary/issue-94340-inc.rs:2:1 + | +LL | #![deny(rust_2018_idioms)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: inner attributes, like `#![no_std]`, annotate the item enclosing them, and are usually found at the beginning of source files + = note: outer attributes, like `#[test]`, annotate the item following them + +error: an inner attribute is not permitted in this context + --> $DIR/auxiliary/issue-94340-inc.rs:3:1 + | +LL | #![deny(unused_must_use)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: inner attributes, like `#![no_std]`, annotate the item enclosing them, and are usually found at the beginning of source files + = note: outer attributes, like `#[test]`, annotate the item following them + +error: aborting due to 2 previous errors + |