Skip to content

don't leak internal temporaries from dbg!, even on false unwind paths#155915

Open
dianne wants to merge 2 commits intorust-lang:mainfrom
dianne:dbg-via-super-let
Open

don't leak internal temporaries from dbg!, even on false unwind paths#155915
dianne wants to merge 2 commits intorust-lang:mainfrom
dianne:dbg-via-super-let

Conversation

@dianne
Copy link
Copy Markdown
Contributor

@dianne dianne commented Apr 28, 2026

Hopefully fixes #155902 for real this time! See #155902 (comment) and the following comments for why I think matching on a tuple of dbg!'s arguments seems not to be a viable implementation strategy. Instead, this uses super let to get better control over scoping, which unfortunately makes for pretty awkward code with the current version of super let.

One alternative to this would be reverting all the recent changes to dbg! for now and re-landing them once super let's replacement is usable. That will probably be the go-to answer for these tricky scoping problems.

Another alternative would be to change Rust's static semantics to (hopefully) make the match-based dbg! not a problem.

I also noticed std::macros::dbg_internal! seems to be stable in beta (playground), so I've taken the liberty of de-stabilizing it. I can pull that out into a separate PR later if that'd be better, but I figure if we revert the recent changes to dbg!, we'd also be reverting the addition of dbg_internal!, so for now that's here.

This may also need clippy and compiler review, but let's start with r? libs

@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Apr 28, 2026

The Clippy subtree was changed

cc @rust-lang/clippy

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-clippy Relevant to the Clippy team. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. beta-nominated Nominated for backporting to the compiler in the beta channel. labels Apr 28, 2026
Comment thread library/std/src/lib.rs Outdated
@dianne dianne force-pushed the dbg-via-super-let branch from d0ae98f to b896b20 Compare April 28, 2026 11:59
@apiraino
Copy link
Copy Markdown
Contributor

t-compiler will defer backport decision to t-libs since this is almost entirely in their purview

@cuviper
Copy link
Copy Markdown
Member

cuviper commented Apr 28, 2026

Maybe it's worth a crater run compared to stable?

@dianne
Copy link
Copy Markdown
Contributor Author

dianne commented May 2, 2026

@bors try

@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request May 2, 2026
don't leak internal temporaries from `dbg!`, even on false unwind paths
@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors Bot commented May 2, 2026

☀️ Try build successful (CI)
Build commit: 012cd62 (012cd62c9add58ab3910e44c137d87db3ab70f61, parent: 67bcaa9c4b1b1015efae3d591155c79760b1e0a5)

@dianne
Copy link
Copy Markdown
Contributor Author

dianne commented May 3, 2026

I guess for a crater run against stable, we'd need a branch with the commits from this, #154994, #154074, and #149869 cherry-picked? I'll try setting that up as a draft PR against stable.

@cuviper
Copy link
Copy Markdown
Member

cuviper commented May 3, 2026

I just meant stable vs. this nightly -- which will include other changes, but that's true if we beta-backport too. I think we can just do this:

@craterbot check start=1.95.0

@craterbot

This comment was marked as resolved.

@cuviper
Copy link
Copy Markdown
Member

cuviper commented May 3, 2026

@craterbot check start=1.95.0 end=try#012cd62c9add58ab3910e44c137d87db3ab70f61

@craterbot
Copy link
Copy Markdown
Collaborator

👌 Experiment pr-155915 created and queued.
🔍 You can check out the queue and this experiment's details.

ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more

@craterbot craterbot added S-waiting-on-crater Status: Waiting on a crater run to be completed. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

beta-nominated Nominated for backporting to the compiler in the beta channel. S-waiting-on-crater Status: Waiting on a crater run to be completed. T-clippy Relevant to the Clippy team. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1.96 beta regression: "lua does not live long enough", take 2

7 participants