Rust: ICE with `impl_trait_in_bindings` when `Wrap`ped

Created on 6 Mar 2019  路  5Comments  路  Source: rust-lang/rust

cc @alexreg @nikomatsakis

While writing test cases:

#![feature(impl_trait_in_bindings)]

trait Lam {}

pub struct B;
impl Lam for B {}
pub struct Wrap<T>(T);

const _A: impl Lam = {
    let x: Wrap<impl Lam> = Wrap(B);
    x.0
};

Produces:

error: internal compiler error: broken MIR in DefId(0/0:7 ~ playground[1ded]::_A[0]) (_1 = Wrap<B>(move _2,)): bad assignment (Wrap<impl Lam> = Wrap<B>): NoSolution
  --> src/lib.rs:12:29
   |
12 |     let x: Wrap<impl Lam> = Wrap(B);
   |                             ^^^^^^^

thread 'rustc' panicked at 'no errors encountered even though `delay_span_bug` issued', src/librustc_errors/lib.rs:354:17
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:71
   2: std::panicking::default_hook::{{closure}}
             at src/libstd/sys_common/backtrace.rs:59
             at src/libstd/panicking.rs:197
   3: std::panicking::default_hook
             at src/libstd/panicking.rs:211
   4: rustc::util::common::panic_hook
   5: std::panicking::rust_panic_with_hook
             at src/libstd/panicking.rs:478
   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: syntax::with_globals
  12: __rust_maybe_catch_panic
             at src/libpanic_unwind/lib.rs:87
  13: <F as alloc::boxed::FnBox<A>>::call_box
  14: std::sys::unix::thread::Thread::new::thread_start
             at /rustc/a9da8fc9c267c08cfdb8cf5b39da14f154d12939/src/liballoc/boxed.rs:759
             at src/libstd/sys_common/thread.rs:14
             at src/libstd/sys/unix/thread.rs:80
  15: start_thread
  16: __clone
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: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports

note: rustc 1.35.0-nightly (a9da8fc9c 2019-03-04) running on x86_64-unknown-linux-gnu

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

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

error: Could not compile `playground`.

Possibly dupe of https://github.com/rust-lang/rust/issues/54600.

A-impl-trait A-typesystem C-bug F-impl_trait_in_bindings I-ICE T-compiler glacier requires-nightly

Most helpful comment

@alexreg Consider it a test case written for you... ;)

All 5 comments

Ugh, I really wish people would ignore that feature for now. It鈥檚 becoming the new generic-associated-types. It will be completely overhauled when I can finally get around to it, maybe in 2 weeks.

@alexreg Consider it a test case written for you... ;)

@Centril Haha, fair!

Ugh, I really wish people would ignore that feature for now. It鈥檚 becoming the new generic-associated-types.

You should add it to:
https://github.com/rust-lang/rust/blob/de4478af91765999f51b2950bea16686ee4cd60a/src/libsyntax/feature_gate.rs#L2023

I'm not sure how much it helps, but it's something.

@varkor Thanks, didn't know about that.

Was this page helpful?
0 / 5 - 0 ratings