rust-lang / hashbrown

Rust port of Google's SwissTable hash map
https://rust-lang.github.io/hashbrown
Apache License 2.0
2.38k stars 275 forks source link

0.14.3 - no method named `clear` found for struct `HashMap` in the current scope #492

Closed miketwenty1 closed 8 months ago

miketwenty1 commented 8 months ago

I'm trying to understand if 0.14.3 has a compile time bug or if it's just being used incorrectly.

I opened up this issue https://github.com/lightningdevkit/ldk-node/issues/221

error[E0599]: no method named `clear` found for struct `HashMap` in the current scope
   --> /...../.cargo/registry/src/index.crates.io-6f17d22bba15001f/hashbrown-0.14.3/src/set.rs:432:18
    |
432 |         self.map.clear();
    |                  ^^^^^
    |
   ::: /..../.cargo/registry/src/index.crates.io-6f17d22bba15001f/hashbrown-0.14.3/src/map.rs:190:1
    |
190 | pub struct HashMap<K, V, S = DefaultHashBuilder, A: Allocator = Global> {
    | ----------------------------------------------------------------------- method `clear` not found for this struct
    |
help: one of the expressions' fields has a method of the same name
    |
432 |         self.map.table.clear();
    |                  ++++++
help: there is a method with a similar name
    |
432 |         self.map.waclear();
    |   

This leads me to think there is an issue with v0.14.3 of hashbrown.

Amanieu commented 8 months ago

help: there is a method with a similar name | 432 | self.map.waclear();

Did you accidentally edit your copy of hashbrown in your .cargo cache? There is no waclear method in hashbrown, it looks like a typo on your end.

miketwenty1 commented 8 months ago

@Amanieu, just running the https://github.com/lightningdevkit/ldk-node readme example. The error makes it look like it's suggesting .waclear instead of clear. I'm a little unsure of how to debug what's going on.

Amanieu commented 8 months ago

Try deleting ~/.cargo/registry to force re-downloading all crates.

miketwenty1 commented 8 months ago

i just built this project for the first time today a bit ago, i don't think anything got downloaded wrong?

miketwenty1 commented 8 months ago

deleting ~/.cargo/registry/src and rebuilding fixed my issue. Unsure why this was needed or what happened though.