diff options
| author | Esteban Küber <esteban@kuber.com.ar> | 2025-08-10 19:26:03 +0000 |
|---|---|---|
| committer | Esteban Küber <esteban@kuber.com.ar> | 2025-08-10 19:26:03 +0000 |
| commit | 74496bc4d9f64ea01ae3714b9680cc22c1535cb2 (patch) | |
| tree | c55e8802d8b1ebc8e192b716fb0919a749f03682 /compiler/rustc_borrowck/src | |
| parent | 2484e189bfbc3decc2aa8480ce249dd84f6d2f9c (diff) | |
| download | rust-74496bc4d9f64ea01ae3714b9680cc22c1535cb2.tar.gz rust-74496bc4d9f64ea01ae3714b9680cc22c1535cb2.zip | |
review comments
Diffstat (limited to 'compiler/rustc_borrowck/src')
| -rw-r--r-- | compiler/rustc_borrowck/src/diagnostics/move_errors.rs | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/compiler/rustc_borrowck/src/diagnostics/move_errors.rs b/compiler/rustc_borrowck/src/diagnostics/move_errors.rs index 5adbaca7e11..af71db69483 100644 --- a/compiler/rustc_borrowck/src/diagnostics/move_errors.rs +++ b/compiler/rustc_borrowck/src/diagnostics/move_errors.rs @@ -571,9 +571,11 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> { fn get_closure_bound_clause_span(&self, def_id: DefId) -> Span { let tcx = self.infcx.tcx; let typeck_result = tcx.typeck(self.mir_def_id()); - let Some(closure_def_id) = def_id.as_local() else { return DUMMY_SP }; - let hir::Node::Expr(expr) = tcx.hir_node_by_def_id(closure_def_id) else { return DUMMY_SP }; - let hir::Node::Expr(parent) = tcx.parent_hir_node(expr.hir_id) else { return DUMMY_SP }; + // Check whether the closure is an argument to a call, if so, + // get the instantiated where-bounds of that call. + let closure_hir_id = tcx.local_def_id_to_hir_id(def_id.expect_local()); + let hir::Node::Expr(parent) = tcx.parent_hir_node(closure_hir_id) else { return DUMMY_SP }; + let predicates = match parent.kind { hir::ExprKind::Call(callee, _) => { 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> { } _ => return DUMMY_SP, }; + + // Check whether one of the where-bounds requires the closure to impl `Fn[Mut]`. for (pred, span) in predicates.predicates.iter().zip(predicates.spans.iter()) { - tracing::info!(?pred); - tracing::info!(?span); if let Some(clause) = pred.as_trait_clause() && let ty::Closure(clause_closure_def_id, _) = clause.self_ty().skip_binder().kind() && *clause_closure_def_id == def_id |
