forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of rust-lang#118932 - matthiaskrgr:rollup-fi7xzqa, r=matth…
…iaskrgr Rollup of 3 pull requests Successful merges: - rust-lang#118375 (Add -Zunpretty=stable-mir output test) - rust-lang#118538 (fix dynamic size/align computation logic for packed types with dyn trait tail) - rust-lang#118789 (fix --dry-run when the change-id warning is printed) r? `@ghost` `@rustbot` modify labels: rollup
- Loading branch information
Showing
10 changed files
with
376 additions
and
64 deletions.
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
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,21 @@ | ||
// run-pass | ||
use std::ptr::addr_of; | ||
|
||
// When the unsized tail is a `dyn Trait`, its alignments is only dynamically known. This means the | ||
// packed(2) needs to be applied at runtime: the actual alignment of the field is `min(2, | ||
// usual_alignment)`. Here we check that we do this right by comparing size, alignment, and field | ||
// offset before and after unsizing. | ||
fn main() { | ||
#[repr(C, packed(2))] | ||
struct Packed<T: ?Sized>(u8, core::mem::ManuallyDrop<T>); | ||
|
||
let p = Packed(0, core::mem::ManuallyDrop::new(1)); | ||
let p: &Packed<usize> = &p; | ||
let sized = (core::mem::size_of_val(p), core::mem::align_of_val(p)); | ||
let sized_offset = unsafe { addr_of!(p.1).cast::<u8>().offset_from(addr_of!(p.0)) }; | ||
let p: &Packed<dyn Send> = p; | ||
let un_sized = (core::mem::size_of_val(p), core::mem::align_of_val(p)); | ||
let un_sized_offset = unsafe { addr_of!(p.1).cast::<u8>().offset_from(addr_of!(p.0)) }; | ||
assert_eq!(sized, un_sized); | ||
assert_eq!(sized_offset, un_sized_offset); | ||
} |
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,21 @@ | ||
// run-pass | ||
use std::ptr::addr_of; | ||
|
||
// When the unsized tail is a `dyn Trait`, its alignments is only dynamically known. This means the | ||
// packed(2) needs to be applied at runtime: the actual alignment of the field is `min(2, | ||
// usual_alignment)`. Here we check that we do this right by comparing size, alignment, and field | ||
// offset before and after unsizing. | ||
fn main() { | ||
#[repr(C, packed(2))] | ||
struct Packed<T: ?Sized>(u8, core::mem::ManuallyDrop<T>); | ||
|
||
let p = Packed(0, core::mem::ManuallyDrop::new(1)); | ||
let p: &Packed<usize> = &p; | ||
let sized = (core::mem::size_of_val(p), core::mem::align_of_val(p)); | ||
let sized_offset = unsafe { addr_of!(p.1).cast::<u8>().offset_from(addr_of!(p.0)) }; | ||
let p: &Packed<dyn Send> = p; | ||
let un_sized = (core::mem::size_of_val(p), core::mem::align_of_val(p)); | ||
let un_sized_offset = unsafe { addr_of!(p.1).cast::<u8>().offset_from(addr_of!(p.0)) }; | ||
assert_eq!(sized, un_sized); | ||
assert_eq!(sized_offset, un_sized_offset); | ||
} |
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,14 @@ | ||
// compile-flags: -Z unpretty=stable-mir -Z mir-opt-level=3 | ||
// check-pass | ||
|
||
fn foo(i:i32) -> i32 { | ||
i + 1 | ||
} | ||
|
||
fn bar(vec: &mut Vec<i32>) -> Vec<i32> { | ||
let mut new_vec = vec.clone(); | ||
new_vec.push(1); | ||
new_vec | ||
} | ||
|
||
fn main(){} |
Oops, something went wrong.