-
Notifications
You must be signed in to change notification settings - Fork 232
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
(c2rust-analyze
) Support ptr-to-ptr casts between safely transmutable types, for now limited to same-sized integers
#839
Commits on Feb 19, 2023
-
(
c2rust-analyze
) Support ptr-to-ptr casts between safely transmutab……le types, for now limited to same-sized integers. This introduces the concept of equivalent/compatible/safely transmutable types. This forms an equivalence class among types, as the safe transmutability must be mutual (i.e. transmutable in both directions; no prefix-transmutability). Thus, we can now allow ptr-to-ptr casts between safely transmutable pointee types, whereas previously they were only allowed for equal types. Equal types could have their `PointerId`s unified as they had the same structure, which is still of safely transmutability types, which are safely transmutability because they have the same structure/layout. As safe transmutability is difficult to check abstractly for any two types, for now we limit it to commonly transmuted types that we know are definitely transmutable: same-sized integer types (with potentially different signedness). Thus, this enables support for string casts like `b"" as *const u8 as *const core::ffi::c_char`, where `c_char = i8`, which fixes #840. Note that the above cast (#833) is still not supported due to the string literal `b""` (#837), but the cast itself (in `string_casts.rs` in `fn cast_only`) works.
Configuration menu - View commit details
-
Copy full SHA for 81d4e46 - Browse repository at this point
Copy the full SHA 81d4e46View commit details -
(
c2rust-analyze
) Clarified thatdo_unify
now requires only compat……ible/safetly transmutable types, not identical.
Configuration menu - View commit details
-
Copy full SHA for 68461db - Browse repository at this point
Copy the full SHA 68461dbView commit details -
(
c2rust-analyze
) Support deeper levels of ptr transmutability (e.x.…… `a ~ b` => `*a ~ *b` for all `a`, `b`).
Configuration menu - View commit details
-
Copy full SHA for da4d961 - Browse repository at this point
Copy the full SHA da4d961View commit details -
Configuration menu - View commit details
-
Copy full SHA for 62ec8dc - Browse repository at this point
Copy the full SHA 62ec8dcView commit details -
(
c2rust-analyze
) Relaxed the transmutable checks from two-way to on……e-way, now allowing for arrays and slices to decay. This expands the definition of safe transmutability to be one-way. That is, it checks if `*T as *U` is safe, rather than also `*U as *T`. Thus, we can now allow for casts decaying pointers to arrays and slices to pointers to their element type. `do_unify` is modified to also be one-way, which it was already in all call sites. New tests are also added to `string_casts.rs` for all the types of ptr-to-ptr casts. Out of the full string cast, `b"" as *const u8 as *const core::ffi::c_char`, this adds support for the `as *const u8` (from `&[u8; _]`), so only support for the string literal itself remains.
Configuration menu - View commit details
-
Copy full SHA for 0d88d7a - Browse repository at this point
Copy the full SHA 0d88d7aView commit details -
Configuration menu - View commit details
-
Copy full SHA for a148146 - Browse repository at this point
Copy the full SHA a148146View commit details -
(
c2rust-analyze
) Fix theis_transmutable_to
docs, formalizing the…… expanded defintion of safe transmutability.
Configuration menu - View commit details
-
Copy full SHA for 26a4275 - Browse repository at this point
Copy the full SHA 26a4275View commit details
Commits on Apr 26, 2023
-
(
c2rust-analyze
) Relax the transmutable checks from two-way to one-……way, now allowing for arrays and slices to decay (#841) Relaxed the transmutable checks from two-way to one-way, now allowing for arrays and slices to decay. This expands the definition of safe transmutability to be one-way. That is, it checks if `*T as *U` is safe, rather than also `*U as *T`. Thus, we can now allow for casts decaying pointers to arrays and slices to pointers to their element type. `do_unify` is modified to also be one-way, which it was already in all call sites. New tests are also added to `string_casts.rs` for all the types of ptr-to-ptr casts. Out of the full string cast, `b"" as *const u8 as *const core::ffi::c_char`, this adds support for the `as *const u8` (from `&[u8; _]`), so only support for the string literal itself remains.
Configuration menu - View commit details
-
Copy full SHA for eae9234 - Browse repository at this point
Copy the full SHA eae9234View commit details
Commits on May 1, 2023
-
Configuration menu - View commit details
-
Copy full SHA for fe926ea - Browse repository at this point
Copy the full SHA fe926eaView commit details -
(
c2rust-analyze
) Expand transmutability to unsizing casts (`[A] => ……[A; N]`, `[A; N] => [A]`). This fixes transmutability-related crashes in `tests/analyze/string_casts.rs` (which weren't being actually run pre-`merge master` for some reason, and so were untested).
Configuration menu - View commit details
-
Copy full SHA for 182b0b5 - Browse repository at this point
Copy the full SHA 182b0b5View commit details -
Configuration menu - View commit details
-
Copy full SHA for 32ca464 - Browse repository at this point
Copy the full SHA 32ca464View commit details -
(
c2rust-analyze
) Revert the use ofis_transmutable_to
in `TypeChe……cker::do_unify` (back to strict equality) as #883 resolved this (#839 (comment)).
Configuration menu - View commit details
-
Copy full SHA for 9a7c501 - Browse repository at this point
Copy the full SHA 9a7c501View commit details -
Configuration menu - View commit details
-
Copy full SHA for 0c9d0ac - Browse repository at this point
Copy the full SHA 0c9d0acView commit details -
(
c2rust-analyze
) Add back the unsizing cast dataflow constraint from ……#883. It's not complete, but fixes the crash in `as_ptr.rs`.
Configuration menu - View commit details
-
Copy full SHA for 2d45f80 - Browse repository at this point
Copy the full SHA 2d45f80View commit details
Commits on May 2, 2023
-
Configuration menu - View commit details
-
Copy full SHA for 14824a1 - Browse repository at this point
Copy the full SHA 14824a1View commit details -
(
c2rust-analyze/tests
) Add an explicit (in terms ofaddr_of!
) ver……sion of the `cast_array_to_ptr` test. The other disabled tests still didn't work with the same approach.
Configuration menu - View commit details
-
Copy full SHA for 95767c3 - Browse repository at this point
Copy the full SHA 95767c3View commit details -
Configuration menu - View commit details
-
Copy full SHA for e41cec1 - Browse repository at this point
Copy the full SHA e41cec1View commit details -
(
c2rust-analyze/tests
) Add a disabled `cast_array_to_slice_ptr_expl……icit` test b/c it still doesn't work even explicitly.
Configuration menu - View commit details
-
Copy full SHA for 2915b8d - Browse repository at this point
Copy the full SHA 2915b8dView commit details -
(
c2rust-analyze/test
) Reword explanation of explicit string cast te……sts to specify `&raw` MIR statements, inserted with `addr_of!`s.
Configuration menu - View commit details
-
Copy full SHA for 11bf351 - Browse repository at this point
Copy the full SHA 11bf351View commit details
Commits on May 5, 2023
-
(
c2rust-analyze
) Remove the leading|
in amatches!
so `rustfmt……` formats it reasonably.
Configuration menu - View commit details
-
Copy full SHA for 65e5140 - Browse repository at this point
Copy the full SHA 65e5140View commit details -
(
c2rust-analyze
) Replace "equivalance relation" with "reflexive, tr……ansitive" since it's non-symmetric, and equivalance relations are symmetric.
Configuration menu - View commit details
-
Copy full SHA for 44ac9f4 - Browse repository at this point
Copy the full SHA 44ac9f4View commit details
Commits on May 22, 2023
-
(
c2rust-analyze
) Separate handling ofCastKind
s and only check sa……fe transmutability for `CastKind::Misc`, which are the only non-type-checked ptr casts. Note that `CastKind::Pointer(PointerCast::Unsize)` needs different rules than safe transmutability. These rules are implemented by typeck, so there's no reason re-implementing that, but we can't include them in transmutability (will be removed in the next commit).
Configuration menu - View commit details
-
Copy full SHA for 4bbb306 - Browse repository at this point
Copy the full SHA 4bbb306View commit details -
Revert "(
c2rust-analyze
) Expand transmutability to unsizing casts (……`[A] => [A; N]`, `[A; N] => [A]`)." This reverts commit 182b0b5.
Configuration menu - View commit details
-
Copy full SHA for 720c2fb - Browse repository at this point
Copy the full SHA 720c2fbView commit details -
(
c2rust-analyze/tests
) Remove thecast_array_to_slice_ptr
tests a……s that cast is unsound and has been removed from transmutability in the last commit.
Configuration menu - View commit details
-
Copy full SHA for df1d63d - Browse repository at this point
Copy the full SHA df1d63dView commit details
Commits on May 25, 2023
-
Configuration menu - View commit details
-
Copy full SHA for b15e24e - Browse repository at this point
Copy the full SHA b15e24eView commit details
Commits on Jun 5, 2023
-
Configuration menu - View commit details
-
Copy full SHA for 6ea8a7e - Browse repository at this point
Copy the full SHA 6ea8a7eView commit details -
Configuration menu - View commit details
-
Copy full SHA for 1fd669c - Browse repository at this point
Copy the full SHA 1fd669cView commit details
Commits on Jun 8, 2023
-
(
c2rust-analyze
) Adjust wording on safe transmutability definition ……to use well-defined instead of safe and to use "implies" instead of "and".
Configuration menu - View commit details
-
Copy full SHA for a73e64d - Browse repository at this point
Copy the full SHA a73e64dView commit details -
(
c2rust-analyze
) Revert the arg names ofdo_unify
tolty{1,2}
f……rom `{pl,rv}_lty`, as they are interchangeable.
Configuration menu - View commit details
-
Copy full SHA for 435e399 - Browse repository at this point
Copy the full SHA 435e399View commit details -
(
c2rust-analyze
) Update safe transmutability rules to add `A ~ B =>……` to the slice and array rules.
Configuration menu - View commit details
-
Copy full SHA for 1317e03 - Browse repository at this point
Copy the full SHA 1317e03View commit details -
(
c2rust-analyze
) For the array safe transmutability rule, require t……han `N > 0` to avoid ZSTs, as then the rule would be unsound.
Configuration menu - View commit details
-
Copy full SHA for 60a4376 - Browse repository at this point
Copy the full SHA 60a4376View commit details -
(
c2rust-analyze
) Remove the slice rule for safe transmutability, as…… it's only sound for non-empty slices, but we can't check that at compile-time.
Configuration menu - View commit details
-
Copy full SHA for 9b43bd6 - Browse repository at this point
Copy the full SHA 9b43bd6View commit details
Commits on Jun 9, 2023
-
(
c2rust-analyze
).unwrap()
on.try_to_scalar_int()
for array le……ngth `Const`s.
Configuration menu - View commit details
-
Copy full SHA for 355b56b - Browse repository at this point
Copy the full SHA 355b56bView commit details -
Configuration menu - View commit details
-
Copy full SHA for 7f87dc1 - Browse repository at this point
Copy the full SHA 7f87dc1View commit details -
Configuration menu - View commit details
-
Copy full SHA for 31baf0a - Browse repository at this point
Copy the full SHA 31baf0aView commit details