rust-lang / rust-lang/rust-analyzer
panic: `could not replace AliasTerm `
Open
Nobody has claimed this yet.
C-bug
I-panic
- Dominant language
- Rust
- Stars
- 16.9k
- Forks
- 2.2k
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 72
Description
trait Other<T> {}
trait Super<T> {
type Assoc;
}
trait Foo<A, B>: Super<<A as Mirror>::Assoc, Assoc = A> {
type FooAssoc: Other<<Self as Super<<A as Super>::Assoc>>::Assoc>;
}
fn is_foo<F: Foo + ?Sized, T, U>() {}
fn main() {
is_foo::<dyn Foo<i32, u32, FooAssoc = i32>, _, _>();
}
RUST_BACKTRACE=full RUSTFLAGS="" ~/.rustup/toolchains/master/bin/rust-analyzer highlight < code.rs
thread 'main' (1166083) panicked at /rust/deps/ra-ap-rustc_next_trait_solver-0.165.0/src/solve/assembly/structural_traits.rs:1005:13:
could not replace AliasTerm { args: [dyn [Binder { value: Trait(ExistentialTraitRef("Foo"[[i32, u32]])), bound_vars: [] }, Binder { value: Projection(ExistentialProjection { def_id: TypeAliasId("Assoc"), args: [?0t], term: i32, .. }), bound_vars: [] }, Binder { value: Projection(ExistentialProjection { def_id: TypeAliasId("FooAssoc"), args: [i32, u32], term: i32, .. }), bound_vars: [] }] + '!1, Alias(AliasTy { args: [i32, {type error}], kind: Projection { def_id: TypeAliasId("Assoc") }, .. })], kind: ProjectionTy { def_id: TypeAliasId("Assoc") }, .. } with term from from dyn [Binder { value: Trait(ExistentialTraitRef("Foo"[[i32, u32]])), bound_vars: [] }, Binder { value: Projection(ExistentialProjection { def_id: TypeAliasId("Assoc"), args: [?0t], term: i32, .. }), bound_vars: [] }, Binder { value: Projection(ExistentialProjection { def_id: TypeAliasId("FooAssoc"), args: [i32, u32], term: i32, .. }), bound_vars: [] }] + '!1
stack backtrace:
0: 0x7f9c7684bed6 - <<std[cf0678d25afc9ccf]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[9662e8fc1527f23c]::fmt::Display>::fmt
1: 0x7f9c76e0f0c8 - core[9662e8fc1527f23c]::fmt::write
2: 0x7f9c7686113c - <std[cf0678d25afc9ccf]::sys::stdio::unix::Stderr as core[9662e8fc1527f23c]::io::write::Write>::write_fmt
3: 0x7f9c7681e04a - std[cf0678d25afc9ccf]::panicking::default_hook::{closure#0}
4: 0x7f9c7683e5f3 - std[cf0678d25afc9ccf]::panicking::default_hook
5: 0x7f9c7683ea5b - std[cf0678d25afc9ccf]::panicking::panic_with_hook
6: 0x7f9c7681e102 - std[cf0678d25afc9ccf]::panicking::panic_handler::{closure#0}
7: 0x7f9c76816a89 - std[cf0678d25afc9ccf]::sys::backtrace::__rust_end_short_backtrace::<std[cf0678d25afc9ccf]::panicking::panic_handler::{closure#0}, !>
8: 0x7f9c7681fa5d - __rustc[c7d2cd00dee8f709]::rust_begin_unwind
9: 0x7f9c73560bac - core[9662e8fc1527f23c]::panicking::panic_fmt
10: 0x55bac9748ddc - <ra_ap_rustc_next_trait_solver[8b18a8e3020f8ede]::solve::assembly::structural_traits::ReplaceProjectionWith<hir_ty[cdb9a6d3e6bba482]::next_solver::interner::DbInterner, hir_ty[cdb9a6d3e6bba482]::next_solver::solver::SolverContext>>::try_eagerly_replace_alias
11: 0x55bac9683d0b - <hir_ty[cdb9a6d3e6bba482]::next_solver::generic_arg::GenericArg as ra_ap_rustc_type_ir[4e6de8744a899384]::fold::TypeFoldable<hir_ty[cdb9a6d3e6bba482]::next_solver::interner::DbInterner>>::try_fold_with::<ra_ap_rustc_next_trait_solver[8b18a8e3020f8ede]::solve::assembly::structural_traits::ReplaceProjectionWith<hir_ty[cdb9a6d3e6bba482]::next_solver::interner::DbInterner, hir_ty[cdb9a6d3e6bba482]::next_solver::solver::SolverContext>>
12: 0x55bac96793c3 - <core[9662e8fc1527f23c]::result::Result<hir_ty[cdb9a6d3e6bba482]::next_solver::generic_arg::GenericArg, ra_ap_rustc_next_trait_solver[8b18a8e3020f8ede]::solve::assembly::structural_traits::Ambiguous> as ra_ap_rustc_type_ir[4e6de8744a899384]::interner::CollectAndApply<hir_ty[cdb9a6d3e6bba482]::next_solver::generic_arg::GenericArg, hir_ty[cdb9a6d3e6bba482]::next_solver::generic_arg::GenericArgs>>::collect_and_apply::<core[9662e8fc1527f23c]::iter::adapters::map::Map<core[9662e8fc1527f23c]::iter::adapters::copied::Copied<core[9662e8fc1527f23c]::slice::iter::Iter<hir_ty[cdb9a6d3e6bba482]::next_solver::generic_arg::GenericArg>>, <hir_ty[cdb9a6d3e6bba482]::next_solver::generic_arg::GenericArgs as ra_ap_rustc_type_ir[4e6de8744a899384]::fold::TypeFoldable<hir_ty[cdb9a6d3e6bba482]::next_solver::interner::DbInterner>>::try_fold_with<ra_ap_rustc_next_trait_solver[8b18a8e3020f8ede]::solve::assembly::structural_traits::ReplaceProjectionWith<hir_ty[cdb9a6d3e6bba482]::next_solver::interner::DbInterner, hir_ty[cdb9a6d3e6bba482]::next_solver::solver::SolverContext>>::{closure#0}>, <hir_ty[cdb9a6d3e6bba482]::next_solver::generic_arg::GenericArgs>::new_from_iter<core[9662e8fc1527f23c]::iter::adapters::map::Map<core[9662e8fc1527f23c]::iter::adapters::copied::Copied<core[9662e8fc1527f23c]::slice::iter::Iter<hir_ty[cdb9a6d3e6bba482]::next_solver::generic_arg::GenericArg>>, <hir_ty[cdb9a6d3e6bba482]::next_solver::generic_arg::GenericArgs as ra_ap_rustc_type_ir[4e6de8744a899384]::fold::TypeFoldable<hir_ty[cdb9a6d3e6bba482]::next_solver::interner::DbInterner>>::try_fold_with<ra_ap_rustc_next_trait_solver[8b18a8e3020f8ede]::solve::assembly::structural_traits::ReplaceProjectionWith<hir_ty[cdb9a6d3e6bba482]::next_solver::interner::DbInterner, hir_ty[cdb9a6d3e6bba482]::next_solver::solver::SolverContext>>::{closure#0}>, core[9662e8fc1527f23c]::result::Result<hir_ty[cdb9a6d3e6bba482]::next_solver::generic_arg::GenericArg, ra_ap_rustc_next_trait_solver[8b18a8e3020f8ede]::solve::assembly::structural_traits::Ambiguous>>::{closure#0}>
13: 0x55bac95cf781 - ra_ap_rustc_next_trait_solver[8b18a8e3020f8ede]::solve::assembly::structural_traits::predicates_for_object_candidate::<hir_ty[cdb9a6d3e6bba482]::next_solver::solver::SolverContext, hir_ty[cdb9a6d3e6bba482]::next_solver::interner::DbInterner>
14: 0x55bac968902d - <ra_ap_rustc_type_ir[4e6de8744a899384]::predicate::TraitPredicate<hir_ty[cdb9a6d3e6bba482]::next_solver::interner::DbInterner> as ra_ap_rustc_next_trait_solver[8b18a8e3020f8ede]::solve::assembly::GoalKind<hir_ty[cdb9a6d3e6bba482]::next_solver::solver::SolverContext, hir_ty[cdb9a6d3e6bba482]::next_solver::interner::DbInterner>>::probe_and_match_goal_against_assumption::<<ra_ap_rustc_type_ir[4e6de8744a899384]::predicate::TraitPredicate<hir_ty[cdb9a6d3e6bba482]::next_solver::interner::DbInterner> as ra_ap_rustc_next_trait_solver[8b18a8e3020f8ede]::solve::assembly::GoalKind<hir_ty[cdb9a6d3e6bba482]::next_solver::solver::SolverContext, hir_ty[cdb9a6d3e6bba482]::next_solver::interner::DbInterner>>::probe_and_consider_object_bound_candidate::{closure#0}>
15: 0x55bac976b333 - <ra_ap_rustc_next_trait_solver[8b18a8e3020f8ede]::solve::eval_ctxt::EvalCtxt<hir_ty[cdb9a6d3e6bba482]::next_solver::solver::SolverContext, hir_ty[cdb9a6d3e6bba482]::next_solver::interner::DbInterner>>::compute_trait_goal
16: 0x55bac97e1e61 - <ra_ap_rustc_type_ir[4e6de8744a899384]::search_graph::SearchGraph<ra_ap_rustc_next_trait_solver[8b18a8e3020f8ede]::solve::search_graph::SearchGraphDelegate<hir_ty[cdb9a6d3e6bba482]::next_solver::solver::SolverContext>, hir_ty[cdb9a6d3e6bba482]::next_solver::interner::DbInterner>>::evaluate_goal_in_task
17: 0x55bac97dabc8 - <ra_ap_rustc_type_ir[4e6de8744a899384]::search_graph::SearchGraph<ra_ap_rustc_next_trait_solver[8b18a8e3020f8ede]::solve::search_graph::SearchGraphDelegate<hir_ty[cdb9a6d3e6bba482]::next_solver::solver::SolverContext>, hir_ty[cdb9a6d3e6bba482]::next_solver::interner::DbInterner>>::evaluate_goal
18: 0x55bac9770294 - <ra_ap_rustc_next_trait_solver[8b18a8e3020f8ede]::solve::eval_ctxt::EvalCtxt<hir_ty[cdb9a6d3e6bba482]::next_solver::solver::SolverContext, hir_ty[cdb9a6d3e6bba482]::next_solver::interner::DbInterner>>::evaluate_goal_raw
19: 0x55bac976f7e9 - <ra_ap_rustc_next_trait_solver[8b18a8e3020f8ede]::solve::eval_ctxt::EvalCtxt<hir_ty[cdb9a6d3e6bba482]::next_solver::solver::SolverContext, hir_ty[cdb9a6d3e6bba482]::next_solver::interner::DbInterner>>::evaluate_goal
20: 0x55bac9986aa7 - <hir_ty[cdb9a6d3e6bba482]::next_solver::solver::SolverContext as ra_ap_rustc_next_trait_solver[8b18a8e3020f8ede]::solve::eval_ctxt::SolverDelegateEvalExt>::evaluate_root_goal
21: 0x55bac9783425 - <hir_ty[cdb9a6d3e6bba482]::next_solver::fulfill::FulfillmentCtxt>::try_evaluate_obligations
22: 0x55bac9823664 - <hir_ty[cdb9a6d3e6bba482]::infer::unify::InferenceTable>::select_obligations_where_possible
23: 0x55bac9823530 - <hir_ty[cdb9a6d3e6bba482]::infer::unify::InferenceTable>::try_structurally_resolve_type
24: 0x55bac9730a5d - <hir_ty[cdb9a6d3e6bba482]::infer::InferenceContext>::infer_path
25: 0x55bac97231e1 - <hir_ty[cdb9a6d3e6bba482]::infer::InferenceContext>::infer_expr_inner
26: 0x55bac9731b7e - <hir_ty[cdb9a6d3e6bba482]::infer::InferenceContext>::infer_call
27: 0x55bac9724c37 - <hir_ty[cdb9a6d3e6bba482]::infer::InferenceContext>::infer_expr_inner
28: 0x55bac97243d7 - <hir_ty[cdb9a6d3e6bba482]::infer::InferenceContext>::infer_expr_inner
29: 0x55bac9722407 - <hir_ty[cdb9a6d3e6bba482]::infer::InferenceContext>::infer_return
30: 0x55bac98448ae - hir_ty[cdb9a6d3e6bba482]::infer::infer_query_with_inspect
31: 0x55bac96ff164 - <salsa[65a99894a6a39c25]::function::IngredientImpl<<hir_ty[cdb9a6d3e6bba482]::infer::InferenceResult>::for_body::_::for_body__Configuration_>>::execute
32: 0x55bac94fef27 - <salsa[65a99894a6a39c25]::attach::Attached>::attach::<dyn hir_ty[cdb9a6d3e6bba482]::db::HirDatabase, &hir_ty[cdb9a6d3e6bba482]::infer::InferenceResult, <hir_ty[cdb9a6d3e6bba482]::infer::InferenceResult>::for_body::for_body_::{closure#0}>
33: 0x55bac915ebcc - <hir[c107f094967a75ab]::semantics::SemanticsImpl>::get_unsafe_ops
34: 0x55bac9ac92b3 - ide[37737ece80204ca3]::syntax_highlighting::highlight
35: 0x55bac9b02e6e - ide[37737ece80204ca3]::syntax_highlighting::html::highlight_as_html_with_config
36: 0x55bac9a69dec - <ide[37737ece80204ca3]::Analysis>::highlight_as_html
37: 0x55baca4b8872 - <rust_analyzer[c9a7b5a74bd4f6b9]::cli::flags::Highlight>::run
38: 0x55baca758034 - rust_analyzer[e3769bb504499c95]::main
39: 0x55baca6ee713 - std[cf0678d25afc9ccf]::sys::backtrace::__rust_begin_short_backtrace::<fn() -> core[9662e8fc1527f23c]::result::Result<std[cf0678d25afc9ccf]::process::ExitCode, anyhow[6279a09abd95b935]::Error>, core[9662e8fc1527f23c]::result::Result<std[cf0678d25afc9ccf]::process::ExitCode, anyhow[6279a09abd95b935]::Error>>
40: 0x55baca751082 - std[cf0678d25afc9ccf]::rt::lang_start::<core[9662e8fc1527f23c]::result::Result<std[cf0678d25afc9ccf]::process::ExitCode, anyhow[6279a09abd95b935]::Error>>::{closure#0}
41: 0x7f9c77f6af99 - std[cf0678d25afc9ccf]::rt::lang_start_internal
42: 0x55baca771148 - main
43: 0x7f9c71827741 - <unknown>
44: 0x7f9c71827879 - __libc_start_main
45: 0x55bac90626e9 - <unknown>
46: 0x0 - <unknown>
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the provided Rust reproducer and run the rust-analyzer highlight command to confirm the panic. Trace the stack to structural_traits.rs, especially try_eagerly_replace_alias, and inspect how the next trait solver handles the AliasTerm shown in the panic. Done means highlighting the reproducer completes without panicking.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers, devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100