Deduplicate associated_body
and body_id
They match on almost the same patterns, which is fishy. Also turn `associated_body` into a method and do some cleanups nearby the call sites
This commit is contained in:
parent
1e30c2915b
commit
0dc876991c
@ -13,7 +13,6 @@ use rustc_hir::{
|
|||||||
use rustc_hir_typeck::expr_use_visitor as euv;
|
use rustc_hir_typeck::expr_use_visitor as euv;
|
||||||
use rustc_infer::infer::{InferCtxt, TyCtxtInferExt};
|
use rustc_infer::infer::{InferCtxt, TyCtxtInferExt};
|
||||||
use rustc_lint::{LateContext, LateLintPass};
|
use rustc_lint::{LateContext, LateLintPass};
|
||||||
use rustc_middle::hir::map::associated_body;
|
|
||||||
use rustc_middle::mir::FakeReadCause;
|
use rustc_middle::mir::FakeReadCause;
|
||||||
use rustc_middle::ty::{self, Ty, TyCtxt, UpvarId, UpvarPath};
|
use rustc_middle::ty::{self, Ty, TyCtxt, UpvarId, UpvarPath};
|
||||||
use rustc_session::impl_lint_pass;
|
use rustc_session::impl_lint_pass;
|
||||||
@ -112,7 +111,10 @@ fn check_closures<'tcx>(
|
|||||||
}
|
}
|
||||||
ctx.prev_bind = None;
|
ctx.prev_bind = None;
|
||||||
ctx.prev_move_to_closure.clear();
|
ctx.prev_move_to_closure.clear();
|
||||||
if let Some(body) = associated_body(cx.tcx.hir_node_by_def_id(closure))
|
if let Some(body) = cx
|
||||||
|
.tcx
|
||||||
|
.hir_node_by_def_id(closure)
|
||||||
|
.associated_body()
|
||||||
.map(|(_, body_id)| hir.body(body_id))
|
.map(|(_, body_id)| hir.body(body_id))
|
||||||
{
|
{
|
||||||
euv::ExprUseVisitor::new(ctx, infcx, closure, cx.param_env, cx.typeck_results()).consume_body(body);
|
euv::ExprUseVisitor::new(ctx, infcx, closure, cx.param_env, cx.typeck_results()).consume_body(body);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user