Skip to content

Properly handle expansion in single_match #14495

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 31, 2025

Conversation

samueltardieu
Copy link
Contributor

Having a macro call as the scrutinee is supported. However, the proposed suggestion must use the macro call itself, not its expansion.

When the scrutinee is a macro call, do not complain about an irrefutable match, as the user may not be aware of the result of the macro. A comparaison will be suggested instead, as if we couldn't see the outcome of the macro.

Similarly, do not accept macro calls as arm patterns.

changelog: [single_match]: proper suggestions in presence of macros

Fixes #14493

Having a macro call as the scrutinee is supported. However, the proposed
suggestion must use the macro call itself, not its expansion.

When the scrutinee is a macro call, do not complain about an irrefutable
match, as the user may not be aware of the result of the macro. A
comparaison will be suggested instead, as if we couldn't see the outcome
of the macro.

Similarly, do not accept macro calls as arm patterns.
@rustbot
Copy link
Collaborator

rustbot commented Mar 28, 2025

r? @Manishearth

rustbot has assigned @Manishearth.
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

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Mar 28, 2025
@Manishearth Manishearth added this pull request to the merge queue Mar 31, 2025
Merged via the queue into rust-lang:master with commit 7d3d824 Mar 31, 2025
11 checks passed
@samueltardieu samueltardieu deleted the push-vzwzutpyzypq branch March 31, 2025 16:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties
Projects
None yet
Development

Successfully merging this pull request may close these issues.

cargo clippy --fix returns compilation errors when fixing clippy::single_match lint
3 participants