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 with next-solver: ExistentialMismatch #132330

Closed
matthiaskrgr opened this issue Oct 29, 2024 · 2 comments
Closed

ICE with next-solver: ExistentialMismatch #132330

matthiaskrgr opened this issue Oct 29, 2024 · 2 comments
Labels
A-trait-system Area: Trait system 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. S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver)

Comments

@matthiaskrgr
Copy link
Member

Code

trait Service {
    type S;
}

trait Framing {
    type F;
}

impl Framing for () {
    type F = ();
}

trait HttpService<F: Framing>: Service<S = F::F> {}

type BoxService = Box<dyn HttpService<(), S = ()>>;

fn build_server<F: FnOnce() -> BoxService>(_: F) {}

fn make_server<F: Framing>() -> Box<dyn HttpService<F, S = F::F>> {
    unimplemented!()
}

fn main() {
    build_server(|| make_server())
}

Meta

rustc --version --verbose:

rustc 1.84.0-nightly (3f1be1ec7 2024-10-28)
binary: rustc
commit-hash: 3f1be1ec7ec3d8e80beb381ee82164a0aa3ca777
commit-date: 2024-10-28
host: x86_64-unknown-linux-gnu
release: 1.84.0-nightly
LLVM version: 19.1.1

Error output

no errors
Backtrace

