Skip to content

Commit 1673cbd

Browse files
committed
Add tests and snapshot of current result
1 parent c0378ae commit 1673cbd

6 files changed

Lines changed: 164 additions & 0 deletions

File tree

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
//@ check-pass
2+
3+
#![deny(dead_code)]
4+
5+
trait Tr {
6+
type A;
7+
type B;
8+
type C: Default;
9+
type D;
10+
type E;
11+
type F;
12+
type G;
13+
type H;
14+
}
15+
16+
impl Tr for i32 {
17+
type A = Self;
18+
type B = Self;
19+
type C = Self;
20+
type D = Self;
21+
type E = Self;
22+
type F = Self;
23+
type G = Self;
24+
type H = Self;
25+
}
26+
27+
trait Tr2 {
28+
type A;
29+
}
30+
31+
impl Tr2 for i32 {
32+
type A = Self;
33+
}
34+
35+
struct Foo<T: Tr2> {
36+
_x: T::A,
37+
}
38+
39+
struct Bar<T> {
40+
_x: T
41+
}
42+
43+
impl<T> Bar<T>
44+
where
45+
T: Tr2<A = i32>
46+
{}
47+
48+
type Baz<T> = <T as Tr>::G;
49+
50+
struct FooBaz<T: Tr> {
51+
_x: Baz<T>,
52+
}
53+
54+
fn foo<T: Tr>(t: impl Tr<A = T>) -> impl Tr
55+
where
56+
T::B: Copy
57+
{
58+
let _a: T::C = Default::default();
59+
baz::<T::F>();
60+
t
61+
}
62+
fn bar<T: ?Sized>() {}
63+
fn baz<T>() {}
64+
65+
fn main() {
66+
foo::<i32>(42);
67+
bar::<dyn Tr2<A = i32>>();
68+
let _d: <i32 as Tr>::D = Default::default();
69+
baz::<<i32 as Tr>::E>();
70+
baz::<Foo<i32>>();
71+
baz::<Bar<i32>>();
72+
baz::<FooBaz<i32>>();
73+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
//@ check-pass
2+
3+
#![deny(dead_code)]
4+
5+
trait Trait { type Ty; }
6+
7+
impl Trait for () { type Ty = (); }
8+
9+
pub struct Wrap(Inner<()>);
10+
struct Inner<T: Trait>(T::Ty); // <- use of QPath::TypeRelative `Ty` in a non-body only
11+
12+
impl Wrap {
13+
pub fn live(self) { _ = self.0; }
14+
}
15+
16+
fn main() {}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
//@ check-pass
2+
3+
#![deny(dead_code)]
4+
5+
pub struct A;
6+
7+
trait B {
8+
type Assoc;
9+
}
10+
11+
impl B for A {
12+
type Assoc = A;
13+
}
14+
15+
const X: <A as B>::Assoc = A;
16+
17+
fn main() {
18+
let _x: A = X;
19+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
//@ check-pass
2+
3+
#![deny(dead_code)]
4+
5+
pub struct A;
6+
7+
trait B {
8+
type Assoc;
9+
}
10+
11+
impl B for A {
12+
type Assoc = A;
13+
}
14+
15+
trait C {}
16+
17+
impl C for <A as B>::Assoc {}
18+
19+
fn foo<T: C>() {}
20+
21+
fn main() {
22+
foo::<A>();
23+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
//@ check-pass
2+
3+
#![feature(inherent_associated_types)]
4+
#![allow(incomplete_features)]
5+
#[deny(dead_code)]
6+
7+
fn main() {
8+
let _: Struct::Item = ();
9+
}
10+
11+
struct Struct;
12+
impl Struct { type Item = (); }
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
//@ check-pass
2+
3+
#![deny(dead_code)]
4+
5+
trait Tr {
6+
type X;
7+
}
8+
9+
struct T;
10+
11+
impl Tr for T {
12+
type X = Self;
13+
}
14+
15+
fn foo<T: Tr>() where {
16+
let _: T::X;
17+
}
18+
19+
fn main() {
20+
foo::<T>();
21+
}

0 commit comments

Comments
 (0)