Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit dc00aa3

Browse files
committed
update: lints.rs for renamed traits
update: `lints.rs` for renamed `SessionSubdiagnostic` and `AddSubdiagnostic` fix: NonSnakeCaseDiagSub fix: OverflowingBinHexSign
1 parent e3bb2eb commit dc00aa3

File tree

1 file changed

+23
-11
lines changed

1 file changed

+23
-11
lines changed

compiler/rustc_lint/src/lints.rs

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
use rustc_errors::{fluent, AddSubdiagnostic, Applicability, DecorateLint, EmissionGuarantee};
1+
use rustc_errors::{fluent, AddToDiagnostic, Applicability, DecorateLint, EmissionGuarantee};
22
use rustc_hir::def_id::DefId;
3-
use rustc_macros::{LintDiagnostic, SessionSubdiagnostic};
3+
use rustc_macros::{LintDiagnostic, Subdiagnostic};
44
use rustc_middle::ty::{Predicate, Ty, TyCtxt};
55
use rustc_span::{symbol::Ident, Span, Symbol};
66

@@ -16,7 +16,7 @@ pub struct ArrayIntoIterDiag<'a> {
1616
pub sub: Option<ArrayIntoIterDiagSub>,
1717
}
1818

19-
#[derive(SessionSubdiagnostic)]
19+
#[derive(Subdiagnostic)]
2020
pub enum ArrayIntoIterDiagSub {
2121
#[suggestion(remove_into_iter_suggestion, code = "", applicability = "maybe-incorrect")]
2222
RemoveIntoIter {
@@ -129,7 +129,7 @@ pub struct NonCamelCaseType<'a> {
129129
pub sub: NonCamelCaseTypeSub,
130130
}
131131

132-
#[derive(SessionSubdiagnostic)]
132+
#[derive(Subdiagnostic)]
133133
pub enum NonCamelCaseTypeSub {
134134
#[label(label)]
135135
Label {
@@ -162,8 +162,14 @@ pub enum NonSnakeCaseDiagSub {
162162
SuggestionAndNote { span: Span },
163163
}
164164

165-
impl AddSubdiagnostic for NonSnakeCaseDiagSub {
166-
fn add_to_diagnostic(self, diag: &mut rustc_errors::Diagnostic) {
165+
impl AddToDiagnostic for NonSnakeCaseDiagSub {
166+
fn add_to_diagnostic_with<F>(self, diag: &mut rustc_errors::Diagnostic, _: F)
167+
where
168+
F: Fn(
169+
&mut rustc_errors::Diagnostic,
170+
rustc_errors::SubdiagnosticMessage,
171+
) -> rustc_errors::SubdiagnosticMessage,
172+
{
167173
match self {
168174
NonSnakeCaseDiagSub::Label { span } => {
169175
diag.span_label(span, fluent::label);
@@ -209,7 +215,7 @@ pub struct NonUpperCaseGlobal<'a> {
209215
pub sub: NonUpperCaseGlobalSub,
210216
}
211217

212-
#[derive(SessionSubdiagnostic)]
218+
#[derive(Subdiagnostic)]
213219
pub enum NonUpperCaseGlobalSub {
214220
#[label(label)]
215221
Label {
@@ -307,8 +313,14 @@ pub enum OverflowingBinHexSign {
307313
Negative,
308314
}
309315

310-
impl AddSubdiagnostic for OverflowingBinHexSign {
311-
fn add_to_diagnostic(self, diag: &mut rustc_errors::Diagnostic) {
316+
impl AddToDiagnostic for OverflowingBinHexSign {
317+
fn add_to_diagnostic_with<F>(self, diag: &mut rustc_errors::Diagnostic, _: F)
318+
where
319+
F: Fn(
320+
&mut rustc_errors::Diagnostic,
321+
rustc_errors::SubdiagnosticMessage,
322+
) -> rustc_errors::SubdiagnosticMessage,
323+
{
312324
match self {
313325
OverflowingBinHexSign::Positive => {
314326
diag.note(fluent::positive_note);
@@ -321,7 +333,7 @@ impl AddSubdiagnostic for OverflowingBinHexSign {
321333
}
322334
}
323335

324-
#[derive(SessionSubdiagnostic)]
336+
#[derive(Subdiagnostic)]
325337
pub enum OverflowingBinHexSub<'a> {
326338
#[suggestion(
327339
suggestion,
@@ -493,7 +505,7 @@ pub struct PathStatementDrop {
493505
pub sub: PathStatementDropSub,
494506
}
495507

496-
#[derive(SessionSubdiagnostic)]
508+
#[derive(Subdiagnostic)]
497509
pub enum PathStatementDropSub {
498510
#[suggestion(suggestion, code = "drop({snippet});", applicability = "machine-applicable")]
499511
Suggestion {

0 commit comments

Comments
 (0)