Skip to content

ICE when referencing associated type via Self in where clauses #39535

Closed
@sinkuu

Description

@sinkuu

rustc hit an ICE when Self::Foo is used in where clauses.

I tried this code:

trait Foo {
}

impl<T> Foo for T where Self::X: Clone {
}

fn main() {
}

I expected to see this happen: Compilation failure.

Instead, this happened: rustc panicked.

error: `Self` type is used before it's determined
 --> test2.rs:4:25
  |
4 | impl<T> Foo for T where Self::X: Clone {
  |                         ^^^^^^^

error: internal compiler error: /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/librustc/ty/mod.rs:1849: No def'n found for DefId { krate: CrateNum(0), node: DefIndex(4) => test2/4089d7c8b778d88cec885baf7b69e6df-exe::{{impl}}[0] } in tcx.impl_trait_refs

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

thread 'rustc' panicked at 'Box<Any>', /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/librustc_errors/lib.rs:416

Meta

rustc --version --verbose:

rustc 1.16.0-nightly (eedaa94e3 2017-02-02)
binary: rustc
commit-hash: eedaa94e330094a84f4df9aa52949515327f8e80
commit-date: 2017-02-02
host: x86_64-unknown-linux-gnu
release: 1.16.0-nightly
LLVM version: 3.9

Backtrace:

   1:     0x7fecfaaf045c - std::sys::imp::backtrace::tracing::imp::write::hf7294f5e24536b4a
                        at /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libstd/sys/unix/backtrace/tracing/gcc_s.rs:42
   2:     0x7fecfaafe90e - std::panicking::default_hook::{{closure}}::h9a07d0b00c43fbee
                        at /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libstd/panicking.rs:351
   3:     0x7fecfaafe4b3 - std::panicking::default_hook::hf25feff2d08bf39b
                        at /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libstd/panicking.rs:361
   4:     0x7fecfaafedab - std::panicking::rust_panic_with_hook::h4cb8c6fbb8386ccf
                        at /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libstd/panicking.rs:555
   5:     0x7fecf3139e37 - std::panicking::begin_panic::h133cfd00382ed92d
   6:     0x7fecf314f51d - rustc_errors::Handler::bug::h0c95eedc3adddeaa
   7:     0x7fecf7c4c10a - rustc::session::opt_span_bug_fmt::{{closure}}::hb77f1c2804eeb101
   8:     0x7fecf7c4bbc5 - rustc::session::opt_span_bug_fmt::h6020528146c503fb
   9:     0x7fecf7c4b822 - rustc::session::bug_fmt::h80c5b006234b3146
  10:     0x7fecf7cd77e9 - rustc::ty::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::impl_trait_ref::h723a544ccabfefd1
  11:     0x7fecf95599ba - <rustc_typeck::astconv::AstConv<'gcx, 'tcx> + 'o>::associated_path_def_to_ty::hcd3a1d566461deb3
  12:     0x7fecf955cbcc - <rustc_typeck::astconv::AstConv<'gcx, 'tcx> + 'o>::ast_ty_to_ty::hf1f13e8dab321530
  13:     0x7fecf956dbcc - rustc_typeck::collect::ty_generic_predicates::h508a0ee6976b8127
  14:     0x7fecf95602e6 - <rustc_typeck::collect::CollectItemTypesVisitor<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_item::h30daff41f9f84591
  15:     0x7fecf955f762 - rustc_typeck::collect::collect_item_types::h5bfa53ea89c0f123
  16:     0x7fecf95872a9 - rustc_typeck::check_crate::h06f4ceb61c7f6528
  17:     0x7fecfae9cf27 - rustc_driver::driver::phase_3_run_analysis_passes::{{closure}}::h074ad5edbf4a7db7
  18:     0x7fecfae8f356 - rustc_driver::driver::phase_3_run_analysis_passes::h380fa931cb354859
  19:     0x7fecfae7d160 - rustc_driver::driver::compile_input::hab977ae496b3a6f1
  20:     0x7fecfaec7a94 - rustc_driver::run_compiler::h81290683db66a63c
  21:     0x7fecfadd3ebb - std::panicking::try::do_call::h00942d7a5d04424f
  22:     0x7fecfab07bea - __rust_maybe_catch_panic
                        at /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libpanic_unwind/lib.rs:98
  23:     0x7fecfadfc122 - <F as alloc::boxed::FnBox<A>>::call_box::hd87f7ab2fccbd670
  24:     0x7fecfaafd764 - std::sys::imp::thread::Thread::new::thread_start::hc16926852e47c008
                        at /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/liballoc/boxed.rs:624
                        at /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libstd/sys_common/thread.rs:21
                        at /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libstd/sys/unix/thread.rs:84
  25:     0x7fecf28e4453 - start_thread
  26:     0x7fecfa7c07de - __GI___clone
  27:                0x0 - <unknown>

Metadata

Metadata

Assignees

No one assigned

    Labels

    I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions