diff options
Diffstat (limited to 'tests/ui/parser')
17 files changed, 120 insertions, 47 deletions
diff --git a/tests/ui/parser/attribute/attr-bad-meta-4.rs b/tests/ui/parser/attribute/attr-bad-meta-4.rs index 937390a6da5..606b41e89a5 100644 --- a/tests/ui/parser/attribute/attr-bad-meta-4.rs +++ b/tests/ui/parser/attribute/attr-bad-meta-4.rs @@ -1,7 +1,7 @@ macro_rules! mac { ($attr_item: meta) => { #[cfg($attr_item)] - //~^ ERROR expected unsuffixed literal, found `meta` metavariable + //~^ ERROR expected a literal (`1u8`, `1.0f32`, `"string"`, etc.) here, found `meta` metavariable struct S; } } @@ -9,7 +9,7 @@ macro_rules! mac { mac!(an(arbitrary token stream)); #[cfg(feature = -1)] -//~^ ERROR expected unsuffixed literal, found `-` +//~^ ERROR expected a literal (`1u8`, `1.0f32`, `"string"`, etc.) here, found `-` fn handler() {} fn main() {} diff --git a/tests/ui/parser/attribute/attr-bad-meta-4.stderr b/tests/ui/parser/attribute/attr-bad-meta-4.stderr index 9c6ab5adadf..1d939942fb9 100644 --- a/tests/ui/parser/attribute/attr-bad-meta-4.stderr +++ b/tests/ui/parser/attribute/attr-bad-meta-4.stderr @@ -1,10 +1,16 @@ -error: expected unsuffixed literal, found `-` +error: expected a literal (`1u8`, `1.0f32`, `"string"`, etc.) here, found `-` --> $DIR/attr-bad-meta-4.rs:11:17 | LL | #[cfg(feature = -1)] | ^ + | +help: negative numbers are not literals, try removing the `-` sign + | +LL - #[cfg(feature = -1)] +LL + #[cfg(feature = 1)] + | -error: expected unsuffixed literal, found `meta` metavariable +error: expected a literal (`1u8`, `1.0f32`, `"string"`, etc.) here, found `meta` metavariable --> $DIR/attr-bad-meta-4.rs:3:15 | LL | #[cfg($attr_item)] diff --git a/tests/ui/parser/attribute/attr-incomplete.rs b/tests/ui/parser/attribute/attr-incomplete.rs new file mode 100644 index 00000000000..49cb66e5f59 --- /dev/null +++ b/tests/ui/parser/attribute/attr-incomplete.rs @@ -0,0 +1,17 @@ +#[cfg(target-os = "windows")] +//~^ ERROR expected one of `(`, `,`, `::`, or `=`, found `-` +pub fn test1() { } + +#[cfg(target_os = %)] +//~^ ERROR expected a literal (`1u8`, `1.0f32`, `"string"`, etc.) here, found `%` +pub fn test2() { } + +#[cfg(target_os?)] +//~^ ERROR expected one of `(`, `,`, `::`, or `=`, found `?` +pub fn test3() { } + +#[cfg[target_os]] +//~^ ERROR wrong meta list delimiters +pub fn test4() { } + +pub fn main() {} diff --git a/tests/ui/parser/attribute/attr-incomplete.stderr b/tests/ui/parser/attribute/attr-incomplete.stderr new file mode 100644 index 00000000000..5909820cef3 --- /dev/null +++ b/tests/ui/parser/attribute/attr-incomplete.stderr @@ -0,0 +1,32 @@ +error: expected one of `(`, `,`, `::`, or `=`, found `-` + --> $DIR/attr-incomplete.rs:1:13 + | +LL | #[cfg(target-os = "windows")] + | ^ expected one of `(`, `,`, `::`, or `=` + +error: expected a literal (`1u8`, `1.0f32`, `"string"`, etc.) here, found `%` + --> $DIR/attr-incomplete.rs:5:19 + | +LL | #[cfg(target_os = %)] + | ^ + +error: expected one of `(`, `,`, `::`, or `=`, found `?` + --> $DIR/attr-incomplete.rs:9:16 + | +LL | #[cfg(target_os?)] + | ^ expected one of `(`, `,`, `::`, or `=` + +error: wrong meta list delimiters + --> $DIR/attr-incomplete.rs:13:6 + | +LL | #[cfg[target_os]] + | ^^^^^^^^^^^ + | +help: the delimiters should be `(` and `)` + | +LL - #[cfg[target_os]] +LL + #[cfg(target_os)] + | + +error: aborting due to 4 previous errors + diff --git a/tests/ui/parser/attribute/attr-unquoted-ident.rs b/tests/ui/parser/attribute/attr-unquoted-ident.rs index 396265f715e..8a0c65b783a 100644 --- a/tests/ui/parser/attribute/attr-unquoted-ident.rs +++ b/tests/ui/parser/attribute/attr-unquoted-ident.rs @@ -4,13 +4,13 @@ fn main() { #[cfg(key=foo)] - //~^ ERROR expected unsuffixed literal, found `foo` + //~^ ERROR expected a literal (`1u8`, `1.0f32`, `"string"`, etc.) here, found `foo` //~| HELP surround the identifier with quotation marks to make it into a string literal println!(); #[cfg(key="bar")] println!(); #[cfg(key=foo bar baz)] - //~^ ERROR expected unsuffixed literal, found `foo` + //~^ ERROR expected a literal (`1u8`, `1.0f32`, `"string"`, etc.) here, found `foo` //~| HELP surround the identifier with quotation marks to make it into a string literal println!(); } diff --git a/tests/ui/parser/attribute/attr-unquoted-ident.stderr b/tests/ui/parser/attribute/attr-unquoted-ident.stderr index 2d7997f1aea..8a2785280ad 100644 --- a/tests/ui/parser/attribute/attr-unquoted-ident.stderr +++ b/tests/ui/parser/attribute/attr-unquoted-ident.stderr @@ -1,4 +1,4 @@ -error: expected unsuffixed literal, found `foo` +error: expected a literal (`1u8`, `1.0f32`, `"string"`, etc.) here, found `foo` --> $DIR/attr-unquoted-ident.rs:6:15 | LL | #[cfg(key=foo)] @@ -9,7 +9,7 @@ help: surround the identifier with quotation marks to make it into a string lite LL | #[cfg(key="foo")] | + + -error: expected unsuffixed literal, found `foo` +error: expected a literal (`1u8`, `1.0f32`, `"string"`, etc.) here, found `foo` --> $DIR/attr-unquoted-ident.rs:12:15 | LL | #[cfg(key=foo bar baz)] diff --git a/tests/ui/parser/bad-lit-suffixes.stderr b/tests/ui/parser/bad-lit-suffixes.stderr index 9a51cf70960..e1a8a6834f4 100644 --- a/tests/ui/parser/bad-lit-suffixes.stderr +++ b/tests/ui/parser/bad-lit-suffixes.stderr @@ -11,31 +11,11 @@ LL | "C"suffix | ^^^^^^^^^ invalid suffix `suffix` error: suffixes on string literals are invalid - --> $DIR/bad-lit-suffixes.rs:30:17 - | -LL | #[rustc_dummy = "string"suffix] - | ^^^^^^^^^^^^^^ invalid suffix `suffix` - -error: suffixes on string literals are invalid - --> $DIR/bad-lit-suffixes.rs:34:14 - | -LL | #[must_use = "string"suffix] - | ^^^^^^^^^^^^^^ invalid suffix `suffix` - -error: suffixes on string literals are invalid --> $DIR/bad-lit-suffixes.rs:39:15 | LL | #[link(name = "string"suffix)] | ^^^^^^^^^^^^^^ invalid suffix `suffix` -error: invalid suffix `suffix` for number literal - --> $DIR/bad-lit-suffixes.rs:43:41 - | -LL | #[rustc_layout_scalar_valid_range_start(0suffix)] - | ^^^^^^^ invalid suffix `suffix` - | - = help: the suffix must be one of the numeric types (`u32`, `isize`, `f32`, etc.) - warning: `extern` declarations without an explicit ABI are deprecated --> $DIR/bad-lit-suffixes.rs:3:1 | @@ -150,6 +130,18 @@ LL | 1.0e10suffix; | = help: valid suffixes are `f32` and `f64` +error: suffixes on string literals are invalid + --> $DIR/bad-lit-suffixes.rs:30:17 + | +LL | #[rustc_dummy = "string"suffix] + | ^^^^^^^^^^^^^^ invalid suffix `suffix` + +error: suffixes on string literals are invalid + --> $DIR/bad-lit-suffixes.rs:34:14 + | +LL | #[must_use = "string"suffix] + | ^^^^^^^^^^^^^^ invalid suffix `suffix` + error[E0539]: malformed `must_use` attribute input --> $DIR/bad-lit-suffixes.rs:34:1 | @@ -168,16 +160,23 @@ LL - #[must_use = "string"suffix] LL + #[must_use] | -error[E0805]: malformed `rustc_layout_scalar_valid_range_start` attribute input +error: invalid suffix `suffix` for number literal + --> $DIR/bad-lit-suffixes.rs:43:41 + | +LL | #[rustc_layout_scalar_valid_range_start(0suffix)] + | ^^^^^^^ invalid suffix `suffix` + | + = help: the suffix must be one of the numeric types (`u32`, `isize`, `f32`, etc.) + +error[E0539]: malformed `rustc_layout_scalar_valid_range_start` attribute input --> $DIR/bad-lit-suffixes.rs:43:1 | LL | #[rustc_layout_scalar_valid_range_start(0suffix)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^---------^ - | | | - | | expected a single argument here + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-------^^ + | | | + | | expected an integer literal here | help: must be of the form: `#[rustc_layout_scalar_valid_range_start(start)]` error: aborting due to 22 previous errors; 2 warnings emitted -Some errors have detailed explanations: E0539, E0805. -For more information about an error, try `rustc --explain E0539`. +For more information about this error, try `rustc --explain E0539`. diff --git a/tests/ui/parser/recover/param-default.rs b/tests/ui/parser/recover/param-default.rs new file mode 100644 index 00000000000..5311d4dfae6 --- /dev/null +++ b/tests/ui/parser/recover/param-default.rs @@ -0,0 +1,5 @@ +fn foo(x: i32 = 1) {} //~ ERROR parameter defaults are not supported + +type Foo = fn(i32 = 0); //~ ERROR parameter defaults are not supported + +fn main() {} diff --git a/tests/ui/parser/recover/param-default.stderr b/tests/ui/parser/recover/param-default.stderr new file mode 100644 index 00000000000..93dea427daf --- /dev/null +++ b/tests/ui/parser/recover/param-default.stderr @@ -0,0 +1,14 @@ +error: parameter defaults are not supported + --> $DIR/param-default.rs:1:15 + | +LL | fn foo(x: i32 = 1) {} + | ^^^ + +error: parameter defaults are not supported + --> $DIR/param-default.rs:3:19 + | +LL | type Foo = fn(i32 = 0); + | ^^^ + +error: aborting due to 2 previous errors + diff --git a/tests/ui/parser/recover/recover-pat-ranges.stderr b/tests/ui/parser/recover/recover-pat-ranges.stderr index 246c704d53f..afa7f254054 100644 --- a/tests/ui/parser/recover/recover-pat-ranges.stderr +++ b/tests/ui/parser/recover/recover-pat-ranges.stderr @@ -192,7 +192,7 @@ LL | (1 + 4)...1 * 2 => (), | = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! = note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2021/warnings-promoted-to-error.html> - = note: `#[warn(ellipsis_inclusive_range_patterns)]` on by default + = note: `#[warn(ellipsis_inclusive_range_patterns)]` (part of `#[warn(rust_2021_compatibility)]`) on by default error: aborting due to 13 previous errors; 1 warning emitted diff --git a/tests/ui/parser/removed-syntax/removed-syntax-fixed-vec.stderr b/tests/ui/parser/removed-syntax/removed-syntax-fixed-vec.stderr index 8d7938a1a46..f584197c98e 100644 --- a/tests/ui/parser/removed-syntax/removed-syntax-fixed-vec.stderr +++ b/tests/ui/parser/removed-syntax/removed-syntax-fixed-vec.stderr @@ -17,7 +17,7 @@ warning: type `v` should have an upper camel case name LL | type v = [isize * 3]; | ^ help: convert the identifier to upper camel case (notice the capitalization): `V` | - = note: `#[warn(non_camel_case_types)]` on by default + = note: `#[warn(non_camel_case_types)]` (part of `#[warn(nonstandard_style)]`) on by default error: aborting due to 1 previous error; 1 warning emitted diff --git a/tests/ui/parser/require-parens-for-chained-comparison.rs b/tests/ui/parser/require-parens-for-chained-comparison.rs index 21a908923f2..6152fff6c03 100644 --- a/tests/ui/parser/require-parens-for-chained-comparison.rs +++ b/tests/ui/parser/require-parens-for-chained-comparison.rs @@ -24,14 +24,14 @@ fn main() { //~| HELP use `::<...>` instead of `<...>` to specify lifetime, type, or const arguments //~| ERROR expected //~| HELP add `'` to close the char literal - //~| ERROR invalid label name + //~| ERROR labels cannot use keyword names f<'_>(); //~^ ERROR comparison operators cannot be chained //~| HELP use `::<...>` instead of `<...>` to specify lifetime, type, or const arguments //~| ERROR expected //~| HELP add `'` to close the char literal - //~| ERROR invalid label name + //~| ERROR labels cannot use keyword names let _ = f<u8>; //~^ ERROR comparison operators cannot be chained diff --git a/tests/ui/parser/require-parens-for-chained-comparison.stderr b/tests/ui/parser/require-parens-for-chained-comparison.stderr index 857c4a55788..9edfae36250 100644 --- a/tests/ui/parser/require-parens-for-chained-comparison.stderr +++ b/tests/ui/parser/require-parens-for-chained-comparison.stderr @@ -53,7 +53,7 @@ help: use `::<...>` instead of `<...>` to specify lifetime, type, or const argum LL | let _ = f::<u8, i8>(); | ++ -error: invalid label name `'_` +error: labels cannot use keyword names --> $DIR/require-parens-for-chained-comparison.rs:22:15 | LL | let _ = f<'_, i8>(); @@ -81,7 +81,7 @@ help: use `::<...>` instead of `<...>` to specify lifetime, type, or const argum LL | let _ = f::<'_, i8>(); | ++ -error: invalid label name `'_` +error: labels cannot use keyword names --> $DIR/require-parens-for-chained-comparison.rs:29:7 | LL | f<'_>(); diff --git a/tests/ui/parser/trait-object-lifetime-parens.e2015.stderr b/tests/ui/parser/trait-object-lifetime-parens.e2015.stderr index cf0b3d77f5b..4f4f89de5d1 100644 --- a/tests/ui/parser/trait-object-lifetime-parens.e2015.stderr +++ b/tests/ui/parser/trait-object-lifetime-parens.e2015.stderr @@ -1,4 +1,4 @@ -error: parenthesized lifetime bounds are not supported +error: lifetime bounds may not be parenthesized --> $DIR/trait-object-lifetime-parens.rs:9:21 | LL | fn f<'a, T: Trait + ('a)>() {} @@ -10,7 +10,7 @@ LL - fn f<'a, T: Trait + ('a)>() {} LL + fn f<'a, T: Trait + 'a>() {} | -error: parenthesized lifetime bounds are not supported +error: lifetime bounds may not be parenthesized --> $DIR/trait-object-lifetime-parens.rs:12:24 | LL | let _: Box<Trait + ('a)>; diff --git a/tests/ui/parser/trait-object-lifetime-parens.e2021.stderr b/tests/ui/parser/trait-object-lifetime-parens.e2021.stderr index b65c079788a..a4e2501cfdf 100644 --- a/tests/ui/parser/trait-object-lifetime-parens.e2021.stderr +++ b/tests/ui/parser/trait-object-lifetime-parens.e2021.stderr @@ -1,4 +1,4 @@ -error: parenthesized lifetime bounds are not supported +error: lifetime bounds may not be parenthesized --> $DIR/trait-object-lifetime-parens.rs:9:21 | LL | fn f<'a, T: Trait + ('a)>() {} @@ -10,7 +10,7 @@ LL - fn f<'a, T: Trait + ('a)>() {} LL + fn f<'a, T: Trait + 'a>() {} | -error: parenthesized lifetime bounds are not supported +error: lifetime bounds may not be parenthesized --> $DIR/trait-object-lifetime-parens.rs:12:24 | LL | let _: Box<Trait + ('a)>; diff --git a/tests/ui/parser/trait-object-lifetime-parens.rs b/tests/ui/parser/trait-object-lifetime-parens.rs index 0ff4660bb0d..47a6884b316 100644 --- a/tests/ui/parser/trait-object-lifetime-parens.rs +++ b/tests/ui/parser/trait-object-lifetime-parens.rs @@ -6,10 +6,10 @@ trait Trait {} -fn f<'a, T: Trait + ('a)>() {} //~ ERROR parenthesized lifetime bounds are not supported +fn f<'a, T: Trait + ('a)>() {} //~ ERROR lifetime bounds may not be parenthesized fn check<'a>() { - let _: Box<Trait + ('a)>; //~ ERROR parenthesized lifetime bounds are not supported + let _: Box<Trait + ('a)>; //~ ERROR lifetime bounds may not be parenthesized //[e2021]~^ ERROR expected a type, found a trait // FIXME: It'd be great if we could suggest removing the parentheses here too. //[e2015]~v ERROR lifetimes must be followed by `+` to form a trait object type diff --git a/tests/ui/parser/trait-object-trait-parens.stderr b/tests/ui/parser/trait-object-trait-parens.stderr index b2067547568..f498d7d36bb 100644 --- a/tests/ui/parser/trait-object-trait-parens.stderr +++ b/tests/ui/parser/trait-object-trait-parens.stderr @@ -24,7 +24,7 @@ LL | let _: Box<(Obj) + (?Sized) + (for<'a> Trait<'a>)>; | = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! = note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2021/warnings-promoted-to-error.html> - = note: `#[warn(bare_trait_objects)]` on by default + = note: `#[warn(bare_trait_objects)]` (part of `#[warn(rust_2021_compatibility)]`) on by default help: if this is a dyn-compatible trait, use `dyn` | LL | let _: Box<dyn (Obj) + (?Sized) + (for<'a> Trait<'a>)>; |
