-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Change untagged_unions to not allow union fields with drop #62330
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
Merged
Changes from 18 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
0a08841
Remove uses of `allow(unions_with_drop_fields)` in the standard library
SimonSapin 84ca0a1
Remove most uses of `allow(unions_with_drop_fields)` in tests
SimonSapin 2f0c821
Change untagged_unions to not allow union fields with drop
bluss fe13bbd
Remove unions_with_drop_fields lint
SimonSapin e247a40
Fixes #41073, it is no longer an ICE
SimonSapin 05a644e
Update src/librustc_typeck/check/mod.rs
SimonSapin 8c5ae86
Update src/librustc_typeck/check/mod.rs
SimonSapin 0301eaf
Update src/librustc_typeck/error_codes.rs
SimonSapin bf25a9c
Update src/test/run-pass/union/union-nodrop.rs
SimonSapin fc512d2
More descriptive variable name
SimonSapin 616cf52
Extend union-nodrop.rs test
SimonSapin 50ec10e
rpass tests are now part of `ui` tests
oli-obk 9c1ad0f
Preserve originally intended test semantics
oli-obk 2fc257c
Prefer `ManuallyDrop::{take,new}` over `ptr::{read,write}`
oli-obk fb23a5c
Clarify a vague comment
oli-obk 7e1a65d
Ensure we do not treat all unions as not having any drop glue.
oli-obk f5669eb
Update ui stderr
oli-obk bb5a652
Rebase fallout
oli-obk 0653694
Don't silently do nothing on mis_use of `check_union_fields`
oli-obk 875bdd5
Report even duplilcate errors in case the feature gat is not active
oli-obk 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
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
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
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
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
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
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
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
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,24 @@ | ||
#![feature(untagged_unions)] | ||
|
||
union Test { | ||
a: A, //~ ERROR unions may not contain fields that need dropping | ||
b: B | ||
} | ||
|
||
#[derive(Debug)] | ||
struct A(i32); | ||
impl Drop for A { | ||
fn drop(&mut self) { println!("A"); } | ||
} | ||
|
||
#[derive(Debug)] | ||
struct B(f32); | ||
impl Drop for B { | ||
fn drop(&mut self) { println!("B"); } | ||
} | ||
|
||
fn main() { | ||
let mut test = Test { a: A(3) }; | ||
println!("{:?}", unsafe { test.b }); | ||
unsafe { test.b = B(0.5); } | ||
} |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.