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#135313 - compiler-errors:needs-mono, r=BoxyUwU
Eagerly mono drop for structs with lifetimes That is, use `!generics.requires_monomorphization()` rather than `generics.is_empty()` like the rest of the mono collector code.
- Loading branch information
Showing
2 changed files
with
48 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// Ensure that we *eagerly* monomorphize drop instances for structs with lifetimes. | ||
|
||
//@ compile-flags:-Zprint-mono-items=eager | ||
//@ compile-flags:--crate-type=lib | ||
|
||
//~ MONO_ITEM fn std::ptr::drop_in_place::<StructWithDrop> - shim(Some(StructWithDrop)) | ||
struct StructWithDrop { | ||
x: i32, | ||
} | ||
|
||
impl Drop for StructWithDrop { | ||
//~ MONO_ITEM fn <StructWithDrop as std::ops::Drop>::drop | ||
fn drop(&mut self) {} | ||
} | ||
|
||
struct StructNoDrop { | ||
x: i32, | ||
} | ||
|
||
//~ MONO_ITEM fn std::ptr::drop_in_place::<EnumWithDrop> - shim(Some(EnumWithDrop)) | ||
enum EnumWithDrop { | ||
A(i32), | ||
} | ||
|
||
impl Drop for EnumWithDrop { | ||
//~ MONO_ITEM fn <EnumWithDrop as std::ops::Drop>::drop | ||
fn drop(&mut self) {} | ||
} | ||
|
||
enum EnumNoDrop { | ||
A(i32), | ||
} | ||
|
||
// We should be able to monomorphize drops for struct with lifetimes. | ||
impl<'a> Drop for StructWithDropAndLt<'a> { | ||
//~ MONO_ITEM fn <StructWithDropAndLt<'_> as std::ops::Drop>::drop | ||
fn drop(&mut self) {} | ||
} | ||
|
||
//~ MONO_ITEM fn std::ptr::drop_in_place::<StructWithDropAndLt<'_>> - shim(Some(StructWithDropAndLt<'_>)) | ||
struct StructWithDropAndLt<'a> { | ||
x: &'a i32, | ||
} |