What version of regex are you using?
0.8.11
Describe the bug at a high level.
Ord for Position is keyed off of offset only, but its Eq and PartialEq are derived, so they can disagree.
|
self.offset.cmp(&other.offset) |
This affects Span as well, since it stores Positions.
The methods of this trait must be consistent with each other and with those of PartialEq.
https://doc.rust-lang.org/std/cmp/trait.PartialOrd.html
What are the steps to reproduce the behavior?
use std::collections::BTreeSet;
use regex_syntax::ast::{Position, Span};
fn main() {
let a = Position { offset: 0, line: 1, column: 1 };
let b = Position { offset: 0, line: 9, column: 9 };
assert_ne!(a, b);
assert_eq!(a.cmp(&b), std::cmp::Ordering::Equal);
let mut set = BTreeSet::new();
set.insert(a);
set.insert(b);
assert_eq!(set.len(), 1);
}
What is the actual behavior?
BTreeSet is confused, all assertions pass.
What is the expected behavior?
Both a and b are inserted.
Found with a fuzzer I'm developing.
What version of regex are you using?
0.8.11
Describe the bug at a high level.
OrdforPositionis keyed off ofoffsetonly, but itsEqandPartialEqarederived, so they can disagree.regex/regex-syntax/src/ast/mod.rs
Line 372 in 72d650c
This affects
Spanas well, since it storesPositions.https://doc.rust-lang.org/std/cmp/trait.PartialOrd.html
What are the steps to reproduce the behavior?
What is the actual behavior?
BTreeSetis confused, all assertions pass.What is the expected behavior?
Both
aandbare inserted.Found with a fuzzer I'm developing.