Skip to content

Ambiguity, differing outlives constraints with types equal modulo normalization #57

@compiler-errors

Description

@compiler-errors
Member
fn main() {
    let _: &dyn Iterator<Item=i32> = &vec![1].into_iter();
}

When coercing &'?0 <Vec<{integer}> as IntoIterator>::IntoIter into &'?1 dyn Iterator<Item=i32>, we end up with two responses.

The first has a type-outlives constraint like <Vec<{integer}> as IntoIterator>::IntoIter: &'?1, and the second has one like std::vec::IntoIter<{integer}>: &'?1. These are identical except for their types being normalized, but that causes us to flounder.

Activity

compiler-errors

compiler-errors commented on Aug 7, 2023

@compiler-errors
MemberAuthor

Interestingly, the code with Box doesn't fail because the Box::new constructor causes the type to be normalized due to the argument being a coercion point:

fn main() {
    let _: Box<dyn Iterator<Item=i32> + '_> = Box::new(vec![1].into_iter());
}
compiler-errors

compiler-errors commented on Aug 8, 2023

@compiler-errors
MemberAuthor

This may be a problem somewhat specific to T -> dyn Trait unsizing -- we could perhaps consider those goals separately within assemble_blanket_impl_candidates, and not in assemble_candidates_via_self_ty.

lcnr

lcnr commented on Aug 8, 2023

@lcnr
Contributor

I think we should consider the three way split of "assemble blanket candidates", "assemble_normalization_step_candidates" and "assemble_candidates_via_self_ty" or whatever

added a commit that references this issue on Aug 15, 2023
da4e7bd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Participants

      @compiler-errors@lcnr

      Issue actions

        Ambiguity, differing outlives constraints with types equal modulo normalization · Issue #57 · rust-lang/trait-system-refactor-initiative