-
Notifications
You must be signed in to change notification settings - Fork 115
/
Copy pathrustc-1.19.0-src.patch
30 lines (26 loc) · 983 Bytes
/
rustc-1.19.0-src.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
--- src/libcore/intrinsics.rs
+++ src/libcore/intrinsics.rs
@@ -691,6 +691,10 @@ extern "rust-intrinsic" {
pub fn size_of_val<T: ?Sized>(_: &T) -> usize;
pub fn min_align_of_val<T: ?Sized>(_: &T) -> usize;
+ /// Obtain the length of a slice pointer
+ #[cfg(rust_compiler="mrustc")]
+ pub fn mrustc_slice_len<T>(pointer: *const [T]) -> usize;
+
/// Gets a static string slice containing the name of a type.
pub fn type_name<T: ?Sized>() -> &'static str;
--- src/libcore/slice/mod.rs
+++ src/libcore/slice/mod.rs
@@ -412,9 +412,11 @@ impl<T> SliceExt for [T] {
#[inline]
fn len(&self) -> usize {
- unsafe {
- mem::transmute::<&[T], Repr<T>>(self).len
- }
+ #[cfg(not(rust_compiler="mrustc"))]
+ let rv = unsafe { mem::transmute::<&[T], Repr<T>>(self).len };
+ #[cfg(rust_compiler="mrustc")]
+ let rv = unsafe { ::intrinsics::mrustc_slice_len(self) };
+ rv
}
#[inline]