Use workspace lints (#2505)

* Use workspace lints

* Use underscores for the lints, since they are canonically written that way

* Put lints after features
This commit is contained in:
Rua 2024-03-28 11:58:43 +01:00 committed by GitHub
parent 15f60f02c9
commit e9c650c966
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
16 changed files with 46 additions and 53 deletions

View File

@ -63,6 +63,24 @@ png = "0.17"
rand = "0.8"
ron = "0.8"
[workspace.lints]
rust.missing_docs = "allow" # TODO: warn eventually
rust.rust_2018_idioms = "warn"
rust.rust_2024_compatibility = "allow" # TODO: warn eventually
clippy.missing_safety_doc = "allow" # TODO: warn eventually
clippy.trivially_copy_pass_by_ref = "warn"
# These lints are a bit too pedantic, so they're disabled here.
# They can be removed if they no longer happen in the future.
clippy.arc_with_non_send_sync = "allow"
clippy.collapsible_else_if = "allow"
clippy.collapsible_if = "allow"
clippy.len_without_is_empty = "allow"
clippy.needless_borrowed_reference = "allow"
clippy.nonminimal_bool = "allow"
clippy.result_large_err = "allow"
clippy.too_many_arguments = "allow"
clippy.type_complexity = "allow"
[profile.CI]
inherits = "dev"
debug = 0

View File

@ -27,3 +27,6 @@ vulkano = { workspace = true }
[features]
shaderc-build-from-source = ["shaderc/build-from-source"]
shaderc-debug = []
[lints]
workspace = true

View File

@ -225,8 +225,6 @@
#![doc(html_logo_url = "https://raw.githubusercontent.com/vulkano-rs/vulkano/master/logo.png")]
#![recursion_limit = "1024"]
#![allow(clippy::needless_borrowed_reference)]
#![warn(rust_2018_idioms, rust_2021_compatibility)]
use crate::codegen::ShaderKind;
use ahash::HashMap;

View File

@ -16,3 +16,6 @@ readme = "../README.md"
ahash = { workspace = true }
vulkano = { workspace = true }
winit = { workspace = true }
[lints]
workspace = true

View File

@ -1,6 +1,3 @@
#![allow(clippy::missing_safety_doc)]
#![warn(rust_2018_idioms, rust_2021_compatibility)]
pub mod context;
pub mod renderer;
pub mod window;

View File

@ -49,3 +49,6 @@ vk-parse = { workspace = true }
default = ["macros"]
macros = ["dep:vulkano-macros"]
document_unchecked = []
[lints]
workspace = true

View File

@ -3,7 +3,7 @@ use heck::ToUpperCamelCase;
use proc_macro2::{Ident, TokenStream};
use quote::{format_ident, quote};
pub fn write(vk_data: &VkRegistryData) {
pub fn write(vk_data: &VkRegistryData<'_>) {
write_file(
"errors.rs",
format!(

View File

@ -26,7 +26,7 @@ fn conflicts_extensions(name: &str) -> &'static [&'static str] {
}
}
pub fn write(vk_data: &VkRegistryData) {
pub fn write(vk_data: &VkRegistryData<'_>) {
write_device_extensions(vk_data);
write_instance_extensions(vk_data);
}
@ -55,7 +55,7 @@ pub enum Requires {
InstanceExtension(String),
}
fn write_device_extensions(vk_data: &VkRegistryData) {
fn write_device_extensions(vk_data: &VkRegistryData<'_>) {
write_file(
"device_extensions.rs",
format!(
@ -66,7 +66,7 @@ fn write_device_extensions(vk_data: &VkRegistryData) {
);
}
fn write_instance_extensions(vk_data: &VkRegistryData) {
fn write_instance_extensions(vk_data: &VkRegistryData<'_>) {
write_file(
"instance_extensions.rs",
format!(
@ -890,7 +890,7 @@ fn extensions_members(ty: &str, extensions: &IndexMap<&str, &Extension>) -> Vec<
}
fn from_one_of(
one_of: Vec<DependsExpression>,
one_of: Vec<DependsExpression<'_>>,
extensions: &IndexMap<&str, &Extension>,
) -> Result<Vec<RequiresOneOf>, String> {
let mut requires_all_of = vec![RequiresOneOf::default()];
@ -979,14 +979,14 @@ fn parse_depends(depends: &str) -> Result<DependsExpression<'_>, String> {
take_while1(|c: char| c.is_ascii_alphanumeric() || c == '_')(input)
}
fn term(input: &str) -> IResult<&str, DependsExpression> {
fn term(input: &str) -> IResult<&str, DependsExpression<'_>> {
alt((
name.map(DependsExpression::Name),
delimited(complete::char('('), expression, complete::char(')')),
))(input)
}
fn expression(input: &str) -> IResult<&str, DependsExpression> {
fn expression(input: &str) -> IResult<&str, DependsExpression<'_>> {
let (input, first) = term(input)?;
if let Some(input) = input.strip_prefix('+') {

View File

@ -50,7 +50,7 @@ fn required_by_extensions(name: &str) -> &'static [(&'static str, &'static str)]
}
}
pub fn write(vk_data: &VkRegistryData) {
pub fn write(vk_data: &VkRegistryData<'_>) {
let features_output = features_output(&features_members(&vk_data.types));
let features_ffi_output =
features_ffi_output(&features_ffi_members(&vk_data.types, &vk_data.extensions));

View File

@ -4,7 +4,7 @@ use proc_macro2::{Ident, TokenStream};
use quote::{format_ident, quote};
use vk_parse::{Extension, ExtensionChild, InterfaceItem};
pub fn write(vk_data: &VkRegistryData) {
pub fn write(vk_data: &VkRegistryData<'_>) {
let entry_fns_output = fns_output(
&[],
"Entry",

View File

@ -8,7 +8,7 @@ use vk_parse::{
Enum, EnumSpec, Extension, ExtensionChild, Feature, Format, FormatChild, InterfaceItem,
};
pub fn write(vk_data: &VkRegistryData) {
pub fn write(vk_data: &VkRegistryData<'_>) {
write_file(
"formats.rs",
format!(

View File

@ -13,7 +13,7 @@ use quote::{format_ident, quote};
use std::{collections::hash_map::Entry, fmt::Write as _};
use vk_parse::{Extension, Type, TypeMember, TypeMemberMarkup, TypeSpec};
pub fn write(vk_data: &VkRegistryData) {
pub fn write(vk_data: &VkRegistryData<'_>) {
let properties_output = properties_output(&properties_members(&vk_data.types));
let properties_ffi_output =
properties_ffi_output(&properties_ffi_members(&vk_data.types, &vk_data.extensions));
@ -430,7 +430,7 @@ struct Member<'a> {
len: Option<&'a str>,
}
fn members(ty: &Type) -> Vec<Member> {
fn members(ty: &Type) -> Vec<Member<'_>> {
fn array_len(input: &str) -> IResult<&str, &str> {
let (input, _) = take_until("[")(input)?;
all_consuming(delimited(

View File

@ -15,7 +15,7 @@ use proc_macro2::TokenStream;
use quote::{format_ident, quote};
use vk_parse::SpirvExtOrCap;
pub fn write(vk_data: &VkRegistryData, grammar: &SpirvGrammar) {
pub fn write(vk_data: &VkRegistryData<'_>, grammar: &SpirvGrammar) {
let grammar_enumerants = grammar
.operand_kinds
.iter()

View File

@ -2,7 +2,7 @@ use super::{write_file, VkRegistryData};
use proc_macro2::{Literal, TokenStream};
use quote::quote;
pub fn write(vk_data: &VkRegistryData) {
pub fn write(vk_data: &VkRegistryData<'_>) {
let version_output = version_output(vk_data.header_version);
write_file(
"version.rs",

View File

@ -2730,7 +2730,7 @@ impl RenderingInfo {
if let (Some(depth_attachment_info), Some(stencil_attachment_info)) =
(depth_attachment, stencil_attachment)
{
if &depth_attachment_info.image_view != &stencil_attachment_info.image_view {
if depth_attachment_info.image_view != stencil_attachment_info.image_view {
return Err(Box::new(ValidationError {
problem: "`depth_attachment` and `stencil_attachment` are both `Some`, but \
`depth_attachment.image_view` does not equal \
@ -2809,7 +2809,7 @@ impl RenderingInfo {
}));
}
if &depth_resolve_info.image_view != &stencil_resolve_info.image_view {
if depth_resolve_info.image_view != stencil_resolve_info.image_view {
return Err(Box::new(ValidationError {
problem: "`depth_attachment` and `stencil_attachment` are both \
`Some`, and `depth_attachment.resolve_info` and \

View File

@ -22,17 +22,16 @@
//! uses, you can add one of the [features](https://docs.rs/crate/winit/latest/features) that
//! starts with `rwh` to `winit`. Currently, vulkano is compatible with `rwh_06`.
//!
//!
//! 4. [Enumerate the physical devices] that are available on the `Instance`, and choose one that
//! is suitable for your program. A [`PhysicalDevice`] represents a Vulkan-capable device that
//! is available on the system, such as a graphics card, a software implementation, etc.
//!
//! 6. Create a [`Device`] and accompanying [`Queue`]s from the selected `PhysicalDevice`. The
//! 5. Create a [`Device`] and accompanying [`Queue`]s from the selected `PhysicalDevice`. The
//! `Device` is the most important object of Vulkan, and you need one to create almost every
//! other object. `Queue`s are created together with the `Device`, and are used to submit work
//! to the device to make it do something.
//!
//! 7. If you created a `Surface` earlier, create a [`Swapchain`]. This object contains special
//! 6. If you created a `Surface` earlier, create a [`Swapchain`]. This object contains special
//! images that correspond to the contents of the surface. Whenever you want to change the
//! contents (show something new to the user), you must first *acquire* one of these images from
//! the swapchain, fill it with the new contents (by rendering, copying or any other means), and
@ -40,7 +39,7 @@
//! of the surface change, such as when the size of the window changes. It then becomes
//! necessary to create a new swapchain.
//!
//! 8. Record a [*command buffer*](command_buffer), containing commands that the device must
//! 7. Record a [*command buffer*](command_buffer), containing commands that the device must
//! execute. Then build the command buffer and submit it to a `Queue`.
//!
//! Many different operations can be recorded to a command buffer, such as *draw*, *compute* and
@ -120,34 +119,6 @@
//! [`vulkano-macros`]: vulkano_macros
//! [`serde`]: https://crates.io/crates/serde
//#![warn(missing_docs)] // TODO: activate
#![warn(
rust_2018_idioms,
rust_2021_compatibility,
clippy::trivially_copy_pass_by_ref
)]
// These lints are a bit too pedantic, so they're disabled here.
#![allow(
clippy::arc_with_non_send_sync,
clippy::collapsible_else_if,
clippy::collapsible_if,
clippy::derivable_impls, // TODO: remove
clippy::large_enum_variant,
clippy::len_without_is_empty,
clippy::missing_safety_doc, // TODO: remove
clippy::module_inception,
clippy::mutable_key_type,
clippy::needless_borrowed_reference,
clippy::new_without_default,
clippy::nonminimal_bool,
clippy::op_ref, // Seems to be bugged, the fixed code triggers a compile error
clippy::result_large_err,
clippy::too_many_arguments,
clippy::type_complexity,
clippy::vec_box,
clippy::wrong_self_convention
)]
pub use ash::vk::Handle;
use bytemuck::{Pod, Zeroable};
pub use extensions::ExtensionProperties;