Skip to main content

Races

Enum Races 

Source
pub enum Races {
    Off,
    Metadata,
    Pointer,
}
Expand description

Whether pointer races are watched, from -fsafety-races=.

Design: spec/safe-memory/09-type-init-and-races.md section 9.5, which is document 03’s C1 through C4 and is judgement J9 of document 04 section 4.4. A thread counts its own metadata stores, a store through a pointer shaped slot leaves that count in the epoch plane, and an access that finds a count from another thread which nothing it has done orders is a race that really happened in the interleaving that really ran.

A flag rather than a default, and the reason is not cost. It is that this is the one plane in the compiler where instrumentation nobody wrote costs a false report instead of a missed one. Every ordering the monitor has was carried by a synchronization edge somebody interposed, so two threads that an edge nobody saw really did join look exactly like two threads nothing joined. The edges that are calls are interposed already, and the ordering that is not a call at all is emitted by this pass beside the checks: an atomic that publishes gets a meta_release in front of it and one that takes gets a meta_acquire after it. A bare atomic_thread_fence gets the same pair with no key, since it orders against every thread rather than against an object and so has no address an edge could be keyed on, and the runtime holds one clock for every fence in the program rather than a table.

Which is also why the default stays Races::Off after the flag works. Turning it on is a decision about a program, not about a build.

Variants§

§

Off

-fsafety-races=off. Nothing records into the epoch plane and nothing asks it anything.

§

Metadata

-fsafety-races=metadata. The classes that produce a wrong pointer rather than a wrong number, which section 9.5 lists as C1, C3 and C4, and which Tier E carries.

§

Pointer

-fsafety-races=pointer. The same, and C2 as well, which is a race on a pointer word reported in its own right rather than only used to decide one of the other three.

Implementations§

Source§

impl Races

Source

pub const fn as_str(self) -> &'static str

The spelling this is asked for by, without the flag in front of it.

Source

pub const fn records(self) -> bool

Whether a store through a pointer shaped slot records which thread made it, and asks first whether another thread got there with nothing in between.

Both of the modes that are not off. Every class section 9.5 lists is decided by comparing against a stamp a store left behind, so both of them record, and the question a store puts is C3, the metadata race, which both of them report.

Source

pub const fn reads(self) -> bool

Whether a load of a pointer asks the same question, which is where the two modes differ.

C2 of section 9.5, the general pointer word race, which the section lists apart from the other three because it is the class reported in its own right rather than used to decide one of them. Tier E carries metadata and not this, so a build that wants every race a load can see has to ask for it by name.

Trait Implementations§

Source§

impl Clone for Races

Source§

fn clone(&self) -> Races

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Races

Source§

impl Debug for Races

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Races

Source§

fn default() -> Races

Returns the “default value” for a type. Read more
Source§

impl Display for Races

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for Races

Source§

impl FromStr for Races

Source§

fn from_str(s: &str) -> Result<Self, ()>

Parses the part after -fsafety-races=.

Source§

type Err = ()

The associated error which can be returned from parsing.
Source§

impl Hash for Races

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Ord for Races

Source§

fn cmp(&self, other: &Races) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 (const: unstable) · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 (const: unstable) · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

fn clamp_to<R>(self, range: R) -> Self
where Self: Sized, R: ClampBounds<Self>,

🔬This is a nightly-only experimental API. (clamp_to)
Restrict a value to a certain range. Read more
Source§

impl PartialEq for Races

Source§

fn eq(&self, other: &Races) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl PartialOrd for Races

Source§

fn partial_cmp(&self, other: &Races) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl StructuralPartialEq for Races

Auto Trait Implementations§

§

impl Freeze for Races

§

impl RefUnwindSafe for Races

§

impl Send for Races

§

impl Sync for Races

§

impl Unpin for Races

§

impl UnsafeUnpin for Races

§

impl UnwindSafe for Races

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.