Repository navigation
Conversation
Collaborator
|
r? @davidtwco rustbot has assigned @davidtwco. Use Why was this reviewer chosen?The reviewer was selected based on:
|
Currently the `asm!` macro supports raw (thin) pointers as operands, and references as input operands. As discussed in Zulip (https://rust-lang.zulipchat.com/#narrow/channel/213817-t-lang/topic/.60NonNull.60s.20as.20register.20operand.20values.20of.20asm.21/with/629100221), it would be acceptable to extend support to fundamental types with the same ABI as raw pointers. This commit adds support for (thin) `NonNull` pointer inputs. The reason for not allowing `NonNull` outputs is that the `asm!` code has no way to explicitly assert that the safety invariant of `NonNull` is preserved.
hsanzg
force-pushed
the
rich-asm-ptr-inputs
branch
from
October 26, 2026 22:23
efa94c9 to
61b2e57
Compare
Member
|
re: that Zulip discussion, Amanieu was critical of this idea in its unqualified form and as our de facto expert in inline r? @Amanieu |
Member
|
LGTM, but this needs a positive codegen test. The current tests all fail and never reach codegen. |
This branch has not been deployed
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.
Currently the
asm!macro supports raw (thin) pointers as operands, and references as input operands. As discussed in Zulip, it seems reasonable to extend support to fundamental types with the same ABI as raw pointers. This commit adds support for (thin)NonNullpointer inputs. The reason for not allowingNonNulloutputs is that theasm!code has no way to explicitly assert that the safety invariant ofNonNullis preserved.Support for
Box<T>andOptional<NonNull<T>>seems a bit more debatable, so that's left as future work (which might require more than a FCP).I'll make the existing error messages dependent on whether the operand is allowed specifically as an input in a subsequent PR (because it also affects references). Right now the message is a bit too general.