-
Notifications
You must be signed in to change notification settings - Fork 12.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate ast_lowering::path to SessionDiagnostic
- Loading branch information
1 parent
a8a33cf
commit 73ae38b
Showing
7 changed files
with
46 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
use rustc_errors::{fluent, AddSubdiagnostic, Applicability, Diagnostic}; | ||
use rustc_macros::SessionDiagnostic; | ||
use rustc_span::Span; | ||
|
||
#[derive(SessionDiagnostic, Clone, Copy)] | ||
#[error(ast_lowering::generic_type_with_parentheses, code = "E0214")] | ||
pub struct GenericTypeWithParentheses { | ||
#[primary_span] | ||
#[label] | ||
pub span: Span, | ||
#[subdiagnostic] | ||
pub sub: Option<UseAngleBrackets>, | ||
} | ||
|
||
#[derive(Clone, Copy)] | ||
pub struct UseAngleBrackets { | ||
pub open_param: Span, | ||
pub close_param: Span, | ||
} | ||
|
||
impl AddSubdiagnostic for UseAngleBrackets { | ||
fn add_to_diagnostic(self, diag: &mut Diagnostic) { | ||
diag.multipart_suggestion( | ||
fluent::ast_lowering::use_angle_brackets, | ||
vec![(self.open_param, String::from("<")), (self.close_param, String::from(">"))], | ||
Applicability::MaybeIncorrect, | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -75,6 +75,7 @@ macro_rules! arena_vec { | |
|
||
mod asm; | ||
mod block; | ||
mod errors; | ||
mod expr; | ||
mod index; | ||
mod item; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
ast_lowering_generic_type_with_parentheses = | ||
parenthesized type parameters may only be used with a `Fn` trait | ||
.label = only `Fn` traits may use parentheses | ||
ast_lowering_use_angle_brackets = use angle brackets instead |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters