]> git.lizzy.rs Git - rust.git/blobdiff - compiler/rustc_mir_transform/src/remove_unneeded_drops.rs
Add rationale for `RemoveUnneededDrops`
[rust.git] / compiler / rustc_mir_transform / src / remove_unneeded_drops.rs
index 5c9d04a08bfec775e45efd7df67f67359536f84e..39f78e9555e2f6a0d660624dd0094901c0c99d28 100644 (file)
@@ -1,4 +1,8 @@
-//! This pass replaces a drop of a type that does not need dropping, with a goto
+//! This pass replaces a drop of a type that does not need dropping, with a goto.
+//!
+//! When the MIR is built, we check `needs_drop` before emitting a `Drop` for a place. This pass is
+//! useful because (unlike MIR building) it runs after type checking, so it can make use of
+//! `Reveal::All` to provide more precies type information.
 
 use crate::MirPass;
 use rustc_middle::mir::*;
@@ -13,7 +17,7 @@ fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
         trace!("Running RemoveUnneededDrops on {:?}", body.source);
 
         let did = body.source.def_id();
-        let param_env = tcx.param_env(did);
+        let param_env = tcx.param_env_reveal_all_normalized(did);
         let mut should_simplify = false;
 
         let (basic_blocks, local_decls) = body.basic_blocks_and_local_decls_mut();