-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Disallow newlines in strings #7053
Comments
I agree that we need raw strings, but that's no reason to disallow newlines in normal strings. Firstly, it's such an unlikely error that crippling strings just to prevent it is silly. Secondly, any editor with syntax highlighting (read: 99.9999996% of all editors) will immediately make this error apparent. Rob Pike may abhor syntax highlighting, but we have no such aversion. Thirdly, we already give a good error here: fn main() {
let c = "foo;
let d = "bar";
}
|
Also note that restricting newlines to raw strings would mean that we wouldn't be able to use |
I tend to agree with @bstrie here. |
The LWN article is wrong about D, as it does allow literal newlines inside all of the string literals it supports. |
When I use strings, ~90% of the time I want normal (i.e., non-raw) strings that support newlines. I do not want to rewrite huge swathes of code to use raw strings in order to have the compiler respect my decision to hit the Enter key. That would drive me batty. |
We have raw strings. We have newlines. I don't think anything needs to change. |
(Nominating) |
notabug! closing! |
…, r=camsteffen,flip1995 Fixing FPs for the `branches_sharing_code` lint Fixes rust-lang#7053 Fixes rust-lang#7054 And an additional CSS adjustment to support dark mode for every inline code. It currently only works in paragraphs, which was an oversight on my part 😅. [Current Example](https://rust-lang.github.io/rust-clippy/master/index.html#blacklisted_name) This also includes ~50 lines of doc comments and is therefor not as big as the changes would indicate. 🐧 --- changelog: none All of these bugs were introduced in this dev version and are therefor not worth a change log entry. r? `@phansch` cc: `@camsteffen` since you have a pretty good overview of the `SpanlessEq` implementation 🙃
From LWN:
The modern trend seems to be to disallow literal newlines inside quoted strings, so that missing quote characters can be quickly detected by the compiler or interpreter. Go follows this trend and, like D, uses the back quote (rather than the Python triple-quote) to surround "raw" strings in which escapes are not recognized and newlines are permitted. Rust bucks the trend by allowing literal newlines in strings and does not provide for uninterpreted strings at all.
Is detecting missing quote characters important? We may already want raw strings so perhaps there's there's no need to 'buck the trend' here.
The text was updated successfully, but these errors were encountered: