Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

ICE: associated type missing default #129216

Closed
matthiaskrgr opened this issue Aug 17, 2024 · 0 comments · Fixed by #129250
Closed

ICE: associated type missing default #129216

matthiaskrgr opened this issue Aug 17, 2024 · 0 comments · Fixed by #129250
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ S-bug-has-test Status: This bug is tracked inside the repo by a `known-bug` test. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@matthiaskrgr
Copy link
Member

auto-reduced (treereduce-rust):

trait Mirror {
    type Assoc;
}

struct Foo;

fn main() {
    <Foo as Mirror>::Assoc::new();
}

original:

// Check that we if we get ahold of an object unsafe trait
//@ check-pass

trait Mirror {
    type Assoc;
}
impl Priv<Pub> {
        pub fn f(arg: Priv) {} // OK
    }

struct Foo;
impl Foo {
    fn new() -> Self { Foo }
}

fn main() {
    <Foo as Mirror>::Assoc::new();
}

Version information

rustc 1.82.0-nightly (0f26ee4fd 2024-08-17)
binary: rustc
commit-hash: 0f26ee4fd95a1c046582dfb18892f520788e2c2c
commit-date: 2024-08-17
host: x86_64-unknown-linux-gnu
release: 1.82.0-nightly
LLVM version: 19.1.0

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc

Program output

error: internal compiler error: compiler/rustc_hir_analysis/src/collect/type_of.rs:451:17: associated type missing default
 --> /tmp/icemaker_global_tempdir.thuP8tncCjle/rustc_testrunner_tmpdir_reporting.6TKvJE1HmZsD/mvce.rs:2:5
  |
2 |     type Assoc;
  |     ^^^^^^^^^^^

