Skip to content
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

Handle str literals written with ' lexed as lifetime #122217

Merged
merged 6 commits into from
Mar 24, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions tests/ui/lexer/lex-bad-str-literal-as-char-3.fixed

This file was deleted.

8 changes: 6 additions & 2 deletions tests/ui/lexer/lex-bad-str-literal-as-char-3.rs
estebank marked this conversation as resolved.
Show resolved Hide resolved
estebank marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
//@ run-rustfix
//@ revisions: rust2015 rust2018 rust2021
//@[rust2018] edition:2018
//@[rust2021] edition:2021
fn main() {
println!('hello world'); //~ ERROR unterminated character literal
println!('hello world');
//[rust2015,rust2018,rust2021]~^ ERROR unterminated character literal
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could be simplified to

Suggested change
//[rust2015,rust2018,rust2021]~^ ERROR unterminated character literal
//~^ ERROR unterminated character literal

but not blocking.

//[rust2021]~^^ ERROR prefix `world` is unknown
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
error[E0762]: unterminated character literal
--> $DIR/lex-bad-str-literal-as-char-3.rs:3:26
--> $DIR/lex-bad-str-literal-as-char-3.rs:5:26
|
LL | println!('hello world');
| ^^^^
| ^^^
|
help: if you meant to write a string literal, use double quotes
|
Expand Down
14 changes: 14 additions & 0 deletions tests/ui/lexer/lex-bad-str-literal-as-char-3.rust2018.stderr
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:5:26
|
LL | println!('hello world');
| ^^^
|
help: if you meant to write a string 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`.
26 changes: 26 additions & 0 deletions tests/ui/lexer/lex-bad-str-literal-as-char-3.rust2021.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
error: prefix `world` is unknown
--> $DIR/lex-bad-str-literal-as-char-3.rs:5:21
|
LL | println!('hello world');
| ^^^^^ unknown prefix
|
= note: prefixed identifiers and literals are reserved since Rust 2021
help: if you meant to write a string literal, use double quotes
|
LL | println!("hello world");
| ~ ~

error[E0762]: unterminated character literal
--> $DIR/lex-bad-str-literal-as-char-3.rs:5:26
|
LL | println!('hello world');
| ^^^
|
help: if you meant to write a string literal, use double quotes
|
LL | println!("hello world");
| ~ ~

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0762`.