]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc/infer/higher_ranked/mod.rs
add the ability to skip leak check within a snapshot
[rust.git] / src / librustc / infer / higher_ranked / mod.rs
index bbca4823431e80800f21ac0830b99f7a063d9e58..d25d186f4d74e86756fc66abca5f134b78748db9 100644 (file)
@@ -128,6 +128,16 @@ pub fn leak_check(
         placeholder_map: &PlaceholderMap<'tcx>,
         snapshot: &CombinedSnapshot<'_, 'tcx>,
     ) -> RelateResult<'tcx, ()> {
+        // If the user gave `-Zno-leak-check`, or we have been
+        // configured to skip the leak check, then skip the leak check
+        // completely. The leak check is deprecated. Any legitimate
+        // subtyping errors that it would have caught will now be
+        // caught later on, during region checking. However, we
+        // continue to use it for a transition period.
+        if self.tcx.sess.opts.debugging_opts.no_leak_check || self.skip_leak_check.get() {
+            return Ok(());
+        }
+
         self.borrow_region_constraints().leak_check(
             self.tcx,
             overly_polymorphic,