Skip to content

Bad unconstrained type parameter error #1019

@philberty

Description

@philberty

I tried this code:

trait A<T> {                                                                                                         
    type Output;                                                                                                                         
                                                                        
    fn test(self, a: &T) -> &Self::Output;
}

struct Foo<T>{
    start: T,
    end: T,
}

impl<T> A<T> for Foo<usize> {
    type Output = T;

    fn test(self, a: &T) -> &Self::Output {
        a
    }
}

I expected to see this happen: compile without error

Instead, this happened:

<source>:12:6: error: unconstrained type parameter
   12 | impl<T> A<T> for Foo<usize> {
      |      ^

see: https://godbolt.org/z/aK4T4xEGq

Meta

  • What version of Rust GCC were you using, git sha if possible. b82408f

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions