Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Pony" is misspelled as "Poney" in dozens of places in map.rs. #410

Open
fadedbee opened this issue Mar 1, 2023 · 1 comment
Open

"Pony" is misspelled as "Poney" in dozens of places in map.rs. #410

fadedbee opened this issue Mar 1, 2023 · 1 comment

Comments

@fadedbee
Copy link

fadedbee commented Mar 1, 2023

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,

@JustForFun88
Copy link
Contributor

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);
}

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

No branches or pull requests

2 participants