c2rust icon indicating copy to clipboard operation
c2rust copied to clipboard

Tracking Issue: Translation nightly features

Open TheDan64 opened this issue 5 years ago • 10 comments

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 and offset_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 generating Cargo.toml files which use the libc crate

TheDan64 avatar Apr 02 '19 19:04 TheDan64

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.

rinon avatar Apr 11 '19 22:04 rinon

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.

bjorn3 avatar Aug 29 '19 10:08 bjorn3

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

panstromek avatar Jul 19 '20 12:07 panstromek

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.

chrysn avatar Sep 22 '20 13:09 chrysn

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: 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.

OvermindDL1 avatar Oct 20 '20 15:10 OvermindDL1

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.

fanninpm avatar Dec 22 '20 01:12 fanninpm

I think it worth to pin this issue, otherwise it's easy to miss and one of the most important, imho.

XVilka avatar Dec 23 '20 06:12 XVilka

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 but offset_from was added in 1.47.0. It is const 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 been const since 1.32.0.

kkysen avatar Jun 09 '22 16:06 kkysen

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?

pitaj avatar Apr 29 '23 03:04 pitaj

  • [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.

mewmew avatar Sep 10 '23 10:09 mewmew