1#![cfg_attr(feature = "nightly", allow(internal_features))]
3#![cfg_attr(feature = "nightly", feature(never_type))]
4#![cfg_attr(feature = "nightly", feature(rustc_attrs))]
5#![warn(unreachable_pub)]
6#[cfg(feature = "nightly")]
9use rustc_macros::{Decodable, Encodable, HashStable_NoContext};
10
11pub mod visit;
12
13#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Copy)]
16#[cfg_attr(feature = "nightly", derive(Encodable, Decodable, HashStable_NoContext))]
17pub enum Movability {
18 Static,
20 Movable,
22}
23
24#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Copy)]
25#[cfg_attr(feature = "nightly", derive(Encodable, Decodable, HashStable_NoContext))]
26pub enum Mutability {
27 Not,
29 Mut,
30}
31
32impl Mutability {
33 pub fn invert(self) -> Self {
34 match self {
35 Mutability::Mut => Mutability::Not,
36 Mutability::Not => Mutability::Mut,
37 }
38 }
39
40 pub fn prefix_str(self) -> &'static str {
42 match self {
43 Mutability::Mut => "mut ",
44 Mutability::Not => "",
45 }
46 }
47
48 pub fn ref_prefix_str(self) -> &'static str {
50 match self {
51 Mutability::Not => "&",
52 Mutability::Mut => "&mut ",
53 }
54 }
55
56 pub fn ptr_str(self) -> &'static str {
58 match self {
59 Mutability::Not => "const",
60 Mutability::Mut => "mut",
61 }
62 }
63
64 pub fn mutably_str(self) -> &'static str {
66 match self {
67 Mutability::Not => "",
68 Mutability::Mut => "mutably ",
69 }
70 }
71
72 pub fn is_mut(self) -> bool {
74 matches!(self, Self::Mut)
75 }
76
77 pub fn is_not(self) -> bool {
79 matches!(self, Self::Not)
80 }
81}
82
83#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Copy)]
84#[cfg_attr(feature = "nightly", derive(Encodable, Decodable, HashStable_NoContext))]
85pub enum Pinnedness {
86 Not,
87 Pinned,
88}