pub struct Stability {
pub level: StabilityLevel,
pub feature: Symbol,
- pub rustc_depr: Option<RustcDeprecation>,
}
/// Represents the `#[rustc_const_unstable]` and `#[rustc_const_stable]` attributes.
}
}
-#[derive(RustcEncodable, RustcDecodable, PartialEq, PartialOrd, Copy, Clone, Debug, Eq, Hash)]
-#[derive(HashStable_Generic)]
-pub struct RustcDeprecation {
- pub since: Symbol,
- pub reason: Symbol,
- /// A text snippet used to completely replace any use of the deprecated item in an expression.
- pub suggestion: Option<Symbol>,
-}
-
/// Checks if `attrs` contains an attribute like `#![feature(feature_name)]`.
/// This will not perform any "sanity checks" on the form of the attributes.
pub fn contains_feature_attr(attrs: &[Attribute], feature_name: Symbol) -> bool {
use StabilityLevel::*;
let mut stab: Option<Stability> = None;
- let mut rustc_depr: Option<RustcDeprecation> = None;
let mut const_stab: Option<ConstStability> = None;
let mut promotable = false;
let mut allow_const_fn_ptr = false;
}
};
- macro_rules! get_meta {
- ($($name:ident),+) => {
- $(
- let mut $name = None;
- )+
- for meta in metas {
- if let Some(mi) = meta.meta_item() {
- match mi.name_or_empty() {
- $(
- sym::$name => if !get(mi, &mut $name) { continue 'outer },
- )+
- _ => {
- let expected = &[ $( stringify!($name) ),+ ];
- handle_errors(
- sess,
- mi.span,
- AttrError::UnknownMetaItem(
- pprust::path_to_string(&mi.path),
- expected,
- ),
- );
- continue 'outer
- }
- }
- } else {
- handle_errors(
- sess,
- meta.span(),
- AttrError::UnsupportedLiteral(
- "unsupported literal",
- false,
- ),
- );
- continue 'outer
- }
- }
- }
- }
-
let meta_name = meta.name_or_empty();
match meta_name {
sym::rustc_const_unstable | sym::unstable => {
(Some(feature), reason, Some(_)) => {
let level = Unstable { reason, issue: issue_num, is_soft };
if sym::unstable == meta_name {
- stab = Some(Stability { level, feature, rustc_depr: None });
+ stab = Some(Stability { level, feature });
} else {
const_stab = Some(ConstStability {
level,
(Some(feature), Some(since)) => {
let level = Stable { since };
if sym::stable == meta_name {
- stab = Some(Stability { level, feature, rustc_depr: None });
+ stab = Some(Stability { level, feature });
} else {
const_stab = Some(ConstStability {
level,
}
}
- // Merge the deprecation info into the stability info
- if let Some(rustc_depr) = rustc_depr {
- if let Some(ref mut stab) = stab {
- stab.rustc_depr = Some(rustc_depr);
- } else {
- struct_span_err!(
- diagnostic,
- item_sp,
- E0549,
- "rustc_deprecated attribute must be paired with \
- either stable or unstable attribute"
- )
- .emit();
- }
- }
-
// Merge the const-unstable info into the stability info
if promotable || allow_const_fn_ptr {
if let Some(ref mut stab) = const_stab {