-
Notifications
You must be signed in to change notification settings - Fork 969
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
use hashbrown
in naga
& main wgpu
crates etc.
#6938
base: trunk
Are you sure you want to change the base?
Conversation
…n hashbrown::HashSet::contains call
match capabilities.iter().find(|cap| available.contains(cap)) { | ||
match capabilities | ||
.iter() | ||
.find(|cap| available.contains::<spirv::Capability>(cap)) | ||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I use hashbrown::HashSet without this update, cargo clippy
(and cargo test with all features) fails with this:
error[E0277]: the trait bound `&spirv::Capability: hashbrown::Equivalent<spirv::Capability>` is not satisfied
--> naga/src/back/spv/writer.rs:172:60
|
172 | ... .find(|cap| available.contains(cap))
| -------- ^^^ the trait `std::borrow::Borrow<&spirv::Capability>` is not implemented for `spirv::Capability`, which is required by `&spirv::Capability: hashbrown::Equivalent<spirv::Capability>`
| |
| required by a bound introduced by this call
|
= note: required for `&spirv::Capability` to implement `hashbrown::Equivalent<spirv::Capability>`
note: required by a bound in `hashbrown::HashSet::<T, S, A>::contains`
--> /Users/cjb/.cargo/registry/src/index.crates.io-6f17d22bba15001f/hashbrown-0.15.2/src/set.rs:864:19
|
862 | pub fn contains<Q>(&self, value: &Q) -> bool
| -------- required by a bound in this associated function
863 | where
864 | Q: Hash + Equivalent<T> + ?Sized,
| ^^^^^^^^^^^^^ required by this bound in `HashSet::<T, S, A>::contains`
For more information about this error, try `rustc --explain E0277`.
It took me a while to figure out that using <spirv::Capability>
in the hashbrown::HashSet::contains
function call would resolve this build issue.
Something about this does not feel 100% right to me, wondering why rustc couldn't handle this call without using the type parameter. Any ideas about this?
hashbrown
in naga
etc.hashbrown
in naga
& main wgpu
crates` etc.
hashbrown
in naga
& main wgpu
crates` etc.hashbrown
in naga
& main wgpu
crates etc.
naga/Cargo.toml
Outdated
@@ -72,6 +72,7 @@ termcolor = { version = "1.4.1" } | |||
# termcolor minimum version was wrong and was fixed in | |||
# /~https://github.com/brendanzab/codespan/commit/e99c867339a877731437e7ee6a903a3d03b5439e | |||
codespan-reporting = { version = "0.11.0" } | |||
hashbrown = { workspace = true, features = ["serde"] } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
serde
should be enabled only via serialize
/deserialize
features. If there's something that needs serialization without those features that would be a bit fishy.
Connections
hashbrown
updates introduced in PR: Start usinghashbrown
#6925Description
hashbrown
innaga
& top-levelwgpu
cratesstd::collections::HashMap
viarustc_hash::FxHashMap
inwgpu-hal
hashbrown
in mainwgpu
cratehashbrown
indeno_webgpu
POSSIBLE API IMPACT
Exported
naga
API with these updates would be exporting types & members using HashMap & HashSet from hashbrown rather than std::collections. I think this is a crucial part of supporting no-std. I don't expect the blast radius to be very high, just wanted to point this out to avoid potential surprises for anyone.Loose ends:I have encountered some issues using✅hashbrown
with spirv & Arbitrary, will investigate these over the weekend./cc @bushrat011899
Testing
cargo test --all-features -p naga
cargo test --all-features -p wgpu-core
cargo test --all-features -p wgpu-hal
cargo test --all-features -p wgpu
cargo xtask test
Checklist
cargo fmt
.taplo format
.cargo clippy
. If applicable, add:--target wasm32-unknown-unknown
--target wasm32-unknown-emscripten
cargo xtask test
to run tests.CHANGELOG.md
. See simple instructions inside file.