From 698f8c2f01ea549d77d7dc3338a12e04c11057b9 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:02:58 +0200 Subject: Adding upstream version 1.64.0+dfsg1. Signed-off-by: Daniel Baumann --- src/test/ui/lexer/lex-bad-binary-literal.rs | 11 ++ src/test/ui/lexer/lex-bad-binary-literal.stderr | 56 ++++++++ src/test/ui/lexer/lex-bad-char-literals-1.rs | 17 +++ src/test/ui/lexer/lex-bad-char-literals-1.stderr | 38 ++++++ src/test/ui/lexer/lex-bad-char-literals-2.rs | 6 + src/test/ui/lexer/lex-bad-char-literals-2.stderr | 13 ++ src/test/ui/lexer/lex-bad-char-literals-3.rs | 7 + src/test/ui/lexer/lex-bad-char-literals-3.stderr | 24 ++++ src/test/ui/lexer/lex-bad-char-literals-4.rs | 5 + src/test/ui/lexer/lex-bad-char-literals-4.stderr | 9 ++ src/test/ui/lexer/lex-bad-char-literals-5.rs | 7 + src/test/ui/lexer/lex-bad-char-literals-5.stderr | 24 ++++ src/test/ui/lexer/lex-bad-char-literals-6.rs | 17 +++ src/test/ui/lexer/lex-bad-char-literals-6.stderr | 81 ++++++++++++ src/test/ui/lexer/lex-bad-char-literals-7.rs | 13 ++ src/test/ui/lexer/lex-bad-char-literals-7.stderr | 21 +++ src/test/ui/lexer/lex-bad-numeric-literals.rs | 27 ++++ src/test/ui/lexer/lex-bad-numeric-literals.stderr | 141 +++++++++++++++++++++ src/test/ui/lexer/lex-bad-octal-literal.rs | 4 + src/test/ui/lexer/lex-bad-octal-literal.stderr | 14 ++ src/test/ui/lexer/lex-bad-token.rs | 3 + src/test/ui/lexer/lex-bad-token.stderr | 8 ++ src/test/ui/lexer/lex-bare-cr-nondoc-comment.rs | 9 ++ .../lex-bare-cr-string-literal-doc-comment.rs | 26 ++++ .../lex-bare-cr-string-literal-doc-comment.stderr | 46 +++++++ src/test/ui/lexer/lex-stray-backslash.rs | 3 + src/test/ui/lexer/lex-stray-backslash.stderr | 8 ++ ...crlf-line-endings-string-literal-doc-comment.rs | 38 ++++++ 28 files changed, 676 insertions(+) create mode 100644 src/test/ui/lexer/lex-bad-binary-literal.rs create mode 100644 src/test/ui/lexer/lex-bad-binary-literal.stderr create mode 100644 src/test/ui/lexer/lex-bad-char-literals-1.rs create mode 100644 src/test/ui/lexer/lex-bad-char-literals-1.stderr create mode 100644 src/test/ui/lexer/lex-bad-char-literals-2.rs create mode 100644 src/test/ui/lexer/lex-bad-char-literals-2.stderr create mode 100644 src/test/ui/lexer/lex-bad-char-literals-3.rs create mode 100644 src/test/ui/lexer/lex-bad-char-literals-3.stderr create mode 100644 src/test/ui/lexer/lex-bad-char-literals-4.rs create mode 100644 src/test/ui/lexer/lex-bad-char-literals-4.stderr create mode 100644 src/test/ui/lexer/lex-bad-char-literals-5.rs create mode 100644 src/test/ui/lexer/lex-bad-char-literals-5.stderr create mode 100644 src/test/ui/lexer/lex-bad-char-literals-6.rs create mode 100644 src/test/ui/lexer/lex-bad-char-literals-6.stderr create mode 100644 src/test/ui/lexer/lex-bad-char-literals-7.rs create mode 100644 src/test/ui/lexer/lex-bad-char-literals-7.stderr create mode 100644 src/test/ui/lexer/lex-bad-numeric-literals.rs create mode 100644 src/test/ui/lexer/lex-bad-numeric-literals.stderr create mode 100644 src/test/ui/lexer/lex-bad-octal-literal.rs create mode 100644 src/test/ui/lexer/lex-bad-octal-literal.stderr create mode 100644 src/test/ui/lexer/lex-bad-token.rs create mode 100644 src/test/ui/lexer/lex-bad-token.stderr create mode 100644 src/test/ui/lexer/lex-bare-cr-nondoc-comment.rs create mode 100644 src/test/ui/lexer/lex-bare-cr-string-literal-doc-comment.rs create mode 100644 src/test/ui/lexer/lex-bare-cr-string-literal-doc-comment.stderr create mode 100644 src/test/ui/lexer/lex-stray-backslash.rs create mode 100644 src/test/ui/lexer/lex-stray-backslash.stderr create mode 100644 src/test/ui/lexer/lexer-crlf-line-endings-string-literal-doc-comment.rs (limited to 'src/test/ui/lexer') diff --git a/src/test/ui/lexer/lex-bad-binary-literal.rs b/src/test/ui/lexer/lex-bad-binary-literal.rs new file mode 100644 index 000000000..7df98073e --- /dev/null +++ b/src/test/ui/lexer/lex-bad-binary-literal.rs @@ -0,0 +1,11 @@ +fn main() { + 0b121; //~ ERROR invalid digit for a base 2 literal + 0b10_10301; //~ ERROR invalid digit for a base 2 literal + 0b30; //~ ERROR invalid digit for a base 2 literal + 0b41; //~ ERROR invalid digit for a base 2 literal + 0b5; //~ ERROR invalid digit for a base 2 literal + 0b6; //~ ERROR invalid digit for a base 2 literal + 0b7; //~ ERROR invalid digit for a base 2 literal + 0b8; //~ ERROR invalid digit for a base 2 literal + 0b9; //~ ERROR invalid digit for a base 2 literal +} diff --git a/src/test/ui/lexer/lex-bad-binary-literal.stderr b/src/test/ui/lexer/lex-bad-binary-literal.stderr new file mode 100644 index 000000000..992b3d248 --- /dev/null +++ b/src/test/ui/lexer/lex-bad-binary-literal.stderr @@ -0,0 +1,56 @@ +error: invalid digit for a base 2 literal + --> $DIR/lex-bad-binary-literal.rs:2:8 + | +LL | 0b121; + | ^ + +error: invalid digit for a base 2 literal + --> $DIR/lex-bad-binary-literal.rs:3:12 + | +LL | 0b10_10301; + | ^ + +error: invalid digit for a base 2 literal + --> $DIR/lex-bad-binary-literal.rs:4:7 + | +LL | 0b30; + | ^ + +error: invalid digit for a base 2 literal + --> $DIR/lex-bad-binary-literal.rs:5:7 + | +LL | 0b41; + | ^ + +error: invalid digit for a base 2 literal + --> $DIR/lex-bad-binary-literal.rs:6:7 + | +LL | 0b5; + | ^ + +error: invalid digit for a base 2 literal + --> $DIR/lex-bad-binary-literal.rs:7:7 + | +LL | 0b6; + | ^ + +error: invalid digit for a base 2 literal + --> $DIR/lex-bad-binary-literal.rs:8:7 + | +LL | 0b7; + | ^ + +error: invalid digit for a base 2 literal + --> $DIR/lex-bad-binary-literal.rs:9:7 + | +LL | 0b8; + | ^ + +error: invalid digit for a base 2 literal + --> $DIR/lex-bad-binary-literal.rs:10:7 + | +LL | 0b9; + | ^ + +error: aborting due to 9 previous errors + diff --git a/src/test/ui/lexer/lex-bad-char-literals-1.rs b/src/test/ui/lexer/lex-bad-char-literals-1.rs new file mode 100644 index 000000000..e7951cfd2 --- /dev/null +++ b/src/test/ui/lexer/lex-bad-char-literals-1.rs @@ -0,0 +1,17 @@ +static c3: char = + '\x1' //~ ERROR: numeric character escape is too short +; + +static s3: &'static str = + "\x1" //~ ERROR: numeric character escape is too short +; + +static c: char = + '\●' //~ ERROR: unknown character escape +; + +static s: &'static str = + "\●" //~ ERROR: unknown character escape +; + +fn main() {} diff --git a/src/test/ui/lexer/lex-bad-char-literals-1.stderr b/src/test/ui/lexer/lex-bad-char-literals-1.stderr new file mode 100644 index 000000000..e6ff1f662 --- /dev/null +++ b/src/test/ui/lexer/lex-bad-char-literals-1.stderr @@ -0,0 +1,38 @@ +error: numeric character escape is too short + --> $DIR/lex-bad-char-literals-1.rs:2:6 + | +LL | '\x1' + | ^^^ + +error: numeric character escape is too short + --> $DIR/lex-bad-char-literals-1.rs:6:6 + | +LL | "\x1" + | ^^^ + +error: unknown character escape: `\u{25cf}` + --> $DIR/lex-bad-char-literals-1.rs:10:7 + | +LL | '\●' + | ^ unknown character escape + | + = help: for more information, visit +help: if you meant to write a literal backslash (perhaps escaping in a regular expression), consider a raw string literal + | +LL | r"\●" + | ~~~~~ + +error: unknown character escape: `\u{25cf}` + --> $DIR/lex-bad-char-literals-1.rs:14:7 + | +LL | "\●" + | ^ unknown character escape + | + = help: for more information, visit +help: if you meant to write a literal backslash (perhaps escaping in a regular expression), consider a raw string literal + | +LL | r"\●" + | ~~~~~ + +error: aborting due to 4 previous errors + diff --git a/src/test/ui/lexer/lex-bad-char-literals-2.rs b/src/test/ui/lexer/lex-bad-char-literals-2.rs new file mode 100644 index 000000000..d35dafd9a --- /dev/null +++ b/src/test/ui/lexer/lex-bad-char-literals-2.rs @@ -0,0 +1,6 @@ +// This test needs to the last one appearing in this file as it kills the parser +static c: char = + 'nope' //~ ERROR: character literal may only contain one codepoint +; + +fn main() {} diff --git a/src/test/ui/lexer/lex-bad-char-literals-2.stderr b/src/test/ui/lexer/lex-bad-char-literals-2.stderr new file mode 100644 index 000000000..c2b19a7ad --- /dev/null +++ b/src/test/ui/lexer/lex-bad-char-literals-2.stderr @@ -0,0 +1,13 @@ +error: character literal may only contain one codepoint + --> $DIR/lex-bad-char-literals-2.rs:3:5 + | +LL | 'nope' + | ^^^^^^ + | +help: if you meant to write a `str` literal, use double quotes + | +LL | "nope" + | ~~~~~~ + +error: aborting due to previous error + diff --git a/src/test/ui/lexer/lex-bad-char-literals-3.rs b/src/test/ui/lexer/lex-bad-char-literals-3.rs new file mode 100644 index 000000000..5194ff4d9 --- /dev/null +++ b/src/test/ui/lexer/lex-bad-char-literals-3.rs @@ -0,0 +1,7 @@ +static c: char = '●●'; +//~^ ERROR: character literal may only contain one codepoint + +fn main() { + let ch: &str = '●●'; + //~^ ERROR: character literal may only contain one codepoint +} diff --git a/src/test/ui/lexer/lex-bad-char-literals-3.stderr b/src/test/ui/lexer/lex-bad-char-literals-3.stderr new file mode 100644 index 000000000..62a5e424c --- /dev/null +++ b/src/test/ui/lexer/lex-bad-char-literals-3.stderr @@ -0,0 +1,24 @@ +error: character literal may only contain one codepoint + --> $DIR/lex-bad-char-literals-3.rs:1:18 + | +LL | static c: char = '●●'; + | ^^^^ + | +help: if you meant to write a `str` literal, use double quotes + | +LL | static c: char = "●●"; + | ~~~~ + +error: character literal may only contain one codepoint + --> $DIR/lex-bad-char-literals-3.rs:5:20 + | +LL | let ch: &str = '●●'; + | ^^^^ + | +help: if you meant to write a `str` literal, use double quotes + | +LL | let ch: &str = "●●"; + | ~~~~ + +error: aborting due to 2 previous errors + diff --git a/src/test/ui/lexer/lex-bad-char-literals-4.rs b/src/test/ui/lexer/lex-bad-char-literals-4.rs new file mode 100644 index 000000000..de0a19df9 --- /dev/null +++ b/src/test/ui/lexer/lex-bad-char-literals-4.rs @@ -0,0 +1,5 @@ +// +// This test needs to the last one appearing in this file as it kills the parser +static c: char = + '● //~ ERROR: unterminated character literal +; diff --git a/src/test/ui/lexer/lex-bad-char-literals-4.stderr b/src/test/ui/lexer/lex-bad-char-literals-4.stderr new file mode 100644 index 000000000..fec4421c4 --- /dev/null +++ b/src/test/ui/lexer/lex-bad-char-literals-4.stderr @@ -0,0 +1,9 @@ +error[E0762]: unterminated character literal + --> $DIR/lex-bad-char-literals-4.rs:4:5 + | +LL | '● + | ^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0762`. diff --git a/src/test/ui/lexer/lex-bad-char-literals-5.rs b/src/test/ui/lexer/lex-bad-char-literals-5.rs new file mode 100644 index 000000000..0c4339edc --- /dev/null +++ b/src/test/ui/lexer/lex-bad-char-literals-5.rs @@ -0,0 +1,7 @@ +static c: char = '\x10\x10'; +//~^ ERROR: character literal may only contain one codepoint + +fn main() { + let ch: &str = '\x10\x10'; + //~^ ERROR: character literal may only contain one codepoint +} diff --git a/src/test/ui/lexer/lex-bad-char-literals-5.stderr b/src/test/ui/lexer/lex-bad-char-literals-5.stderr new file mode 100644 index 000000000..184817a65 --- /dev/null +++ b/src/test/ui/lexer/lex-bad-char-literals-5.stderr @@ -0,0 +1,24 @@ +error: character literal may only contain one codepoint + --> $DIR/lex-bad-char-literals-5.rs:1:18 + | +LL | static c: char = '\x10\x10'; + | ^^^^^^^^^^ + | +help: if you meant to write a `str` literal, use double quotes + | +LL | static c: char = "\x10\x10"; + | ~~~~~~~~~~ + +error: character literal may only contain one codepoint + --> $DIR/lex-bad-char-literals-5.rs:5:20 + | +LL | let ch: &str = '\x10\x10'; + | ^^^^^^^^^^ + | +help: if you meant to write a `str` literal, use double quotes + | +LL | let ch: &str = "\x10\x10"; + | ~~~~~~~~~~ + +error: aborting due to 2 previous errors + diff --git a/src/test/ui/lexer/lex-bad-char-literals-6.rs b/src/test/ui/lexer/lex-bad-char-literals-6.rs new file mode 100644 index 000000000..4379b4fa6 --- /dev/null +++ b/src/test/ui/lexer/lex-bad-char-literals-6.rs @@ -0,0 +1,17 @@ +fn main() { + let x: &str = 'ab'; + //~^ ERROR: character literal may only contain one codepoint + let y: char = 'cd'; + //~^ ERROR: character literal may only contain one codepoint + let z = 'ef'; + //~^ ERROR: character literal may only contain one codepoint + + if x == y {} + //~^ ERROR: can't compare `&str` with `char` + if y == z {} // no error here + if x == z {} + //~^ ERROR: can't compare `&str` with `char` + + let a: usize = ""; + //~^ ERROR: mismatched types +} diff --git a/src/test/ui/lexer/lex-bad-char-literals-6.stderr b/src/test/ui/lexer/lex-bad-char-literals-6.stderr new file mode 100644 index 000000000..afef0cb60 --- /dev/null +++ b/src/test/ui/lexer/lex-bad-char-literals-6.stderr @@ -0,0 +1,81 @@ +error: character literal may only contain one codepoint + --> $DIR/lex-bad-char-literals-6.rs:2:19 + | +LL | let x: &str = 'ab'; + | ^^^^ + | +help: if you meant to write a `str` literal, use double quotes + | +LL | let x: &str = "ab"; + | ~~~~ + +error: character literal may only contain one codepoint + --> $DIR/lex-bad-char-literals-6.rs:4:19 + | +LL | let y: char = 'cd'; + | ^^^^ + | +help: if you meant to write a `str` literal, use double quotes + | +LL | let y: char = "cd"; + | ~~~~ + +error: character literal may only contain one codepoint + --> $DIR/lex-bad-char-literals-6.rs:6:13 + | +LL | let z = 'ef'; + | ^^^^ + | +help: if you meant to write a `str` literal, use double quotes + | +LL | let z = "ef"; + | ~~~~ + +error[E0277]: can't compare `&str` with `char` + --> $DIR/lex-bad-char-literals-6.rs:9:10 + | +LL | if x == y {} + | ^^ no implementation for `&str == char` + | + = help: the trait `PartialEq` is not implemented for `&str` + = help: the following other types implement trait `PartialEq`: + <&'a str as PartialEq> + <&'a str as PartialEq> + <&'b str as PartialEq>> + > + >> + > + + >> + and 4 others + +error[E0308]: mismatched types + --> $DIR/lex-bad-char-literals-6.rs:15:20 + | +LL | let a: usize = ""; + | ----- ^^ expected `usize`, found `&str` + | | + | expected due to this + +error[E0277]: can't compare `&str` with `char` + --> $DIR/lex-bad-char-literals-6.rs:12:10 + | +LL | if x == z {} + | ^^ no implementation for `&str == char` + | + = help: the trait `PartialEq` is not implemented for `&str` + = help: the following other types implement trait `PartialEq`: + <&'a str as PartialEq> + <&'a str as PartialEq> + <&'b str as PartialEq>> + > + >> + > + + >> + and 4 others + +error: aborting due to 6 previous errors + +Some errors have detailed explanations: E0277, E0308. +For more information about an error, try `rustc --explain E0277`. diff --git a/src/test/ui/lexer/lex-bad-char-literals-7.rs b/src/test/ui/lexer/lex-bad-char-literals-7.rs new file mode 100644 index 000000000..c675df2f3 --- /dev/null +++ b/src/test/ui/lexer/lex-bad-char-literals-7.rs @@ -0,0 +1,13 @@ +fn main() { + let _: char = ''; + //~^ ERROR: empty character literal + let _: char = '\u{}'; + //~^ ERROR: empty unicode escape + + // Next two are OK, but may befool error recovery + let _ = '/'; + let _ = b'/'; + + let _ = ' hello // here's a comment + //~^ ERROR: unterminated character literal +} diff --git a/src/test/ui/lexer/lex-bad-char-literals-7.stderr b/src/test/ui/lexer/lex-bad-char-literals-7.stderr new file mode 100644 index 000000000..255b9c689 --- /dev/null +++ b/src/test/ui/lexer/lex-bad-char-literals-7.stderr @@ -0,0 +1,21 @@ +error: empty character literal + --> $DIR/lex-bad-char-literals-7.rs:2:20 + | +LL | let _: char = ''; + | ^ empty character literal + +error: empty unicode escape + --> $DIR/lex-bad-char-literals-7.rs:4:20 + | +LL | let _: char = '\u{}'; + | ^^^^ this escape must have at least 1 hex digit + +error[E0762]: unterminated character literal + --> $DIR/lex-bad-char-literals-7.rs:11:13 + | +LL | let _ = ' hello // here's a comment + | ^^^^^^^^ + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0762`. diff --git a/src/test/ui/lexer/lex-bad-numeric-literals.rs b/src/test/ui/lexer/lex-bad-numeric-literals.rs new file mode 100644 index 000000000..cf8440ca4 --- /dev/null +++ b/src/test/ui/lexer/lex-bad-numeric-literals.rs @@ -0,0 +1,27 @@ +fn main() { + 0o1.0; //~ ERROR: octal float literal is not supported + 0o2f32; //~ ERROR: octal float literal is not supported + 0o3.0f32; //~ ERROR: octal float literal is not supported + 0o4e4; //~ ERROR: octal float literal is not supported + 0o5.0e5; //~ ERROR: octal float literal is not supported + 0o6e6f32; //~ ERROR: octal float literal is not supported + 0o7.0e7f64; //~ ERROR: octal float literal is not supported + 0x8.0e+9; //~ ERROR: hexadecimal float literal is not supported + 0x9.0e-9; //~ ERROR: hexadecimal float literal is not supported + 0o; //~ ERROR: no valid digits + 1e+; //~ ERROR: expected at least one digit in exponent + 0x539.0; //~ ERROR: hexadecimal float literal is not supported + 9900000000000000000000000000999999999999999999999999999999; + //~^ ERROR: integer literal is too large + 9900000000000000000000000000999999999999999999999999999999; + //~^ ERROR: integer literal is too large + 0x; //~ ERROR: no valid digits + 0xu32; //~ ERROR: no valid digits + 0ou32; //~ ERROR: no valid digits + 0bu32; //~ ERROR: no valid digits + 0b; //~ ERROR: no valid digits + 0o123f64; //~ ERROR: octal float literal is not supported + 0o123.456; //~ ERROR: octal float literal is not supported + 0b101f64; //~ ERROR: binary float literal is not supported + 0b111.101; //~ ERROR: binary float literal is not supported +} diff --git a/src/test/ui/lexer/lex-bad-numeric-literals.stderr b/src/test/ui/lexer/lex-bad-numeric-literals.stderr new file mode 100644 index 000000000..f05d61603 --- /dev/null +++ b/src/test/ui/lexer/lex-bad-numeric-literals.stderr @@ -0,0 +1,141 @@ +error: octal float literal is not supported + --> $DIR/lex-bad-numeric-literals.rs:2:5 + | +LL | 0o1.0; + | ^^^^^ + +error: octal float literal is not supported + --> $DIR/lex-bad-numeric-literals.rs:4:5 + | +LL | 0o3.0f32; + | ^^^^^ + +error: octal float literal is not supported + --> $DIR/lex-bad-numeric-literals.rs:5:5 + | +LL | 0o4e4; + | ^^^^^ + +error: octal float literal is not supported + --> $DIR/lex-bad-numeric-literals.rs:6:5 + | +LL | 0o5.0e5; + | ^^^^^^^ + +error: octal float literal is not supported + --> $DIR/lex-bad-numeric-literals.rs:7:5 + | +LL | 0o6e6f32; + | ^^^^^ + +error: octal float literal is not supported + --> $DIR/lex-bad-numeric-literals.rs:8:5 + | +LL | 0o7.0e7f64; + | ^^^^^^^ + +error: hexadecimal float literal is not supported + --> $DIR/lex-bad-numeric-literals.rs:9:5 + | +LL | 0x8.0e+9; + | ^^^^^^^^ + +error: hexadecimal float literal is not supported + --> $DIR/lex-bad-numeric-literals.rs:10:5 + | +LL | 0x9.0e-9; + | ^^^^^^^^ + +error[E0768]: no valid digits found for number + --> $DIR/lex-bad-numeric-literals.rs:11:5 + | +LL | 0o; + | ^^ + +error: expected at least one digit in exponent + --> $DIR/lex-bad-numeric-literals.rs:12:5 + | +LL | 1e+; + | ^^^ + +error: hexadecimal float literal is not supported + --> $DIR/lex-bad-numeric-literals.rs:13:5 + | +LL | 0x539.0; + | ^^^^^^^ + +error[E0768]: no valid digits found for number + --> $DIR/lex-bad-numeric-literals.rs:18:5 + | +LL | 0x; + | ^^ + +error[E0768]: no valid digits found for number + --> $DIR/lex-bad-numeric-literals.rs:19:5 + | +LL | 0xu32; + | ^^ + +error[E0768]: no valid digits found for number + --> $DIR/lex-bad-numeric-literals.rs:20:5 + | +LL | 0ou32; + | ^^ + +error[E0768]: no valid digits found for number + --> $DIR/lex-bad-numeric-literals.rs:21:5 + | +LL | 0bu32; + | ^^ + +error[E0768]: no valid digits found for number + --> $DIR/lex-bad-numeric-literals.rs:22:5 + | +LL | 0b; + | ^^ + +error: octal float literal is not supported + --> $DIR/lex-bad-numeric-literals.rs:24:5 + | +LL | 0o123.456; + | ^^^^^^^^^ + +error: binary float literal is not supported + --> $DIR/lex-bad-numeric-literals.rs:26:5 + | +LL | 0b111.101; + | ^^^^^^^^^ + +error: octal float literal is not supported + --> $DIR/lex-bad-numeric-literals.rs:3:5 + | +LL | 0o2f32; + | ^^^^^^ not supported + +error: integer literal is too large + --> $DIR/lex-bad-numeric-literals.rs:14:5 + | +LL | 9900000000000000000000000000999999999999999999999999999999; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: integer literal is too large + --> $DIR/lex-bad-numeric-literals.rs:16:5 + | +LL | 9900000000000000000000000000999999999999999999999999999999; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: octal float literal is not supported + --> $DIR/lex-bad-numeric-literals.rs:23:5 + | +LL | 0o123f64; + | ^^^^^^^^ not supported + +error: binary float literal is not supported + --> $DIR/lex-bad-numeric-literals.rs:25:5 + | +LL | 0b101f64; + | ^^^^^^^^ not supported + +error: aborting due to 23 previous errors + +For more information about this error, try `rustc --explain E0768`. diff --git a/src/test/ui/lexer/lex-bad-octal-literal.rs b/src/test/ui/lexer/lex-bad-octal-literal.rs new file mode 100644 index 000000000..49631f16b --- /dev/null +++ b/src/test/ui/lexer/lex-bad-octal-literal.rs @@ -0,0 +1,4 @@ +fn main() { + 0o18; //~ ERROR invalid digit for a base 8 literal + 0o1234_9_5670; //~ ERROR invalid digit for a base 8 literal +} diff --git a/src/test/ui/lexer/lex-bad-octal-literal.stderr b/src/test/ui/lexer/lex-bad-octal-literal.stderr new file mode 100644 index 000000000..2cb8ca5de --- /dev/null +++ b/src/test/ui/lexer/lex-bad-octal-literal.stderr @@ -0,0 +1,14 @@ +error: invalid digit for a base 8 literal + --> $DIR/lex-bad-octal-literal.rs:2:8 + | +LL | 0o18; + | ^ + +error: invalid digit for a base 8 literal + --> $DIR/lex-bad-octal-literal.rs:3:12 + | +LL | 0o1234_9_5670; + | ^ + +error: aborting due to 2 previous errors + diff --git a/src/test/ui/lexer/lex-bad-token.rs b/src/test/ui/lexer/lex-bad-token.rs new file mode 100644 index 000000000..9e4824611 --- /dev/null +++ b/src/test/ui/lexer/lex-bad-token.rs @@ -0,0 +1,3 @@ +● //~ ERROR: unknown start of token + +fn main() {} diff --git a/src/test/ui/lexer/lex-bad-token.stderr b/src/test/ui/lexer/lex-bad-token.stderr new file mode 100644 index 000000000..43c43721b --- /dev/null +++ b/src/test/ui/lexer/lex-bad-token.stderr @@ -0,0 +1,8 @@ +error: unknown start of token: \u{25cf} + --> $DIR/lex-bad-token.rs:1:1 + | +LL | ● + | ^ + +error: aborting due to previous error + diff --git a/src/test/ui/lexer/lex-bare-cr-nondoc-comment.rs b/src/test/ui/lexer/lex-bare-cr-nondoc-comment.rs new file mode 100644 index 000000000..5b528d6e1 --- /dev/null +++ b/src/test/ui/lexer/lex-bare-cr-nondoc-comment.rs @@ -0,0 +1,9 @@ +// run-pass +// ignore-tidy-cr + +// nondoc comment with bare CR: ' ' +//// nondoc comment with bare CR: ' ' +/* block nondoc comment with bare CR: ' ' */ + +fn main() { +} diff --git a/src/test/ui/lexer/lex-bare-cr-string-literal-doc-comment.rs b/src/test/ui/lexer/lex-bare-cr-string-literal-doc-comment.rs new file mode 100644 index 000000000..b7752e1f0 --- /dev/null +++ b/src/test/ui/lexer/lex-bare-cr-string-literal-doc-comment.rs @@ -0,0 +1,26 @@ +// ignore-tidy-cr + +/// doc comment with bare CR: ' ' +pub fn foo() {} +//~^^ ERROR: bare CR not allowed in doc-comment + +/** block doc comment with bare CR: ' ' */ +pub fn bar() {} +//~^^ ERROR: bare CR not allowed in block doc-comment + +fn main() { + //! doc comment with bare CR: ' ' + //~^ ERROR: bare CR not allowed in doc-comment + + /*! block doc comment with bare CR: ' ' */ + //~^ ERROR: bare CR not allowed in block doc-comment + + // the following string literal has a bare CR in it + let _s = "foo bar"; //~ ERROR: bare CR not allowed in string + + // the following string literal has a bare CR in it + let _s = r"bar foo"; //~ ERROR: bare CR not allowed in raw string + + // the following string literal has a bare CR in it + let _s = "foo\ bar"; //~ ERROR: unknown character escape: `\r` +} diff --git a/src/test/ui/lexer/lex-bare-cr-string-literal-doc-comment.stderr b/src/test/ui/lexer/lex-bare-cr-string-literal-doc-comment.stderr new file mode 100644 index 000000000..1a21fed63 --- /dev/null +++ b/src/test/ui/lexer/lex-bare-cr-string-literal-doc-comment.stderr @@ -0,0 +1,46 @@ +error: bare CR not allowed in doc-comment + --> $DIR/lex-bare-cr-string-literal-doc-comment.rs:3:32 + | +LL | /// doc comment with bare CR: ' ' + | ^ + +error: bare CR not allowed in block doc-comment + --> $DIR/lex-bare-cr-string-literal-doc-comment.rs:7:38 + | +LL | /** block doc comment with bare CR: ' ' */ + | ^ + +error: bare CR not allowed in doc-comment + --> $DIR/lex-bare-cr-string-literal-doc-comment.rs:12:36 + | +LL | //! doc comment with bare CR: ' ' + | ^ + +error: bare CR not allowed in block doc-comment + --> $DIR/lex-bare-cr-string-literal-doc-comment.rs:15:42 + | +LL | /*! block doc comment with bare CR: ' ' */ + | ^ + +error: bare CR not allowed in string, use `\r` instead + --> $DIR/lex-bare-cr-string-literal-doc-comment.rs:19:18 + | +LL | let _s = "foo bar"; + | ^ help: escape the character: `\r` + +error: bare CR not allowed in raw string + --> $DIR/lex-bare-cr-string-literal-doc-comment.rs:22:19 + | +LL | let _s = r"bar foo"; + | ^ + +error: unknown character escape: `\r` + --> $DIR/lex-bare-cr-string-literal-doc-comment.rs:25:19 + | +LL | let _s = "foo\ bar"; + | ^ unknown character escape + | + = help: this is an isolated carriage return; consider checking your editor and version control settings + +error: aborting due to 7 previous errors + diff --git a/src/test/ui/lexer/lex-stray-backslash.rs b/src/test/ui/lexer/lex-stray-backslash.rs new file mode 100644 index 000000000..bb27f44c2 --- /dev/null +++ b/src/test/ui/lexer/lex-stray-backslash.rs @@ -0,0 +1,3 @@ +\ //~ ERROR: unknown start of token: \ + +fn main() {} diff --git a/src/test/ui/lexer/lex-stray-backslash.stderr b/src/test/ui/lexer/lex-stray-backslash.stderr new file mode 100644 index 000000000..06dc0f2b5 --- /dev/null +++ b/src/test/ui/lexer/lex-stray-backslash.stderr @@ -0,0 +1,8 @@ +error: unknown start of token: \ + --> $DIR/lex-stray-backslash.rs:1:1 + | +LL | \ + | ^ + +error: aborting due to previous error + diff --git a/src/test/ui/lexer/lexer-crlf-line-endings-string-literal-doc-comment.rs b/src/test/ui/lexer/lexer-crlf-line-endings-string-literal-doc-comment.rs new file mode 100644 index 000000000..802be7f5a --- /dev/null +++ b/src/test/ui/lexer/lexer-crlf-line-endings-string-literal-doc-comment.rs @@ -0,0 +1,38 @@ +// run-pass +// ignore-tidy-cr +// ignore-tidy-cr (repeated again because of tidy bug) +// license is ignored because tidy can't handle the CRLF here properly. + +// N.B., this file needs CRLF line endings. The .gitattributes file in +// this directory should enforce it. + +// ignore-pretty issue #37195 + +/// Doc comment that ends in CRLF +pub fn foo() {} + +/** Block doc comment that + * contains CRLF characters + */ +pub fn bar() {} + +fn main() { + let s = "string +literal"; + assert_eq!(s, "string\nliteral"); + + let s = "literal with \ + escaped newline"; + assert_eq!(s, "literal with escaped newline"); + + let s = r"string +literal"; + assert_eq!(s, "string\nliteral"); + let s = br"byte string +literal"; + assert_eq!(s, "byte string\nliteral".as_bytes()); + + // validate that our source file has CRLF endings + let source = include_str!("lexer-crlf-line-endings-string-literal-doc-comment.rs"); + assert!(source.contains("string\r\nliteral")); +} -- cgit v1.2.3