Skip to main content

Assumption

Enum Assumption 

Source
pub enum Assumption {
    Approaching,
    NoWrap(Chrec),
    StrictOverflow,
}
Expand description

Something that has to be true for a trip count to be the right answer.

Section 7.5 asks for exactly this: not a trip count but a trip count plus a predicate under which it holds, so the consumer either proves the predicate, emits a runtime check for it, or gives up. These are the predicates.

Variants§

§

Approaching

The counter starts on the near side of its limit, so the distance between them is a number that is not negative.

For a loop ending on an ordering this is the loop being entered at all. for (i = 0; i < n; i++) with n of zero runs no times and the distance is zero, but n of minus one also runs no times and the distance is minus one, so a count taken from the distance has to be told which case it is in. For a loop ending on != it is the limit being somewhere the counter is heading, because one stepping away from its limit never arrives.

Only ever present on a symbolic count. When the distance is a number the sign of it is there to be read, so this is settled rather than assumed.

§

NoWrap(Chrec)

The induction variable does not wrap in its own type before the exit is taken.

Present whenever the increment did not carry the matching nsw or nuw flag. With the flag there is nothing to assume, because the flag is the promise.

§

StrictOverflow

Signed overflow is undefined here, which is what makes for (int i = 0; i <= n; i++) finite.

GCC infers loop bounds from this in infer_loop_bounds_from_signedness, and it is the single most common source of a report that the compiler broke a working program. It is recorded rather than assumed silently so that -fwrapv can withdraw the count and so that a dump can name it.

Implementations§

Source§

impl Assumption

Source

pub fn describe(&self) -> String

What it says, in a line, for a dump to print.

Section 7.5 asks that every inference of this kind be dumpable and say what it rests on, because a user who has been bitten by one deserves a command that tells them which line the compiler used against them. This is the sentence that command prints.

Trait Implementations§

Source§

impl Clone for Assumption

Source§

fn clone(&self) -> Assumption

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 Assumption

Source§

impl Debug for Assumption

Source§

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

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

impl Eq for Assumption

Source§

impl PartialEq for Assumption

Source§

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

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

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Assumption

Auto Trait Implementations§

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, 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.