Skip to content

Commit 397283d

Browse files
committed
rename extra -> meta in place
1 parent 50c00a9 commit 397283d

File tree

5 files changed

+34
-34
lines changed

5 files changed

+34
-34
lines changed

src/librustc_mir/const_eval.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,9 @@ pub fn op_to_const<'tcx>(
119119
}
120120
};
121121
let val = match normalized_op {
122-
Err(MemPlace { ptr, align, extra }) => {
122+
Err(MemPlace { ptr, align, meta }) => {
123123
// extract alloc-offset pair
124-
assert!(extra.is_none());
124+
assert!(meta.is_none());
125125
let ptr = ptr.to_ptr()?;
126126
let alloc = ecx.memory.get(ptr.alloc_id)?;
127127
assert!(alloc.align.abi() >= align.abi());

src/librustc_mir/interpret/eval_context.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ impl<'a, 'mir, 'tcx: 'mir, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tc
330330
}
331331

332332
/// Return the actual dynamic size and alignment of the place at the given type.
333-
/// Only the "extra" (metadata) part of the place matters.
333+
/// Only the `meta` part of the place matters.
334334
pub(super) fn size_and_align_of(
335335
&self,
336336
metadata: Option<Scalar<M::PointerTag>>,
@@ -416,7 +416,7 @@ impl<'a, 'mir, 'tcx: 'mir, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tc
416416
&self,
417417
mplace: MPlaceTy<'tcx, M::PointerTag>
418418
) -> EvalResult<'tcx, (Size, Align)> {
419-
self.size_and_align_of(mplace.extra, mplace.layout)
419+
self.size_and_align_of(mplace.meta, mplace.layout)
420420
}
421421

422422
pub fn push_stack_frame(

src/librustc_mir/interpret/place.rs

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ pub struct MemPlace<Tag=(), Id=AllocId> {
3434
/// Metadata for unsized places. Interpretation is up to the type.
3535
/// Must not be present for sized types, but can be missing for unsized types
3636
/// (e.g. `extern type`).
37-
pub extra: Option<Scalar<Tag, Id>>,
37+
pub meta: Option<Scalar<Tag, Id>>,
3838
}
3939

4040
#[derive(Copy, Clone, Debug, Hash, PartialEq, Eq)]
@@ -97,7 +97,7 @@ impl MemPlace {
9797
MemPlace {
9898
ptr: self.ptr.with_default_tag(),
9999
align: self.align,
100-
extra: self.extra.map(Scalar::with_default_tag),
100+
meta: self.meta.map(Scalar::with_default_tag),
101101
}
102102
}
103103
}
@@ -109,7 +109,7 @@ impl<Tag> MemPlace<Tag> {
109109
MemPlace {
110110
ptr: self.ptr.erase_tag(),
111111
align: self.align,
112-
extra: self.extra.map(Scalar::erase_tag),
112+
meta: self.meta.map(Scalar::erase_tag),
113113
}
114114
}
115115

@@ -118,7 +118,7 @@ impl<Tag> MemPlace<Tag> {
118118
MemPlace {
119119
ptr,
120120
align,
121-
extra: None,
121+
meta: None,
122122
}
123123
}
124124

@@ -129,11 +129,11 @@ impl<Tag> MemPlace<Tag> {
129129

130130
#[inline(always)]
131131
pub fn to_scalar_ptr_align(self) -> (Scalar<Tag>, Align) {
132-
assert!(self.extra.is_none());
132+
assert!(self.meta.is_none());
133133
(self.ptr, self.align)
134134
}
135135

136-
/// Extract the ptr part of the mplace
136+
/// metact the ptr part of the mplace
137137
#[inline(always)]
138138
pub fn to_ptr(self) -> EvalResult<'tcx, Pointer<Tag>> {
139139
// At this point, we forget about the alignment information --
@@ -147,9 +147,9 @@ impl<Tag> MemPlace<Tag> {
147147
pub fn to_ref(self) -> Value<Tag> {
148148
// We ignore the alignment of the place here -- special handling for packed structs ends
149149
// at the `&` operator.
150-
match self.extra {
150+
match self.meta {
151151
None => Value::Scalar(self.ptr.into()),
152-
Some(extra) => Value::ScalarPair(self.ptr.into(), extra.into()),
152+
Some(meta) => Value::ScalarPair(self.ptr.into(), meta.into()),
153153
}
154154
}
155155
}
@@ -175,10 +175,10 @@ impl<'tcx, Tag> MPlaceTy<'tcx, Tag> {
175175
#[inline]
176176
pub(super) fn len(self, cx: impl HasDataLayout) -> EvalResult<'tcx, u64> {
177177
if self.layout.is_unsized() {
178-
// We need to consult `extra` metadata
178+
// We need to consult `meta` metadata
179179
match self.layout.ty.sty {
180180
ty::Slice(..) | ty::Str =>
181-
return self.mplace.extra.unwrap().to_usize(cx),
181+
return self.mplace.meta.unwrap().to_usize(cx),
182182
_ => bug!("len not supported on unsized type {:?}", self.layout.ty),
183183
}
184184
} else {
@@ -194,7 +194,7 @@ impl<'tcx, Tag> MPlaceTy<'tcx, Tag> {
194194
#[inline]
195195
pub(super) fn vtable(self) -> EvalResult<'tcx, Pointer<Tag>> {
196196
match self.layout.ty.sty {
197-
ty::Dynamic(..) => self.mplace.extra.unwrap().to_ptr(),
197+
ty::Dynamic(..) => self.mplace.meta.unwrap().to_ptr(),
198198
_ => bug!("vtable not supported on type {:?}", self.layout.ty),
199199
}
200200
}
@@ -283,9 +283,9 @@ impl
283283
let align = layout.align;
284284
let mplace = match *val {
285285
Value::Scalar(ptr) =>
286-
MemPlace { ptr: ptr.not_undef()?, align, extra: None },
287-
Value::ScalarPair(ptr, extra) =>
288-
MemPlace { ptr: ptr.not_undef()?, align, extra: Some(extra.not_undef()?) },
286+
MemPlace { ptr: ptr.not_undef()?, align, meta: None },
287+
Value::ScalarPair(ptr, meta) =>
288+
MemPlace { ptr: ptr.not_undef()?, align, meta: Some(meta.not_undef()?) },
289289
};
290290
Ok(MPlaceTy { mplace, layout })
291291
}
@@ -321,13 +321,13 @@ impl
321321
let field_layout = base.layout.field(self, usize::try_from(field).unwrap_or(0))?;
322322

323323
// Offset may need adjustment for unsized fields
324-
let (extra, offset) = if field_layout.is_unsized() {
324+
let (meta, offset) = if field_layout.is_unsized() {
325325
// re-use parent metadata to determine dynamic field layout
326-
let (_, align) = self.size_and_align_of(base.extra, field_layout)?;
327-
(base.extra, offset.abi_align(align))
326+
let (_, align) = self.size_and_align_of(base.meta, field_layout)?;
327+
(base.meta, offset.abi_align(align))
328328

329329
} else {
330-
// base.extra could be present; we might be accessing a sized field of an unsized
330+
// base.meta could be present; we might be accessing a sized field of an unsized
331331
// struct.
332332
(None, offset)
333333
};
@@ -338,7 +338,7 @@ impl
338338
// codegen -- mostly to see if we can get away with that
339339
.restrict_for_offset(offset); // must be last thing that happens
340340

341-
Ok(MPlaceTy { mplace: MemPlace { ptr, align, extra }, layout: field_layout })
341+
Ok(MPlaceTy { mplace: MemPlace { ptr, align, meta }, layout: field_layout })
342342
}
343343

344344
// Iterates over all fields of an array. Much more efficient than doing the
@@ -359,7 +359,7 @@ impl
359359
Ok((0..len).map(move |i| {
360360
let ptr = base.ptr.ptr_offset(i * stride, dl)?;
361361
Ok(MPlaceTy {
362-
mplace: MemPlace { ptr, align: base.align, extra: None },
362+
mplace: MemPlace { ptr, align: base.align, meta: None },
363363
layout
364364
})
365365
}))
@@ -383,9 +383,9 @@ impl
383383
};
384384
let ptr = base.ptr.ptr_offset(from_offset, self)?;
385385

386-
// Compute extra and new layout
386+
// Compute meta and new layout
387387
let inner_len = len - to - from;
388-
let (extra, ty) = match base.layout.ty.sty {
388+
let (meta, ty) = match base.layout.ty.sty {
389389
// It is not nice to match on the type, but that seems to be the only way to
390390
// implement this.
391391
ty::Array(inner, _) =>
@@ -400,7 +400,7 @@ impl
400400
let layout = self.layout_of(ty)?;
401401

402402
Ok(MPlaceTy {
403-
mplace: MemPlace { ptr, align: base.align, extra },
403+
mplace: MemPlace { ptr, align: base.align, meta },
404404
layout
405405
})
406406
}
@@ -411,7 +411,7 @@ impl
411411
variant: usize,
412412
) -> EvalResult<'tcx, MPlaceTy<'tcx, M::PointerTag>> {
413413
// Downcasts only change the layout
414-
assert!(base.extra.is_none());
414+
assert!(base.meta.is_none());
415415
Ok(MPlaceTy { layout: base.layout.for_variant(self, variant), ..base })
416416
}
417417

@@ -838,7 +838,7 @@ impl
838838
}
839839

840840
let mplace = MPlaceTy {
841-
mplace: MemPlace { extra: None, ..*mplace },
841+
mplace: MemPlace { meta: None, ..*mplace },
842842
layout
843843
};
844844
Ok((instance, mplace))

src/librustc_mir/interpret/snapshot.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,11 +209,11 @@ impl_snapshot_for!(enum ScalarMaybeUndef {
209209
impl_stable_hash_for!(struct ::interpret::MemPlace {
210210
ptr,
211211
align,
212-
extra,
212+
meta,
213213
});
214214
impl_snapshot_for!(struct MemPlace {
215215
ptr,
216-
extra,
216+
meta,
217217
align -> *align, // just copy alignment verbatim
218218
});
219219

src/librustc_mir/interpret/validity.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M>
186186
let tail = self.tcx.struct_tail(place.layout.ty);
187187
match tail.sty {
188188
ty::Dynamic(..) => {
189-
let vtable = try_validation!(place.extra.unwrap().to_ptr(),
189+
let vtable = try_validation!(place.meta.unwrap().to_ptr(),
190190
"non-pointer vtable in fat pointer", path);
191191
try_validation!(self.read_drop_type_from_vtable(vtable),
192192
"invalid drop fn in vtable", path);
@@ -195,7 +195,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M>
195195
// FIXME: More checks for the vtable.
196196
}
197197
ty::Slice(..) | ty::Str => {
198-
try_validation!(place.extra.unwrap().to_usize(self),
198+
try_validation!(place.meta.unwrap().to_usize(self),
199199
"non-integer slice length in fat pointer", path);
200200
}
201201
ty::Foreign(..) => {
@@ -208,7 +208,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M>
208208
// for safe ptrs, also check the ptr values itself
209209
if !ty.is_unsafe_ptr() {
210210
// Make sure this is non-NULL and aligned
211-
let (size, align) = self.size_and_align_of(place.extra, place.layout)?;
211+
let (size, align) = self.size_and_align_of(place.meta, place.layout)?;
212212
match self.memory.check_align(place.ptr, align) {
213213
Ok(_) => {},
214214
Err(err) => match err.kind {

0 commit comments

Comments
 (0)