Skip to content

Commit d80ff12

Browse files
committed
Rename get_len() to get_meta()
The functions is useful for all kinds of fat pointers, but get_len() just feels so wrong for trait object fat pointers. Let's use get_meta() because that's rather neutral.
1 parent 2375743 commit d80ff12

File tree

8 files changed

+21
-21
lines changed

8 files changed

+21
-21
lines changed

src/librustc_trans/trans/_match.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -886,9 +886,9 @@ fn compare_values<'blk, 'tcx>(cx: Block<'blk, 'tcx>,
886886
&format!("comparison of `{}`", rhs_t),
887887
StrEqFnLangItem);
888888
let lhs_data = Load(cx, expr::get_dataptr(cx, lhs));
889-
let lhs_len = Load(cx, expr::get_len(cx, lhs));
889+
let lhs_len = Load(cx, expr::get_meta(cx, lhs));
890890
let rhs_data = Load(cx, expr::get_dataptr(cx, rhs));
891-
let rhs_len = Load(cx, expr::get_len(cx, rhs));
891+
let rhs_len = Load(cx, expr::get_meta(cx, rhs));
892892
callee::trans_lang_call(cx, did, &[lhs_data, lhs_len, rhs_data, rhs_len], None, debug_loc)
893893
}
894894

@@ -910,14 +910,14 @@ fn compare_values<'blk, 'tcx>(cx: Block<'blk, 'tcx>,
910910

911911
let rhs_str = alloc_ty(cx, ty_str_slice, "rhs_str");
912912
Store(cx, GEPi(cx, rhs, &[0, 0]), expr::get_dataptr(cx, rhs_str));
913-
Store(cx, C_uint(cx.ccx(), pat_len), expr::get_len(cx, rhs_str));
913+
Store(cx, C_uint(cx.ccx(), pat_len), expr::get_meta(cx, rhs_str));
914914

915915
let lhs_str;
916916
if val_ty(lhs) == val_ty(rhs) {
917917
// Both the discriminant and the pattern are thin pointers
918918
lhs_str = alloc_ty(cx, ty_str_slice, "lhs_str");
919919
Store(cx, GEPi(cx, lhs, &[0, 0]), expr::get_dataptr(cx, lhs_str));
920-
Store(cx, C_uint(cx.ccx(), pat_len), expr::get_len(cx, lhs_str));
920+
Store(cx, C_uint(cx.ccx(), pat_len), expr::get_meta(cx, lhs_str));
921921
}
922922
else {
923923
// The discriminant is a fat pointer
@@ -1196,9 +1196,9 @@ fn compile_submatch_continue<'a, 'p, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
11961196
let llty = type_of::type_of(bcx.ccx(), unsized_ty);
11971197
let scratch = alloca_no_lifetime(bcx, llty, "__struct_field_fat_ptr");
11981198
let data = adt::trans_field_ptr(bcx, &*repr, struct_val, 0, arg_count);
1199-
let len = Load(bcx, expr::get_len(bcx, val.val));
1199+
let len = Load(bcx, expr::get_meta(bcx, val.val));
12001200
Store(bcx, data, expr::get_dataptr(bcx, scratch));
1201-
Store(bcx, len, expr::get_len(bcx, scratch));
1201+
Store(bcx, len, expr::get_meta(bcx, scratch));
12021202
field_vals.push(scratch);
12031203
}
12041204
_ => {}

src/librustc_trans/trans/base.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -835,7 +835,7 @@ pub fn store_ty<'blk, 'tcx>(cx: Block<'blk, 'tcx>, v: ValueRef, dst: ValueRef, t
835835

836836
if common::type_is_fat_ptr(cx.tcx(), t) {
837837
Store(cx, ExtractValue(cx, v, abi::FAT_PTR_ADDR), expr::get_dataptr(cx, dst));
838-
Store(cx, ExtractValue(cx, v, abi::FAT_PTR_EXTRA), expr::get_len(cx, dst));
838+
Store(cx, ExtractValue(cx, v, abi::FAT_PTR_EXTRA), expr::get_meta(cx, dst));
839839
} else {
840840
let store = Store(cx, from_arg_ty(cx, v, t), to_arg_ty_ptr(cx, dst, t));
841841
unsafe {
@@ -1389,7 +1389,7 @@ pub fn create_datums_for_fn_args<'a, 'tcx>(mut bcx: Block<'a, 'tcx>,
13891389
arg_scope_id, (data, extra),
13901390
|(data, extra), bcx, dst| {
13911391
Store(bcx, data, expr::get_dataptr(bcx, dst));
1392-
Store(bcx, extra, expr::get_len(bcx, dst));
1392+
Store(bcx, extra, expr::get_meta(bcx, dst));
13931393
bcx
13941394
}))
13951395
} else {
@@ -1420,7 +1420,7 @@ pub fn create_datums_for_fn_args<'a, 'tcx>(mut bcx: Block<'a, 'tcx>,
14201420
let data = get_param(bcx.fcx.llfn, idx);
14211421
let extra = get_param(bcx.fcx.llfn, idx + 1);
14221422
Store(bcx, data, expr::get_dataptr(bcx, lldest));
1423-
Store(bcx, extra, expr::get_len(bcx, lldest));
1423+
Store(bcx, extra, expr::get_meta(bcx, lldest));
14241424
idx += 2;
14251425
} else {
14261426
let datum = datum::Datum::new(
@@ -1822,7 +1822,7 @@ fn trans_enum_variant_or_tuple_like_struct<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx
18221822
i);
18231823
if common::type_is_fat_ptr(bcx.tcx(), arg_ty) {
18241824
Store(bcx, get_param(fcx.llfn, llarg_idx), expr::get_dataptr(bcx, lldestptr));
1825-
Store(bcx, get_param(fcx.llfn, llarg_idx + 1), expr::get_len(bcx, lldestptr));
1825+
Store(bcx, get_param(fcx.llfn, llarg_idx + 1), expr::get_meta(bcx, lldestptr));
18261826
llarg_idx += 2;
18271827
} else {
18281828
let arg = get_param(fcx.llfn, llarg_idx);

src/librustc_trans/trans/callee.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1128,7 +1128,7 @@ pub fn trans_arg_datum<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
11281128

11291129
if common::type_is_fat_ptr(bcx.tcx(), formal_arg_ty) {
11301130
llargs.push(Load(bcx, expr::get_dataptr(bcx, val)));
1131-
llargs.push(Load(bcx, expr::get_len(bcx, val)));
1131+
llargs.push(Load(bcx, expr::get_meta(bcx, val)));
11321132
} else {
11331133
llargs.push(val);
11341134
}

src/librustc_trans/trans/expr.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ pub fn trans<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
282282
return DatumBlock::new(bcx, datum);
283283
}
284284

285-
pub fn get_len(bcx: Block, fat_ptr: ValueRef) -> ValueRef {
285+
pub fn get_meta(bcx: Block, fat_ptr: ValueRef) -> ValueRef {
286286
GEPi(bcx, fat_ptr, &[0, abi::FAT_PTR_EXTRA])
287287
}
288288

@@ -292,7 +292,7 @@ pub fn get_dataptr(bcx: Block, fat_ptr: ValueRef) -> ValueRef {
292292

293293
pub fn copy_fat_ptr(bcx: Block, src_ptr: ValueRef, dst_ptr: ValueRef) {
294294
Store(bcx, Load(bcx, get_dataptr(bcx, src_ptr)), get_dataptr(bcx, dst_ptr));
295-
Store(bcx, Load(bcx, get_len(bcx, src_ptr)), get_len(bcx, dst_ptr));
295+
Store(bcx, Load(bcx, get_meta(bcx, src_ptr)), get_meta(bcx, dst_ptr));
296296
}
297297

298298
/// Retrieve the information we are losing (making dynamic) in an unsizing
@@ -454,7 +454,7 @@ fn coerce_unsized<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
454454
// load out the original data pointer so we can repackage
455455
// it.
456456
(Load(bcx, get_dataptr(bcx, source.val)),
457-
Some(Load(bcx, get_len(bcx, source.val))))
457+
Some(Load(bcx, get_meta(bcx, source.val))))
458458
} else {
459459
let val = if source.kind.is_by_ref() {
460460
load_ty(bcx, source.val, source.ty)
@@ -473,7 +473,7 @@ fn coerce_unsized<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
473473
let base = PointerCast(bcx, base, ptr_ty);
474474

475475
Store(bcx, base, get_dataptr(bcx, target.val));
476-
Store(bcx, info, get_len(bcx, target.val));
476+
Store(bcx, info, get_meta(bcx, target.val));
477477
}
478478

479479
// This can be extended to enums and tuples in the future.
@@ -729,8 +729,8 @@ fn trans_field<'blk, 'tcx, F>(bcx: Block<'blk, 'tcx>,
729729
} else {
730730
let scratch = rvalue_scratch_datum(bcx, d.ty, "");
731731
Store(bcx, d.val, get_dataptr(bcx, scratch.val));
732-
let info = Load(bcx, get_len(bcx, base_datum.val));
733-
Store(bcx, info, get_len(bcx, scratch.val));
732+
let info = Load(bcx, get_meta(bcx, base_datum.val));
733+
Store(bcx, info, get_meta(bcx, scratch.val));
734734

735735
// Always generate an lvalue datum, because this pointer doesn't own
736736
// the data and cleanup is scheduled elsewhere.

src/librustc_trans/trans/foreign.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ pub fn trans_native_call<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
302302
"__arg");
303303
if type_is_fat_ptr(ccx.tcx(), passed_arg_tys[i]) {
304304
Store(bcx, llargs_rust[i + offset], expr::get_dataptr(bcx, scratch));
305-
Store(bcx, llargs_rust[i + offset + 1], expr::get_len(bcx, scratch));
305+
Store(bcx, llargs_rust[i + offset + 1], expr::get_meta(bcx, scratch));
306306
offset += 1;
307307
} else {
308308
base::store_ty(bcx, llarg_rust, scratch, passed_arg_tys[i]);

src/librustc_trans/trans/glue.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ fn trans_struct_drop<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
389389
let (_, bcx) = if type_is_sized(bcx.tcx(), t) {
390390
invoke(bcx, dtor_addr, &[v0], dtor_ty, DebugLoc::None)
391391
} else {
392-
let args = [Load(bcx, expr::get_dataptr(bcx, v0)), Load(bcx, expr::get_len(bcx, v0))];
392+
let args = [Load(bcx, expr::get_dataptr(bcx, v0)), Load(bcx, expr::get_meta(bcx, v0))];
393393
invoke(bcx, dtor_addr, &args, dtor_ty, DebugLoc::None)
394394
};
395395

src/librustc_trans/trans/intrinsic.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,7 @@ pub fn trans_intrinsic_call<'a, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
449449
} else {
450450
let scratch = rvalue_scratch_datum(bcx, tp_ty, "tmp");
451451
Store(bcx, llargs[0], expr::get_dataptr(bcx, scratch.val));
452-
Store(bcx, llargs[1], expr::get_len(bcx, scratch.val));
452+
Store(bcx, llargs[1], expr::get_meta(bcx, scratch.val));
453453
fcx.schedule_lifetime_end(cleanup::CustomScope(cleanup_scope), scratch.val);
454454
scratch.val
455455
};

src/librustc_trans/trans/tvec.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ pub fn get_base_and_len<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
310310
ty::TyArray(_, n) => get_fixed_base_and_len(bcx, llval, n),
311311
ty::TySlice(_) | ty::TyStr => {
312312
let base = Load(bcx, expr::get_dataptr(bcx, llval));
313-
let len = Load(bcx, expr::get_len(bcx, llval));
313+
let len = Load(bcx, expr::get_meta(bcx, llval));
314314
(base, len)
315315
}
316316

0 commit comments

Comments
 (0)