thread 'rustc' panicked at compiler/rustc_hir_analysis/src/collect/type_of.rs:451:17:
Box<dyn Any>
stack backtrace:
   0:     0x7ebe535c429d - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::hce35dec2bed7e8e1
   1:     0x7ebe53e05297 - core::fmt::write::haaf8a728f3019c12
   2:     0x7ebe550bbd91 - std::io::Write::write_fmt::hb0dc5188703aea0d
   3:     0x7ebe535c697b - std::panicking::default_hook::{{closure}}::h35c501ae74c82675
   4:     0x7ebe535c65ee - std::panicking::default_hook::hc1ddd62643c4c855
   5:     0x7ebe52758729 - std[54b021f941472252]::panicking::update_hook::<alloc[8840b3d3a55bb7af]::boxed::Box<rustc_driver_impl[ec4d44b725e7aa11]::install_ice_hook::{closure#0}>>::{closure#0}
   6:     0x7ebe535c7297 - std::panicking::rust_panic_with_hook::h7960ad04eaeb646d
   7:     0x7ebe52793111 - std[54b021f941472252]::panicking::begin_panic::<rustc_errors[2e519a482e3c741a]::ExplicitBug>::{closure#0}
   8:     0x7ebe52786156 - std[54b021f941472252]::sys::backtrace::__rust_end_short_backtrace::<std[54b021f941472252]::panicking::begin_panic<rustc_errors[2e519a482e3c741a]::ExplicitBug>::{closure#0}, !>
   9:     0x7ebe52781536 - std[54b021f941472252]::panicking::begin_panic::<rustc_errors[2e519a482e3c741a]::ExplicitBug>
  10:     0x7ebe5279c0f1 - <rustc_errors[2e519a482e3c741a]::diagnostic::BugAbort as rustc_errors[2e519a482e3c741a]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
  11:     0x7ebe52820b1f - <rustc_errors[2e519a482e3c741a]::DiagCtxtHandle>::span_bug::<rustc_span[a5a4c6b08f7cf6f]::span_encoding::Span, alloc[8840b3d3a55bb7af]::string::String>
  12:     0x7ebe52881528 - rustc_middle[10ec7aec7d9fdda3]::util::bug::opt_span_bug_fmt::<rustc_span[a5a4c6b08f7cf6f]::span_encoding::Span>::{closure#0}
  13:     0x7ebe5288525a - rustc_middle[10ec7aec7d9fdda3]::ty::context::tls::with_opt::<rustc_middle[10ec7aec7d9fdda3]::util::bug::opt_span_bug_fmt<rustc_span[a5a4c6b08f7cf6f]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  14:     0x7ebe52848f9b - rustc_middle[10ec7aec7d9fdda3]::ty::context::tls::with_context_opt::<rustc_middle[10ec7aec7d9fdda3]::ty::context::tls::with_opt<rustc_middle[10ec7aec7d9fdda3]::util::bug::opt_span_bug_fmt<rustc_span[a5a4c6b08f7cf6f]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  15:     0x7ebe52848807 - rustc_middle[10ec7aec7d9fdda3]::util::bug::span_bug_fmt::<rustc_span[a5a4c6b08f7cf6f]::span_encoding::Span>
  16:     0x7ebe5147fba4 - rustc_hir_analysis[c0d9d1e917b71b24]::collect::type_of::type_of
  17:     0x7ebe53e271f0 - rustc_query_impl[69287ea093d06d1d]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[69287ea093d06d1d]::query_impl::type_of::dynamic_query::{closure#2}::{closure#0}, rustc_middle[10ec7aec7d9fdda3]::query::erase::Erased<[u8; 8usize]>>
  18:     0x7ebe53e25ea7 - rustc_query_system[1449707d44461b06]::query::plumbing::try_execute_query::<rustc_query_impl[69287ea093d06d1d]::DynamicConfig<rustc_query_system[1449707d44461b06]::query::caches::DefIdCache<rustc_middle[10ec7aec7d9fdda3]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[69287ea093d06d1d]::plumbing::QueryCtxt, false>
  19:     0x7ebe53e25a67 - rustc_query_impl[69287ea093d06d1d]::query_impl::type_of::get_query_non_incr::__rust_end_short_backtrace
  20:     0x7ebe542f4751 - rustc_middle[10ec7aec7d9fdda3]::query::plumbing::query_get_at::<rustc_query_system[1449707d44461b06]::query::caches::DefIdCache<rustc_middle[10ec7aec7d9fdda3]::query::erase::Erased<[u8; 8usize]>>>
  21:     0x7ebe52a9e0f3 - <rustc_hir_typeck[cd6451a3b3fe12c4]::fn_ctxt::FnCtxt>::suggest_traits_to_import
  22:     0x7ebe52a8b20a - <rustc_hir_typeck[cd6451a3b3fe12c4]::fn_ctxt::FnCtxt>::report_no_match_method_error
  23:     0x7ebe52abf32a - <rustc_hir_typeck[cd6451a3b3fe12c4]::fn_ctxt::FnCtxt>::report_method_error
  24:     0x7ebe5480e190 - <rustc_hir_typeck[cd6451a3b3fe12c4]::fn_ctxt::FnCtxt>::check_expr_path
  25:     0x7ebe54900058 - <rustc_hir_typeck[cd6451a3b3fe12c4]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  26:     0x7ebe5490178d - <rustc_hir_typeck[cd6451a3b3fe12c4]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  27:     0x7ebe548fad7d - <rustc_hir_typeck[cd6451a3b3fe12c4]::fn_ctxt::FnCtxt>::check_block_with_expected
  28:     0x7ebe54902247 - <rustc_hir_typeck[cd6451a3b3fe12c4]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  29:     0x7ebe54043661 - rustc_hir_typeck[cd6451a3b3fe12c4]::check::check_fn
  30:     0x7ebe545fbf1f - rustc_hir_typeck[cd6451a3b3fe12c4]::typeck
  31:     0x7ebe545fb975 - rustc_query_impl[69287ea093d06d1d]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[69287ea093d06d1d]::query_impl::typeck::dynamic_query::{closure#2}::{closure#0}, rustc_middle[10ec7aec7d9fdda3]::query::erase::Erased<[u8; 8usize]>>
  32:     0x7ebe540d4bf9 - rustc_query_system[1449707d44461b06]::query::plumbing::try_execute_query::<rustc_query_impl[69287ea093d06d1d]::DynamicConfig<rustc_query_system[1449707d44461b06]::query::caches::VecCache<rustc_span[a5a4c6b08f7cf6f]::def_id::LocalDefId, rustc_middle[10ec7aec7d9fdda3]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[69287ea093d06d1d]::plumbing::QueryCtxt, false>
  33:     0x7ebe540d3e15 - rustc_query_impl[69287ea093d06d1d]::query_impl::typeck::get_query_non_incr::__rust_end_short_backtrace
  34:     0x7ebe540d3a9b - <rustc_middle[10ec7aec7d9fdda3]::hir::map::Map>::par_body_owners::<rustc_hir_analysis[c0d9d1e917b71b24]::check_crate::{closure#4}>::{closure#0}
  35:     0x7ebe540d17e4 - rustc_hir_analysis[c0d9d1e917b71b24]::check_crate
  36:     0x7ebe54584cbf - rustc_interface[f40e7651e6b02ea1]::passes::run_required_analyses
  37:     0x7ebe5495c49e - rustc_interface[f40e7651e6b02ea1]::passes::analysis
  38:     0x7ebe5495c471 - rustc_query_impl[69287ea093d06d1d]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[69287ea093d06d1d]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[10ec7aec7d9fdda3]::query::erase::Erased<[u8; 1usize]>>
  39:     0x7ebe54d867ee - rustc_query_system[1449707d44461b06]::query::plumbing::try_execute_query::<rustc_query_impl[69287ea093d06d1d]::DynamicConfig<rustc_query_system[1449707d44461b06]::query::caches::SingleCache<rustc_middle[10ec7aec7d9fdda3]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[69287ea093d06d1d]::plumbing::QueryCtxt, false>
  40:     0x7ebe54d8654f - rustc_query_impl[69287ea093d06d1d]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  41:     0x7ebe54bd38ea - rustc_interface[f40e7651e6b02ea1]::interface::run_compiler::<core[5070cb7ec77c977]::result::Result<(), rustc_span[a5a4c6b08f7cf6f]::ErrorGuaranteed>, rustc_driver_impl[ec4d44b725e7aa11]::run_compiler::{closure#0}>::{closure#1}
  42:     0x7ebe54bb3210 - std[54b021f941472252]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[f40e7651e6b02ea1]::util::run_in_thread_with_globals<rustc_interface[f40e7651e6b02ea1]::util::run_in_thread_pool_with_globals<rustc_interface[f40e7651e6b02ea1]::interface::run_compiler<core[5070cb7ec77c977]::result::Result<(), rustc_span[a5a4c6b08f7cf6f]::ErrorGuaranteed>, rustc_driver_impl[ec4d44b725e7aa11]::run_compiler::{closure#0}>::{closure#1}, core[5070cb7ec77c977]::result::Result<(), rustc_span[a5a4c6b08f7cf6f]::ErrorGuaranteed>>::{closure#0}, core[5070cb7ec77c977]::result::Result<(), rustc_span[a5a4c6b08f7cf6f]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[5070cb7ec77c977]::result::Result<(), rustc_span[a5a4c6b08f7cf6f]::ErrorGuaranteed>>
  43:     0x7ebe54bb387a - <<std[54b021f941472252]::thread::Builder>::spawn_unchecked_<rustc_interface[f40e7651e6b02ea1]::util::run_in_thread_with_globals<rustc_interface[f40e7651e6b02ea1]::util::run_in_thread_pool_with_globals<rustc_interface[f40e7651e6b02ea1]::interface::run_compiler<core[5070cb7ec77c977]::result::Result<(), rustc_span[a5a4c6b08f7cf6f]::ErrorGuaranteed>, rustc_driver_impl[ec4d44b725e7aa11]::run_compiler::{closure#0}>::{closure#1}, core[5070cb7ec77c977]::result::Result<(), rustc_span[a5a4c6b08f7cf6f]::ErrorGuaranteed>>::{closure#0}, core[5070cb7ec77c977]::result::Result<(), rustc_span[a5a4c6b08f7cf6f]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[5070cb7ec77c977]::result::Result<(), rustc_span[a5a4c6b08f7cf6f]::ErrorGuaranteed>>::{closure#1} as core[5070cb7ec77c977]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  44:     0x7ebe54bb3beb - std::sys::pal::unix::thread::Thread::new::thread_start::he8fde62ed04f9a93
  45:     0x7ebe5635e39d - <unknown>
  46:     0x7ebe563e349c - <unknown>
  47:                0x0 - <unknown>

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: please make sure that you have updated to the latest nightly

note: rustc 1.82.0-nightly (0f26ee4fd 2024-08-17) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [type_of] computing type of `Mirror::Assoc`
#1 [typeck] type-checking `main`
end of query stack
error: aborting due to 1 previous error


@matthiaskrgr matthiaskrgr added I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. C-bug Category: This is a bug. labels Aug 17, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Aug 17, 2024
@saethlin saethlin removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Aug 20, 2024
@matthiaskrgr matthiaskrgr added the S-bug-has-test Status: This bug is tracked inside the repo by a `known-bug` test. label Aug 25, 2024
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Aug 26, 2024
…errors

Do not ICE on non-ADT rcvr type when looking for crate version collision

When looking for multiple versions of the same crate, do not blindly construct the receiver type.

Follow up to rust-lang#128786.
Fixes rust-lang#129205
Fixes rust-lang#129216
@bors bors closed this as completed in d4d4b6b Aug 27, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Aug 27, 2024
Rollup merge of rust-lang#129250 - estebank:issue-129205, r=compiler-errors

Do not ICE on non-ADT rcvr type when looking for crate version collision

When looking for multiple versions of the same crate, do not blindly construct the receiver type.

Follow up to rust-lang#128786.
Fixes rust-lang#129205
Fixes rust-lang#129216
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ S-bug-has-test Status: This bug is tracked inside the repo by a `known-bug` test. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants