diff options
| author | Rejyr <jerrylwang123@gmail.com> | 2022-09-21 20:47:24 -0400 |
|---|---|---|
| committer | Rejyr <jerrylwang123@gmail.com> | 2023-01-09 17:07:25 -0500 |
| commit | dc00aa31142199ac6901fd08e4e4fd2be9b22be3 (patch) | |
| tree | 0c479f29fcc68ca423d6648f67cad02d469ad6a4 /compiler/rustc_lint/src | |
| parent | e3bb2ebfbfba0e928f27d2aea04cc070a1b8ebfe (diff) | |
| download | rust-dc00aa31142199ac6901fd08e4e4fd2be9b22be3.tar.gz rust-dc00aa31142199ac6901fd08e4e4fd2be9b22be3.zip | |
update: `lints.rs` for renamed traits
update: `lints.rs` for renamed `SessionSubdiagnostic` and `AddSubdiagnostic` fix: NonSnakeCaseDiagSub fix: OverflowingBinHexSign
Diffstat (limited to 'compiler/rustc_lint/src')
| -rw-r--r-- | compiler/rustc_lint/src/lints.rs | 34 |
1 files changed, 23 insertions, 11 deletions
diff --git a/compiler/rustc_lint/src/lints.rs b/compiler/rustc_lint/src/lints.rs index 686aca2d404..431ded9cd5f 100644 --- a/compiler/rustc_lint/src/lints.rs +++ b/compiler/rustc_lint/src/lints.rs @@ -1,6 +1,6 @@ -use rustc_errors::{fluent, AddSubdiagnostic, Applicability, DecorateLint, EmissionGuarantee}; +use rustc_errors::{fluent, AddToDiagnostic, Applicability, DecorateLint, EmissionGuarantee}; use rustc_hir::def_id::DefId; -use rustc_macros::{LintDiagnostic, SessionSubdiagnostic}; +use rustc_macros::{LintDiagnostic, Subdiagnostic}; use rustc_middle::ty::{Predicate, Ty, TyCtxt}; use rustc_span::{symbol::Ident, Span, Symbol}; @@ -16,7 +16,7 @@ pub struct ArrayIntoIterDiag<'a> { pub sub: Option<ArrayIntoIterDiagSub>, } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] pub enum ArrayIntoIterDiagSub { #[suggestion(remove_into_iter_suggestion, code = "", applicability = "maybe-incorrect")] RemoveIntoIter { @@ -129,7 +129,7 @@ pub struct NonCamelCaseType<'a> { pub sub: NonCamelCaseTypeSub, } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] pub enum NonCamelCaseTypeSub { #[label(label)] Label { @@ -162,8 +162,14 @@ pub enum NonSnakeCaseDiagSub { SuggestionAndNote { span: Span }, } -impl AddSubdiagnostic for NonSnakeCaseDiagSub { - fn add_to_diagnostic(self, diag: &mut rustc_errors::Diagnostic) { +impl AddToDiagnostic for NonSnakeCaseDiagSub { + fn add_to_diagnostic_with<F>(self, diag: &mut rustc_errors::Diagnostic, _: F) + where + F: Fn( + &mut rustc_errors::Diagnostic, + rustc_errors::SubdiagnosticMessage, + ) -> rustc_errors::SubdiagnosticMessage, + { match self { NonSnakeCaseDiagSub::Label { span } => { diag.span_label(span, fluent::label); @@ -209,7 +215,7 @@ pub struct NonUpperCaseGlobal<'a> { pub sub: NonUpperCaseGlobalSub, } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] pub enum NonUpperCaseGlobalSub { #[label(label)] Label { @@ -307,8 +313,14 @@ pub enum OverflowingBinHexSign { Negative, } -impl AddSubdiagnostic for OverflowingBinHexSign { - fn add_to_diagnostic(self, diag: &mut rustc_errors::Diagnostic) { +impl AddToDiagnostic for OverflowingBinHexSign { + fn add_to_diagnostic_with<F>(self, diag: &mut rustc_errors::Diagnostic, _: F) + where + F: Fn( + &mut rustc_errors::Diagnostic, + rustc_errors::SubdiagnosticMessage, + ) -> rustc_errors::SubdiagnosticMessage, + { match self { OverflowingBinHexSign::Positive => { diag.note(fluent::positive_note); @@ -321,7 +333,7 @@ impl AddSubdiagnostic for OverflowingBinHexSign { } } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] pub enum OverflowingBinHexSub<'a> { #[suggestion( suggestion, @@ -493,7 +505,7 @@ pub struct PathStatementDrop { pub sub: PathStatementDropSub, } -#[derive(SessionSubdiagnostic)] +#[derive(Subdiagnostic)] pub enum PathStatementDropSub { #[suggestion(suggestion, code = "drop({snippet});", applicability = "machine-applicable")] Suggestion { |
