Don't translate compiler-internal bug messages
This commit is contained in:
parent
c67cb3e577
commit
d97ec97b94
6 changed files with 27 additions and 45 deletions
|
@ -247,7 +247,7 @@ impl<'a> Parser<'a> {
|
|||
self.sess.span_diagnostic.struct_span_err(sp, m)
|
||||
}
|
||||
|
||||
pub fn span_bug<S: Into<MultiSpan>>(&self, sp: S, m: impl Into<DiagnosticMessage>) -> ! {
|
||||
pub fn span_bug<S: Into<MultiSpan>>(&self, sp: S, m: impl Into<String>) -> ! {
|
||||
self.sess.span_diagnostic.span_bug(sp, m)
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,6 @@ use crate::errors::{
|
|||
TrailingVertNotAllowed, UnexpectedLifetimeInPattern, UnexpectedVertVertBeforeFunctionParam,
|
||||
UnexpectedVertVertInPattern,
|
||||
};
|
||||
use crate::fluent_generated as fluent;
|
||||
use crate::{maybe_recover_from_interpolated_ty_qpath, maybe_whole};
|
||||
use rustc_ast::mut_visit::{noop_visit_pat, MutVisitor};
|
||||
use rustc_ast::ptr::P;
|
||||
|
@ -214,41 +213,25 @@ impl<'a> Parser<'a> {
|
|||
|
||||
if let PatKind::Or(pats) = &pat.kind {
|
||||
let span = pat.span;
|
||||
|
||||
if trailing_vert {
|
||||
// We already emitted an error and suggestion to remove the trailing vert. Don't
|
||||
// emit again.
|
||||
|
||||
// FIXME(#100717): pass `TopLevelOrPatternNotAllowed::* { sub: None }` to
|
||||
// `delay_span_bug()` instead of fluent message
|
||||
self.sess.span_diagnostic.delay_span_bug(
|
||||
span,
|
||||
match syntax_loc {
|
||||
PatternLocation::LetBinding => {
|
||||
fluent::parse_or_pattern_not_allowed_in_let_binding
|
||||
}
|
||||
PatternLocation::FunctionParameter => {
|
||||
fluent::parse_or_pattern_not_allowed_in_fn_parameters
|
||||
}
|
||||
},
|
||||
);
|
||||
let pat = pprust::pat_to_string(&pat);
|
||||
let sub = if pats.len() == 1 {
|
||||
Some(TopLevelOrPatternNotAllowedSugg::RemoveLeadingVert { span, pat })
|
||||
} else {
|
||||
let pat = pprust::pat_to_string(&pat);
|
||||
let sub = if pats.len() == 1 {
|
||||
Some(TopLevelOrPatternNotAllowedSugg::RemoveLeadingVert { span, pat })
|
||||
} else {
|
||||
Some(TopLevelOrPatternNotAllowedSugg::WrapInParens { span, pat })
|
||||
};
|
||||
Some(TopLevelOrPatternNotAllowedSugg::WrapInParens { span, pat })
|
||||
};
|
||||
|
||||
self.sess.emit_err(match syntax_loc {
|
||||
PatternLocation::LetBinding => {
|
||||
TopLevelOrPatternNotAllowed::LetBinding { span, sub }
|
||||
}
|
||||
PatternLocation::FunctionParameter => {
|
||||
TopLevelOrPatternNotAllowed::FunctionParameter { span, sub }
|
||||
}
|
||||
});
|
||||
let mut err = self.sess.create_err(match syntax_loc {
|
||||
PatternLocation::LetBinding => {
|
||||
TopLevelOrPatternNotAllowed::LetBinding { span, sub }
|
||||
}
|
||||
PatternLocation::FunctionParameter => {
|
||||
TopLevelOrPatternNotAllowed::FunctionParameter { span, sub }
|
||||
}
|
||||
});
|
||||
if trailing_vert {
|
||||
err.delay_as_bug();
|
||||
}
|
||||
err.emit();
|
||||
}
|
||||
|
||||
Ok((pat, colon))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue