use TypingEnv when no infcx is available
the behavior of the type system not only depends on the current assumptions, but also the currentnphase of the compiler. This is mostly necessary as we need to decide whether and how to reveal opaque types. We track this via the `TypingMode`.
This commit is contained in:
@@ -6,7 +6,6 @@ use rustc_index::Idx;
|
||||
use rustc_middle::mir::patch::MirPatch;
|
||||
use rustc_middle::mir::*;
|
||||
use rustc_middle::span_bug;
|
||||
use rustc_middle::traits::Reveal;
|
||||
use rustc_middle::ty::util::IntTypeExt;
|
||||
use rustc_middle::ty::{self, GenericArgsRef, Ty, TyCtxt};
|
||||
use rustc_span::DUMMY_SP;
|
||||
@@ -111,7 +110,7 @@ pub trait DropElaborator<'a, 'tcx>: fmt::Debug {
|
||||
fn patch(&mut self) -> &mut MirPatch<'tcx>;
|
||||
fn body(&self) -> &'a Body<'tcx>;
|
||||
fn tcx(&self) -> TyCtxt<'tcx>;
|
||||
fn param_env(&self) -> ty::ParamEnv<'tcx>;
|
||||
fn typing_env(&self) -> ty::TypingEnv<'tcx>;
|
||||
|
||||
// Drop logic
|
||||
|
||||
@@ -273,9 +272,9 @@ where
|
||||
let subpath = self.elaborator.field_subpath(variant_path, field);
|
||||
let tcx = self.tcx();
|
||||
|
||||
assert_eq!(self.elaborator.param_env().reveal(), Reveal::All);
|
||||
assert_eq!(self.elaborator.typing_env().typing_mode, ty::TypingMode::PostAnalysis);
|
||||
let field_ty =
|
||||
tcx.normalize_erasing_regions(self.elaborator.param_env(), f.ty(tcx, args));
|
||||
tcx.normalize_erasing_regions(self.elaborator.typing_env(), f.ty(tcx, args));
|
||||
|
||||
(tcx.mk_place_field(base_place, field, field_ty), subpath)
|
||||
})
|
||||
@@ -372,7 +371,7 @@ where
|
||||
|
||||
let mut fields = fields;
|
||||
fields.retain(|&(place, _)| {
|
||||
self.place_ty(place).needs_drop(self.tcx(), self.elaborator.param_env())
|
||||
self.place_ty(place).needs_drop(self.tcx(), self.elaborator.typing_env())
|
||||
});
|
||||
|
||||
debug!("drop_ladder - fields needing drop: {:?}", fields);
|
||||
@@ -544,11 +543,11 @@ where
|
||||
} else {
|
||||
have_otherwise = true;
|
||||
|
||||
let param_env = self.elaborator.param_env();
|
||||
let typing_env = self.elaborator.typing_env();
|
||||
let have_field_with_drop_glue = variant
|
||||
.fields
|
||||
.iter()
|
||||
.any(|field| field.ty(tcx, args).needs_drop(tcx, param_env));
|
||||
.any(|field| field.ty(tcx, args).needs_drop(tcx, typing_env));
|
||||
if have_field_with_drop_glue {
|
||||
have_otherwise_with_drop_glue = true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user