From dc00aa31142199ac6901fd08e4e4fd2be9b22be3 Mon Sep 17 00:00:00 2001 From: Rejyr Date: Wed, 21 Sep 2022 20:47:24 -0400 Subject: [PATCH] update: `lints.rs` for renamed traits update: `lints.rs` for renamed `SessionSubdiagnostic` and `AddSubdiagnostic` fix: NonSnakeCaseDiagSub fix: OverflowingBinHexSign --- compiler/rustc_lint/src/lints.rs | 34 +++++++++++++++++++++----------- 1 file 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, } -#[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(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(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 @@ fn add_to_diagnostic(self, diag: &mut rustc_errors::Diagnostic) { } } -#[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 { -- 2.44.0