Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 71c166a

Browse files
committed
use NonZeroU64 for AllocId to restore old type sizes
1 parent 626605c commit 71c166a

File tree

6 files changed

+14
-13
lines changed

6 files changed

+14
-13
lines changed

compiler/rustc_middle/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
#![feature(iter_zip)]
5050
#![feature(thread_local_const_init)]
5151
#![feature(try_reserve)]
52+
#![feature(nonzero_ops)]
5253
#![recursion_limit = "512"]
5354

5455
#[macro_use]

compiler/rustc_middle/src/mir/interpret/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ use std::convert::TryFrom;
9999
use std::fmt;
100100
use std::io;
101101
use std::io::{Read, Write};
102-
use std::num::NonZeroU32;
102+
use std::num::{NonZeroU32, NonZeroU64};
103103
use std::sync::atomic::{AtomicU32, Ordering};
104104

105105
use rustc_ast::LitKind;
@@ -177,7 +177,7 @@ pub enum LitToConstError {
177177
}
178178

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

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

429429
impl<'tcx> AllocMap<'tcx> {
430430
crate fn new() -> Self {
431-
AllocMap { alloc_map: Default::default(), dedup: Default::default(), next_id: AllocId(0) }
431+
AllocMap { alloc_map: Default::default(), dedup: Default::default(), next_id: AllocId(NonZeroU64::new(1).unwrap()) }
432432
}
433433
fn reserve(&mut self) -> AllocId {
434434
let next = self.next_id;

compiler/rustc_middle/src/mir/interpret/pointer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ pub struct Pointer<Tag = AllocId> {
135135
pub provenance: Tag,
136136
}
137137

138-
//FIXME static_assert_size!(Pointer, 16);
138+
static_assert_size!(Pointer, 16);
139139

140140
// We want the `Debug` output to be readable as it is used by `derive(Debug)` for
141141
// all the Miri types.

compiler/rustc_middle/src/mir/interpret/value.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ pub enum Scalar<Tag = AllocId> {
136136
}
137137

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

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

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

527527
impl<Tag> From<Scalar<Tag>> for ScalarMaybeUninit<Tag> {
528528
#[inline(always)]

compiler/rustc_mir/src/interpret/operand.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ pub enum Immediate<Tag = AllocId> {
3434
}
3535

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

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

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

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

compiler/rustc_mir/src/interpret/place.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ pub enum MemPlaceMeta<Tag = AllocId> {
3434
}
3535

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

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

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

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

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

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

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

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

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

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

0 commit comments

Comments
 (0)