-
Notifications
You must be signed in to change notification settings - Fork 12.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Trait impl hidden by trait bound on function #51586
Comments
@stokhos, I looked at issues labeled with A-specialization and they seem to relate to the specialization feature in Rust. The example code in this issue does not make use of this feature, only of plain old trait impls. Is this label appropriate? |
Seems like a bug? Just to illustrate that this is not specific to #![crate_type = "lib"]
struct A;
struct B;
trait Foo<T> {}
impl Foo<B> for A {}
fn f<T0>(_: T0) where A: Foo<T0> {
g::<_>(B); // expected type `T0`
}
fn g<T1>(_: T1) where A: Foo<T1> {} But this works fine: struct A;
struct B;
trait Foo<T> {}
impl Foo<B> for A {}
fn main() { g::<_>(B); }
fn g<T>(_: T) where A: Foo<T> {} |
@Centril: As requested, I tried with older rust versions and the original example is rejected even by rust 1.0.0: https://godbolt.org/g/ECbAi4 |
@stephaneyfx Great, thank you ❤️; then at least there's no regression :) |
This looks very much like #24066 and the original example not compiling seems to be intentional: see comments starting at #33108 (comment), especially from @eddyb and @aturon. |
I could have sworn I read a similar issue a couple of days/weeks ago but I could not find it back. #37138 seems related too.
Shoudn't this code compile? playground
The text was updated successfully, but these errors were encountered: