diff options
| author | Michael Goulet <michael@errs.io> | 2024-05-23 19:48:54 -0400 |
|---|---|---|
| committer | Michael Goulet <michael@errs.io> | 2024-05-23 19:49:48 -0400 |
| commit | c58b7c9c81cf150bf307ca13375f12fb1c8f6420 (patch) | |
| tree | 315573d92e87856eb88f4fabe84a0f588cf8b3c6 /compiler | |
| parent | 5baee04b6349d176440cb1fcd5424a89f67b9f7b (diff) | |
| download | rust-c58b7c9c81cf150bf307ca13375f12fb1c8f6420.tar.gz rust-c58b7c9c81cf150bf307ca13375f12fb1c8f6420.zip | |
Don't skip inner const when looking for body for suggestion
Diffstat (limited to 'compiler')
| -rw-r--r-- | compiler/rustc_hir_typeck/src/coercion.rs | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/compiler/rustc_hir_typeck/src/coercion.rs b/compiler/rustc_hir_typeck/src/coercion.rs index 11a1c65b749..ebdc558282a 100644 --- a/compiler/rustc_hir_typeck/src/coercion.rs +++ b/compiler/rustc_hir_typeck/src/coercion.rs @@ -1871,11 +1871,8 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> { // If this is due to a block, then maybe we forgot a `return`/`break`. if due_to_block && let Some(expr) = expression - && let Some((parent_fn_decl, parent_id)) = fcx - .tcx - .hir() - .parent_iter(block_or_return_id) - .find_map(|(_, node)| Some((node.fn_decl()?, node.associated_body()?.0))) + && let Some(parent_fn_decl) = + fcx.tcx.hir().fn_decl_by_hir_id(fcx.tcx.local_def_id_to_hir_id(fcx.body_id)) { fcx.suggest_missing_break_or_return_expr( &mut err, @@ -1884,7 +1881,7 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> { expected, found, block_or_return_id, - parent_id, + fcx.body_id, ); } |
