-
Couldn't load subscription status.
- Fork 13.9k
lint: use transparent_newtype_field to avoid ICE
#74340
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
Merged
bors
merged 1 commit into
rust-lang:master
from
davidtwco:issue-73747-improper-ctypes-defns-is-zst-with-params
Jul 14, 2020
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| // check-pass | ||
|
|
||
| #[repr(transparent)] | ||
| struct NonNullRawComPtr<T: ComInterface> { | ||
| inner: std::ptr::NonNull<<T as ComInterface>::VTable>, | ||
| } | ||
|
|
||
| trait ComInterface { | ||
| type VTable; | ||
| } | ||
|
|
||
| extern "C" fn invoke<T: ComInterface>(_: Option<NonNullRawComPtr<T>>) {} | ||
|
|
||
| fn main() {} |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does
is_zsteven do? I'm surprised to see that method onTy, and suspicious of how it might be implemented.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added it in an earlier PR (or I just made it with existing logic, I forget), it’s predominantly used in lints which care about transparent types. Its logic is the same as where transparent types are checked in typeck (but it wasn’t trivial to factor it out there too) - it basically gets the layout of the type and calls
is_zston that, returningfalseif any of the intermediate stuff fails.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think
Tyshould have methods that interact with layout, feels like an abstraction violation.If something relies on layout that should be clear (i.e.
is_zstcallers should uselayout_ofthemselves - not to mention that e.g.LateLintContextshould have betterlayout_ofintegration than doing it onTy)