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 opaque type #85113

Closed
alexkirsz opened this issue May 9, 2021 · 3 comments · Fixed by #86248
Closed

ICE with opaque type #85113

alexkirsz opened this issue May 9, 2021 · 3 comments · Fixed by #86248
Labels
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. F-impl_trait_in_bindings `#![feature(impl_trait_in_bindings)]` F-type_alias_impl_trait `#[feature(type_alias_impl_trait)]` glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@alexkirsz
Copy link
Contributor

I was playing around with existential types in nightly, forgot to update some code, and hit this ICE.

Code

https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=3794cac3bdc24912ee114d8991502058

#![feature(min_type_alias_impl_trait)]
#![feature(impl_trait_in_bindings)]

type OpaqueOutputImpl<'a> = impl Output<'a> + 'a;

trait Output<'a> {}

impl<'a> Output<'a> for &'a str {}

fn cool_fn<'a>(arg: &'a str) -> OpaqueOutputImpl<'a> {
    let out: OpaqueOutputImpl<'a> = arg;
    arg // This was supposed to be `out`
}

fn main() {
    let s = String::from("wassup");
    cool_fn(&s);
}

Meta

rustc --version --verbose:

rustc 1.54.0-nightly (881c1ac40 2021-05-08) running on x86_64-unknown-linux-gnu

Error output

error: internal compiler error: member constraint for `DefId(0:5 ~ playground[b426]::OpaqueOutputImpl::{opaque#0})` has an option region `'_#7r` that is not a universal region
  --> src/main.rs:11:37
   |
11 |     let out: OpaqueOutputImpl<'a> = arg;
   |                                     ^^^
   |
   = note: delayed at compiler/rustc_mir/src/borrow_check/region_infer/mod.rs:697:22

thread 'rustc' panicked at 'no errors encountered even though `delay_span_bug` issued', compiler/rustc_errors/src/lib.rs:1019:13
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

error: internal compiler error: unexpected panic

note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: rustc 1.54.0-nightly (881c1ac40 2021-05-08) running on x86_64-unknown-linux-gnu

note: compiler flags: -C embed-bitcode=no -C codegen-units=1 -C debuginfo=2 --crate-type bin

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
end of query stack
error: could not compile `playground`

To learn more, run the command again with --verbose.
Backtrace

error: internal compiler error: member constraint for `DefId(0:5 ~ playground[b426]::OpaqueOutputImpl::{opaque#0})` has an option region `'_#7r` that is not a universal region
  --> src/main.rs:11:37
   |
11 |     let out: OpaqueOutputImpl<'a> = arg;
   |                                     ^^^
   |
   = note: delayed at compiler/rustc_mir/src/borrow_check/region_infer/mod.rs:697:22

thread 'rustc' panicked at 'no errors encountered even though `delay_span_bug` issued', compiler/rustc_errors/src/lib.rs:1019:13
stack backtrace:
   0: rust_begin_unwind
             at /rustc/881c1ac408d93bb7adaa3a51dabab9266e82eee8/library/std/src/panicking.rs:493:5
   1: std::panicking::begin_panic_fmt
             at /rustc/881c1ac408d93bb7adaa3a51dabab9266e82eee8/library/std/src/panicking.rs:435:5
   2: rustc_errors::HandlerInner::flush_delayed
   3: <rustc_errors::HandlerInner as core::ops::drop::Drop>::drop
   4: core::ptr::drop_in_place<rustc_session::parse::ParseSess>
   5: <alloc::rc::Rc<T> as core::ops::drop::Drop>::drop
   6: core::ptr::drop_in_place<rustc_interface::interface::Compiler>
   7: rustc_span::with_source_map
   8: rustc_interface::interface::create_compiler_and_run
   9: scoped_tls::ScopedKey<T>::set
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

@alexkirsz alexkirsz added C-bug Category: This is a bug. 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. labels May 9, 2021
@jonas-schievink jonas-schievink added F-type_alias_impl_trait `#[feature(type_alias_impl_trait)]` F-impl_trait_in_bindings `#![feature(impl_trait_in_bindings)]` labels May 9, 2021
@araruna
Copy link

araruna commented May 12, 2021

@rustbot label: +requires-nightly

@rustbot rustbot added the requires-nightly This issue requires a nightly compiler in some way. label May 12, 2021
@rust-lang-glacier-bot rust-lang-glacier-bot added the glacier ICE tracked in rust-lang/glacier. label May 12, 2021
@aticu
Copy link
Contributor

aticu commented Jun 2, 2021

I'm not sure, if it's the same cause, but this ICE seems related (found in #85883 by @Boddlnagg), so I'll post it here instead of in a new issue:

#![feature(unboxed_closures)]
#![feature(min_type_alias_impl_trait)]
#![feature(impl_trait_in_bindings)]

type Fun = impl Fn<()>;
static BBB: Fun = bbb;
type Out = <Fun as FnOnce<()>>::Output;

fn bbb() {}

fn main() {
    let bar: Out = BBB();
}
error: internal compiler error: broken MIR in DefId(0:8 ~ playground[2b78]::main) (NoSolution): failed to normalize `<_ as std::ops::FnOnce<()>>::Output`
  |
  = note: delayed at compiler/rustc_mir/src/borrow_check/type_check/mod.rs:252:27

thread 'rustc' panicked at 'no errors encountered even though `delay_span_bug` issued', compiler/rustc_errors/src/lib.rs:1021:13
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

error: internal compiler error: unexpected panic

note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: rustc 1.54.0-nightly (625d5a693 2021-06-01) running on x86_64-unknown-linux-gnu

note: compiler flags: -C embed-bitcode=no -C codegen-units=1 -C debuginfo=2 --crate-type bin

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
end of query stack
error: could not compile `playground`

To learn more, run the command again with --verbose.

@JohnTitor
Copy link
Member

The original ICE has been fixed by #86118 but #85113 (comment) hasn't, @aticu could you open a new issue if it hasn't been reported yet?

@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 Jun 10, 2021
@bors bors closed this as completed in ac41056 Jun 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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. F-impl_trait_in_bindings `#![feature(impl_trait_in_bindings)]` F-type_alias_impl_trait `#[feature(type_alias_impl_trait)]` glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Development

Successfully merging a pull request may close this issue.

7 participants