]> git.proxmox.com Git - rustc.git/blame - src/test/ui/specialization/specialization-default-projection.rs
Update unsuspicious file list
[rustc.git] / src / test / ui / specialization / specialization-default-projection.rs
CommitLineData
f035d41b 1#![feature(specialization)] //~ WARN the feature `specialization` is incomplete
54a0048b
SL
2
3// Make sure we can't project defaulted associated types
4
5trait Foo {
6 type Assoc;
7}
8
9impl<T> Foo for T {
10 default type Assoc = ();
11}
12
13impl Foo for u8 {
14 type Assoc = String;
15}
16
17fn generic<T>() -> <T as Foo>::Assoc {
18 // `T` could be some downstream crate type that specializes (or,
19 // for that matter, `u8`).
20
21 () //~ ERROR mismatched types
22}
23
24fn monomorphic() -> () {
25 // Even though we know that `()` is not specialized in a
26 // downstream crate, typeck refuses to project here.
27
28 generic::<()>() //~ ERROR mismatched types
29}
30
31fn main() {
32 // No error here, we CAN project from `u8`, as there is no `default`
33 // in that impl.
34 let s: String = generic::<u8>();
35 println!("{}", s); // bad news if this all compiles
36}