Expand description
Utilities for evaluating whether eagerly evaluated expressions can be made lazy and vice versa.
Things to consider:
- does the expression have side-effects?
- is the expression computationally expensive?
See lints:
- unnecessary-lazy-evaluations
- or-fun-call
- option-if-let-else
Re-exportsยง
use crate::consts::ConstEvalCtxt;๐use crate::consts::FullInt;๐use crate::sym;๐use crate::ty::all_clauses_of;๐use crate::visitors::is_const_evaluatable;๐use rustc_hir::def::DefKind;๐use rustc_hir::def::Res;๐use rustc_hir::def_id::DefId;๐use rustc_hir::intravisit::Visitor;๐use rustc_hir::intravisit::walk_expr;๐use rustc_hir::BinOpKind;๐use rustc_hir::Block;๐use rustc_hir::Expr;๐use rustc_hir::ExprKind;๐use rustc_hir::QPath;๐use rustc_hir::UnOp;๐use rustc_lint::LateContext;๐use rustc_middle::ty::adjustment::Adjust;๐use rustc_middle::ty::adjustment::DerefAdjustKind;๐use rustc_middle::ty;๐use rustc_middle::ty::TyCtxt;๐use rustc_span::Symbol;๐use std::cmp;๐use std::ops;๐
Enumsยง
- Eagerness
Suggestion ๐
Functionsยง
- expr_
eagerness ๐ - fn_
eagerness ๐ - Determine the eagerness of the given function call.
- res_
has_ ๐significant_ drop - switch_
to_ eager_ eval - Whether the given expression should be changed to evaluate eagerly
- switch_
to_ lazy_ eval - Whether the given expression should be changed to evaluate lazily