Rollup merge of #107493 - clubby789:range-fat-arrow-followup, r=estebank
Improve diagnostic for missing space in range pattern Improves the diagnostic in #107425 by turning it into a note explaining the parsing issue. r? `@compiler-errors`
This commit is contained in:
commit
e9c4e291c4
6 changed files with 24 additions and 21 deletions
|
@ -670,13 +670,10 @@ pub(crate) struct InclusiveRangeExtraEquals {
|
|||
#[diag(parse_inclusive_range_match_arrow)]
|
||||
pub(crate) struct InclusiveRangeMatchArrow {
|
||||
#[primary_span]
|
||||
pub arrow: Span,
|
||||
#[label]
|
||||
pub span: Span,
|
||||
#[suggestion(
|
||||
suggestion_add_space,
|
||||
style = "verbose",
|
||||
code = " ",
|
||||
applicability = "machine-applicable"
|
||||
)]
|
||||
#[suggestion(style = "verbose", code = " ", applicability = "machine-applicable")]
|
||||
pub after_pat: Span,
|
||||
}
|
||||
|
||||
|
|
|
@ -2717,6 +2717,14 @@ impl<'a> Parser<'a> {
|
|||
);
|
||||
err.emit();
|
||||
this.bump();
|
||||
} else if matches!(
|
||||
(&this.prev_token.kind, &this.token.kind),
|
||||
(token::DotDotEq, token::Gt)
|
||||
) {
|
||||
// `error_inclusive_range_match_arrow` handles cases like `0..=> {}`,
|
||||
// so we supress the error here
|
||||
err.delay_as_bug();
|
||||
this.bump();
|
||||
} else {
|
||||
return Err(err);
|
||||
}
|
||||
|
|
|
@ -743,7 +743,7 @@ impl<'a> Parser<'a> {
|
|||
}
|
||||
token::Gt if no_space => {
|
||||
let after_pat = span.with_hi(span.hi() - rustc_span::BytePos(1)).shrink_to_hi();
|
||||
self.sess.emit_err(InclusiveRangeMatchArrow { span, after_pat });
|
||||
self.sess.emit_err(InclusiveRangeMatchArrow { span, arrow: tok.span, after_pat });
|
||||
}
|
||||
_ => {
|
||||
self.sess.emit_err(InclusiveRangeNoEnd { span });
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue