1
Fork 0

Auto merge of #82159 - BoxyUwU:uwu, r=varkor

Use correct param_env in conservative_is_privately_uninhabited

cc `@lcnr`
r? `@varkor` since this is your FIXME that was removed ^^
This commit is contained in:
bors 2021-02-24 21:54:52 +00:00
commit 1fdadbf13a
9 changed files with 131 additions and 57 deletions

View file

@ -1734,7 +1734,10 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
}
}
None => {
if !sig.output().conservative_is_privately_uninhabited(self.tcx()) {
if !self
.tcx()
.conservative_is_privately_uninhabited(self.param_env.and(sig.output()))
{
span_mirbug!(self, term, "call to converging function {:?} w/o dest", sig);
}
}

View file

@ -1007,9 +1007,9 @@ fn insert_panic_block<'tcx>(
assert_block
}
fn can_return<'tcx>(tcx: TyCtxt<'tcx>, body: &Body<'tcx>) -> bool {
fn can_return<'tcx>(tcx: TyCtxt<'tcx>, body: &Body<'tcx>, param_env: ty::ParamEnv<'tcx>) -> bool {
// Returning from a function with an uninhabited return type is undefined behavior.
if body.return_ty().conservative_is_privately_uninhabited(tcx) {
if tcx.conservative_is_privately_uninhabited(param_env.and(body.return_ty())) {
return false;
}
@ -1320,7 +1320,7 @@ impl<'tcx> MirPass<'tcx> for StateTransform {
// `storage_liveness` tells us which locals have live storage at suspension points
let (remap, layout, storage_liveness) = compute_layout(liveness_info, body);
let can_return = can_return(tcx, body);
let can_return = can_return(tcx, body, tcx.param_env(body.source.def_id()));
// Run the transformation which converts Places from Local to generator struct
// accesses for locals in `remap`.