Skip to content

Commit 74496bc

Browse files
committed
review comments
1 parent 2484e18 commit 74496bc

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

compiler/rustc_borrowck/src/diagnostics/move_errors.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -571,9 +571,11 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
571571
fn get_closure_bound_clause_span(&self, def_id: DefId) -> Span {
572572
let tcx = self.infcx.tcx;
573573
let typeck_result = tcx.typeck(self.mir_def_id());
574-
let Some(closure_def_id) = def_id.as_local() else { return DUMMY_SP };
575-
let hir::Node::Expr(expr) = tcx.hir_node_by_def_id(closure_def_id) else { return DUMMY_SP };
576-
let hir::Node::Expr(parent) = tcx.parent_hir_node(expr.hir_id) else { return DUMMY_SP };
574+
// Check whether the closure is an argument to a call, if so,
575+
// get the instantiated where-bounds of that call.
576+
let closure_hir_id = tcx.local_def_id_to_hir_id(def_id.expect_local());
577+
let hir::Node::Expr(parent) = tcx.parent_hir_node(closure_hir_id) else { return DUMMY_SP };
578+
577579
let predicates = match parent.kind {
578580
hir::ExprKind::Call(callee, _) => {
579581
let Some(ty) = typeck_result.node_type_opt(callee.hir_id) else { return DUMMY_SP };
@@ -589,9 +591,9 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
589591
}
590592
_ => return DUMMY_SP,
591593
};
594+
595+
// Check whether one of the where-bounds requires the closure to impl `Fn[Mut]`.
592596
for (pred, span) in predicates.predicates.iter().zip(predicates.spans.iter()) {
593-
tracing::info!(?pred);
594-
tracing::info!(?span);
595597
if let Some(clause) = pred.as_trait_clause()
596598
&& let ty::Closure(clause_closure_def_id, _) = clause.self_ty().skip_binder().kind()
597599
&& *clause_closure_def_id == def_id

0 commit comments

Comments
 (0)