Tweak comment and naming for recover_unclosed_char
.
Because it can be used for a lifetime or a label.
This commit is contained in:
parent
6351247048
commit
5bda589ff3
1 changed files with 7 additions and 7 deletions
|
@ -1737,16 +1737,16 @@ impl<'a> Parser<'a> {
|
||||||
Ok(expr)
|
Ok(expr)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Emit an error when a char is parsed as a lifetime because of a missing quote.
|
/// Emit an error when a char is parsed as a lifetime or label because of a missing quote.
|
||||||
pub(super) fn recover_unclosed_char<L>(
|
pub(super) fn recover_unclosed_char<L>(
|
||||||
&self,
|
&self,
|
||||||
lifetime: Ident,
|
ident: Ident,
|
||||||
mk_lit_char: impl FnOnce(Symbol, Span) -> L,
|
mk_lit_char: impl FnOnce(Symbol, Span) -> L,
|
||||||
err: impl FnOnce(&Self) -> DiagnosticBuilder<'a>,
|
err: impl FnOnce(&Self) -> DiagnosticBuilder<'a>,
|
||||||
) -> L {
|
) -> L {
|
||||||
if let Some(diag) = self.dcx().steal_diagnostic(lifetime.span, StashKey::LifetimeIsChar) {
|
if let Some(diag) = self.dcx().steal_diagnostic(ident.span, StashKey::LifetimeIsChar) {
|
||||||
diag.with_span_suggestion_verbose(
|
diag.with_span_suggestion_verbose(
|
||||||
lifetime.span.shrink_to_hi(),
|
ident.span.shrink_to_hi(),
|
||||||
"add `'` to close the char literal",
|
"add `'` to close the char literal",
|
||||||
"'",
|
"'",
|
||||||
Applicability::MaybeIncorrect,
|
Applicability::MaybeIncorrect,
|
||||||
|
@ -1755,15 +1755,15 @@ impl<'a> Parser<'a> {
|
||||||
} else {
|
} else {
|
||||||
err(self)
|
err(self)
|
||||||
.with_span_suggestion_verbose(
|
.with_span_suggestion_verbose(
|
||||||
lifetime.span.shrink_to_hi(),
|
ident.span.shrink_to_hi(),
|
||||||
"add `'` to close the char literal",
|
"add `'` to close the char literal",
|
||||||
"'",
|
"'",
|
||||||
Applicability::MaybeIncorrect,
|
Applicability::MaybeIncorrect,
|
||||||
)
|
)
|
||||||
.emit();
|
.emit();
|
||||||
}
|
}
|
||||||
let name = lifetime.without_first_quote().name;
|
let name = ident.without_first_quote().name;
|
||||||
mk_lit_char(name, lifetime.span)
|
mk_lit_char(name, ident.span)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Recover on the syntax `do catch { ... }` suggesting `try { ... }` instead.
|
/// Recover on the syntax `do catch { ... }` suggesting `try { ... }` instead.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue