Don't skip inner const when looking for body for suggestion · rust-lang/rust@c58b7c9

Original file line numberDiff line numberDiff line change

@@ -1871,11 +1871,8 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {

18711871

// If this is due to a block, then maybe we forgot a `return`/`break`.

18721872

if due_to_block

18731873

&& let Some(expr) = expression

1874-

&& let Some((parent_fn_decl, parent_id)) = fcx

1875-

.tcx

1876-

.hir()

1877-

.parent_iter(block_or_return_id)

1878-

.find_map(|(_, node)| Some((node.fn_decl()?, node.associated_body()?.0)))

1874+

&& let Some(parent_fn_decl) =

1875+

fcx.tcx.hir().fn_decl_by_hir_id(fcx.tcx.local_def_id_to_hir_id(fcx.body_id))

18791876

{

18801877

fcx.suggest_missing_break_or_return_expr(

18811878

&mut err,

@@ -1884,7 +1881,7 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {

18841881

expected,

18851882

found,

18861883

block_or_return_id,

1887-

parent_id,

1884+

fcx.body_id,

18881885

);

18891886

}

18901887