Skip to content

fix(syntax): make Position's Ord match Eq - #1395

Open
jaideeppyne wants to merge 1 commit into
rust-lang:masterfrom
jaideeppyne:fix/position-ord
Open

jaideeppyne wants to merge 1 commit into
rust-lang:masterfrom
jaideeppyne:fix/position-ord

Conversation

@jaideeppyne

Copy link
Copy Markdown

`Position`'s `Ord` compared `offset` only, while `Eq` was derived over offset, line, and column. Two positions with the same offset and different line/column were unequal but compared `Equal`, which breaks `BTreeSet`/`BTreeMap`.

Derive `Ord`/`PartialOrd` so the total order agrees with equality.

Fixes #1393

Ord compared offset only while Eq was derived over offset, line, and
column, so two positions could be unequal and still compare Equal.
Derive Ord/PartialOrd so the total order agrees with Eq.

Fixes rust-lang#1393
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(syntax): Ord on ast::Position is inconsistent with Eq

1 participant