Rollup merge of #121669 - nnethercote:count-stashed-errs-again, r=estebank
Count stashed errors again Stashed diagnostics are such a pain. Their "might be emitted, might not" semantics messes with lots of things. #120828 and #121206 made some big changes to how they work, improving some things, but still leaving some problems, as seen by the issues caused by #121206. This PR aims to fix all of them by restricting them in a way that eliminates the "might be emitted, might not" semantics while still allowing 98% of their benefit. Details in the individual commit logs. r? `@oli-obk`
This commit is contained in:
commit
a5945b5d8d
40 changed files with 476 additions and 343 deletions
|
@ -1762,24 +1762,25 @@ impl<'a> Parser<'a> {
|
|||
err: impl FnOnce(&Self) -> Diag<'a>,
|
||||
) -> L {
|
||||
assert!(could_be_unclosed_char_literal(ident));
|
||||
if let Some(diag) = self.dcx().steal_diagnostic(ident.span, StashKey::LifetimeIsChar) {
|
||||
diag.with_span_suggestion_verbose(
|
||||
ident.span.shrink_to_hi(),
|
||||
"add `'` to close the char literal",
|
||||
"'",
|
||||
Applicability::MaybeIncorrect,
|
||||
)
|
||||
.emit();
|
||||
} else {
|
||||
err(self)
|
||||
.with_span_suggestion_verbose(
|
||||
self.dcx()
|
||||
.try_steal_modify_and_emit_err(ident.span, StashKey::LifetimeIsChar, |err| {
|
||||
err.span_suggestion_verbose(
|
||||
ident.span.shrink_to_hi(),
|
||||
"add `'` to close the char literal",
|
||||
"'",
|
||||
Applicability::MaybeIncorrect,
|
||||
)
|
||||
.emit();
|
||||
}
|
||||
);
|
||||
})
|
||||
.unwrap_or_else(|| {
|
||||
err(self)
|
||||
.with_span_suggestion_verbose(
|
||||
ident.span.shrink_to_hi(),
|
||||
"add `'` to close the char literal",
|
||||
"'",
|
||||
Applicability::MaybeIncorrect,
|
||||
)
|
||||
.emit()
|
||||
});
|
||||
let name = ident.without_first_quote().name;
|
||||
mk_lit_char(name, ident.span)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue