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 when missing trait bound in peculiar case #138214

Open
konnorandrews opened this issue Mar 8, 2025 · 0 comments
Open

ICE when missing trait bound in peculiar case #138214

konnorandrews opened this issue Mar 8, 2025 · 0 comments
Labels
C-bug Category: This is a bug. fixed-by-next-solver Fixed by the next-generation trait solver, `-Znext-solver`. 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. T-types Relevant to the types team, which will review and decide on the PR/issue.

Comments

@konnorandrews
Copy link

Code

struct Demo<X, Y: A = X, Z = <<Y as A>::U as B>::V>(X, Y, Z);

impl<V> Demo<V> {
    fn new() {}
}

pub trait A<Group = ()> {
    type U: B;
}

pub trait B {
    type V;
}

Meta

rustc --version --verbose:

rustc 1.85.0 (4d91de4e4 2025-02-17)
binary: rustc
commit-hash: 4d91de4e48198da2e33413efdcd9cd2cc0c46688
commit-date: 2025-02-17
host: x86_64-unknown-linux-gnu
release: 1.85.0
LLVM version: 19.1.7

Also happens on beta and nightly. Running with -Znext-solver does not have the ICE (the error is kept as expected). May be related to #133868.

Error output

error[E0277]: the trait bound `V: A` is not satisfied
 --> src/lib.rs:3:9
  |
