-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
[rustc_ty_utils] Treat drop_in_place
's *mut argument like &mut when adding LLVM attributes
#111807
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
f71741b
[rustc_ty_utils] Add the LLVM `noalias` parameter attribute to `drop_…
pcwalton 74dd3cb
Fix noalias box test
pcwalton 21b8815
Apply `noalias`, `nonnull`, `dereferenceable`, and `align` attributes…
pcwalton 2836e55
Update documentation for `drop_in_place()`
pcwalton b2ef9f7
Add missing "unsafe" to fix doctest
pcwalton 58c3999
improve drop_in_place docs
erikdesjardins 47444d7
improve code checking for drop_in_place lang item
erikdesjardins 6448183
ensure !Unpin types do not get noalias
erikdesjardins c4d69b7
make noalias-box-off filecheck more precise
erikdesjardins 340827a
drop_in_place docs: remove pseudocode-ish implementation details
erikdesjardins fb7f1d2
drop-in-place-noalias test: needs -O to ensure attributes are added o…
erikdesjardins 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 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 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 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,38 @@ | ||
// compile-flags: -O -C no-prepopulate-passes | ||
|
||
// Tests that the compiler can apply `noalias` and other &mut attributes to `drop_in_place`. | ||
// Note that non-Unpin types should not get `noalias`, matching &mut behavior. | ||
|
||
#![crate_type="lib"] | ||
|
||
use std::marker::PhantomPinned; | ||
|
||
// CHECK: define internal void @{{.*}}core{{.*}}ptr{{.*}}drop_in_place{{.*}}StructUnpin{{.*}}({{.*\*|ptr}} noalias noundef align 4 dereferenceable(12) %{{.+}}) | ||
|
||
// CHECK: define internal void @{{.*}}core{{.*}}ptr{{.*}}drop_in_place{{.*}}StructNotUnpin{{.*}}({{.*\*|ptr}} noundef nonnull align 4 %{{.+}}) | ||
|
||
pub struct StructUnpin { | ||
a: i32, | ||
b: i32, | ||
c: i32, | ||
} | ||
|
||
impl Drop for StructUnpin { | ||
fn drop(&mut self) {} | ||
} | ||
|
||
pub struct StructNotUnpin { | ||
a: i32, | ||
b: i32, | ||
c: i32, | ||
p: PhantomPinned, | ||
} | ||
|
||
impl Drop for StructNotUnpin { | ||
fn drop(&mut self) {} | ||
} | ||
|
||
pub unsafe fn main(x: StructUnpin, y: StructNotUnpin) { | ||
drop(x); | ||
drop(y); | ||
} |
This file contains 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
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.
This particular requirement is ill-placed in the list since it is not a consequence of the things said above the enumeration -- but the docs claim that all list items follow from that prior information.
I think it is better to just state the requirement, we don't need to document hiw they come about because from the internal implementation details.
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.
Makes sense, undid the change to the introduction of this section