]> git.lizzy.rs Git - rust.git/commitdiff
update: `lints.rs` for renamed traits
authorRejyr <jerrylwang123@gmail.com>
Thu, 22 Sep 2022 00:47:24 +0000 (20:47 -0400)
committerRejyr <jerrylwang123@gmail.com>
Mon, 9 Jan 2023 22:07:25 +0000 (17:07 -0500)
update: `lints.rs` for renamed `SessionSubdiagnostic` and `AddSubdiagnostic`

fix: NonSnakeCaseDiagSub

fix: OverflowingBinHexSign

compiler/rustc_lint/src/lints.rs

index 686aca2d404e475192b2bccf5254045c2305351c..431ded9cd5f2d976bc5c31ef98b1b1f030e5a2f5 100644 (file)
@@ -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 @@ 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 {