Lint against having both #[unstable_feature_bound] and #[stable] on the same item
This commit is contained in:
@@ -136,6 +136,9 @@ attr_parsing_unrecognized_repr_hint =
|
|||||||
attr_parsing_unstable_cfg_target_compact =
|
attr_parsing_unstable_cfg_target_compact =
|
||||||
compact `cfg(target(..))` is experimental and subject to change
|
compact `cfg(target(..))` is experimental and subject to change
|
||||||
|
|
||||||
|
attr_parsing_unstable_feature_bound_incompatible_stability = Item annotated with `#[unstable_feature_bound]` should not be stable
|
||||||
|
.help = If this item is meant to be stable, do not use any functions annotated with `#[unstable_feature_bound]`. Otherwise, mark this item as unstable with `#[unstable]`
|
||||||
|
|
||||||
attr_parsing_unsupported_literal_cfg_boolean =
|
attr_parsing_unsupported_literal_cfg_boolean =
|
||||||
literal in `cfg` predicate value must be a boolean
|
literal in `cfg` predicate value must be a boolean
|
||||||
attr_parsing_unsupported_literal_cfg_string =
|
attr_parsing_unsupported_literal_cfg_string =
|
||||||
|
|||||||
@@ -98,6 +98,16 @@ impl<S: Stage> AttributeParser<S> for StabilityParser {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if let Some((Stability { level: StabilityLevel::Stable { .. }, .. }, _)) = self.stability {
|
||||||
|
for other_attr in cx.all_attrs {
|
||||||
|
if other_attr.word_is(sym::unstable_feature_bound) {
|
||||||
|
cx.emit_err(session_diagnostics::UnstableFeatureBoundIncompatibleStability {
|
||||||
|
span: cx.target_span,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let (stability, span) = self.stability?;
|
let (stability, span) = self.stability?;
|
||||||
|
|
||||||
Some(AttributeKind::Stability { stability, span })
|
Some(AttributeKind::Stability { stability, span })
|
||||||
|
|||||||
@@ -503,6 +503,14 @@ pub(crate) struct UnrecognizedReprHint {
|
|||||||
pub span: Span,
|
pub span: Span,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Diagnostic)]
|
||||||
|
#[diag(attr_parsing_unstable_feature_bound_incompatible_stability)]
|
||||||
|
#[help]
|
||||||
|
pub(crate) struct UnstableFeatureBoundIncompatibleStability {
|
||||||
|
#[primary_span]
|
||||||
|
pub span: Span,
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(attr_parsing_naked_functions_incompatible_attribute, code = E0736)]
|
#[diag(attr_parsing_naked_functions_incompatible_attribute, code = E0736)]
|
||||||
pub(crate) struct NakedFunctionIncompatibleAttribute {
|
pub(crate) struct NakedFunctionIncompatibleAttribute {
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
#![allow(internal_features)]
|
||||||
|
#![feature(staged_api)]
|
||||||
|
#![allow(dead_code)]
|
||||||
|
#![stable(feature = "a", since = "1.1.1" )]
|
||||||
|
|
||||||
|
// Lint against the usage of both #[unstable_feature_bound] and #[stable] on the
|
||||||
|
// same item.
|
||||||
|
|
||||||
|
#[stable(feature = "a", since = "1.1.1")]
|
||||||
|
#[unstable_feature_bound(feat_bar)]
|
||||||
|
fn bar() {}
|
||||||
|
//~^ ERROR Item annotated with `#[unstable_feature_bound]` should not be stable
|
||||||
|
|
||||||
|
fn main() {}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
error: Item annotated with `#[unstable_feature_bound]` should not be stable
|
||||||
|
--> $DIR/unstable_feature_bound_incompatible_stability.rs:11:1
|
||||||
|
|
|
||||||
|
LL | fn bar() {}
|
||||||
|
| ^^^^^^^^^^^
|
||||||
|
|
|
||||||
|
= help: If this item is meant to be stable, do not use any functions annotated with `#[unstable_feature_bound]`. Otherwise, mark this item as unstable with `#[unstable]`
|
||||||
|
|
||||||
|
error: aborting due to 1 previous error
|
||||||
|
|
||||||
Reference in New Issue
Block a user