Closed
Description
A function that returns an associated struct tuple such as that starts with Self::
such as Self::Type(0)
causes a panic.
This lib.rs
gives a panic in rustc 1.15.0-nightly
.
pub trait Trait {
type Type;
fn get(&self) -> Self::Type;
}
pub struct Struct (usize);
impl Trait for Struct {
type Type = Struct;
fn get(&self) -> Self::Type {
Self::Type(0)
}
}
$ RUST_BACKTRACE=1 cargo build --verbose
Compiling bug v0.1.0 (file:///home/oever/src/bug)
Running `rustc src/lib.rs --crate-name bug --crate-type lib -g -C metadata=0262005d8de49048 --out-dir /home/oever/src/bug/target/debug/deps --emit=dep-info,link -L dependency=/home/oever/src/bug/target/debug/deps`
error: internal compiler error: src/librustc_typeck/check/mod.rs:4379: unexpected definition: AssociatedTy(DefId { krate: CrateNum(0), node: DefIndex(5) => bug/5baa2d6ec3a2d3d06eef63d5c6fc5cad::Trait[0]::Type[0] })
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: run with `RUST_BACKTRACE=1` for a backtrace
thread 'rustc' panicked at 'Box<Any>', src/librustc_errors/lib.rs:424
stack backtrace:
1: 0x7f529c62da4a - std::sys::imp::backtrace::tracing::imp::write::h944c02ac40aee2d7
2: 0x7f529c63c9df - std::panicking::default_hook::{{closure}}::h6875a2976258b020
3: 0x7f529c63c57d - std::panicking::default_hook::h88ffbc5922643264
4: 0x7f529c63ce87 - std::panicking::rust_panic_with_hook::ha5aed1dfc0e220e3
5: 0x7f52981fb47a - std::panicking::begin_panic::h264cdc75d51b518b
6: 0x7f529820c08d - rustc_errors::Handler::bug::h620f7270292f0095
7: 0x7f52999fcee1 - rustc::session::opt_span_bug_fmt::{{closure}}::h4a9b70c3df8b4b3a
8: 0x7f52999fccfe - rustc::session::opt_span_bug_fmt::h7d83586c6e2c7ae6
9: 0x7f52999fc962 - rustc::session::bug_fmt::he2d2f00a4afa9d1e
10: 0x7f529ab2c039 - rustc_typeck::check::FnCtxt::instantiate_value_path::h4229ac945aebfa55
11: 0x7f529ab1b96f - rustc_typeck::check::FnCtxt::check_expr_kind::hfeeca7568cc99087
12: 0x7f529ab18d62 - rustc_typeck::check::FnCtxt::check_expr_with_expectation_and_lvalue_pref::h5d7f5141d7386bb8
13: 0x7f529aaeac74 - rustc_typeck::check::callee::<impl rustc_typeck::check::FnCtxt<'a, 'gcx, 'tcx>>::check_call::h762a25d0c9a1f5b4
14: 0x7f529ab19eff - rustc_typeck::check::FnCtxt::check_expr_kind::hfeeca7568cc99087
15: 0x7f529ab18d62 - rustc_typeck::check::FnCtxt::check_expr_with_expectation_and_lvalue_pref::h5d7f5141d7386bb8
16: 0x7f529ab2acfe - rustc_typeck::check::FnCtxt::check_block_with_expected::he90dd72b6855e5e4
17: 0x7f529ab19218 - rustc_typeck::check::FnCtxt::check_expr_kind::hfeeca7568cc99087
18: 0x7f529ab18d62 - rustc_typeck::check::FnCtxt::check_expr_with_expectation_and_lvalue_pref::h5d7f5141d7386bb8
19: 0x7f529ab00087 - rustc_typeck::check::check_fn::h96bd864b4d4fc711
20: 0x7f529aafec5b - rustc_typeck::check::check_bare_fn::heb8c1cdb84569c5e
21: 0x7f529ab01a2d - rustc_typeck::check::check_item_body::h1e039ede2f960fb9
22: 0x7f529aafc52d - rustc_typeck::check::check_item_bodies::hd22adb7703cc56d7
23: 0x7f529ab63202 - rustc_typeck::check_crate::h4045752b69a796e8
24: 0x7f529c9dda6e - rustc_driver::driver::phase_3_run_analysis_passes::{{closure}}::h97a3a12d948df547
25: 0x7f529c955019 - rustc::ty::context::TyCtxt::create_and_enter::hdbe8789e1b639eb8
26: 0x7f529c9c6c55 - rustc_driver::driver::compile_input::h8e119234b60571d5
27: 0x7f529ca081e8 - rustc_driver::run_compiler::hbdfc4f84e2e0f4b9
28: 0x7f529c923418 - std::panicking::try::do_call::hf679f17bf3b43b0b
29: 0x7f529c64563a - __rust_maybe_catch_panic
30: 0x7f529c9452d8 - <F as alloc::boxed::FnBox<A>>::call_box::h506fb5d7b8891cd4
31: 0x7f529c63b844 - std::sys::imp::thread::Thread::new::thread_start::h8084b1107992ae5b
32: 0x7f52979a41f3 - start_thread
33: 0x7f529c30312e - __GI___clone
34: 0x0 - <unknown>
error: Could not compile `bug`.
Caused by:
process didn't exit successfully: `rustc src/lib.rs --crate-name bug --crate-type lib -g -C metadata=0262005d8de49048 --out-dir /home/oever/src/bug/target/debug/deps --emit=dep-info,link -L dependency=/home/oever/src/bug/target/debug/deps` (exit code: 101)