about summary refs log tree commit diff
path: root/compiler/rustc_codegen_cranelift/example
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2022-07-10 06:26:03 +0000
committerbors <bors@rust-lang.org>2022-07-10 06:26:03 +0000
commit95e77648e466c780a9adce2fa3d3eb5e423dc04e (patch)
tree762773e1168956c00981deb80267e49fb2195ea1 /compiler/rustc_codegen_cranelift/example
parent100142b258e570a2c8fbd713eecc77a8fe6c0435 (diff)
parent0753fd117bebe14306823432f6a195d32aab85d3 (diff)
downloadrust-95e77648e466c780a9adce2fa3d3eb5e423dc04e.tar.gz
rust-95e77648e466c780a9adce2fa3d3eb5e423dc04e.zip
Auto merge of #97522 - xfix:stabilize-slice-from-raw-parts, r=dtolnay
Partially stabilize const_slice_from_raw_parts

This doesn't stabilize methods working on mutable pointers.

This pull request continues from #94946.

Pinging `@rust-lang/wg-const-eval` this because I use `rustc_allow_const_fn_unstable`. I believe this is justifiable as it's already possible to use `slice::from_raw_parts` in stable by abusing `transmute`. The stable alternative to this would be to provide a stable const implementation of `std::ptr::from_raw_parts` (as it can already be implemented in stable).

```rust
use std::mem;

#[repr(C)]
struct Slice<T> {
    data: *const T,
    len: usize,
}

fn main() {
    let data: *const i32 = [1, 2, 3, 4].as_ptr();
    let len = 4;
    println!("{:?}", unsafe {
        mem::transmute::<Slice<i32>, &[i32]>(Slice { data, len })
    });
}
```

`@rustbot` modify labels: +T-libs-api
Diffstat (limited to 'compiler/rustc_codegen_cranelift/example')
-rw-r--r--compiler/rustc_codegen_cranelift/example/issue-91827-extern-types.rs1
1 files changed, 0 insertions, 1 deletions
diff --git a/compiler/rustc_codegen_cranelift/example/issue-91827-extern-types.rs b/compiler/rustc_codegen_cranelift/example/issue-91827-extern-types.rs
index cf8fada5320..2ecc8b8238b 100644
--- a/compiler/rustc_codegen_cranelift/example/issue-91827-extern-types.rs
+++ b/compiler/rustc_codegen_cranelift/example/issue-91827-extern-types.rs
@@ -6,7 +6,6 @@
 // Regression test for issue #91827.
 
 #![feature(const_ptr_offset_from)]
-#![feature(const_slice_from_raw_parts)]
 #![feature(extern_types)]
 
 use std::ptr::addr_of;