Skip to content

Commit

Permalink
Fix lints
Browse files Browse the repository at this point in the history
  • Loading branch information
udoprog committed Jun 14, 2024
1 parent 821c1fc commit e310957
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 11 deletions.
1 change: 0 additions & 1 deletion crates/rune-alloc/src/hashbrown/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7039,7 +7039,6 @@ mod test_map {
use std::collections::hash_map::DefaultHasher;
use std::ops::AddAssign;
use std::thread;
use std::usize;
use std::vec::Vec;
use std::{format, println};

Expand Down
8 changes: 6 additions & 2 deletions crates/rune-alloc/src/hashbrown/raw/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1082,7 +1082,9 @@ impl<T, A: Allocator> RawTable<T, A> {
&|cx, table, index| hasher.hash(cx, table.bucket::<T>(index).as_ref()),
Self::TABLE_LAYOUT,
if T::NEEDS_DROP {
Some(mem::transmute(ptr::drop_in_place::<T> as unsafe fn(*mut T)))
Some(mem::transmute::<unsafe fn(*mut T), fn(*mut u8)>(
ptr::drop_in_place::<T> as unsafe fn(*mut T),
))
} else {
None
},
Expand Down Expand Up @@ -4009,7 +4011,9 @@ mod test_map {
&move |cx, table, index| hasher(cx, table.bucket::<T>(index).as_ref()),
mem::size_of::<T>(),
if mem::needs_drop::<T>() {
Some(mem::transmute(ptr::drop_in_place::<T> as unsafe fn(*mut T)))
Some(mem::transmute::<unsafe fn(*mut T), fn(*mut u8)>(
ptr::drop_in_place::<T> as unsafe fn(*mut T),
))
} else {
None
},
Expand Down
5 changes: 4 additions & 1 deletion crates/rune/src/runtime/shared.rs
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,10 @@ impl<T: ?Sized> SharedBox<T> {
// has already been taken (as indicated by `is_taken`).
//
// If it has been taken, the shared box contains invalid memory.
drop(transmute::<_, Box<SharedBox<ManuallyDrop<T>>>>(this));
drop(transmute::<
Box<SharedBox<T>>,
Box<SharedBox<ManuallyDrop<T>>>,
>(this));
} else {
// NB: At the point of the final drop, no on else should be using
// this.
Expand Down
8 changes: 4 additions & 4 deletions crates/rune/src/workspace/spanned_value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -454,11 +454,11 @@ impl<'de> de::Deserialize<'de> for Value {
where
E: de::Error,
{
if value <= i64::max_value() as u64 {
Ok(Value::Integer(value as i64))
} else {
Err(de::Error::custom("u64 value was too large"))
if let Ok(value) = i64::try_from(value) {
return Ok(Value::Integer(value));
}

Err(de::Error::custom("u64 value was too large"))
}

fn visit_u32<E>(self, value: u32) -> Result<Value, E> {
Expand Down
4 changes: 1 addition & 3 deletions examples/examples/checked_add_assign.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,7 @@ fn main() -> rune::support::Result<()> {

let mut vm = Vm::new(runtime, Arc::new(unit));

let input = External {
value: i64::max_value(),
};
let input = External { value: i64::MAX };
let err = vm.call(["main"], (input,)).unwrap_err();
println!("{:?}", err);
Ok(())
Expand Down
1 change: 1 addition & 0 deletions examples/examples/hot_reloading/path_reloader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ pub enum EventKind {
/// A path update event.
pub struct Event {
/// The path that was modified.
#[allow(unused)]
pub path: PathBuf,
/// The unit that was constructed from the path.
pub unit: Arc<Unit>,
Expand Down

0 comments on commit e310957

Please sign in to comment.