Struct clippy_utils::consts::ConstEvalLateContext
source · pub struct ConstEvalLateContext<'a, 'tcx> {
lcx: &'a LateContext<'tcx>,
typeck_results: &'a TypeckResults<'tcx>,
param_env: ParamEnv<'tcx>,
needed_resolution: bool,
substs: SubstsRef<'tcx>,
}
Fields§
§lcx: &'a LateContext<'tcx>
§typeck_results: &'a TypeckResults<'tcx>
§param_env: ParamEnv<'tcx>
§needed_resolution: bool
§substs: SubstsRef<'tcx>
Implementations§
source§impl<'a, 'tcx> ConstEvalLateContext<'a, 'tcx>
impl<'a, 'tcx> ConstEvalLateContext<'a, 'tcx>
sourcepub fn expr(&mut self, e: &Expr<'_>) -> Option<Constant>
pub fn expr(&mut self, e: &Expr<'_>) -> Option<Constant>
Simple constant folding: Insert an expression, get a constant or none.
fn constant_not(&self, o: &Constant, ty: Ty<'_>) -> Option<Constant>
fn constant_negate(&self, o: &Constant, ty: Ty<'_>) -> Option<Constant>
sourcefn multi(&mut self, vec: &[Expr<'_>]) -> Option<Vec<Constant>>
fn multi(&mut self, vec: &[Expr<'_>]) -> Option<Vec<Constant>>
Create Some(Vec![..])
of all constants, unless there is any
non-constant part.
sourcefn fetch_path(
&mut self,
qpath: &QPath<'_>,
id: HirId,
ty: Ty<'tcx>
) -> Option<Constant>
fn fetch_path(
&mut self,
qpath: &QPath<'_>,
id: HirId,
ty: Ty<'tcx>
) -> Option<Constant>
Lookup a possibly constant expression from an ExprKind::Path
.
fn index(&mut self, lhs: &Expr<'_>, index: &Expr<'_>) -> Option<Constant>
sourcefn block(&mut self, block: &Block<'_>) -> Option<Constant>
fn block(&mut self, block: &Block<'_>) -> Option<Constant>
A block can only yield a constant if it only has one constant expression.
fn ifthenelse(
&mut self,
cond: &Expr<'_>,
then: &Expr<'_>,
otherwise: Option<&Expr<'_>>
) -> Option<Constant>
fn binop(
&mut self,
op: BinOp,
left: &Expr<'_>,
right: &Expr<'_>
) -> Option<Constant>
Auto Trait Implementations§
impl<'a, 'tcx> !RefUnwindSafe for ConstEvalLateContext<'a, 'tcx>
impl<'a, 'tcx> !Send for ConstEvalLateContext<'a, 'tcx>
impl<'a, 'tcx> !Sync for ConstEvalLateContext<'a, 'tcx>
impl<'a, 'tcx> Unpin for ConstEvalLateContext<'a, 'tcx>where
'tcx: 'a,
impl<'a, 'tcx> !UnwindSafe for ConstEvalLateContext<'a, 'tcx>
Blanket Implementations§
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: 40 bytes