-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
Add error message for using >= 65535 hashes for raw string literal escapes #50296
Conversation
This comment has been minimized.
This comment has been minimized.
src/test/ui/raw_string_hash_count.rs
Outdated
// except according to those terms. | ||
|
||
fn main() { | ||
let x = r################################################################################################################################################################################################################################################################"test"################################################################################################################################################################################################################################################################ |
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.
This file needs an // ignore-tidy-linelength
header.
This comment has been minimized.
This comment has been minimized.
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.
It's looking good to me! I just left a few very minor comments.
The test is currently failing because the offset in the line/column number is wrong (after you added the line to ignore tidy), but once you tweak the range/text you can just regenerate it.
error: too many `#` characters surrounding a raw string; only 255 or fewer characters can be used | ||
--> src/test/ui/raw_string_hash_count.rs:12:13 | ||
| | ||
LL | let x = r################################################################################################################################################################################################################################################################"test"################################################################################################################################################################################################################################################################ |
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.
Is it possible to offset the range by 1, so that it underlines all the #
on the left hand side (i.e. at the moment, the r
is included, but not the final #
).
src/test/ui/raw_string_hash_count.rs
Outdated
// ignore-tidy-linelength | ||
|
||
fn main() { | ||
let x = r################################################################################################################################################################################################################################################################"test"################################################################################################################################################################################################################################################################ |
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.
For simplicity, you can eliminate the variable as well, and just have the raw string as a standalone statement.
src/libsyntax/parse/lexer/mod.rs
Outdated
let last_bpos = self.pos; | ||
self.fatal_span_(start_bpos, | ||
last_bpos, | ||
"too many `#` characters surrounding a raw string; \ |
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.
Maybe clarify to "raw byte string". It's probably fine to only test one of them, though, as it's a minor error. Also, the indentation here is off.
src/libsyntax/parse/lexer/mod.rs
Outdated
let last_bpos = self.pos; | ||
self.fatal_span_(start_bpos, | ||
last_bpos, | ||
"too many `#` characters surrounding a raw string; \ |
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.
The wording could be a little more concise here. Maybe:
too many `#` symbols: raw strings may be delimited by up to 255 `#` symbols
(and same for byte strings).
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
@@ -0,0 +1,8 @@ | |||
error: too many `#` symbols: raw strings may be delimited by up to 255 `#` symbols | |||
--> src/test/ui/raw_string_hash_count.rs:14:5 |
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.
You need to replace src/test/ui
with $DIR
.
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
src/test/ui/raw_string_hash_count.rs
Outdated
|
||
fn main() { | ||
r################################################################################################################################################################################################################################################################"test"################################################################################################################################################################################################################################################################; | ||
//~^ ERROR too many `#` characters |
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.
This needs to be updated to use symbols
instead of characters
.
Why do we want to do this? cc @rust-lang/compiler |
Probably for better diagnostics? We either introduce some limit or make the number of hashes technically unlimited by counting them into u64 or larger. |
Idk. Doesn't feel like something that we are allowed to break under the breaking change rules. Then again, seems like an accident that such riddiculous numbers of hashes are allowed. |
I feel ok about going to |
@nikomatsakis I don't thinks this helps anything. @nnethercote changed it to |
OK, point is, we can impose a limit. I'm indifferent about what limit we impose. |
@CMDD could you squash your commits? |
@estebank commits have been squashed, hopefully without messing anything up in the process |
I'm nominating this PR for discussion, on the topic of what limits can an implementation reasonably have (rustc currently uses |
We discussed this in the lang team meeting, and we all agreed that we can safely limit this to 255 without concern. |
@CMDD merge conflict :( |
@CMDD you should rebase on master, even if you don't see any conflict at first glance. |
Sorry for the delay! I've rebased onto master. |
@nikomatsakis Are these changes good to be pushed onto |
@bors r+ |
📌 Commit 313d6c5 has been approved by |
Add error message for using >= 65535 hashes for raw string literal escapes Fixes #50111.
💔 Test failed - status-appveyor |
⌛ Testing commit 313d6c5 with merge 2bd50a523053b5bd02014a73e45a072663efcb53... |
Add error message for using >= 65535 hashes for raw string literal escapes Fixes #50111.
☀️ Test successful - status-appveyor, status-travis |
Fixes #50111.