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

Avoid hash_slice in VecDeque's Hash implementation #81170

Merged
merged 1 commit into from
Jan 24, 2021

Conversation

KamilaBorowska
Copy link
Contributor

Fixes #80303.

@rust-highfive
Copy link
Collaborator

r? @sfackler

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jan 18, 2021
@clarfonthey
Copy link
Contributor

Is there a reason why hash_slice hashes the length and not just the items? Maybe that could be changed instead.

@sfackler
Copy link
Member

@bors r+

Is there a reason why hash_slice hashes the length and not just the items? Maybe that could be changed instead.

It prevents hashes of values like these from colliding:

#[derive(Hash)]
struct Foo {
    a: Vec<u8>,
    b: Vec<u8>,
}

let thing1 = Foo {
    a: vec![1, 2],
    b: vec![3, 4],
};

let thing2 = Foo {
    a: vec![1],
    b: vec![2, 3, 4],
};

@bors
Copy link
Contributor

bors commented Jan 23, 2021

📌 Commit ae3a515 has been approved by sfackler

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jan 23, 2021
bors added a commit to rust-lang-ci/rust that referenced this pull request Jan 23, 2021
…as-schievink

Rollup of 15 pull requests

Successful merges:

 - rust-lang#79841 (More clear documentation for NonNull<T>)
 - rust-lang#81072 (PlaceRef::ty: use method call syntax)
 - rust-lang#81130 (Edit rustc_middle::dep_graph module documentation)
 - rust-lang#81170 (Avoid hash_slice in VecDeque's Hash implementation)
 - rust-lang#81243 (mir: Improve size_of handling when arg is unsized)
 - rust-lang#81245 (Update cargo)
 - rust-lang#81249 (Lower closure prototype after its body.)
 - rust-lang#81252 (Add more self-profile info to rustc_resolve)
 - rust-lang#81275 (Fix <unknown> queries and add more timing info to render_html)
 - rust-lang#81281 (Inline methods of Path and OsString)
 - rust-lang#81283 (Note library tracking issue template in tracking issue template.)
 - rust-lang#81285 (Remove special casing of rustdoc in rustc_lint)
 - rust-lang#81288 (rustdoc: Fix visibility of trait and impl items)
 - rust-lang#81298 (replace RefCell with Cell in FnCtxt)
 - rust-lang#81301 (Fix small typo)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 05a95a4 into rust-lang:master Jan 24, 2021
@rustbot rustbot added this to the 1.51.0 milestone Jan 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

VecDeque's Hash::hash implementation is incorrect
6 participants