Evaluate caches stack-dependent results
Open
Nobody has claimed this yet.
A-trait-system
fixed-by-next-solver
T-types
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.2k
- PR merge metrics
- PR metrics pending
Description
struct W<T: ?Sized>(*const T);
trait Foo {}
trait Bar {}
impl<T: Bar + NotImplemented> Foo for T {}
impl Foo for W<u32> {}
impl<T: Foo + AssertInferenceConstraintsApplied> Bar for T {}
trait AssertInferenceConstraintsApplied {}
trait GuideFromEnv {}
trait ErrOnGuidance {}
impl<T: GuideFromEnv + ErrOnGuidance> AssertInferenceConstraintsApplied for T {}
impl<T> GuideFromEnv for T {}
impl ErrOnGuidance for W<u32> {}
impl<T> Bar for T
where
W<T>: NotImplemented {}
trait NotImplemented {}
fn impls_foo<T: Foo>() {}
fn impls_bar<T: Bar>() {}
fn with_bound()
where
W<u64>: GuideFromEnv,
{
impls_foo::<W<_>>(); // commenting this line changes the next one to OK
impls_bar::<W<_>>(); // ERROR
}
fn main() {
with_bound();
}
cc @compiler-errors #123303 this should be broken even after https://github.com/rust-lang/rust/pull/122791
THe idea is from https://github.com/rust-lang/rust/issues/123303#issuecomment-2030904635
- GoalA
- CandA1
- GoalB
- CandB1
- GoalA (inductive cycle -> ambig)
- AssertInferenceConstraintsApplied (fails due to incompleteness if the inference constraints from
CandA2have not yet been applied)- CandB2
- Impossible (necessary to evaluate nested goals of
CandB1during selection)- CandA2
- guide inference ~> Ok, but inference constraints
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 running the supplied Rust reproducer and compare the result with and without the impls_foo call. Read issue #123303 and PR #122791 for the related trait-solver behavior and inference-constraint context; done means the stack-dependent result is reproduced, understood, and covered by a compiler regression test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100