-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
C-bugCategory: This is a bug.Category: This is a bug.F-inherent_associated_types`#![feature(inherent_associated_types)]``#![feature(inherent_associated_types)]`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.requires-nightlyThis issue requires a nightly compiler in some way.This issue requires a nightly compiler in some way.
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
Metadata
Metadata
Assignees
Labels
C-bugCategory: This is a bug.Category: This is a bug.F-inherent_associated_types`#![feature(inherent_associated_types)]``#![feature(inherent_associated_types)]`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.requires-nightlyThis issue requires a nightly compiler in some way.This issue requires a nightly compiler in some way.
Type
Projects
Status
Done