1#![cfg_attr(feature = "nightly", allow(internal_features))]
10#![cfg_attr(feature = "nightly", feature(rustc_attrs))]
11use std::fmt;
14
15#[cfg(feature = "nightly")]
16use rustc_macros::{Decodable_NoContext, Encodable_NoContext, StableHash};
17#[cfg(feature = "nightly")]
18use rustc_span::{Symbol, sym};
19
20pub mod visit;
21
22#[derive(#[automatically_derived]
#[doc(hidden)]
unsafe impl ::core::clone::TrivialClone for IntTy { }
#[automatically_derived]
impl ::core::clone::Clone for IntTy {
#[inline]
fn clone(&self) -> Self { *self }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for IntTy { }Copy, #[automatically_derived]
impl ::core::marker::StructuralPartialEq for IntTy { }
#[automatically_derived]
impl ::core::cmp::PartialEq for IntTy {
#[inline]
fn eq(&self, other: &Self) -> bool {
::core::intrinsics::discriminant_value(self) ==
::core::intrinsics::discriminant_value(other)
}
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for IntTy { }Eq, #[automatically_derived]
impl ::core::cmp::PartialOrd for IntTy {
#[inline]
fn partial_cmp(&self, other: &Self)
-> ::core::option::Option<::core::cmp::Ordering> {
::core::option::Option::Some(::core::cmp::Ord::cmp(self, other))
}
}PartialOrd, #[automatically_derived]
impl ::core::cmp::Ord for IntTy {
#[inline]
fn cmp(&self, other: &Self) -> ::core::cmp::Ordering {
::core::cmp::Ord::cmp(&::core::intrinsics::discriminant_value(self),
&::core::intrinsics::discriminant_value(other))
}
}Ord, #[automatically_derived]
impl ::core::hash::Hash for IntTy {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
::core::hash::Hash::hash(&::core::intrinsics::discriminant_value(self),
state)
}
}Hash)]
23#[cfg_attr(feature = "nightly", derive(const _: () =
{
impl<__E: ::rustc_serialize::Encoder>
::rustc_serialize::Encodable<__E> for IntTy {
fn encode(&self, __encoder: &mut __E) {
let disc =
match *self {
IntTy::Isize => { 0usize }
IntTy::I8 => { 1usize }
IntTy::I16 => { 2usize }
IntTy::I32 => { 3usize }
IntTy::I64 => { 4usize }
IntTy::I128 => { 5usize }
};
::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8);
}
}
};Encodable_NoContext, const _: () =
{
impl<__D: ::rustc_serialize::Decoder>
::rustc_serialize::Decodable<__D> for IntTy {
fn decode(__decoder: &mut __D) -> Self {
match ::rustc_serialize::Decoder::read_u8(__decoder) as usize
{
0usize => { IntTy::Isize }
1usize => { IntTy::I8 }
2usize => { IntTy::I16 }
3usize => { IntTy::I32 }
4usize => { IntTy::I64 }
5usize => { IntTy::I128 }
n => {
::core::panicking::panic_fmt(format_args!("invalid enum variant tag while decoding `IntTy`, expected 0..6, actual {0}",
n));
}
}
}
}
};Decodable_NoContext, const _: () =
{
impl ::rustc_data_structures::stable_hash::StableHash for IntTy {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
::std::mem::discriminant(self).stable_hash(__hcx, __hasher);
match *self {
IntTy::Isize => {}
IntTy::I8 => {}
IntTy::I16 => {}
IntTy::I32 => {}
IntTy::I64 => {}
IntTy::I128 => {}
}
}
}
};StableHash))]
24pub enum IntTy {
25 Isize,
26 I8,
27 I16,
28 I32,
29 I64,
30 I128,
31}
32
33impl IntTy {
34 pub fn name_str(&self) -> &'static str {
35 match *self {
36 IntTy::Isize => "isize",
37 IntTy::I8 => "i8",
38 IntTy::I16 => "i16",
39 IntTy::I32 => "i32",
40 IntTy::I64 => "i64",
41 IntTy::I128 => "i128",
42 }
43 }
44
45 #[cfg(feature = "nightly")]
46 pub fn name(self) -> Symbol {
47 match self {
48 IntTy::Isize => sym::isize,
49 IntTy::I8 => sym::i8,
50 IntTy::I16 => sym::i16,
51 IntTy::I32 => sym::i32,
52 IntTy::I64 => sym::i64,
53 IntTy::I128 => sym::i128,
54 }
55 }
56
57 pub fn bit_width(&self) -> Option<u64> {
58 Some(match *self {
59 IntTy::Isize => return None,
60 IntTy::I8 => 8,
61 IntTy::I16 => 16,
62 IntTy::I32 => 32,
63 IntTy::I64 => 64,
64 IntTy::I128 => 128,
65 })
66 }
67
68 pub fn normalize(&self, target_width: u16) -> Self {
69 match self {
70 IntTy::Isize => match target_width {
71 16 => IntTy::I16,
72 32 => IntTy::I32,
73 64 => IntTy::I64,
74 _ => ::core::panicking::panic("internal error: entered unreachable code")unreachable!(),
75 },
76 _ => *self,
77 }
78 }
79
80 pub fn to_unsigned(self) -> UintTy {
81 match self {
82 IntTy::Isize => UintTy::Usize,
83 IntTy::I8 => UintTy::U8,
84 IntTy::I16 => UintTy::U16,
85 IntTy::I32 => UintTy::U32,
86 IntTy::I64 => UintTy::U64,
87 IntTy::I128 => UintTy::U128,
88 }
89 }
90}
91
92impl fmt::Debug for IntTy {
93 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
94 f.write_fmt(format_args!("{0}", self.name_str()))write!(f, "{}", self.name_str())
95 }
96}
97
98#[derive(#[automatically_derived]
#[doc(hidden)]
unsafe impl ::core::clone::TrivialClone for UintTy { }
#[automatically_derived]
impl ::core::clone::Clone for UintTy {
#[inline]
fn clone(&self) -> Self { *self }
}Clone, #[automatically_derived]
impl ::core::marker::StructuralPartialEq for UintTy { }
#[automatically_derived]
impl ::core::cmp::PartialEq for UintTy {
#[inline]
fn eq(&self, other: &Self) -> bool {
::core::intrinsics::discriminant_value(self) ==
::core::intrinsics::discriminant_value(other)
}
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for UintTy { }Eq, #[automatically_derived]
impl ::core::cmp::PartialOrd for UintTy {
#[inline]
fn partial_cmp(&self, other: &Self)
-> ::core::option::Option<::core::cmp::Ordering> {
::core::option::Option::Some(::core::cmp::Ord::cmp(self, other))
}
}PartialOrd, #[automatically_derived]
impl ::core::cmp::Ord for UintTy {
#[inline]
fn cmp(&self, other: &Self) -> ::core::cmp::Ordering {
::core::cmp::Ord::cmp(&::core::intrinsics::discriminant_value(self),
&::core::intrinsics::discriminant_value(other))
}
}Ord, #[automatically_derived]
impl ::core::hash::Hash for UintTy {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
::core::hash::Hash::hash(&::core::intrinsics::discriminant_value(self),
state)
}
}Hash, #[automatically_derived]
impl ::core::marker::Copy for UintTy { }Copy)]
99#[cfg_attr(feature = "nightly", derive(const _: () =
{
impl<__E: ::rustc_serialize::Encoder>
::rustc_serialize::Encodable<__E> for UintTy {
fn encode(&self, __encoder: &mut __E) {
let disc =
match *self {
UintTy::Usize => { 0usize }
UintTy::U8 => { 1usize }
UintTy::U16 => { 2usize }
UintTy::U32 => { 3usize }
UintTy::U64 => { 4usize }
UintTy::U128 => { 5usize }
};
::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8);
}
}
};Encodable_NoContext, const _: () =
{
impl<__D: ::rustc_serialize::Decoder>
::rustc_serialize::Decodable<__D> for UintTy {
fn decode(__decoder: &mut __D) -> Self {
match ::rustc_serialize::Decoder::read_u8(__decoder) as usize
{
0usize => { UintTy::Usize }
1usize => { UintTy::U8 }
2usize => { UintTy::U16 }
3usize => { UintTy::U32 }
4usize => { UintTy::U64 }
5usize => { UintTy::U128 }
n => {
::core::panicking::panic_fmt(format_args!("invalid enum variant tag while decoding `UintTy`, expected 0..6, actual {0}",
n));
}
}
}
}
};Decodable_NoContext, const _: () =
{
impl ::rustc_data_structures::stable_hash::StableHash for UintTy {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
::std::mem::discriminant(self).stable_hash(__hcx, __hasher);
match *self {
UintTy::Usize => {}
UintTy::U8 => {}
UintTy::U16 => {}
UintTy::U32 => {}
UintTy::U64 => {}
UintTy::U128 => {}
}
}
}
};StableHash))]
100pub enum UintTy {
101 Usize,
102 U8,
103 U16,
104 U32,
105 U64,
106 U128,
107}
108
109impl UintTy {
110 pub fn name_str(&self) -> &'static str {
111 match *self {
112 UintTy::Usize => "usize",
113 UintTy::U8 => "u8",
114 UintTy::U16 => "u16",
115 UintTy::U32 => "u32",
116 UintTy::U64 => "u64",
117 UintTy::U128 => "u128",
118 }
119 }
120
121 #[cfg(feature = "nightly")]
122 pub fn name(self) -> Symbol {
123 match self {
124 UintTy::Usize => sym::usize,
125 UintTy::U8 => sym::u8,
126 UintTy::U16 => sym::u16,
127 UintTy::U32 => sym::u32,
128 UintTy::U64 => sym::u64,
129 UintTy::U128 => sym::u128,
130 }
131 }
132
133 pub fn bit_width(&self) -> Option<u64> {
134 Some(match *self {
135 UintTy::Usize => return None,
136 UintTy::U8 => 8,
137 UintTy::U16 => 16,
138 UintTy::U32 => 32,
139 UintTy::U64 => 64,
140 UintTy::U128 => 128,
141 })
142 }
143
144 pub fn normalize(&self, target_width: u16) -> Self {
145 match self {
146 UintTy::Usize => match target_width {
147 16 => UintTy::U16,
148 32 => UintTy::U32,
149 64 => UintTy::U64,
150 _ => ::core::panicking::panic("internal error: entered unreachable code")unreachable!(),
151 },
152 _ => *self,
153 }
154 }
155
156 pub fn to_signed(self) -> IntTy {
157 match self {
158 UintTy::Usize => IntTy::Isize,
159 UintTy::U8 => IntTy::I8,
160 UintTy::U16 => IntTy::I16,
161 UintTy::U32 => IntTy::I32,
162 UintTy::U64 => IntTy::I64,
163 UintTy::U128 => IntTy::I128,
164 }
165 }
166}
167
168impl fmt::Debug for UintTy {
169 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
170 f.write_fmt(format_args!("{0}", self.name_str()))write!(f, "{}", self.name_str())
171 }
172}
173
174#[derive(#[automatically_derived]
#[doc(hidden)]
unsafe impl ::core::clone::TrivialClone for FloatTy { }
#[automatically_derived]
impl ::core::clone::Clone for FloatTy {
#[inline]
fn clone(&self) -> Self { *self }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for FloatTy { }Copy, #[automatically_derived]
impl ::core::marker::StructuralPartialEq for FloatTy { }
#[automatically_derived]
impl ::core::cmp::PartialEq for FloatTy {
#[inline]
fn eq(&self, other: &Self) -> bool {
::core::intrinsics::discriminant_value(self) ==
::core::intrinsics::discriminant_value(other)
}
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for FloatTy { }Eq, #[automatically_derived]
impl ::core::cmp::PartialOrd for FloatTy {
#[inline]
fn partial_cmp(&self, other: &Self)
-> ::core::option::Option<::core::cmp::Ordering> {
::core::option::Option::Some(::core::cmp::Ord::cmp(self, other))
}
}PartialOrd, #[automatically_derived]
impl ::core::cmp::Ord for FloatTy {
#[inline]
fn cmp(&self, other: &Self) -> ::core::cmp::Ordering {
::core::cmp::Ord::cmp(&::core::intrinsics::discriminant_value(self),
&::core::intrinsics::discriminant_value(other))
}
}Ord, #[automatically_derived]
impl ::core::hash::Hash for FloatTy {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
::core::hash::Hash::hash(&::core::intrinsics::discriminant_value(self),
state)
}
}Hash)]
175#[cfg_attr(feature = "nightly", derive(const _: () =
{
impl<__E: ::rustc_serialize::Encoder>
::rustc_serialize::Encodable<__E> for FloatTy {
fn encode(&self, __encoder: &mut __E) {
let disc =
match *self {
FloatTy::F16 => { 0usize }
FloatTy::F32 => { 1usize }
FloatTy::F64 => { 2usize }
FloatTy::F128 => { 3usize }
};
::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8);
}
}
};Encodable_NoContext, const _: () =
{
impl<__D: ::rustc_serialize::Decoder>
::rustc_serialize::Decodable<__D> for FloatTy {
fn decode(__decoder: &mut __D) -> Self {
match ::rustc_serialize::Decoder::read_u8(__decoder) as usize
{
0usize => { FloatTy::F16 }
1usize => { FloatTy::F32 }
2usize => { FloatTy::F64 }
3usize => { FloatTy::F128 }
n => {
::core::panicking::panic_fmt(format_args!("invalid enum variant tag while decoding `FloatTy`, expected 0..4, actual {0}",
n));
}
}
}
}
};Decodable_NoContext, const _: () =
{
impl ::rustc_data_structures::stable_hash::StableHash for FloatTy {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
::std::mem::discriminant(self).stable_hash(__hcx, __hasher);
match *self {
FloatTy::F16 => {}
FloatTy::F32 => {}
FloatTy::F64 => {}
FloatTy::F128 => {}
}
}
}
};StableHash))]
176pub enum FloatTy {
177 F16,
178 F32,
179 F64,
180 F128,
181}
182
183impl FloatTy {
184 pub fn name_str(self) -> &'static str {
185 match self {
186 FloatTy::F16 => "f16",
187 FloatTy::F32 => "f32",
188 FloatTy::F64 => "f64",
189 FloatTy::F128 => "f128",
190 }
191 }
192
193 #[cfg(feature = "nightly")]
194 pub fn name(self) -> Symbol {
195 match self {
196 FloatTy::F16 => sym::f16,
197 FloatTy::F32 => sym::f32,
198 FloatTy::F64 => sym::f64,
199 FloatTy::F128 => sym::f128,
200 }
201 }
202
203 pub fn bit_width(self) -> u64 {
204 match self {
205 FloatTy::F16 => 16,
206 FloatTy::F32 => 32,
207 FloatTy::F64 => 64,
208 FloatTy::F128 => 128,
209 }
210 }
211}
212
213impl fmt::Debug for FloatTy {
214 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
215 f.write_fmt(format_args!("{0}", self.name_str()))write!(f, "{}", self.name_str())
216 }
217}
218
219#[derive(#[automatically_derived]
#[doc(hidden)]
unsafe impl ::core::clone::TrivialClone for Movability { }
#[automatically_derived]
impl ::core::clone::Clone for Movability {
#[inline]
fn clone(&self) -> Self { *self }
}Clone, #[automatically_derived]
impl ::core::marker::StructuralPartialEq for Movability { }
#[automatically_derived]
impl ::core::cmp::PartialEq for Movability {
#[inline]
fn eq(&self, other: &Self) -> bool {
::core::intrinsics::discriminant_value(self) ==
::core::intrinsics::discriminant_value(other)
}
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for Movability { }Eq, #[automatically_derived]
impl ::core::cmp::PartialOrd for Movability {
#[inline]
fn partial_cmp(&self, other: &Self)
-> ::core::option::Option<::core::cmp::Ordering> {
::core::option::Option::Some(::core::cmp::Ord::cmp(self, other))
}
}PartialOrd, #[automatically_derived]
impl ::core::cmp::Ord for Movability {
#[inline]
fn cmp(&self, other: &Self) -> ::core::cmp::Ordering {
::core::cmp::Ord::cmp(&::core::intrinsics::discriminant_value(self),
&::core::intrinsics::discriminant_value(other))
}
}Ord, #[automatically_derived]
impl ::core::hash::Hash for Movability {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
::core::hash::Hash::hash(&::core::intrinsics::discriminant_value(self),
state)
}
}Hash, #[automatically_derived]
impl ::core::fmt::Debug for Movability {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::write_str(f,
match self {
Movability::Static => "Static",
Movability::Movable => "Movable",
})
}
}Debug, #[automatically_derived]
impl ::core::marker::Copy for Movability { }Copy)]
222#[cfg_attr(feature = "nightly", derive(const _: () =
{
impl<__E: ::rustc_serialize::Encoder>
::rustc_serialize::Encodable<__E> for Movability {
fn encode(&self, __encoder: &mut __E) {
let disc =
match *self {
Movability::Static => { 0usize }
Movability::Movable => { 1usize }
};
::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8);
}
}
};Encodable_NoContext, const _: () =
{
impl<__D: ::rustc_serialize::Decoder>
::rustc_serialize::Decodable<__D> for Movability {
fn decode(__decoder: &mut __D) -> Self {
match ::rustc_serialize::Decoder::read_u8(__decoder) as usize
{
0usize => { Movability::Static }
1usize => { Movability::Movable }
n => {
::core::panicking::panic_fmt(format_args!("invalid enum variant tag while decoding `Movability`, expected 0..2, actual {0}",
n));
}
}
}
}
};Decodable_NoContext, const _: () =
{
impl ::rustc_data_structures::stable_hash::StableHash for Movability {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
::std::mem::discriminant(self).stable_hash(__hcx, __hasher);
match *self {
Movability::Static => {}
Movability::Movable => {}
}
}
}
};StableHash))]
223pub enum Movability {
224 Static,
226 Movable,
228}
229
230#[derive(#[automatically_derived]
#[doc(hidden)]
unsafe impl ::core::clone::TrivialClone for Mutability { }
#[automatically_derived]
impl ::core::clone::Clone for Mutability {
#[inline]
fn clone(&self) -> Self { *self }
}Clone, #[automatically_derived]
impl ::core::marker::StructuralPartialEq for Mutability { }
#[automatically_derived]
impl ::core::cmp::PartialEq for Mutability {
#[inline]
fn eq(&self, other: &Self) -> bool {
::core::intrinsics::discriminant_value(self) ==
::core::intrinsics::discriminant_value(other)
}
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for Mutability { }Eq, #[automatically_derived]
impl ::core::cmp::PartialOrd for Mutability {
#[inline]
fn partial_cmp(&self, other: &Self)
-> ::core::option::Option<::core::cmp::Ordering> {
::core::option::Option::Some(::core::cmp::Ord::cmp(self, other))
}
}PartialOrd, #[automatically_derived]
impl ::core::cmp::Ord for Mutability {
#[inline]
fn cmp(&self, other: &Self) -> ::core::cmp::Ordering {
::core::cmp::Ord::cmp(&::core::intrinsics::discriminant_value(self),
&::core::intrinsics::discriminant_value(other))
}
}Ord, #[automatically_derived]
impl ::core::hash::Hash for Mutability {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
::core::hash::Hash::hash(&::core::intrinsics::discriminant_value(self),
state)
}
}Hash, #[automatically_derived]
impl ::core::fmt::Debug for Mutability {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::write_str(f,
match self {
Mutability::Not => "Not",
Mutability::Mut => "Mut",
})
}
}Debug, #[automatically_derived]
impl ::core::marker::Copy for Mutability { }Copy)]
231#[cfg_attr(feature = "nightly", derive(const _: () =
{
impl<__E: ::rustc_serialize::Encoder>
::rustc_serialize::Encodable<__E> for Mutability {
fn encode(&self, __encoder: &mut __E) {
let disc =
match *self {
Mutability::Not => { 0usize }
Mutability::Mut => { 1usize }
};
::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8);
}
}
};Encodable_NoContext, const _: () =
{
impl<__D: ::rustc_serialize::Decoder>
::rustc_serialize::Decodable<__D> for Mutability {
fn decode(__decoder: &mut __D) -> Self {
match ::rustc_serialize::Decoder::read_u8(__decoder) as usize
{
0usize => { Mutability::Not }
1usize => { Mutability::Mut }
n => {
::core::panicking::panic_fmt(format_args!("invalid enum variant tag while decoding `Mutability`, expected 0..2, actual {0}",
n));
}
}
}
}
};Decodable_NoContext, const _: () =
{
impl ::rustc_data_structures::stable_hash::StableHash for Mutability {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
::std::mem::discriminant(self).stable_hash(__hcx, __hasher);
match *self { Mutability::Not => {} Mutability::Mut => {} }
}
}
};StableHash))]
232pub enum Mutability {
233 Not,
235 Mut,
236}
237
238impl Mutability {
239 pub fn invert(self) -> Self {
240 match self {
241 Mutability::Mut => Mutability::Not,
242 Mutability::Not => Mutability::Mut,
243 }
244 }
245
246 pub fn prefix_str(self) -> &'static str {
248 match self {
249 Mutability::Mut => "mut ",
250 Mutability::Not => "",
251 }
252 }
253
254 pub fn ref_prefix_str(self) -> &'static str {
256 match self {
257 Mutability::Not => "&",
258 Mutability::Mut => "&mut ",
259 }
260 }
261
262 pub fn ptr_str(self) -> &'static str {
264 match self {
265 Mutability::Not => "const",
266 Mutability::Mut => "mut",
267 }
268 }
269
270 pub fn mutably_str(self) -> &'static str {
272 match self {
273 Mutability::Not => "",
274 Mutability::Mut => "mutably ",
275 }
276 }
277
278 pub fn is_mut(self) -> bool {
280 #[allow(non_exhaustive_omitted_patterns)] match self {
Self::Mut => true,
_ => false,
}matches!(self, Self::Mut)
281 }
282
283 pub fn is_not(self) -> bool {
285 #[allow(non_exhaustive_omitted_patterns)] match self {
Self::Not => true,
_ => false,
}matches!(self, Self::Not)
286 }
287}
288
289#[derive(#[automatically_derived]
#[doc(hidden)]
unsafe impl ::core::clone::TrivialClone for Pinnedness { }
#[automatically_derived]
impl ::core::clone::Clone for Pinnedness {
#[inline]
fn clone(&self) -> Self { *self }
}Clone, #[automatically_derived]
impl ::core::marker::StructuralPartialEq for Pinnedness { }
#[automatically_derived]
impl ::core::cmp::PartialEq for Pinnedness {
#[inline]
fn eq(&self, other: &Self) -> bool {
::core::intrinsics::discriminant_value(self) ==
::core::intrinsics::discriminant_value(other)
}
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for Pinnedness { }Eq, #[automatically_derived]
impl ::core::cmp::PartialOrd for Pinnedness {
#[inline]
fn partial_cmp(&self, other: &Self)
-> ::core::option::Option<::core::cmp::Ordering> {
::core::option::Option::Some(::core::cmp::Ord::cmp(self, other))
}
}PartialOrd, #[automatically_derived]
impl ::core::cmp::Ord for Pinnedness {
#[inline]
fn cmp(&self, other: &Self) -> ::core::cmp::Ordering {
::core::cmp::Ord::cmp(&::core::intrinsics::discriminant_value(self),
&::core::intrinsics::discriminant_value(other))
}
}Ord, #[automatically_derived]
impl ::core::hash::Hash for Pinnedness {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
::core::hash::Hash::hash(&::core::intrinsics::discriminant_value(self),
state)
}
}Hash, #[automatically_derived]
impl ::core::fmt::Debug for Pinnedness {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::write_str(f,
match self {
Pinnedness::Not => "Not",
Pinnedness::Pinned => "Pinned",
})
}
}Debug, #[automatically_derived]
impl ::core::marker::Copy for Pinnedness { }Copy)]
290#[cfg_attr(feature = "nightly", derive(const _: () =
{
impl<__E: ::rustc_serialize::Encoder>
::rustc_serialize::Encodable<__E> for Pinnedness {
fn encode(&self, __encoder: &mut __E) {
let disc =
match *self {
Pinnedness::Not => { 0usize }
Pinnedness::Pinned => { 1usize }
};
::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8);
}
}
};Encodable_NoContext, const _: () =
{
impl<__D: ::rustc_serialize::Decoder>
::rustc_serialize::Decodable<__D> for Pinnedness {
fn decode(__decoder: &mut __D) -> Self {
match ::rustc_serialize::Decoder::read_u8(__decoder) as usize
{
0usize => { Pinnedness::Not }
1usize => { Pinnedness::Pinned }
n => {
::core::panicking::panic_fmt(format_args!("invalid enum variant tag while decoding `Pinnedness`, expected 0..2, actual {0}",
n));
}
}
}
}
};Decodable_NoContext, const _: () =
{
impl ::rustc_data_structures::stable_hash::StableHash for Pinnedness {
#[inline]
fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
__hcx: &mut __Hcx,
__hasher:
&mut ::rustc_data_structures::stable_hash::StableHasher) {
::std::mem::discriminant(self).stable_hash(__hcx, __hasher);
match *self { Pinnedness::Not => {} Pinnedness::Pinned => {} }
}
}
};StableHash))]
291pub enum Pinnedness {
292 Not,
293 Pinned,
294}
295
296impl Pinnedness {
297 pub fn is_pinned(self) -> bool {
299 #[allow(non_exhaustive_omitted_patterns)] match self {
Self::Pinned => true,
_ => false,
}matches!(self, Self::Pinned)
300 }
301
302 pub fn prefix_str(self, mutbl: Mutability) -> &'static str {
305 match (self, mutbl) {
306 (Pinnedness::Pinned, Mutability::Mut) => "pin mut ",
307 (Pinnedness::Pinned, Mutability::Not) => "pin const ",
308 (Pinnedness::Not, Mutability::Mut) => "mut ",
309 (Pinnedness::Not, Mutability::Not) => "",
310 }
311 }
312}