Skip to content

Commit 76b2086

Browse files
committed
don't bug! if the unsized struct tail isn't [T], str, or a trait object
There are other types that can be in a DST struct’s tail: other DST structs, DST tuples, and possibly more. The only one we don’t want to allow is extern types, so I added a check for that
1 parent 38efc95 commit 76b2086

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/librustc_trans/mir/lvalue.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -239,12 +239,13 @@ impl<'a, 'tcx> LvalueRef<'tcx> {
239239
return simple();
240240
}
241241

242-
// If the type of the last field is [T] or str, then we don't need to do
243-
// any adjusments. Otherwise it must be a trait object.
244242
match field.ty.sty {
243+
// If the type of the last field is [T] or str, then we don't need
244+
// to do any adjustments.
245245
ty::TySlice(..) | ty::TyStr => return simple(),
246-
ty::TyDynamic(..) => (),
247-
_ => bug!("unexpected DST tail: {:?}", fty.sty),
246+
// extern types aren't allowed in struct tails, this is a bug
247+
ty::TyForeign(..) => bug!("extern type in a struct field"),
248+
_ => ()
248249
}
249250

250251
// We need to get the pointer manually now.

0 commit comments

Comments
 (0)