unconstrained associated type in `param_env` results in ICE
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
trait MyFnOnce: FnOnce() -> Self::Ret {
type Ret;
}
impl<F: FnOnce() -> R, R> MyFnOnce for F {
type Ret = R;
}
trait FnOnceWhichOutputs<R>: MyFnOnce<Ret = R> {}
impl<R, F: FnOnce() -> R> FnOnceWhichOutputs<R> for F {}
fn ice_ice_baby<F: for<'any> FnOnceWhichOutputs<&'any str>>() {}
The following ICEs in fn normalize_param_env_or_error with
error: internal compiler error: `[Binder { value: TraitPredicate(<F as FnOnceWhichOutputs<&'any str>>, polarity:Positive), bound_vars: [Region(BrNamed(DefId(0:16 ~ playground[dcd1]::ice_ice_baby::'any)))] }, Binder { value: ProjectionPredicate(AliasTerm { args: [F/#0], def_id: DefId(0:4 ~ playground[dcd1]::MyFnOnce::Ret), .. }, Term::Ty(&'^0.Named(DefId(0:16 ~ playground[dcd1]::ice_ice_baby::'any)) str)), bound_vars: [Region(BrNamed(DefId(0:16 ~ playground[dcd1]::ice_ice_baby::'any)))] }, Binder { value: TraitPredicate(<F as MyFnOnce>, polarity:Positive), bound_vars: [Region(BrNamed(DefId(0:16 ~ playground[dcd1]::ice_ice_baby::'any)))] }, Binder { value: ProjectionPredicate(AliasTerm { args: [F/#0, ()], def_id: DefId(2:3993 ~ core[2e27]::ops::function::FnOnce::Output), .. }, Term::Ty(&'?0 str)), bound_vars: [Region(BrNamed(DefId(0:16 ~ playground[dcd1]::ice_ice_baby::'any)))] }, Binder { value: TraitPredicate(<F as std::ops::FnOnce<()>>, polarity:Positive), bound_vars: [Region(BrNamed(DefId(0:16 ~ playground[dcd1]::ice_ice_baby::'any)))] }, Binder { value: TraitPredicate(<F as std::marker::MetaSized>, polarity:Positive), bound_vars: [Region(BrNamed(DefId(0:16 ~ playground[dcd1]::ice_ice_baby::'any)))] }, Binder { value: TraitPredicate(<F as std::marker::Sized>, polarity:Positive), bound_vars: [] }]` is not fully resolved
|
= note: delayed at /rustc-dev/ded5c06cf21d2b93bffd5d884aa6e96934ee4234/compiler/rustc_infer/src/infer/mod.rs:1260:43 - disabled backtrace
Discovered by @danielhenrymantilla (https://github.com/rust-lang/rust/issues/141713#issuecomment-3769164441) and further minimized by @maxdexh (https://github.com/rust-lang/rust/issues/141713#issuecomment-3769230685). cc @theemathas
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 minimized Rust example and reading fn normalize_param_env_or_error in compiler/rustc_infer/src/infer/mod.rs around line 1260. Trace how the unconstrained associated type enters the param environment and verify that the reproducer no longer triggers an internal compiler error, with regression coverage for this case.
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
- Mostly clear
- Newbie friendliness
- 45/100