Skip to content

delegation: do not always inherit ConstArgHasType predicates#158722

Open
aerooneqq wants to merge 1 commit into
rust-lang:mainfrom
aerooneqq:delegation-const-predicates-ice
Open

delegation: do not always inherit ConstArgHasType predicates#158722
aerooneqq wants to merge 1 commit into
rust-lang:mainfrom
aerooneqq:delegation-const-predicates-ice

Conversation

@aerooneqq

@aerooneqq aerooneqq commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

The explanation can be found in comment in inherit_predicates_for_delegation_item.

So the problem is that we have two ConstArgHasType predicates in param_env which tell that a single const has different types. But the function find_const_ty_from_env panics in this situation. This assert is here for a long time, and I do not have enough knowledge to say if it is correct or not, however I have thoughts that having contradictory predicates should not lead to panic, instead an error from trait solver or whatever engine that solves those predicates should be reported. Do not want to dive too deep into researching and possibly rewriting find_const_ty_from_env, so fixed it on delegation level.

Fixes #158675. Part of #118212.
r? @petrochenkov

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jul 3, 2026
@aerooneqq aerooneqq force-pushed the delegation-const-predicates-ice branch from 0310105 to 4d1093d Compare July 3, 2026 09:10
@petrochenkov petrochenkov added the F-fn_delegation `#![feature(fn_delegation)]` label Jul 3, 2026
@petrochenkov

Copy link
Copy Markdown
Contributor

r? types

@rustbot rustbot added the T-types Relevant to the types team, which will review and decide on the PR/issue. label Jul 3, 2026
@rustbot rustbot assigned oli-obk and unassigned petrochenkov Jul 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

F-fn_delegation `#![feature(fn_delegation)]` S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. 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

Successfully merging this pull request may close these issues.

[ICE]: did not expect duplicate ConstParamHasTy for N/#1 in param-env: ParamEnv {

4 participants