Closed
Description
The following code should compile since for Subj<(i32,)>
one has T == i32
and thus Subj::Un == i32
. However, the current implementation incorrectly substitutes T
with (i32,)
leading to a compile error after encountering the let-statement.
#![feature(inherent_associated_types)]
#![allow(incomplete_features)]
struct Subj<T>(T);
impl<T> Subj<(T,)> {
type Un = T;
}
fn main() {
let _: Subj::<(i32,)>::Un = 0i32;
}
error[E0308]: mismatched types
--> src/main.rs:11:33
|
11 | let _: Subj::<(i32,)>::Un = 0i32;
| ------------------ ^^^^ expected tuple, found `i32`
| |
| expected due to this
|
= note: expected tuple `(i32,)`
found type `i32`
help: use a trailing comma to create a tuple with one element
|
11 | let _: Subj::<(i32,)>::Un = (0i32,);
| + ++
For comparison, the analogous program involving inherent associated functions successfully compiles:
struct Subj<T>(T);
impl<T: Default> Subj<(T,)> {
fn un() -> T { T::default() }
}
fn main() {
let _: i32 = Subj::<(i32,)>::un();
}
@rustbot label T-compiler requires-nightly F-inherent_associated_types
@rustbot claim