3 | impl<V> Demo<V> {
  |         ^^^^^^^ the trait `A` is not implemented for `V`
  |
help: consider restricting type parameter `V` with trait `A`
  |
3 | impl<V: A> Demo<V> {
  |       +++

error: internal compiler error: compiler/rustc_trait_selection/src/traits/normalize.rs:69:17: deeply_normalize should not be called with pending obligations: [
                                    Obligation(predicate=Binder { value: ProjectionPredicate(AliasTerm { args: [?0t], def_id: DefId(0:18 ~ playground[465c]::B::V), .. }, Term::Ty(?1t)), bound_vars: [] }, depth=1),
                                ]
 --> src/lib.rs:3:9
  |
3 | impl<V> Demo<V> {
  |         ^^^^^^^
Backtrace

thread 'rustc' panicked at compiler/rustc_trait_selection/src/traits/normalize.rs:69:17:
Box<dyn Any>
stack backtrace:
   0:     0x78ca309cb634 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::hc366073dd4ba6a4f
   1:     0x78ca31205aa2 - core::fmt::write::hb9256d1d79ff6859
   2:     0x78ca3259ddd1 - std::io::Write::write_fmt::hd9a4a51e43d6ab68
   3:     0x78ca309cb492 - std::sys::backtrace::BacktraceLock::print::h81b51ca9905b58b8
   4:     0x78ca309cdd72 - std::panicking::default_hook::{{closure}}::h800cff087746fb32
   5:     0x78ca309cd964 - std::panicking::default_hook::h8e77302320466097
   6:     0x78ca2fb24177 - std[7d1496126c658a52]::panicking::update_hook::<alloc[b94a15b63fd00bf8]::boxed::Box<rustc_driver_impl[95ea3323f115095d]::install_ice_hook::{closure#1}>>::{closure#0}
   7:     0x78ca309ce5e3 - std::panicking::rust_panic_with_hook::hf2880f219899d673
   8:     0x78ca2fb60541 - std[7d1496126c658a52]::panicking::begin_panic::<rustc_errors[25a204b9d9cca0a9]::ExplicitBug>::{closure#0}
   9:     0x78ca2fb54a76 - std[7d1496126c658a52]::sys::backtrace::__rust_end_short_backtrace::<std[7d1496126c658a52]::panicking::begin_panic<rustc_errors[25a204b9d9cca0a9]::ExplicitBug>::{closure#0}, !>
  10:     0x78ca2fb54857 - std[7d1496126c658a52]::panicking::begin_panic::<rustc_errors[25a204b9d9cca0a9]::ExplicitBug>
  11:     0x78ca2fb69f41 - <rustc_errors[25a204b9d9cca0a9]::diagnostic::BugAbort as rustc_errors[25a204b9d9cca0a9]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
  12:     0x78ca300b9c0c - <rustc_errors[25a204b9d9cca0a9]::DiagCtxtHandle>::span_bug::<rustc_span[515292683a253d38]::span_encoding::Span, alloc[b94a15b63fd00bf8]::string::String>
  13:     0x78ca3014088a - rustc_middle[56e4ff076cda644b]::util::bug::opt_span_bug_fmt::<rustc_span[515292683a253d38]::span_encoding::Span>::{closure#0}
  14:     0x78ca3012838a - rustc_middle[56e4ff076cda644b]::ty::context::tls::with_opt::<rustc_middle[56e4ff076cda644b]::util::bug::opt_span_bug_fmt<rustc_span[515292683a253d38]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  15:     0x78ca301281fb - rustc_middle[56e4ff076cda644b]::ty::context::tls::with_context_opt::<rustc_middle[56e4ff076cda644b]::ty::context::tls::with_opt<rustc_middle[56e4ff076cda644b]::util::bug::opt_span_bug_fmt<rustc_span[515292683a253d38]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  16:     0x78ca2ea09267 - rustc_middle[56e4ff076cda644b]::util::bug::span_bug_fmt::<rustc_span[515292683a253d38]::span_encoding::Span>
  17:     0x78ca31609a4a - <rustc_trait_selection[635ca99423ce600e]::traits::engine::ObligationCtxt<rustc_trait_selection[635ca99423ce600e]::traits::FulfillmentError>>::assumed_wf_types_and_report_errors
  18:     0x78ca31a99d87 - rustc_hir_analysis[44a464fc9530b13d]::check::wfcheck::check_associated_item
  19:     0x78ca31974d57 - rustc_hir_analysis[44a464fc9530b13d]::check::wfcheck::check_well_formed
  20:     0x78ca3197338d - rustc_query_impl[ffcc3d1c9e8154f]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[ffcc3d1c9e8154f]::query_impl::check_well_formed::dynamic_query::{closure#2}::{closure#0}, rustc_middle[56e4ff076cda644b]::query::erase::Erased<[u8; 1usize]>>
  21:     0x78ca31972e44 - rustc_query_system[973ddc25b5c3187c]::query::plumbing::try_execute_query::<rustc_query_impl[ffcc3d1c9e8154f]::DynamicConfig<rustc_data_structures[16871ea2f26fa4bd]::vec_cache::VecCache<rustc_span[515292683a253d38]::def_id::LocalDefId, rustc_middle[56e4ff076cda644b]::query::erase::Erased<[u8; 1usize]>, rustc_query_system[973ddc25b5c3187c]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[ffcc3d1c9e8154f]::plumbing::QueryCtxt, false>
  22:     0x78ca319728ff - rustc_query_impl[ffcc3d1c9e8154f]::query_impl::check_well_formed::get_query_non_incr::__rust_end_short_backtrace
  23:     0x78ca31970218 - rustc_hir_analysis[44a464fc9530b13d]::check::wfcheck::check_mod_type_wf
  24:     0x78ca3196ff1f - rustc_query_impl[ffcc3d1c9e8154f]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[ffcc3d1c9e8154f]::query_impl::check_mod_type_wf::dynamic_query::{closure#2}::{closure#0}, rustc_middle[56e4ff076cda644b]::query::erase::Erased<[u8; 1usize]>>
  25:     0x78ca3229e856 - rustc_query_system[973ddc25b5c3187c]::query::plumbing::try_execute_query::<rustc_query_impl[ffcc3d1c9e8154f]::DynamicConfig<rustc_query_system[973ddc25b5c3187c]::query::caches::DefaultCache<rustc_span[515292683a253d38]::def_id::LocalModDefId, rustc_middle[56e4ff076cda644b]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[ffcc3d1c9e8154f]::plumbing::QueryCtxt, false>
  26:     0x78ca3229e5ff - rustc_query_impl[ffcc3d1c9e8154f]::query_impl::check_mod_type_wf::get_query_non_incr::__rust_end_short_backtrace
  27:     0x78ca3155c18f - rustc_hir_analysis[44a464fc9530b13d]::check_crate
  28:     0x78ca316754b2 - rustc_interface[307c5e6bd736cecc]::passes::run_required_analyses
  29:     0x78ca3218637a - rustc_interface[307c5e6bd736cecc]::passes::analysis
  30:     0x78ca32186359 - rustc_query_impl[ffcc3d1c9e8154f]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[ffcc3d1c9e8154f]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[56e4ff076cda644b]::query::erase::Erased<[u8; 0usize]>>
  31:     0x78ca322bef0b - rustc_query_system[973ddc25b5c3187c]::query::plumbing::try_execute_query::<rustc_query_impl[ffcc3d1c9e8154f]::DynamicConfig<rustc_query_system[973ddc25b5c3187c]::query::caches::SingleCache<rustc_middle[56e4ff076cda644b]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[ffcc3d1c9e8154f]::plumbing::QueryCtxt, false>
  32:     0x78ca322bebf9 - rustc_query_impl[ffcc3d1c9e8154f]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  33:     0x78ca3231623d - rustc_interface[307c5e6bd736cecc]::passes::create_and_enter_global_ctxt::<core[2ed51ce221d9613e]::option::Option<rustc_interface[307c5e6bd736cecc]::queries::Linker>, rustc_driver_impl[95ea3323f115095d]::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}
  34:     0x78ca32306160 - rustc_interface[307c5e6bd736cecc]::interface::run_compiler::<(), rustc_driver_impl[95ea3323f115095d]::run_compiler::{closure#0}>::{closure#1}
  35:     0x78ca32194588 - std[7d1496126c658a52]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[307c5e6bd736cecc]::util::run_in_thread_with_globals<rustc_interface[307c5e6bd736cecc]::util::run_in_thread_pool_with_globals<rustc_interface[307c5e6bd736cecc]::interface::run_compiler<(), rustc_driver_impl[95ea3323f115095d]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  36:     0x78ca32194e74 - <<std[7d1496126c658a52]::thread::Builder>::spawn_unchecked_<rustc_interface[307c5e6bd736cecc]::util::run_in_thread_with_globals<rustc_interface[307c5e6bd736cecc]::util::run_in_thread_pool_with_globals<rustc_interface[307c5e6bd736cecc]::interface::run_compiler<(), rustc_driver_impl[95ea3323f115095d]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[2ed51ce221d9613e]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  37:     0x78ca32196277 - std::sys::pal::unix::thread::Thread::new::thread_start::h39d9c8bec2c62e1a
  38:     0x78ca33786a94 - <unknown>
  39:     0x78ca33813a34 - clone
  40:                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: please attach the file at `/playground/rustc-ice-2025-03-08T09_02_47-24.txt` to your bug report

note: compiler flags: --crate-type lib -C embed-bitcode=no -C codegen-units=1 -C debuginfo=2

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
#0 [check_well_formed] checking that `<impl at src/lib.rs:3:1: 3:16>::new` is well-formed
#1 [check_mod_type_wf] checking that types are well-formed in top-level module
... and 1 other queries... use `env RUST_BACKTRACE=1` to see the full query stack
For more information about this error, try `rustc --explain E0277`.

@konnorandrews konnorandrews added C-bug Category: This is a bug. 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. labels Mar 8, 2025
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Mar 8, 2025
@Noratrieb Noratrieb added T-types Relevant to the types team, which will review and decide on the PR/issue. fixed-by-next-solver Fixed by the next-generation trait solver, `-Znext-solver`. and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Mar 8, 2025
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. fixed-by-next-solver Fixed by the next-generation trait solver, `-Znext-solver`. 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. T-types Relevant to the types team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

3 participants