Skip to content

ICE on HRTB containing Associated Types #36694

Closed
@djzin

Description

@djzin

Was messing with associated types & lifetimes when the compiler panicked. Reproduces on stable, beta & nightly.

Note: seems similar to #34430 and #36381

trait Assoc<'a> {
    type Type;
}

impl<'a> Assoc<'a> for () {
    type Type = &'a ();
}

fn check_bounds<F>(_: F)
where F: for<'a> Fn(<() as Assoc<'a>>::Type)
{}

fn f<'a>(_: <() as Assoc<'a>>::Type) {}

fn main() {
    check_bounds(f);
}

The error does not reproduce with an equivalent closure. Again, interestingly, replacing the function f with fn f<'a>(_: &'a ()) {} fails to compile, even though it seems to name the same type.

Backtrace:

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: run with `RUST_BACKTRACE=1` for a backtrace
thread 'rustc' panicked at 'assertion failed: concrete_substs.is_normalized_for_trans()', ../src/librustc_trans/collector.rs:996
stack backtrace:
   1:     0x7f4ecf561e2f - std::sys::backtrace::tracing::imp::write::h46e546df6e4e4fe6
   2:     0x7f4ecf57013b - std::panicking::default_hook::_$u7b$$u7b$closure$u7d$$u7d$::h077deeda8b799591
   3:     0x7f4ecf56fcd8 - std::panicking::default_hook::heb8b6fd640571a4f
   4:     0x7f4ecf535ade - std::panicking::rust_panic_with_hook::hd7b83626099d3416
   5:     0x7f4ece3f735f - std::panicking::begin_panic::hf17b963d1d3f11f5
   6:     0x7f4ece4c84ee - rustc_trans::collector::create_fn_trans_item::h8bd6268564719399
   7:     0x7f4ece4c8f05 - _<rustc_trans..collector..MirNeighborCollector<'a, 'tcx> as rustc..mir..visit..Visitor<'tcx>>::visit_operand::hf8c3e75b85fa0b1f
   8:     0x7f4ece4c7706 - _<rustc_trans..collector..MirNeighborCollector<'a, 'tcx> as rustc..mir..visit..Visitor<'tcx>>::visit_terminator_kind::he7778fd60c9a073c
   9:     0x7f4ece4c5ebe - rustc::mir::visit::Visitor::visit_mir::hb8bb80ce2712f8d9
  10:     0x7f4ece4bf7fa - rustc_trans::collector::collect_items_rec::h5050ec155a8ba230
  11:     0x7f4ece47fcf3 - rustc_trans::base::collect_and_partition_translation_items::_$u7b$$u7b$closure$u7d$$u7d$::h4262b1b51d73b2b4
  12:     0x7f4ece46ce19 - rustc_trans::base::trans_crate::h75826f6271b49faf
  13:     0x7f4ecfab607f - rustc_driver::driver::phase_4_translate_to_llvm::hbc7e9672529bb439
  14:     0x7f4ecfab306c - rustc_driver::driver::compile_input::_$u7b$$u7b$closure$u7d$$u7d$::h7168080c5b7e33b9
  15:     0x7f4ecfaaf77d - rustc_driver::driver::phase_3_run_analysis_passes::_$u7b$$u7b$closure$u7d$$u7d$::hded790081e457a76
  16:     0x7f4ecfaa8f49 - rustc::ty::context::TyCtxt::create_and_enter::h7622c0f52ea2e7fe
  17:     0x7f4ecfa6680f - rustc_driver::driver::compile_input::hdfe4405d66704c31
  18:     0x7f4ecfa52f44 - rustc_driver::run_compiler::h581448fb74257353
  19:     0x7f4ecfa5004e - std::panicking::try::call::hf081e8ea5e252d1a
  20:     0x7f4ecf57e63b - __rust_try
  21:     0x7f4ecf57e5de - __rust_maybe_catch_panic
  22:     0x7f4ecfa50b34 - _<F as alloc..boxed..FnBox<A>>::call_box::h2d5dcb354b3ff8db
  23:     0x7f4ecf56e264 - std::sys::thread::Thread::new::thread_start::hf2eed4b6f7149599
  24:     0x7f4ec77d36f9 - start_thread
  25:     0x7f4ecf1b0b5c - clone
  26:                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