forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Handle str literals written with
'
lexed as lifetime
Given `'hello world'` and `'1 str', provide a structured suggestion for a valid string literal: ``` error[E0762]: unterminated character literal --> $DIR/lex-bad-str-literal-as-char-3.rs:2:26 | LL | println!('hello world'); | ^^^^ | help: if you meant to write a `str` literal, use double quotes | LL | println!("hello world"); | ~ ~ ``` ``` error[E0762]: unterminated character literal --> $DIR/lex-bad-str-literal-as-char-1.rs:2:20 | LL | println!('1 + 1'); | ^^^^ | help: if you meant to write a `str` literal, use double quotes | LL | println!("1 + 1"); | ~ ~ ``` Fix rust-lang#119685.
- Loading branch information
Showing
13 changed files
with
135 additions
and
5 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
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
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,6 @@ | ||
//@ run-rustfix | ||
fn main() { | ||
println!("1 + 1"); | ||
//~^ ERROR unterminated character literal | ||
//~| ERROR lifetimes cannot start with a number | ||
} |
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,6 @@ | ||
//@ run-rustfix | ||
fn main() { | ||
println!('1 + 1'); | ||
//~^ ERROR unterminated character literal | ||
//~| ERROR lifetimes cannot start with a number | ||
} |
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[E0762]: unterminated character literal | ||
--> $DIR/lex-bad-str-literal-as-char-1.rs:3:20 | ||
| | ||
LL | println!('1 + 1'); | ||
| ^^^ | ||
| | ||
help: if you meant to write a `str` literal, use double quotes | ||
| | ||
LL | println!("1 + 1"); | ||
| ~ ~ | ||
|
||
error: lifetimes cannot start with a number | ||
--> $DIR/lex-bad-str-literal-as-char-1.rs:3:14 | ||
| | ||
LL | println!('1 + 1'); | ||
| ^^ | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0762`. |
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,4 @@ | ||
//@ run-rustfix | ||
fn main() { | ||
println!(" 1 + 1"); //~ ERROR character literal may only contain one codepoint | ||
} |
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,4 @@ | ||
//@ run-rustfix | ||
fn main() { | ||
println!(' 1 + 1'); //~ ERROR character literal may only contain one codepoint | ||
} |
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,13 @@ | ||
error: character literal may only contain one codepoint | ||
--> $DIR/lex-bad-str-literal-as-char-2.rs:3:14 | ||
| | ||
LL | println!(' 1 + 1'); | ||
| ^^^^^^^^ | ||
| | ||
help: if you meant to write a `str` literal, use double quotes | ||
| | ||
LL | println!(" 1 + 1"); | ||
| ~~~~~~~~ | ||
|
||
error: aborting due to 1 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,4 @@ | ||
//@ run-rustfix | ||
fn main() { | ||
println!("hello world"); //~ ERROR unterminated character literal | ||
} |
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,4 @@ | ||
//@ run-rustfix | ||
fn main() { | ||
println!('hello world'); //~ ERROR unterminated character literal | ||
} |
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,14 @@ | ||
error[E0762]: unterminated character literal | ||
--> $DIR/lex-bad-str-literal-as-char-3.rs:3:26 | ||
| | ||
LL | println!('hello world'); | ||
| ^^^^ | ||
| | ||
help: if you meant to write a `str` literal, use double quotes | ||
| | ||
LL | println!("hello world"); | ||
| ~ ~ | ||
|
||
error: aborting due to 1 previous error | ||
|
||
For more information about this error, try `rustc --explain E0762`. |