Skip to content

Commit 877514f

Browse files
committed
glib: Silence a new clippy warning that requires Rust 1.65
error: casting the result of `from_raw_parts` to *const [u8] --> glib/src/variant_type.rs:140:16 | 140 | &*(slice::from_raw_parts(self.ptr.as_ptr() as *const u8, self.len) as *const [u8] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `core::ptr::slice_from_raw_parts(self.ptr.as_ptr() as *const u8, self.len)` | = note: `-D clippy::cast-slice-from-raw-parts` implied by `-D warnings` = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#cast_slice_from_raw_parts error: casting the result of `from_raw_parts` to *const [u8] --> glib/src/variant_type.rs:456:12 | 456 | &*(slice::from_raw_parts(ptr as *const u8, len) as *const [u8] as *const VariantTy) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `core::ptr::slice_from_raw_parts(ptr as *const u8, len)` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#cast_slice_from_raw_parts
1 parent daa7779 commit 877514f

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

glib/src/variant_type.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,8 @@ impl Clone for VariantType {
135135

136136
impl Deref for VariantType {
137137
type Target = VariantTy;
138+
139+
#[allow(clippy::cast_slice_from_raw_parts)]
138140
fn deref(&self) -> &VariantTy {
139141
unsafe {
140142
&*(slice::from_raw_parts(self.ptr.as_ptr() as *const u8, self.len) as *const [u8]
@@ -449,6 +451,7 @@ impl VariantTy {
449451
/// Creates `&VariantTy` with a wildcard lifetime from a `GVariantType`
450452
/// pointer.
451453
#[doc(hidden)]
454+
#[allow(clippy::cast_slice_from_raw_parts)]
452455
pub unsafe fn from_ptr<'a>(ptr: *const ffi::GVariantType) -> &'a VariantTy {
453456
assert!(!ptr.is_null());
454457
let len = ffi::g_variant_type_get_string_length(ptr) as usize;

0 commit comments

Comments
 (0)