Skip to content

Commit

Permalink
Use workspace lints (#2505)
Browse files Browse the repository at this point in the history
* Use workspace lints

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

* Put lints after features
  • Loading branch information
Rua authored Mar 28, 2024
1 parent 15f60f0 commit e9c650c
Show file tree
Hide file tree
Showing 16 changed files with 46 additions and 53 deletions.
18 changes: 18 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions vulkano-shaders/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,6 @@ vulkano = { workspace = true }
[features]
shaderc-build-from-source = ["shaderc/build-from-source"]
shaderc-debug = []

[lints]
workspace = true
2 changes: 0 additions & 2 deletions vulkano-shaders/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 3 additions & 0 deletions vulkano-util/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,6 @@ readme = "../README.md"
ahash = { workspace = true }
vulkano = { workspace = true }
winit = { workspace = true }

[lints]
workspace = true
3 changes: 0 additions & 3 deletions vulkano-util/src/lib.rs
Original file line number Diff line number Diff line change
@@ -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;
3 changes: 3 additions & 0 deletions vulkano/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,6 @@ vk-parse = { workspace = true }
default = ["macros"]
macros = ["dep:vulkano-macros"]
document_unchecked = []

[lints]
workspace = true
2 changes: 1 addition & 1 deletion vulkano/autogen/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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!(
Expand Down
12 changes: 6 additions & 6 deletions vulkano/autogen/extensions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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!(
Expand All @@ -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!(
Expand Down Expand Up @@ -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()];
Expand Down Expand Up @@ -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('+') {
Expand Down
2 changes: 1 addition & 1 deletion vulkano/autogen/features.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
2 changes: 1 addition & 1 deletion vulkano/autogen/fns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion vulkano/autogen/formats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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!(
Expand Down
4 changes: 2 additions & 2 deletions vulkano/autogen/properties.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion vulkano/autogen/spirv_reqs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion vulkano/autogen/version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions vulkano/src/command_buffer/commands/render_pass.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down Expand Up @@ -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 \
Expand Down
35 changes: 3 additions & 32 deletions vulkano/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,25 +22,24 @@
//! 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
//! then *present* it back to the swapchain. A swapchain can become outdated if the properties
//! 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
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit e9c650c

Please sign in to comment.