Skip to content

Commit bfc38e5

Browse files
committed
---
yaml --- r: 174106 b: refs/heads/batch c: 2868404 h: refs/heads/master v: v3
1 parent 28de299 commit bfc38e5

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
@@ -29,7 +29,7 @@ refs/tags/0.12.0: f0c419429ef30723ceaf6b42f9b5a2aeb5d2e2d1
2929
refs/heads/issue-18208-method-dispatch-2: 9e1eae4fb9b6527315b4441cf8a0f5ca911d1671
3030
refs/heads/automation-fail: 1bf06495443584539b958873e04cc2f864ab10e4
3131
refs/heads/issue-18208-method-dispatch-3-quick-reject: 2009f85b9f99dedcec4404418eda9ddba90258a2
32-
refs/heads/batch: ff6085f401844bc5cb07b804f0d2258bb5c2b9a8
32+
refs/heads/batch: 2868404fcaed4030935ffafa87f5ea31ba4cd5bb
3333
refs/heads/building: 126db549b038c84269a1e4fe46f051b2c15d6970
3434
refs/heads/beta: 44a287e6eb22ec3c2a687fc156813577464017f7
3535
refs/heads/windistfix: 7608dbad651f02e837ed05eef3d74a6662a6e928

branches/batch/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)