Remove more BuiltinLintDiag in rustc_resolve

This commit is contained in:
Guillaume Gomez
2026-03-22 20:32:22 +01:00
parent 33fbecc394
commit 2fcd8a71f7
5 changed files with 17 additions and 22 deletions
+3 -5
View File
@@ -118,13 +118,14 @@ fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, ()> {
}
BuiltinLintDiag::SingleUseLifetime {
param_span,
use_span: Some((use_span, elide)),
use_span,
elidable,
deletion_span,
ident,
} => {
debug!(?param_span, ?use_span, ?deletion_span);
let suggestion = if let Some(deletion_span) = deletion_span {
let (use_span, replace_lt) = if elide {
let (use_span, replace_lt) = if elidable {
let use_span =
self.sess.source_map().span_extend_while_whitespace(use_span);
(use_span, String::new())
@@ -145,9 +146,6 @@ fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, ()> {
lints::SingleUseLifetime { suggestion, param_span, use_span, ident }
.into_diag(dcx, level)
}
BuiltinLintDiag::SingleUseLifetime { use_span: None, deletion_span, ident, .. } => {
lints::UnusedLifetime { deletion_span, ident }.into_diag(dcx, level)
}
BuiltinLintDiag::NamedArgumentUsedPositionally {
position_sp_to_replace,
position_sp_for_msg,
-9
View File
@@ -3149,15 +3149,6 @@ pub(crate) struct SingleUseLifetimeSugg {
pub replace_lt: String,
}
#[derive(Diagnostic)]
#[diag("lifetime parameter `{$ident}` never used")]
pub(crate) struct UnusedLifetime {
#[suggestion("elide the unused lifetime", code = "", applicability = "machine-applicable")]
pub deletion_span: Option<Span>,
pub ident: Ident,
}
#[derive(Diagnostic)]
#[diag("named argument `{$named_arg_name}` is not used by name")]
pub(crate) struct NamedArgumentUsedPositionally {
+2 -1
View File
@@ -681,7 +681,8 @@ pub enum BuiltinLintDiag {
deletion_span: Option<Span>,
/// Span of the single use, or None if the lifetime is never used.
/// If true, the lifetime will be fully elided.
use_span: Option<(Span, bool)>,
use_span: Span,
elidable: bool,
ident: Ident,
},
NamedArgumentUsedPositionally {
+9
View File
@@ -1583,3 +1583,12 @@ fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, G> {
diag
}
}
#[derive(Diagnostic)]
#[diag("lifetime parameter `{$ident}` never used")]
pub(crate) struct UnusedLifetime {
#[suggestion("elide the unused lifetime", code = "", applicability = "machine-applicable")]
pub deletion_span: Option<Span>,
pub ident: Ident,
}
@@ -3653,7 +3653,8 @@ pub(crate) fn maybe_report_lifetime_uses(
param.ident.span,
lint::BuiltinLintDiag::SingleUseLifetime {
param_span: param.ident.span,
use_span: Some((use_span, elidable)),
use_span,
elidable,
deletion_span,
ident: param.ident,
},
@@ -3669,12 +3670,7 @@ pub(crate) fn maybe_report_lifetime_uses(
lint::builtin::UNUSED_LIFETIMES,
param.id,
param.ident.span,
lint::BuiltinLintDiag::SingleUseLifetime {
param_span: param.ident.span,
use_span: None,
deletion_span,
ident: param.ident,
},
errors::UnusedLifetime { deletion_span, ident: param.ident },
);
}
}