Skip to main content

Alignment

Struct Alignment 

Source
pub struct Alignment {
    pub differences: Vec<Difference>,
    pub matched: usize,
    pub truncated: bool,
}
Expand description

The result of putting two streams side by side: where they differ, and how much of them agreed.

The two counts are what make a reading comparable between runs —the plan’s §5.2 requires that the number of differences only ever goes down, and a count of matched tokens is what keeps a run that got shorter from looking like a run that got better.

§The order of differences is part of the contract

Sorted by Difference::at, ascending, and every field derived from that order is only meaningful because of it: a run is a group of adjacent positions, and adjacency is not a property of an unordered set. The traceback that produces them does not guarantee this —it walks backwards and a run of deletions comes out in descending order —so the sort is in align rather than left to whoever reads the list.

Fields§

§differences: Vec<Difference>§matched: usize

Tokens the two streams agreed on, spelling for spelling.

§truncated: bool

Whether the comparison stopped early —see MAX_EDIT_DISTANCE.

Load-bearing, and the one field a caller must read before believing Alignment::differences is exhaustive. Two streams that share almost nothing (one of them empty, or the wrong file entirely) have a difference count proportional to their length, which for a standard library header is millions —so the walk is bounded, and a bounded walk has to say that it was bounded rather than present a prefix as a whole.

Implementations§

Source§

impl Alignment

Source

pub fn by_reason(&self, our_files: &HashSet<&Path>) -> Vec<(Reason, usize)>

Differences grouped by mechanism, largest group first —what a report should print.

The grouping is a BTreeMap over Reason, so the order two mechanisms come out in does not depend on the order their differences happened to appear in the stream. That is what makes the line a report records — /// UnexpandedMacro=14 ConditionDisagreement=3 —comparable between two runs, which is the plan’s §5.2 requirement that the difference count only ever go down.

Source

pub fn agrees(&self) -> bool

Did the two streams agree as sequences of spellings?

Source

pub fn headers_we_never_entered(&self, our_files: &HashSet<&Path>) -> Vec<&Path>

The files the compiler read and this reading never entered, each once, in path order.

The names behind Reason::MissingHeader, which is the one certain classification this module makes: it is asked of a difference whose token carries a file our stream does not mention at all, so it is a fact about the two readings rather than a shape being interpreted. A count of those differences says how big the gap is; this says which search went differently, and that is what a caller can act on.

It earns its own method because of a measurement: on #include <vector> against MSVC’s own STL, 46 files came out this way while the two streams’ total lengths differed by 252 tokens. So the gap was never “we read the same files slightly differently” — it was whole files one side read and the other did not, which is a different repair.

Trait Implementations§

Source§

impl Clone for Alignment

Source§

fn clone(&self) -> Self

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 Debug for Alignment

Source§

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

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

impl Default for Alignment

Source§

fn default() -> Self

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

impl Eq for Alignment

Source§

impl PartialEq for Alignment

Source§

fn eq(&self, other: &Self) -> 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 Alignment

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<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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.