about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--compiler/rustc_arena/src/lib.rs8
-rw-r--r--compiler/rustc_ast_pretty/src/pp.rs4
-rw-r--r--compiler/rustc_ast_pretty/src/pprust/state.rs2
-rw-r--r--compiler/rustc_middle/src/mir/coverage.rs (renamed from compiler/rustc_middle/src/mir/coverage/mod.rs)0
-rw-r--r--compiler/rustc_middle/src/mir/terminator.rs (renamed from compiler/rustc_middle/src/mir/terminator/mod.rs)0
-rw-r--r--compiler/rustc_mir/src/interpret/intern.rs6
-rw-r--r--compiler/rustc_trait_selection/src/traits/codegen.rs (renamed from compiler/rustc_trait_selection/src/traits/codegen/mod.rs)0
-rw-r--r--library/core/src/intrinsics.rs12
-rw-r--r--src/librustdoc/lib.rs9
-rw-r--r--src/test/codegen/issue-73827-bounds-check-index-in-subexpr.rs18
-rw-r--r--src/test/ui/consts/const-eval/const_panic.rs21
-rw-r--r--src/test/ui/consts/const-eval/const_panic.stderr82
-rw-r--r--src/test/ui/consts/const-eval/const_panic_libcore.rs12
-rw-r--r--src/test/ui/consts/const-eval/const_panic_libcore_bin.rs (renamed from src/test/ui/consts/const-eval/const_panic_libcore_main.rs)0
-rw-r--r--src/test/ui/consts/const-eval/const_panic_libcore_bin.stderr (renamed from src/test/ui/consts/const-eval/const_panic_libcore.stderr)12
-rw-r--r--src/test/ui/consts/const-eval/const_panic_libcore_main.stderr33
-rw-r--r--src/test/ui/issues/issue-68010-large-zst-consts.rs5
-rw-r--r--src/test/ui/mir/auxiliary/issue_76375_aux.rs14
-rw-r--r--src/test/ui/mir/issue-68841.rs15
-rw-r--r--src/test/ui/mir/issue-75053.rs48
-rw-r--r--src/test/ui/mir/issue-76375.rs15
-rw-r--r--src/test/ui/mir/issue-77911.rs16
22 files changed, 242 insertions, 90 deletions
diff --git a/compiler/rustc_arena/src/lib.rs b/compiler/rustc_arena/src/lib.rs
index 34736b820e9..1a85a46ed74 100644
--- a/compiler/rustc_arena/src/lib.rs
+++ b/compiler/rustc_arena/src/lib.rs
@@ -217,8 +217,12 @@ impl<T> TypedArena<T> {
             let mut chunks = self.chunks.borrow_mut();
             let mut new_cap;
             if let Some(last_chunk) = chunks.last_mut() {
-                let used_bytes = self.ptr.get() as usize - last_chunk.start() as usize;
-                last_chunk.entries = used_bytes / mem::size_of::<T>();
+                // If a type is `!needs_drop`, we don't need to keep track of how many elements
+                // the chunk stores - the field will be ignored anyway.
+                if mem::needs_drop::<T>() {
+                    let used_bytes = self.ptr.get() as usize - last_chunk.start() as usize;
+                    last_chunk.entries = used_bytes / mem::size_of::<T>();
+                }
 
                 // If the previous chunk's len is less than HUGE_PAGE
                 // bytes, then this chunk will be least double the previous
diff --git a/compiler/rustc_ast_pretty/src/pp.rs b/compiler/rustc_ast_pretty/src/pp.rs
index 95f969d7691..56e769ba6b7 100644
--- a/compiler/rustc_ast_pretty/src/pp.rs
+++ b/compiler/rustc_ast_pretty/src/pp.rs
@@ -390,7 +390,7 @@ impl Printer {
         self.scan_stack.pop_front().unwrap()
     }
 
-    fn scan_top(&mut self) -> usize {
+    fn scan_top(&self) -> usize {
         *self.scan_stack.front().unwrap()
     }
 
@@ -484,7 +484,7 @@ impl Printer {
         self.pending_indentation += amount;
     }
 
-    fn get_top(&mut self) -> PrintStackElem {
+    fn get_top(&self) -> PrintStackElem {
         *self.print_stack.last().unwrap_or({
             &PrintStackElem { offset: 0, pbreak: PrintStackBreak::Broken(Breaks::Inconsistent) }
         })
diff --git a/compiler/rustc_ast_pretty/src/pprust/state.rs b/compiler/rustc_ast_pretty/src/pprust/state.rs
index af8f8132780..029a6cb664d 100644
--- a/compiler/rustc_ast_pretty/src/pprust/state.rs
+++ b/compiler/rustc_ast_pretty/src/pprust/state.rs
@@ -63,7 +63,7 @@ impl<'a> Comments<'a> {
     }
 
     pub fn trailing_comment(
-        &mut self,
+        &self,
         span: rustc_span::Span,
         next_pos: Option<BytePos>,
     ) -> Option<Comment> {
diff --git a/compiler/rustc_middle/src/mir/coverage/mod.rs b/compiler/rustc_middle/src/mir/coverage.rs
index 0421eabc2dc..0421eabc2dc 100644
--- a/compiler/rustc_middle/src/mir/coverage/mod.rs
+++ b/compiler/rustc_middle/src/mir/coverage.rs
diff --git a/compiler/rustc_middle/src/mir/terminator/mod.rs b/compiler/rustc_middle/src/mir/terminator.rs
index e1071454e65..e1071454e65 100644
--- a/compiler/rustc_middle/src/mir/terminator/mod.rs
+++ b/compiler/rustc_middle/src/mir/terminator.rs
diff --git a/compiler/rustc_mir/src/interpret/intern.rs b/compiler/rustc_mir/src/interpret/intern.rs
index dd5e9c99774..945791eddc8 100644
--- a/compiler/rustc_mir/src/interpret/intern.rs
+++ b/compiler/rustc_mir/src/interpret/intern.rs
@@ -187,6 +187,12 @@ impl<'rt, 'mir, 'tcx: 'mir, M: CompileTimeMachine<'mir, 'tcx>> ValueVisitor<'mir
                 return walked;
             }
         }
+
+        // ZSTs do not need validation unless they're uninhabited
+        if mplace.layout.is_zst() && !mplace.layout.abi.is_uninhabited() {
+            return Ok(());
+        }
+
         self.walk_aggregate(mplace, fields)
     }
 
diff --git a/compiler/rustc_trait_selection/src/traits/codegen/mod.rs b/compiler/rustc_trait_selection/src/traits/codegen.rs
index 05e6c4804ff..05e6c4804ff 100644
--- a/compiler/rustc_trait_selection/src/traits/codegen/mod.rs
+++ b/compiler/rustc_trait_selection/src/traits/codegen.rs
diff --git a/library/core/src/intrinsics.rs b/library/core/src/intrinsics.rs
index 2a7c105e807..dbc7921a62a 100644
--- a/library/core/src/intrinsics.rs
+++ b/library/core/src/intrinsics.rs
@@ -1660,22 +1660,22 @@ extern "rust-intrinsic" {
     /// Returns (a + b) mod 2<sup>N</sup>, where N is the width of T in bits.
     ///
     /// The stabilized versions of this intrinsic are available on the integer
-    /// primitives via the `checked_add` method. For example,
-    /// [`u32::checked_add`]
+    /// primitives via the `wrapping_add` method. For example,
+    /// [`u32::wrapping_add`]
     #[rustc_const_stable(feature = "const_int_wrapping", since = "1.40.0")]
     pub fn wrapping_add<T: Copy>(a: T, b: T) -> T;
     /// Returns (a - b) mod 2<sup>N</sup>, where N is the width of T in bits.
     ///
     /// The stabilized versions of this intrinsic are available on the integer
-    /// primitives via the `checked_sub` method. For example,
-    /// [`u32::checked_sub`]
+    /// primitives via the `wrapping_sub` method. For example,
+    /// [`u32::wrapping_sub`]
     #[rustc_const_stable(feature = "const_int_wrapping", since = "1.40.0")]
     pub fn wrapping_sub<T: Copy>(a: T, b: T) -> T;
     /// Returns (a * b) mod 2<sup>N</sup>, where N is the width of T in bits.
     ///
     /// The stabilized versions of this intrinsic are available on the integer
-    /// primitives via the `checked_mul` method. For example,
-    /// [`u32::checked_mul`]
+    /// primitives via the `wrapping_mul` method. For example,
+    /// [`u32::wrapping_mul`]
     #[rustc_const_stable(feature = "const_int_wrapping", since = "1.40.0")]
     pub fn wrapping_mul<T: Copy>(a: T, b: T) -> T;
 
diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs
index 12726d2bd9a..616f0efcd75 100644
--- a/src/librustdoc/lib.rs
+++ b/src/librustdoc/lib.rs
@@ -85,12 +85,6 @@ mod theme;
 mod visit_ast;
 mod visit_lib;
 
-struct Output {
-    krate: clean::Crate,
-    renderinfo: config::RenderInfo,
-    renderopts: config::RenderOptions,
-}
-
 pub fn main() {
     rustc_driver::set_sigpipe_handler();
     rustc_driver::install_ice_hook();
@@ -521,15 +515,12 @@ fn main_options(options: config::Options) -> MainResult {
 
     krate.version = crate_version;
 
-    let out = Output { krate, renderinfo, renderopts };
-
     if show_coverage {
         // if we ran coverage, bail early, we don't need to also generate docs at this point
         // (also we didn't load in any of the useful passes)
         return Ok(());
     }
 
-    let Output { krate, renderinfo, renderopts } = out;
     info!("going to format");
     let (error_format, edition, debugging_options) = diag_opts;
     let diag = core::new_handler(error_format, None, &debugging_options);
diff --git a/src/test/codegen/issue-73827-bounds-check-index-in-subexpr.rs b/src/test/codegen/issue-73827-bounds-check-index-in-subexpr.rs
new file mode 100644
index 00000000000..d07eaa75b7a
--- /dev/null
+++ b/src/test/codegen/issue-73827-bounds-check-index-in-subexpr.rs
@@ -0,0 +1,18 @@
+// This test checks that bounds checks are elided when
+// index is part of a (x | y) < C style condition
+
+// min-llvm-version: 11.0.0
+// compile-flags: -O
+
+#![crate_type = "lib"]
+
+// CHECK-LABEL: @get
+#[no_mangle]
+pub fn get(array: &[u8; 8], x: usize, y: usize) -> u8 {
+    if x > 7 || y > 7 {
+        0
+    } else {
+        // CHECK-NOT: panic_bounds_check
+        array[y]
+    }
+}
diff --git a/src/test/ui/consts/const-eval/const_panic.rs b/src/test/ui/consts/const-eval/const_panic.rs
index 3e5112b0b14..ada9feec897 100644
--- a/src/test/ui/consts/const-eval/const_panic.rs
+++ b/src/test/ui/consts/const-eval/const_panic.rs
@@ -1,11 +1,26 @@
 #![feature(const_panic)]
 #![crate_type = "lib"]
 
-pub const Z: () = panic!("cheese");
+const Z: () = std::panic!("cheese");
 //~^ ERROR any use of this value will cause an error
 
-pub const Y: () = unreachable!();
+const Z2: () = std::panic!();
 //~^ ERROR any use of this value will cause an error
 
-pub const X: () = unimplemented!();
+const Y: () = std::unreachable!();
+//~^ ERROR any use of this value will cause an error
+
+const X: () = std::unimplemented!();
+//~^ ERROR any use of this value will cause an error
+
+const Z_CORE: () = core::panic!("cheese");
+//~^ ERROR any use of this value will cause an error
+
+const Z2_CORE: () = core::panic!();
+//~^ ERROR any use of this value will cause an error
+
+const Y_CORE: () = core::unreachable!();
+//~^ ERROR any use of this value will cause an error
+
+const X_CORE: () = core::unimplemented!();
 //~^ ERROR any use of this value will cause an error
diff --git a/src/test/ui/consts/const-eval/const_panic.stderr b/src/test/ui/consts/const-eval/const_panic.stderr
index 679d8f280cc..e4ca1f4fa26 100644
--- a/src/test/ui/consts/const-eval/const_panic.stderr
+++ b/src/test/ui/consts/const-eval/const_panic.stderr
@@ -1,33 +1,83 @@
 error: any use of this value will cause an error
-  --> $DIR/const_panic.rs:4:19
+  --> $DIR/const_panic.rs:4:15
    |
-LL | pub const Z: () = panic!("cheese");
-   | ------------------^^^^^^^^^^^^^^^^-
-   |                   |
-   |                   the evaluated program panicked at 'cheese', $DIR/const_panic.rs:4:19
+LL | const Z: () = std::panic!("cheese");
+   | --------------^^^^^^^^^^^^^^^^^^^^^-
+   |               |
+   |               the evaluated program panicked at 'cheese', $DIR/const_panic.rs:4:15
    |
    = note: `#[deny(const_err)]` on by default
    = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: any use of this value will cause an error
-  --> $DIR/const_panic.rs:7:19
+  --> $DIR/const_panic.rs:7:16
    |
-LL | pub const Y: () = unreachable!();
-   | ------------------^^^^^^^^^^^^^^-
-   |                   |
-   |                   the evaluated program panicked at 'internal error: entered unreachable code', $DIR/const_panic.rs:7:19
+LL | const Z2: () = std::panic!();
+   | ---------------^^^^^^^^^^^^^-
+   |                |
+   |                the evaluated program panicked at 'explicit panic', $DIR/const_panic.rs:7:16
    |
    = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: any use of this value will cause an error
-  --> $DIR/const_panic.rs:10:19
+  --> $DIR/const_panic.rs:10:15
    |
-LL | pub const X: () = unimplemented!();
-   | ------------------^^^^^^^^^^^^^^^^-
-   |                   |
-   |                   the evaluated program panicked at 'not implemented', $DIR/const_panic.rs:10:19
+LL | const Y: () = std::unreachable!();
+   | --------------^^^^^^^^^^^^^^^^^^^-
+   |               |
+   |               the evaluated program panicked at 'internal error: entered unreachable code', $DIR/const_panic.rs:10:15
    |
    = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
 
-error: aborting due to 3 previous errors
+error: any use of this value will cause an error
+  --> $DIR/const_panic.rs:13:15
+   |
+LL | const X: () = std::unimplemented!();
+   | --------------^^^^^^^^^^^^^^^^^^^^^-
+   |               |
+   |               the evaluated program panicked at 'not implemented', $DIR/const_panic.rs:13:15
+   |
+   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error: any use of this value will cause an error
+  --> $DIR/const_panic.rs:16:20
+   |
+LL | const Z_CORE: () = core::panic!("cheese");
+   | -------------------^^^^^^^^^^^^^^^^^^^^^^-
+   |                    |
+   |                    the evaluated program panicked at 'cheese', $DIR/const_panic.rs:16:20
+   |
+   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error: any use of this value will cause an error
+  --> $DIR/const_panic.rs:19:21
+   |
+LL | const Z2_CORE: () = core::panic!();
+   | --------------------^^^^^^^^^^^^^^-
+   |                     |
+   |                     the evaluated program panicked at 'explicit panic', $DIR/const_panic.rs:19:21
+   |
+   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error: any use of this value will cause an error
+  --> $DIR/const_panic.rs:22:20
+   |
+LL | const Y_CORE: () = core::unreachable!();
+   | -------------------^^^^^^^^^^^^^^^^^^^^-
+   |                    |
+   |                    the evaluated program panicked at 'internal error: entered unreachable code', $DIR/const_panic.rs:22:20
+   |
+   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error: any use of this value will cause an error
+  --> $DIR/const_panic.rs:25:20
+   |
+LL | const X_CORE: () = core::unimplemented!();
+   | -------------------^^^^^^^^^^^^^^^^^^^^^^-
+   |                    |
+   |                    the evaluated program panicked at 'not implemented', $DIR/const_panic.rs:25:20
+   |
+   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error: aborting due to 8 previous errors
 
diff --git a/src/test/ui/consts/const-eval/const_panic_libcore.rs b/src/test/ui/consts/const-eval/const_panic_libcore.rs
deleted file mode 100644
index e42685e9c76..00000000000
--- a/src/test/ui/consts/const-eval/const_panic_libcore.rs
+++ /dev/null
@@ -1,12 +0,0 @@
-#![no_std]
-#![crate_type = "lib"]
-#![feature(const_panic)]
-
-const Z: () = panic!("cheese");
-//~^ ERROR any use of this value will cause an error
-
-const Y: () = unreachable!();
-//~^ ERROR any use of this value will cause an error
-
-const X: () = unimplemented!();
-//~^ ERROR any use of this value will cause an error
diff --git a/src/test/ui/consts/const-eval/const_panic_libcore_main.rs b/src/test/ui/consts/const-eval/const_panic_libcore_bin.rs
index 6b03e847def..6b03e847def 100644
--- a/src/test/ui/consts/const-eval/const_panic_libcore_main.rs
+++ b/src/test/ui/consts/const-eval/const_panic_libcore_bin.rs
diff --git a/src/test/ui/consts/const-eval/const_panic_libcore.stderr b/src/test/ui/consts/const-eval/const_panic_libcore_bin.stderr
index 2abf158aade..9eeddc464f5 100644
--- a/src/test/ui/consts/const-eval/const_panic_libcore.stderr
+++ b/src/test/ui/consts/const-eval/const_panic_libcore_bin.stderr
@@ -1,31 +1,31 @@
 error: any use of this value will cause an error
-  --> $DIR/const_panic_libcore.rs:5:15
+  --> $DIR/const_panic_libcore_bin.rs:9:15
    |
 LL | const Z: () = panic!("cheese");
    | --------------^^^^^^^^^^^^^^^^-
    |               |
-   |               the evaluated program panicked at 'cheese', $DIR/const_panic_libcore.rs:5:15
+   |               the evaluated program panicked at 'cheese', $DIR/const_panic_libcore_bin.rs:9:15
    |
    = note: `#[deny(const_err)]` on by default
    = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: any use of this value will cause an error
-  --> $DIR/const_panic_libcore.rs:8:15
+  --> $DIR/const_panic_libcore_bin.rs:12:15
    |
 LL | const Y: () = unreachable!();
    | --------------^^^^^^^^^^^^^^-
    |               |
-   |               the evaluated program panicked at 'internal error: entered unreachable code', $DIR/const_panic_libcore.rs:8:15
+   |               the evaluated program panicked at 'internal error: entered unreachable code', $DIR/const_panic_libcore_bin.rs:12:15
    |
    = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: any use of this value will cause an error
-  --> $DIR/const_panic_libcore.rs:11:15
+  --> $DIR/const_panic_libcore_bin.rs:15:15
    |
 LL | const X: () = unimplemented!();
    | --------------^^^^^^^^^^^^^^^^-
    |               |
-   |               the evaluated program panicked at 'not implemented', $DIR/const_panic_libcore.rs:11:15
+   |               the evaluated program panicked at 'not implemented', $DIR/const_panic_libcore_bin.rs:15:15
    |
    = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
 
diff --git a/src/test/ui/consts/const-eval/const_panic_libcore_main.stderr b/src/test/ui/consts/const-eval/const_panic_libcore_main.stderr
deleted file mode 100644
index c5887ff8c56..00000000000
--- a/src/test/ui/consts/const-eval/const_panic_libcore_main.stderr
+++ /dev/null
@@ -1,33 +0,0 @@
-error: any use of this value will cause an error
-  --> $DIR/const_panic_libcore_main.rs:9:15
-   |
-LL | const Z: () = panic!("cheese");
-   | --------------^^^^^^^^^^^^^^^^-
-   |               |
-   |               the evaluated program panicked at 'cheese', $DIR/const_panic_libcore_main.rs:9:15
-   |
-   = note: `#[deny(const_err)]` on by default
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
-
-error: any use of this value will cause an error
-  --> $DIR/const_panic_libcore_main.rs:12:15
-   |
-LL | const Y: () = unreachable!();
-   | --------------^^^^^^^^^^^^^^-
-   |               |
-   |               the evaluated program panicked at 'internal error: entered unreachable code', $DIR/const_panic_libcore_main.rs:12:15
-   |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
-
-error: any use of this value will cause an error
-  --> $DIR/const_panic_libcore_main.rs:15:15
-   |
-LL | const X: () = unimplemented!();
-   | --------------^^^^^^^^^^^^^^^^-
-   |               |
-   |               the evaluated program panicked at 'not implemented', $DIR/const_panic_libcore_main.rs:15:15
-   |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
-
-error: aborting due to 3 previous errors
-
diff --git a/src/test/ui/issues/issue-68010-large-zst-consts.rs b/src/test/ui/issues/issue-68010-large-zst-consts.rs
new file mode 100644
index 00000000000..4f1bd45e90a
--- /dev/null
+++ b/src/test/ui/issues/issue-68010-large-zst-consts.rs
@@ -0,0 +1,5 @@
+// build-pass
+
+fn main() {
+    println!("{}", [(); std::usize::MAX].len());
+}
diff --git a/src/test/ui/mir/auxiliary/issue_76375_aux.rs b/src/test/ui/mir/auxiliary/issue_76375_aux.rs
new file mode 100644
index 00000000000..f8b318d58ba
--- /dev/null
+++ b/src/test/ui/mir/auxiliary/issue_76375_aux.rs
@@ -0,0 +1,14 @@
+// edition:2018
+// compile-flags: -Z mir-opt-level=2 -Z unsound-mir-opts
+
+#[inline(always)]
+pub fn f(s: bool) -> String {
+    let a = "Hello world!".to_string();
+    let b = a;
+    let c = b;
+    if s {
+        c
+    } else {
+        String::new()
+    }
+}
diff --git a/src/test/ui/mir/issue-68841.rs b/src/test/ui/mir/issue-68841.rs
new file mode 100644
index 00000000000..14884a97fab
--- /dev/null
+++ b/src/test/ui/mir/issue-68841.rs
@@ -0,0 +1,15 @@
+// compile-flags: -Z mir-opt-level=2
+// edition:2018
+// build-pass
+
+#![feature(async_closure)]
+
+use std::future::Future;
+
+fn async_closure() -> impl Future<Output = u8> {
+    (async move || -> u8 { 42 })()
+}
+
+fn main() {
+    let _fut = async_closure();
+}
diff --git a/src/test/ui/mir/issue-75053.rs b/src/test/ui/mir/issue-75053.rs
new file mode 100644
index 00000000000..6e7211c2ee6
--- /dev/null
+++ b/src/test/ui/mir/issue-75053.rs
@@ -0,0 +1,48 @@
+// compile-flags: -Z mir-opt-level=2
+// build-pass
+
+#![feature(type_alias_impl_trait)]
+
+use std::marker::PhantomData;
+
+trait MyIndex<T> {
+    type O;
+    fn my_index(self) -> Self::O;
+}
+trait MyFrom<T>: Sized {
+    type Error;
+    fn my_from(value: T) -> Result<Self, Self::Error>;
+}
+
+trait F {}
+impl F for () {}
+type DummyT<T> = impl F;
+fn _dummy_t<T>() -> DummyT<T> {}
+
+struct Phantom1<T>(PhantomData<T>);
+struct Phantom2<T>(PhantomData<T>);
+struct Scope<T>(Phantom2<DummyT<T>>);
+
+impl<T> Scope<T> {
+    fn new() -> Self {
+        unimplemented!()
+    }
+}
+
+impl<T> MyFrom<Phantom2<T>> for Phantom1<T> {
+    type Error = ();
+    fn my_from(_: Phantom2<T>) -> Result<Self, Self::Error> {
+        unimplemented!()
+    }
+}
+
+impl<T: MyFrom<Phantom2<DummyT<U>>>, U> MyIndex<Phantom1<T>> for Scope<U> {
+    type O = T;
+    fn my_index(self) -> Self::O {
+        MyFrom::my_from(self.0).ok().unwrap()
+    }
+}
+
+fn main() {
+    let _pos: Phantom1<DummyT<()>> = Scope::new().my_index();
+}
diff --git a/src/test/ui/mir/issue-76375.rs b/src/test/ui/mir/issue-76375.rs
new file mode 100644
index 00000000000..ef459f6a28e
--- /dev/null
+++ b/src/test/ui/mir/issue-76375.rs
@@ -0,0 +1,15 @@
+// edition:2018
+// build-pass
+// compile-flags: -Z mir-opt-level=2 -L.
+// aux-build:issue_76375_aux.rs
+
+#![crate_type = "lib"]
+
+extern crate issue_76375_aux;
+
+pub async fn g() {
+    issue_76375_aux::f(true);
+    h().await;
+}
+
+pub async fn h() {}
diff --git a/src/test/ui/mir/issue-77911.rs b/src/test/ui/mir/issue-77911.rs
new file mode 100644
index 00000000000..b24faa6f885
--- /dev/null
+++ b/src/test/ui/mir/issue-77911.rs
@@ -0,0 +1,16 @@
+// compile-flags: -Z mir-opt-level=2
+// ignore-cloudabi no std::fs
+// build-pass
+
+use std::fs::File;
+use std::io::{BufRead, BufReader};
+
+fn file_lines() -> impl Iterator<Item = String> {
+    BufReader::new(File::open("").unwrap())
+        .lines()
+        .map(Result::unwrap)
+}
+
+fn main() {
+    for _ in file_lines() {}
+}