thread 'rustc' panicked at /rustc/3f1be1ec7ec3d8e80beb381ee82164a0aa3ca777/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/canonical.rs:391:86:
called `Result::unwrap()` on an `Err` value: ExistentialMismatch(ExpectedFound { expected: [Binder { value: Trait(HttpService<()>), bound_vars: [] }, Binder { value: Projection(S = ()), bound_vars: [] }, Binder { value: Projection(S = _), bound_vars: [] }], found: [Binder { value: Trait(HttpService<()>), bound_vars: [] }, Binder { value: Projection(S = ()), bound_vars: [] }, Binder { value: Projection(S = ()), bound_vars: [] }] })
stack backtrace:
   0:     0x7f08e12a2a3a - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::h7767b02c5430d02b
   1:     0x7f08e1a0444a - core::fmt::write::hd9cf23088539bf85
   2:     0x7f08e2ca0251 - std::io::Write::write_fmt::h516df85bf7181425
   3:     0x7f08e12a2892 - std::sys::backtrace::BacktraceLock::print::h5907c3622e037863
   4:     0x7f08e12a4d96 - std::panicking::default_hook::{{closure}}::h13cd352e0714d74b
   5:     0x7f08e12a4be0 - std::panicking::default_hook::ha087b22e6b135389
   6:     0x7f08e031d62f - std[6f01353fa805a722]::panicking::update_hook::<alloc[62edfd2f77ae8093]::boxed::Box<rustc_driver_impl[b57e977af7ed3191]::install_ice_hook::{closure#0}>>::{closure#0}
   7:     0x7f08e12a54a8 - std::panicking::rust_panic_with_hook::ha12d21b564771d78
   8:     0x7f08e12a527a - std::panicking::begin_panic_handler::{{closure}}::h29f91f01f78dfedc
   9:     0x7f08e12a2ee9 - std::sys::backtrace::__rust_end_short_backtrace::h1e39edc6648a642b
  10:     0x7f08e12a4f3c - rust_begin_unwind
  11:     0x7f08ddce8a50 - core::panicking::panic_fmt::hea12f2402e677eaa
  12:     0x7f08de07b6b6 - core::result::unwrap_failed::hb52ad530f4fe86dd
  13:     0x7f08e266f29e - <rustc_next_trait_solver[4bfa710c1e5e135a]::solve::eval_ctxt::EvalCtxt<rustc_trait_selection[d2c87e7718ceefbc]::solve::delegate::SolverDelegate, rustc_middle[a71cce3b55612100]::ty::context::TyCtxt>>::unify_query_var_values
  14:     0x7f08e26740b5 - <rustc_trait_selection[d2c87e7718ceefbc]::solve::inspect::analyse::InspectCandidate>::instantiate_nested_goals_and_opt_impl_args
  15:     0x7f08e29339e8 - <rustc_trait_selection[d2c87e7718ceefbc]::solve::fulfill::BestObligation as rustc_trait_selection[d2c87e7718ceefbc]::solve::inspect::analyse::ProofTreeVisitor>::visit_goal
  16:     0x7f08e29340fb - <rustc_trait_selection[d2c87e7718ceefbc]::solve::fulfill::BestObligation as rustc_trait_selection[d2c87e7718ceefbc]::solve::inspect::analyse::ProofTreeVisitor>::visit_goal
  17:     0x7f08e265c6dd - <rustc_infer[b005096d9ca2d9eb]::infer::InferCtxt as rustc_trait_selection[d2c87e7718ceefbc]::solve::inspect::analyse::ProofTreeInferCtxtExt>::visit_proof_tree_at_depth::<rustc_trait_selection[d2c87e7718ceefbc]::solve::fulfill::BestObligation>
  18:     0x7f08e265c506 - rustc_trait_selection[d2c87e7718ceefbc]::solve::fulfill::find_best_leaf_obligation
  19:     0x7f08e265a53e - <rustc_trait_selection[d2c87e7718ceefbc]::traits::FulfillmentError as rustc_infer[b005096d9ca2d9eb]::traits::engine::FromSolverError<rustc_trait_selection[d2c87e7718ceefbc]::solve::fulfill::NextSolverError>>::from_solver_error
  20:     0x7f08e06040b7 - <rustc_trait_selection[d2c87e7718ceefbc]::solve::fulfill::FulfillmentCtxt<rustc_trait_selection[d2c87e7718ceefbc]::traits::FulfillmentError> as rustc_infer[b005096d9ca2d9eb]::traits::engine::TraitEngine<rustc_trait_selection[d2c87e7718ceefbc]::traits::FulfillmentError>>::select_where_possible
  21:     0x7f08e1ce0137 - <rustc_hir_typeck[cbc9bfea74fd92f]::fn_ctxt::FnCtxt>::structurally_resolve_type
  22:     0x7f08e269e7b4 - <rustc_hir_typeck[cbc9bfea74fd92f]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  23:     0x7f08e2698e90 - <rustc_hir_typeck[cbc9bfea74fd92f]::fn_ctxt::FnCtxt>::check_block_with_expected
  24:     0x7f08e269f32e - <rustc_hir_typeck[cbc9bfea74fd92f]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  25:     0x7f08e1cf79d0 - rustc_hir_typeck[cbc9bfea74fd92f]::check::check_fn
  26:     0x7f08e1ced28d - rustc_hir_typeck[cbc9bfea74fd92f]::typeck
  27:     0x7f08e1cecb87 - rustc_query_impl[363319b8d14e6982]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[363319b8d14e6982]::query_impl::typeck::dynamic_query::{closure#2}::{closure#0}, rustc_middle[a71cce3b55612100]::query::erase::Erased<[u8; 8usize]>>
  28:     0x7f08e1d9e181 - rustc_query_system[4cfb2d0902ef8f12]::query::plumbing::try_execute_query::<rustc_query_impl[363319b8d14e6982]::DynamicConfig<rustc_query_system[4cfb2d0902ef8f12]::query::caches::VecCache<rustc_span[b0d64f4f8585b504]::def_id::LocalDefId, rustc_middle[a71cce3b55612100]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[363319b8d14e6982]::plumbing::QueryCtxt, false>
  29:     0x7f08e1d9c7d5 - rustc_query_impl[363319b8d14e6982]::query_impl::typeck::get_query_non_incr::__rust_end_short_backtrace
  30:     0x7f08e1d9c45b - <rustc_middle[a71cce3b55612100]::hir::map::Map>::par_body_owners::<rustc_hir_analysis[bffcb7f74fda0573]::check_crate::{closure#4}>::{closure#0}
  31:     0x7f08e1d9a346 - rustc_hir_analysis[bffcb7f74fda0573]::check_crate
  32:     0x7f08e2347557 - rustc_interface[26b25201e591a79d]::passes::run_required_analyses
  33:     0x7f08e28eec1e - rustc_interface[26b25201e591a79d]::passes::analysis
  34:     0x7f08e28eebf1 - rustc_query_impl[363319b8d14e6982]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[363319b8d14e6982]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[a71cce3b55612100]::query::erase::Erased<[u8; 1usize]>>
  35:     0x7f08e292b1ee - rustc_query_system[4cfb2d0902ef8f12]::query::plumbing::try_execute_query::<rustc_query_impl[363319b8d14e6982]::DynamicConfig<rustc_query_system[4cfb2d0902ef8f12]::query::caches::SingleCache<rustc_middle[a71cce3b55612100]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[363319b8d14e6982]::plumbing::QueryCtxt, false>
  36:     0x7f08e292aecf - rustc_query_impl[363319b8d14e6982]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  37:     0x7f08e27f6273 - rustc_interface[26b25201e591a79d]::interface::run_compiler::<core[97274f6297637c56]::result::Result<(), rustc_span[b0d64f4f8585b504]::ErrorGuaranteed>, rustc_driver_impl[b57e977af7ed3191]::run_compiler::{closure#0}>::{closure#1}
  38:     0x7f08e2872394 - std[6f01353fa805a722]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[26b25201e591a79d]::util::run_in_thread_with_globals<rustc_interface[26b25201e591a79d]::util::run_in_thread_pool_with_globals<rustc_interface[26b25201e591a79d]::interface::run_compiler<core[97274f6297637c56]::result::Result<(), rustc_span[b0d64f4f8585b504]::ErrorGuaranteed>, rustc_driver_impl[b57e977af7ed3191]::run_compiler::{closure#0}>::{closure#1}, core[97274f6297637c56]::result::Result<(), rustc_span[b0d64f4f8585b504]::ErrorGuaranteed>>::{closure#0}, core[97274f6297637c56]::result::Result<(), rustc_span[b0d64f4f8585b504]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[97274f6297637c56]::result::Result<(), rustc_span[b0d64f4f8585b504]::ErrorGuaranteed>>
  39:     0x7f08e28727cd - <<std[6f01353fa805a722]::thread::Builder>::spawn_unchecked_<rustc_interface[26b25201e591a79d]::util::run_in_thread_with_globals<rustc_interface[26b25201e591a79d]::util::run_in_thread_pool_with_globals<rustc_interface[26b25201e591a79d]::interface::run_compiler<core[97274f6297637c56]::result::Result<(), rustc_span[b0d64f4f8585b504]::ErrorGuaranteed>, rustc_driver_impl[b57e977af7ed3191]::run_compiler::{closure#0}>::{closure#1}, core[97274f6297637c56]::result::Result<(), rustc_span[b0d64f4f8585b504]::ErrorGuaranteed>>::{closure#0}, core[97274f6297637c56]::result::Result<(), rustc_span[b0d64f4f8585b504]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[97274f6297637c56]::result::Result<(), rustc_span[b0d64f4f8585b504]::ErrorGuaranteed>>::{closure#1} as core[97274f6297637c56]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  40:     0x7f08e287326b - std::sys::pal::unix::thread::Thread::new::thread_start::hbed294d48a38d6d6
  41:     0x7f08e401339d - <unknown>
  42:     0x7f08e409849c - <unknown>
  43:                0x0 - <unknown>

error: the compiler unexpectedly panicked. this is a bug.

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 `/tmp/im/rustc-ice-2024-10-29T20_27_37-1444394.txt` to your bug report

note: compiler flags: -Z next-solver=globally

query stack during panic:
#0 [typeck] type-checking `main`
#1 [analysis] running analysis passes on this crate
end of query stack

@matthiaskrgr matthiaskrgr 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. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver) labels Oct 29, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Oct 29, 2024
@cyrgani
Copy link
Contributor

cyrgani commented Oct 29, 2024

Reduced:

trait Service {
    type S;
}

trait Framing {
    type F;
}

impl Framing for () {
    type F = ();
}

trait HttpService: Service<S = <() as Framing>::F> {}

fn main() {
    let _: dyn HttpService<S = ()>;
}

@jieyouxu jieyouxu added S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue A-trait-system Area: Trait system and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Oct 30, 2024
@matthiaskrgr matthiaskrgr added the S-bug-has-test Status: This bug is tracked inside the repo by a `known-bug` test. label Nov 7, 2024
@compiler-errors
Copy link
Member

Closed by #136458

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-trait-system Area: Trait system 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. S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver)
Projects
None yet
Development

No branches or pull requests

5 participants