Skip to content

Commit 2fcd8a7

Browse files
Remove more BuiltinLintDiag in rustc_resolve
1 parent 33fbecc commit 2fcd8a7

5 files changed

Lines changed: 17 additions & 22 deletions

File tree

compiler/rustc_lint/src/early/diagnostics.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -118,13 +118,14 @@ impl<'a> Diagnostic<'a, ()> for DecorateBuiltinLint<'_, '_> {
118118
}
119119
BuiltinLintDiag::SingleUseLifetime {
120120
param_span,
121-
use_span: Some((use_span, elide)),
121+
use_span,
122+
elidable,
122123
deletion_span,
123124
ident,
124125
} => {
125126
debug!(?param_span, ?use_span, ?deletion_span);
126127
let suggestion = if let Some(deletion_span) = deletion_span {
127-
let (use_span, replace_lt) = if elide {
128+
let (use_span, replace_lt) = if elidable {
128129
let use_span =
129130
self.sess.source_map().span_extend_while_whitespace(use_span);
130131
(use_span, String::new())
@@ -145,9 +146,6 @@ impl<'a> Diagnostic<'a, ()> for DecorateBuiltinLint<'_, '_> {
145146
lints::SingleUseLifetime { suggestion, param_span, use_span, ident }
146147
.into_diag(dcx, level)
147148
}
148-
BuiltinLintDiag::SingleUseLifetime { use_span: None, deletion_span, ident, .. } => {
149-
lints::UnusedLifetime { deletion_span, ident }.into_diag(dcx, level)
150-
}
151149
BuiltinLintDiag::NamedArgumentUsedPositionally {
152150
position_sp_to_replace,
153151
position_sp_for_msg,

compiler/rustc_lint/src/lints.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3149,15 +3149,6 @@ pub(crate) struct SingleUseLifetimeSugg {
31493149
pub replace_lt: String,
31503150
}
31513151

3152-
#[derive(Diagnostic)]
3153-
#[diag("lifetime parameter `{$ident}` never used")]
3154-
pub(crate) struct UnusedLifetime {
3155-
#[suggestion("elide the unused lifetime", code = "", applicability = "machine-applicable")]
3156-
pub deletion_span: Option<Span>,
3157-
3158-
pub ident: Ident,
3159-
}
3160-
31613152
#[derive(Diagnostic)]
31623153
#[diag("named argument `{$named_arg_name}` is not used by name")]
31633154
pub(crate) struct NamedArgumentUsedPositionally {

compiler/rustc_lint_defs/src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -681,7 +681,8 @@ pub enum BuiltinLintDiag {
681681
deletion_span: Option<Span>,
682682
/// Span of the single use, or None if the lifetime is never used.
683683
/// If true, the lifetime will be fully elided.
684-
use_span: Option<(Span, bool)>,
684+
use_span: Span,
685+
elidable: bool,
685686
ident: Ident,
686687
},
687688
NamedArgumentUsedPositionally {

compiler/rustc_resolve/src/errors.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1583,3 +1583,12 @@ impl<'a, G: EmissionGuarantee> Diagnostic<'a, G> for Ambiguity {
15831583
diag
15841584
}
15851585
}
1586+
1587+
#[derive(Diagnostic)]
1588+
#[diag("lifetime parameter `{$ident}` never used")]
1589+
pub(crate) struct UnusedLifetime {
1590+
#[suggestion("elide the unused lifetime", code = "", applicability = "machine-applicable")]
1591+
pub deletion_span: Option<Span>,
1592+
1593+
pub ident: Ident,
1594+
}

compiler/rustc_resolve/src/late/diagnostics.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3653,7 +3653,8 @@ impl<'ast, 'ra, 'tcx> LateResolutionVisitor<'_, 'ast, 'ra, 'tcx> {
36533653
param.ident.span,
36543654
lint::BuiltinLintDiag::SingleUseLifetime {
36553655
param_span: param.ident.span,
3656-
use_span: Some((use_span, elidable)),
3656+
use_span,
3657+
elidable,
36573658
deletion_span,
36583659
ident: param.ident,
36593660
},
@@ -3669,12 +3670,7 @@ impl<'ast, 'ra, 'tcx> LateResolutionVisitor<'_, 'ast, 'ra, 'tcx> {
36693670
lint::builtin::UNUSED_LIFETIMES,
36703671
param.id,
36713672
param.ident.span,
3672-
lint::BuiltinLintDiag::SingleUseLifetime {
3673-
param_span: param.ident.span,
3674-
use_span: None,
3675-
deletion_span,
3676-
ident: param.ident,
3677-
},
3673+
errors::UnusedLifetime { deletion_span, ident: param.ident },
36783674
);
36793675
}
36803676
}

0 commit comments

Comments
 (0)