generator: Remove unnecessary impl BuildHasher from HashMap types

Some clippy lint long ago apparently suggested to explicitly specify a
type for all random generators in 8550683 ("Address all the clippy lints
(#233)"), so the `impl BuildHasher` trait was apparently passed as a
placeholder for the `RandomState` default that's selected.

This does not serve any purpose and that (likely bogus) clippy warning
no longer shows up, making it safe to remove the trait.
This commit is contained in:
Marijn Suijten 2021-12-20 22:59:34 +01:00 committed by Benjamin Saunders
parent f781777931
commit ac94739e11

View file

@ -14,7 +14,6 @@ use quote::*;
use regex::Regex; use regex::Regex;
use std::collections::{BTreeMap, HashMap, HashSet}; use std::collections::{BTreeMap, HashMap, HashSet};
use std::fmt::Display; use std::fmt::Display;
use std::hash::BuildHasher;
use std::path::Path; use std::path::Path;
use syn::Ident; use syn::Ident;
@ -886,8 +885,8 @@ pub type CommandMap<'a> = HashMap<vkxml::Identifier, &'a vkxml::Command>;
fn generate_function_pointers<'a>( fn generate_function_pointers<'a>(
ident: Ident, ident: Ident,
commands: &[&'a vkxml::Command], commands: &[&'a vkxml::Command],
aliases: &HashMap<String, String, impl BuildHasher>, aliases: &HashMap<String, String>,
fn_cache: &mut HashSet<&'a str, impl BuildHasher>, fn_cache: &mut HashSet<&'a str>,
) -> TokenStream { ) -> TokenStream {
// Commands can have duplicates inside them because they are declared per features. But we only // Commands can have duplicates inside them because they are declared per features. But we only
// really want to generate one function pointer. // really want to generate one function pointer.
@ -1098,7 +1097,7 @@ pub fn generate_extension_constants<'a>(
extension_name: &str, extension_name: &str,
extension_number: i64, extension_number: i64,
extension_items: &'a [vk_parse::ExtensionChild], extension_items: &'a [vk_parse::ExtensionChild],
const_cache: &mut HashSet<&'a str, impl BuildHasher>, const_cache: &mut HashSet<&'a str>,
const_values: &mut BTreeMap<Ident, ConstantTypeInfo>, const_values: &mut BTreeMap<Ident, ConstantTypeInfo>,
) -> TokenStream { ) -> TokenStream {
let items = extension_items let items = extension_items
@ -1154,8 +1153,8 @@ pub fn generate_extension_commands<'a>(
extension_name: &str, extension_name: &str,
items: &[vk_parse::ExtensionChild], items: &[vk_parse::ExtensionChild],
cmd_map: &CommandMap<'a>, cmd_map: &CommandMap<'a>,
cmd_aliases: &HashMap<String, String, impl BuildHasher>, cmd_aliases: &HashMap<String, String>,
fn_cache: &mut HashSet<&'a str, impl BuildHasher>, fn_cache: &mut HashSet<&'a str>,
) -> TokenStream { ) -> TokenStream {
let mut commands = Vec::new(); let mut commands = Vec::new();
let mut aliases = HashMap::new(); let mut aliases = HashMap::new();
@ -1229,10 +1228,10 @@ pub fn generate_extension_commands<'a>(
pub fn generate_extension<'a>( pub fn generate_extension<'a>(
extension: &'a vk_parse::Extension, extension: &'a vk_parse::Extension,
cmd_map: &CommandMap<'a>, cmd_map: &CommandMap<'a>,
const_cache: &mut HashSet<&'a str, impl BuildHasher>, const_cache: &mut HashSet<&'a str>,
const_values: &mut BTreeMap<Ident, ConstantTypeInfo>, const_values: &mut BTreeMap<Ident, ConstantTypeInfo>,
cmd_aliases: &HashMap<String, String, impl BuildHasher>, cmd_aliases: &HashMap<String, String>,
fn_cache: &mut HashSet<&'a str, impl BuildHasher>, fn_cache: &mut HashSet<&'a str>,
) -> Option<TokenStream> { ) -> Option<TokenStream> {
// Okay this is a little bit odd. We need to generate all extensions, even disabled ones, // Okay this is a little bit odd. We need to generate all extensions, even disabled ones,
// because otherwise some StructureTypes won't get generated. But we don't generate extensions // because otherwise some StructureTypes won't get generated. But we don't generate extensions
@ -1330,7 +1329,7 @@ pub fn generate_typedef(typedef: &vkxml::Typedef) -> TokenStream {
} }
pub fn generate_bitmask( pub fn generate_bitmask(
bitmask: &vkxml::Bitmask, bitmask: &vkxml::Bitmask,
bitflags_cache: &mut HashSet<Ident, impl BuildHasher>, bitflags_cache: &mut HashSet<Ident>,
const_values: &mut BTreeMap<Ident, ConstantTypeInfo>, const_values: &mut BTreeMap<Ident, ConstantTypeInfo>,
) -> Option<TokenStream> { ) -> Option<TokenStream> {
// Workaround for empty bitmask // Workaround for empty bitmask
@ -1458,9 +1457,9 @@ pub fn bitflags_impl_block(
pub fn generate_enum<'a>( pub fn generate_enum<'a>(
enum_: &'a vk_parse::Enums, enum_: &'a vk_parse::Enums,
const_cache: &mut HashSet<&'a str, impl BuildHasher>, const_cache: &mut HashSet<&'a str>,
const_values: &mut BTreeMap<Ident, ConstantTypeInfo>, const_values: &mut BTreeMap<Ident, ConstantTypeInfo>,
bitflags_cache: &mut HashSet<Ident, impl BuildHasher>, bitflags_cache: &mut HashSet<Ident>,
) -> EnumType { ) -> EnumType {
let name = enum_.name.as_ref().unwrap(); let name = enum_.name.as_ref().unwrap();
let clean_name = name.strip_prefix("Vk").unwrap(); let clean_name = name.strip_prefix("Vk").unwrap();
@ -1667,10 +1666,7 @@ pub fn derive_default(_struct: &vkxml::Struct) -> Option<TokenStream> {
}; };
Some(q) Some(q)
} }
pub fn derive_debug( pub fn derive_debug(_struct: &vkxml::Struct, union_types: &HashSet<&str>) -> Option<TokenStream> {
_struct: &vkxml::Struct,
union_types: &HashSet<&str, impl BuildHasher>,
) -> Option<TokenStream> {
let name = name_to_tokens(&_struct.name); let name = name_to_tokens(&_struct.name);
let members = _struct.elements.iter().filter_map(|elem| match *elem { let members = _struct.elements.iter().filter_map(|elem| match *elem {
vkxml::StructElement::Member(ref field) => Some(field), vkxml::StructElement::Member(ref field) => Some(field),
@ -1731,7 +1727,7 @@ pub fn derive_debug(
pub fn derive_setters( pub fn derive_setters(
struct_: &vkxml::Struct, struct_: &vkxml::Struct,
root_structs: &HashSet<Ident, impl BuildHasher>, root_structs: &HashSet<Ident>,
) -> Option<TokenStream> { ) -> Option<TokenStream> {
if &struct_.name == "VkBaseInStructure" if &struct_.name == "VkBaseInStructure"
|| &struct_.name == "VkBaseOutStructure" || &struct_.name == "VkBaseOutStructure"
@ -2047,8 +2043,8 @@ pub fn manual_derives(_struct: &vkxml::Struct) -> TokenStream {
} }
pub fn generate_struct( pub fn generate_struct(
_struct: &vkxml::Struct, _struct: &vkxml::Struct,
root_structs: &HashSet<Ident, impl BuildHasher>, root_structs: &HashSet<Ident>,
union_types: &HashSet<&str, impl BuildHasher>, union_types: &HashSet<&str>,
) -> TokenStream { ) -> TokenStream {
let name = name_to_tokens(&_struct.name); let name = name_to_tokens(&_struct.name);
if &_struct.name == "VkTransformMatrixKHR" { if &_struct.name == "VkTransformMatrixKHR" {
@ -2251,9 +2247,9 @@ pub fn root_structs(definitions: &[&vkxml::DefinitionsElement]) -> HashSet<Ident
} }
pub fn generate_definition( pub fn generate_definition(
definition: &vkxml::DefinitionsElement, definition: &vkxml::DefinitionsElement,
union_types: &HashSet<&str, impl BuildHasher>, union_types: &HashSet<&str>,
root_structs: &HashSet<Ident, impl BuildHasher>, root_structs: &HashSet<Ident>,
bitflags_cache: &mut HashSet<Ident, impl BuildHasher>, bitflags_cache: &mut HashSet<Ident>,
const_values: &mut BTreeMap<Ident, ConstantTypeInfo>, const_values: &mut BTreeMap<Ident, ConstantTypeInfo>,
identifier_renames: &mut BTreeMap<String, Ident>, identifier_renames: &mut BTreeMap<String, Ident>,
) -> Option<TokenStream> { ) -> Option<TokenStream> {
@ -2277,7 +2273,7 @@ pub fn generate_definition(
pub fn generate_feature<'a>( pub fn generate_feature<'a>(
feature: &vkxml::Feature, feature: &vkxml::Feature,
commands: &CommandMap<'a>, commands: &CommandMap<'a>,
fn_cache: &mut HashSet<&'a str, impl BuildHasher>, fn_cache: &mut HashSet<&'a str>,
) -> TokenStream { ) -> TokenStream {
let (static_commands, entry_commands, device_commands, instance_commands) = feature let (static_commands, entry_commands, device_commands, instance_commands) = feature
.elements .elements
@ -2363,7 +2359,7 @@ pub fn constant_name(name: &str) -> &str {
pub fn generate_constant<'a>( pub fn generate_constant<'a>(
constant: &'a vkxml::Constant, constant: &'a vkxml::Constant,
cache: &mut HashSet<&'a str, impl BuildHasher>, cache: &mut HashSet<&'a str>,
) -> TokenStream { ) -> TokenStream {
cache.insert(constant.name.as_str()); cache.insert(constant.name.as_str());
let c = Constant::from_constant(constant); let c = Constant::from_constant(constant);
@ -2384,7 +2380,7 @@ pub fn generate_constant<'a>(
pub fn generate_feature_extension<'a>( pub fn generate_feature_extension<'a>(
registry: &'a vk_parse::Registry, registry: &'a vk_parse::Registry,
const_cache: &mut HashSet<&'a str, impl BuildHasher>, const_cache: &mut HashSet<&'a str>,
const_values: &mut BTreeMap<Ident, ConstantTypeInfo>, const_values: &mut BTreeMap<Ident, ConstantTypeInfo>,
) -> TokenStream { ) -> TokenStream {
let constants = registry.0.iter().filter_map(|item| match item { let constants = registry.0.iter().filter_map(|item| match item {
@ -2557,7 +2553,7 @@ pub fn extract_native_types(registry: &vk_parse::Registry) -> (Vec<(String, Stri
} }
pub fn generate_aliases_of_types( pub fn generate_aliases_of_types(
types: &vk_parse::Types, types: &vk_parse::Types,
ty_cache: &mut HashSet<Ident, impl BuildHasher>, ty_cache: &mut HashSet<Ident>,
) -> TokenStream { ) -> TokenStream {
let aliases = types let aliases = types
.children .children