mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-14 16:36:55 +00:00
Turn on clippy for Rust and fix lints for non-generated code (#7575)
Co-authored-by: Casper Neo <cneo@google.com>
This commit is contained in:
@@ -116,7 +116,7 @@ impl<'fbb> FlatBufferBuilder<'fbb> {
|
||||
// memset only the part of the buffer that could be dirty:
|
||||
{
|
||||
let to_clear = self.owned_buf.len() - self.head;
|
||||
let ptr = (&mut self.owned_buf[self.head..]).as_mut_ptr();
|
||||
let ptr = self.owned_buf[self.head..].as_mut_ptr();
|
||||
// Safety:
|
||||
// Verified ptr is valid for `to_clear` above
|
||||
unsafe {
|
||||
@@ -150,7 +150,7 @@ impl<'fbb> FlatBufferBuilder<'fbb> {
|
||||
self.align(sz, P::alignment());
|
||||
self.make_space(sz);
|
||||
{
|
||||
let (dst, rest) = (&mut self.owned_buf[self.head..]).split_at_mut(sz);
|
||||
let (dst, rest) = self.owned_buf[self.head..].split_at_mut(sz);
|
||||
// Safety:
|
||||
// Called make_space above
|
||||
unsafe { x.push(dst, rest.len()) };
|
||||
@@ -605,7 +605,7 @@ impl<'fbb> FlatBufferBuilder<'fbb> {
|
||||
}
|
||||
// finally, zero out the old end data.
|
||||
{
|
||||
let ptr = (&mut self.owned_buf[..middle]).as_mut_ptr();
|
||||
let ptr = self.owned_buf[..middle].as_mut_ptr();
|
||||
// Safety:
|
||||
// ptr is byte aligned and of length middle
|
||||
unsafe {
|
||||
|
||||
@@ -179,10 +179,6 @@ pub unsafe fn read_scalar<T: EndianScalar>(s: &[u8]) -> T {
|
||||
|
||||
let mut mem = core::mem::MaybeUninit::<T::Scalar>::uninit();
|
||||
// Since [u8] has alignment 1, we copy it into T which may have higher alignment.
|
||||
core::ptr::copy_nonoverlapping(
|
||||
s.as_ptr(),
|
||||
mem.as_mut_ptr() as *mut u8,
|
||||
size,
|
||||
);
|
||||
core::ptr::copy_nonoverlapping(s.as_ptr(), mem.as_mut_ptr() as *mut u8, size);
|
||||
T::from_little_endian(mem.assume_init())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user