diff --git a/cranelift/src/compile.rs b/cranelift/src/compile.rs index 50b21faf15..9903dd6161 100644 --- a/cranelift/src/compile.rs +++ b/cranelift/src/compile.rs @@ -111,9 +111,7 @@ fn handle_module( .compile(isa) .map_err(|err| pretty_error(&context.func, Some(isa), err))?; - let mut mem = Vec::new(); - mem.resize(total_size as usize, 0); - + let mut mem = vec![0; total_size as usize]; let mut relocs = PrintRelocs { flag_print }; let mut traps = PrintTraps { flag_print }; let mut code_sink: binemit::MemoryCodeSink; diff --git a/cranelift/src/wasm.rs b/cranelift/src/wasm.rs index 00574f6259..af8e818697 100644 --- a/cranelift/src/wasm.rs +++ b/cranelift/src/wasm.rs @@ -4,7 +4,7 @@ //! Reads Wasm binary/text files, translates the functions' code to Cranelift IR. #![cfg_attr( feature = "cargo-clippy", - allow(too_many_arguments, cyclomatic_complexity) + allow(clippy::too_many_arguments, clippy::cyclomatic_complexity) )] use crate::utils::{parse_sets_and_triple, read_to_end}; diff --git a/lib/bforest/src/lib.rs b/lib/bforest/src/lib.rs index ee9213b00a..e78292600e 100644 --- a/lib/bforest/src/lib.rs +++ b/lib/bforest/src/lib.rs @@ -17,10 +17,7 @@ #![warn(unused_import_braces)] #![cfg_attr(feature = "std", warn(unstable_features))] #![cfg_attr(feature = "clippy", plugin(clippy(conf_file = "../../clippy.toml")))] -#![cfg_attr( - feature = "cargo-clippy", - allow(new_without_default, new_without_default_derive) -)] +#![cfg_attr(feature = "cargo-clippy", allow(clippy::new_without_default))] #![cfg_attr( feature = "cargo-clippy", warn( diff --git a/lib/bforest/src/map.rs b/lib/bforest/src/map.rs index a809282833..313b870f49 100644 --- a/lib/bforest/src/map.rs +++ b/lib/bforest/src/map.rs @@ -284,7 +284,7 @@ where /// /// If the cursor reaches the end, return `None` and leave the cursor at the off-the-end /// position. - #[cfg_attr(feature = "cargo-clippy", allow(should_implement_trait))] + #[cfg_attr(feature = "cargo-clippy", allow(clippy::should_implement_trait))] pub fn next(&mut self) -> Option<(K, V)> { self.path.next(self.pool) } diff --git a/lib/bforest/src/pool.rs b/lib/bforest/src/pool.rs index cec5e40a7d..0eb873ccab 100644 --- a/lib/bforest/src/pool.rs +++ b/lib/bforest/src/pool.rs @@ -63,7 +63,7 @@ impl NodePool { pub fn free_tree(&mut self, node: Node) { if let NodeData::Inner { size, tree, .. } = self[node] { // Note that we have to capture `tree` by value to avoid borrow checker trouble. - #[cfg_attr(feature = "cargo-clippy", allow(needless_range_loop))] + #[cfg_attr(feature = "cargo-clippy", allow(clippy::needless_range_loop))] for i in 0..usize::from(size + 1) { // Recursively free sub-trees. This recursion can never be deeper than `MAX_PATH`, // and since most trees have less than a handful of nodes, it is worthwhile to diff --git a/lib/bforest/src/set.rs b/lib/bforest/src/set.rs index 0ca5d92457..e73171d368 100644 --- a/lib/bforest/src/set.rs +++ b/lib/bforest/src/set.rs @@ -225,7 +225,7 @@ where /// /// If the cursor reaches the end, return `None` and leave the cursor at the off-the-end /// position. - #[cfg_attr(feature = "cargo-clippy", allow(should_implement_trait))] + #[cfg_attr(feature = "cargo-clippy", allow(clippy::should_implement_trait))] pub fn next(&mut self) -> Option { self.path.next(self.pool).map(|(k, _)| k) } diff --git a/lib/codegen/meta/src/constant_hash.rs b/lib/codegen/meta/src/constant_hash.rs index 84b5513d5a..7f629d0d8b 100644 --- a/lib/codegen/meta/src/constant_hash.rs +++ b/lib/codegen/meta/src/constant_hash.rs @@ -18,8 +18,7 @@ pub fn generate_table usize>(items: &Vec, hash_function: H) - size.next_power_of_two() }; - let mut table: Vec> = Vec::new(); - table.resize(size, None); + let mut table: Vec> = vec![None; size]; for i in items { let mut h = hash_function(i) % size; diff --git a/lib/codegen/meta/src/gen_settings.rs b/lib/codegen/meta/src/gen_settings.rs index 497c1cc2f1..bdcd206e13 100644 --- a/lib/codegen/meta/src/gen_settings.rs +++ b/lib/codegen/meta/src/gen_settings.rs @@ -355,8 +355,7 @@ fn gen_descriptors(group: &SettingGroup, fmt: &mut Formatter) { } fn gen_template(group: &SettingGroup, fmt: &mut Formatter) { - let mut default_bytes: Vec = Vec::new(); - default_bytes.resize(group.settings_size as usize, 0); + let mut default_bytes: Vec = vec![0; group.settings_size as usize]; for setting in &group.settings { *default_bytes.get_mut(setting.byte_offset as usize).unwrap() |= setting.default_byte(); } diff --git a/lib/codegen/src/binemit/memorysink.rs b/lib/codegen/src/binemit/memorysink.rs index 7f6c62f451..3d7d673719 100644 --- a/lib/codegen/src/binemit/memorysink.rs +++ b/lib/codegen/src/binemit/memorysink.rs @@ -89,7 +89,7 @@ impl<'a> CodeSink for MemoryCodeSink<'a> { fn put2(&mut self, x: u16) { unsafe { - #[cfg_attr(feature = "cargo-clippy", allow(cast_ptr_alignment))] + #[cfg_attr(feature = "cargo-clippy", allow(clippy::cast_ptr_alignment))] write_unaligned(self.data.offset(self.offset) as *mut u16, x); } self.offset += 2; @@ -97,7 +97,7 @@ impl<'a> CodeSink for MemoryCodeSink<'a> { fn put4(&mut self, x: u32) { unsafe { - #[cfg_attr(feature = "cargo-clippy", allow(cast_ptr_alignment))] + #[cfg_attr(feature = "cargo-clippy", allow(clippy::cast_ptr_alignment))] write_unaligned(self.data.offset(self.offset) as *mut u32, x); } self.offset += 4; @@ -105,7 +105,7 @@ impl<'a> CodeSink for MemoryCodeSink<'a> { fn put8(&mut self, x: u64) { unsafe { - #[cfg_attr(feature = "cargo-clippy", allow(cast_ptr_alignment))] + #[cfg_attr(feature = "cargo-clippy", allow(clippy::cast_ptr_alignment))] write_unaligned(self.data.offset(self.offset) as *mut u64, x); } self.offset += 8; diff --git a/lib/codegen/src/cursor.rs b/lib/codegen/src/cursor.rs index eae5fc0b1f..ba7bc92b13 100644 --- a/lib/codegen/src/cursor.rs +++ b/lib/codegen/src/cursor.rs @@ -751,7 +751,7 @@ impl<'c, 'f> ir::InstInserterBase<'c> for &'c mut EncCursor<'f> { } // Assign an encoding. // XXX Is there a way to describe this error to the user? - #[cfg_attr(feature = "cargo-clippy", allow(match_wild_err_arm))] + #[cfg_attr(feature = "cargo-clippy", allow(clippy::match_wild_err_arm))] match self .isa .encode(&self.func, &self.func.dfg[inst], ctrl_typevar) diff --git a/lib/codegen/src/dce.rs b/lib/codegen/src/dce.rs index d42c36870e..0aa9adc15b 100644 --- a/lib/codegen/src/dce.rs +++ b/lib/codegen/src/dce.rs @@ -9,7 +9,6 @@ use crate::entity::EntityRef; use crate::ir::instructions::InstructionData; use crate::ir::{DataFlowGraph, Function, Inst, Opcode}; use crate::timing; -use std::vec::Vec; /// Test whether the given opcode is unsafe to even consider for DCE. fn trivially_unsafe_for_dce(opcode: Opcode) -> bool { @@ -46,9 +45,7 @@ pub fn do_dce(func: &mut Function, domtree: &mut DominatorTree) { let _tt = timing::dce(); debug_assert!(domtree.is_valid()); - let mut live = Vec::with_capacity(func.dfg.num_values()); - live.resize(func.dfg.num_values(), false); - + let mut live = vec![false; func.dfg.num_values()]; for &ebb in domtree.cfg_postorder() { let mut pos = FuncCursor::new(func).at_bottom(ebb); while let Some(inst) = pos.prev_inst() { diff --git a/lib/codegen/src/divconst_magic_numbers.rs b/lib/codegen/src/divconst_magic_numbers.rs index 89c686498e..ebf1ae3f12 100644 --- a/lib/codegen/src/divconst_magic_numbers.rs +++ b/lib/codegen/src/divconst_magic_numbers.rs @@ -221,7 +221,7 @@ mod tests { use super::{magic_s32, magic_s64, magic_u32, magic_u64}; use super::{MS32, MS64, MU32, MU64}; - fn mkMU32(mul_by: u32, do_add: bool, shift_by: i32) -> MU32 { + fn make_mu32(mul_by: u32, do_add: bool, shift_by: i32) -> MU32 { MU32 { mul_by, do_add, @@ -229,7 +229,7 @@ mod tests { } } - fn mkMU64(mul_by: u64, do_add: bool, shift_by: i32) -> MU64 { + fn make_mu64(mul_by: u64, do_add: bool, shift_by: i32) -> MU64 { MU64 { mul_by, do_add, @@ -237,237 +237,282 @@ mod tests { } } - fn mkMS32(mul_by: i32, shift_by: i32) -> MS32 { + fn make_ms32(mul_by: i32, shift_by: i32) -> MS32 { MS32 { mul_by, shift_by } } - fn mkMS64(mul_by: i64, shift_by: i32) -> MS64 { + fn make_ms64(mul_by: i64, shift_by: i32) -> MS64 { MS64 { mul_by, shift_by } } #[test] fn test_magicU32() { - assert_eq!(magic_u32(2u32), mkMU32(0x80000000u32, false, 0)); - assert_eq!(magic_u32(3u32), mkMU32(0xaaaaaaabu32, false, 1)); - assert_eq!(magic_u32(4u32), mkMU32(0x40000000u32, false, 0)); - assert_eq!(magic_u32(5u32), mkMU32(0xcccccccdu32, false, 2)); - assert_eq!(magic_u32(6u32), mkMU32(0xaaaaaaabu32, false, 2)); - assert_eq!(magic_u32(7u32), mkMU32(0x24924925u32, true, 3)); - assert_eq!(magic_u32(9u32), mkMU32(0x38e38e39u32, false, 1)); - assert_eq!(magic_u32(10u32), mkMU32(0xcccccccdu32, false, 3)); - assert_eq!(magic_u32(11u32), mkMU32(0xba2e8ba3u32, false, 3)); - assert_eq!(magic_u32(12u32), mkMU32(0xaaaaaaabu32, false, 3)); - assert_eq!(magic_u32(25u32), mkMU32(0x51eb851fu32, false, 3)); - assert_eq!(magic_u32(125u32), mkMU32(0x10624dd3u32, false, 3)); - assert_eq!(magic_u32(625u32), mkMU32(0xd1b71759u32, false, 9)); - assert_eq!(magic_u32(1337u32), mkMU32(0x88233b2bu32, true, 11)); - assert_eq!(magic_u32(65535u32), mkMU32(0x80008001u32, false, 15)); - assert_eq!(magic_u32(65536u32), mkMU32(0x00010000u32, false, 0)); - assert_eq!(magic_u32(65537u32), mkMU32(0xffff0001u32, false, 16)); - assert_eq!(magic_u32(31415927u32), mkMU32(0x445b4553u32, false, 23)); - assert_eq!(magic_u32(0xdeadbeefu32), mkMU32(0x93275ab3u32, false, 31)); - assert_eq!(magic_u32(0xfffffffdu32), mkMU32(0x40000001u32, false, 30)); - assert_eq!(magic_u32(0xfffffffeu32), mkMU32(0x00000003u32, true, 32)); - assert_eq!(magic_u32(0xffffffffu32), mkMU32(0x80000001u32, false, 31)); + assert_eq!(magic_u32(2u32), make_mu32(0x80000000u32, false, 0)); + assert_eq!(magic_u32(3u32), make_mu32(0xaaaaaaabu32, false, 1)); + assert_eq!(magic_u32(4u32), make_mu32(0x40000000u32, false, 0)); + assert_eq!(magic_u32(5u32), make_mu32(0xcccccccdu32, false, 2)); + assert_eq!(magic_u32(6u32), make_mu32(0xaaaaaaabu32, false, 2)); + assert_eq!(magic_u32(7u32), make_mu32(0x24924925u32, true, 3)); + assert_eq!(magic_u32(9u32), make_mu32(0x38e38e39u32, false, 1)); + assert_eq!(magic_u32(10u32), make_mu32(0xcccccccdu32, false, 3)); + assert_eq!(magic_u32(11u32), make_mu32(0xba2e8ba3u32, false, 3)); + assert_eq!(magic_u32(12u32), make_mu32(0xaaaaaaabu32, false, 3)); + assert_eq!(magic_u32(25u32), make_mu32(0x51eb851fu32, false, 3)); + assert_eq!(magic_u32(125u32), make_mu32(0x10624dd3u32, false, 3)); + assert_eq!(magic_u32(625u32), make_mu32(0xd1b71759u32, false, 9)); + assert_eq!(magic_u32(1337u32), make_mu32(0x88233b2bu32, true, 11)); + assert_eq!(magic_u32(65535u32), make_mu32(0x80008001u32, false, 15)); + assert_eq!(magic_u32(65536u32), make_mu32(0x00010000u32, false, 0)); + assert_eq!(magic_u32(65537u32), make_mu32(0xffff0001u32, false, 16)); + assert_eq!(magic_u32(31415927u32), make_mu32(0x445b4553u32, false, 23)); + assert_eq!( + magic_u32(0xdeadbeefu32), + make_mu32(0x93275ab3u32, false, 31) + ); + assert_eq!( + magic_u32(0xfffffffdu32), + make_mu32(0x40000001u32, false, 30) + ); + assert_eq!(magic_u32(0xfffffffeu32), make_mu32(0x00000003u32, true, 32)); + assert_eq!( + magic_u32(0xffffffffu32), + make_mu32(0x80000001u32, false, 31) + ); } #[test] fn test_magicU64() { - assert_eq!(magic_u64(2u64), mkMU64(0x8000000000000000u64, false, 0)); - assert_eq!(magic_u64(3u64), mkMU64(0xaaaaaaaaaaaaaaabu64, false, 1)); - assert_eq!(magic_u64(4u64), mkMU64(0x4000000000000000u64, false, 0)); - assert_eq!(magic_u64(5u64), mkMU64(0xcccccccccccccccdu64, false, 2)); - assert_eq!(magic_u64(6u64), mkMU64(0xaaaaaaaaaaaaaaabu64, false, 2)); - assert_eq!(magic_u64(7u64), mkMU64(0x2492492492492493u64, true, 3)); - assert_eq!(magic_u64(9u64), mkMU64(0xe38e38e38e38e38fu64, false, 3)); - assert_eq!(magic_u64(10u64), mkMU64(0xcccccccccccccccdu64, false, 3)); - assert_eq!(magic_u64(11u64), mkMU64(0x2e8ba2e8ba2e8ba3u64, false, 1)); - assert_eq!(magic_u64(12u64), mkMU64(0xaaaaaaaaaaaaaaabu64, false, 3)); - assert_eq!(magic_u64(25u64), mkMU64(0x47ae147ae147ae15u64, true, 5)); - assert_eq!(magic_u64(125u64), mkMU64(0x0624dd2f1a9fbe77u64, true, 7)); - assert_eq!(magic_u64(625u64), mkMU64(0x346dc5d63886594bu64, false, 7)); - assert_eq!(magic_u64(1337u64), mkMU64(0xc4119d952866a139u64, false, 10)); + assert_eq!(magic_u64(2u64), make_mu64(0x8000000000000000u64, false, 0)); + assert_eq!(magic_u64(3u64), make_mu64(0xaaaaaaaaaaaaaaabu64, false, 1)); + assert_eq!(magic_u64(4u64), make_mu64(0x4000000000000000u64, false, 0)); + assert_eq!(magic_u64(5u64), make_mu64(0xcccccccccccccccdu64, false, 2)); + assert_eq!(magic_u64(6u64), make_mu64(0xaaaaaaaaaaaaaaabu64, false, 2)); + assert_eq!(magic_u64(7u64), make_mu64(0x2492492492492493u64, true, 3)); + assert_eq!(magic_u64(9u64), make_mu64(0xe38e38e38e38e38fu64, false, 3)); + assert_eq!(magic_u64(10u64), make_mu64(0xcccccccccccccccdu64, false, 3)); + assert_eq!(magic_u64(11u64), make_mu64(0x2e8ba2e8ba2e8ba3u64, false, 1)); + assert_eq!(magic_u64(12u64), make_mu64(0xaaaaaaaaaaaaaaabu64, false, 3)); + assert_eq!(magic_u64(25u64), make_mu64(0x47ae147ae147ae15u64, true, 5)); + assert_eq!(magic_u64(125u64), make_mu64(0x0624dd2f1a9fbe77u64, true, 7)); + assert_eq!( + magic_u64(625u64), + make_mu64(0x346dc5d63886594bu64, false, 7) + ); + assert_eq!( + magic_u64(1337u64), + make_mu64(0xc4119d952866a139u64, false, 10) + ); assert_eq!( magic_u64(31415927u64), - mkMU64(0x116d154b9c3d2f85u64, true, 25) + make_mu64(0x116d154b9c3d2f85u64, true, 25) ); assert_eq!( magic_u64(0x00000000deadbeefu64), - mkMU64(0x93275ab2dfc9094bu64, false, 31) + make_mu64(0x93275ab2dfc9094bu64, false, 31) ); assert_eq!( magic_u64(0x00000000fffffffdu64), - mkMU64(0x8000000180000005u64, false, 31) + make_mu64(0x8000000180000005u64, false, 31) ); assert_eq!( magic_u64(0x00000000fffffffeu64), - mkMU64(0x0000000200000005u64, true, 32) + make_mu64(0x0000000200000005u64, true, 32) ); assert_eq!( magic_u64(0x00000000ffffffffu64), - mkMU64(0x8000000080000001u64, false, 31) + make_mu64(0x8000000080000001u64, false, 31) ); assert_eq!( magic_u64(0x0000000100000000u64), - mkMU64(0x0000000100000000u64, false, 0) + make_mu64(0x0000000100000000u64, false, 0) ); assert_eq!( magic_u64(0x0000000100000001u64), - mkMU64(0xffffffff00000001u64, false, 32) + make_mu64(0xffffffff00000001u64, false, 32) ); assert_eq!( magic_u64(0x0ddc0ffeebadf00du64), - mkMU64(0x2788e9d394b77da1u64, true, 60) + make_mu64(0x2788e9d394b77da1u64, true, 60) ); assert_eq!( magic_u64(0xfffffffffffffffdu64), - mkMU64(0x4000000000000001u64, false, 62) + make_mu64(0x4000000000000001u64, false, 62) ); assert_eq!( magic_u64(0xfffffffffffffffeu64), - mkMU64(0x0000000000000003u64, true, 64) + make_mu64(0x0000000000000003u64, true, 64) ); assert_eq!( magic_u64(0xffffffffffffffffu64), - mkMU64(0x8000000000000001u64, false, 63) + make_mu64(0x8000000000000001u64, false, 63) ); } #[test] fn test_magicS32() { - assert_eq!(magic_s32(-0x80000000i32), mkMS32(0x7fffffffu32 as i32, 30)); - assert_eq!(magic_s32(-0x7FFFFFFFi32), mkMS32(0xbfffffffu32 as i32, 29)); - assert_eq!(magic_s32(-0x7FFFFFFEi32), mkMS32(0x7ffffffdu32 as i32, 30)); - assert_eq!(magic_s32(-31415927i32), mkMS32(0xbba4baadu32 as i32, 23)); - assert_eq!(magic_s32(-1337i32), mkMS32(0x9df73135u32 as i32, 9)); - assert_eq!(magic_s32(-256i32), mkMS32(0x7fffffffu32 as i32, 7)); - assert_eq!(magic_s32(-5i32), mkMS32(0x99999999u32 as i32, 1)); - assert_eq!(magic_s32(-3i32), mkMS32(0x55555555u32 as i32, 1)); - assert_eq!(magic_s32(-2i32), mkMS32(0x7fffffffu32 as i32, 0)); - assert_eq!(magic_s32(2i32), mkMS32(0x80000001u32 as i32, 0)); - assert_eq!(magic_s32(3i32), mkMS32(0x55555556u32 as i32, 0)); - assert_eq!(magic_s32(4i32), mkMS32(0x80000001u32 as i32, 1)); - assert_eq!(magic_s32(5i32), mkMS32(0x66666667u32 as i32, 1)); - assert_eq!(magic_s32(6i32), mkMS32(0x2aaaaaabu32 as i32, 0)); - assert_eq!(magic_s32(7i32), mkMS32(0x92492493u32 as i32, 2)); - assert_eq!(magic_s32(9i32), mkMS32(0x38e38e39u32 as i32, 1)); - assert_eq!(magic_s32(10i32), mkMS32(0x66666667u32 as i32, 2)); - assert_eq!(magic_s32(11i32), mkMS32(0x2e8ba2e9u32 as i32, 1)); - assert_eq!(magic_s32(12i32), mkMS32(0x2aaaaaabu32 as i32, 1)); - assert_eq!(magic_s32(25i32), mkMS32(0x51eb851fu32 as i32, 3)); - assert_eq!(magic_s32(125i32), mkMS32(0x10624dd3u32 as i32, 3)); - assert_eq!(magic_s32(625i32), mkMS32(0x68db8badu32 as i32, 8)); - assert_eq!(magic_s32(1337i32), mkMS32(0x6208cecbu32 as i32, 9)); - assert_eq!(magic_s32(31415927i32), mkMS32(0x445b4553u32 as i32, 23)); - assert_eq!(magic_s32(0x7ffffffei32), mkMS32(0x80000003u32 as i32, 30)); - assert_eq!(magic_s32(0x7fffffffi32), mkMS32(0x40000001u32 as i32, 29)); + assert_eq!( + magic_s32(-0x80000000i32), + make_ms32(0x7fffffffu32 as i32, 30) + ); + assert_eq!( + magic_s32(-0x7FFFFFFFi32), + make_ms32(0xbfffffffu32 as i32, 29) + ); + assert_eq!( + magic_s32(-0x7FFFFFFEi32), + make_ms32(0x7ffffffdu32 as i32, 30) + ); + assert_eq!(magic_s32(-31415927i32), make_ms32(0xbba4baadu32 as i32, 23)); + assert_eq!(magic_s32(-1337i32), make_ms32(0x9df73135u32 as i32, 9)); + assert_eq!(magic_s32(-256i32), make_ms32(0x7fffffffu32 as i32, 7)); + assert_eq!(magic_s32(-5i32), make_ms32(0x99999999u32 as i32, 1)); + assert_eq!(magic_s32(-3i32), make_ms32(0x55555555u32 as i32, 1)); + assert_eq!(magic_s32(-2i32), make_ms32(0x7fffffffu32 as i32, 0)); + assert_eq!(magic_s32(2i32), make_ms32(0x80000001u32 as i32, 0)); + assert_eq!(magic_s32(3i32), make_ms32(0x55555556u32 as i32, 0)); + assert_eq!(magic_s32(4i32), make_ms32(0x80000001u32 as i32, 1)); + assert_eq!(magic_s32(5i32), make_ms32(0x66666667u32 as i32, 1)); + assert_eq!(magic_s32(6i32), make_ms32(0x2aaaaaabu32 as i32, 0)); + assert_eq!(magic_s32(7i32), make_ms32(0x92492493u32 as i32, 2)); + assert_eq!(magic_s32(9i32), make_ms32(0x38e38e39u32 as i32, 1)); + assert_eq!(magic_s32(10i32), make_ms32(0x66666667u32 as i32, 2)); + assert_eq!(magic_s32(11i32), make_ms32(0x2e8ba2e9u32 as i32, 1)); + assert_eq!(magic_s32(12i32), make_ms32(0x2aaaaaabu32 as i32, 1)); + assert_eq!(magic_s32(25i32), make_ms32(0x51eb851fu32 as i32, 3)); + assert_eq!(magic_s32(125i32), make_ms32(0x10624dd3u32 as i32, 3)); + assert_eq!(magic_s32(625i32), make_ms32(0x68db8badu32 as i32, 8)); + assert_eq!(magic_s32(1337i32), make_ms32(0x6208cecbu32 as i32, 9)); + assert_eq!(magic_s32(31415927i32), make_ms32(0x445b4553u32 as i32, 23)); + assert_eq!( + magic_s32(0x7ffffffei32), + make_ms32(0x80000003u32 as i32, 30) + ); + assert_eq!( + magic_s32(0x7fffffffi32), + make_ms32(0x40000001u32 as i32, 29) + ); } #[test] fn test_magicS64() { assert_eq!( magic_s64(-0x8000000000000000i64), - mkMS64(0x7fffffffffffffffu64 as i64, 62) + make_ms64(0x7fffffffffffffffu64 as i64, 62) ); assert_eq!( magic_s64(-0x7FFFFFFFFFFFFFFFi64), - mkMS64(0xbfffffffffffffffu64 as i64, 61) + make_ms64(0xbfffffffffffffffu64 as i64, 61) ); assert_eq!( magic_s64(-0x7FFFFFFFFFFFFFFEi64), - mkMS64(0x7ffffffffffffffdu64 as i64, 62) + make_ms64(0x7ffffffffffffffdu64 as i64, 62) ); assert_eq!( magic_s64(-0x0ddC0ffeeBadF00di64), - mkMS64(0x6c3b8b1635a4412fu64 as i64, 59) + make_ms64(0x6c3b8b1635a4412fu64 as i64, 59) ); assert_eq!( magic_s64(-0x100000001i64), - mkMS64(0x800000007fffffffu64 as i64, 31) + make_ms64(0x800000007fffffffu64 as i64, 31) ); assert_eq!( magic_s64(-0x100000000i64), - mkMS64(0x7fffffffffffffffu64 as i64, 31) + make_ms64(0x7fffffffffffffffu64 as i64, 31) ); assert_eq!( magic_s64(-0xFFFFFFFFi64), - mkMS64(0x7fffffff7fffffffu64 as i64, 31) + make_ms64(0x7fffffff7fffffffu64 as i64, 31) ); assert_eq!( magic_s64(-0xFFFFFFFEi64), - mkMS64(0x7ffffffefffffffdu64 as i64, 31) + make_ms64(0x7ffffffefffffffdu64 as i64, 31) ); assert_eq!( magic_s64(-0xFFFFFFFDi64), - mkMS64(0x7ffffffe7ffffffbu64 as i64, 31) + make_ms64(0x7ffffffe7ffffffbu64 as i64, 31) ); assert_eq!( magic_s64(-0xDeadBeefi64), - mkMS64(0x6cd8a54d2036f6b5u64 as i64, 31) + make_ms64(0x6cd8a54d2036f6b5u64 as i64, 31) ); assert_eq!( magic_s64(-31415927i64), - mkMS64(0x7749755a31e1683du64 as i64, 24) + make_ms64(0x7749755a31e1683du64 as i64, 24) + ); + assert_eq!( + magic_s64(-1337i64), + make_ms64(0x9df731356bccaf63u64 as i64, 9) + ); + assert_eq!( + magic_s64(-256i64), + make_ms64(0x7fffffffffffffffu64 as i64, 7) + ); + assert_eq!(magic_s64(-5i64), make_ms64(0x9999999999999999u64 as i64, 1)); + assert_eq!(magic_s64(-3i64), make_ms64(0x5555555555555555u64 as i64, 1)); + assert_eq!(magic_s64(-2i64), make_ms64(0x7fffffffffffffffu64 as i64, 0)); + assert_eq!(magic_s64(2i64), make_ms64(0x8000000000000001u64 as i64, 0)); + assert_eq!(magic_s64(3i64), make_ms64(0x5555555555555556u64 as i64, 0)); + assert_eq!(magic_s64(4i64), make_ms64(0x8000000000000001u64 as i64, 1)); + assert_eq!(magic_s64(5i64), make_ms64(0x6666666666666667u64 as i64, 1)); + assert_eq!(magic_s64(6i64), make_ms64(0x2aaaaaaaaaaaaaabu64 as i64, 0)); + assert_eq!(magic_s64(7i64), make_ms64(0x4924924924924925u64 as i64, 1)); + assert_eq!(magic_s64(9i64), make_ms64(0x1c71c71c71c71c72u64 as i64, 0)); + assert_eq!(magic_s64(10i64), make_ms64(0x6666666666666667u64 as i64, 2)); + assert_eq!(magic_s64(11i64), make_ms64(0x2e8ba2e8ba2e8ba3u64 as i64, 1)); + assert_eq!(magic_s64(12i64), make_ms64(0x2aaaaaaaaaaaaaabu64 as i64, 1)); + assert_eq!(magic_s64(25i64), make_ms64(0xa3d70a3d70a3d70bu64 as i64, 4)); + assert_eq!( + magic_s64(125i64), + make_ms64(0x20c49ba5e353f7cfu64 as i64, 4) + ); + assert_eq!( + magic_s64(625i64), + make_ms64(0x346dc5d63886594bu64 as i64, 7) + ); + assert_eq!( + magic_s64(1337i64), + make_ms64(0x6208ceca9433509du64 as i64, 9) ); - assert_eq!(magic_s64(-1337i64), mkMS64(0x9df731356bccaf63u64 as i64, 9)); - assert_eq!(magic_s64(-256i64), mkMS64(0x7fffffffffffffffu64 as i64, 7)); - assert_eq!(magic_s64(-5i64), mkMS64(0x9999999999999999u64 as i64, 1)); - assert_eq!(magic_s64(-3i64), mkMS64(0x5555555555555555u64 as i64, 1)); - assert_eq!(magic_s64(-2i64), mkMS64(0x7fffffffffffffffu64 as i64, 0)); - assert_eq!(magic_s64(2i64), mkMS64(0x8000000000000001u64 as i64, 0)); - assert_eq!(magic_s64(3i64), mkMS64(0x5555555555555556u64 as i64, 0)); - assert_eq!(magic_s64(4i64), mkMS64(0x8000000000000001u64 as i64, 1)); - assert_eq!(magic_s64(5i64), mkMS64(0x6666666666666667u64 as i64, 1)); - assert_eq!(magic_s64(6i64), mkMS64(0x2aaaaaaaaaaaaaabu64 as i64, 0)); - assert_eq!(magic_s64(7i64), mkMS64(0x4924924924924925u64 as i64, 1)); - assert_eq!(magic_s64(9i64), mkMS64(0x1c71c71c71c71c72u64 as i64, 0)); - assert_eq!(magic_s64(10i64), mkMS64(0x6666666666666667u64 as i64, 2)); - assert_eq!(magic_s64(11i64), mkMS64(0x2e8ba2e8ba2e8ba3u64 as i64, 1)); - assert_eq!(magic_s64(12i64), mkMS64(0x2aaaaaaaaaaaaaabu64 as i64, 1)); - assert_eq!(magic_s64(25i64), mkMS64(0xa3d70a3d70a3d70bu64 as i64, 4)); - assert_eq!(magic_s64(125i64), mkMS64(0x20c49ba5e353f7cfu64 as i64, 4)); - assert_eq!(magic_s64(625i64), mkMS64(0x346dc5d63886594bu64 as i64, 7)); - assert_eq!(magic_s64(1337i64), mkMS64(0x6208ceca9433509du64 as i64, 9)); assert_eq!( magic_s64(31415927i64), - mkMS64(0x88b68aa5ce1e97c3u64 as i64, 24) + make_ms64(0x88b68aa5ce1e97c3u64 as i64, 24) ); assert_eq!( magic_s64(0x00000000deadbeefi64), - mkMS64(0x93275ab2dfc9094bu64 as i64, 31) + make_ms64(0x93275ab2dfc9094bu64 as i64, 31) ); assert_eq!( magic_s64(0x00000000fffffffdi64), - mkMS64(0x8000000180000005u64 as i64, 31) + make_ms64(0x8000000180000005u64 as i64, 31) ); assert_eq!( magic_s64(0x00000000fffffffei64), - mkMS64(0x8000000100000003u64 as i64, 31) + make_ms64(0x8000000100000003u64 as i64, 31) ); assert_eq!( magic_s64(0x00000000ffffffffi64), - mkMS64(0x8000000080000001u64 as i64, 31) + make_ms64(0x8000000080000001u64 as i64, 31) ); assert_eq!( magic_s64(0x0000000100000000i64), - mkMS64(0x8000000000000001u64 as i64, 31) + make_ms64(0x8000000000000001u64 as i64, 31) ); assert_eq!( magic_s64(0x0000000100000001i64), - mkMS64(0x7fffffff80000001u64 as i64, 31) + make_ms64(0x7fffffff80000001u64 as i64, 31) ); assert_eq!( magic_s64(0x0ddc0ffeebadf00di64), - mkMS64(0x93c474e9ca5bbed1u64 as i64, 59) + make_ms64(0x93c474e9ca5bbed1u64 as i64, 59) ); assert_eq!( magic_s64(0x7ffffffffffffffdi64), - mkMS64(0x2000000000000001u64 as i64, 60) + make_ms64(0x2000000000000001u64 as i64, 60) ); assert_eq!( magic_s64(0x7ffffffffffffffei64), - mkMS64(0x8000000000000003u64 as i64, 62) + make_ms64(0x8000000000000003u64 as i64, 62) ); assert_eq!( magic_s64(0x7fffffffffffffffi64), - mkMS64(0x4000000000000001u64 as i64, 61) + make_ms64(0x4000000000000001u64 as i64, 61) ); } #[test] diff --git a/lib/codegen/src/ir/globalvalue.rs b/lib/codegen/src/ir/globalvalue.rs index aedfa1dfc8..6c7d8032f6 100644 --- a/lib/codegen/src/ir/globalvalue.rs +++ b/lib/codegen/src/ir/globalvalue.rs @@ -27,7 +27,8 @@ pub enum GlobalValueData { /// Type of the loaded value. global_type: Type, - /// Specifies whether the memory that this refers to is readonly, allowing for the elimination of redundant loads. + /// Specifies whether the memory that this refers to is readonly, allowing for the + /// elimination of redundant loads. readonly: bool, }, diff --git a/lib/codegen/src/ir/instructions.rs b/lib/codegen/src/ir/instructions.rs index f0ac7c24c1..4f9cf5125e 100644 --- a/lib/codegen/src/ir/instructions.rs +++ b/lib/codegen/src/ir/instructions.rs @@ -335,8 +335,8 @@ pub struct OpcodeConstraints { typeset_offset: u8, /// Offset into `OPERAND_CONSTRAINT` table of the descriptors for this opcode. The first - /// `num_fixed_results()` entries describe the result constraints, then follows constraints for the - /// fixed `Value` input operands. (`num_fixed_value_arguments()` of them). + /// `num_fixed_results()` entries describe the result constraints, then follows constraints for + /// the fixed `Value` input operands. (`num_fixed_value_arguments()` of them). constraint_offset: u16, } diff --git a/lib/codegen/src/legalizer/heap.rs b/lib/codegen/src/legalizer/heap.rs index 41d9778421..8ffd02ec5f 100644 --- a/lib/codegen/src/legalizer/heap.rs +++ b/lib/codegen/src/legalizer/heap.rs @@ -117,7 +117,7 @@ fn static_addr( } // Check `offset > limit` which is now known non-negative. - let limit = bound - u64::from(access_size); + let limit = bound - access_size; // We may be able to omit the check entirely for 32-bit offsets if the heap bound is 4 GB or // more. diff --git a/lib/codegen/src/lib.rs b/lib/codegen/src/lib.rs index 737aca4140..eb61f62f09 100644 --- a/lib/codegen/src/lib.rs +++ b/lib/codegen/src/lib.rs @@ -6,27 +6,27 @@ #![cfg_attr(feature = "clippy", plugin(clippy(conf_file = "../../clippy.toml")))] #![cfg_attr(feature="cargo-clippy", allow( // Produces only a false positive: - while_let_loop, + clippy::while_let_loop, // Produces many false positives, but did produce some valid lints, now fixed: - needless_lifetimes, + clippy::needless_lifetimes, // Generated code makes some style transgressions, but readability doesn't suffer much: - many_single_char_names, - identity_op, - needless_borrow, - cast_lossless, - unreadable_literal, - assign_op_pattern, - empty_line_after_outer_attr, + clippy::many_single_char_names, + clippy::identity_op, + clippy::needless_borrow, + clippy::cast_lossless, + clippy::unreadable_literal, + clippy::assign_op_pattern, + clippy::empty_line_after_outer_attr, // Hard to avoid in generated code: - cyclomatic_complexity, - too_many_arguments, + clippy::cyclomatic_complexity, + clippy::too_many_arguments, // Code generator doesn't have a way to collapse identical arms: - match_same_arms, + clippy::match_same_arms, // These are relatively minor style issues, but would be easy to fix: - new_without_default, - new_without_default_derive, - should_implement_trait, - len_without_is_empty))] + clippy::new_without_default, + clippy::new_without_default_derive, + clippy::should_implement_trait, + clippy::len_without_is_empty))] #![cfg_attr( feature = "cargo-clippy", warn( diff --git a/lib/codegen/src/licm.rs b/lib/codegen/src/licm.rs index 101eb47d36..cb3dbd87a9 100644 --- a/lib/codegen/src/licm.rs +++ b/lib/codegen/src/licm.rs @@ -191,7 +191,7 @@ fn remove_loop_invariant_instructions( loop_values.insert(*val); } pos.goto_top(*ebb); - #[cfg_attr(feature = "cargo-clippy", allow(block_in_if_condition_stmt))] + #[cfg_attr(feature = "cargo-clippy", allow(clippy::block_in_if_condition_stmt))] while let Some(inst) = pos.next_inst() { if is_loop_invariant(inst, &pos.func.dfg, &loop_values) { // If all the instruction's argument are defined outside the loop diff --git a/lib/codegen/src/regalloc/solver.rs b/lib/codegen/src/regalloc/solver.rs index 0b433a4587..ceb6cdfb4b 100644 --- a/lib/codegen/src/regalloc/solver.rs +++ b/lib/codegen/src/regalloc/solver.rs @@ -295,7 +295,7 @@ impl Move { } /// Get the "from" register and register class, if possible. - #[cfg_attr(feature = "cargo-clippy", allow(wrong_self_convention))] + #[cfg_attr(feature = "cargo-clippy", allow(clippy::wrong_self_convention))] fn from_reg(&self) -> Option<(RegClass, RegUnit)> { match *self { Move::Reg { rc, from, .. } | Move::Spill { rc, from, .. } => Some((rc, from)), diff --git a/lib/codegen/src/regalloc/virtregs.rs b/lib/codegen/src/regalloc/virtregs.rs index deb3b5f20b..3fe55474de 100644 --- a/lib/codegen/src/regalloc/virtregs.rs +++ b/lib/codegen/src/regalloc/virtregs.rs @@ -97,7 +97,7 @@ impl VirtRegs { /// /// If `value` belongs to a virtual register, the congruence class is the values of the virtual /// register. Otherwise it is just the value itself. - #[cfg_attr(feature = "cargo-clippy", allow(trivially_copy_pass_by_ref))] + #[cfg_attr(feature = "cargo-clippy", allow(clippy::trivially_copy_pass_by_ref))] pub fn congruence_class<'a, 'b>(&'a self, value: &'b Value) -> &'b [Value] where 'a: 'b, diff --git a/lib/entity/src/lib.rs b/lib/entity/src/lib.rs index cde226690b..ce34c1e50f 100644 --- a/lib/entity/src/lib.rs +++ b/lib/entity/src/lib.rs @@ -15,9 +15,9 @@ //! //! - [`PrimaryMap`](struct.PrimaryMap.html) is used to keep track of a vector of entities, //! assigning a unique entity reference to each. -//! - [`SecondaryMap`](struct.SecondaryMap.html) is used to associate secondary information to an entity. -//! The map is implemented as a simple vector, so it does not keep track of which entities have -//! been inserted. Instead, any unknown entities map to the default value. +//! - [`SecondaryMap`](struct.SecondaryMap.html) is used to associate secondary information to an +//! entity. The map is implemented as a simple vector, so it does not keep track of which +//! entities have been inserted. Instead, any unknown entities map to the default value. //! - [`SparseMap`](struct.SparseMap.html) is used to associate secondary information to a small //! number of entities. It tracks accurately which entities have been inserted. This is a //! specialized data structure which can use a lot of memory, so read the documentation before @@ -35,7 +35,7 @@ #![cfg_attr(feature = "clippy", plugin(clippy(conf_file = "../../clippy.toml")))] #![cfg_attr( feature = "cargo-clippy", - allow(new_without_default, new_without_default_derive) + allow(clippy::new_without_default, clippy::new_without_default_derive) )] #![cfg_attr( feature = "cargo-clippy", diff --git a/lib/entity/src/map.rs b/lib/entity/src/map.rs index 47e40d0a74..e0f331106b 100644 --- a/lib/entity/src/map.rs +++ b/lib/entity/src/map.rs @@ -11,8 +11,8 @@ use std::vec::Vec; /// A mapping `K -> V` for densely indexed entity references. /// /// The `SecondaryMap` data structure uses the dense index space to implement a map with a vector. -/// Unlike `PrimaryMap`, an `SecondaryMap` can't be used to allocate entity references. It is used to -/// associate secondary information with entities. +/// Unlike `PrimaryMap`, an `SecondaryMap` can't be used to allocate entity references. It is used +/// to associate secondary information with entities. /// /// The map does not track if an entry for a key has been inserted or not. Instead it behaves as if /// all keys have a default entry from the beginning. diff --git a/lib/entity/src/sparse.rs b/lib/entity/src/sparse.rs index a07dc589b1..a6a43db5e0 100644 --- a/lib/entity/src/sparse.rs +++ b/lib/entity/src/sparse.rs @@ -37,19 +37,20 @@ pub trait SparseMapValue { /// /// # Compared to `SecondaryMap` /// -/// When should we use a `SparseMap` instead of a secondary `SecondaryMap`? First of all, `SparseMap` -/// does not provide the functionality of a `PrimaryMap` which can allocate and assign entity -/// references to objects as they are pushed onto the map. It is only the secondary entity maps -/// that can be replaced with a `SparseMap`. +/// When should we use a `SparseMap` instead of a secondary `SecondaryMap`? First of all, +/// `SparseMap` does not provide the functionality of a `PrimaryMap` which can allocate and assign +/// entity references to objects as they are pushed onto the map. It is only the secondary entity +/// maps that can be replaced with a `SparseMap`. /// /// - A secondary entity map assigns a default mapping to all keys. It doesn't distinguish between /// an unmapped key and one that maps to the default value. `SparseMap` does not require /// `Default` values, and it tracks accurately if a key has been mapped or not. -/// - Iterating over the contents of an `SecondaryMap` is linear in the size of the *key space*, while -/// iterating over a `SparseMap` is linear in the number of elements in the mapping. This is an -/// advantage precisely when the mapping is sparse. -/// - `SparseMap::clear()` is constant time and super-fast. `SecondaryMap::clear()` is linear in the -/// size of the key space. (Or, rather the required `resize()` call following the `clear()` is). +/// - Iterating over the contents of an `SecondaryMap` is linear in the size of the *key space*, +/// while iterating over a `SparseMap` is linear in the number of elements in the mapping. This +/// is an advantage precisely when the mapping is sparse. +/// - `SparseMap::clear()` is constant time and super-fast. `SecondaryMap::clear()` is linear in +/// the size of the key space. (Or, rather the required `resize()` call following the `clear()` +/// is). /// - `SparseMap` requires the values to implement `SparseMapValue` which means that they must /// contain their own key. pub struct SparseMap diff --git a/lib/faerie/src/backend.rs b/lib/faerie/src/backend.rs index db1b13d596..699311441d 100644 --- a/lib/faerie/src/backend.rs +++ b/lib/faerie/src/backend.rs @@ -152,8 +152,7 @@ impl Backend for FaerieBackend { namespace: &ModuleNamespace, code_size: u32, ) -> ModuleResult { - let mut code: Vec = Vec::with_capacity(code_size as usize); - code.resize(code_size as usize, 0); + let mut code: Vec = vec![0; code_size as usize]; // Non-lexical lifetimes would obviate the braces here. { diff --git a/lib/faerie/src/lib.rs b/lib/faerie/src/lib.rs index 1f7167a8ce..096faf1148 100644 --- a/lib/faerie/src/lib.rs +++ b/lib/faerie/src/lib.rs @@ -12,7 +12,7 @@ #![cfg_attr(feature = "clippy", plugin(clippy(conf_file = "../../clippy.toml")))] #![cfg_attr( feature = "cargo-clippy", - allow(new_without_default, new_without_default_derive) + allow(clippy::new_without_default, clippy::new_without_default_derive) )] #![cfg_attr( feature = "cargo-clippy", diff --git a/lib/filetests/src/lib.rs b/lib/filetests/src/lib.rs index 084620e3a0..6284e945fa 100644 --- a/lib/filetests/src/lib.rs +++ b/lib/filetests/src/lib.rs @@ -10,7 +10,7 @@ unstable_features )] #![warn(unused_import_braces)] -#![cfg_attr(feature = "cargo-clippy", allow(type_complexity))] +#![cfg_attr(feature = "cargo-clippy", allow(clippy::type_complexity))] #![cfg_attr( feature = "cargo-clippy", warn( diff --git a/lib/frontend/src/frontend.rs b/lib/frontend/src/frontend.rs index 1d454661c9..8867f9ad69 100644 --- a/lib/frontend/src/frontend.rs +++ b/lib/frontend/src/frontend.rs @@ -546,7 +546,7 @@ impl<'a> FunctionBuilder<'a> { /// /// Useful for debug purposes. Use it with `None` for standard printing. // Clippy thinks the lifetime that follows is needless, but rustc needs it - #[cfg_attr(feature = "cargo-clippy", allow(needless_lifetimes))] + #[cfg_attr(feature = "cargo-clippy", allow(clippy::needless_lifetimes))] pub fn display<'b, I: Into>>(&'b self, isa: I) -> DisplayFunction { self.func.display(isa) } @@ -608,7 +608,7 @@ impl<'a> FunctionBuilder<'a> { "`size` is not a power of two" ); assert!( - access_size >= ::std::cmp::min(src_align, dest_align) as u64, + access_size >= u64::from(::std::cmp::min(src_align, dest_align)), "`size` is smaller than `dest` and `src`'s alignment value." ); @@ -689,7 +689,7 @@ impl<'a> FunctionBuilder<'a> { "`size` is not a power of two" ); assert!( - access_size >= buffer_align as u64, + access_size >= u64::from(buffer_align), "`size` is smaller than `dest` and `src`'s alignment value." ); @@ -702,14 +702,14 @@ impl<'a> FunctionBuilder<'a> { let load_and_store_amount = size / access_size; if load_and_store_amount > THRESHOLD { - let ch = self.ins().iconst(types::I32, ch as i64); + let ch = self.ins().iconst(types::I32, i64::from(ch)); let size = self.ins().iconst(config.pointer_type(), size as i64); self.call_memset(config, buffer, ch, size); } else { let mut flags = MemFlags::new(); flags.set_aligned(); - let ch = ch as u64; + let ch = u64::from(ch); let raw_value = if int_type == types::I64 { (ch << 32) | (ch << 16) | (ch << 8) | ch } else if int_type == types::I32 { @@ -777,7 +777,7 @@ impl<'a> FunctionBuilder<'a> { "`size` is not a power of two" ); assert!( - access_size >= ::std::cmp::min(src_align, dest_align) as u64, + access_size >= u64::from(::std::cmp::min(src_align, dest_align)), "`size` is smaller than `dest` and `src`'s alignment value." ); let load_and_store_amount = size / access_size; diff --git a/lib/frontend/src/lib.rs b/lib/frontend/src/lib.rs index 3f8ec616cc..0eb2b47692 100644 --- a/lib/frontend/src/lib.rs +++ b/lib/frontend/src/lib.rs @@ -160,7 +160,7 @@ #![deny(missing_docs, trivial_numeric_casts, unused_extern_crates)] #![warn(unused_import_braces)] #![cfg_attr(feature = "std", deny(unstable_features))] -#![cfg_attr(feature = "cargo-clippy", allow(new_without_default))] +#![cfg_attr(feature = "cargo-clippy", allow(clippy::new_without_default))] #![cfg_attr( feature = "cargo-clippy", warn( diff --git a/lib/module/src/lib.rs b/lib/module/src/lib.rs index bd6ca28c8a..a62a6d2e65 100644 --- a/lib/module/src/lib.rs +++ b/lib/module/src/lib.rs @@ -4,10 +4,7 @@ #![warn(unused_import_braces)] #![cfg_attr(feature = "std", deny(unstable_features))] #![cfg_attr(feature = "clippy", plugin(clippy(conf_file = "../../clippy.toml")))] -#![cfg_attr( - feature = "cargo-clippy", - allow(new_without_default, new_without_default_derive) -)] +#![cfg_attr(feature = "cargo-clippy", allow(clippy::new_without_default))] #![cfg_attr( feature = "cargo-clippy", warn( diff --git a/lib/native/src/lib.rs b/lib/native/src/lib.rs index 24650ca28c..a780405288 100644 --- a/lib/native/src/lib.rs +++ b/lib/native/src/lib.rs @@ -9,10 +9,7 @@ )] #![warn(unused_import_braces)] #![cfg_attr(feature = "clippy", plugin(clippy(conf_file = "../../clippy.toml")))] -#![cfg_attr( - feature = "cargo-clippy", - allow(new_without_default, new_without_default_derive) -)] +#![cfg_attr(feature = "cargo-clippy", allow(clippy::new_without_default))] #![cfg_attr( feature = "cargo-clippy", warn( diff --git a/lib/preopt/src/lib.rs b/lib/preopt/src/lib.rs index 321b7a58b6..b93e914cb2 100644 --- a/lib/preopt/src/lib.rs +++ b/lib/preopt/src/lib.rs @@ -4,10 +4,7 @@ #![warn(unused_import_braces)] #![cfg_attr(feature = "std", deny(unstable_features))] #![cfg_attr(feature = "clippy", plugin(clippy(conf_file = "../../clippy.toml")))] -#![cfg_attr( - feature = "cargo-clippy", - allow(new_without_default, new_without_default_derive) -)] +#![cfg_attr(feature = "cargo-clippy", allow(clippy::new_without_default))] #![cfg_attr( feature = "cargo-clippy", warn( diff --git a/lib/reader/src/lib.rs b/lib/reader/src/lib.rs index d2e6a96e8b..803c17c62d 100644 --- a/lib/reader/src/lib.rs +++ b/lib/reader/src/lib.rs @@ -11,10 +11,7 @@ )] #![warn(unused_import_braces)] #![cfg_attr(feature = "clippy", plugin(clippy(conf_file = "../../clippy.toml")))] -#![cfg_attr( - feature = "cargo-clippy", - allow(new_without_default, new_without_default_derive) -)] +#![cfg_attr(feature = "cargo-clippy", allow(clippy::new_without_default))] #![cfg_attr( feature = "cargo-clippy", warn( diff --git a/lib/reader/src/parser.rs b/lib/reader/src/parser.rs index 7503805bb6..3aefb575f3 100644 --- a/lib/reader/src/parser.rs +++ b/lib/reader/src/parser.rs @@ -51,7 +51,8 @@ pub fn parse_test<'a>( let isa_spec: isaspec::IsaSpec; let commands: Vec>; - // Check for specified passes and target, if present throw out test commands/targets specified in file. + // Check for specified passes and target, if present throw out test commands/targets specified + // in file. match passes { Some(pass_vec) => { parser.parse_test_commands(); @@ -338,7 +339,7 @@ impl<'a> Parser<'a> { // clippy says self.lookahead is immutable so this loop is either infinite or never // running. I don't think this is true - self.lookahead is mutated in the loop body - so // maybe this is a clippy bug? Either way, disable clippy for this. - #[cfg_attr(feature = "cargo-clippy", allow(while_immutable_condition))] + #[cfg_attr(feature = "cargo-clippy", allow(clippy::while_immutable_condition))] while self.lookahead == None { match self.lex.next() { Some(Ok(LocatedToken { token, location })) => { diff --git a/lib/serde/src/clif-json.rs b/lib/serde/src/clif-json.rs index 9253d08d1c..34f97cc971 100644 --- a/lib/serde/src/clif-json.rs +++ b/lib/serde/src/clif-json.rs @@ -8,10 +8,7 @@ )] #![warn(unused_import_braces)] #![cfg_attr(feature = "clippy", plugin(clippy(conf_file = "../../clippy.toml")))] -#![cfg_attr( - feature = "cargo-clippy", - allow(new_without_default, new_without_default_derive) -)] +#![cfg_attr(feature = "cargo-clippy", allow(clippy::new_without_default))] #![cfg_attr( feature = "cargo-clippy", warn( diff --git a/lib/simplejit/src/backend.rs b/lib/simplejit/src/backend.rs index b7582c9c7b..8dc3ee09d0 100644 --- a/lib/simplejit/src/backend.rs +++ b/lib/simplejit/src/backend.rs @@ -326,13 +326,13 @@ impl<'simple_jit_backend> Backend for SimpleJITBackend { match reloc { Reloc::Abs4 => { // TODO: Handle overflow. - #[cfg_attr(feature = "cargo-clippy", allow(cast_ptr_alignment))] + #[cfg_attr(feature = "cargo-clippy", allow(clippy::cast_ptr_alignment))] unsafe { write_unaligned(at as *mut u32, what as u32) }; } Reloc::Abs8 => { - #[cfg_attr(feature = "cargo-clippy", allow(cast_ptr_alignment))] + #[cfg_attr(feature = "cargo-clippy", allow(clippy::cast_ptr_alignment))] unsafe { write_unaligned(at as *mut u64, what as u64) }; @@ -340,7 +340,7 @@ impl<'simple_jit_backend> Backend for SimpleJITBackend { Reloc::X86PCRel4 | Reloc::X86CallPCRel4 => { // TODO: Handle overflow. let pcrel = ((what as isize) - (at as isize)) as i32; - #[cfg_attr(feature = "cargo-clippy", allow(cast_ptr_alignment))] + #[cfg_attr(feature = "cargo-clippy", allow(clippy::cast_ptr_alignment))] unsafe { write_unaligned(at as *mut i32, pcrel) }; @@ -391,13 +391,13 @@ impl<'simple_jit_backend> Backend for SimpleJITBackend { match reloc { Reloc::Abs4 => { // TODO: Handle overflow. - #[cfg_attr(feature = "cargo-clippy", allow(cast_ptr_alignment))] + #[cfg_attr(feature = "cargo-clippy", allow(clippy::cast_ptr_alignment))] unsafe { write_unaligned(at as *mut u32, what as u32) }; } Reloc::Abs8 => { - #[cfg_attr(feature = "cargo-clippy", allow(cast_ptr_alignment))] + #[cfg_attr(feature = "cargo-clippy", allow(clippy::cast_ptr_alignment))] unsafe { write_unaligned(at as *mut u64, what as u64) }; diff --git a/lib/simplejit/src/lib.rs b/lib/simplejit/src/lib.rs index eabeb7ac0f..57fc809b08 100644 --- a/lib/simplejit/src/lib.rs +++ b/lib/simplejit/src/lib.rs @@ -8,10 +8,7 @@ )] #![warn(unused_import_braces)] #![cfg_attr(feature = "clippy", plugin(clippy(conf_file = "../../clippy.toml")))] -#![cfg_attr( - feature = "cargo-clippy", - allow(new_without_default, new_without_default_derive) -)] +#![cfg_attr(feature = "cargo-clippy", allow(clippy::new_without_default))] #![cfg_attr( feature = "cargo-clippy", warn( diff --git a/lib/umbrella/src/lib.rs b/lib/umbrella/src/lib.rs index c14134e4f4..90927323a5 100644 --- a/lib/umbrella/src/lib.rs +++ b/lib/umbrella/src/lib.rs @@ -8,10 +8,7 @@ )] #![warn(unused_import_braces)] #![cfg_attr(feature = "clippy", plugin(clippy(conf_file = "../../clippy.toml")))] -#![cfg_attr( - feature = "cargo-clippy", - allow(new_without_default, new_without_default_derive) -)] +#![cfg_attr(feature = "cargo-clippy", allow(clippy::new_without_default))] #![cfg_attr( feature = "cargo-clippy", warn( diff --git a/lib/wasm/src/code_translator.rs b/lib/wasm/src/code_translator.rs index a7b61fc580..f956efab31 100644 --- a/lib/wasm/src/code_translator.rs +++ b/lib/wasm/src/code_translator.rs @@ -37,7 +37,7 @@ use std::{i32, u32}; use wasmparser::{MemoryImmediate, Operator}; // Clippy warns about "flags: _" but its important to document that the flags field is ignored -#[cfg_attr(feature = "cargo-clippy", allow(unneeded_field_pattern))] +#[cfg_attr(feature = "cargo-clippy", allow(clippy::unneeded_field_pattern))] /// Translates wasm operators into Cranelift IR instructions. Returns `true` if it inserted /// a return. pub fn translate_operator( @@ -894,7 +894,7 @@ pub fn translate_operator( } // Clippy warns us of some fields we are deliberately ignoring -#[cfg_attr(feature = "cargo-clippy", allow(unneeded_field_pattern))] +#[cfg_attr(feature = "cargo-clippy", allow(clippy::unneeded_field_pattern))] /// Deals with a Wasm instruction located in an unreachable portion of the code. Most of them /// are dropped but special ones like `End` or `Else` signal the potential end of the unreachable /// portion so the translation state must be updated accordingly. diff --git a/lib/wasm/src/environ/dummy.rs b/lib/wasm/src/environ/dummy.rs index 081244ca49..b52b5bfc1d 100644 --- a/lib/wasm/src/environ/dummy.rs +++ b/lib/wasm/src/environ/dummy.rs @@ -187,7 +187,7 @@ impl<'dummy_environment> FuncEnvironment for DummyFuncEnvironment<'dummy_environ let vmctx = func.create_global_value(ir::GlobalValueData::VMContext {}); GlobalVariable::Memory { gv: vmctx, - offset: offset, + offset, ty: self.mod_info.globals[index].entity.ty, } } diff --git a/lib/wasm/src/environ/spec.rs b/lib/wasm/src/environ/spec.rs index 27249c1234..f79152f5be 100644 --- a/lib/wasm/src/environ/spec.rs +++ b/lib/wasm/src/environ/spec.rs @@ -164,7 +164,7 @@ pub trait FuncEnvironment { /// The signature `sig_ref` was previously created by `make_indirect_sig()`. /// /// Return the call instruction whose results are the WebAssembly return values. - #[cfg_attr(feature = "cargo-clippy", allow(too_many_arguments))] + #[cfg_attr(feature = "cargo-clippy", allow(clippy::too_many_arguments))] fn translate_call_indirect( &mut self, pos: FuncCursor, diff --git a/lib/wasm/src/lib.rs b/lib/wasm/src/lib.rs index 2b75ce9e4c..854fb65dce 100644 --- a/lib/wasm/src/lib.rs +++ b/lib/wasm/src/lib.rs @@ -13,10 +13,7 @@ #![warn(unused_import_braces)] #![cfg_attr(feature = "std", deny(unstable_features))] #![cfg_attr(feature = "clippy", plugin(clippy(conf_file = "../../clippy.toml")))] -#![cfg_attr( - feature = "cargo-clippy", - allow(new_without_default, new_without_default_derive) -)] +#![cfg_attr(feature = "cargo-clippy", allow(clippy::new_without_default))] #![cfg_attr( feature = "cargo-clippy", warn(