Skip to content

Commit

Permalink
Use Embark standard lints v0.2 (#475)
Browse files Browse the repository at this point in the history
  • Loading branch information
repi authored Mar 8, 2021
1 parent d37b41c commit a990ed5
Show file tree
Hide file tree
Showing 13 changed files with 317 additions and 55 deletions.
4 changes: 0 additions & 4 deletions crates/rustc_codegen_spirv/src/decorations.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand Down
63 changes: 41 additions & 22 deletions crates/rustc_codegen_spirv/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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: <https://github.com/EmbarkStudios/rust-ecosystem/issues/59>
#![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;
Expand Down
2 changes: 1 addition & 1 deletion crates/rustc_codegen_spirv/src/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions crates/rustc_codegen_spirv/src/linker/specializer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
51 changes: 50 additions & 1 deletion crates/spirv-builder/src/lib.rs
Original file line number Diff line number Diff line change
@@ -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: <https://github.com/EmbarkStudios/rust-ecosystem/issues/59>
#![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;

Expand Down Expand Up @@ -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<PathBuf, SpirvBuilderError> {
Expand Down
49 changes: 49 additions & 0 deletions crates/spirv-std-macros/src/lib.rs
Original file line number Diff line number Diff line change
@@ -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: <https://github.com/EmbarkStudios/rust-ecosystem/issues/59>
#![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]
Expand Down
52 changes: 33 additions & 19 deletions crates/spirv-std/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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: <https://github.com/EmbarkStudios/rust-ecosystem/issues/59>
#![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]
Expand Down
1 change: 1 addition & 0 deletions crates/spirv-tools-sys/spirv-headers
Submodule spirv-headers added at 784573
1 change: 1 addition & 0 deletions crates/spirv-tools-sys/spirv-tools
Submodule spirv-tools added at 36494d
Loading

0 comments on commit a990ed5

Please sign in to comment.