Use shorter span for existing '
-> "
structured suggestion
This commit is contained in:
parent
982918f493
commit
4a10b01f95
14 changed files with 51 additions and 41 deletions
|
@ -2216,12 +2216,21 @@ pub enum MoreThanOneCharSugg {
|
|||
ch: String,
|
||||
},
|
||||
#[suggestion(parse_use_double_quotes, code = "{sugg}", applicability = "machine-applicable")]
|
||||
Quotes {
|
||||
QuotesFull {
|
||||
#[primary_span]
|
||||
span: Span,
|
||||
is_byte: bool,
|
||||
sugg: String,
|
||||
},
|
||||
#[multipart_suggestion(parse_use_double_quotes, applicability = "machine-applicable")]
|
||||
Quotes {
|
||||
#[suggestion_part(code = "{prefix}\"")]
|
||||
start: Span,
|
||||
#[suggestion_part(code = "\"")]
|
||||
end: Span,
|
||||
is_byte: bool,
|
||||
prefix: &'static str,
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(Subdiagnostic)]
|
||||
|
|
|
@ -95,11 +95,21 @@ pub(crate) fn emit_unescape_error(
|
|||
}
|
||||
escaped.push(c);
|
||||
}
|
||||
let sugg = format!("{prefix}\"{escaped}\"");
|
||||
MoreThanOneCharSugg::Quotes {
|
||||
span: full_lit_span,
|
||||
is_byte: mode == Mode::Byte,
|
||||
sugg,
|
||||
if escaped.len() != lit.len() {
|
||||
let sugg = format!("{prefix}\"{escaped}\"");
|
||||
MoreThanOneCharSugg::QuotesFull {
|
||||
span: full_lit_span,
|
||||
is_byte: mode == Mode::Byte,
|
||||
sugg,
|
||||
}
|
||||
} else {
|
||||
MoreThanOneCharSugg::Quotes {
|
||||
start: full_lit_span
|
||||
.with_hi(full_lit_span.lo() + BytePos((prefix.len() + 1) as u32)),
|
||||
end: full_lit_span.with_lo(full_lit_span.hi() - BytePos(1)),
|
||||
is_byte: mode == Mode::Byte,
|
||||
prefix,
|
||||
}
|
||||
}
|
||||
});
|
||||
dcx.emit_err(UnescapeError::MoreThanOneChar {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue