Expand description
A different sort of visitor for walking fn bodies. Unlike the
normal visitor, which just walks the entire body in one shot, the
ExprUseVisitor determines how expressions are being used.
In the compiler, this is only used for upvar inference and diagnostics, but there are many uses within clippy.
Re-exportsยง
use std::cell::Ref;๐use std::cell::RefCell;๐use std::ops::Deref;๐use hir::def::DefKind;๐use hir::pat_util::EnumerateAndAdjustIterator as _;๐use rustc_abi::FIRST_VARIANT;๐use rustc_abi::FieldIdx;๐use rustc_abi::VariantIdx;๐use rustc_ast::UnsafeBinderCastKind;๐use rustc_data_structures::fx::FxIndexMap;๐use rustc_hir::def::CtorOf;๐use rustc_hir::def::Res;๐use rustc_hir::def_id::LocalDefId;๐use rustc_hir as hir;๐use rustc_hir::HirId;๐use rustc_hir::PatExpr;๐use rustc_hir::PatExprKind;๐use rustc_hir::PatKind;๐use rustc_lint::LateContext;๐use rustc_middle::hir::place::ProjectionKind;๐use rustc_middle::mir::FakeReadCause;๐use rustc_middle::thir::DerefPatBorrowMode;๐use rustc_middle::ty::adjustment::DerefAdjustKind;๐use rustc_middle::ty;๐use rustc_middle::ty::BorrowKind;๐use rustc_middle::ty::Ty;๐use rustc_middle::ty::TyCtxt;๐use rustc_middle::ty::TypeFoldable;๐use rustc_middle::ty::TypeVisitableExt as _;๐use rustc_middle::ty::adjustment;๐use rustc_span::ErrorGuaranteed;๐use rustc_span::Span;๐use rustc_span::bug;๐use rustc_span::span_bug;๐use rustc_trait_selection::infer::InferCtxtExt;๐use tracing::debug;๐use tracing::instrument;๐use tracing::instrument;๐use tracing::trace;๐use crate::fn_ctxt::FnCtxt;๐
Structsยง
- Expr
Place ๐Delegate - Expr
UseVisitor - A visitor that reports how each expression is being used.
- Place
- A
Placerepresents how a value is located in memory. This does not always correspond to a syntactic place expression. For example, when processing a pattern, aPlacecan be used to refer to the sub-value currently being inspected. - Place
With HirId - A
PlaceWithHirIdrepresents how a value is located in memory. This does not always correspond to a syntactic place expression. For example, when processing a pattern, aPlacecan be used to refer to the sub-value currently being inspected. - Projection
Enumsยง
Traitsยง
- Delegate
- This trait defines the callbacks you can expect to receive when employing the ExprUseVisitor.
- Type
Information Ctxt - This trait makes
ExprUseVisitorusable with bothFnCtxtandLateContext, depending on where in the compiler it is used.
Functionsยง
- expr_
place ๐ - Categorizes
expras a place for diagnostic suggestions.