Migrated the rustc_passes lint for annotations without effect to the new diagnostic infrastructure
This commit is contained in:
parent
a926696384
commit
6a47326a04
3 changed files with 17 additions and 10 deletions
|
@ -268,3 +268,6 @@ passes_link_ordinal = attribute should be applied to a foreign function or stati
|
||||||
|
|
||||||
passes_collapse_debuginfo = `collapse_debuginfo` attribute should be applied to macro definitions
|
passes_collapse_debuginfo = `collapse_debuginfo` attribute should be applied to macro definitions
|
||||||
.label = not a macro definition
|
.label = not a macro definition
|
||||||
|
|
||||||
|
passes_deprecated_annotation_has_no_effect = this `#[deprecated]` annotation has no effect
|
||||||
|
.suggestion = remove the unnecessary deprecation attribute
|
||||||
|
|
|
@ -658,3 +658,10 @@ pub struct CollapseDebuginfo {
|
||||||
#[label]
|
#[label]
|
||||||
pub defn_span: Span,
|
pub defn_span: Span,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(LintDiagnostic)]
|
||||||
|
#[diag(passes::deprecated_annotation_has_no_effect)]
|
||||||
|
pub struct DeprecatedAnnotationHasNoEffect {
|
||||||
|
#[suggestion(applicability = "machine-applicable", code = "")]
|
||||||
|
pub span: Span,
|
||||||
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
//! A pass that annotates every item and method with its stability level,
|
//! A pass that annotates every item and method with its stability level,
|
||||||
//! propagating default levels lexically from parent to children ast nodes.
|
//! propagating default levels lexically from parent to children ast nodes.
|
||||||
|
|
||||||
|
use crate::errors;
|
||||||
use rustc_attr::{
|
use rustc_attr::{
|
||||||
self as attr, rust_version_symbol, ConstStability, Stability, StabilityLevel, Unstable,
|
self as attr, rust_version_symbol, ConstStability, Stability, StabilityLevel, Unstable,
|
||||||
UnstableReason, VERSION_PLACEHOLDER,
|
UnstableReason, VERSION_PLACEHOLDER,
|
||||||
|
@ -122,16 +123,12 @@ impl<'a, 'tcx> Annotator<'a, 'tcx> {
|
||||||
|
|
||||||
if kind == AnnotationKind::Prohibited || kind == AnnotationKind::DeprecationProhibited {
|
if kind == AnnotationKind::Prohibited || kind == AnnotationKind::DeprecationProhibited {
|
||||||
let hir_id = self.tcx.hir().local_def_id_to_hir_id(def_id);
|
let hir_id = self.tcx.hir().local_def_id_to_hir_id(def_id);
|
||||||
self.tcx.struct_span_lint_hir(USELESS_DEPRECATED, hir_id, *span, |lint| {
|
self.tcx.emit_spanned_lint(
|
||||||
lint.build("this `#[deprecated]` annotation has no effect")
|
USELESS_DEPRECATED,
|
||||||
.span_suggestion_short(
|
hir_id,
|
||||||
*span,
|
*span,
|
||||||
"remove the unnecessary deprecation attribute",
|
errors::DeprecatedAnnotationHasNoEffect { span: *span },
|
||||||
"",
|
);
|
||||||
rustc_errors::Applicability::MachineApplicable,
|
|
||||||
)
|
|
||||||
.emit();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// `Deprecation` is just two pointers, no need to intern it
|
// `Deprecation` is just two pointers, no need to intern it
|
||||||
|
|
Loading…
Add table
Reference in a new issue