mirror of
https://github.com/rust-lang/rust.git
synced 2026-04-27 18:57:42 +03:00
linting, moving error to session diagnostics
This commit is contained in:
@@ -452,8 +452,6 @@ pub(crate) fn parse_unstability<S: Stage>(
|
||||
|
||||
match (feature, issue) {
|
||||
(Ok(feature), Ok(_)) => {
|
||||
// Validate that unstable attributes don't use already-stable language features
|
||||
|
||||
if ACCEPTED_LANG_FEATURES.iter().any(|f| f.name == feature) {
|
||||
cx.emit_err(session_diagnostics::UnstableAttrForAlreadyStableFeature {
|
||||
attr_span: cx.attr_span,
|
||||
@@ -461,7 +459,7 @@ pub(crate) fn parse_unstability<S: Stage>(
|
||||
});
|
||||
return None;
|
||||
}
|
||||
|
||||
|
||||
let level = StabilityLevel::Unstable {
|
||||
reason: UnstableReason::from_opt_reason(reason),
|
||||
issue: issue_num,
|
||||
|
||||
@@ -1046,3 +1046,14 @@ pub(crate) struct CustomMirIncompatibleDialectAndPhase {
|
||||
#[label("... is not compatible with this phase")]
|
||||
pub phase_span: Span,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag("can't mark as unstable using an already stable feature")]
|
||||
pub(crate) struct UnstableAttrForAlreadyStableFeature {
|
||||
#[primary_span]
|
||||
#[label("this feature is already stable")]
|
||||
#[help("consider removing the attribute")]
|
||||
pub attr_span: Span,
|
||||
#[label("the stability attribute annotates this item")]
|
||||
pub item_span: Span,
|
||||
}
|
||||
|
||||
@@ -16,9 +16,7 @@
|
||||
use rustc_data_structures::thin_vec::ThinVec;
|
||||
use rustc_data_structures::unord::UnordMap;
|
||||
use rustc_errors::{DiagCtxtHandle, IntoDiagArg, MultiSpan, StashKey, msg};
|
||||
use rustc_feature::{
|
||||
AttributeDuplicates, AttributeType, BUILTIN_ATTRIBUTE_MAP, BuiltinAttribute,
|
||||
};
|
||||
use rustc_feature::{AttributeDuplicates, AttributeType, BUILTIN_ATTRIBUTE_MAP, BuiltinAttribute};
|
||||
use rustc_hir::attrs::diagnostic::Directive;
|
||||
use rustc_hir::attrs::{
|
||||
AttributeKind, DocAttribute, DocInline, EiiDecl, EiiImpl, EiiImplResolution, InlineAttr,
|
||||
@@ -29,8 +27,7 @@
|
||||
use rustc_hir::intravisit::{self, Visitor};
|
||||
use rustc_hir::{
|
||||
self as hir, Attribute, CRATE_HIR_ID, Constness, FnSig, ForeignItem, GenericParamKind, HirId,
|
||||
Item, ItemKind, MethodKind, Node, ParamName, PartialConstStability, Safety, Stability,
|
||||
StabilityLevel, Target, TraitItem, find_attr,
|
||||
Item, ItemKind, MethodKind, Node, ParamName, Safety, Target, TraitItem, find_attr,
|
||||
};
|
||||
use rustc_macros::Diagnostic;
|
||||
use rustc_middle::hir::nested_filter;
|
||||
@@ -156,14 +153,8 @@ fn check_attributes(
|
||||
self.check_proc_macro(hir_id, target, ProcMacroKind::Derive)
|
||||
}
|
||||
Attribute::Parsed(
|
||||
AttributeKind::Stability {
|
||||
span: attr_span,
|
||||
stability: Stability { level, feature },
|
||||
}
|
||||
| AttributeKind::RustcConstStability {
|
||||
span: attr_span,
|
||||
stability: PartialConstStability { level, feature, .. },
|
||||
},
|
||||
AttributeKind::Stability { .. }
|
||||
| AttributeKind::RustcConstStability { .. },
|
||||
) => {}
|
||||
Attribute::Parsed(AttributeKind::Inline(InlineAttr::Force { .. }, ..)) => {} // handled separately below
|
||||
Attribute::Parsed(AttributeKind::Inline(kind, attr_span)) => {
|
||||
|
||||
@@ -871,17 +871,6 @@ pub(crate) struct CannotStabilizeDeprecated {
|
||||
pub item_sp: Span,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag("can't mark as unstable using an already stable feature")]
|
||||
pub(crate) struct UnstableAttrForAlreadyStableFeature {
|
||||
#[primary_span]
|
||||
#[label("this feature is already stable")]
|
||||
#[help("consider removing the attribute")]
|
||||
pub attr_span: Span,
|
||||
#[label("the stability attribute annotates this item")]
|
||||
pub item_span: Span,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag("{$descr} has missing stability attribute")]
|
||||
pub(crate) struct MissingStabilityAttr<'a> {
|
||||
|
||||
Reference in New Issue
Block a user