"unexpected ambiguity: `CanonicalQueryInput`" with conflicting associated type specifiers
Open
Nobody has claimed this yet.
A-associated-items
A-impl-trait
C-bug
I-ICE
P-medium
regression-from-stable-to-stable
S-has-bisection
S-has-mcve
T-compiler
T-types
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
Code
pub trait Trait {
type Assoc: Copy + 'static;
}
const fn conjure<T>() -> T {
panic!()
}
const fn get_assoc<T: Trait>() -> impl Copy {
conjure::<<T as Trait>::Assoc>()
}
pub fn foo<T: Trait<Assoc = i32> + Trait<Assoc = i64>>() {
const {
get_assoc::<T>();
}
}
(slightly adapted from @theemathas's example here)
Meta
cargo bisect-rustc:
(Edit: https://github.com/rust-lang/rust/issues/146371#issuecomment-3275211557)
Regression in nightly-2024-11-27
- commit[0] 2024-11-25: Auto merge of #133247 - GuillaumeGomez:reduce-integer-display-impl, r=workingjubilee
- commit[1] 2024-11-26: Auto merge of #133465 - ehuss:update-cargo, r=ehuss
- commit[2] 2024-11-26: Auto merge of #132894 - frank-king:feature/where-refactor, r=cjgillot
- commit[3] 2024-11-26: Auto merge of #133500 - GuillaumeGomez:rollup-4vcthwo, r=GuillaumeGomez~~
Error output
note: no errors encountered even though delayed bugs were created
note: those delayed bugs will now be shown as internal compiler errors
error: internal compiler error: unexpected ambiguity: CanonicalQueryInput { canonical: Canonical { value: ParamEnvAnd { param_env: ParamEnv { caller_bounds: [Binder { value: ProjectionPredicate(AliasTerm { args: [T/#0], def_id: DefId(0:4 ~ playground[81cc]::Trait::Assoc), .. }, Term::Ty(i64)), bound_vars: [] }, Binder { value: ProjectionPredicate(AliasTerm { args: [T/#0], def_id: DefId(0:4 ~ playground[81cc]::Trait::Assoc), .. }, Term::Ty(i32)), bound_vars: [] }, Binder { value: TraitPredicate(<T as Trait>, polarity:Positive), bound_vars: [] }, Binder { value: TraitPredicate(<T as std::marker::Sized>, polarity:Positive), bound_vars: [] }] }, value: AliasTy { args: [T/#0], def_id: DefId(0:4 ~ playground[81cc]::Trait::Assoc), .. } }, max_universe: U0, variables: [] }, typing_mode: PostAnalysis } Canonical { value: QueryResponse { var_values: CanonicalVarValues { var_values: [] }, region_constraints: QueryRegionConstraints { outlives: [] }, certainty: Ambiguous, opaque_types: [], value: NormalizationResult { normalized_ty: ^0 } }, max_universe: U0, variables: [Ty(General(U0))] }
|
= note: delayed at compiler/rustc_trait_selection/src/traits/query/normalize.rs:288:30 - disabled backtrace
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: rustc 1.89.0 (29483883e 2025-08-04) running on x86_64-unknown-linux-gnu
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:
end of query stack
@rustbot label A-impossible-bounds T-types regression-from-stable-to-stable
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 by reproducing the provided Rust example and inspect the delayed bug at compiler/rustc_trait_selection/src/traits/query/normalize.rs:288. Use cargo bisect-rustc to confirm the reported regression range. Done means the example no longer produces an internal compiler error and the regression is covered by an appropriate compiler test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100