diff --git a/src/lib.rs b/src/lib.rs index 35351664caf4..1a07ce9aa12b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -9,7 +9,7 @@ #![feature(is_some_with)] #![feature(nonzero_ops)] #![feature(local_key_cell_methods)] -#![warn(rust_2018_idioms)] +// Configure clippy and other lints #![allow( clippy::collapsible_else_if, clippy::collapsible_if, @@ -24,6 +24,7 @@ clippy::derive_hash_xor_eq, clippy::too_many_arguments )] +#![warn(rust_2018_idioms, clippy::cast_lossless)] extern crate rustc_apfloat; extern crate rustc_ast; diff --git a/src/shims/env.rs b/src/shims/env.rs index f0818e71b667..c1d39dc09286 100644 --- a/src/shims/env.rs +++ b/src/shims/env.rs @@ -202,7 +202,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx let env_block_ptr = this.read_pointer(env_block_op)?; let result = this.deallocate_ptr(env_block_ptr, None, MiriMemoryKind::Runtime.into()); // If the function succeeds, the return value is nonzero. - Ok(result.is_ok() as i32) + Ok(i32::from(result.is_ok())) } fn setenv( diff --git a/src/shims/tls.rs b/src/shims/tls.rs index 13af447f76c6..9d19160b84d6 100644 --- a/src/shims/tls.rs +++ b/src/shims/tls.rs @@ -73,7 +73,7 @@ impl<'tcx> TlsData<'tcx> { self.keys.try_insert(new_key, TlsEntry { data: Default::default(), dtor }).unwrap(); trace!("New TLS key allocated: {} with dtor {:?}", new_key, dtor); - if max_size.bits() < 128 && new_key >= (1u128 << max_size.bits() as u128) { + if max_size.bits() < 128 && new_key >= (1u128 << max_size.bits()) { throw_unsup_format!("we ran out of TLS key space"); } Ok(new_key) diff --git a/src/stacked_borrows/item.rs b/src/stacked_borrows/item.rs index ad1b9b075b40..709b27d191b2 100644 --- a/src/stacked_borrows/item.rs +++ b/src/stacked_borrows/item.rs @@ -22,7 +22,7 @@ impl Item { assert!(tag.0.get() <= TAG_MASK); let packed_tag = tag.0.get(); let packed_perm = perm.to_bits() << PERM_SHIFT; - let packed_protected = (protected as u64) << PROTECTED_SHIFT; + let packed_protected = u64::from(protected) << PROTECTED_SHIFT; let new = Self(packed_tag | packed_perm | packed_protected);