Skip to content

Add temporary scope to assert_matches#155431

Open
Voultapher wants to merge 1 commit intorust-lang:mainfrom
Voultapher:add-tmp-scope-to-assert-matches
Open

Add temporary scope to assert_matches#155431
Voultapher wants to merge 1 commit intorust-lang:mainfrom
Voultapher:add-tmp-scope-to-assert-matches

Conversation

@Voultapher
Copy link
Copy Markdown
Contributor

Addresses #154406 in part. assert_eq will be done in a separate PR.

Addresses rust-lang#154406 in part.
assert_eq will be done in a separate PR.
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Apr 17, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Apr 17, 2026

r? @jhpratt

rustbot has assigned @jhpratt.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: libs
  • libs expanded to 6 candidates
  • Random selection from Mark-Simulacrum, jhpratt

@Voultapher
Copy link
Copy Markdown
Contributor Author

r? @Amanieu

@rustbot rustbot assigned Amanieu and unassigned jhpratt Apr 17, 2026
Comment on lines +237 to +238
// Fails to compile if the macros don't introduce a temporary scope, since `&mut val` would
// create a second mutable borrow while `MutRefWithDrop` still holds a unique ref.
Copy link
Copy Markdown
Member

@jieyouxu jieyouxu Apr 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: consider adding a backlink to #154406 for extra context

View changes since the review

Comment on lines +241 to +243
(assert_matches!(*MutRefWithDrop(&mut val).0, 0), std::mem::take(&mut val));

(debug_assert_matches!(*MutRefWithDrop(&mut val).0, 0), std::mem::take(&mut val));
Copy link
Copy Markdown
Contributor

@dianne dianne Apr 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the expansions when there is and isn't a format string are defined separately, maybe it'd be worth having test cases for assert_matches! and debug_assert_matches! with a format string too?

View changes since the review

@dianne dianne added the beta-nominated Nominated for backporting to the compiler in the beta channel. label Apr 17, 2026
@dianne
Copy link
Copy Markdown
Contributor

dianne commented Apr 17, 2026

Beta-nominating per #154406 (comment)

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-review Status: Awaiting review from the assignee but also interested parties. 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.

6 participants