Skip to content

Commit c219cdf

Browse files
committed
Removed sizing parameter from struct_llfields.
1 parent 7971a47 commit c219cdf

File tree

2 files changed

+10
-18
lines changed

2 files changed

+10
-18
lines changed

src/librustc_trans/adt.rs

+9-17
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,12 @@ pub fn compute_fields<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>,
9090
/// and fill in the actual contents in a second pass to prevent
9191
/// unbounded recursion; see also the comments in `trans::type_of`.
9292
pub fn type_of<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>) -> Type {
93-
generic_type_of(cx, t, None, false)
93+
generic_type_of(cx, t, None)
9494
}
9595

9696
pub fn incomplete_type_of<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
9797
t: Ty<'tcx>, name: &str) -> Type {
98-
generic_type_of(cx, t, Some(name), false)
98+
generic_type_of(cx, t, Some(name))
9999
}
100100

101101
pub fn finish_type_of<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
@@ -114,7 +114,7 @@ pub fn finish_type_of<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
114114
_ => unreachable!()
115115
};
116116
let fields = compute_fields(cx, t, nonnull_variant_index as usize, true);
117-
llty.set_struct_body(&struct_llfields(cx, &fields, nonnull_variant, false),
117+
llty.set_struct_body(&struct_llfields(cx, &fields, nonnull_variant),
118118
packed)
119119
},
120120
_ => bug!("This function cannot handle {} with layout {:#?}", t, l)
@@ -123,10 +123,9 @@ pub fn finish_type_of<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
123123

124124
fn generic_type_of<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
125125
t: Ty<'tcx>,
126-
name: Option<&str>,
127-
sizing: bool) -> Type {
126+
name: Option<&str>) -> Type {
128127
let l = cx.layout_of(t);
129-
debug!("adt::generic_type_of t: {:?} name: {:?} sizing: {}", t, name, sizing);
128+
debug!("adt::generic_type_of t: {:?} name: {:?}", t, name);
130129
match *l {
131130
layout::CEnum { discr, .. } => Type::from_integer(cx, discr),
132131
layout::RawNullablePointer { nndiscr, .. } => {
@@ -146,11 +145,10 @@ fn generic_type_of<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
146145
let fields = compute_fields(cx, t, nndiscr as usize, false);
147146
match name {
148147
None => {
149-
Type::struct_(cx, &struct_llfields(cx, &fields, nonnull, sizing),
148+
Type::struct_(cx, &struct_llfields(cx, &fields, nonnull),
150149
nonnull.packed)
151150
}
152151
Some(name) => {
153-
assert_eq!(sizing, false);
154152
Type::named_struct(cx, name)
155153
}
156154
}
@@ -161,13 +159,12 @@ fn generic_type_of<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
161159
let fields = compute_fields(cx, t, 0, true);
162160
match name {
163161
None => {
164-
let fields = struct_llfields(cx, &fields, &variant, sizing);
162+
let fields = struct_llfields(cx, &fields, &variant);
165163
Type::struct_(cx, &fields, variant.packed)
166164
}
167165
Some(name) => {
168166
// Hypothesis: named_struct's can never need a
169167
// drop flag. (... needs validation.)
170-
assert_eq!(sizing, false);
171168
Type::named_struct(cx, name)
172169
}
173170
}
@@ -256,19 +253,14 @@ pub fn struct_llfields_index(variant: &layout::Struct, index: usize) -> usize {
256253

257254

258255
pub fn struct_llfields<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, field_tys: &Vec<Ty<'tcx>>,
259-
variant: &layout::Struct,
260-
sizing: bool) -> Vec<Type> {
261-
if sizing {
262-
bug!();
263-
}
256+
variant: &layout::Struct) -> Vec<Type> {
264257
debug!("struct_llfields: variant: {:?}", variant);
265258
let mut first_field = true;
266259
let mut min_offset = 0;
267260
let mut result: Vec<Type> = Vec::with_capacity(field_tys.len() * 2);
268261
let field_iter = variant.field_index_by_increasing_offset().map(|i| {
269262
(i, field_tys[i as usize], variant.offsets[i as usize].bytes()) });
270-
for (index, ty, target_offset) in field_iter.filter(
271-
|&(_, ty, _)| !sizing || cx.shared().type_is_sized(ty)) {
263+
for (index, ty, target_offset) in field_iter {
272264
if first_field {
273265
debug!("struct_llfields: {} ty: {} min_offset: {} target_offset: {}",
274266
index, ty, min_offset, target_offset);

src/librustc_trans/mir/lvalue.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ impl<'a, 'tcx> LvalueRef<'tcx> {
132132

133133
let alignment = self.alignment | Alignment::from_packed(st.packed);
134134

135-
let llfields = adt::struct_llfields(ccx, fields, st, false);
135+
let llfields = adt::struct_llfields(ccx, fields, st);
136136
let ptr_val = if needs_cast {
137137
let real_ty = Type::struct_(ccx, &llfields[..], st.packed);
138138
bcx.pointercast(self.llval, real_ty.ptr_to())

0 commit comments

Comments
 (0)