hashbrown
hashbrown copied to clipboard
"Pony" is misspelled as "Poney" in dozens of places in map.rs.
The length of the correct spelling is also less, so char count test results will need to be adjusted.
https://github.com/rust-lang/hashbrown/blob/master/src/map.rs#L1294 and onward,
In your closed pull request, you can simply correct not only the spelling, but also the tests themselves.
Just run cargo test --doc
after correcting the spelling and the compiler will show you which tests need to be corrected. Unfortunately rustdoc only seems to point to the start line of the test, something like this:
failures:
---- src\map.rs - map::Entry<'a,K,V,S,A>::or_insert_with_key (line 5086) stdout ----
Test executable failed (exit code: 101).
stderr:
thread 'main' panicked at 'assertion failed: `(left == right)`
left: `8`,
right: `9`', src\map.rs:10:1
stack backtrace:
Here line 5086
is the line you are looking for in the src\map.rs file where the failed test starts:
use hashbrown::HashMap;
let mut map: HashMap<&str, usize> = HashMap::new();
// nonexistent key
map.entry("ponyland").or_insert_with_key(|key| key.chars().count());
assert_eq!(map["ponyland"], 9);
// existing key
*map.entry("ponyland").or_insert_with_key(|key| key.chars().count() * 10) *= 2
assert_eq!(map["ponyland"], 18);
Go to line 10 inside the test, i.e. assert_eq!(map["ponyland"], 9);
and change 9 to 8, i.e. assert_eq!(map["ponyland"], 8);
The numbering doesn't converge because rustdoc wraps the body of the function (which you actually see above) into a real test function like the one below. Honestly, I don't remember the exact wrapping rule, see rustdoc
.
#[test]
fn test {
use hashbrown::HashMap;
let mut map: HashMap<&str, usize> = HashMap::new();
// nonexistent key
map.entry("ponyland").or_insert_with_key(|key| key.chars().count());
assert_eq!(map["ponyland"], 9);
// existing key
*map.entry("ponyland").or_insert_with_key(|key| key.chars().count() * 10) *= 2
assert_eq!(map["ponyland"], 18);
}