Skip to content

Commit

Permalink
safe transmute: use AtomicU32 State ids to appease mips
Browse files Browse the repository at this point in the history
...instead of `AtomicU64`, which is unavailable.

ref: #92268 (comment)
  • Loading branch information
jswrenn committed Jul 28, 2022
1 parent aee5f31 commit e8a1925
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions compiler/rustc_transmute/src/layout/dfa.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use super::{nfa, Byte, Nfa, Ref};
use crate::Map;
use std::fmt;
use std::sync::atomic::{AtomicU64, Ordering};
use std::sync::atomic::{AtomicU32, Ordering};

#[derive(PartialEq, Clone, Debug)]
pub(crate) struct Dfa<R>
Expand Down Expand Up @@ -49,7 +49,7 @@ where

/// The states in a `Nfa` represent byte offsets.
#[derive(Hash, Eq, PartialEq, PartialOrd, Ord, Copy, Clone)]
pub(crate) struct State(u64);
pub(crate) struct State(u32);

#[derive(Hash, Eq, PartialEq, Clone, Copy)]
pub(crate) enum Transition<R>
Expand Down Expand Up @@ -166,7 +166,7 @@ where

impl State {
pub(crate) fn new() -> Self {
static COUNTER: AtomicU64 = AtomicU64::new(0);
static COUNTER: AtomicU32 = AtomicU32::new(0);
Self(COUNTER.fetch_add(1, Ordering::SeqCst))
}
}
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_transmute/src/layout/nfa.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use super::{Byte, Ref, Tree, Uninhabited};
use crate::{Map, Set};
use std::fmt;
use std::sync::atomic::{AtomicU64, Ordering};
use std::sync::atomic::{AtomicU32, Ordering};

/// A non-deterministic finite automaton (NFA) that represents the layout of a type.
/// The transmutability of two given types is computed by comparing their `Nfa`s.
Expand All @@ -17,7 +17,7 @@ where

/// The states in a `Nfa` represent byte offsets.
#[derive(Hash, Eq, PartialEq, PartialOrd, Ord, Copy, Clone)]
pub(crate) struct State(u64);
pub(crate) struct State(u32);

/// The transitions between states in a `Nfa` reflect bit validity.
#[derive(Hash, Eq, PartialEq, Clone, Copy)]
Expand Down Expand Up @@ -173,7 +173,7 @@ where

impl State {
pub(crate) fn new() -> Self {
static COUNTER: AtomicU64 = AtomicU64::new(0);
static COUNTER: AtomicU32 = AtomicU32::new(0);
Self(COUNTER.fetch_add(1, Ordering::SeqCst))
}
}

0 comments on commit e8a1925

Please sign in to comment.