Skip to content

Unconstrained inference variables in generic impl block #3242

Closed
@philberty

Description

@philberty

Summary

There is an issue with this test case it was issue-1773.rs but that issue references different code.

Reproducer

I tried this code:

#[lang = "sized"]
pub trait Sized {}

trait Foo<T> {
    type A;

    fn test(a: Self::A) -> Self::A {
        a
    }
}

struct Bar<T>(T);
impl<T> Foo<T> for Bar<i32> {
    type A = T;
}

fn main() {
    let a;
    a = Bar(123);

    let b;
    b = Bar::test(a.0);
}

Godbolt link

No response

Actual behavior

The current behavior is...

test.rs:21:9: error: type annotations needed [E0282]
   21 |     let b;
      |         ^
test.rs:22:5: error: type annotations needed [E0282]
   22 |     b = Bar::test(a.0);
      |     ^
test.rs:22:14: error: type annotations needed [E0282]
   22 |     b = Bar::test(a.0);
      |              ^~~~
crab1: error: type annotations needed [E0282]
test.rs:22:14: error: type annotations needed [E0282]
crab1: error: type annotations needed [E0282]
crab1: error: type annotations needed [E0282]

Expected behavior

I expected to see...

compiles without error

GCC Version

0e6135c

Metadata

Metadata

Assignees

Type

Projects

Status

Done

Relationships

None yet

Development

No branches or pull requests

Issue actions