Skip to content

False ambiguity due to overlap between higher-ranked and other where clause #27834

Open
@nikomatsakis

Description

@nikomatsakis

The test at http://is.gd/xHYV2z was extracted from the qcollect-traits package on crates.io. It fails to compile due to a false ambiguity between the higher-ranked where-clause and the other one. This is particularly frustrating because the ambiguity occurs as part of projection and the higher-ranked where clause doesn't even list a binding for Output.

The correct fix is probably to prune one where clause or the other as part of selection, but this is a bit tricky with the current region setup due to #21974.

pub trait ImmutableSequenceTypes<'a, T:'a>{
    type Output;
}

pub trait MutableSequenceTypes<'a, T:'a>: ImmutableSequenceTypes<'a, T> {
}

fn foo<'t,X,T:'t>()
    where X: for<'a> ImmutableSequenceTypes<'a, T>,
          X: ImmutableSequenceTypes<'t, T, Output=&'t T>
{
    bar::<<X as ImmutableSequenceTypes<'t,T>>::Output>();
}

fn bar<A>() { }

fn main() { }

(Due to this bug, PR #27641 causes a regression in qcollect-traits, but the problem is pre-existing.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-higher-rankedArea: Higher-ranked things (e.g., lifetimes, types, trait bounds aka HRTBs)A-trait-systemArea: Trait systemC-bugCategory: This is a bug.T-compilerRelevant 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.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions