Skip to content

Commit 4d215e1

Browse files
eddybalexcrichton
authored andcommitted
---
yaml --- r: 278269 b: refs/heads/beta c: aacc890 h: refs/heads/master i: 278267: f3a057a
1 parent b02dacf commit 4d215e1

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ refs/tags/0.9: 36870b185fc5f5486636d4515f0e22677493f225
2323
refs/tags/0.10: ac33f2b15782272ae348dbd7b14b8257b2148b5a
2424
refs/tags/0.11.0: e1247cb1d0d681be034adb4b558b5a0c0d5720f9
2525
refs/tags/0.12.0: f0c419429ef30723ceaf6b42f9b5a2aeb5d2e2d1
26-
refs/heads/beta: dcd8d2496dfbbc3d2fcbf7e7027455eb1276f98a
26+
refs/heads/beta: aacc89072a3d8c7f290641d69b3c3879995a119a
2727
refs/tags/1.0.0-alpha: e42bd6d93a1d3433c486200587f8f9e12590a4d7
2828
refs/heads/tmp: e06d2ad9fcd5027bcaac5b08fc9aa39a49d0ecd3
2929
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f

branches/beta/src/librustc_trans/type_of.rs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ use abi::FnType;
1717
use adt;
1818
use common::*;
1919
use machine;
20+
use rustc::traits::ProjectionMode;
2021
use rustc::ty::{self, Ty, TypeFoldable};
2122

2223
use type_::Type;
@@ -121,6 +122,37 @@ pub fn sizing_type_of<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>) -> Typ
121122
debug!("--> mapped t={:?} to llsizingty={:?}", t, llsizingty);
122123

123124
cx.llsizingtypes().borrow_mut().insert(t, llsizingty);
125+
126+
// FIXME(eddyb) Temporary sanity check for ty::layout.
127+
let infcx = infer::normalizing_infer_ctxt(cx.tcx(), &cx.tcx().tables, ProjectionMode::Any);
128+
match t.layout(&infcx) {
129+
Ok(layout) => {
130+
if !type_is_sized(cx.tcx(), t) {
131+
if !layout.is_unsized() {
132+
bug!("layout should be unsized for type `{}` / {:#?}",
133+
t, layout);
134+
}
135+
136+
// Unsized types get turned into a fat pointer for LLVM.
137+
return llsizingty;
138+
}
139+
let r = layout.size(&cx.tcx().data_layout).bytes();
140+
let l = machine::llsize_of_alloc(cx, llsizingty);
141+
if r != l {
142+
bug!("size differs (rustc: {}, llvm: {}) for type `{}` / {:#?}",
143+
r, l, t, layout);
144+
}
145+
let r = layout.align(&cx.tcx().data_layout).abi();
146+
let l = machine::llalign_of_min(cx, llsizingty) as u64;
147+
if r != l {
148+
bug!("align differs (rustc: {}, llvm: {}) for type `{}` / {:#?}",
149+
r, l, t, layout);
150+
}
151+
}
152+
Err(e) => {
153+
bug!("failed to get layout for `{}`: {}", t, e);
154+
}
155+
}
124156
llsizingty
125157
}
126158

0 commit comments

Comments
 (0)