From 1f2c1576afc74a3ae2bf873e06d6163bfc88a673 Mon Sep 17 00:00:00 2001 From: Johan Andersson Date: Sat, 11 Jun 2022 14:26:35 +0200 Subject: [PATCH] Upgrade to Embark standard lints v6 https://github.com/EmbarkStudios/rust-ecosystem/issues/59 --- .cargo/config.toml | 79 ++++++++++++++++++++++++++++++++++++++++++++++ src/lib.rs | 69 +++++----------------------------------- sys/build.rs | 2 +- sys/src/lib.rs | 55 -------------------------------- 4 files changed, 88 insertions(+), 117 deletions(-) create mode 100644 .cargo/config.toml diff --git a/.cargo/config.toml b/.cargo/config.toml new file mode 100644 index 0000000..5a6be99 --- /dev/null +++ b/.cargo/config.toml @@ -0,0 +1,79 @@ +[target.'cfg(all())'] +rustflags = [ + # BEGIN - Embark standard lints v6 for Rust 1.55+ + # do not change or add/remove here, but one can add exceptions after this section + # for more info see: + "-Dunsafe_code", + "-Wclippy::all", + "-Wclippy::await_holding_lock", + "-Wclippy::char_lit_as_u8", + "-Wclippy::checked_conversions", + "-Wclippy::dbg_macro", + "-Wclippy::debug_assert_with_mut_call", + "-Wclippy::doc_markdown", + "-Wclippy::empty_enum", + "-Wclippy::enum_glob_use", + "-Wclippy::exit", + "-Wclippy::expl_impl_clone_on_copy", + "-Wclippy::explicit_deref_methods", + "-Wclippy::explicit_into_iter_loop", + "-Wclippy::fallible_impl_from", + "-Wclippy::filter_map_next", + "-Wclippy::flat_map_option", + "-Wclippy::float_cmp_const", + "-Wclippy::fn_params_excessive_bools", + "-Wclippy::from_iter_instead_of_collect", + "-Wclippy::if_let_mutex", + "-Wclippy::implicit_clone", + "-Wclippy::imprecise_flops", + "-Wclippy::inefficient_to_string", + "-Wclippy::invalid_upcast_comparisons", + "-Wclippy::large_digit_groups", + "-Wclippy::large_stack_arrays", + "-Wclippy::large_types_passed_by_value", + "-Wclippy::let_unit_value", + "-Wclippy::linkedlist", + "-Wclippy::lossy_float_literal", + "-Wclippy::macro_use_imports", + "-Wclippy::manual_ok_or", + "-Wclippy::map_err_ignore", + "-Wclippy::map_flatten", + "-Wclippy::map_unwrap_or", + "-Wclippy::match_on_vec_items", + "-Wclippy::match_same_arms", + "-Wclippy::match_wild_err_arm", + "-Wclippy::match_wildcard_for_single_variants", + "-Wclippy::mem_forget", + "-Wclippy::mismatched_target_os", + "-Wclippy::missing_enforced_import_renames", + "-Wclippy::mut_mut", + "-Wclippy::mutex_integer", + "-Wclippy::needless_borrow", + "-Wclippy::needless_continue", + "-Wclippy::needless_for_each", + "-Wclippy::option_option", + "-Wclippy::path_buf_push_overwrite", + "-Wclippy::ptr_as_ptr", + "-Wclippy::rc_mutex", + "-Wclippy::ref_option_ref", + "-Wclippy::rest_pat_in_fully_bound_structs", + "-Wclippy::same_functions_in_if_condition", + "-Wclippy::semicolon_if_nothing_returned", + "-Wclippy::single_match_else", + "-Wclippy::string_add_assign", + "-Wclippy::string_add", + "-Wclippy::string_lit_as_bytes", + "-Wclippy::string_to_string", + "-Wclippy::todo", + "-Wclippy::trait_duplication_in_bounds", + "-Wclippy::unimplemented", + "-Wclippy::unnested_or_patterns", + "-Wclippy::unused_self", + "-Wclippy::useless_transmute", + "-Wclippy::verbose_file_reads", + "-Wclippy::zero_sized_map_values", + "-Wfuture_incompatible", + "-Wnonstandard_style", + "-Wrust_2018_idioms", + # END - Embark standard lints v6 for Rust 1.55+ +] \ No newline at end of file diff --git a/src/lib.rs b/src/lib.rs index 0854d9a..8b53b09 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -27,59 +27,6 @@ //! //! - `enable` - this flag is used by default and enables calling the Superluminal Performance API. This can be useful to only enable the events only for specific application features -// BEGIN - Embark standard lints v0.3 -// 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::large_types_passed_by_value, - clippy::let_unit_value, - clippy::linkedlist, - clippy::lossy_float_literal, - clippy::macro_use_imports, - clippy::map_err_ignore, - clippy::map_flatten, - clippy::map_unwrap_or, - clippy::match_on_vec_items, - clippy::match_same_arms, - 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_add_assign, - clippy::string_add, - clippy::string_to_string, - clippy::suboptimal_flops, - clippy::todo, - clippy::unimplemented, - clippy::unnested_or_patterns, - clippy::unused_self, - clippy::verbose_file_reads, - future_incompatible, - nonstandard_style, - rust_2018_idioms -)] -// END - Embark standard lints v0.3 -// crate-specific exceptions: #![allow(unused_variables)] #![allow(unsafe_code)] @@ -99,12 +46,12 @@ pub fn begin_event(id: &str) { #[cfg(all(feature = "enable", target_os = "windows"))] unsafe { ffi::PerformanceAPI_BeginEvent_N( - id.as_ptr() as *const i8, + id.as_ptr().cast::(), id.len() as u16, std::ptr::null(), 0, ffi::DEFAULT_COLOR, - ) + ); } } @@ -113,12 +60,12 @@ pub fn begin_event_with_color(id: &str, color: u32) { #[cfg(all(feature = "enable", target_os = "windows"))] unsafe { ffi::PerformanceAPI_BeginEvent_N( - id.as_ptr() as *const i8, + id.as_ptr().cast::(), id.len() as u16, std::ptr::null(), 0, color, - ) + ); } } @@ -129,12 +76,12 @@ pub fn begin_event_with_data(id: &str, data: &str, color: u32) { #[cfg(all(feature = "enable", target_os = "windows"))] unsafe { ffi::PerformanceAPI_BeginEvent_N( - id.as_ptr() as *const i8, + id.as_ptr().cast::(), id.len() as u16, - data.as_ptr() as *const i8, + data.as_ptr().cast::(), data.len() as u16, color, - ) + ); } } @@ -154,6 +101,6 @@ pub fn end_event() { pub fn set_current_thread_name(name: &str) { #[cfg(all(feature = "enable", target_os = "windows"))] unsafe { - ffi::PerformanceAPI_SetCurrentThreadName_N(name.as_ptr() as *const i8, name.len() as u16) + ffi::PerformanceAPI_SetCurrentThreadName_N(name.as_ptr().cast::(), name.len() as u16); } } diff --git a/sys/build.rs b/sys/build.rs index 0c02117..51ef774 100644 --- a/sys/build.rs +++ b/sys/build.rs @@ -14,5 +14,5 @@ fn main() { "cargo:rustc-link-search={}/external/lib/x64/", std::env!("CARGO_MANIFEST_DIR") ); - println!("cargo:rustc-link-lib=PerformanceAPI_{}", runtime()) + println!("cargo:rustc-link-lib=PerformanceAPI_{}", runtime()); } diff --git a/sys/src/lib.rs b/sys/src/lib.rs index 7e19091..25d41a8 100644 --- a/sys/src/lib.rs +++ b/sys/src/lib.rs @@ -1,58 +1,3 @@ -// BEGIN - Embark standard lints v0.3 -// 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::large_types_passed_by_value, - clippy::let_unit_value, - clippy::linkedlist, - clippy::lossy_float_literal, - clippy::macro_use_imports, - clippy::map_err_ignore, - clippy::map_flatten, - clippy::map_unwrap_or, - clippy::match_on_vec_items, - clippy::match_same_arms, - 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_add_assign, - clippy::string_add, - clippy::string_to_string, - clippy::suboptimal_flops, - clippy::todo, - clippy::unimplemented, - clippy::unnested_or_patterns, - clippy::unused_self, - clippy::verbose_file_reads, - future_incompatible, - nonstandard_style, - rust_2018_idioms -)] -// END - Embark standard lints v0.3 -// crate-specific exceptions: -#![allow()] - use std::os::raw::c_char; pub const DEFAULT_COLOR: u32 = 0xFF_FF_FF_FF;