c2rust
c2rust copied to clipboard
Tracking Issue: Translation nightly features
This is the tracking issue for generated code which requires nightly to run:
- ~Assembly -
asm
- https://github.com/rust-lang/rust/issues/29722~asm!
stabilized since 1.59.0 - Intrinsics for atomic operations -
core_intrinsics
- Unlikely to ever be stabilized itself, no tracking issue - ~Ptr to ptr offset calculation -
ptr_wrapping_offset_from
- https://github.com/rust-lang/rust/issues/41079~wrapping_offset_from
removed andoffset_from
added in 1.47.0, still const unstable. - Labels for breaks in relooper -
label_break_value
- https://github.com/rust-lang/rust/issues/48594 - Opaque extern types -
extern_types
- https://github.com/rust-lang/rust/issues/43467 - Thread Local variables -
thread_local
- https://github.com/rust-lang/rust/issues/29594 - ~Cast const ptr to usize -
const_raw_ptr_to_usize_cast
- https://github.com/rust-lang/rust/issues/51910~const_raw_ptr_to_usize_cast
removed, no longer needed either, and impossible in C as well - ~Cast const slice to pointer -
const_slice_as_ptr
~ -[].as_ptr()
const since 1.32.0 - C-compatible variadic functions -
c_variadics
- https://github.com/rust-lang/rust/issues/44930 - ~Libc types -
libc
~ - Now generatingCargo.toml
files which use thelibc
crate
Since libc
is on crates.io and rustc errors when we use the internal version, we should drop that off the list of nightly features.
Intrinsics for atomic operations - core_intrinsics - Unlikely to ever be stabilized itself, no tracking issue
Maybe cast the pointer from say *mut u64
to *mut AtomicU64
and then use the normal AtomicU64
methods on it.
Note about ptr_offset_from
stabilization:
Method wrapping_offset_from
(which is often used in c2rust output) has been deprecated since 1.46
and it is being removed in ptr_offset_from
stabilization PR: https://github.com/rust-lang/rust/pull/74238
Assembly is now tracked at https://github.com/rust-lang/rust/issues/70173 -- but without any plan for stabilization; see #306. Unless the asm transpilation is significantly reworked (to produce Rust asm rather than llvm_asm), this now falls in the "unlikely to be stabilized" category.
Method
wrapping_offset_from
(which is often used in c2rust output) has been deprecated since1.46
and it is being removed inptr_offset_from
stabilization PR: rust-lang/rust#74238
And looks like it's entirely gone now, says the feature doesn't exist and the wrapping_offset_from
call no longer exists in the source.
And looks like it's entirely gone now, says the feature doesn't exist and the
wrapping_offset_from
call no longer exists in the source.
It was removed in August.
I think it worth to pin this issue, otherwise it's easy to miss and one of the most important, imho.
A bunch of these features have since been stabilized or removed:
-
asm!
is stabilized since 1.59.0:core::arch::asm!
-
wrapping_offset_from
was removed butoffset_from
was added in 1.47.0. It isconst
unstable. -
const_raw_ptr_to_usize_cast
was removed since it is unsafe at compile time. Why do we need this? You can't const cast a pointer to an integer in C either, even if the pointer was originally cast from an integer: https://godbolt.org/z/xKrhfG7z6. These are errors because they try to be variable-length array declarations:
#include <stdint.h>
int a[(uintptr_t) (char *) 0];
int b[(uintptr_t) ""];
-
const_slice_as_ptr
works on stable now:[].as_ptr()
has beenconst
since 1.32.0.
It appears that core_intrinsics
is also used for rotate_left
and rotate_right
. Is there a reason these can't just use the inherent methods instead?
- [x] Labels for breaks in relooper - label_break_value - https://github.com/rust-lang/rust/issues/48594
the feature
label_break_value
has been stable since 1.65.0 and no longer requires an attribute to enable
ref: https://github.com/rust-lang/rust/pull/99332
Thus, #![feature(label_break_value)]
can be removed from transpiled code output.