Skip to content

Commit 4591b02

Browse files
committed
---
yaml --- r: 175977 b: refs/heads/try c: 2868404 h: refs/heads/master i: 175975: 77b63ee v: v3
1 parent 955177f commit 4591b02

File tree

3 files changed

+40
-5
lines changed

3 files changed

+40
-5
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: a530cc9706324ad44dba464d541a807eb5afdb08
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 777435990e0e91df6b72ce80c9b6fa485eeb5daa
5-
refs/heads/try: ff6085f401844bc5cb07b804f0d2258bb5c2b9a8
5+
refs/heads/try: 2868404fcaed4030935ffafa87f5ea31ba4cd5bb
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
88
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596

branches/try/src/librustc_trans/trans/common.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -217,12 +217,15 @@ pub fn type_needs_drop<'tcx>(cx: &ty::ctxt<'tcx>,
217217
ty::type_contents(cx, ty).needs_drop(cx)
218218
}
219219

220-
fn type_is_newtype_immediate<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
221-
ty: Ty<'tcx>) -> bool {
220+
fn type_is_newtype_immediate<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, ty: Ty<'tcx>) -> bool {
222221
match ty.sty {
223222
ty::ty_struct(def_id, substs) => {
224-
let fields = ty::struct_fields(ccx.tcx(), def_id, substs);
225-
fields.len() == 1 && type_is_immediate(ccx, fields[0].mt.ty)
223+
let fields = ty::lookup_struct_fields(ccx.tcx(), def_id);
224+
fields.len() == 1 && {
225+
let ty = ty::lookup_field_type(ccx.tcx(), def_id, fields[0].id, substs);
226+
let ty = monomorphize::normalize_associated_type(ccx.tcx(), &ty);
227+
type_is_immediate(ccx, ty)
228+
}
226229
}
227230
_ => false
228231
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
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+
#![allow(unstable)]
15+
16+
pub trait OffsetState: Sized {}
17+
pub trait Offset { type State: OffsetState; }
18+
19+
#[derive(Copy)] pub struct X;
20+
impl Offset for X { type State = Y; }
21+
22+
#[derive(Copy)] pub struct Y;
23+
impl OffsetState for Y {}
24+
25+
pub fn now() -> DateTime<X> { from_utc(Y) }
26+
27+
pub struct DateTime<Off: Offset> { pub offset: Off::State }
28+
pub fn from_utc<Off: Offset>(offset: Off::State) -> DateTime<Off> { DateTime { offset: offset } }
29+
30+
pub fn main() {
31+
let _x = now();
32+
}

0 commit comments

Comments
 (0)