Repository navigation
"unexpected ambiguity: CanonicalQueryInput" with conflicting associated type specifiers #146371
Copy link
Copy link
Open
Labels
A-associated-itemsArea: Associated items (types, constants & functions)Area: Associated items (types, constants & functions)A-impl-traitArea: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.Area: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.C-bugCategory: This is a bug.Category: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️P-mediumMedium priorityMedium priorityS-has-bisectionStatus: A bisection has been found for this issueStatus: A bisection has been found for this issueS-has-mcveStatus: A Minimal Complete and Verifiable Example has been found for this issueStatus: A Minimal Complete and Verifiable Example has been found for this issueT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.T-typesRelevant to the types team, which will review and decide on the PR/issue.Relevant to the types team, which will review and decide on the PR/issue.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.Performance or correctness regression from one stable version to another.
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: #146371 (comment))
Regression in nightly-2024-11-27
- commit[0] 2024-11-25: Auto merge of Reduce integer
Displayimplementation size #133247 - GuillaumeGomez:reduce-integer-display-impl, r=workingjubilee - commit[1] 2024-11-26: Auto merge of Update cargo and books #133465 - ehuss:update-cargo, r=ehuss
- commit[2] 2024-11-26: Auto merge of Refactor
wherepredicates, and reserve for attributes support #132894 - frank-king:feature/where-refactor, r=cjgillot - commit[3] 2024-11-26: Auto merge of Rollup of 13 pull requests #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
Reacted by León Orell Valerian Liehr and Tim (Theemathas) Chirananthavat
Metadata
Metadata
Assignees
Labels
A-associated-itemsArea: Associated items (types, constants & functions)Area: Associated items (types, constants & functions)A-impl-traitArea: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.Area: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.C-bugCategory: This is a bug.Category: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️P-mediumMedium priorityMedium priorityS-has-bisectionStatus: A bisection has been found for this issueStatus: A bisection has been found for this issueS-has-mcveStatus: A Minimal Complete and Verifiable Example has been found for this issueStatus: A Minimal Complete and Verifiable Example has been found for this issueT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.T-typesRelevant to the types team, which will review and decide on the PR/issue.Relevant to the types team, which will review and decide on the PR/issue.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.Performance or correctness regression from one stable version to another.
Activity
fmease commentedon Sep 9, 2025
This can't be. I've just tried nightly-2024-11-01 (to see what the output used to look like) and it also reproduces.
Maybe it's flip-flopping?
Edit: As a matter of fact, the regression didn't occur in nightly-2024-11-27; nightly-2024-11-26, nightly-2024-11-27, nightly-2024-11-28 all ICE for me (in check or build). I'm not sure what your bisect-rustc invocation looked like.
fmease commentedon Sep 9, 2025
Smaller (no const blocks, etc.):
Without
conjurebut with assoc fn:fmease commentedon Sep 9, 2025
Since cargo-bisect-rustc is acting up for me for some reason (maybe my commit range is too large?), I'll be manually bisecting for a bit.
Local lower bound (PASS): 1.63 (2022-08-08)
Local upper bound (ICE): 1.64 (2022-09-19)
fmease commentedon Sep 10, 2025
searched toolchains nightly-2022-06-24 through nightly-2022-08-05
Regression in nightly-2022-07-16
looking for regression commit between 2022-07-15 and 2022-07-16
fetching (via remote github) commits from max(c2f428d, 2022-07-13) to 23e21bd
ending github query because we found starting sha: c2f428d
get_commits_between returning commits, len: 9
commit[0] 2022-07-14: Auto merge of #99252 - lqd:win-dwarf5, r=eddyb
commit[1] 2022-07-14: Auto merge of #96544 - m-ysk:feature/issue-96358, r=cjgillot
commit[2] 2022-07-15: Auto merge of #98203 - kckeiks:gather-body-owners-in-hir-item-queries, r=cjgillot
commit[3] 2022-07-15: Auto merge of #97406 - aliemjay:verify-bounds-fix-master, r=oli-obk
commit[4] 2022-07-15: Auto merge of #99267 - Dylan-DPC:rollup-d8l7y1o, r=Dylan-DPC
commit[5] 2022-07-15: Auto merge of #99013 - RalfJung:dont-poison-my-places, r=oli-obk
commit[6] 2022-07-15: Auto merge of #99278 - Dylan-DPC:rollup-fcln6st, r=Dylan-DPC
commit[7] 2022-07-15: Auto merge of #99046 - nnethercote:final-derive-output-improvements, r=Mark-Simulacrum
commit[8] 2022-07-15: Auto merge of #99015 - lcnr:fn-ctxt-no-more, r=compiler-errors
fmease commentedon Sep 10, 2025
Maybe #97406 or #99015?
lcnr commentedon Sep 11, 2025
definitely #99015 😁 see 7808f69
I would assume we've already got different issues where this ICEs? The underlying bug is older, we should either already error during HIR typeck or not normalize assuming there won't be errors afterwards
this makes sense to me. proving
T: Traitis easy while normalizing<T as Trait>::Assocfails with ambiguity (as it should) 😁The reveal all pass shouldn't expect things to succeed if we're in an impossible env. I think we've already got stuff there which replaces MIR bodies with nothing if the env has any impossible where-clauses?
It's just not possible to detect "is the given set of where-clauses inconsistent" in general 🤔
[-]`unexpected ambiguity: CanonicalQueryInput` with conflicting associated type specifiers[/-][+]"unexpected ambiguity: `CanonicalQueryInput`" with conflicting associated type specifiers[/+]apiraino commentedon Sep 19, 2025
Assigning priority (discussion on Zulip).
@rustbot label -I-prioritize +P-medium
theemathas commentedon Mar 21, 2026
A version of this which has actually-possible bounds (it ICEs on the old solver, but compiles with next-solver):
theemathas commentedon Mar 21, 2026
A version that has actually-possible bounds, and ICEs on both the old solver and next-solver: