Skip to content

The bounds information of associated types is not propagated correctly when used with trait aliases. #68210

Open
@wdanilo

Description

@wdanilo

Hi! The following code does not compile, while it should. The functions test1 and test2 do the same thing, while test1 compiles and test2 does not:

#![feature(trait_alias)]

use std::marker::PhantomData;

pub struct X{}

pub trait T2 = where PhantomData<Self>: Into<X>;

pub trait T {
    type Item: T2;
    
    fn test1() -> X {
        PhantomData::<Self::Item>.into()
    }
}

fn test2<S:T>(s:S) -> X {
    PhantomData::<S::Item>.into()
}

Error:

error[E0277]: the trait bound `X: std::convert::From<std::marker::PhantomData<<S as T>::Item>>` is not satisfied
  --> src/lib.rs:18:28
   |
18 |     PhantomData::<S::Item>.into()
   |                            ^^^^ the trait `std::convert::From<std::marker::PhantomData<<S as T>::Item>>` is not implemented for `X`
   |
   = note: required because of the requirements on the impl of `std::convert::Into<X>` for `std::marker::PhantomData<<S as T>::Item>`

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-trait-systemArea: Trait systemC-bugCategory: This is a bug.F-trait_alias`#![feature(trait_alias)]`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.T-langRelevant to the language teamrequires-nightlyThis issue requires a nightly compiler in some way.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions