Closed
Description
Given the following code: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=057c1715bd0bea7866420e59e5a070f1
// Not including std::hash::Hasher, which is why the build fails
use std::hash::BuildHasher;
fn next_u64() -> u64 {
let bh = std::collections::hash_map::RandomState::new();
let h = bh.build_hasher();
h.finish()
}
fn main() {}
The current (nightly
) output is:
Compiling playground v0.0.1 (/playground)
error[E0599]: no method named `finish` found for struct `DefaultHasher` in the current scope
--> src/main.rs:7:7
|
7 | h.finish()
| ^^^^^^ method not found in `DefaultHasher`
|
help: consider wrapping the receiver expression with the appropriate type
|
7 | Box::new(h).finish()
| ^^^^^^^^^ ^
help: consider wrapping the receiver expression with the appropriate type
|
7 | Box::new(&mut h).finish()
| ^^^^^^^^^^^^^ ^
error: aborting due to previous error
For more information about this error, try `rustc --explain E0599`.
error: could not compile `playground`
To learn more, run the command again with --verbose.
On stable, there was a line telling you which trait you need to import in order to call the function.
Compiling playground v0.0.1 (/playground)
error[E0599]: no method named `finish` found for struct `DefaultHasher` in the current scope
--> src/main.rs:7:7
|
7 | h.finish()
| ^^^^^^ method not found in `DefaultHasher`
|
= help: items from traits can only be used if the trait is in scope
help: the following trait is implemented but not in scope; perhaps add a `use` for it:
|
2 | use std::hash::Hasher;
|
error: aborting due to previous error
For more information about this error, try `rustc --explain E0599`.
error: could not compile `playground`
To learn more, run the command again with --verbose.
Also, boxing the object here isn't helpful, so it shouldn't be suggested.
Bisected this, and I'm assuming that the relevant issue is #83667, but I'm not sure how I would verify that.
searched nightlies: from nightly-2021-03-30 to nightly-2021-03-31
regressed nightly: nightly-2021-03-31
searched commits: from 48691ea to 74874a6
regressed commit: 16156fb
bisected with cargo-bisect-rustc v0.6.0
Host triple: x86_64-unknown-linux-gnu
Reproduce with:
cargo bisect-rustc --test-dir=. --start=2021-03-30 --end=2021-03-31 --preserve --script=./test.sh
(where test.sh is
#!/bin/bash
cargo check 2>&1 | grep "std::hash::Hasher"
)