Closed
Description
I tried this code:
#![allow(dead_code)]
trait Trait1<T, U> {
fn f1(self) -> U;
}
trait Trait2 {
type T;
type U: Trait2<T = Self::T>;
fn f2(f: impl FnOnce(&Self::U));
}
fn f3<T: Trait2>() -> impl Trait1<T, T::T> {
Struct1
}
struct Struct1;
impl<T: Trait2> Trait1<T, T::T> for Struct1 {
fn f1(self) -> T::T {
unimplemented!()
}
}
fn f4<T: Trait2>() {
T::f2(|_| {
f3::<T::U>().f1();
});
}
I expected to see this happen: Rustc should either print an error message or compile my code.
Instead, this happened: Rustc panics.
Meta
rustc --version --verbose
:
rustc 1.38.0 (625451e 2019-09-23)
binary: rustc
commit-hash: 625451e
commit-date: 2019-09-23
host: x86_64-unknown-linux-gnu
release: 1.38.0
LLVM version: 9.0
Backtrace:
Put the above code in myfile.rs and execute:
RUST_BACKTRACE=1 rustc myfile.rs --crate-type=lib
:
error: internal compiler error: broken MIR in DefId(0:31 ~ lib[8787]::f4[0]::{{closure}}[0]) (NoSolution): could not prove Binder(TraitPredicate(<impl Trait1<<T as Trait2>::U, <<T as Trait2>::U as Trait2>::T> as Trait1<<T as Trait2>::U, <T as Trait2>::T>>))
error: internal compiler error: broken MIR in DefId(0:31 ~ lib[8787]::f4[0]::{{closure}}[0]) (Terminator { source_info: SourceInfo { span: src/lib.rs:26:9: 26:26, scope: scope[0] }, kind: _3 = const <impl Trait1<<T as Trait2>::U, <<T as Trait2>::U as Trait2>::T> as Trait1<<T as Trait2>::U, <<T as Trait2>::U as Trait2>::T>>::f1(move _4) -> [return: bb3, unwind: bb4] }): call dest mismatch (<<T as Trait2>::U as Trait2>::T <- <T as Trait2>::T): NoSolution
--> src/lib.rs:25:11
|
25 | T::f2(|_| {
| ___________^
26 | | f3::<T::U>().f1();
27 | | });
| |_____^
thread 'rustc' panicked at 'no errors encountered even though `delay_span_bug` issued', src/librustc_errors/lib.rs:361:17
stack backtrace:
0: backtrace::backtrace::libunwind::trace
at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.34/src/backtrace/libunwind.rs:88
1: backtrace::backtrace::trace_unsynchronized
at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.34/src/backtrace/mod.rs:66
2: std::sys_common::backtrace::_print
at src/libstd/sys_common/backtrace.rs:47
3: std::sys_common::backtrace::print
at src/libstd/sys_common/backtrace.rs:36
4: std::panicking::default_hook::{{closure}}
at src/libstd/panicking.rs:200
5: std::panicking::default_hook
at src/libstd/panicking.rs:214
6: rustc::util::common::panic_hook
7: std::panicking::rust_panic_with_hook
at src/libstd/panicking.rs:481
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: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports
note: rustc 1.38.0 (625451e37 2019-09-23) running on x86_64-unknown-linux-gnu
note: compiler flags: --crate-type lib
Metadata
Metadata
Assignees
Labels
Area: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.Area: Trait systemCategory: This is a bug.Call for participation: An issue has been fixed and does not reproduce, but no test has been added.Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️High priorityRelevant to the compiler team, which will review and decide on the PR/issue.ICE tracked in rust-lang/glacier.