-
Notifications
You must be signed in to change notification settings - Fork 246
Open
Labels
s: qptr may fixThis might be fixed by the "qptr" experiment (https://github.com/EmbarkStudios/spirt/pull/24)This might be fixed by the "qptr" experiment (https://github.com/EmbarkStudios/spirt/pull/24)t: enhancementA new feature or improvement to an existing one.A new feature or improvement to an existing one.
Description
When calling a function with a sub-slice of some other slice, the compiler throws a strange error:
Small example:
pub fn t1(main: &[f32]){
let a = t2(&main[10..13]);
}
fn t2(sub: &[f32]) -> u32{
1
}
throws
error: Cannot cast between pointer types
--> /.../rustup/toolchains/nightly-2021-08-27-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ptr/const_ptr.rs:49:6
|
49 | }
| ^
|
= note: from: *f32
= note: to: *struct () { }
error: Cannot cast between pointer types
--> /.../.rustup/toolchains/nightly-2021-08-27-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ptr/metadata.rs:117:14
|
117 | unsafe { PtrRepr { components: PtrComponents { data_address, metadata } }.const_ptr }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: from: *[u8; 8]
= note: to: *struct core::ptr::metadata::PtrComponents<[f32]> { *struct () { }, u32 }
error: Cannot cast between pointer types
--> /.../.rustup/toolchains/nightly-2021-08-27-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ptr/metadata.rs:117:14
|
117 | unsafe { PtrRepr { components: PtrComponents { data_address, metadata } }.const_ptr }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: from: *[u8; 8]
= note: to: *struct *const [f32] { *[f32], u32 }
error: Cannot offset a pointer to an arbitrary element
--> /.../.rustup/toolchains/nightly-2021-08-27-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ptr/const_ptr.rs:235:18
|
235 | unsafe { intrinsics::offset(self, count) }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
This is probably a similar problem like this, however, under different circumstances. If this is viewed as a duplicate, just close the Issue please.
Metadata
Metadata
Assignees
Labels
s: qptr may fixThis might be fixed by the "qptr" experiment (https://github.com/EmbarkStudios/spirt/pull/24)This might be fixed by the "qptr" experiment (https://github.com/EmbarkStudios/spirt/pull/24)t: enhancementA new feature or improvement to an existing one.A new feature or improvement to an existing one.