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

Un-skipped whitespace after backslash in string literal should be warned about #87318

Closed
scottmcm opened this issue Jul 20, 2021 · 2 comments
Closed
Assignees
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-lint Area: Lints (warnings about flaws in source code) such as unused_mut.

Comments

@scottmcm
Copy link
Member

scottmcm commented Jul 20, 2021

let b = "foo\
         bar";
let c = "foo\
         bar";
dbg!((b,c));

https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=a8ab2d71eb82732581a9b6aedde68aed

[src/main.rs:6] (b, c) = (
    "foobar",
    "foo\u{a0}      bar",
)

Like we have confusables lints, I think this should have a warning noting that the particular kind of whitespace is not actually being skipped here, since that's completely invisible when looking at the code.

(Based on rust-lang/reference#1042 I think this would warn for things where char::is_whitespace is true but that isn't ' ', '\t', '\r', or '\n' -- with #87319 being a related lint that would warn on '\r' and '\n' after the first one.)

@scottmcm scottmcm added A-lint Area: Lints (warnings about flaws in source code) such as unused_mut. A-diagnostics Area: Messages for errors, warnings, and lints labels Jul 20, 2021
@jesyspa
Copy link
Contributor

jesyspa commented Jul 28, 2021

@rustbot claim

JohnTitor added a commit to JohnTitor/rust that referenced this issue Jul 30, 2021
…ce, r=estebank

Add warning when whitespace is not skipped after an escaped newline

Fixes issue rust-lang#87318, also simplifies issue rust-lang#87319.

* Add support to the lexer to emit warnings as well as errors.
* Emit a warning when a string literal contains an escaped newline, but when (some of) the whitespace on the next line is not skipped due to it being non-ASCII.
JohnTitor added a commit to JohnTitor/rust that referenced this issue Jul 30, 2021
…ce, r=estebank

Add warning when whitespace is not skipped after an escaped newline

Fixes issue rust-lang#87318, also simplifies issue rust-lang#87319.

* Add support to the lexer to emit warnings as well as errors.
* Emit a warning when a string literal contains an escaped newline, but when (some of) the whitespace on the next line is not skipped due to it being non-ASCII.
@JohnTitor
Copy link
Member

Fixed by #87596.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-lint Area: Lints (warnings about flaws in source code) such as unused_mut.
Projects
None yet
Development

No branches or pull requests

3 participants