Skip to content

Commit

Permalink
use NonZeroU64 for AllocId to restore old type sizes
Browse files Browse the repository at this point in the history
  • Loading branch information
RalfJung committed Jul 14, 2021
1 parent 626605c commit 71c166a
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 13 deletions.
1 change: 1 addition & 0 deletions compiler/rustc_middle/src/lib.rs
Expand Up @@ -49,6 +49,7 @@
#![feature(iter_zip)]
#![feature(thread_local_const_init)]
#![feature(try_reserve)]
#![feature(nonzero_ops)]
#![recursion_limit = "512"]

#[macro_use]
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_middle/src/mir/interpret/mod.rs
Expand Up @@ -99,7 +99,7 @@ use std::convert::TryFrom;
use std::fmt;
use std::io;
use std::io::{Read, Write};
use std::num::NonZeroU32;
use std::num::{NonZeroU32, NonZeroU64};
use std::sync::atomic::{AtomicU32, Ordering};

use rustc_ast::LitKind;
Expand Down Expand Up @@ -177,7 +177,7 @@ pub enum LitToConstError {
}

#[derive(Copy, Clone, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct AllocId(pub u64);
pub struct AllocId(pub NonZeroU64);

// We want the `Debug` output to be readable as it is used by `derive(Debug)` for
// all the Miri types.
Expand Down Expand Up @@ -428,7 +428,7 @@ crate struct AllocMap<'tcx> {

impl<'tcx> AllocMap<'tcx> {
crate fn new() -> Self {
AllocMap { alloc_map: Default::default(), dedup: Default::default(), next_id: AllocId(0) }
AllocMap { alloc_map: Default::default(), dedup: Default::default(), next_id: AllocId(NonZeroU64::new(1).unwrap()) }
}
fn reserve(&mut self) -> AllocId {
let next = self.next_id;
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_middle/src/mir/interpret/pointer.rs
Expand Up @@ -135,7 +135,7 @@ pub struct Pointer<Tag = AllocId> {
pub provenance: Tag,
}

//FIXME static_assert_size!(Pointer, 16);
static_assert_size!(Pointer, 16);

// We want the `Debug` output to be readable as it is used by `derive(Debug)` for
// all the Miri types.
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_middle/src/mir/interpret/value.rs
Expand Up @@ -136,7 +136,7 @@ pub enum Scalar<Tag = AllocId> {
}

#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
//FIXME static_assert_size!(Scalar, 24);
static_assert_size!(Scalar, 24);

// We want the `Debug` output to be readable as it is used by `derive(Debug)` for
// all the Miri types.
Expand Down Expand Up @@ -522,7 +522,7 @@ pub enum ScalarMaybeUninit<Tag = AllocId> {
}

#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
//FIXME static_assert_size!(ScalarMaybeUninit, 24);
static_assert_size!(ScalarMaybeUninit, 24);

impl<Tag> From<Scalar<Tag>> for ScalarMaybeUninit<Tag> {
#[inline(always)]
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_mir/src/interpret/operand.rs
Expand Up @@ -34,7 +34,7 @@ pub enum Immediate<Tag = AllocId> {
}

#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
//FIXME rustc_data_structures::static_assert_size!(Immediate, 56);
rustc_data_structures::static_assert_size!(Immediate, 56);

impl<Tag: Provenance> std::fmt::Debug for Immediate<Tag> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
Expand Down Expand Up @@ -100,7 +100,7 @@ pub struct ImmTy<'tcx, Tag = AllocId> {
}

#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
//FIXME rustc_data_structures::static_assert_size!(ImmTy<'_>, 72);
rustc_data_structures::static_assert_size!(ImmTy<'_>, 72);

impl<'tcx, Tag: Provenance> std::fmt::Debug for ImmTy<'tcx, Tag> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
Expand Down
10 changes: 5 additions & 5 deletions compiler/rustc_mir/src/interpret/place.rs
Expand Up @@ -34,7 +34,7 @@ pub enum MemPlaceMeta<Tag = AllocId> {
}

#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
//FIXME rustc_data_structures::static_assert_size!(MemPlaceMeta, 24);
rustc_data_structures::static_assert_size!(MemPlaceMeta, 24);

impl<Tag: Provenance> std::fmt::Debug for MemPlaceMeta<Tag> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
Expand Down Expand Up @@ -87,7 +87,7 @@ pub struct MemPlace<Tag = AllocId> {
}

#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
//FIXME rustc_data_structures::static_assert_size!(MemPlace, 56);
rustc_data_structures::static_assert_size!(MemPlace, 48);

impl<Tag: Provenance> std::fmt::Debug for MemPlace<Tag> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
Expand All @@ -111,7 +111,7 @@ pub enum Place<Tag = AllocId> {
}

#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
//FIXME rustc_data_structures::static_assert_size!(Place, 64);
rustc_data_structures::static_assert_size!(Place, 56);

impl<Tag: Provenance> std::fmt::Debug for Place<Tag> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
Expand All @@ -132,7 +132,7 @@ pub struct PlaceTy<'tcx, Tag = AllocId> {
}

#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
//FIXME rustc_data_structures::static_assert_size!(PlaceTy<'_>, 80);
rustc_data_structures::static_assert_size!(PlaceTy<'_>, 72);

impl<'tcx, Tag: Provenance> std::fmt::Debug for PlaceTy<'tcx, Tag> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
Expand All @@ -157,7 +157,7 @@ pub struct MPlaceTy<'tcx, Tag = AllocId> {
}

#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
//FIXME rustc_data_structures::static_assert_size!(MPlaceTy<'_>, 72);
rustc_data_structures::static_assert_size!(MPlaceTy<'_>, 64);

impl<'tcx, Tag: Provenance> std::fmt::Debug for MPlaceTy<'tcx, Tag> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
Expand Down

0 comments on commit 71c166a

Please sign in to comment.