diff options
| author | lcnr <rust@lcnr.de> | 2024-11-15 13:53:31 +0100 |
|---|---|---|
| committer | lcnr <rust@lcnr.de> | 2024-11-18 10:38:56 +0100 |
| commit | 9cba14b95bb07a5b31ed1aac2bf4eadd248232da (patch) | |
| tree | 60791c9abdfdc19133ab67c41a6d2872dfce745b /compiler/rustc_mir_dataflow/src/elaborate_drops.rs | |
| parent | bf6adec108e83c5ddfcbb443a9177203db5eb945 (diff) | |
| download | rust-9cba14b95bb07a5b31ed1aac2bf4eadd248232da.tar.gz rust-9cba14b95bb07a5b31ed1aac2bf4eadd248232da.zip | |
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`.
Diffstat (limited to 'compiler/rustc_mir_dataflow/src/elaborate_drops.rs')
| -rw-r--r-- | compiler/rustc_mir_dataflow/src/elaborate_drops.rs | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/compiler/rustc_mir_dataflow/src/elaborate_drops.rs b/compiler/rustc_mir_dataflow/src/elaborate_drops.rs index 9a1f000d39d..494b7d54d8a 100644 --- a/compiler/rustc_mir_dataflow/src/elaborate_drops.rs +++ b/compiler/rustc_mir_dataflow/src/elaborate_drops.rs @@ -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; } |
