Skip to content

Commit a255b47

Browse files
committed
rust: alloc: drain: Fix build with rust 1.87
Signed-off-by: Janne Grunau <j@jannau.net>
1 parent 1ec786c commit a255b47

2 files changed

Lines changed: 4 additions & 0 deletions

File tree

rust/kernel/alloc/drain.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,10 @@ impl<T, A: Allocator> Drop for Drain<'_, T, A> {
236236
// it from the original vec but also avoid creating a &mut to the front since that could
237237
// invalidate raw pointers to it which some unsafe code might rely on.
238238
let vec_ptr = vec.as_mut().as_mut_ptr();
239+
#[cfg(not(version("1.87")))]
239240
let drop_offset = drop_ptr.sub_ptr(vec_ptr);
241+
#[cfg(version("1.87"))]
242+
let drop_offset = drop_ptr.offset_from_unsigned(vec_ptr);
240243
let to_drop = ptr::slice_from_raw_parts_mut(vec_ptr.add(drop_offset), drop_len);
241244
ptr::drop_in_place(to_drop);
242245
}

rust/kernel/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#![no_std]
1515
#![feature(arbitrary_self_types)]
1616
#![feature(associated_type_defaults)]
17+
#![feature(cfg_version)]
1718
#![cfg_attr(CONFIG_RUSTC_HAS_COERCE_POINTEE, feature(derive_coerce_pointee))]
1819
#![cfg_attr(CONFIG_RUSTC_HAS_COERCE_POINTEE, feature(pin_coerce_unsized_trait))]
1920
#![cfg_attr(not(CONFIG_RUSTC_HAS_COERCE_POINTEE), feature(coerce_unsized))]

0 commit comments

Comments
 (0)