Skip to content

Commit 2e00d64

Browse files
committed
s/AllocType/AllocKind/
1 parent a1e83a9 commit 2e00d64

File tree

8 files changed

+40
-40
lines changed

8 files changed

+40
-40
lines changed

src/librustc/ich/impls_ty.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ impl_stable_hash_for!(
338338
);
339339

340340
impl_stable_hash_for!(
341-
impl<'tcx> for enum mir::interpret::AllocType<'tcx> [ mir::interpret::AllocType ] {
341+
impl<'tcx> for enum mir::interpret::AllocKind<'tcx> [ mir::interpret::AllocKind ] {
342342
Function(instance),
343343
Static(def_id),
344344
Memory(mem),

src/librustc/mir/interpret/mod.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -103,20 +103,20 @@ pub fn specialized_encode_alloc_id<
103103
tcx: TyCtxt<'a, 'tcx, 'tcx>,
104104
alloc_id: AllocId,
105105
) -> Result<(), E::Error> {
106-
let alloc_type: AllocType<'tcx> =
106+
let alloc_type: AllocKind<'tcx> =
107107
tcx.alloc_map.lock().get(alloc_id).expect("no value for AllocId");
108108
match alloc_type {
109-
AllocType::Memory(alloc) => {
109+
AllocKind::Memory(alloc) => {
110110
trace!("encoding {:?} with {:#?}", alloc_id, alloc);
111111
AllocDiscriminant::Alloc.encode(encoder)?;
112112
alloc.encode(encoder)?;
113113
}
114-
AllocType::Function(fn_instance) => {
114+
AllocKind::Function(fn_instance) => {
115115
trace!("encoding {:?} with {:#?}", alloc_id, fn_instance);
116116
AllocDiscriminant::Fn.encode(encoder)?;
117117
fn_instance.encode(encoder)?;
118118
}
119-
AllocType::Static(did) => {
119+
AllocKind::Static(did) => {
120120
// referring to statics doesn't need to know about their allocations,
121121
// just about its DefId
122122
AllocDiscriminant::Static.encode(encoder)?;
@@ -291,7 +291,7 @@ impl fmt::Display for AllocId {
291291
}
292292

293293
#[derive(Debug, Clone, Eq, PartialEq, Hash, RustcDecodable, RustcEncodable)]
294-
pub enum AllocType<'tcx> {
294+
pub enum AllocKind<'tcx> {
295295
/// The alloc id is used as a function pointer
296296
Function(Instance<'tcx>),
297297
/// The alloc id points to a "lazy" static variable that did not get computed (yet).
@@ -303,10 +303,10 @@ pub enum AllocType<'tcx> {
303303

304304
pub struct AllocMap<'tcx> {
305305
/// Lets you know what an AllocId refers to
306-
id_to_type: FxHashMap<AllocId, AllocType<'tcx>>,
306+
id_to_type: FxHashMap<AllocId, AllocKind<'tcx>>,
307307

308308
/// Used to ensure that statics only get one associated AllocId
309-
type_interner: FxHashMap<AllocType<'tcx>, AllocId>,
309+
type_interner: FxHashMap<AllocKind<'tcx>, AllocId>,
310310

311311
/// The AllocId to assign to the next requested id.
312312
/// Always incremented, never gets smaller.
@@ -339,7 +339,7 @@ impl<'tcx> AllocMap<'tcx> {
339339
next
340340
}
341341

342-
fn intern(&mut self, alloc_type: AllocType<'tcx>) -> AllocId {
342+
fn intern(&mut self, alloc_type: AllocKind<'tcx>) -> AllocId {
343343
if let Some(&alloc_id) = self.type_interner.get(&alloc_type) {
344344
return alloc_id;
345345
}
@@ -356,29 +356,29 @@ impl<'tcx> AllocMap<'tcx> {
356356
/// `main as fn() == main as fn()` is false, while `let x = main as fn(); x == x` is true.
357357
pub fn create_fn_alloc(&mut self, instance: Instance<'tcx>) -> AllocId {
358358
let id = self.reserve();
359-
self.id_to_type.insert(id, AllocType::Function(instance));
359+
self.id_to_type.insert(id, AllocKind::Function(instance));
360360
id
361361
}
362362

363363
/// Returns `None` in case the `AllocId` is dangling.
364364
/// This function exists to allow const eval to detect the difference between evaluation-
365365
/// local dangling pointers and allocations in constants/statics.
366-
pub fn get(&self, id: AllocId) -> Option<AllocType<'tcx>> {
366+
pub fn get(&self, id: AllocId) -> Option<AllocKind<'tcx>> {
367367
self.id_to_type.get(&id).cloned()
368368
}
369369

370370
/// Panics if the `AllocId` does not refer to an `Allocation`
371371
pub fn unwrap_memory(&self, id: AllocId) -> &'tcx Allocation {
372372
match self.get(id) {
373-
Some(AllocType::Memory(mem)) => mem,
373+
Some(AllocKind::Memory(mem)) => mem,
374374
_ => bug!("expected allocation id {} to point to memory", id),
375375
}
376376
}
377377

378378
/// Generate an `AllocId` for a static or return a cached one in case this function has been
379379
/// called on the same static before.
380380
pub fn intern_static(&mut self, static_id: DefId) -> AllocId {
381-
self.intern(AllocType::Static(static_id))
381+
self.intern(AllocKind::Static(static_id))
382382
}
383383

384384
/// Intern the `Allocation` and return a new `AllocId`, even if there's already an identical
@@ -395,15 +395,15 @@ impl<'tcx> AllocMap<'tcx> {
395395
/// Freeze an `AllocId` created with `reserve` by pointing it at an `Allocation`. Trying to
396396
/// call this function twice, even with the same `Allocation` will ICE the compiler.
397397
pub fn set_id_memory(&mut self, id: AllocId, mem: &'tcx Allocation) {
398-
if let Some(old) = self.id_to_type.insert(id, AllocType::Memory(mem)) {
398+
if let Some(old) = self.id_to_type.insert(id, AllocKind::Memory(mem)) {
399399
bug!("tried to set allocation id {}, but it was already existing as {:#?}", id, old);
400400
}
401401
}
402402

403403
/// Freeze an `AllocId` created with `reserve` by pointing it at an `Allocation`. May be called
404404
/// twice for the same `(AllocId, Allocation)` pair.
405405
pub fn set_id_same_memory(&mut self, id: AllocId, mem: &'tcx Allocation) {
406-
self.id_to_type.insert_same(id, AllocType::Memory(mem));
406+
self.id_to_type.insert_same(id, AllocKind::Memory(mem));
407407
}
408408
}
409409

src/librustc/mir/interpret/value.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use super::{EvalResult, Pointer, PointerArithmetic, Allocation, AllocId, sign_ex
1818
/// Represents the result of a raw const operation, pre-validation.
1919
#[derive(Copy, Clone, Debug, Eq, PartialEq, RustcEncodable, RustcDecodable, Hash)]
2020
pub struct RawConst<'tcx> {
21-
// the value lives here, at offset 0, and that allocation definitely is a `AllocType::Memory`
21+
// the value lives here, at offset 0, and that allocation definitely is a `AllocKind::Memory`
2222
// (so you can use `AllocMap::unwrap_memory`).
2323
pub alloc_id: AllocId,
2424
pub ty: Ty<'tcx>,

src/librustc/mir/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2629,7 +2629,7 @@ pub fn fmt_const_val(f: &mut impl Write, const_val: &ty::Const<'_>) -> fmt::Resu
26292629
if let Ref(_, &ty::TyS { sty: Str, .. }, _) = ty.sty {
26302630
return ty::tls::with(|tcx| {
26312631
let alloc = tcx.alloc_map.lock().get(ptr.alloc_id);
2632-
if let Some(interpret::AllocType::Memory(alloc)) = alloc {
2632+
if let Some(interpret::AllocKind::Memory(alloc)) = alloc {
26332633
assert_eq!(len as usize as u128, len);
26342634
let slice =
26352635
&alloc.bytes[(ptr.offset.bytes() as usize)..][..(len as usize)];

src/librustc_codegen_llvm/common.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use value::Value;
2121
use rustc_codegen_ssa::traits::*;
2222

2323
use rustc::ty::layout::{HasDataLayout, LayoutOf, self, TyLayout, Size};
24-
use rustc::mir::interpret::{Scalar, AllocType, Allocation};
24+
use rustc::mir::interpret::{Scalar, AllocKind, Allocation};
2525
use consts::const_alloc_to_llvm;
2626
use rustc_codegen_ssa::mir::place::PlaceRef;
2727

@@ -318,18 +318,18 @@ impl ConstMethods<'tcx> for CodegenCx<'ll, 'tcx> {
318318
Scalar::Ptr(ptr) => {
319319
let alloc_type = self.tcx.alloc_map.lock().get(ptr.alloc_id);
320320
let base_addr = match alloc_type {
321-
Some(AllocType::Memory(alloc)) => {
321+
Some(AllocKind::Memory(alloc)) => {
322322
let init = const_alloc_to_llvm(self, alloc);
323323
if alloc.mutability == Mutability::Mutable {
324324
self.static_addr_of_mut(init, alloc.align, None)
325325
} else {
326326
self.static_addr_of(init, alloc.align, None)
327327
}
328328
}
329-
Some(AllocType::Function(fn_instance)) => {
329+
Some(AllocKind::Function(fn_instance)) => {
330330
self.get_fn(fn_instance)
331331
}
332-
Some(AllocType::Static(def_id)) => {
332+
Some(AllocKind::Static(def_id)) => {
333333
assert!(self.tcx.is_static(def_id).is_some());
334334
self.get_static(def_id)
335335
}

src/librustc_mir/interpret/memory.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ use syntax::ast::Mutability;
2929

3030
use super::{
3131
Pointer, AllocId, Allocation, GlobalId, AllocationExtra,
32-
EvalResult, Scalar, EvalErrorKind, AllocType, PointerArithmetic,
32+
EvalResult, Scalar, EvalErrorKind, AllocKind, PointerArithmetic,
3333
Machine, AllocMap, MayLeak, ErrorHandled, InboundsCheck,
3434
};
3535

@@ -204,12 +204,12 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> Memory<'a, 'mir, 'tcx, M> {
204204
None => {
205205
// Deallocating static memory -- always an error
206206
return match self.tcx.alloc_map.lock().get(ptr.alloc_id) {
207-
Some(AllocType::Function(..)) => err!(DeallocatedWrongMemoryKind(
207+
Some(AllocKind::Function(..)) => err!(DeallocatedWrongMemoryKind(
208208
"function".to_string(),
209209
format!("{:?}", kind),
210210
)),
211-
Some(AllocType::Static(..)) |
212-
Some(AllocType::Memory(..)) => err!(DeallocatedWrongMemoryKind(
211+
Some(AllocKind::Static(..)) |
212+
Some(AllocKind::Memory(..)) => err!(DeallocatedWrongMemoryKind(
213213
"static".to_string(),
214214
format!("{:?}", kind),
215215
)),
@@ -326,15 +326,15 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> Memory<'a, 'mir, 'tcx, M> {
326326
) -> EvalResult<'tcx, Cow<'tcx, Allocation<M::PointerTag, M::AllocExtra>>> {
327327
let alloc = tcx.alloc_map.lock().get(id);
328328
let def_id = match alloc {
329-
Some(AllocType::Memory(mem)) => {
329+
Some(AllocKind::Memory(mem)) => {
330330
// We got tcx memory. Let the machine figure out whether and how to
331331
// turn that into memory with the right pointer tag.
332332
return Ok(M::adjust_static_allocation(mem, memory_extra))
333333
}
334-
Some(AllocType::Function(..)) => {
334+
Some(AllocKind::Function(..)) => {
335335
return err!(DerefFunctionPointer)
336336
}
337-
Some(AllocType::Static(did)) => {
337+
Some(AllocKind::Static(did)) => {
338338
did
339339
}
340340
None =>
@@ -435,8 +435,8 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> Memory<'a, 'mir, 'tcx, M> {
435435
}
436436
// Could also be a fn ptr or extern static
437437
match self.tcx.alloc_map.lock().get(id) {
438-
Some(AllocType::Function(..)) => (Size::ZERO, Align::from_bytes(1).unwrap()),
439-
Some(AllocType::Static(did)) => {
438+
Some(AllocKind::Function(..)) => (Size::ZERO, Align::from_bytes(1).unwrap()),
439+
Some(AllocKind::Static(did)) => {
440440
// The only way `get` couldn't have worked here is if this is an extern static
441441
assert!(self.tcx.is_foreign_item(did));
442442
// Use size and align of the type
@@ -459,7 +459,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> Memory<'a, 'mir, 'tcx, M> {
459459
}
460460
trace!("reading fn ptr: {}", ptr.alloc_id);
461461
match self.tcx.alloc_map.lock().get(ptr.alloc_id) {
462-
Some(AllocType::Function(instance)) => Ok(instance),
462+
Some(AllocKind::Function(instance)) => Ok(instance),
463463
_ => Err(EvalErrorKind::ExecuteMemory.into()),
464464
}
465465
}
@@ -557,16 +557,16 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> Memory<'a, 'mir, 'tcx, M> {
557557
Err(()) => {
558558
// static alloc?
559559
match self.tcx.alloc_map.lock().get(id) {
560-
Some(AllocType::Memory(alloc)) => {
560+
Some(AllocKind::Memory(alloc)) => {
561561
self.dump_alloc_helper(
562562
&mut allocs_seen, &mut allocs_to_print,
563563
msg, alloc, " (immutable)".to_owned()
564564
);
565565
}
566-
Some(AllocType::Function(func)) => {
566+
Some(AllocKind::Function(func)) => {
567567
trace!("{} {}", msg, func);
568568
}
569-
Some(AllocType::Static(did)) => {
569+
Some(AllocKind::Static(did)) => {
570570
trace!("{} {:?}", msg, did);
571571
}
572572
None => {

src/librustc_mir/interpret/validity.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use rustc::ty::layout::{self, Size, Align, TyLayout, LayoutOf, VariantIdx};
1717
use rustc::ty;
1818
use rustc_data_structures::fx::FxHashSet;
1919
use rustc::mir::interpret::{
20-
Scalar, AllocType, EvalResult, EvalErrorKind,
20+
Scalar, AllocKind, EvalResult, EvalErrorKind,
2121
};
2222

2323
use super::{
@@ -388,7 +388,7 @@ impl<'rt, 'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>>
388388
"integer pointer in non-ZST reference", self.path);
389389
// Skip validation entirely for some external statics
390390
let alloc_kind = self.ecx.tcx.alloc_map.lock().get(ptr.alloc_id);
391-
if let Some(AllocType::Static(did)) = alloc_kind {
391+
if let Some(AllocKind::Static(did)) = alloc_kind {
392392
// `extern static` cannot be validated as they have no body.
393393
// FIXME: Statics from other crates are also skipped.
394394
// They might be checked at a different type, but for now we

src/librustc_mir/monomorphize/collector.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ use rustc::session::config;
197197
use rustc::mir::{self, Location, Promoted};
198198
use rustc::mir::visit::Visitor as MirVisitor;
199199
use rustc::mir::mono::MonoItem;
200-
use rustc::mir::interpret::{Scalar, GlobalId, AllocType, ErrorHandled};
200+
use rustc::mir::interpret::{Scalar, GlobalId, AllocKind, ErrorHandled};
201201

202202
use monomorphize::{self, Instance};
203203
use rustc::util::nodemap::{FxHashSet, FxHashMap, DefIdMap};
@@ -1163,20 +1163,20 @@ fn collect_miri<'a, 'tcx>(
11631163
) {
11641164
let alloc_type = tcx.alloc_map.lock().get(alloc_id);
11651165
match alloc_type {
1166-
Some(AllocType::Static(did)) => {
1166+
Some(AllocKind::Static(did)) => {
11671167
let instance = Instance::mono(tcx, did);
11681168
if should_monomorphize_locally(tcx, &instance) {
11691169
trace!("collecting static {:?}", did);
11701170
output.push(MonoItem::Static(did));
11711171
}
11721172
}
1173-
Some(AllocType::Memory(alloc)) => {
1173+
Some(AllocKind::Memory(alloc)) => {
11741174
trace!("collecting {:?} with {:#?}", alloc_id, alloc);
11751175
for &((), inner) in alloc.relocations.values() {
11761176
collect_miri(tcx, inner, output);
11771177
}
11781178
},
1179-
Some(AllocType::Function(fn_instance)) => {
1179+
Some(AllocKind::Function(fn_instance)) => {
11801180
if should_monomorphize_locally(tcx, &fn_instance) {
11811181
trace!("collecting {:?} with {:#?}", alloc_id, fn_instance);
11821182
output.push(create_fn_mono_item(fn_instance));

0 commit comments

Comments
 (0)