Clippy fixes for Rust 1.73.0 (#2347)

* Clippy fixes for Rust 1.73.0

* Doc fixes too
This commit is contained in:
Rua 2023-10-07 14:13:17 +02:00 committed by GitHub
parent 9d988440df
commit fb828a6db2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 115 additions and 74 deletions

View File

@ -23,11 +23,8 @@ pub fn derive_buffer_contents(mut ast: DeriveInput) -> Result<TokenStream> {
if !ast if !ast
.attrs .attrs
.iter() .iter()
.filter_map(|attr| { .filter(|&attr| attr.path.is_ident("repr"))
attr.path .map(|attr| attr.parse_meta().unwrap())
.is_ident("repr")
.then(|| attr.parse_meta().unwrap())
})
.any(|meta| match meta { .any(|meta| match meta {
Meta::List(MetaList { nested, .. }) => { Meta::List(MetaList { nested, .. }) => {
nested.iter().any(|nested_meta| match nested_meta { nested.iter().any(|nested_meta| match nested_meta {

View File

@ -50,7 +50,7 @@ pub struct VulkanoWindowRenderer {
impl VulkanoWindowRenderer { impl VulkanoWindowRenderer {
/// Creates a new [`VulkanoWindowRenderer`] which is used to orchestrate your rendering with /// Creates a new [`VulkanoWindowRenderer`] which is used to orchestrate your rendering with
/// Vulkano. Pass [`WindowDescriptor`] and optionally a function modifying the /// Vulkano. Pass [`WindowDescriptor`] and optionally a function modifying the
/// [`SwapchainCreateInfo`](vulkano::swapchain::SwapchainCreateInfo) parameters. /// [`SwapchainCreateInfo`] parameters.
pub fn new( pub fn new(
vulkano_context: &VulkanoContext, vulkano_context: &VulkanoContext,
window: winit::window::Window, window: winit::window::Window,
@ -254,7 +254,7 @@ impl VulkanoWindowRenderer {
} }
/// Begin your rendering by calling `acquire`. /// Begin your rendering by calling `acquire`.
/// Returns a [`GpuFuture`](vulkano::sync::GpuFuture) representing the time after which the /// Returns a [`GpuFuture`] representing the time after which the
/// swapchain image has been acquired and previous frame ended. /// swapchain image has been acquired and previous frame ended.
/// Execute your command buffers after calling this function and finish rendering by calling /// Execute your command buffers after calling this function and finish rendering by calling
/// [`VulkanoWindowRenderer::present`]. /// [`VulkanoWindowRenderer::present`].

View File

@ -95,16 +95,26 @@ fn device_extensions_output(members: &[ExtensionsMember]) -> TokenStream {
}| { }| {
let name_string = name.to_string(); let name_string = name.to_string();
let dependency_check_items = requires_all_of.iter().filter_map( let dependency_check_items = requires_all_of
|RequiresOneOf { .iter()
api_version, .filter(
device_extensions, |&RequiresOneOf {
instance_extensions, api_version,
features: _, device_extensions,
}| { instance_extensions,
(device_extensions.is_empty() features: _,
&& (api_version.is_some() || !instance_extensions.is_empty())) }| {
.then(|| { device_extensions.is_empty()
&& (api_version.is_some() || !instance_extensions.is_empty())
},
)
.map(
|RequiresOneOf {
api_version,
device_extensions: _,
instance_extensions,
features: _,
}| {
let condition_items = (api_version.iter().map(|version| { let condition_items = (api_version.iter().map(|version| {
let version = format_ident!("V{}_{}", version.0, version.1); let version = format_ident!("V{}_{}", version.0, version.1);
quote! { api_version >= crate::Version::#version } quote! { api_version >= crate::Version::#version }
@ -141,9 +151,8 @@ fn device_extensions_output(members: &[ExtensionsMember]) -> TokenStream {
})); }));
} }
} }
}) },
}, );
);
let problem = format!( let problem = format!(
"contains `{}`, but this extension is not supported by the physical device", "contains `{}`, but this extension is not supported by the physical device",
name_string, name_string,
@ -164,21 +173,38 @@ fn device_extensions_output(members: &[ExtensionsMember]) -> TokenStream {
}, },
); );
let enable_dependencies_items = members.iter().filter_map( let enable_dependencies_items = members
|ExtensionsMember { .iter()
name, .filter(
requires_all_of, |&ExtensionsMember {
.. name: _,
}| { requires_all_of,
(!requires_all_of.is_empty()).then(|| { ..
let requires_all_of_items = requires_all_of.iter().filter_map( }| (!requires_all_of.is_empty()),
|RequiresOneOf { )
api_version, .map(
device_extensions, |ExtensionsMember {
instance_extensions: _, name,
features: _, requires_all_of,
}| { ..
(!device_extensions.is_empty()).then(|| { }| {
let requires_all_of_items = requires_all_of
.iter()
.filter(
|&RequiresOneOf {
api_version: _,
device_extensions,
instance_extensions: _,
features: _,
}| (!device_extensions.is_empty()),
)
.map(
|RequiresOneOf {
api_version,
device_extensions,
instance_extensions: _,
features: _,
}| {
let condition_items = api_version let condition_items = api_version
.iter() .iter()
.map(|(major, minor)| { .map(|(major, minor)| {
@ -226,18 +252,16 @@ fn device_extensions_output(members: &[ExtensionsMember]) -> TokenStream {
} }
} }
} }
}) },
}, );
);
quote! { quote! {
if self.#name { if self.#name {
#(#requires_all_of_items)* #(#requires_all_of_items)*
} }
} }
}) },
}, );
);
quote! { quote! {
#common #common
@ -325,21 +349,38 @@ fn instance_extensions_output(members: &[ExtensionsMember]) -> TokenStream {
}, },
); );
let enable_dependencies_items = members.iter().filter_map( let enable_dependencies_items = members
|ExtensionsMember { .iter()
name, .filter(
requires_all_of, |&ExtensionsMember {
.. name: _,
}| { requires_all_of,
(!requires_all_of.is_empty()).then(|| { ..
let requires_all_of_items = requires_all_of.iter().filter_map( }| (!requires_all_of.is_empty()),
|RequiresOneOf { )
api_version, .map(
device_extensions: _, |ExtensionsMember {
instance_extensions, name,
features: _, requires_all_of,
}| { ..
(!instance_extensions.is_empty()).then(|| { }| {
let requires_all_of_items = requires_all_of
.iter()
.filter(
|&RequiresOneOf {
api_version: _,
device_extensions: _,
instance_extensions,
features: _,
}| (!instance_extensions.is_empty()),
)
.map(
|RequiresOneOf {
api_version,
device_extensions: _,
instance_extensions,
features: _,
}| {
let condition_items = api_version let condition_items = api_version
.iter() .iter()
.map(|(major, minor)| { .map(|(major, minor)| {
@ -387,18 +428,16 @@ fn instance_extensions_output(members: &[ExtensionsMember]) -> TokenStream {
} }
} }
} }
}) },
}, );
);
quote! { quote! {
if self.#name { if self.#name {
#(#requires_all_of_items)* #(#requires_all_of_items)*
} }
} }
}) },
}, );
);
quote! { quote! {
#common #common

View File

@ -170,18 +170,23 @@ fn formats_output(members: &[FormatMember]) -> TokenStream {
Some(quote! { Self::#name => &[#(Self::#planes),*], }) Some(quote! { Self::#name => &[#(Self::#planes),*], })
} }
}); });
let texels_per_block_items = members.iter().filter_map( let texels_per_block_items = members
|FormatMember { .iter()
name, .filter(
texels_per_block, |&FormatMember {
.. texels_per_block, ..
}| { }| (*texels_per_block != 1),
(*texels_per_block != 1).then(|| { )
.map(
|FormatMember {
name,
texels_per_block,
..
}| {
let texels_per_block = Literal::u8_unsuffixed(*texels_per_block); let texels_per_block = Literal::u8_unsuffixed(*texels_per_block);
quote! { Self::#name => #texels_per_block, } quote! { Self::#name => #texels_per_block, }
}) },
}, );
);
let numeric_format_color_items = members.iter().filter_map( let numeric_format_color_items = members.iter().filter_map(
|FormatMember { |FormatMember {
name, name,

View File

@ -211,7 +211,7 @@ impl VulkanLibrary {
/// Returns the list of layers that are available when creating an instance. /// Returns the list of layers that are available when creating an instance.
/// ///
/// On success, this function returns an iterator that produces /// On success, this function returns an iterator that produces
/// [`LayerProperties`](crate::instance::LayerProperties) objects. In order to enable a layer, /// [`LayerProperties`] objects. In order to enable a layer,
/// you need to pass its name (returned by `LayerProperties::name()`) when creating the /// you need to pass its name (returned by `LayerProperties::name()`) when creating the
/// [`Instance`](crate::instance::Instance). /// [`Instance`](crate::instance::Instance).
/// ///

View File

@ -156,7 +156,7 @@ impl Hash for DeviceAlignment {
impl PartialOrd for DeviceAlignment { impl PartialOrd for DeviceAlignment {
#[inline] #[inline]
fn partial_cmp(&self, other: &Self) -> Option<Ordering> { fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
self.as_nonzero().partial_cmp(&other.as_nonzero()) Some(self.cmp(other))
} }
} }