};
let def_id = def_id::DefId::local(body.hir_id.owner);
let region_scope_tree = &cx.tcx.region_scope_tree(def_id);
- ExprUseVisitor::new(&mut delegate, cx.tcx, cx.param_env, region_scope_tree, cx.tables, None).walk_expr(body);
+ ExprUseVisitor::new(
+ &mut delegate,
+ cx.tcx,
+ def_id,
+ cx.param_env,
+ region_scope_tree,
+ cx.tables,
+ None,
+ )
+ .walk_expr(body);
delegate.mutation_span()
}
}
let res = self.cx.tables.qpath_res(seqpath, seqexpr.hir_id);
match res {
- Res::Local(hir_id) | Res::Upvar(hir_id, ..) => {
+ Res::Local(hir_id) => {
let parent_id = self.cx.tcx.hir().get_parent_item(expr.hir_id);
let parent_def_id = self.cx.tcx.hir().local_def_id_from_hir_id(parent_id);
let extent = self.cx.tcx.region_scope_tree(parent_def_id).var_scope(hir_id.local_id);
if let QPath::Resolved(None, ref path) = *qpath;
if path.segments.len() == 1;
then {
- match self.cx.tables.qpath_res(qpath, expr.hir_id) {
- Res::Upvar(local_id, ..) => {
- if local_id == self.var {
- // we are not indexing anything, record that
- self.nonindex = true;
- }
- }
- Res::Local(local_id) =>
- {
-
- if local_id == self.var {
- self.nonindex = true;
- } else {
- // not the correct variable, but still a variable
- self.referenced.insert(path.segments[0].ident.name);
- }
+ if let Res::Local(local_id) = self.cx.tables.qpath_res(qpath, expr.hir_id) {
+ if local_id == self.var {
+ self.nonindex = true;
+ } else {
+ // not the correct variable, but still a variable
+ self.referenced.insert(path.segments[0].ident.name);
}
- _ => {}
}
}
}
let res = self.cx.tables.qpath_res(qpath, ex.hir_id);
then {
match res {
- Res::Local(node_id) | Res::Upvar(node_id, ..) => {
+ Res::Local(node_id) => {
self.ids.insert(node_id);
},
Res::Def(DefKind::Static, def_id) => {
/// Tests whether `res` is a variable defined outside a macro.
fn non_macro_local(cx: &LateContext<'_, '_>, res: def::Res) -> bool {
- match res {
- def::Res::Local(id) | def::Res::Upvar(id, ..) => !in_macro_or_desugar(cx.tcx.hir().span_by_hir_id(id)),
- _ => false,
+ if let def::Res::Local(id) = res {
+ !in_macro_or_desugar(cx.tcx.hir().span_by_hir_id(id))
+ } else {
+ false
}
}
};
let def_id = def_id::DefId::local(expr.hir_id.owner);
let region_scope_tree = &cx.tcx.region_scope_tree(def_id);
- ExprUseVisitor::new(&mut delegate, cx.tcx, cx.param_env, region_scope_tree, cx.tables, None).walk_expr(expr);
+ ExprUseVisitor::new(
+ &mut delegate,
+ cx.tcx,
+ def_id,
+ cx.param_env,
+ region_scope_tree,
+ cx.tables,
+ None,
+ )
+ .walk_expr(expr);
if delegate.skip {
return None;
expr: &'tcx Expr,
cx: &'a LateContext<'a, 'tcx>,
) -> bool {
- let id = match variable.res {
- Res::Local(id) | Res::Upvar(id, ..) => id,
- _ => return true,
- };
- mutated_variables(expr, cx).map_or(true, |mutated| mutated.contains(&id))
+ if let Res::Local(id) = variable.res {
+ mutated_variables(expr, cx).map_or(true, |mutated| mutated.contains(&id))
+ } else {
+ return true;
+ }
}
struct MutVarsDelegate {