[macros] Support shrinking value transmutes#2581
Merged
Conversation
This was referenced Jun 9, 2025
0dc4ac5 to
5f19ed9
Compare
df3a207 to
15f9941
Compare
jswrenn
reviewed
Jun 9, 2025
| @@ -51,39 +51,109 @@ | |||
| /// This macro can be invoked in `const` contexts. | |||
| #[macro_export] | |||
| macro_rules! transmute { | |||
Collaborator
There was a problem hiding this comment.
Need to document allow(shrink).
c18affd to
50bb997
Compare
In `transmute!`, support an `#![allow(shrink)]` attribute which is invoked as follows: transmute!(#![allow(shrink)] src); When this attribute is provided, `transmute!` will permit shrinking transmutes, in which the destination value may be smaller than the source value. Co-authored-by: Jack Wrenn <[email protected]> gherrit-pr-id: I46b18b4b1d10507b7e1d2e01b09dc4960cfcdce1
50bb997 to
8e4a6e5
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2581 +/- ##
==========================================
- Coverage 88.91% 88.72% -0.19%
==========================================
Files 20 20
Lines 5312 5332 +20
==========================================
+ Hits 4723 4731 +8
- Misses 589 601 +12 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
jswrenn
requested changes
Jun 10, 2025
Co-authored-by: Jack Wrenn <[email protected]>
jswrenn
approved these changes
Jun 10, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In
transmute!, support an#![allow(shrink)]attribute which isinvoked as follows:
transmute!(#![allow(shrink)] src);
When this attribute is provided,
transmute!will permit shrinkingtransmutes, in which the destination value may be smaller than the
source value.
Co-authored-by: Jack Wrenn [email protected]
This PR is on branch transmute-ref-dst.