diff --git a/crates/rustc_codegen_spirv/src/decorations.rs b/crates/rustc_codegen_spirv/src/decorations.rs index 6c9af42265..0646f14d1e 100644 --- a/crates/rustc_codegen_spirv/src/decorations.rs +++ b/crates/rustc_codegen_spirv/src/decorations.rs @@ -1,10 +1,6 @@ //! SPIR-V decorations specific to `rustc_codegen_spirv`, produced during //! the original codegen of a crate, and consumed by the `linker`. -// FIXME(eddyb) Remove when a fix for clippy warning in `serde` derives -// (https://github.com/rust-lang/rust-clippy/issues/6818) lands in nightly. -#![allow(clippy::use_self)] - use rspirv::dr::{Instruction, Module, Operand}; use rspirv::spirv::{Decoration, Op, Word}; use rustc_span::{source_map::SourceMap, FileName, Pos, Span}; diff --git a/crates/rustc_codegen_spirv/src/lib.rs b/crates/rustc_codegen_spirv/src/lib.rs index 31d63a08f3..49408c7acf 100644 --- a/crates/rustc_codegen_spirv/src/lib.rs +++ b/crates/rustc_codegen_spirv/src/lib.rs @@ -17,42 +17,61 @@ //! [`spirv-tools-sys`]: https://embarkstudios.github.io/rust-gpu/api/spirv_tools_sys #![feature(rustc_private)] #![feature(once_cell)] -#![deny(clippy::unimplemented, clippy::ok_expect, clippy::mem_forget)] -// Our standard Clippy lints that we use in Embark projects, we opt out of a few that are not appropriate for the specific crate (yet) +// BEGIN - Embark standard lints v0.2. +// do not change or add/remove here, but one can add exceptions after this section +// for more info see: +#![deny(unsafe_code)] #![warn( clippy::all, - clippy::doc_markdown, + clippy::await_holding_lock, clippy::dbg_macro, - //clippy::todo, + clippy::debug_assert_with_mut_call, + clippy::doc_markdown, clippy::empty_enum, - //clippy::enum_glob_use, - clippy::pub_enum_variant_names, - clippy::mem_forget, - clippy::use_self, + clippy::enum_glob_use, + clippy::exit, + clippy::explicit_into_iter_loop, clippy::filter_map_next, - clippy::needless_continue, - clippy::needless_borrow, - clippy::match_wildcard_for_single_variants, + clippy::fn_params_excessive_bools, clippy::if_let_mutex, - clippy::mismatched_target_os, - clippy::await_holding_lock, - //clippy::match_on_vec_items, clippy::imprecise_flops, - clippy::suboptimal_flops, - clippy::lossy_float_literal, - clippy::rest_pat_in_fully_bound_structs, - clippy::fn_params_excessive_bools, - clippy::exit, clippy::inefficient_to_string, + clippy::let_unit_value, clippy::linkedlist, + clippy::lossy_float_literal, clippy::macro_use_imports, + clippy::map_flatten, + clippy::map_unwrap_or, + clippy::match_on_vec_items, + clippy::match_wildcard_for_single_variants, + clippy::mem_forget, + clippy::mismatched_target_os, + clippy::needless_borrow, + clippy::needless_continue, clippy::option_option, - clippy::verbose_file_reads, + clippy::pub_enum_variant_names, + clippy::ref_option_ref, + clippy::rest_pat_in_fully_bound_structs, + clippy::string_to_string, + clippy::suboptimal_flops, + clippy::todo, clippy::unnested_or_patterns, - rust_2018_idioms, + clippy::unused_self, + clippy::verbose_file_reads, future_incompatible, - nonstandard_style + nonstandard_style, + rust_2018_idioms +)] +// END - Embark standard lints v0.2 +// crate-specific exceptions: +#![allow( + unsafe_code, // still quite a bit of unsafe + clippy::map_unwrap_or, // TODO: test enabling + clippy::match_on_vec_items, // TODO: test enabling + clippy::enum_glob_use, + clippy::todo, // still lots to implement :) )] +#![deny(clippy::unimplemented, clippy::ok_expect)] extern crate rustc_ast; extern crate rustc_attr; diff --git a/crates/rustc_codegen_spirv/src/link.rs b/crates/rustc_codegen_spirv/src/link.rs index fba0100f9e..120a332e0a 100644 --- a/crates/rustc_codegen_spirv/src/link.rs +++ b/crates/rustc_codegen_spirv/src/link.rs @@ -465,7 +465,7 @@ pub(crate) fn run_thin( let mut thin_buffers = Vec::with_capacity(modules.len()); let mut module_names = Vec::with_capacity(modules.len() + cached_modules.len()); - for (name, buffer) in modules.into_iter() { + for (name, buffer) in modules { let cname = CString::new(name.clone()).unwrap(); thin_buffers.push(buffer); module_names.push(cname); diff --git a/crates/rustc_codegen_spirv/src/linker/specializer.rs b/crates/rustc_codegen_spirv/src/linker/specializer.rs index b29e4796ab..db68397187 100644 --- a/crates/rustc_codegen_spirv/src/linker/specializer.rs +++ b/crates/rustc_codegen_spirv/src/linker/specializer.rs @@ -1261,6 +1261,7 @@ struct Unapplicable; impl<'a, S: Specialization> InferCx<'a, S> { /// Match `storage_class` against `pat`, returning a `Match` with found `Var`s. + #[allow(clippy::unused_self)] // TODO: remove? fn match_storage_class_pat( &self, pat: &StorageClassPat, diff --git a/crates/spirv-builder/src/lib.rs b/crates/spirv-builder/src/lib.rs index 8fcfc8730d..76b64f2a3c 100644 --- a/crates/spirv-builder/src/lib.rs +++ b/crates/spirv-builder/src/lib.rs @@ -1,3 +1,52 @@ +// BEGIN - Embark standard lints v0.2. +// do not change or add/remove here, but one can add exceptions after this section +// for more info see: +#![deny(unsafe_code)] +#![warn( + clippy::all, + clippy::await_holding_lock, + clippy::dbg_macro, + clippy::debug_assert_with_mut_call, + clippy::doc_markdown, + clippy::empty_enum, + clippy::enum_glob_use, + clippy::exit, + clippy::explicit_into_iter_loop, + clippy::filter_map_next, + clippy::fn_params_excessive_bools, + clippy::if_let_mutex, + clippy::imprecise_flops, + clippy::inefficient_to_string, + clippy::let_unit_value, + clippy::linkedlist, + clippy::lossy_float_literal, + clippy::macro_use_imports, + clippy::map_flatten, + clippy::map_unwrap_or, + clippy::match_on_vec_items, + clippy::match_wildcard_for_single_variants, + clippy::mem_forget, + clippy::mismatched_target_os, + clippy::needless_borrow, + clippy::needless_continue, + clippy::option_option, + clippy::pub_enum_variant_names, + clippy::ref_option_ref, + clippy::rest_pat_in_fully_bound_structs, + clippy::string_to_string, + clippy::suboptimal_flops, + clippy::todo, + clippy::unnested_or_patterns, + clippy::unused_self, + clippy::verbose_file_reads, + future_incompatible, + nonstandard_style, + rust_2018_idioms +)] +// END - Embark standard lints v0.2 +// crate-specific exceptions: +#![allow()] + #[cfg(test)] mod test; @@ -75,7 +124,7 @@ impl SpirvBuilder { self } - /// Builds the module. Returns the path to the built spir-v file. If print_metadata is true, + /// Builds the module. Returns the path to the built spir-v file. If `print_metadata` is true, /// you usually don't have to inspect the path, as the environment variable will already be /// set. pub fn build(self) -> Result { diff --git a/crates/spirv-std-macros/src/lib.rs b/crates/spirv-std-macros/src/lib.rs index ed9228eb09..9060a465f9 100644 --- a/crates/spirv-std-macros/src/lib.rs +++ b/crates/spirv-std-macros/src/lib.rs @@ -1,3 +1,52 @@ +// BEGIN - Embark standard lints v0.2. +// do not change or add/remove here, but one can add exceptions after this section +// for more info see: +#![deny(unsafe_code)] +#![warn( + clippy::all, + clippy::await_holding_lock, + clippy::dbg_macro, + clippy::debug_assert_with_mut_call, + clippy::doc_markdown, + clippy::empty_enum, + clippy::enum_glob_use, + clippy::exit, + clippy::explicit_into_iter_loop, + clippy::filter_map_next, + clippy::fn_params_excessive_bools, + clippy::if_let_mutex, + clippy::imprecise_flops, + clippy::inefficient_to_string, + clippy::let_unit_value, + clippy::linkedlist, + clippy::lossy_float_literal, + clippy::macro_use_imports, + clippy::map_flatten, + clippy::map_unwrap_or, + clippy::match_on_vec_items, + clippy::match_wildcard_for_single_variants, + clippy::mem_forget, + clippy::mismatched_target_os, + clippy::needless_borrow, + clippy::needless_continue, + clippy::option_option, + clippy::pub_enum_variant_names, + clippy::ref_option_ref, + clippy::rest_pat_in_fully_bound_structs, + clippy::string_to_string, + clippy::suboptimal_flops, + clippy::todo, + clippy::unnested_or_patterns, + clippy::unused_self, + clippy::verbose_file_reads, + future_incompatible, + nonstandard_style, + rust_2018_idioms +)] +// END - Embark standard lints v0.2 +// crate-specific exceptions: +#![allow()] + use proc_macro::{Delimiter, Group, TokenStream, TokenTree}; #[proc_macro_attribute] diff --git a/crates/spirv-std/src/lib.rs b/crates/spirv-std/src/lib.rs index cee36a77f0..db52e161ca 100644 --- a/crates/spirv-std/src/lib.rs +++ b/crates/spirv-std/src/lib.rs @@ -4,40 +4,54 @@ feature(asm, register_attr, repr_simd, core_intrinsics, lang_items), register_attr(spirv) )] -// Our standard Clippy lints that we use in Embark projects, we opt out of a few that are not appropriate for the specific crate (yet) +// BEGIN - Embark standard lints v0.2. +// do not change or add/remove here, but one can add exceptions after this section +// for more info see: +#![deny(unsafe_code)] #![warn( clippy::all, - clippy::doc_markdown, + clippy::await_holding_lock, clippy::dbg_macro, - clippy::todo, + clippy::debug_assert_with_mut_call, + clippy::doc_markdown, clippy::empty_enum, clippy::enum_glob_use, - clippy::pub_enum_variant_names, - clippy::mem_forget, + clippy::exit, + clippy::explicit_into_iter_loop, clippy::filter_map_next, - clippy::needless_continue, - clippy::needless_borrow, - clippy::match_wildcard_for_single_variants, + clippy::fn_params_excessive_bools, clippy::if_let_mutex, - clippy::mismatched_target_os, - clippy::await_holding_lock, - clippy::match_on_vec_items, clippy::imprecise_flops, - //clippy::suboptimal_flops, - clippy::lossy_float_literal, - clippy::rest_pat_in_fully_bound_structs, - clippy::fn_params_excessive_bools, - clippy::exit, clippy::inefficient_to_string, + clippy::let_unit_value, clippy::linkedlist, + clippy::lossy_float_literal, clippy::macro_use_imports, + clippy::map_flatten, + clippy::map_unwrap_or, + clippy::match_on_vec_items, + clippy::match_wildcard_for_single_variants, + clippy::mem_forget, + clippy::mismatched_target_os, + clippy::needless_borrow, + clippy::needless_continue, clippy::option_option, - clippy::verbose_file_reads, + clippy::pub_enum_variant_names, + clippy::ref_option_ref, + clippy::rest_pat_in_fully_bound_structs, + clippy::string_to_string, + clippy::suboptimal_flops, + clippy::todo, clippy::unnested_or_patterns, - rust_2018_idioms, + clippy::unused_self, + clippy::verbose_file_reads, future_incompatible, - nonstandard_style + nonstandard_style, + rust_2018_idioms )] +// END - Embark standard lints v0.2 +// crate-specific exceptions: +#![allow(unsafe_code)] // still quite a bit needed #[cfg(not(target_arch = "spirv"))] #[macro_use] diff --git a/crates/spirv-tools-sys/spirv-headers b/crates/spirv-tools-sys/spirv-headers new file mode 160000 index 0000000000..7845730cab --- /dev/null +++ b/crates/spirv-tools-sys/spirv-headers @@ -0,0 +1 @@ +Subproject commit 7845730cab6ebbdeb621e7349b7dc1a59c3377be diff --git a/crates/spirv-tools-sys/spirv-tools b/crates/spirv-tools-sys/spirv-tools new file mode 160000 index 0000000000..36494dd966 --- /dev/null +++ b/crates/spirv-tools-sys/spirv-tools @@ -0,0 +1 @@ +Subproject commit 36494dd966ecaa4a399f3f7755bbdcf561229503 diff --git a/examples/runners/ash/src/main.rs b/examples/runners/ash/src/main.rs index 9520b917b8..5579423cf2 100644 --- a/examples/runners/ash/src/main.rs +++ b/examples/runners/ash/src/main.rs @@ -1,3 +1,47 @@ +// standard Embark lints +//#![deny(unsafe_code)] // impractical in this crate dealing with unsafe `ash` +#![warn( + clippy::all, + clippy::await_holding_lock, + clippy::dbg_macro, + clippy::debug_assert_with_mut_call, + clippy::doc_markdown, + clippy::empty_enum, + clippy::enum_glob_use, + clippy::exit, + clippy::explicit_into_iter_loop, + clippy::filter_map_next, + clippy::fn_params_excessive_bools, + clippy::if_let_mutex, + clippy::imprecise_flops, + clippy::inefficient_to_string, + clippy::let_unit_value, + clippy::linkedlist, + clippy::lossy_float_literal, + clippy::macro_use_imports, + clippy::map_flatten, + clippy::map_unwrap_or, + clippy::match_on_vec_items, + clippy::match_wildcard_for_single_variants, + clippy::mem_forget, + clippy::mismatched_target_os, + clippy::needless_borrow, + clippy::needless_continue, + clippy::option_option, + clippy::pub_enum_variant_names, + clippy::ref_option_ref, + clippy::rest_pat_in_fully_bound_structs, + clippy::string_to_string, + clippy::suboptimal_flops, + clippy::todo, + clippy::unnested_or_patterns, + clippy::unused_self, + clippy::verbose_file_reads, + future_incompatible, + nonstandard_style, + rust_2018_idioms +)] + use ash::{ extensions::{ext, khr}, util::read_spv, @@ -54,7 +98,7 @@ pub fn main() { // Create shader module and pipelines for SpvFile { name, data } in shaders { - ctx.insert_shader_module(name, data); + ctx.insert_shader_module(name, &data); } ctx.build_pipelines( vk::PipelineCache::null(), @@ -88,7 +132,7 @@ pub fn main() { } Ok(new_shaders) => { for SpvFile { name, data } in new_shaders { - ctx.insert_shader_module(name, data); + ctx.insert_shader_module(name, &data); } ctx.recompiling_shaders = false; ctx.rebuild_pipelines(vk::PipelineCache::null()); @@ -261,7 +305,7 @@ impl RenderBase { .get_physical_device_queue_family_properties(*pdevice) .iter() .enumerate() - .find_map(|(index, ref info)| { + .find_map(|(index, info)| { if info.queue_flags.contains(vk::QueueFlags::GRAPHICS) && surface_loader .get_physical_device_surface_support( @@ -326,7 +370,7 @@ impl RenderBase { } }; - RenderBase { + Self { window, entry, instance, @@ -578,7 +622,7 @@ impl RenderCtx { ) }; - RenderCtx { + Self { sync, base, swapchain, @@ -711,8 +755,8 @@ impl RenderCtx { /// Add a shader module to the hash map of shader modules. returns a handle to the module, and the /// old shader module if there was one with the same name already. Does not rebuild pipelines /// that may be using the shader module, nor does it invalidate them. - pub fn insert_shader_module(&mut self, name: String, spirv: Vec) { - let shader_info = vk::ShaderModuleCreateInfo::builder().code(&spirv); + pub fn insert_shader_module(&mut self, name: String, spirv: &[u32]) { + let shader_info = vk::ShaderModuleCreateInfo::builder().code(spirv); let shader_module = unsafe { self.base .device diff --git a/examples/runners/cpu/src/main.rs b/examples/runners/cpu/src/main.rs index 6a255f24f4..8ed96018d5 100644 --- a/examples/runners/cpu/src/main.rs +++ b/examples/runners/cpu/src/main.rs @@ -1,3 +1,47 @@ +// standard Embark lints +#![deny(unsafe_code)] +#![warn( + clippy::all, + clippy::await_holding_lock, + clippy::dbg_macro, + clippy::debug_assert_with_mut_call, + clippy::doc_markdown, + clippy::empty_enum, + clippy::enum_glob_use, + clippy::exit, + clippy::explicit_into_iter_loop, + clippy::filter_map_next, + clippy::fn_params_excessive_bools, + clippy::if_let_mutex, + clippy::imprecise_flops, + clippy::inefficient_to_string, + clippy::let_unit_value, + clippy::linkedlist, + clippy::lossy_float_literal, + clippy::macro_use_imports, + clippy::map_flatten, + clippy::map_unwrap_or, + clippy::match_on_vec_items, + clippy::match_wildcard_for_single_variants, + clippy::mem_forget, + clippy::mismatched_target_os, + clippy::needless_borrow, + clippy::needless_continue, + clippy::option_option, + clippy::pub_enum_variant_names, + clippy::ref_option_ref, + clippy::rest_pat_in_fully_bound_structs, + clippy::string_to_string, + clippy::suboptimal_flops, + clippy::todo, + clippy::unnested_or_patterns, + clippy::unused_self, + clippy::verbose_file_reads, + future_incompatible, + nonstandard_style, + rust_2018_idioms +)] + use minifb::{Key, Window, WindowOptions}; use rayon::prelude::*; use shared::ShaderConstants; diff --git a/examples/runners/wgpu/src/graphics.rs b/examples/runners/wgpu/src/graphics.rs index 8075e2c255..e9c3636499 100644 --- a/examples/runners/wgpu/src/graphics.rs +++ b/examples/runners/wgpu/src/graphics.rs @@ -114,7 +114,7 @@ async fn run( let mut swap_chain = surface .as_ref() - .map(|surface| device.create_swap_chain(&surface, &sc_desc)); + .map(|surface| device.create_swap_chain(surface, &sc_desc)); let start = std::time::Instant::now(); diff --git a/examples/runners/wgpu/src/lib.rs b/examples/runners/wgpu/src/lib.rs index f489d7b1ed..4da9d7c7e7 100644 --- a/examples/runners/wgpu/src/lib.rs +++ b/examples/runners/wgpu/src/lib.rs @@ -1,3 +1,47 @@ +// standard Embark lints +//#![deny(unsafe_code)] // quite a bit of unsafe with wgpu still, would be nice to remove +#![warn( + clippy::all, + clippy::await_holding_lock, + clippy::dbg_macro, + clippy::debug_assert_with_mut_call, + clippy::doc_markdown, + clippy::empty_enum, + clippy::enum_glob_use, + clippy::exit, + clippy::explicit_into_iter_loop, + clippy::filter_map_next, + clippy::fn_params_excessive_bools, + clippy::if_let_mutex, + clippy::imprecise_flops, + clippy::inefficient_to_string, + clippy::let_unit_value, + clippy::linkedlist, + clippy::lossy_float_literal, + clippy::macro_use_imports, + clippy::map_flatten, + clippy::map_unwrap_or, + clippy::match_on_vec_items, + clippy::match_wildcard_for_single_variants, + clippy::mem_forget, + clippy::mismatched_target_os, + clippy::needless_borrow, + clippy::needless_continue, + clippy::option_option, + clippy::pub_enum_variant_names, + clippy::ref_option_ref, + clippy::rest_pat_in_fully_bound_structs, + clippy::string_to_string, + clippy::suboptimal_flops, + clippy::todo, + clippy::unnested_or_patterns, + clippy::unused_self, + clippy::verbose_file_reads, + future_incompatible, + nonstandard_style, + rust_2018_idioms +)] + use clap::Clap; use strum::{Display, EnumString};