Repository navigation
Correctly handle assert_* intrinsics - #742
Conversation
|
@zhassan-aws brought #648 to my attention, thanks!! Removing/Changing |
danielsn
left a comment
There was a problem hiding this comment.
The tests I see are for primitive types. Would it make sense to also ensure that we do the right thing for enums and structs?
There was a problem hiding this comment.
Reference to rust documentation here?
There was a problem hiding this comment.
Added links to rust docs.
There was a problem hiding this comment.
Is there a spec we can point to here?
There was a problem hiding this comment.
I was not able to find one as documentation regarding these intrinsics is quite hard to find.
The closest thing I could find is the actual implementation in rustc_codegen_ssa/src/mir/block.rs (codegen_panic_intrinsic) in addition to PR discussions. But if you know of one I will be happy to add it here.
There was a problem hiding this comment.
FWIW, I think links directly to code serve as a reasonable reference, too. Maybe add that as a comment? (e.g. link directly to it on github?)
There was a problem hiding this comment.
My main concern with that is that links to rustc code may become outdated pretty quickly. But even that is better that no links, so just added a note here linking to that function.
There was a problem hiding this comment.
Is there a spec we can point to here?
There was a problem hiding this comment.
Do we have a tracking issue for this?
There was a problem hiding this comment.
Should we also have a test with an expected pass (e.g. zero initializing a u8)?
There was a problem hiding this comment.
The test in src/test/rmc/Intrinsics/Assert/zero_valid.rs (path updated in this PR) already does this for several types, including a user-defined struct.
There was a problem hiding this comment.
FWIW, I think links directly to code serve as a reasonable reference, too. Maybe add that as a comment? (e.g. link directly to it on github?)
5cc5515 to
e20525f
Compare
e20525f to
797ecc3
Compare
Description of changes:
Adds support for the
assert_uninitandassert_zerointrinsics. Inserts the code for them andassert_inhabitedinto a single function.Resolved issues:
Resolves #6
Resolves #7
Call-outs:
assert_inhabitedfirst, then proceed to do the other ones. This proposal follows the same pattern.assert_inhabited(i.e., insrc/test/rmc/Intrinsics/Assert/inhabited_panic.rs) isThis is due to the
Nevershook being applied instead of theIntrinsicsone. I have tried doing some changes to the application condition (for example, returnfalseif the instance is an intrinsic) to no success (ended up in some code that expected theNevershook to have applied).Assertnow contains the multiple assertions test only, and anotherAssertfolder has been created withinIntrinsicsto keep the tests related to the intrinsics in this PR.Testing:
How is this change tested? Existing regression + 3 new tests + 1 removed test.
Is this a refactor change? No.
Checklist
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 and MIT licenses.