Skip to content

Evaluate caches stack-dependent results #123403

Open
@lcnr

Description

@lcnr
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 #122791

THe idea is from #123303 (comment)

  • GoalA
    • CandA1
      • GoalB
        • CandB1
          • GoalA (inductive cycle -> ambig)
          • AssertInferenceConstraintsApplied (fails due to incompleteness if the inference constraints from CandA2 have not yet been applied)
        • CandB2
          • Impossible (necessary to evaluate nested goals of CandB1 during selection)
    • CandA2
      • guide inference ~> Ok, but inference constraints

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-trait-systemArea: Trait systemT-typesRelevant to the types team, which will review and decide on the PR/issue.fixed-by-next-solverFixed by the next-generation trait solver, `-Znext-solver`.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions