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

Original file line number Diff line number Diff line change
@@ -1871,11 +1871,8 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
1871 1871 // If this is due to a block, then maybe we forgot a `return`/`break`.
1872 1872 if due_to_block
1873 1873 && 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)
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))
1879 1876 {
1880 1877 fcx.suggest_missing_break_or_return_expr(
1881 1878 &mut err,
@@ -1884,7 +1881,7 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
1884 1881 expected,
1885 1882 found,
1886 1883 block_or_return_id,
1887 -parent_id,
1884 +fcx.body_id,
1888 1885 );
1889 1886 }
1890 1887