Skip to content

Implement pinned drop sugar#9

Open
P8L1 wants to merge 3 commits intofrank-king:feature/pin-dropfrom
P8L1:implement-pin-drop-sugar
Open

Implement pinned drop sugar#9
P8L1 wants to merge 3 commits intofrank-king:feature/pin-dropfrom
P8L1:implement-pin-drop-sugar

Conversation

@P8L1
Copy link
Copy Markdown

@P8L1 P8L1 commented May 4, 2026

Implements fn drop(&pin mut self) as sugar for Drop::pin_drop.

The resolver recognizes the sugar only for the actual #[lang = "drop"] trait, maps accepted impl items to effective pin_drop resolution, and passes marked impl item IDs to lowering. Lowering then emits HIR with ident pin_drop, so existing type checking, Drop validation, drop glue, and direct-call checks remain unchanged.

Drop identity is handled without a hardcoded core::ops::drop::Drop path check. Local #[lang = "drop"] traits are recorded from raw AST attributes, and external Drop identity is checked through external lang-item metadata via defined_lang_items. This avoids calling the all-crates tcx.lang_items() query from resolver.

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.

@P8L1
Copy link
Copy Markdown
Author

P8L1 commented May 8, 2026

@frank-king have you had time to review this by any chance?

@frank-king
Copy link
Copy Markdown
Owner

frank-king commented May 9, 2026

I'm not the proper reviewer for this PR, could you please open a PR directly merging to the upstream rust-lang/rust repo?

(Note, you can open a draft PR and mark it ready since rust-lang#144537 is merged)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants