1use std::num::NonZero;
2
3use rustc_macros::{BlobDecodable, Decodable, Encodable, HashStable_Generic, PrintAttribute};
4use rustc_span::{ErrorGuaranteed, Symbol, sym};
5
6use crate::RustcVersion;
7use crate::attrs::PrintAttribute;
8
9pub const VERSION_PLACEHOLDER: &str = "CURRENT_RUSTC_VERSION"concat!("CURRENT_RUSTC_VERSIO", "N");
14#[derive(const _: () =
{
impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
for Stability {
fn encode(&self, __encoder: &mut __E) {
match *self {
Stability { level: ref __binding_0, feature: ref __binding_1
} => {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
::rustc_serialize::Encodable::<__E>::encode(__binding_1,
__encoder);
}
}
}
}
};Encodable, const _: () =
{
impl<__D: ::rustc_span::BlobDecoder> ::rustc_serialize::Decodable<__D>
for Stability {
fn decode(__decoder: &mut __D) -> Self {
Stability {
level: ::rustc_serialize::Decodable::decode(__decoder),
feature: ::rustc_serialize::Decodable::decode(__decoder),
}
}
}
};BlobDecodable, #[automatically_derived]
impl ::core::marker::Copy for Stability { }Copy, #[automatically_derived]
impl ::core::clone::Clone for Stability {
#[inline]
fn clone(&self) -> Stability {
let _: ::core::clone::AssertParamIsClone<StabilityLevel>;
let _: ::core::clone::AssertParamIsClone<Symbol>;
*self
}
}Clone, #[automatically_derived]
impl ::core::fmt::Debug for Stability {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field2_finish(f, "Stability",
"level", &self.level, "feature", &&self.feature)
}
}Debug, #[automatically_derived]
impl ::core::cmp::PartialEq for Stability {
#[inline]
fn eq(&self, other: &Stability) -> bool {
self.level == other.level && self.feature == other.feature
}
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for Stability {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_receiver_is_total_eq(&self) -> () {
let _: ::core::cmp::AssertParamIsEq<StabilityLevel>;
let _: ::core::cmp::AssertParamIsEq<Symbol>;
}
}Eq, #[automatically_derived]
impl ::core::hash::Hash for Stability {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () {
::core::hash::Hash::hash(&self.level, state);
::core::hash::Hash::hash(&self.feature, state)
}
}Hash)]
25#[derive(const _: () =
{
impl<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
for Stability where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
Stability { level: ref __binding_0, feature: ref __binding_1
} => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic, const _: () =
{
#[allow(unused)]
impl PrintAttribute for Stability {
fn should_render(&self) -> bool { true }
fn print_attribute(&self,
__p: &mut rustc_ast_pretty::pp::Printer) {
let Self { level, feature } = self;
__p.word("Stability");
if true && !level.should_render() && !feature.should_render()
{
return;
}
__p.nbsp();
__p.word("{");
let mut __printed_anything = false;
if level.should_render() {
if __printed_anything { __p.word_space(","); }
__p.word("level");
__p.word(":");
__p.nbsp();
__printed_anything = true;
}
level.print_attribute(__p);
if feature.should_render() {
if __printed_anything { __p.word_space(","); }
__p.word("feature");
__p.word(":");
__p.nbsp();
__printed_anything = true;
}
feature.print_attribute(__p);
__p.word("}");
}
}
};PrintAttribute)]
26pub struct Stability {
27 pub level: StabilityLevel,
28 pub feature: Symbol,
29}
30
31impl Stability {
32 pub fn is_unstable(&self) -> bool {
33 self.level.is_unstable()
34 }
35
36 pub fn is_stable(&self) -> bool {
37 self.level.is_stable()
38 }
39
40 pub fn stable_since(&self) -> Option<StableSince> {
41 self.level.stable_since()
42 }
43}
44
45#[derive(const _: () =
{
impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
for ConstStability {
fn encode(&self, __encoder: &mut __E) {
match *self {
ConstStability {
level: ref __binding_0,
feature: ref __binding_1,
promotable: ref __binding_2,
const_stable_indirect: ref __binding_3 } => {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
::rustc_serialize::Encodable::<__E>::encode(__binding_1,
__encoder);
::rustc_serialize::Encodable::<__E>::encode(__binding_2,
__encoder);
::rustc_serialize::Encodable::<__E>::encode(__binding_3,
__encoder);
}
}
}
}
};Encodable, const _: () =
{
impl<__D: ::rustc_span::SpanDecoder> ::rustc_serialize::Decodable<__D>
for ConstStability {
fn decode(__decoder: &mut __D) -> Self {
ConstStability {
level: ::rustc_serialize::Decodable::decode(__decoder),
feature: ::rustc_serialize::Decodable::decode(__decoder),
promotable: ::rustc_serialize::Decodable::decode(__decoder),
const_stable_indirect: ::rustc_serialize::Decodable::decode(__decoder),
}
}
}
};Decodable, #[automatically_derived]
impl ::core::marker::Copy for ConstStability { }Copy, #[automatically_derived]
impl ::core::clone::Clone for ConstStability {
#[inline]
fn clone(&self) -> ConstStability {
let _: ::core::clone::AssertParamIsClone<StabilityLevel>;
let _: ::core::clone::AssertParamIsClone<Symbol>;
let _: ::core::clone::AssertParamIsClone<bool>;
*self
}
}Clone, #[automatically_derived]
impl ::core::fmt::Debug for ConstStability {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field4_finish(f,
"ConstStability", "level", &self.level, "feature", &self.feature,
"promotable", &self.promotable, "const_stable_indirect",
&&self.const_stable_indirect)
}
}Debug, #[automatically_derived]
impl ::core::cmp::PartialEq for ConstStability {
#[inline]
fn eq(&self, other: &ConstStability) -> bool {
self.promotable == other.promotable &&
self.const_stable_indirect == other.const_stable_indirect &&
self.level == other.level && self.feature == other.feature
}
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for ConstStability {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_receiver_is_total_eq(&self) -> () {
let _: ::core::cmp::AssertParamIsEq<StabilityLevel>;
let _: ::core::cmp::AssertParamIsEq<Symbol>;
let _: ::core::cmp::AssertParamIsEq<bool>;
}
}Eq, #[automatically_derived]
impl ::core::hash::Hash for ConstStability {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () {
::core::hash::Hash::hash(&self.level, state);
::core::hash::Hash::hash(&self.feature, state);
::core::hash::Hash::hash(&self.promotable, state);
::core::hash::Hash::hash(&self.const_stable_indirect, state)
}
}Hash)]
47#[derive(const _: () =
{
impl<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
for ConstStability where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
ConstStability {
level: ref __binding_0,
feature: ref __binding_1,
promotable: ref __binding_2,
const_stable_indirect: ref __binding_3 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
{ __binding_3.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic, const _: () =
{
#[allow(unused)]
impl PrintAttribute for ConstStability {
fn should_render(&self) -> bool { true }
fn print_attribute(&self,
__p: &mut rustc_ast_pretty::pp::Printer) {
let Self { level, feature, promotable, const_stable_indirect
} = self;
__p.word("ConstStability");
if true && !level.should_render() && !feature.should_render()
&& !promotable.should_render() &&
!const_stable_indirect.should_render() {
return;
}
__p.nbsp();
__p.word("{");
let mut __printed_anything = false;
if level.should_render() {
if __printed_anything { __p.word_space(","); }
__p.word("level");
__p.word(":");
__p.nbsp();
__printed_anything = true;
}
level.print_attribute(__p);
if feature.should_render() {
if __printed_anything { __p.word_space(","); }
__p.word("feature");
__p.word(":");
__p.nbsp();
__printed_anything = true;
}
feature.print_attribute(__p);
if promotable.should_render() {
if __printed_anything { __p.word_space(","); }
__p.word("promotable");
__p.word(":");
__p.nbsp();
__printed_anything = true;
}
promotable.print_attribute(__p);
if const_stable_indirect.should_render() {
if __printed_anything { __p.word_space(","); }
__p.word("const_stable_indirect");
__p.word(":");
__p.nbsp();
__printed_anything = true;
}
const_stable_indirect.print_attribute(__p);
__p.word("}");
}
}
};PrintAttribute)]
48pub struct ConstStability {
49 pub level: StabilityLevel,
50 pub feature: Symbol,
51 pub promotable: bool,
53 pub const_stable_indirect: bool,
55}
56
57impl ConstStability {
58 pub fn from_partial(
59 PartialConstStability { level, feature, promotable }: PartialConstStability,
60 const_stable_indirect: bool,
61 ) -> Self {
62 Self { const_stable_indirect, level, feature, promotable }
63 }
64
65 pub fn unmarked(const_stable_indirect: bool, regular_stab: Stability) -> Self {
67 Self {
68 feature: regular_stab.feature,
69 promotable: false,
70 level: regular_stab.level,
71 const_stable_indirect,
72 }
73 }
74
75 pub fn is_const_unstable(&self) -> bool {
76 self.level.is_unstable()
77 }
78
79 pub fn is_const_stable(&self) -> bool {
80 self.level.is_stable()
81 }
82}
83
84#[derive(const _: () =
{
impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
for PartialConstStability {
fn encode(&self, __encoder: &mut __E) {
match *self {
PartialConstStability {
level: ref __binding_0,
feature: ref __binding_1,
promotable: ref __binding_2 } => {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
::rustc_serialize::Encodable::<__E>::encode(__binding_1,
__encoder);
::rustc_serialize::Encodable::<__E>::encode(__binding_2,
__encoder);
}
}
}
}
};Encodable, const _: () =
{
impl<__D: ::rustc_span::SpanDecoder> ::rustc_serialize::Decodable<__D>
for PartialConstStability {
fn decode(__decoder: &mut __D) -> Self {
PartialConstStability {
level: ::rustc_serialize::Decodable::decode(__decoder),
feature: ::rustc_serialize::Decodable::decode(__decoder),
promotable: ::rustc_serialize::Decodable::decode(__decoder),
}
}
}
};Decodable, #[automatically_derived]
impl ::core::marker::Copy for PartialConstStability { }Copy, #[automatically_derived]
impl ::core::clone::Clone for PartialConstStability {
#[inline]
fn clone(&self) -> PartialConstStability {
let _: ::core::clone::AssertParamIsClone<StabilityLevel>;
let _: ::core::clone::AssertParamIsClone<Symbol>;
let _: ::core::clone::AssertParamIsClone<bool>;
*self
}
}Clone, #[automatically_derived]
impl ::core::fmt::Debug for PartialConstStability {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field3_finish(f,
"PartialConstStability", "level", &self.level, "feature",
&self.feature, "promotable", &&self.promotable)
}
}Debug, #[automatically_derived]
impl ::core::cmp::PartialEq for PartialConstStability {
#[inline]
fn eq(&self, other: &PartialConstStability) -> bool {
self.promotable == other.promotable && self.level == other.level &&
self.feature == other.feature
}
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for PartialConstStability {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_receiver_is_total_eq(&self) -> () {
let _: ::core::cmp::AssertParamIsEq<StabilityLevel>;
let _: ::core::cmp::AssertParamIsEq<Symbol>;
let _: ::core::cmp::AssertParamIsEq<bool>;
}
}Eq, #[automatically_derived]
impl ::core::hash::Hash for PartialConstStability {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () {
::core::hash::Hash::hash(&self.level, state);
::core::hash::Hash::hash(&self.feature, state);
::core::hash::Hash::hash(&self.promotable, state)
}
}Hash)]
87#[derive(const _: () =
{
impl<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
for PartialConstStability where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
PartialConstStability {
level: ref __binding_0,
feature: ref __binding_1,
promotable: ref __binding_2 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic, const _: () =
{
#[allow(unused)]
impl PrintAttribute for PartialConstStability {
fn should_render(&self) -> bool { true }
fn print_attribute(&self,
__p: &mut rustc_ast_pretty::pp::Printer) {
let Self { level, feature, promotable } = self;
__p.word("PartialConstStability");
if true && !level.should_render() && !feature.should_render()
&& !promotable.should_render() {
return;
}
__p.nbsp();
__p.word("{");
let mut __printed_anything = false;
if level.should_render() {
if __printed_anything { __p.word_space(","); }
__p.word("level");
__p.word(":");
__p.nbsp();
__printed_anything = true;
}
level.print_attribute(__p);
if feature.should_render() {
if __printed_anything { __p.word_space(","); }
__p.word("feature");
__p.word(":");
__p.nbsp();
__printed_anything = true;
}
feature.print_attribute(__p);
if promotable.should_render() {
if __printed_anything { __p.word_space(","); }
__p.word("promotable");
__p.word(":");
__p.nbsp();
__printed_anything = true;
}
promotable.print_attribute(__p);
__p.word("}");
}
}
};PrintAttribute)]
88pub struct PartialConstStability {
89 pub level: StabilityLevel,
90 pub feature: Symbol,
91 pub promotable: bool,
93}
94
95impl PartialConstStability {
96 pub fn is_const_unstable(&self) -> bool {
97 self.level.is_unstable()
98 }
99
100 pub fn is_const_stable(&self) -> bool {
101 self.level.is_stable()
102 }
103}
104
105#[derive(const _: () =
{
impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
for StabilityLevel {
fn encode(&self, __encoder: &mut __E) {
let disc =
match *self {
StabilityLevel::Unstable {
reason: ref __binding_0,
issue: ref __binding_1,
is_soft: ref __binding_2,
implied_by: ref __binding_3,
old_name: ref __binding_4 } => {
0usize
}
StabilityLevel::Stable {
since: ref __binding_0,
allowed_through_unstable_modules: ref __binding_1 } => {
1usize
}
};
::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8);
match *self {
StabilityLevel::Unstable {
reason: ref __binding_0,
issue: ref __binding_1,
is_soft: ref __binding_2,
implied_by: ref __binding_3,
old_name: ref __binding_4 } => {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
::rustc_serialize::Encodable::<__E>::encode(__binding_1,
__encoder);
::rustc_serialize::Encodable::<__E>::encode(__binding_2,
__encoder);
::rustc_serialize::Encodable::<__E>::encode(__binding_3,
__encoder);
::rustc_serialize::Encodable::<__E>::encode(__binding_4,
__encoder);
}
StabilityLevel::Stable {
since: ref __binding_0,
allowed_through_unstable_modules: ref __binding_1 } => {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
::rustc_serialize::Encodable::<__E>::encode(__binding_1,
__encoder);
}
}
}
}
};Encodable, const _: () =
{
impl<__D: ::rustc_span::BlobDecoder> ::rustc_serialize::Decodable<__D>
for StabilityLevel {
fn decode(__decoder: &mut __D) -> Self {
match ::rustc_serialize::Decoder::read_u8(__decoder) as usize
{
0usize => {
StabilityLevel::Unstable {
reason: ::rustc_serialize::Decodable::decode(__decoder),
issue: ::rustc_serialize::Decodable::decode(__decoder),
is_soft: ::rustc_serialize::Decodable::decode(__decoder),
implied_by: ::rustc_serialize::Decodable::decode(__decoder),
old_name: ::rustc_serialize::Decodable::decode(__decoder),
}
}
1usize => {
StabilityLevel::Stable {
since: ::rustc_serialize::Decodable::decode(__decoder),
allowed_through_unstable_modules: ::rustc_serialize::Decodable::decode(__decoder),
}
}
n => {
::core::panicking::panic_fmt(format_args!("invalid enum variant tag while decoding `StabilityLevel`, expected 0..2, actual {0}",
n));
}
}
}
}
};BlobDecodable, #[automatically_derived]
impl ::core::cmp::PartialEq for StabilityLevel {
#[inline]
fn eq(&self, other: &StabilityLevel) -> bool {
let __self_discr = ::core::intrinsics::discriminant_value(self);
let __arg1_discr = ::core::intrinsics::discriminant_value(other);
__self_discr == __arg1_discr &&
match (self, other) {
(StabilityLevel::Unstable {
reason: __self_0,
issue: __self_1,
is_soft: __self_2,
implied_by: __self_3,
old_name: __self_4 }, StabilityLevel::Unstable {
reason: __arg1_0,
issue: __arg1_1,
is_soft: __arg1_2,
implied_by: __arg1_3,
old_name: __arg1_4 }) =>
__self_2 == __arg1_2 && __self_0 == __arg1_0 &&
__self_1 == __arg1_1 && __self_3 == __arg1_3 &&
__self_4 == __arg1_4,
(StabilityLevel::Stable {
since: __self_0, allowed_through_unstable_modules: __self_1
}, StabilityLevel::Stable {
since: __arg1_0, allowed_through_unstable_modules: __arg1_1
}) => __self_0 == __arg1_0 && __self_1 == __arg1_1,
_ => unsafe { ::core::intrinsics::unreachable() }
}
}
}PartialEq, #[automatically_derived]
impl ::core::marker::Copy for StabilityLevel { }Copy, #[automatically_derived]
impl ::core::clone::Clone for StabilityLevel {
#[inline]
fn clone(&self) -> StabilityLevel {
let _: ::core::clone::AssertParamIsClone<UnstableReason>;
let _: ::core::clone::AssertParamIsClone<Option<NonZero<u32>>>;
let _: ::core::clone::AssertParamIsClone<bool>;
let _: ::core::clone::AssertParamIsClone<Option<Symbol>>;
let _: ::core::clone::AssertParamIsClone<Option<Symbol>>;
let _: ::core::clone::AssertParamIsClone<StableSince>;
let _: ::core::clone::AssertParamIsClone<Option<Symbol>>;
*self
}
}Clone, #[automatically_derived]
impl ::core::fmt::Debug for StabilityLevel {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
StabilityLevel::Unstable {
reason: __self_0,
issue: __self_1,
is_soft: __self_2,
implied_by: __self_3,
old_name: __self_4 } =>
::core::fmt::Formatter::debug_struct_field5_finish(f,
"Unstable", "reason", __self_0, "issue", __self_1,
"is_soft", __self_2, "implied_by", __self_3, "old_name",
&__self_4),
StabilityLevel::Stable {
since: __self_0, allowed_through_unstable_modules: __self_1 }
=>
::core::fmt::Formatter::debug_struct_field2_finish(f,
"Stable", "since", __self_0,
"allowed_through_unstable_modules", &__self_1),
}
}
}Debug, #[automatically_derived]
impl ::core::cmp::Eq for StabilityLevel {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_receiver_is_total_eq(&self) -> () {
let _: ::core::cmp::AssertParamIsEq<UnstableReason>;
let _: ::core::cmp::AssertParamIsEq<Option<NonZero<u32>>>;
let _: ::core::cmp::AssertParamIsEq<bool>;
let _: ::core::cmp::AssertParamIsEq<Option<Symbol>>;
let _: ::core::cmp::AssertParamIsEq<Option<Symbol>>;
let _: ::core::cmp::AssertParamIsEq<StableSince>;
let _: ::core::cmp::AssertParamIsEq<Option<Symbol>>;
}
}Eq, #[automatically_derived]
impl ::core::hash::Hash for StabilityLevel {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () {
let __self_discr = ::core::intrinsics::discriminant_value(self);
::core::hash::Hash::hash(&__self_discr, state);
match self {
StabilityLevel::Unstable {
reason: __self_0,
issue: __self_1,
is_soft: __self_2,
implied_by: __self_3,
old_name: __self_4 } => {
::core::hash::Hash::hash(__self_0, state);
::core::hash::Hash::hash(__self_1, state);
::core::hash::Hash::hash(__self_2, state);
::core::hash::Hash::hash(__self_3, state);
::core::hash::Hash::hash(__self_4, state)
}
StabilityLevel::Stable {
since: __self_0, allowed_through_unstable_modules: __self_1 }
=> {
::core::hash::Hash::hash(__self_0, state);
::core::hash::Hash::hash(__self_1, state)
}
}
}
}Hash)]
107#[derive(const _: () =
{
impl<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
for StabilityLevel where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
match *self {
StabilityLevel::Unstable {
reason: ref __binding_0,
issue: ref __binding_1,
is_soft: ref __binding_2,
implied_by: ref __binding_3,
old_name: ref __binding_4 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
{ __binding_3.hash_stable(__hcx, __hasher); }
{ __binding_4.hash_stable(__hcx, __hasher); }
}
StabilityLevel::Stable {
since: ref __binding_0,
allowed_through_unstable_modules: ref __binding_1 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic, const _: () =
{
#[allow(unused)]
impl PrintAttribute for StabilityLevel {
fn should_render(&self) -> bool { true }
fn print_attribute(&self,
__p: &mut rustc_ast_pretty::pp::Printer) {
match self {
Self::Unstable {
reason, issue, is_soft, implied_by, old_name } => {
__p.word("Unstable");
if true && !reason.should_render() && !issue.should_render()
&& !is_soft.should_render() && !implied_by.should_render()
&& !old_name.should_render() {
return;
}
__p.nbsp();
__p.word("{");
let mut __printed_anything = false;
if reason.should_render() {
if __printed_anything { __p.word_space(","); }
__p.word("reason");
__p.word(":");
__p.nbsp();
__printed_anything = true;
}
reason.print_attribute(__p);
if issue.should_render() {
if __printed_anything { __p.word_space(","); }
__p.word("issue");
__p.word(":");
__p.nbsp();
__printed_anything = true;
}
issue.print_attribute(__p);
if is_soft.should_render() {
if __printed_anything { __p.word_space(","); }
__p.word("is_soft");
__p.word(":");
__p.nbsp();
__printed_anything = true;
}
is_soft.print_attribute(__p);
if implied_by.should_render() {
if __printed_anything { __p.word_space(","); }
__p.word("implied_by");
__p.word(":");
__p.nbsp();
__printed_anything = true;
}
implied_by.print_attribute(__p);
if old_name.should_render() {
if __printed_anything { __p.word_space(","); }
__p.word("old_name");
__p.word(":");
__p.nbsp();
__printed_anything = true;
}
old_name.print_attribute(__p);
__p.word("}");
}
Self::Stable { since, allowed_through_unstable_modules } =>
{
__p.word("Stable");
if true && !since.should_render() &&
!allowed_through_unstable_modules.should_render() {
return;
}
__p.nbsp();
__p.word("{");
let mut __printed_anything = false;
if since.should_render() {
if __printed_anything { __p.word_space(","); }
__p.word("since");
__p.word(":");
__p.nbsp();
__printed_anything = true;
}
since.print_attribute(__p);
if allowed_through_unstable_modules.should_render() {
if __printed_anything { __p.word_space(","); }
__p.word("allowed_through_unstable_modules");
__p.word(":");
__p.nbsp();
__printed_anything = true;
}
allowed_through_unstable_modules.print_attribute(__p);
__p.word("}");
}
}
}
}
};PrintAttribute)]
108pub enum StabilityLevel {
109 Unstable {
111 reason: UnstableReason,
113 issue: Option<NonZero<u32>>,
115 is_soft: bool,
116 implied_by: Option<Symbol>,
136 old_name: Option<Symbol>,
137 },
138 Stable {
140 since: StableSince,
142 allowed_through_unstable_modules: Option<Symbol>,
145 },
146}
147
148#[derive(const _: () =
{
impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
for StableSince {
fn encode(&self, __encoder: &mut __E) {
let disc =
match *self {
StableSince::Version(ref __binding_0) => { 0usize }
StableSince::Current => { 1usize }
StableSince::Err(ref __binding_0) => { 2usize }
};
::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8);
match *self {
StableSince::Version(ref __binding_0) => {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
}
StableSince::Current => {}
StableSince::Err(ref __binding_0) => {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
}
}
}
}
};Encodable, const _: () =
{
impl<__D: ::rustc_span::BlobDecoder> ::rustc_serialize::Decodable<__D>
for StableSince {
fn decode(__decoder: &mut __D) -> Self {
match ::rustc_serialize::Decoder::read_u8(__decoder) as usize
{
0usize => {
StableSince::Version(::rustc_serialize::Decodable::decode(__decoder))
}
1usize => { StableSince::Current }
2usize => {
StableSince::Err(::rustc_serialize::Decodable::decode(__decoder))
}
n => {
::core::panicking::panic_fmt(format_args!("invalid enum variant tag while decoding `StableSince`, expected 0..3, actual {0}",
n));
}
}
}
}
};BlobDecodable, #[automatically_derived]
impl ::core::cmp::PartialEq for StableSince {
#[inline]
fn eq(&self, other: &StableSince) -> bool {
let __self_discr = ::core::intrinsics::discriminant_value(self);
let __arg1_discr = ::core::intrinsics::discriminant_value(other);
__self_discr == __arg1_discr &&
match (self, other) {
(StableSince::Version(__self_0),
StableSince::Version(__arg1_0)) => __self_0 == __arg1_0,
(StableSince::Err(__self_0), StableSince::Err(__arg1_0)) =>
__self_0 == __arg1_0,
_ => true,
}
}
}PartialEq, #[automatically_derived]
impl ::core::marker::Copy for StableSince { }Copy, #[automatically_derived]
impl ::core::clone::Clone for StableSince {
#[inline]
fn clone(&self) -> StableSince {
let _: ::core::clone::AssertParamIsClone<RustcVersion>;
let _: ::core::clone::AssertParamIsClone<ErrorGuaranteed>;
*self
}
}Clone, #[automatically_derived]
impl ::core::fmt::Debug for StableSince {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
StableSince::Version(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"Version", &__self_0),
StableSince::Current =>
::core::fmt::Formatter::write_str(f, "Current"),
StableSince::Err(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Err",
&__self_0),
}
}
}Debug, #[automatically_derived]
impl ::core::cmp::Eq for StableSince {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_receiver_is_total_eq(&self) -> () {
let _: ::core::cmp::AssertParamIsEq<RustcVersion>;
let _: ::core::cmp::AssertParamIsEq<ErrorGuaranteed>;
}
}Eq, #[automatically_derived]
impl ::core::cmp::PartialOrd for StableSince {
#[inline]
fn partial_cmp(&self, other: &StableSince)
-> ::core::option::Option<::core::cmp::Ordering> {
let __self_discr = ::core::intrinsics::discriminant_value(self);
let __arg1_discr = ::core::intrinsics::discriminant_value(other);
match (self, other) {
(StableSince::Version(__self_0), StableSince::Version(__arg1_0))
=> ::core::cmp::PartialOrd::partial_cmp(__self_0, __arg1_0),
(StableSince::Err(__self_0), StableSince::Err(__arg1_0)) =>
::core::cmp::PartialOrd::partial_cmp(__self_0, __arg1_0),
_ =>
::core::cmp::PartialOrd::partial_cmp(&__self_discr,
&__arg1_discr),
}
}
}PartialOrd, #[automatically_derived]
impl ::core::cmp::Ord for StableSince {
#[inline]
fn cmp(&self, other: &StableSince) -> ::core::cmp::Ordering {
let __self_discr = ::core::intrinsics::discriminant_value(self);
let __arg1_discr = ::core::intrinsics::discriminant_value(other);
match ::core::cmp::Ord::cmp(&__self_discr, &__arg1_discr) {
::core::cmp::Ordering::Equal =>
match (self, other) {
(StableSince::Version(__self_0),
StableSince::Version(__arg1_0)) =>
::core::cmp::Ord::cmp(__self_0, __arg1_0),
(StableSince::Err(__self_0), StableSince::Err(__arg1_0)) =>
::core::cmp::Ord::cmp(__self_0, __arg1_0),
_ => ::core::cmp::Ordering::Equal,
},
cmp => cmp,
}
}
}Ord, #[automatically_derived]
impl ::core::hash::Hash for StableSince {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () {
let __self_discr = ::core::intrinsics::discriminant_value(self);
::core::hash::Hash::hash(&__self_discr, state);
match self {
StableSince::Version(__self_0) =>
::core::hash::Hash::hash(__self_0, state),
StableSince::Err(__self_0) =>
::core::hash::Hash::hash(__self_0, state),
_ => {}
}
}
}Hash)]
150#[derive(const _: () =
{
impl<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
for StableSince where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
match *self {
StableSince::Version(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
StableSince::Current => {}
StableSince::Err(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic, const _: () =
{
#[allow(unused)]
impl PrintAttribute for StableSince {
fn should_render(&self) -> bool { true }
fn print_attribute(&self,
__p: &mut rustc_ast_pretty::pp::Printer) {
match self {
Self::Version(f0) => {
__p.word("Version");
if true && !f0.should_render() { return; }
__p.popen();
let mut __printed_anything = false;
if f0.should_render() {
if __printed_anything { __p.word_space(","); }
__printed_anything = true;
}
f0.print_attribute(__p);
__p.pclose();
}
Self::Current => { __p.word("Current") }
Self::Err(f0) => {
__p.word("Err");
if true && !f0.should_render() { return; }
__p.popen();
let mut __printed_anything = false;
if f0.should_render() {
if __printed_anything { __p.word_space(","); }
__printed_anything = true;
}
f0.print_attribute(__p);
__p.pclose();
}
}
}
}
};PrintAttribute)]
151pub enum StableSince {
152 Version(RustcVersion),
154 Current,
156 Err(ErrorGuaranteed),
158}
159
160impl StabilityLevel {
161 pub fn is_unstable(&self) -> bool {
162 #[allow(non_exhaustive_omitted_patterns)] match self {
StabilityLevel::Unstable { .. } => true,
_ => false,
}matches!(self, StabilityLevel::Unstable { .. })
163 }
164 pub fn is_stable(&self) -> bool {
165 #[allow(non_exhaustive_omitted_patterns)] match self {
StabilityLevel::Stable { .. } => true,
_ => false,
}matches!(self, StabilityLevel::Stable { .. })
166 }
167 pub fn stable_since(&self) -> Option<StableSince> {
168 match *self {
169 StabilityLevel::Stable { since, .. } => Some(since),
170 StabilityLevel::Unstable { .. } => None,
171 }
172 }
173}
174
175#[derive(const _: () =
{
impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
for UnstableReason {
fn encode(&self, __encoder: &mut __E) {
let disc =
match *self {
UnstableReason::None => { 0usize }
UnstableReason::Default => { 1usize }
UnstableReason::Some(ref __binding_0) => { 2usize }
};
::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8);
match *self {
UnstableReason::None => {}
UnstableReason::Default => {}
UnstableReason::Some(ref __binding_0) => {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
}
}
}
}
};Encodable, const _: () =
{
impl<__D: ::rustc_span::BlobDecoder> ::rustc_serialize::Decodable<__D>
for UnstableReason {
fn decode(__decoder: &mut __D) -> Self {
match ::rustc_serialize::Decoder::read_u8(__decoder) as usize
{
0usize => { UnstableReason::None }
1usize => { UnstableReason::Default }
2usize => {
UnstableReason::Some(::rustc_serialize::Decodable::decode(__decoder))
}
n => {
::core::panicking::panic_fmt(format_args!("invalid enum variant tag while decoding `UnstableReason`, expected 0..3, actual {0}",
n));
}
}
}
}
};BlobDecodable, #[automatically_derived]
impl ::core::cmp::PartialEq for UnstableReason {
#[inline]
fn eq(&self, other: &UnstableReason) -> bool {
let __self_discr = ::core::intrinsics::discriminant_value(self);
let __arg1_discr = ::core::intrinsics::discriminant_value(other);
__self_discr == __arg1_discr &&
match (self, other) {
(UnstableReason::Some(__self_0),
UnstableReason::Some(__arg1_0)) => __self_0 == __arg1_0,
_ => true,
}
}
}PartialEq, #[automatically_derived]
impl ::core::marker::Copy for UnstableReason { }Copy, #[automatically_derived]
impl ::core::clone::Clone for UnstableReason {
#[inline]
fn clone(&self) -> UnstableReason {
let _: ::core::clone::AssertParamIsClone<Symbol>;
*self
}
}Clone, #[automatically_derived]
impl ::core::fmt::Debug for UnstableReason {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
UnstableReason::None =>
::core::fmt::Formatter::write_str(f, "None"),
UnstableReason::Default =>
::core::fmt::Formatter::write_str(f, "Default"),
UnstableReason::Some(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Some",
&__self_0),
}
}
}Debug, #[automatically_derived]
impl ::core::cmp::Eq for UnstableReason {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_receiver_is_total_eq(&self) -> () {
let _: ::core::cmp::AssertParamIsEq<Symbol>;
}
}Eq, #[automatically_derived]
impl ::core::hash::Hash for UnstableReason {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () {
let __self_discr = ::core::intrinsics::discriminant_value(self);
::core::hash::Hash::hash(&__self_discr, state);
match self {
UnstableReason::Some(__self_0) =>
::core::hash::Hash::hash(__self_0, state),
_ => {}
}
}
}Hash)]
176#[derive(const _: () =
{
impl<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
for UnstableReason where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
match *self {
UnstableReason::None => {}
UnstableReason::Default => {}
UnstableReason::Some(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic, const _: () =
{
#[allow(unused)]
impl PrintAttribute for UnstableReason {
fn should_render(&self) -> bool { true }
fn print_attribute(&self,
__p: &mut rustc_ast_pretty::pp::Printer) {
match self {
Self::None => { __p.word("None") }
Self::Default => { __p.word("Default") }
Self::Some(f0) => {
__p.word("Some");
if true && !f0.should_render() { return; }
__p.popen();
let mut __printed_anything = false;
if f0.should_render() {
if __printed_anything { __p.word_space(","); }
__printed_anything = true;
}
f0.print_attribute(__p);
__p.pclose();
}
}
}
}
};PrintAttribute)]
177pub enum UnstableReason {
178 None,
179 Default,
180 Some(Symbol),
181}
182
183#[derive(const _: () =
{
impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
for DefaultBodyStability {
fn encode(&self, __encoder: &mut __E) {
match *self {
DefaultBodyStability {
level: ref __binding_0, feature: ref __binding_1 } => {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
::rustc_serialize::Encodable::<__E>::encode(__binding_1,
__encoder);
}
}
}
}
};Encodable, const _: () =
{
impl<__D: ::rustc_span::SpanDecoder> ::rustc_serialize::Decodable<__D>
for DefaultBodyStability {
fn decode(__decoder: &mut __D) -> Self {
DefaultBodyStability {
level: ::rustc_serialize::Decodable::decode(__decoder),
feature: ::rustc_serialize::Decodable::decode(__decoder),
}
}
}
};Decodable, #[automatically_derived]
impl ::core::marker::Copy for DefaultBodyStability { }Copy, #[automatically_derived]
impl ::core::clone::Clone for DefaultBodyStability {
#[inline]
fn clone(&self) -> DefaultBodyStability {
let _: ::core::clone::AssertParamIsClone<StabilityLevel>;
let _: ::core::clone::AssertParamIsClone<Symbol>;
*self
}
}Clone, #[automatically_derived]
impl ::core::fmt::Debug for DefaultBodyStability {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field2_finish(f,
"DefaultBodyStability", "level", &self.level, "feature",
&&self.feature)
}
}Debug, #[automatically_derived]
impl ::core::cmp::PartialEq for DefaultBodyStability {
#[inline]
fn eq(&self, other: &DefaultBodyStability) -> bool {
self.level == other.level && self.feature == other.feature
}
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for DefaultBodyStability {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_receiver_is_total_eq(&self) -> () {
let _: ::core::cmp::AssertParamIsEq<StabilityLevel>;
let _: ::core::cmp::AssertParamIsEq<Symbol>;
}
}Eq, #[automatically_derived]
impl ::core::hash::Hash for DefaultBodyStability {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () {
::core::hash::Hash::hash(&self.level, state);
::core::hash::Hash::hash(&self.feature, state)
}
}Hash)]
185#[derive(const _: () =
{
impl<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
for DefaultBodyStability where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
DefaultBodyStability {
level: ref __binding_0, feature: ref __binding_1 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic, const _: () =
{
#[allow(unused)]
impl PrintAttribute for DefaultBodyStability {
fn should_render(&self) -> bool { true }
fn print_attribute(&self,
__p: &mut rustc_ast_pretty::pp::Printer) {
let Self { level, feature } = self;
__p.word("DefaultBodyStability");
if true && !level.should_render() && !feature.should_render()
{
return;
}
__p.nbsp();
__p.word("{");
let mut __printed_anything = false;
if level.should_render() {
if __printed_anything { __p.word_space(","); }
__p.word("level");
__p.word(":");
__p.nbsp();
__printed_anything = true;
}
level.print_attribute(__p);
if feature.should_render() {
if __printed_anything { __p.word_space(","); }
__p.word("feature");
__p.word(":");
__p.nbsp();
__printed_anything = true;
}
feature.print_attribute(__p);
__p.word("}");
}
}
};PrintAttribute)]
186pub struct DefaultBodyStability {
187 pub level: StabilityLevel,
188 pub feature: Symbol,
189}
190
191impl UnstableReason {
192 pub fn from_opt_reason(reason: Option<Symbol>) -> Self {
193 match reason {
195 Some(r) => Self::Some(r),
196 None => Self::None,
197 }
198 }
199
200 pub fn to_opt_reason(&self) -> Option<Symbol> {
201 match self {
202 Self::None => None,
203 Self::Default => Some(sym::unstable_location_reason_default),
204 Self::Some(r) => Some(*r),
205 }
206 }
207}