Skip to content

Commit f97b721

Browse files
committed
---
yaml --- r: 227061 b: refs/heads/master c: 8b68f58 h: refs/heads/master i: 227059: 1bc3303 v: v3
1 parent 67030f2 commit f97b721

File tree

3 files changed

+23
-11
lines changed

3 files changed

+23
-11
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 1f5739fb3cdaff001d1af138a7b9b096a06c94e8
2+
refs/heads/master: 8b68f58fef4ffb833c123f057638484fa59ded76
33
refs/heads/snap-stage3: 1af31d4974e33027a68126fa5a5a3c2c6491824f
44
refs/heads/try: b53c0f93eedcdedd4fd89bccc5a3a09d1c5cd23e
55
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105

trunk/src/librustc_trans/trans/type_of.rs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,13 @@ pub fn sizing_type_of<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>) -> Typ
224224

225225
ty::TyStruct(..) => {
226226
if t.is_simd() {
227-
let llet = type_of(cx, t.simd_type(cx.tcx()));
227+
let e = t.simd_type(cx.tcx());
228+
if !e.is_machine() {
229+
cx.sess().fatal(&format!("monomorphising SIMD type `{}` with \
230+
a non-machine element type `{}`",
231+
t, e))
232+
}
233+
let llet = type_of(cx, e);
228234
let n = t.simd_size(cx.tcx()) as u64;
229235
ensure_array_fits_in_address_space(cx, llet, n, t);
230236
Type::vector(&llet, n)
@@ -410,7 +416,13 @@ pub fn in_memory_type_of<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>) ->
410416
}
411417
ty::TyStruct(def, ref substs) => {
412418
if t.is_simd() {
413-
let llet = in_memory_type_of(cx, t.simd_type(cx.tcx()));
419+
let e = t.simd_type(cx.tcx());
420+
if !e.is_machine() {
421+
cx.sess().fatal(&format!("monomorphising SIMD type `{}` with \
422+
a non-machine element type `{}`",
423+
t, e))
424+
}
425+
let llet = in_memory_type_of(cx, e);
414426
let n = t.simd_size(cx.tcx()) as u64;
415427
ensure_array_fits_in_address_space(cx, llet, n, t);
416428
Type::vector(&llet, n)

trunk/src/librustc_typeck/check/mod.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4321,10 +4321,6 @@ pub fn check_instantiable(tcx: &ty::ctxt,
43214321

43224322
pub fn check_simd(tcx: &ty::ctxt, sp: Span, id: ast::NodeId) {
43234323
let t = tcx.node_id_to_type(id);
4324-
if t.needs_subst() {
4325-
span_err!(tcx.sess, sp, E0074, "SIMD vector cannot be generic");
4326-
return;
4327-
}
43284324
match t.sty {
43294325
ty::TyStruct(def, substs) => {
43304326
let fields = &def.struct_variant().fields;
@@ -4337,10 +4333,14 @@ pub fn check_simd(tcx: &ty::ctxt, sp: Span, id: ast::NodeId) {
43374333
span_err!(tcx.sess, sp, E0076, "SIMD vector should be homogeneous");
43384334
return;
43394335
}
4340-
if !e.is_machine() {
4341-
span_err!(tcx.sess, sp, E0077,
4342-
"SIMD vector element type should be machine type");
4343-
return;
4336+
match e.sty {
4337+
ty::TyParam(_) => { /* struct<T>(T, T, T, T) is ok */ }
4338+
_ if e.is_machine() => { /* struct(u8, u8, u8, u8) is ok */ }
4339+
_ => {
4340+
span_err!(tcx.sess, sp, E0077,
4341+
"SIMD vector element type should be machine type");
4342+
return;
4343+
}
43444344
}
43454345
}
43464346
_ => ()

0 commit comments

Comments
 (0)