Rust-GCC / gccrs

GCC Front-End for Rust
https://rust-gcc.github.io/
GNU General Public License v2.0
2.42k stars 156 forks source link

Drop Order glue #371

Open philberty opened 3 years ago

philberty commented 3 years ago

https://doc.rust-lang.org/std/ops/trait.Drop.html

bjorn3 commented 3 years ago

In rustc the ptr::drop_in_place function is annotated with #[lang = "drop_in_place"] such that any attempt at getting the MIR of this function results in the drop glue for the respective type being generated and returned. Automatically inserted drops call this function.

ptr::drop_in_place: https://github.com/rust-lang/rust/blob/5258a74c887f8ae14717e1f98b652b470877ce4e/library/core/src/ptr/mod.rs#L190-L198

drop glue generation: https://github.com/rust-lang/rust/blob/5258a74c887f8ae14717e1f98b652b470877ce4e/compiler/rustc_mir/src/shim.rs#L132-L202

philberty commented 3 years ago

Thanks that's really helpful, this might make me want to bring MIR in for this and #144

bjorn3 commented 3 years ago

The main shim is manually implemented. There is no MIR generated for it. Left a comment on #144.