Skip to content
Merged
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
2 changes: 1 addition & 1 deletion compiler/rustc_parse/src/lexer/unescape_error_reporting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ pub(crate) fn emit_unescape_error(
}
escaped.push(c);
}
if escaped.len() != lit.len() {
if escaped.len() != lit.len() || full_lit_span.is_empty() {
Copy link
Member

Choose a reason for hiding this comment

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

I understand that this prevents the negative overflow & that makes sense but why wasn't this an issue before? Don't have the time to dig deep into the code myself.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Before we were replacing the full span with the new string (instead of doing BytePos math). We just end up with an invalid suggestion that won't be displayed.

let sugg = format!("{prefix}\"{escaped}\"");
MoreThanOneCharSugg::QuotesFull {
span: full_lit_span,
Expand Down