1
Fork 0

Migrate rustc_session::expr_parentheses_needed to Subdiagnostic struct

This commit is contained in:
Xiretza 2022-08-25 10:58:53 +02:00
parent 57ee5cf5a9
commit 495e271883
3 changed files with 22 additions and 7 deletions

View file

@ -219,3 +219,18 @@ impl IntoDiagnostic<'_> for InvalidCharacterInCrateName<'_> {
diag
}
}
#[derive(Subdiagnostic)]
#[multipart_suggestion(session::expr_parentheses_needed, applicability = "machine-applicable")]
pub struct ExprParenthesesNeeded {
#[suggestion_part(code = "(")]
pub left: Span,
#[suggestion_part(code = ")")]
pub right: Span,
}
impl ExprParenthesesNeeded {
pub fn surrounding(s: Span) -> Self {
ExprParenthesesNeeded { left: s.shrink_to_lo(), right: s.shrink_to_hi() }
}
}