mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-16 21:15:18 +03:00
4903ba3b6b
Implement pinned drop sugar Implements `fn drop(&pin mut self)` as sugar for `Drop::pin_drop`. The resolver recognizes `fn drop(&pin mut self)` syntactically in trait impls and performs lookup using the effective `pin_drop` name. AST lowering independently rechecks the syntactic sugar, validates that the resolved item belongs to the actual `Drop` lang trait, and emits HIR with ident `pin_drop` for accepted sugar. Existing type checking, Drop validation, drop glue, and direct-call checks remain unchanged. Drop identity is checked during AST lowering through `tcx.lang_items().drop_trait()`, after resolver has performed the effective `pin_drop` lookup. The resolver does not need to know whether the trait is the actual `Drop` lang item, and it no longer passes marked impl item IDs to lowering. This intentionally preserves the base pinned-drop behavior where `#[pin_v2]` types must use `pin_drop`, while non-`#[pin_v2]` types may still implement `pin_drop`. r? @petrochenkov ## Related https://github.com/rust-lang/rust/pull/144537 https://github.com/rust-lang/rust/issues/130494