Struct rustc_typeck::check::regionck::RegionCtxt
[−]
[src]
pub struct RegionCtxt<'a, 'gcx: 'a + 'tcx, 'tcx: 'a> { pub fcx: &'a FnCtxt<'a, 'gcx, 'tcx>, // some fields omitted }
rustc_private
)Fields
fcx: &'a FnCtxt<'a, 'gcx, 'tcx>
rustc_private
)Methods
impl<'a, 'gcx, 'tcx> RegionCtxt<'a, 'gcx, 'tcx>
[src]
fn new(fcx: &'a FnCtxt<'a, 'gcx, 'tcx>,
RepeatingScope: RepeatingScope,
initial_body_id: NodeId,
Subject: Subject)
-> RegionCtxt<'a, 'gcx, 'tcx>
RepeatingScope: RepeatingScope,
initial_body_id: NodeId,
Subject: Subject)
-> RegionCtxt<'a, 'gcx, 'tcx>
rustc_private
)fn resolve_type(&self, unresolved_ty: Ty<'tcx>) -> Ty<'tcx>
rustc_private
)Try to resolve the type for the given node, returning t_err if an error results. Note that we never care about the details of the error, the same error will be detected and reported in the writeback phase.
Note one important point: we do not attempt to resolve region variables here. This is because regionck is essentially adding constraints to those region variables and so may yet influence how they are resolved.
Consider this silly example:
fn borrow(x: &i32) -> &i32 {x} fn foo(x: @i32) -> i32 { // block: B let b = borrow(x); // region: <R0> *b }
Here, the region of b
will be <R0>
. <R0>
is constrained to be some subregion of the
block B and some superregion of the call. If we forced it now, we'd choose the smaller
region (the call). But that would make the *b illegal. Since we don't resolve, the type
of b will be &<R0>.i32
and then *b
will require that <R0>
be bigger than the let and
the *b
expression, so we will effectively resolve <R0>
to be the block B.
fn resolve_expr_type_adjusted(&mut self, expr: &Expr) -> Ty<'tcx>
rustc_private
)Try to resolve the type for the given node.
impl<'a, 'gcx, 'tcx> RegionCtxt<'a, 'gcx, 'tcx>
[src]
fn mk_subregion_due_to_dereference(&mut self,
deref_span: Span,
minimum_lifetime: &'tcx Region,
maximum_lifetime: &'tcx Region)
deref_span: Span,
minimum_lifetime: &'tcx Region,
maximum_lifetime: &'tcx Region)
rustc_private
)fn type_must_outlive(&self,
origin: SubregionOrigin<'tcx>,
ty: Ty<'tcx>,
region: &'tcx Region)
origin: SubregionOrigin<'tcx>,
ty: Ty<'tcx>,
region: &'tcx Region)
rustc_private
)Ensures that type is well-formed in region
, which implies (among
other things) that all borrowed data reachable via ty
outlives
region
.
Methods from Deref<Target=FnCtxt<'a, 'gcx, 'tcx>>
fn autoderef(&'a self,
span: Span,
base_ty: Ty<'tcx>)
-> Autoderef<'a, 'gcx, 'tcx>
span: Span,
base_ty: Ty<'tcx>)
-> Autoderef<'a, 'gcx, 'tcx>
rustc_private
)fn try_overloaded_deref(&self,
span: Span,
base_expr: Option<&Expr>,
base_ty: Ty<'tcx>,
lvalue_pref: LvaluePreference)
-> Option<MethodCallee<'tcx>>
span: Span,
base_expr: Option<&Expr>,
base_ty: Ty<'tcx>,
lvalue_pref: LvaluePreference)
-> Option<MethodCallee<'tcx>>
rustc_private
)fn check_pat(&self, pat: &'gcx Pat, expected: Ty<'tcx>)
rustc_private
)fn check_pat_arg(&self, pat: &'gcx Pat, expected: Ty<'tcx>, is_arg: bool)
rustc_private
)The is_arg
argument indicates whether this pattern is the
outermost pattern in an argument (e.g., in fn foo(&x: &u32)
, it is true for the &x
pattern but not x
). This is
used to tailor error reporting.
fn check_dereferencable(&self,
span: Span,
expected: Ty<'tcx>,
inner: &Pat)
-> bool
span: Span,
expected: Ty<'tcx>,
inner: &Pat)
-> bool
rustc_private
)fn check_match(&self,
expr: &'gcx Expr,
discrim: &'gcx Expr,
arms: &'gcx [Arm],
expected: Expectation<'tcx>,
match_src: MatchSource)
-> Ty<'tcx>
expr: &'gcx Expr,
discrim: &'gcx Expr,
arms: &'gcx [Arm],
expected: Expectation<'tcx>,
match_src: MatchSource)
-> Ty<'tcx>
rustc_private
)fn resolve_type_vars_in_body(&self,
body: &'gcx Body)
-> &'gcx TypeckTables<'gcx>
body: &'gcx Body)
-> &'gcx TypeckTables<'gcx>
rustc_private
)fn regionck_expr(&self, body: &'gcx Body)
rustc_private
)fn regionck_item(&self, item_id: NodeId, span: Span, wf_tys: &[Ty<'tcx>])
rustc_private
)Region checking during the WF phase for items. wf_tys
are the
types from which we should derive implied bounds, if any.
fn regionck_fn(&self, fn_id: NodeId, body: &'gcx Body)
rustc_private
)fn try_coerce(&self,
expr: &Expr,
expr_ty: Ty<'tcx>,
target: Ty<'tcx>)
-> RelateResult<'tcx, Ty<'tcx>>
expr: &Expr,
expr_ty: Ty<'tcx>,
target: Ty<'tcx>)
-> RelateResult<'tcx, Ty<'tcx>>
rustc_private
)Attempt to coerce an expression to a type, and return the adjusted type of the expression, if successful. Adjustments are only recorded if the coercion succeeded. The expressions must not have any pre-existing adjustments.
fn try_find_coercion_lub<'b, E, I>(&self,
cause: &ObligationCause<'tcx>,
exprs: E,
prev_ty: Ty<'tcx>,
new: &'b Expr,
new_ty: Ty<'tcx>)
-> RelateResult<'tcx, Ty<'tcx>> where E: Fn() -> I, I: IntoIterator<Item=&'b Expr>
cause: &ObligationCause<'tcx>,
exprs: E,
prev_ty: Ty<'tcx>,
new: &'b Expr,
new_ty: Ty<'tcx>)
-> RelateResult<'tcx, Ty<'tcx>> where E: Fn() -> I, I: IntoIterator<Item=&'b Expr>
rustc_private
)Given some expressions, their known unified type and another expression, tries to unify the types, potentially inserting coercions on any of the provided expressions and returns their LUB (aka "common supertype").
fn demand_suptype(&self, sp: Span, expected: Ty<'tcx>, actual: Ty<'tcx>)
rustc_private
)fn demand_eqtype(&self, sp: Span, expected: Ty<'tcx>, actual: Ty<'tcx>)
rustc_private
)fn demand_eqtype_diag(&self,
sp: Span,
expected: Ty<'tcx>,
actual: Ty<'tcx>)
-> Option<DiagnosticBuilder<'tcx>>
sp: Span,
expected: Ty<'tcx>,
actual: Ty<'tcx>)
-> Option<DiagnosticBuilder<'tcx>>
rustc_private
)fn demand_eqtype_with_origin(&self,
cause: &ObligationCause<'tcx>,
expected: Ty<'tcx>,
actual: Ty<'tcx>)
-> Option<DiagnosticBuilder<'tcx>>
cause: &ObligationCause<'tcx>,
expected: Ty<'tcx>,
actual: Ty<'tcx>)
-> Option<DiagnosticBuilder<'tcx>>
rustc_private
)fn demand_coerce(&self, expr: &Expr, checked_ty: Ty<'tcx>, expected: Ty<'tcx>)
rustc_private
)fn confirm_method(&self,
span: Span,
self_expr: &'gcx Expr,
call_expr: &'gcx Expr,
unadjusted_self_ty: Ty<'tcx>,
pick: Pick<'tcx>,
supplied_method_types: Vec<Ty<'tcx>>)
-> MethodCallee<'tcx>
span: Span,
self_expr: &'gcx Expr,
call_expr: &'gcx Expr,
unadjusted_self_ty: Ty<'tcx>,
pick: Pick<'tcx>,
supplied_method_types: Vec<Ty<'tcx>>)
-> MethodCallee<'tcx>
rustc_private
)fn probe_for_return_type(&self,
span: Span,
mode: Mode,
return_type: Ty<'tcx>,
self_ty: Ty<'tcx>,
scope_expr_id: NodeId)
-> Vec<AssociatedItem>
span: Span,
mode: Mode,
return_type: Ty<'tcx>,
self_ty: Ty<'tcx>,
scope_expr_id: NodeId)
-> Vec<AssociatedItem>
rustc_private
)This is used to offer suggestions to users. It returns methods that could have been called which have the desired return type. Some effort is made to rule out methods that, if called, would result in an error (basically, the same criteria we would use to decide if a method is a plausible fit for ambiguity purposes).
fn probe_for_name(&self,
span: Span,
mode: Mode,
item_name: Name,
is_suggestion: IsSuggestion,
self_ty: Ty<'tcx>,
scope_expr_id: NodeId)
-> PickResult<'tcx>
span: Span,
mode: Mode,
item_name: Name,
is_suggestion: IsSuggestion,
self_ty: Ty<'tcx>,
scope_expr_id: NodeId)
-> PickResult<'tcx>
rustc_private
)fn report_method_error(&self,
span: Span,
rcvr_ty: Ty<'tcx>,
item_name: Name,
rcvr_expr: Option<&Expr>,
error: MethodError<'tcx>,
args: Option<&'gcx [Expr]>)
span: Span,
rcvr_ty: Ty<'tcx>,
item_name: Name,
rcvr_expr: Option<&Expr>,
error: MethodError<'tcx>,
args: Option<&'gcx [Expr]>)
rustc_private
)fn method_exists(&self,
span: Span,
method_name: Name,
self_ty: Ty<'tcx>,
call_expr_id: NodeId,
allow_private: bool)
-> bool
span: Span,
method_name: Name,
self_ty: Ty<'tcx>,
call_expr_id: NodeId,
allow_private: bool)
-> bool
rustc_private
)Determines whether the type self_ty
supports a method name method_name
or not.
fn lookup_method(&self,
span: Span,
method_name: Name,
self_ty: Ty<'tcx>,
supplied_method_types: Vec<Ty<'tcx>>,
call_expr: &'gcx Expr,
self_expr: &'gcx Expr)
-> Result<MethodCallee<'tcx>, MethodError<'tcx>>
span: Span,
method_name: Name,
self_ty: Ty<'tcx>,
supplied_method_types: Vec<Ty<'tcx>>,
call_expr: &'gcx Expr,
self_expr: &'gcx Expr)
-> Result<MethodCallee<'tcx>, MethodError<'tcx>>
rustc_private
)Performs method lookup. If lookup is successful, it will return the callee
and store an appropriate adjustment for the self-expr. In some cases it may
report an error (e.g., invoking the drop
method).
Arguments
Given a method call like foo.bar::<T1,...Tn>(...)
:
fcx
: the surroundingFnCtxt
(!)span
: the span for the method callmethod_name
: the name of the method being called (bar
)self_ty
: the (unadjusted) type of the self expression (foo
)supplied_method_types
: the explicit method type parameters, if any (T1..Tn
)self_expr
: the self expression (foo
)
fn lookup_method_in_trait(&self,
span: Span,
self_expr: Option<&Expr>,
m_name: Name,
trait_def_id: DefId,
self_ty: Ty<'tcx>,
opt_input_types: Option<Vec<Ty<'tcx>>>)
-> Option<MethodCallee<'tcx>>
span: Span,
self_expr: Option<&Expr>,
m_name: Name,
trait_def_id: DefId,
self_ty: Ty<'tcx>,
opt_input_types: Option<Vec<Ty<'tcx>>>)
-> Option<MethodCallee<'tcx>>
rustc_private
)fn lookup_method_in_trait_adjusted(&self,
span: Span,
self_expr: Option<&Expr>,
m_name: Name,
trait_def_id: DefId,
autoderefs: usize,
unsize: bool,
self_ty: Ty<'tcx>,
opt_input_types: Option<Vec<Ty<'tcx>>>)
-> Option<MethodCallee<'tcx>>
span: Span,
self_expr: Option<&Expr>,
m_name: Name,
trait_def_id: DefId,
autoderefs: usize,
unsize: bool,
self_ty: Ty<'tcx>,
opt_input_types: Option<Vec<Ty<'tcx>>>)
-> Option<MethodCallee<'tcx>>
rustc_private
)lookup_in_trait_adjusted
is used for overloaded operators.
It does a very narrow slice of what the normal probe/confirm path does.
In particular, it doesn't really do any probing: it simply constructs
an obligation for aparticular trait with the given self-type and checks
whether that trait is implemented.
FIXME(#18741) -- It seems likely that we can consolidate some of this code with the other method-lookup code. In particular, autoderef on index is basically identical to autoderef with normal probes, except that the test also looks for built-in indexing. Also, the second half of this method is basically the same as confirmation.
fn resolve_ufcs(&self,
span: Span,
method_name: Name,
self_ty: Ty<'tcx>,
expr_id: NodeId)
-> Result<Def, MethodError<'tcx>>
span: Span,
method_name: Name,
self_ty: Ty<'tcx>,
expr_id: NodeId)
-> Result<Def, MethodError<'tcx>>
rustc_private
)fn associated_item(&self,
def_id: DefId,
item_name: Name)
-> Option<AssociatedItem>
def_id: DefId,
item_name: Name)
-> Option<AssociatedItem>
rustc_private
)Find item with name item_name
defined in impl/trait def_id
and return it, or None
, if no such item was defined there.
fn closure_analyze(&self, body: &'gcx Body)
rustc_private
)fn check_expr_closure(&self,
expr: &Expr,
_capture: CaptureClause,
decl: &'gcx FnDecl,
body_id: BodyId,
expected: Expectation<'tcx>)
-> Ty<'tcx>
expr: &Expr,
_capture: CaptureClause,
decl: &'gcx FnDecl,
body_id: BodyId,
expected: Expectation<'tcx>)
-> Ty<'tcx>
rustc_private
)fn check_call(&self,
call_expr: &'gcx Expr,
callee_expr: &'gcx Expr,
arg_exprs: &'gcx [Expr],
expected: Expectation<'tcx>)
-> Ty<'tcx>
call_expr: &'gcx Expr,
callee_expr: &'gcx Expr,
arg_exprs: &'gcx [Expr],
expected: Expectation<'tcx>)
-> Ty<'tcx>
rustc_private
)fn check_binop_assign(&self,
expr: &'gcx Expr,
op: BinOp,
lhs_expr: &'gcx Expr,
rhs_expr: &'gcx Expr)
-> Ty<'tcx>
expr: &'gcx Expr,
op: BinOp,
lhs_expr: &'gcx Expr,
rhs_expr: &'gcx Expr)
-> Ty<'tcx>
rustc_private
)Check a a <op>= b
fn check_binop(&self,
expr: &'gcx Expr,
op: BinOp,
lhs_expr: &'gcx Expr,
rhs_expr: &'gcx Expr)
-> Ty<'tcx>
expr: &'gcx Expr,
op: BinOp,
lhs_expr: &'gcx Expr,
rhs_expr: &'gcx Expr)
-> Ty<'tcx>
rustc_private
)Check a potentially overloaded binary operator.
fn check_user_unop(&self,
op_str: &str,
mname: &str,
trait_did: Option<DefId>,
ex: &'gcx Expr,
operand_expr: &'gcx Expr,
operand_ty: Ty<'tcx>,
op: UnOp)
-> Ty<'tcx>
op_str: &str,
mname: &str,
trait_did: Option<DefId>,
ex: &'gcx Expr,
operand_expr: &'gcx Expr,
operand_ty: Ty<'tcx>,
op: UnOp)
-> Ty<'tcx>
rustc_private
)fn sess(&self) -> &Session
rustc_private
)fn err_count_since_creation(&self) -> usize
rustc_private
)fn cause(&self,
span: Span,
code: ObligationCauseCode<'tcx>)
-> ObligationCause<'tcx>
span: Span,
code: ObligationCauseCode<'tcx>)
-> ObligationCause<'tcx>
rustc_private
)fn misc(&self, span: Span) -> ObligationCause<'tcx>
rustc_private
)fn tag(&self) -> String
rustc_private
)fn local_ty(&self, span: Span, nid: NodeId) -> Ty<'tcx>
rustc_private
)fn write_ty(&self, node_id: NodeId, ty: Ty<'tcx>)
rustc_private
)fn write_substs(&self, node_id: NodeId, substs: ItemSubsts<'tcx>)
rustc_private
)fn write_autoderef_adjustment(&self,
node_id: NodeId,
derefs: usize,
adjusted_ty: Ty<'tcx>)
node_id: NodeId,
derefs: usize,
adjusted_ty: Ty<'tcx>)
rustc_private
)fn write_adjustment(&self, node_id: NodeId, adj: Adjustment<'tcx>)
rustc_private
)fn write_nil(&self, node_id: NodeId)
rustc_private
)fn write_error(&self, node_id: NodeId)
rustc_private
)fn require_type_meets(&self,
ty: Ty<'tcx>,
span: Span,
code: ObligationCauseCode<'tcx>,
def_id: DefId)
ty: Ty<'tcx>,
span: Span,
code: ObligationCauseCode<'tcx>,
def_id: DefId)
rustc_private
)fn require_type_is_sized(&self,
ty: Ty<'tcx>,
span: Span,
code: ObligationCauseCode<'tcx>)
ty: Ty<'tcx>,
span: Span,
code: ObligationCauseCode<'tcx>)
rustc_private
)fn register_bound(&self,
ty: Ty<'tcx>,
def_id: DefId,
cause: ObligationCause<'tcx>)
ty: Ty<'tcx>,
def_id: DefId,
cause: ObligationCause<'tcx>)
rustc_private
)fn register_predicate(&self, obligation: PredicateObligation<'tcx>)
rustc_private
)fn register_predicates(&self, obligations: Vec<PredicateObligation<'tcx>>)
rustc_private
)fn register_infer_ok_obligations<T>(&self, infer_ok: InferOk<'tcx, T>) -> T
rustc_private
)fn to_ty(&self, ast_t: &Ty) -> Ty<'tcx>
rustc_private
)fn node_ty(&self, id: NodeId) -> Ty<'tcx>
rustc_private
)fn opt_node_ty_substs<F>(&self, id: NodeId, f: F) where F: FnOnce(&ItemSubsts<'tcx>)
rustc_private
)fn register_region_obligation(&self,
ty: Ty<'tcx>,
region: &'tcx Region,
cause: ObligationCause<'tcx>)
ty: Ty<'tcx>,
region: &'tcx Region,
cause: ObligationCause<'tcx>)
rustc_private
)Registers an obligation for checking later, during regionck, that the type ty
must
outlive the region r
.
fn register_wf_obligation(&self,
ty: Ty<'tcx>,
span: Span,
code: ObligationCauseCode<'tcx>)
ty: Ty<'tcx>,
span: Span,
code: ObligationCauseCode<'tcx>)
rustc_private
)Registers an obligation for checking later, during regionck, that the type ty
must
outlive the region r
.
fn register_old_wf_obligation(&self,
ty: Ty<'tcx>,
span: Span,
code: ObligationCauseCode<'tcx>)
ty: Ty<'tcx>,
span: Span,
code: ObligationCauseCode<'tcx>)
rustc_private
)fn add_wf_bounds(&self, substs: &Substs<'tcx>, expr: &Expr)
rustc_private
)Registers obligations that all types appearing in substs
are well-formed.
fn add_obligations_for_parameters(&self,
cause: ObligationCause<'tcx>,
predicates: &InstantiatedPredicates<'tcx>)
cause: ObligationCause<'tcx>,
predicates: &InstantiatedPredicates<'tcx>)
rustc_private
)Given a fully substituted set of bounds (generic_bounds
), and the values with which each
type/region parameter was instantiated (substs
), creates and registers suitable
trait/region obligations.
For example, if there is a function:
fn foo<'a,T:'a>(...)
and a reference:
let f = foo;
Then we will create a fresh region variable '$0
and a fresh type variable $1
for 'a
and T
. This routine will add a region obligation $1:'$0
and register it locally.
fn field_ty(&self,
span: Span,
field: &'tcx FieldDef,
substs: &Substs<'tcx>)
-> Ty<'tcx>
span: Span,
field: &'tcx FieldDef,
substs: &Substs<'tcx>)
-> Ty<'tcx>
rustc_private
)fn check_expr_has_type(&self, expr: &'gcx Expr, expected: Ty<'tcx>) -> Ty<'tcx>
rustc_private
)fn impl_self_ty(&self, span: Span, did: DefId) -> TypeAndSubsts<'tcx>
rustc_private
)fn check_struct_path(&self,
qpath: &QPath,
node_id: NodeId)
-> Option<(&'tcx VariantDef, Ty<'tcx>)>
qpath: &QPath,
node_id: NodeId)
-> Option<(&'tcx VariantDef, Ty<'tcx>)>
rustc_private
)fn resolve_ty_and_def_ufcs<'b>(&self,
qpath: &'b QPath,
node_id: NodeId,
span: Span)
-> (Def, Option<Ty<'tcx>>, &'b [PathSegment])
qpath: &'b QPath,
node_id: NodeId,
span: Span)
-> (Def, Option<Ty<'tcx>>, &'b [PathSegment])
rustc_private
)fn check_decl_initializer(&self,
local: &'gcx Local,
init: &'gcx Expr)
-> Ty<'tcx>
local: &'gcx Local,
init: &'gcx Expr)
-> Ty<'tcx>
rustc_private
)fn check_decl_local(&self, local: &'gcx Local)
rustc_private
)fn check_stmt(&self, stmt: &'gcx Stmt)
rustc_private
)fn check_block_no_value(&self, blk: &'gcx Block)
rustc_private
)fn instantiate_value_path(&self,
segments: &[PathSegment],
opt_self_ty: Option<Ty<'tcx>>,
def: Def,
span: Span,
node_id: NodeId)
-> Ty<'tcx>
segments: &[PathSegment],
opt_self_ty: Option<Ty<'tcx>>,
def: Def,
span: Span,
node_id: NodeId)
-> Ty<'tcx>
rustc_private
)fn structurally_resolved_type(&self, sp: Span, ty: Ty<'tcx>) -> Ty<'tcx>
rustc_private
)Trait Implementations
impl<'a, 'gcx, 'tcx> Deref for RegionCtxt<'a, 'gcx, 'tcx>
[src]
type Target = FnCtxt<'a, 'gcx, 'tcx>
The resulting type after dereferencing
fn deref(&self) -> &Self::Target
The method called to dereference a value
impl<'a, 'gcx, 'tcx> Visitor<'gcx> for RegionCtxt<'a, 'gcx, 'tcx>
[src]
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'gcx>
rustc_private
)The default versions of the visit_nested_XXX
routines invoke this method to get a map to use. By selecting an enum variant, you control which kinds of nested HIR are visited; see NestedVisitorMap
for details. By "nested HIR", we are referring to bits of HIR that are not directly embedded within one another but rather indirectly, through a table in the crate. This is done to control dependencies during incremental compilation: the non-inline bits of HIR can be tracked and hashed separately. Read more
fn visit_fn(&mut self,
_fk: FnKind<'gcx>,
_: &'gcx FnDecl,
b: BodyId,
span: Span,
id: NodeId)
_fk: FnKind<'gcx>,
_: &'gcx FnDecl,
b: BodyId,
span: Span,
id: NodeId)
rustc_private
)fn visit_arm(&mut self, arm: &'gcx Arm)
rustc_private
)fn visit_local(&mut self, l: &'gcx Local)
rustc_private
)fn visit_expr(&mut self, expr: &'gcx Expr)
rustc_private
)fn visit_nested_item(&mut self, id: ItemId)
rustc_private
)Invoked when a nested item is encountered. By default does nothing unless you override nested_visit_map
to return Some(_)
, in which case it will walk the item. You probably don't want to override this method -- instead, override nested_visit_map
or use the "shallow" or "deep" visit patterns described on itemlikevisit::ItemLikeVisitor
. The only reason to override this method is if you want a nested pattern but cannot supply a Map
; see nested_visit_map
for advice. Read more
fn visit_nested_trait_item(&mut self, id: TraitItemId)
rustc_private
)Like visit_nested_item()
, but for trait items. See visit_nested_item()
for advice on when to override this method. Read more
fn visit_nested_impl_item(&mut self, id: ImplItemId)
rustc_private
)Like visit_nested_item()
, but for impl items. See visit_nested_item()
for advice on when to override this method. Read more
fn visit_nested_body(&mut self, id: BodyId)
rustc_private
)Invoked to visit the body of a function, method or closure. Like visit_nested_item, does nothing by default unless you override nested_visit_map
to return Some(_)
, in which case it will walk the body. Read more
fn visit_item(&mut self, i: &'v Item)
rustc_private
)Visit the top-level item and (optionally) nested items / impl items. See visit_nested_item
for details. Read more
fn visit_body(&mut self, b: &'v Body)
rustc_private
)fn as_deep_visitor(&'s mut self) -> DeepVisitor<'s, Self>
rustc_private
)When invoking visit_all_item_likes()
, you need to supply an item-like visitor. This method converts a "intra-visit" visitor into an item-like visitor that walks the entire tree. If you use this, you probably don't want to process the contents of nested item-like things, since the outer loop will visit them as well. Read more
fn visit_id(&mut self, _node_id: NodeId)
rustc_private
)fn visit_def_mention(&mut self, _def: Def)
rustc_private
)fn visit_name(&mut self, _span: Span, _name: Symbol)
rustc_private
)fn visit_mod(&mut self, m: &'v Mod, _s: Span, n: NodeId)
rustc_private
)fn visit_foreign_item(&mut self, i: &'v ForeignItem)
rustc_private
)fn visit_block(&mut self, b: &'v Block)
rustc_private
)fn visit_stmt(&mut self, s: &'v Spanned<Stmt_>)
rustc_private
)fn visit_pat(&mut self, p: &'v Pat)
rustc_private
)fn visit_decl(&mut self, d: &'v Spanned<Decl_>)
rustc_private
)fn visit_ty(&mut self, t: &'v Ty)
rustc_private
)fn visit_generics(&mut self, g: &'v Generics)
rustc_private
)fn visit_where_predicate(&mut self, predicate: &'v WherePredicate)
rustc_private
)fn visit_fn_decl(&mut self, fd: &'v FnDecl)
rustc_private
)fn visit_trait_item(&mut self, ti: &'v TraitItem)
rustc_private
)fn visit_trait_item_ref(&mut self, ii: &'v TraitItemRef)
rustc_private
)fn visit_impl_item(&mut self, ii: &'v ImplItem)
rustc_private
)fn visit_impl_item_ref(&mut self, ii: &'v ImplItemRef)
rustc_private
)fn visit_trait_ref(&mut self, t: &'v TraitRef)
rustc_private
)fn visit_ty_param_bound(&mut self, bounds: &'v TyParamBound)
rustc_private
)fn visit_poly_trait_ref(&mut self, t: &'v PolyTraitRef, m: TraitBoundModifier)
rustc_private
)fn visit_variant_data(&mut self,
s: &'v VariantData,
Symbol,
&'v Generics,
_parent_id: NodeId,
Span)
s: &'v VariantData,
Symbol,
&'v Generics,
_parent_id: NodeId,
Span)
rustc_private
)fn visit_struct_field(&mut self, s: &'v StructField)
rustc_private
)fn visit_enum_def(&mut self,
enum_definition: &'v EnumDef,
generics: &'v Generics,
item_id: NodeId,
Span)
enum_definition: &'v EnumDef,
generics: &'v Generics,
item_id: NodeId,
Span)
rustc_private
)fn visit_variant(&mut self,
v: &'v Spanned<Variant_>,
g: &'v Generics,
item_id: NodeId)
v: &'v Spanned<Variant_>,
g: &'v Generics,
item_id: NodeId)
rustc_private
)fn visit_lifetime(&mut self, lifetime: &'v Lifetime)
rustc_private
)fn visit_lifetime_def(&mut self, lifetime: &'v LifetimeDef)
rustc_private
)fn visit_qpath(&mut self, qpath: &'v QPath, id: NodeId, span: Span)
rustc_private
)fn visit_path(&mut self, path: &'v Path, _id: NodeId)
rustc_private
)fn visit_path_segment(&mut self, path_span: Span, path_segment: &'v PathSegment)
rustc_private
)fn visit_path_parameters(&mut self,
path_span: Span,
path_parameters: &'v PathParameters)
path_span: Span,
path_parameters: &'v PathParameters)
rustc_private
)fn visit_assoc_type_binding(&mut self, type_binding: &'v TypeBinding)
rustc_private
)fn visit_attribute(&mut self, _attr: &'v Attribute)
rustc_private
)fn visit_macro_def(&mut self, macro_def: &'v MacroDef)
rustc_private
)fn visit_vis(&mut self, vis: &'v Visibility)
rustc_private
)fn visit_associated_item_kind(&mut self, kind: &'v AssociatedItemKind)
rustc_private
)fn visit_defaultness(&mut self, defaultness: &'v Defaultness)
rustc_private
)