rust-borrow-semantics

Diagnose Rust borrow and drop-point behavior driven by expression form and edition rules.

2|1|Updated Aug 19, 2026
One-click install
npx skills add https://github.com/po4yka/rust-skills --skill rust-borrow-semantics-po4yka
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: rust-borrow-semantics
Source: https://github.com/po4yka/rust-skills/tree/main/skills/rust-borrow-semantics
Command: npx skills add https://github.com/po4yka/rust-skills --skill rust-borrow-semantics-po4yka

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Rust borrow and drop points often depend on expression form rather than types, so a manual desugaring, a helper call, a macro, or an edition 2024 migration can silently move drop points or break compilation with errors like E0716 and E0502. This Skill provides a systematic method to identify place versus value expressions, temporary scopes, lifetime extension, and two-phase borrows before proposing a fix. ## Core Features & Use Cases - Triage Tables: Maps symptoms like UFCS rewrites failing with E0502, E0716 after adding a helper call, or lock guards releasing earlier on edition 2024 to their likely causes and first actions. - Edition 2024 Migration Review: Covers the if_let_rescope and tail_expr_drop_order lints, narrowed temporary scopes, and how to interpret cargo fix --edition output without turning migration into a lock-lifetime refactor. - Verification Probes: Defines a probe workflow using rustc with the workspace edition and MSRV toolchains, compile_fail tests with named error codes, and runtime assertions like try_lock().is_ok() to prove drop points. - Use Case: After moving a crate to edition 2024, an if let block that held a Mutex guard now releases it early and a race appears; use this Skill to bind the guard to a named local in an explicit block so the drop point is identical on every edition. ## Quick Start Ask the agent to explain why a specific Rust expression fails with E0716 or changes lock behavior after an edition 2024 migration, and have it verify the fix with a minimal probe.

Frequently Asked Questions about rust-borrow-semantics

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
Why does my Rust code fail with E0716 after adding a helper function call?▼

E0716 appears because an ordinary function call does not extend a temporary's lifetime, unlike certain let patterns and constructor arguments. Fix it by naming the owner in a let binding before passing the borrow to the call.

How do I fix Rust lock guards dropping earlier after edition 2024 migration?▼

Edition 2024 narrows if let scrutinee and block-tail temporary scopes, releasing guards earlier. Bind the guard to a named local inside an explicit block so the drop point is explicit and identical across editions.

Why does a UFCS rewrite fail with E0502 when the method call compiles?▼

Method calls create an implicit two-phase borrow that permits shared reads between reservation and activation, but an explicit &mut borrow in a UFCS rewrite is not two-phase. Restore the method-call shape or compute the other argument first.

Does temporary lifetime extension work through tuple struct constructors in Rust?▼

Since Rust 1.89, lifetime extension passes through tuple struct and tuple variant constructor arguments, so Some(&temp()) compiles on stable. On older MSRV toolchains the same code fails with E0716, requiring a named owner binding.

When should I not use clone to fix a Rust borrow error?▼

Clone duplicates ownership without explaining the borrow, so it hides the actual scope problem. Name the owner or add a block for temporary scope issues, and reserve clone for small values or shared read-only state, never resource handles.