Split ComparisonOrShiftInterpretedAsGenericSugg
This commit is contained in:
parent
9a114c686f
commit
cda9b8c157
2 changed files with 21 additions and 11 deletions
|
|
@ -861,7 +861,16 @@ pub(crate) struct ComparisonInterpretedAsGeneric {
|
|||
#[label("interpreted as generic arguments")]
|
||||
pub args: Span,
|
||||
#[subdiagnostic]
|
||||
pub suggestion: ComparisonOrShiftInterpretedAsGenericSugg,
|
||||
pub suggestion: ComparisonInterpretedAsGenericSugg,
|
||||
}
|
||||
|
||||
#[derive(Subdiagnostic)]
|
||||
#[multipart_suggestion("try comparing the cast value", applicability = "machine-applicable")]
|
||||
pub(crate) struct ComparisonInterpretedAsGenericSugg {
|
||||
#[suggestion_part(code = "(")]
|
||||
pub left: Span,
|
||||
#[suggestion_part(code = ")")]
|
||||
pub right: Span,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
|
|
@ -874,12 +883,12 @@ pub(crate) struct ShiftInterpretedAsGeneric {
|
|||
#[label("interpreted as generic arguments")]
|
||||
pub args: Span,
|
||||
#[subdiagnostic]
|
||||
pub suggestion: ComparisonOrShiftInterpretedAsGenericSugg,
|
||||
pub suggestion: ShiftInterpretedAsGenericSugg,
|
||||
}
|
||||
|
||||
#[derive(Subdiagnostic)]
|
||||
#[multipart_suggestion("BROKEN", applicability = "machine-applicable")]
|
||||
pub(crate) struct ComparisonOrShiftInterpretedAsGenericSugg {
|
||||
#[multipart_suggestion("try shifting the cast value", applicability = "machine-applicable")]
|
||||
pub(crate) struct ShiftInterpretedAsGenericSugg {
|
||||
#[suggestion_part(code = "(")]
|
||||
pub left: Span,
|
||||
#[suggestion_part(code = ")")]
|
||||
|
|
|
|||
|
|
@ -727,25 +727,26 @@ impl<'a> Parser<'a> {
|
|||
);
|
||||
|
||||
let args_span = self.look_ahead(1, |t| t.span).to(span_after_type);
|
||||
let suggestion = errors::ComparisonOrShiftInterpretedAsGenericSugg {
|
||||
left: expr.span.shrink_to_lo(),
|
||||
right: expr.span.shrink_to_hi(),
|
||||
};
|
||||
|
||||
match self.token.kind {
|
||||
token::Lt => {
|
||||
self.dcx().emit_err(errors::ComparisonInterpretedAsGeneric {
|
||||
comparison: self.token.span,
|
||||
r#type: path,
|
||||
args: args_span,
|
||||
suggestion,
|
||||
suggestion: errors::ComparisonInterpretedAsGenericSugg {
|
||||
left: expr.span.shrink_to_lo(),
|
||||
right: expr.span.shrink_to_hi(),
|
||||
},
|
||||
})
|
||||
}
|
||||
token::Shl => self.dcx().emit_err(errors::ShiftInterpretedAsGeneric {
|
||||
shift: self.token.span,
|
||||
r#type: path,
|
||||
args: args_span,
|
||||
suggestion,
|
||||
suggestion: errors::ShiftInterpretedAsGenericSugg {
|
||||
left: expr.span.shrink_to_lo(),
|
||||
right: expr.span.shrink_to_hi(),
|
||||
},
|
||||
}),
|
||||
_ => {
|
||||
// We can end up here even without `<` being the next token, for
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue