-
Notifications
You must be signed in to change notification settings - Fork 13k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve raw string diagnostic #61255
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
error: unterminated raw string | ||
--> $DIR/raw-byte-string-eof.rs:2:5 | ||
| | ||
LL | br##"a"#; | ||
| ^^^^ unterminated raw string | ||
help: you might have meant to end the raw string here | ||
| | ||
LL | br##"a'##; | ||
| ^^^ | ||
|
||
error: aborting due to previous error | ||
|
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 | ||
|
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"#); | ||
} | ||
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 | ||
|
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 | ||
"#; | ||
} |
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 | "##; | ||
| ^^^ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm worried about the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. True, the reason for it is, that I look for |
||
|
||
error: aborting due to previous error | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,9 +2,7 @@ error: unterminated raw string | |
--> $DIR/raw-str-unterminated.rs:2:5 | ||
| | ||
LL | r#" string literal goes on | ||
| ^ unterminated raw string | ||
| | ||
= note: this raw string should be terminated with `"#` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe we should keep the current |
||
| ^^ unterminated raw string | ||
|
||
error: aborting due to previous error | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
error: unterminated raw string | ||
--> $DIR/raw-str.rs:2:13 | ||
| | ||
LL | let x = r##"lol"#; | ||
| ^^^ unterminated raw string | ||
help: you might have meant to end the raw string here | ||
| | ||
LL | let x = r##"lol'##; | ||
| ^^^ | ||
|
||
error: aborting due to previous error | ||
|
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add another tests with the following combinations?
Just want us to catch any regressions in the future.