From 2868404fcaed4030935ffafa87f5ea31ba4cd5bb Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Tue, 13 Jan 2015 16:03:07 -0500 Subject: Normalize associated types in the type_is_newtype_immediate pass. Fixes #21010. --- .../associated-types-normalize-unifield-struct.rs | 32 ++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 src/test/run-pass/associated-types-normalize-unifield-struct.rs (limited to 'src/test') diff --git a/src/test/run-pass/associated-types-normalize-unifield-struct.rs b/src/test/run-pass/associated-types-normalize-unifield-struct.rs new file mode 100644 index 00000000000..c517f61de0c --- /dev/null +++ b/src/test/run-pass/associated-types-normalize-unifield-struct.rs @@ -0,0 +1,32 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Regression test for issue #21010: Normalize associated types in +// various special paths in the `type_is_immediate` function. + +#![allow(unstable)] + +pub trait OffsetState: Sized {} +pub trait Offset { type State: OffsetState; } + +#[derive(Copy)] pub struct X; +impl Offset for X { type State = Y; } + +#[derive(Copy)] pub struct Y; +impl OffsetState for Y {} + +pub fn now() -> DateTime { from_utc(Y) } + +pub struct DateTime { pub offset: Off::State } +pub fn from_utc(offset: Off::State) -> DateTime { DateTime { offset: offset } } + +pub fn main() { + let _x = now(); +} -- cgit 1.4.1-3-g733a5