Migrate rustc_session::expr_parentheses_needed to Subdiagnostic struct
This commit is contained in:
parent
57ee5cf5a9
commit
495e271883
3 changed files with 22 additions and 7 deletions
|
@ -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() }
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue