summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
f53fc41)
This avoids an ambiguity (when reading) where `.level.is_stable()` is
not immediately clear whether it is general stability or const
stability.
+impl Stability {
+ pub fn is_unstable(&self) -> bool {
+ self.level.is_unstable()
+ }
+
+ pub fn is_stable(&self) -> bool {
+ self.level.is_stable()
+ }
+}
+
/// Represents the `#[rustc_const_unstable]` and `#[rustc_const_stable]` attributes.
#[derive(Encodable, Decodable, Copy, Clone, Debug, PartialEq, Eq, Hash)]
#[derive(HashStable_Generic)]
/// Represents the `#[rustc_const_unstable]` and `#[rustc_const_stable]` attributes.
#[derive(Encodable, Decodable, Copy, Clone, Debug, PartialEq, Eq, Hash)]
#[derive(HashStable_Generic)]
+impl ConstStability {
+ pub fn is_const_unstable(&self) -> bool {
+ self.level.is_unstable()
+ }
+
+ pub fn is_const_stable(&self) -> bool {
+ self.level.is_stable()
+ }
+}
+
/// The available stability levels.
#[derive(Encodable, Decodable, PartialEq, Copy, Clone, Debug, Eq, Hash)]
#[derive(HashStable_Generic)]
/// The available stability levels.
#[derive(Encodable, Decodable, PartialEq, Copy, Clone, Debug, Eq, Hash)]
#[derive(HashStable_Generic)]
pub fn is_unstable_const_fn(tcx: TyCtxt<'_>, def_id: DefId) -> Option<Symbol> {
if tcx.is_const_fn_raw(def_id) {
let const_stab = tcx.lookup_const_stability(def_id)?;
pub fn is_unstable_const_fn(tcx: TyCtxt<'_>, def_id: DefId) -> Option<Symbol> {
if tcx.is_const_fn_raw(def_id) {
let const_stab = tcx.lookup_const_stability(def_id)?;
- if const_stab.level.is_unstable() { Some(const_stab.feature) } else { None }
+ if const_stab.is_const_unstable() { Some(const_stab.feature) } else { None }
// have no `rustc_const_stable` attributes to be const-unstable as well. This
// should be fixed later.
let callee_is_unstable_unmarked = tcx.lookup_const_stability(callee).is_none()
// have no `rustc_const_stable` attributes to be const-unstable as well. This
// should be fixed later.
let callee_is_unstable_unmarked = tcx.lookup_const_stability(callee).is_none()
- && tcx.lookup_stability(callee).map_or(false, |s| s.level.is_unstable());
+ && tcx.lookup_stability(callee).map_or(false, |s| s.is_unstable());
if callee_is_unstable_unmarked {
trace!("callee_is_unstable_unmarked");
// We do not use `const` modifiers for intrinsic "functions", as intrinsics are
if callee_is_unstable_unmarked {
trace!("callee_is_unstable_unmarked");
// We do not use `const` modifiers for intrinsic "functions", as intrinsics are
pub fn is_const_fn(self, def_id: DefId) -> bool {
if self.is_const_fn_raw(def_id) {
match self.lookup_const_stability(def_id) {
pub fn is_const_fn(self, def_id: DefId) -> bool {
if self.is_const_fn_raw(def_id) {
match self.lookup_const_stability(def_id) {
- Some(stability) if stability.level.is_unstable() => {
+ Some(stability) if stability.is_const_unstable() => {
// has a `rustc_const_unstable` attribute, check whether the user enabled the
// corresponding feature gate.
self.features()
// has a `rustc_const_unstable` attribute, check whether the user enabled the
// corresponding feature gate.
self.features()
// Propagate unstability. This can happen even for non-staged-api crates in case
// -Zforce-unstable-if-unmarked is set.
if let Some(stab) = self.parent_stab {
// Propagate unstability. This can happen even for non-staged-api crates in case
// -Zforce-unstable-if-unmarked is set.
if let Some(stab) = self.parent_stab {
- if inherit_deprecation.yes() && stab.level.is_unstable() {
+ if inherit_deprecation.yes() && stab.is_unstable() {
self.index.stab_map.insert(def_id, stab);
}
}
self.index.stab_map.insert(def_id, stab);
}
}
if const_stab.is_none() {
debug!("annotate: const_stab not found, parent = {:?}", self.parent_const_stab);
if let Some(parent) = self.parent_const_stab {
if const_stab.is_none() {
debug!("annotate: const_stab not found, parent = {:?}", self.parent_const_stab);
if let Some(parent) = self.parent_const_stab {
- if parent.level.is_unstable() {
+ if parent.is_const_unstable() {
self.index.const_stab_map.insert(def_id, parent);
}
}
self.index.const_stab_map.insert(def_id, parent);
}
}
if stab.is_none() {
debug!("annotate: stab not found, parent = {:?}", self.parent_stab);
if let Some(stab) = self.parent_stab {
if stab.is_none() {
debug!("annotate: stab not found, parent = {:?}", self.parent_stab);
if let Some(stab) = self.parent_stab {
- if inherit_deprecation.yes() && stab.level.is_unstable()
- || inherit_from_parent.yes()
- {
+ if inherit_deprecation.yes() && stab.is_unstable() || inherit_from_parent.yes() {
self.index.stab_map.insert(def_id, stab);
}
}
self.index.stab_map.insert(def_id, stab);
}
}
}
if let Some(stab) = tcx.lookup_stability(did) {
}
if let Some(stab) = tcx.lookup_stability(did) {
- if stab.level.is_unstable() && stab.feature == sym::rustc_private {
+ if stab.is_unstable() && stab.feature == sym::rustc_private {
}
if let Some(stab) = tcx.lookup_stability(did) {
}
if let Some(stab) = tcx.lookup_stability(did) {
- if stab.level.is_unstable() && stab.feature == sym::rustc_private {
+ if stab.is_unstable() && stab.feature == sym::rustc_private {
self.stability(tcx).as_ref().and_then(|s| {
let mut classes = Vec::with_capacity(2);
self.stability(tcx).as_ref().and_then(|s| {
let mut classes = Vec::with_capacity(2);
- if s.level.is_unstable() {
classes.push("unstable");
}
classes.push("unstable");
}
// The "rustc_private" crates are permanently unstable so it makes no sense
// to render "unstable" everywhere.
// The "rustc_private" crates are permanently unstable so it makes no sense
// to render "unstable" everywhere.
- if item
- .stability(tcx)
- .as_ref()
- .map(|s| s.level.is_unstable() && s.feature != sym::rustc_private)
+ if item.stability(tcx).as_ref().map(|s| s.is_unstable() && s.feature != sym::rustc_private)
== Some(true)
{
tags += &tag_html("unstable", "", "Experimental");
== Some(true)
{
tags += &tag_html("unstable", "", "Experimental");