pub(crate) enum ConstantExpr {
TypeSystem {
expr: Box<str>,
},
Path {
path: Box<str>,
},
Anonymous {
body: BodyId,
},
Extern {
def_id: DefId,
},
Local {
def_id: DefId,
body: BodyId,
},
Infer,
}Variants§
TypeSystem
This is the wrapper around ty::Const for a non-local constant. Because it doesn’t have a
BodyId, we need to handle it on its own.
Note that ty::Const includes generic parameters, and may not always be uniquely identified
by a DefId. So this field must be different from Extern.
Path
A constant that is just a path (i.e., referring to a const param, free const, etc.).
Anonymous
A constant (expression) that’s not an item or associated item. These are usually found nested inside types (e.g., array lengths) or expressions (e.g., repeat counts), and also used to define explicit discriminant values for enum variants.
Fields
body: BodyIdExtern
A constant from a different crate.
Fields
def_id: DefIdLocal
const FOO: u32 = ...;
Infer
An inferred constant as in [10u8; _].
Implementations§
Source§impl ConstantExpr
impl ConstantExpr
pub(crate) fn rendered(&self, tcx: TyCtxt<'_>) -> String
pub(crate) fn evaluated_rendered(&self, tcx: TyCtxt<'_>) -> Option<String>
pub(crate) fn is_literal(&self, tcx: TyCtxt<'_>) -> bool
Trait Implementations§
Source§impl Clone for ConstantExpr
impl Clone for ConstantExpr
Source§impl Debug for ConstantExpr
impl Debug for ConstantExpr
impl Eq for ConstantExpr
Source§impl FromClean<ConstantExpr> for Constant
impl FromClean<ConstantExpr> for Constant
fn from_clean(constant: &ConstantExpr, renderer: &JsonRenderer<'_>) -> Self
Source§impl Hash for ConstantExpr
impl Hash for ConstantExpr
Source§impl PartialEq for ConstantExpr
impl PartialEq for ConstantExpr
impl StructuralPartialEq for ConstantExpr
Auto Trait Implementations§
impl DynSend for ConstantExpr
impl DynSync for ConstantExpr
impl Forget for ConstantExpr
impl Freeze for ConstantExpr
impl RefUnwindSafe for ConstantExpr
impl Send for ConstantExpr
impl Sync for ConstantExpr
impl Unpin for ConstantExpr
impl UnsafeUnpin for ConstantExpr
impl UnwindSafe for ConstantExpr
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> WithSubscriber for T
impl<T> WithSubscriber for T
§fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘwhere
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘwhere
S: Into<Dispatch>,
§fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ
fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ
Layout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 24 bytes
Size for each variant:
TypeSystem: 20 bytesPath: 20 bytesAnonymous: 8 bytesExtern: 8 bytesLocal: 16 bytesInfer: 0 bytes