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: usizeTokens the two streams agreed on, spelling for spelling.
truncated: boolWhether 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
impl Alignment
Sourcepub fn by_reason(&self, our_files: &HashSet<&Path>) -> Vec<(Reason, usize)>
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.
Sourcepub fn headers_we_never_entered(&self, our_files: &HashSet<&Path>) -> Vec<&Path>
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§
impl Eq for Alignment
impl StructuralPartialEq for Alignment
Auto Trait Implementations§
impl Forget for Alignment
impl Freeze for Alignment
impl RefUnwindSafe for Alignment
impl Send for Alignment
impl Sync for Alignment
impl Unpin for Alignment
impl UnsafeUnpin for Alignment
impl UnwindSafe for Alignment
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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