]> git.lizzy.rs Git - rust.git/blob - src/test/run-pass/associated-types-normalize-unifield-struct.rs
2288e19aae0bceaaa59131547736cc9cc3653fc9
[rust.git] / src / test / run-pass / associated-types-normalize-unifield-struct.rs
1 // Copyright 2015 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10
11 // Regression test for issue #21010: Normalize associated types in
12 // various special paths in the `type_is_immediate` function.
13
14
15 pub trait OffsetState: Sized {}
16 pub trait Offset {
17     type State: OffsetState;
18     fn dummy(&self) { }
19 }
20
21 #[derive(Copy)] pub struct X;
22 impl Offset for X { type State = Y; }
23
24 #[derive(Copy)] pub struct Y;
25 impl OffsetState for Y {}
26
27 pub fn now() -> DateTime<X> { from_utc(Y) }
28
29 pub struct DateTime<Off: Offset> { pub offset: Off::State }
30 pub fn from_utc<Off: Offset>(offset: Off::State) -> DateTime<Off> { DateTime { offset: offset } }
31
32 pub fn main() {
33     let _x = now();
34 }