Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

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

Closed
sinkuu opened this issue Feb 4, 2017 · 2 comments
Closed

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

sinkuu opened this issue Feb 4, 2017 · 2 comments
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@sinkuu
Copy link
Contributor

sinkuu commented Feb 4, 2017

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>
@petrochenkov
Copy link
Contributor

Regression from #38920.
I'll investigate.

@Rufflewind
Copy link
Contributor

Ran into this as well, but when using an auxiliary trait parameter.

Seems to affect nightly and beta, but not stable.

use std::ops::Add;

struct Trivial;

impl Add<Self::Output> for Trivial {
      // ^^^^^^^^^^^^ rustc really hates this
    type Output = Trivial;
    fn add(self, _: Trivial) -> Trivial { self }
}

fn main() {}

Run this on the Rust Playground

Crash log
error: internal compiler error: /checkout/src/librustc/ty/mod.rs:1896: No def'n found for DefId { krate: CrateNum(0), node: DefIndex(6) => test/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

note: run with `RUST_BACKTRACE=1` for a backtrace

thread 'rustc' panicked at 'Box<Any>', /checkout/src/librustc_errors/lib.rs:417
stack backtrace:
   1:     0x7f81a8a24c59 - std::sys::imp::backtrace::tracing::imp::write::hbb14611794d3841b
                        at /checkout/src/libstd/sys/unix/backtrace/tracing/gcc_s.rs:42
   2:     0x7f81a8a332fe - std::panicking::default_hook::{{closure}}::h6ed906c7818ac88c
                        at /checkout/src/libstd/panicking.rs:351
   3:     0x7f81a8a32ea4 - std::panicking::default_hook::h23eeafbf7c1c05c3
                        at /checkout/src/libstd/panicking.rs:361
   4:     0x7f81a8a3375b - std::panicking::rust_panic_with_hook::hd0067971b6d1240e
                        at /checkout/src/libstd/panicking.rs:545
   5:     0x7f81a1076d27 - std::panicking::begin_panic::hc300cc1c3c24c382
   6:     0x7f81a108c32d - rustc_errors::Handler::bug::h86684df8c5f40d57
   7:     0x7f81a5b8192a - rustc::session::opt_span_bug_fmt::{{closure}}::h3ad09996f9e31eb1
   8:     0x7f81a5b81737 - rustc::session::opt_span_bug_fmt::h4b0bb8c3e1670f11
   9:     0x7f81a5b81392 - rustc::session::bug_fmt::h2dbe8dc3b71c81a2
  10:     0x7f81a5c0ed99 - rustc::ty::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::impl_trait_ref::h900e5b606ada5d7b
  11:     0x7f81a6266e0b - <rustc_typeck::astconv::AstConv<'gcx, 'tcx> + 'o>::associated_path_def_to_ty::hf76c72c0ac489aae
  12:     0x7f81a6269e41 - <rustc_typeck::astconv::AstConv<'gcx, 'tcx> + 'o>::ast_ty_to_ty::h9ff30c990d450a79
  13:     0x7f81a625d0b1 - <rustc_typeck::astconv::AstConv<'gcx, 'tcx> + 'o>::create_substs_for_ast_path::{{closure}}::hd03791d22bb2421e
  14:     0x7f81a618e72d - rustc::ty::subst::<impl rustc::ty::Slice<rustc::ty::subst::Kind<'tcx>>>::fill_item::h237a29bcbae752fb
  15:     0x7f81a625cbd5 - <rustc_typeck::astconv::AstConv<'gcx, 'tcx> + 'o>::create_substs_for_ast_path::h82a4170662063c25
  16:     0x7f81a626076f - <rustc_typeck::astconv::AstConv<'gcx, 'tcx> + 'o>::create_substs_for_ast_trait_ref::h5a9d38af4735e350
  17:     0x7f81a6260478 - <rustc_typeck::astconv::AstConv<'gcx, 'tcx> + 'o>::ast_path_to_mono_trait_ref::h948d3ba9dce820dc
  18:     0x7f81a626da82 - <rustc_typeck::collect::CollectItemTypesVisitor<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_item::h1ab3f3fbeb8eecde
  19:     0x7f81a626cc42 - rustc_typeck::collect::collect_item_types::h62789b6036667a93
  20:     0x7f81a6294719 - rustc_typeck::check_crate::h441df7c8151905be
  21:     0x7f81a8dcec44 - rustc_driver::driver::phase_3_run_analysis_passes::{{closure}}::h7d2a6da150c7eba7
  22:     0x7f81a8dc61fd - rustc_driver::driver::phase_3_run_analysis_passes::hb4049a05b492319a
  23:     0x7f81a8daea03 - rustc_driver::driver::compile_input::hf3e3aa4173908b86
  24:     0x7f81a8df998d - rustc_driver::run_compiler::h8f8d47f1d258a8a6
  25:     0x7f81a8d068ab - std::panicking::try::do_call::h206b9daee04f4ea2
  26:     0x7f81a8a3c60a - __rust_maybe_catch_panic
                        at /checkout/src/libpanic_unwind/lib.rs:98
  27:     0x7f81a8d2ec42 - <F as alloc::boxed::FnBox<A>>::call_box::h5d196fbb3229f499
  28:     0x7f81a8a32144 - std::sys::imp::thread::Thread::new::thread_start::h2c901daa88f3cb32
                        at /checkout/src/liballoc/boxed.rs:648
                        at /checkout/src/libstd/sys_common/thread.rs:21
                        at /checkout/src/libstd/sys/unix/thread.rs:84
  29:     0x7f81a0821453 - start_thread
  30:     0x7f81a86f27de - __GI___clone
  31:                0x0 - <unknown>

@sfackler sfackler added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label Feb 18, 2017
bors added a commit that referenced this issue Feb 19, 2017
Fix two ICEs in path resolution

Fixes #39535
Fixes #39559
Fixes #39924

r? @eddyb
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

No branches or pull requests

4 participants