Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ICE with HRTB: Broken MIR in DefId [...] could not prove Binder #59311

Closed
cbourjau opened this issue Mar 20, 2019 · 2 comments · Fixed by #74889
Closed

ICE with HRTB: Broken MIR in DefId [...] could not prove Binder #59311

cbourjau opened this issue Mar 20, 2019 · 2 comments · Fixed by #74889
Labels
A-MIR Area: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.html C-bug Category: This is a bug. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@cbourjau
Copy link

rustc ICEes when trying to compile the following code. As far as I can tell, the issue is due to the HRTB. All other issues I found mentioning broken MIR in DefId where either using unstable features and/or related to impl Trait which seems to be unrelated to this issue.

Playground link

use std::sync::mpsc::channel;

pub struct S<T> {
    pub thing: T,
}

#[derive(Debug)]
struct E;

impl std::fmt::Display for E {
    fn fmt(&self, _f: &mut std::fmt::Formatter) -> std::fmt::Result {
        unimplemented!()
    }
}

impl std::error::Error for E {}

impl<T> S<T> {
    pub fn do_thing()
    where
        for<'a> &'a T: 'static,
    {
        let (_sender, rx) = channel::<T>();
        let _ = rx.recv().map_err(|_| E);
    }
}

Meta

On the playground, I am able to reproduce the ICE on stable (1.33), beta, and nightly. Locally I have the following setup:

rustc --version --verbose:

rustc 1.33.0 (2aa4c46cf 2019-02-28)
binary: rustc
commit-hash: 2aa4c46cfdd726e97360c2734835aa3515e8c858
commit-date: 2019-02-28
host: x86_64-unknown-linux-gnu
release: 1.33.0
LLVM version: 8.0

Backtrace:

error: internal compiler error: broken MIR in DefId(0/0:9 ~ playground[59ee]::{{impl}}[2]::do_thing[0]) (NoSolution): could not prove Binder(OutlivesPredicate(&'a T, ReStatic))
  --> src/lib.rs:24:35
   |
24 |         let _ = rx.recv().map_err(|_| E);
   |                                   ^^^^^

thread 'rustc' panicked at 'no errors encountered even though `delay_span_bug` issued', src/librustc_errors/lib.rs:322:17
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
stack backtrace:
   0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
             at src/libstd/sys/unix/backtrace/tracing/gcc_s.rs:39
   1: std::sys_common::backtrace::_print
             at src/libstd/sys_common/backtrace.rs:70
   2: std::panicking::default_hook::{{closure}}
             at src/libstd/sys_common/backtrace.rs:58
             at src/libstd/panicking.rs:200
   3: std::panicking::default_hook
             at src/libstd/panicking.rs:215
   4: rustc::util::common::panic_hook
   5: std::panicking::rust_panic_with_hook
             at src/libstd/panicking.rs:482
   6: std::panicking::begin_panic
   7: <rustc_errors::Handler as core::ops::drop::Drop>::drop
   8: core::ptr::real_drop_in_place
   9: core::ptr::real_drop_in_place
  10: core::ptr::real_drop_in_place
  11: <scoped_tls::ScopedKey<T>>::set
@jonas-schievink jonas-schievink added I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. A-MIR Area: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.html C-bug Category: This is a bug. labels Mar 20, 2019
@rust-lang-glacier-bot rust-lang-glacier-bot added the glacier ICE tracked in rust-lang/glacier. label Oct 15, 2019
@Centril
Copy link
Contributor

Centril commented Mar 10, 2020

Triage: Reproduces as of 2020-03-10.

@JohnTitor
Copy link
Member

Triage: This ICE has been fixed in the latest nightly, I assume it's fixed by #73503. Marking as E-needs-test.

@JohnTitor JohnTitor added the E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. label Jul 28, 2020
JohnTitor added a commit to JohnTitor/rust that referenced this issue Aug 6, 2020
Add HRTB-related regression test

Closes rust-lang#59311 and cc rust-lang#71546
This closes the former but the test is taken from rust-lang#71546 (comment) since it seems they have the same cause and it's simplified.
JohnTitor added a commit to JohnTitor/rust that referenced this issue Aug 6, 2020
Add HRTB-related regression test

Closes rust-lang#59311 and cc rust-lang#71546
This closes the former but the test is taken from rust-lang#71546 (comment) since it seems they have the same cause and it's simplified.
@bors bors closed this as completed in 4b0882c Aug 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-MIR Area: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.html C-bug Category: This is a bug. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants