mirror of
https://github.com/rust-lang/rust.git
synced 2026-04-27 18:57:42 +03:00
Remove more BuiltinLintDiag in rustc_resolve
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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 },
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user