FractalFir / rustc_codegen_clr

This rust compiler backend(module) emmits valid CIL (.NET IR), enabling you to use Rust in .NET projects.
MIT License
1.56k stars 35 forks source link

Add `core::intrinsics::transmute` intrinsics test #49

Closed Oneirical closed 3 months ago

Oneirical commented 3 months ago

Part of #45.

Presenting this to narrow down if this is what you are looking for in intrinsics tests. The 3 transmute test cases are inspired from the transmute official docs.

A possible improvement I noticed for the test suite is the wall of:

// snip
run_test! {intrinsics,ctpop,stable}
run_test! {intrinsics,atomics,stable}
run_test! {intrinsics,alloc,stable}
run_test! {intrinsics,size_of_val,stable}
run_test! {intrinsics,malloc,stable}
run_test! {intrinsics,offset_of,stable}
// snip

in compile_test.rs. Addressing this could be the subject of another PR.

Oneirical commented 3 months ago

I am getting a failure in the CI, though I am not sure if this is due to a mistake in the test or simply due to transmute not being supported yet.

FractalFir commented 3 months ago

The test seems to be OK, it just tripped up an additional warning.

Some time ago, I added new checks, which attempt to find type errors related to pointers. This requires changing the type of a pointer to be explicit(to use the CastPtr IR node).

I must have accidentally missed one of special cases of transmutation(fn ptr to raw ptr) when I updated my backend to use explicit pointer casts.

Since the pointer cast was implicit, the codegen detected a potential issue, and printed a warning to stderr. Since a warning was printed, the test is considered a "failure", even tough it works.