-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Report monomorphization time errors in dead code, too #112879
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
a15060e
b41e06d
d429bc3
8ef09f9
8647afb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -703,10 +703,19 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { | |
self.stack_mut().push(frame); | ||
|
||
// Make sure all the constants required by this frame evaluate successfully (post-monomorphization check). | ||
for ct in &body.required_consts { | ||
let span = ct.span; | ||
let ct = self.subst_from_current_frame_and_normalize_erasing_regions(ct.literal)?; | ||
self.eval_mir_constant(&ct, Some(span), None)?; | ||
for (ct, span) in &body.required_items { | ||
if let mir::MonoItem::Const(ct) = ct { | ||
match ct.literal { | ||
mir::ConstantKind::Ty(c) => match c.kind() { | ||
ty::ConstKind::Unevaluated(_) => {} | ||
_ => continue, | ||
}, | ||
mir::ConstantKind::Unevaluated(_, _) => {} | ||
mir::ConstantKind::Val(_, _) => continue, | ||
} | ||
Comment on lines
+708
to
+715
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What's this about? The codegen backends don't do this. At least this needs a comment explaining why we are skipping some consts. |
||
let ct = self.subst_from_current_frame_and_normalize_erasing_regions(ct.literal)?; | ||
self.eval_mir_constant(&ct, Some(*span), None)?; | ||
} | ||
} | ||
|
||
// Most locals are initially dead. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -625,18 +625,7 @@ impl<'tcx> Inliner<'tcx> { | |
kind: TerminatorKind::Goto { target: integrator.map_block(START_BLOCK) }, | ||
}); | ||
|
||
// Copy only unevaluated constants from the callee_body into the caller_body. | ||
// Although we are only pushing `ConstKind::Unevaluated` consts to | ||
// `required_consts`, here we may not only have `ConstKind::Unevaluated` | ||
// because we are calling `subst_and_normalize_erasing_regions`. | ||
caller_body.required_consts.extend( | ||
callee_body.required_consts.iter().copied().filter(|&ct| match ct.literal { | ||
ConstantKind::Ty(_) => { | ||
bug!("should never encounter ty::UnevaluatedConst in `required_consts`") | ||
} | ||
ConstantKind::Val(..) | ConstantKind::Unevaluated(..) => true, | ||
}), | ||
); | ||
caller_body.required_items.extend(callee_body.required_items.iter().cloned()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wouldn't required_items already reference the callee one way or another, making this redundant? |
||
} | ||
kind => bug!("unexpected terminator kind {:?}", kind), | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have this logic a couple of times. Might be worth it to have a
required_consts
method onmir::Body
?