-
Notifications
You must be signed in to change notification settings - Fork 12.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
improved error reporting on lexer with raw literals
The lexer now emits a suggestion for `cargo fix`
- Loading branch information
Showing
10 changed files
with
162 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,12 @@ | ||
error: unterminated raw string | ||
--> $DIR/raw-byte-string-eof.rs:2:6 | ||
--> $DIR/raw-byte-string-eof.rs:2:5 | ||
| | ||
LL | br##"a"#; | ||
| ^ unterminated raw string | ||
| ^^^^ unterminated raw string | ||
help: you might have meant to end the raw string here | ||
| | ||
= note: this raw string should be terminated with `"##` | ||
LL | br##"a'##; | ||
| ^^^ | ||
|
||
error: aborting due to previous error | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
error: found invalid character; only `#` is allowed in raw string delimitation: ~ | ||
--> $DIR/raw-str-delim.rs:2:5 | ||
error: found invalid character; only `#` is allowed in raw string delimitation | ||
--> $DIR/raw-str-delim.rs:2:7 | ||
| | ||
LL | r#~"#"~# | ||
| ^^ | ||
| ^ | ||
= help: replace with `#` | ||
|
||
error: aborting due to previous error | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// check-pass | ||
|
||
macro_rules! m1 { | ||
($tt:tt #) => () | ||
} | ||
|
||
macro_rules! m2 { | ||
($tt:tt) => () | ||
} | ||
|
||
macro_rules! m3 { | ||
($tt:tt #) => () | ||
} | ||
|
||
fn main() { | ||
m1!(r#"abc"##); | ||
m2!(r#"abc"##); | ||
m3!(r#"abc"#); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
error: no rules expected the token `#` | ||
--> $DIR/raw-str-in-macro-call.rs:17:17 | ||
| | ||
LL | macro_rules! m2 { | ||
| --------------- when calling this macro | ||
... | ||
LL | m2!(r#"abc"##); | ||
| ^ no rules expected this token in macro call | ||
|
||
error: unexpected end of macro invocation | ||
--> $DIR/raw-str-in-macro-call.rs:18:5 | ||
| | ||
LL | macro_rules! m3 { | ||
| --------------- when calling this macro | ||
... | ||
LL | m3!(r#"abc"#); | ||
| ^^^^^^^^^^^^^^ missing tokens in macro arguments | ||
|
||
error: aborting due to 2 previous errors | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
fn main() { | ||
let a = r##"This //~ ERROR unterminated raw string | ||
is | ||
a | ||
very | ||
long | ||
string | ||
which | ||
goes | ||
over | ||
a | ||
b | ||
c | ||
d | ||
e | ||
f | ||
g | ||
h | ||
lines | ||
"#; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
error: unterminated raw string | ||
--> $DIR/raw-str-long.rs:2:13 | ||
| | ||
LL | let a = r##"This | ||
| ^^^ unterminated raw string | ||
help: you might have meant to end the raw string here | ||
| | ||
LL | "##; | ||
| ^^^ | ||
|
||
error: aborting due to previous error | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,12 @@ | ||
error: unterminated raw string | ||
--> $DIR/raw_string.rs:2:13 | ||
--> $DIR/raw-str.rs:2:13 | ||
| | ||
LL | let x = r##"lol"#; | ||
| ^ unterminated raw string | ||
| ^^^ unterminated raw string | ||
help: you might have meant to end the raw string here | ||
| | ||
= note: this raw string should be terminated with `"##` | ||
LL | let x = r##"lol'##; | ||
| ^^^ | ||
|
||
error: aborting due to previous error | ||
|