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 closure return type as impl trait type alias defining use #63263

Luexa opened this issue Aug 4, 2019 · 1 comment

ICE with closure return type as impl trait type alias defining use #63263

Luexa opened this issue Aug 4, 2019 · 1 comment


Copy link

@Luexa Luexa commented Aug 4, 2019

In an attempt to make the compiler recognize my defining use of an impl trait type alias without making a separate wrapper function, I ran this code, but it resulted in an ICE:


pub type Closure = impl FnOnce();

fn main() {
    || -> Closure { || () };


Compiler Output:

   Compiling playground v0.0.1 (/playground)
error: internal compiler error: broken MIR in DefId(0:14 ~ playground[1d12]::main[0]::{{closure}}[0]) (bb0[0]): equate_normalized_input_or_output: `Closure==[closure@src/ 6:26]` failed with `NoSolution`
 --> src/
6 |     || -> Closure { || () };
  |                            ^

thread 'rustc' panicked at 'no errors encountered even though `delay_span_bug` issued', src/librustc_errors/
stack backtrace:
   0: backtrace::backtrace::libunwind::trace
             at /cargo/registry/src/
   1: backtrace::backtrace::trace_unsynchronized
             at /cargo/registry/src/
   2: std::sys_common::backtrace::_print
             at src/libstd/sys_common/
   3: std::sys_common::backtrace::print
             at src/libstd/sys_common/
   4: std::panicking::default_hook::{{closure}}
             at src/libstd/
   5: std::panicking::default_hook
             at src/libstd/
   6: rustc::util::common::panic_hook
   7: std::panicking::rust_panic_with_hook
             at src/libstd/
   8: std::panicking::begin_panic
   9: <rustc_errors::Handler as core::ops::drop::Drop>::drop
  10: core::ptr::real_drop_in_place
  11: <alloc::rc::Rc<T> as core::ops::drop::Drop>::drop
  12: core::ptr::real_drop_in_place
  13: rustc_interface::interface::run_compiler_in_existing_thread_pool
  14: std::thread::local::LocalKey<T>::with
  15: syntax::with_globals
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
query stack during panic:
end of query stack

error: internal compiler error: unexpected panic

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

note: we would appreciate a bug report:

note: rustc 1.38.0-nightly (d3f8a0b5d 2019-08-04) running on x86_64-unknown-linux-gnu

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

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

error: Could not compile `playground`.

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

@hellow554 hellow554 commented Aug 5, 2019



pub type Closure = impl FnOnce();

fn main() {
    || -> Closure { || () };


tmandry added a commit to tmandry/rust that referenced this issue Nov 27, 2019

Use `eq_opaque_type_and_type` when type-checking closure signatures

This handles the case where a user explicitly annotations a closure
signature with a opaque return type.

Fixes rust-lang#63263
@bors bors closed this in b696f48 Nov 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

4 participants