Skip to content

Commit 777af6e

Browse files
dingxiangfei2009compiler-errors
authored andcommitted
handle synthetic defs
1 parent 7e7613f commit 777af6e

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

compiler/rustc_mir_transform/src/lint_tail_expr_drop_order.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,12 @@ fn is_descendent_of_hir_id(
7777
}
7878

7979
pub(crate) fn run_lint<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId, body: &Body<'tcx>) {
80-
let hir_node = tcx.hir_node_by_def_id(def_id);
81-
let Some(body_id) = hir_node.body_id() else { return };
80+
if matches!(tcx.def_kind(def_id), rustc_hir::def::DefKind::SyntheticCoroutineBody) {
81+
// Synthetic coroutine has no HIR body and it is enough to just analyse the original body
82+
return;
83+
}
8284
let (tail_expr_hir_id, tail_expr_span) = {
83-
let expr = tcx.hir().body(body_id).value;
85+
let expr = tcx.hir().body_owned_by(def_id).value;
8486
match expr.kind {
8587
ExprKind::Block(block, _) => {
8688
if let Some(expr) = block.expr {

0 commit comments

Comments
 (0)