diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-30 03:57:31 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-30 03:57:31 +0000 |
commit | dc0db358abe19481e475e10c32149b53370f1a1c (patch) | |
tree | ab8ce99c4b255ce46f99ef402c27916055b899ee /tests/ui/parser | |
parent | Releasing progress-linux version 1.71.1+dfsg1-2~progress7.99u1. (diff) | |
download | rustc-dc0db358abe19481e475e10c32149b53370f1a1c.tar.xz rustc-dc0db358abe19481e475e10c32149b53370f1a1c.zip |
Merging upstream version 1.72.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/ui/parser')
25 files changed, 299 insertions, 9 deletions
diff --git a/tests/ui/parser/bad-escape-suggest-raw-string.rs b/tests/ui/parser/bad-escape-suggest-raw-string.rs index 978b92cbc..06df82d28 100644 --- a/tests/ui/parser/bad-escape-suggest-raw-string.rs +++ b/tests/ui/parser/bad-escape-suggest-raw-string.rs @@ -2,6 +2,6 @@ fn main() { let ok = r"ab\[c"; let bad = "ab\[c"; //~^ ERROR unknown character escape: `[` - //~| HELP for more information, visit <https://static.rust-lang.org/doc/master/reference.html#literals> + //~| HELP for more information, visit <https://doc.rust-lang.org/reference/tokens.html#literals> //~| HELP if you meant to write a literal backslash (perhaps escaping in a regular expression), consider a raw string literal } diff --git a/tests/ui/parser/bad-escape-suggest-raw-string.stderr b/tests/ui/parser/bad-escape-suggest-raw-string.stderr index fc34bd328..45d24bc0f 100644 --- a/tests/ui/parser/bad-escape-suggest-raw-string.stderr +++ b/tests/ui/parser/bad-escape-suggest-raw-string.stderr @@ -4,7 +4,7 @@ error: unknown character escape: `[` LL | let bad = "ab\[c"; | ^ unknown character escape | - = help: for more information, visit <https://static.rust-lang.org/doc/master/reference.html#literals> + = help: for more information, visit <https://doc.rust-lang.org/reference/tokens.html#literals> help: if you meant to write a literal backslash (perhaps escaping in a regular expression), consider a raw string literal | LL | let bad = r"ab\[c"; diff --git a/tests/ui/parser/bad-interpolated-block.stderr b/tests/ui/parser/bad-interpolated-block.stderr index 2a0999afd..651036c51 100644 --- a/tests/ui/parser/bad-interpolated-block.stderr +++ b/tests/ui/parser/bad-interpolated-block.stderr @@ -10,6 +10,10 @@ LL | m!({}); | ------ in this macro invocation | = note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info) +help: wrap this in another block + | +LL | 'lab: { $b }; + | + + error: cannot use a `block` macro fragment here --> $DIR/bad-interpolated-block.rs:6:16 @@ -23,6 +27,10 @@ LL | m!({}); | ------ in this macro invocation | = note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info) +help: wrap this in another block + | +LL | unsafe { $b }; + | + + error: cannot use a `block` macro fragment here --> $DIR/bad-interpolated-block.rs:7:23 @@ -34,6 +42,10 @@ LL | m!({}); | ------ in this macro invocation | = note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info) +help: wrap this in another block + | +LL | |x: u8| -> () { $b }; + | + + error: aborting due to 3 previous errors diff --git a/tests/ui/parser/byte-literals.stderr b/tests/ui/parser/byte-literals.stderr index efa55ae05..5b414c892 100644 --- a/tests/ui/parser/byte-literals.stderr +++ b/tests/ui/parser/byte-literals.stderr @@ -4,7 +4,7 @@ error: unknown byte escape: `f` LL | static FOO: u8 = b'\f'; | ^ unknown byte escape | - = help: for more information, visit <https://static.rust-lang.org/doc/master/reference.html#literals> + = help: for more information, visit <https://doc.rust-lang.org/reference/tokens.html#literals> error: unknown byte escape: `f` --> $DIR/byte-literals.rs:6:8 @@ -12,7 +12,7 @@ error: unknown byte escape: `f` LL | b'\f'; | ^ unknown byte escape | - = help: for more information, visit <https://static.rust-lang.org/doc/master/reference.html#literals> + = help: for more information, visit <https://doc.rust-lang.org/reference/tokens.html#literals> error: invalid character in numeric character escape: `Z` --> $DIR/byte-literals.rs:7:10 diff --git a/tests/ui/parser/byte-string-literals.stderr b/tests/ui/parser/byte-string-literals.stderr index 5b96cc3d1..655b6998e 100644 --- a/tests/ui/parser/byte-string-literals.stderr +++ b/tests/ui/parser/byte-string-literals.stderr @@ -4,7 +4,7 @@ error: unknown byte escape: `f` LL | static FOO: &'static [u8] = b"\f"; | ^ unknown byte escape | - = help: for more information, visit <https://static.rust-lang.org/doc/master/reference.html#literals> + = help: for more information, visit <https://doc.rust-lang.org/reference/tokens.html#literals> error: unknown byte escape: `f` --> $DIR/byte-string-literals.rs:4:8 @@ -12,7 +12,7 @@ error: unknown byte escape: `f` LL | b"\f"; | ^ unknown byte escape | - = help: for more information, visit <https://static.rust-lang.org/doc/master/reference.html#literals> + = help: for more information, visit <https://doc.rust-lang.org/reference/tokens.html#literals> error: invalid character in numeric character escape: `Z` --> $DIR/byte-string-literals.rs:5:10 diff --git a/tests/ui/parser/foreign-ty-semantic-fail.rs b/tests/ui/parser/foreign-ty-semantic-fail.rs index 96b15232b..4d30086e7 100644 --- a/tests/ui/parser/foreign-ty-semantic-fail.rs +++ b/tests/ui/parser/foreign-ty-semantic-fail.rs @@ -15,4 +15,5 @@ extern "C" { //~^ ERROR incorrect `type` inside `extern` block type E: where; + //~^ ERROR `type`s inside `extern` blocks cannot have `where` clauses } diff --git a/tests/ui/parser/foreign-ty-semantic-fail.stderr b/tests/ui/parser/foreign-ty-semantic-fail.stderr index 588e4966a..2b400dfea 100644 --- a/tests/ui/parser/foreign-ty-semantic-fail.stderr +++ b/tests/ui/parser/foreign-ty-semantic-fail.stderr @@ -61,5 +61,16 @@ LL | type D = u8; | = note: for more information, visit https://doc.rust-lang.org/std/keyword.extern.html -error: aborting due to 6 previous errors +error: `type`s inside `extern` blocks cannot have `where` clauses + --> $DIR/foreign-ty-semantic-fail.rs:17:13 + | +LL | extern "C" { + | ---------- `extern` block begins here +... +LL | type E: where; + | ^^^^^ help: remove the `where` clause + | + = note: for more information, visit https://doc.rust-lang.org/std/keyword.extern.html + +error: aborting due to 7 previous errors diff --git a/tests/ui/parser/issue-112188.fixed b/tests/ui/parser/issue-112188.fixed new file mode 100644 index 000000000..5e73d8e38 --- /dev/null +++ b/tests/ui/parser/issue-112188.fixed @@ -0,0 +1,14 @@ +// run-rustfix + +#![allow(unused)] + +struct Foo { x: i32 } + +fn main() { + let f = Foo { x: 0 }; + let Foo { .. } = f; + let Foo { .. } = f; //~ ERROR expected `}`, found `,` + let Foo { x, .. } = f; + let Foo { x, .. } = f; //~ ERROR expected `}`, found `,` + let Foo { x, .. } = f; //~ ERROR expected `}`, found `,` +} diff --git a/tests/ui/parser/issue-112188.rs b/tests/ui/parser/issue-112188.rs new file mode 100644 index 000000000..27ca192e5 --- /dev/null +++ b/tests/ui/parser/issue-112188.rs @@ -0,0 +1,14 @@ +// run-rustfix + +#![allow(unused)] + +struct Foo { x: i32 } + +fn main() { + let f = Foo { x: 0 }; + let Foo { .. } = f; + let Foo { .., } = f; //~ ERROR expected `}`, found `,` + let Foo { x, .. } = f; + let Foo { .., x } = f; //~ ERROR expected `}`, found `,` + let Foo { .., x, .. } = f; //~ ERROR expected `}`, found `,` +} diff --git a/tests/ui/parser/issue-112188.stderr b/tests/ui/parser/issue-112188.stderr new file mode 100644 index 000000000..6d2d8e6a3 --- /dev/null +++ b/tests/ui/parser/issue-112188.stderr @@ -0,0 +1,37 @@ +error: expected `}`, found `,` + --> $DIR/issue-112188.rs:10:17 + | +LL | let Foo { .., } = f; + | --^ + | | | + | | expected `}` + | | help: remove this comma + | `..` must be at the end and cannot have a trailing comma + +error: expected `}`, found `,` + --> $DIR/issue-112188.rs:12:17 + | +LL | let Foo { .., x } = f; + | --^ + | | | + | | expected `}` + | `..` must be at the end and cannot have a trailing comma + | +help: move the `..` to the end of the field list + | +LL - let Foo { .., x } = f; +LL + let Foo { x, .. } = f; + | + +error: expected `}`, found `,` + --> $DIR/issue-112188.rs:13:17 + | +LL | let Foo { .., x, .. } = f; + | --^- + | | | + | | expected `}` + | `..` must be at the end and cannot have a trailing comma + | help: remove the starting `..` + +error: aborting due to 3 previous errors + diff --git a/tests/ui/parser/issue-113342.rs b/tests/ui/parser/issue-113342.rs new file mode 100644 index 000000000..18b502736 --- /dev/null +++ b/tests/ui/parser/issue-113342.rs @@ -0,0 +1,9 @@ +#[link(name = "my_c_library")] +extern "C" { + fn my_c_function(x: i32) -> bool; +} + +#[no_mangle] +extern "C" pub fn id(x: i32) -> i32 { x } //~ ERROR expected `fn`, found keyword `pub` + +fn main() {} diff --git a/tests/ui/parser/issue-113342.stderr b/tests/ui/parser/issue-113342.stderr new file mode 100644 index 000000000..a0c5e665f --- /dev/null +++ b/tests/ui/parser/issue-113342.stderr @@ -0,0 +1,11 @@ +error: expected `fn`, found keyword `pub` + --> $DIR/issue-113342.rs:7:12 + | +LL | extern "C" pub fn id(x: i32) -> i32 { x } + | -----------^^^ + | | | + | | expected `fn` + | help: visibility `pub` must come before `extern "C"`: `pub extern "C"` + +error: aborting due to previous error + diff --git a/tests/ui/parser/issue-49257.stderr b/tests/ui/parser/issue-49257.stderr index 846467f7f..97e16f88b 100644 --- a/tests/ui/parser/issue-49257.stderr +++ b/tests/ui/parser/issue-49257.stderr @@ -25,7 +25,7 @@ LL | let Point { .., y } = p; help: move the `..` to the end of the field list | LL - let Point { .., y } = p; -LL + let Point { y , .. } = p; +LL + let Point { y, .. } = p; | error: expected `}`, found `,` diff --git a/tests/ui/parser/issues/issue-111692.rs b/tests/ui/parser/issues/issue-111692.rs new file mode 100644 index 000000000..56096f706 --- /dev/null +++ b/tests/ui/parser/issues/issue-111692.rs @@ -0,0 +1,32 @@ +mod module { + #[derive(Eq, PartialEq)] + pub struct Type { + pub x: u8, + pub y: u8, + } + + pub const C: u8 = 32u8; +} + +fn test(x: module::Type) { + if x == module::Type { x: module::C, y: 1 } { //~ ERROR invalid struct literal + } +} + +fn test2(x: module::Type) { + if x ==module::Type { x: module::C, y: 1 } { //~ ERROR invalid struct literal + } +} + + +fn test3(x: module::Type) { + if x == Type { x: module::C, y: 1 } { //~ ERROR invalid struct literal + } +} + +fn test4(x: module::Type) { + if x == demo_module::Type { x: module::C, y: 1 } { //~ ERROR invalid struct literal + } +} + +fn main() { } diff --git a/tests/ui/parser/issues/issue-111692.stderr b/tests/ui/parser/issues/issue-111692.stderr new file mode 100644 index 000000000..068b0483b --- /dev/null +++ b/tests/ui/parser/issues/issue-111692.stderr @@ -0,0 +1,46 @@ +error: invalid struct literal + --> $DIR/issue-111692.rs:12:21 + | +LL | if x == module::Type { x: module::C, y: 1 } { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: you might need to surround the struct literal with parentheses + | +LL | if x == (module::Type { x: module::C, y: 1 }) { + | + + + +error: invalid struct literal + --> $DIR/issue-111692.rs:17:20 + | +LL | if x ==module::Type { x: module::C, y: 1 } { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: you might need to surround the struct literal with parentheses + | +LL | if x ==(module::Type { x: module::C, y: 1 }) { + | + + + +error: invalid struct literal + --> $DIR/issue-111692.rs:23:13 + | +LL | if x == Type { x: module::C, y: 1 } { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: you might need to surround the struct literal with parentheses + | +LL | if x == (Type { x: module::C, y: 1 }) { + | + + + +error: invalid struct literal + --> $DIR/issue-111692.rs:28:26 + | +LL | if x == demo_module::Type { x: module::C, y: 1 } { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: you might need to surround the struct literal with parentheses + | +LL | if x == (demo_module::Type { x: module::C, y: 1 }) { + | + + + +error: aborting due to 4 previous errors + diff --git a/tests/ui/parser/issues/issue-112458.rs b/tests/ui/parser/issues/issue-112458.rs new file mode 100644 index 000000000..36895450c --- /dev/null +++ b/tests/ui/parser/issues/issue-112458.rs @@ -0,0 +1,4 @@ +fn main() { + println!("{}", x.); //~ ERROR unexpected token: `)` + //~^ ERROR cannot find value `x` in this scope +} diff --git a/tests/ui/parser/issues/issue-112458.stderr b/tests/ui/parser/issues/issue-112458.stderr new file mode 100644 index 000000000..54a8f1d03 --- /dev/null +++ b/tests/ui/parser/issues/issue-112458.stderr @@ -0,0 +1,15 @@ +error: unexpected token: `)` + --> $DIR/issue-112458.rs:2:22 + | +LL | println!("{}", x.); + | ^ + +error[E0425]: cannot find value `x` in this scope + --> $DIR/issue-112458.rs:2:20 + | +LL | println!("{}", x.); + | ^ not found in this scope + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0425`. diff --git a/tests/ui/parser/labeled-no-colon-expr.stderr b/tests/ui/parser/labeled-no-colon-expr.stderr index 62288fe15..4d61d9c14 100644 --- a/tests/ui/parser/labeled-no-colon-expr.stderr +++ b/tests/ui/parser/labeled-no-colon-expr.stderr @@ -77,6 +77,10 @@ LL | m!({}); | ------ in this macro invocation | = note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info) +help: wrap this in another block + | +LL | 'l5 { $b }; + | + + error: labeled expression must be followed by `:` --> $DIR/labeled-no-colon-expr.rs:14:8 diff --git a/tests/ui/parser/lit-err-in-macro.rs b/tests/ui/parser/lit-err-in-macro.rs new file mode 100644 index 000000000..cff8ee6b4 --- /dev/null +++ b/tests/ui/parser/lit-err-in-macro.rs @@ -0,0 +1,10 @@ +macro_rules! f { + ($abi:literal) => { + extern $abi fn f() {} + } +} + +f!("Foo"__); +//~^ ERROR suffixes on string literals are invalid + +fn main() {} diff --git a/tests/ui/parser/lit-err-in-macro.stderr b/tests/ui/parser/lit-err-in-macro.stderr new file mode 100644 index 000000000..a61fb5c85 --- /dev/null +++ b/tests/ui/parser/lit-err-in-macro.stderr @@ -0,0 +1,8 @@ +error: suffixes on string literals are invalid + --> $DIR/lit-err-in-macro.rs:7:4 + | +LL | f!("Foo"__); + | ^^^^^^^ invalid suffix `__` + +error: aborting due to previous error + diff --git a/tests/ui/parser/method-call-on-struct-literal-in-if-condition.stderr b/tests/ui/parser/method-call-on-struct-literal-in-if-condition.stderr index 7fd7ffc94..dedbad909 100644 --- a/tests/ui/parser/method-call-on-struct-literal-in-if-condition.stderr +++ b/tests/ui/parser/method-call-on-struct-literal-in-if-condition.stderr @@ -4,7 +4,7 @@ error: invalid struct literal LL | if Example { a: one(), }.is_pos() { | ^^^^^^^^^^^^^^^^^^^^^ | -help: you might need to surround the struct literal in parentheses +help: you might need to surround the struct literal with parentheses | LL | if (Example { a: one(), }).is_pos() { | + + diff --git a/tests/ui/parser/typod-const-in-const-param-def.rs b/tests/ui/parser/typod-const-in-const-param-def.rs new file mode 100644 index 000000000..85d3ebba5 --- /dev/null +++ b/tests/ui/parser/typod-const-in-const-param-def.rs @@ -0,0 +1,16 @@ +pub fn foo<Const N: u8>() {} +//~^ ERROR `const` keyword was mistyped as `Const` + +pub fn bar<Const>() {} +// OK + +pub fn baz<Const N: u8, T>() {} +//~^ ERROR `const` keyword was mistyped as `Const` + +pub fn qux<T, Const N: u8>() {} +//~^ ERROR `const` keyword was mistyped as `Const` + +pub fn quux<T, Const N: u8, U>() {} +//~^ ERROR `const` keyword was mistyped as `Const` + +fn main() {} diff --git a/tests/ui/parser/typod-const-in-const-param-def.stderr b/tests/ui/parser/typod-const-in-const-param-def.stderr new file mode 100644 index 000000000..75d73c6ea --- /dev/null +++ b/tests/ui/parser/typod-const-in-const-param-def.stderr @@ -0,0 +1,46 @@ +error: `const` keyword was mistyped as `Const` + --> $DIR/typod-const-in-const-param-def.rs:1:12 + | +LL | pub fn foo<Const N: u8>() {} + | ^^^^^ + | +help: use the `const` keyword + | +LL | pub fn foo<const N: u8>() {} + | ~~~~~ + +error: `const` keyword was mistyped as `Const` + --> $DIR/typod-const-in-const-param-def.rs:7:12 + | +LL | pub fn baz<Const N: u8, T>() {} + | ^^^^^ + | +help: use the `const` keyword + | +LL | pub fn baz<const N: u8, T>() {} + | ~~~~~ + +error: `const` keyword was mistyped as `Const` + --> $DIR/typod-const-in-const-param-def.rs:10:15 + | +LL | pub fn qux<T, Const N: u8>() {} + | ^^^^^ + | +help: use the `const` keyword + | +LL | pub fn qux<T, const N: u8>() {} + | ~~~~~ + +error: `const` keyword was mistyped as `Const` + --> $DIR/typod-const-in-const-param-def.rs:13:16 + | +LL | pub fn quux<T, Const N: u8, U>() {} + | ^^^^^ + | +help: use the `const` keyword + | +LL | pub fn quux<T, const N: u8, U>() {} + | ~~~~~ + +error: aborting due to 4 previous errors + diff --git a/tests/ui/parser/utf16-be-without-bom.stderr b/tests/ui/parser/utf16-be-without-bom.stderr Binary files differindex 768d2c531..c041f3ecf 100644 --- a/tests/ui/parser/utf16-be-without-bom.stderr +++ b/tests/ui/parser/utf16-be-without-bom.stderr diff --git a/tests/ui/parser/utf16-le-without-bom.stderr b/tests/ui/parser/utf16-le-without-bom.stderr Binary files differindex 4f4b91e39..cc2220441 100644 --- a/tests/ui/parser/utf16-le-without-bom.stderr +++ b/tests/ui/parser/utf16-le-without-bom.stderr |