]> git.lizzy.rs Git - rust.git/blob - tests/ui/associated-types/associated-types-normalize-unifield-struct.rs
Rollup merge of #106427 - mejrs:translation_errors, r=davidtwco
[rust.git] / tests / ui / associated-types / associated-types-normalize-unifield-struct.rs
1 // run-pass
2 // Regression test for issue #21010: Normalize associated types in
3 // various special paths in the `type_is_immediate` function.
4
5 pub trait OffsetState: Sized {}
6 pub trait Offset {
7     type State: OffsetState;
8     fn dummy(&self) { }
9 }
10
11 #[derive(Copy, Clone)] pub struct X;
12 impl Offset for X { type State = Y; }
13
14 #[derive(Copy, Clone)] pub struct Y;
15 impl OffsetState for Y {}
16
17 pub fn now() -> DateTime<X> { from_utc(Y) }
18
19 pub struct DateTime<Off: Offset> { pub offset: Off::State }
20 pub fn from_utc<Off: Offset>(offset: Off::State) -> DateTime<Off> { DateTime { offset: offset } }
21
22 pub fn main() {
23     let _x = now();
24 }