Skip to content

Rollup of 2 pull requests - #163147

Closed
jhpratt wants to merge 5 commits into
rust-lang:mainfrom
jhpratt:rollup-PdRMPxS
Closed

jhpratt wants to merge 5 commits into
rust-lang:mainfrom
jhpratt:rollup-PdRMPxS

Conversation

@jhpratt

@jhpratt jhpratt commented Sep 22, 2026

Copy link
Copy Markdown
Member

Successful merges:

r? @ghost

Create a similar rollup

Albab-Hasan and others added 5 commits August 25, 2026 14:36
parentheses around a pattern passed to a `macro_rules!` metavariable can be
required by the matcher even though they are redundant once expanded, so
suggesting their removal breaks the macro call. a `$p:pat_param` fragment never
accepts a top-level `|` and neither does `$p:pat` before edition 2021.

a metavariable keeps the call site syntax context while the code around it keeps
the macro definition context, so compare the two and reuse the existing
`avoid_or` flag when they differ. parens written inside a macro body share one
context and keep linting as before.
…typeck is tainted

We started to check typeck result's tainted_by_errors in check_pat for LateLint,
But ideally the check should be in a better place which all lints profit from it.
… r=oli-obk

Check tainted_by_error in LateLint

## Context
This PR continues from rust-lang#138679 (comment).
In the last PR, I introduced typeck result's tainted_by_error in check_pat. But as we've discussed, I should put the check to a better place which all lints get benefit from the check.

## Change
Since visit_nested_body in late.rs is the starting point of late lint for a nested body, I moved the error check to the function.
I also rename one ui test case which I introduced in the last PR. I think the new name describes what the test wants to check more.

This PR fixes rust-lang#138361 .

Note that we need to use actually_rustdoc to call typeck_body() in visit_nested_body. Otherwise rustdoc returns an error. However, as its comment describes we shouldn't use actually_rustdoc if there is an alternative solution. So far I only come up with using actually_rustdoc (this change), or checking tainted_by_error in each check_xxx functions (e.g., check on check_pat in rust-lang#138679, and on check_expr for rust-lang#138361).
…t, r=nnethercote

dont lint unused parens on a pattern that came from a macro argument

fixes rust-lang#86959

r? @folkertdev
@rust-bors rust-bors Bot added the rollup A PR which is a rollup label Sep 22, 2026
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Sep 22, 2026
@jhpratt

jhpratt commented Sep 22, 2026

Copy link
Copy Markdown
Member Author

@bors r+ p=5

@rust-bors

rust-bors Bot commented Sep 22, 2026

Copy link
Copy Markdown
Contributor

📌 Commit d34a771 has been approved by jhpratt

It is now in the queue for this repository.

@rust-bors rust-bors Bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Sep 22, 2026
@rust-log-analyzer

Copy link
Copy Markdown
Collaborator

The job test-x86_64-gnu-gcc failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)
test [ui] tests/ui/zero-sized/zero-sized-btreemap-insert.rs ... ok

failures:

---- [ui] tests/ui/lint/unused-parens-macro-pat-issue-86959.rs#e2018 stdout ----
Saved the actual stderr to `/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/lint/unused-parens-macro-pat-issue-86959.e2018/unused-parens-macro-pat-issue-86959.e2018.stderr`
diff of stderr:

18 error: unnecessary parentheses around pattern
19   --> $DIR/unused-parens-macro-pat-issue-86959.rs:54:13
20    |
+ LL | macro_rules! body_or_pat {
+ ...
21 LL |             ('a' | 'A') => {}
22    |             ^^^^^^^^^^^
23 ...

24 LL |     body_or_pat!();
25    |     -------------- in this macro invocation
---
To only update this specific test, also pass `--test-args lint/unused-parens-macro-pat-issue-86959.rs`

error in revision `e2018`: 1 errors occurred comparing output.
status: exit status: 1
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/lint/unused-parens-macro-pat-issue-86959.rs" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2" "-Zcodegen-backend=gcc" "--target=x86_64-unknown-linux-gnu" "--cfg" "e2018" "--check-cfg" "cfg(test,FALSE,e2018,e2021)" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/lint/unused-parens-macro-pat-issue-86959.e2018" "-Znext-solver=coherence" "-A" "unused" "-W" "unused_attributes" "-A" "internal_features" "-A" "incomplete_features" "-A" "unused_parens" "-A" "unused_braces" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--edition=2018"
stdout: none
--- stderr -------------------------------
error: unnecessary parentheses around pattern
##[error]  --> /checkout/tests/ui/lint/unused-parens-macro-pat-issue-86959.rs:76:16
   |
LL |     match_pat!(('a')); //~ ERROR unnecessary parentheses around pattern
   |                ^   ^
   |
note: the lint level is defined here
  --> /checkout/tests/ui/lint/unused-parens-macro-pat-issue-86959.rs:9:9
   |
LL | #![deny(unused_parens)]
   |         ^^^^^^^^^^^^^
help: remove these parentheses
   |
LL -     match_pat!(('a')); //~ ERROR unnecessary parentheses around pattern
LL +     match_pat!('a'); //~ ERROR unnecessary parentheses around pattern
   |

error: unnecessary parentheses around pattern
##[error]  --> /checkout/tests/ui/lint/unused-parens-macro-pat-issue-86959.rs:54:13
   |
LL | macro_rules! body_or_pat {
...
LL |             ('a' | 'A') => {} //~ ERROR unnecessary parentheses around pattern
   |             ^^^^^^^^^^^
...
LL |     body_or_pat!();
   |     -------------- in this macro invocation

error: unnecessary parentheses around pattern
##[error]  --> /checkout/tests/ui/lint/unused-parens-macro-pat-issue-86959.rs:80:9
   |
LL |     let (_x) = 1; //~ ERROR unnecessary parentheses around pattern
   |         ^  ^
   |
help: remove these parentheses
   |
LL -     let (_x) = 1; //~ ERROR unnecessary parentheses around pattern
LL +     let _x = 1; //~ ERROR unnecessary parentheses around pattern
   |

error: aborting due to 3 previous errors
------------------------------------------

---- [ui] tests/ui/lint/unused-parens-macro-pat-issue-86959.rs#e2018 stdout end ----
---- [ui] tests/ui/lint/unused-parens-macro-pat-issue-86959.rs#e2021 stdout ----
Saved the actual stderr to `/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/lint/unused-parens-macro-pat-issue-86959.e2021/unused-parens-macro-pat-issue-86959.e2021.stderr`
diff of stderr:

18 error: unnecessary parentheses around pattern
19   --> $DIR/unused-parens-macro-pat-issue-86959.rs:54:13
20    |
+ LL | macro_rules! body_or_pat {
+ ...
21 LL |             ('a' | 'A') => {}
22    |             ^^^^^^^^^^^
23 ...

24 LL |     body_or_pat!();
25    |     -------------- in this macro invocation
---
To only update this specific test, also pass `--test-args lint/unused-parens-macro-pat-issue-86959.rs`

error in revision `e2021`: 1 errors occurred comparing output.
status: exit status: 1
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/lint/unused-parens-macro-pat-issue-86959.rs" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2" "-Zcodegen-backend=gcc" "--target=x86_64-unknown-linux-gnu" "--cfg" "e2021" "--check-cfg" "cfg(test,FALSE,e2018,e2021)" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/lint/unused-parens-macro-pat-issue-86959.e2021" "-Znext-solver=coherence" "-A" "unused" "-W" "unused_attributes" "-A" "internal_features" "-A" "incomplete_features" "-A" "unused_parens" "-A" "unused_braces" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--edition=2021"
stdout: none
--- stderr -------------------------------
error: unnecessary parentheses around pattern
##[error]  --> /checkout/tests/ui/lint/unused-parens-macro-pat-issue-86959.rs:76:16
   |
LL |     match_pat!(('a')); //~ ERROR unnecessary parentheses around pattern
   |                ^   ^
   |
note: the lint level is defined here
  --> /checkout/tests/ui/lint/unused-parens-macro-pat-issue-86959.rs:9:9
   |
LL | #![deny(unused_parens)]
   |         ^^^^^^^^^^^^^
help: remove these parentheses
   |
LL -     match_pat!(('a')); //~ ERROR unnecessary parentheses around pattern
LL +     match_pat!('a'); //~ ERROR unnecessary parentheses around pattern
   |

error: unnecessary parentheses around pattern
##[error]  --> /checkout/tests/ui/lint/unused-parens-macro-pat-issue-86959.rs:54:13
   |
LL | macro_rules! body_or_pat {
...
LL |             ('a' | 'A') => {} //~ ERROR unnecessary parentheses around pattern
   |             ^^^^^^^^^^^
...
LL |     body_or_pat!();
   |     -------------- in this macro invocation

error: unnecessary parentheses around pattern
##[error]  --> /checkout/tests/ui/lint/unused-parens-macro-pat-issue-86959.rs:80:9
   |
LL |     let (_x) = 1; //~ ERROR unnecessary parentheses around pattern
   |         ^  ^
   |
help: remove these parentheses
   |
LL -     let (_x) = 1; //~ ERROR unnecessary parentheses around pattern
LL +     let _x = 1; //~ ERROR unnecessary parentheses around pattern
   |

error: aborting due to 3 previous errors
------------------------------------------

Important

For more information how to resolve CI failures of this job, visit this link.

@jhpratt jhpratt closed this Sep 22, 2026
@rust-bors rust-bors Bot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Sep 22, 2026
@rust-bors

rust-bors Bot commented Sep 22, 2026

Copy link
Copy Markdown
Contributor

PR #161728, which is a member of this rollup, was unapproved.

This rollup was thus unapproved.

@jhpratt
jhpratt deleted the rollup-PdRMPxS branch September 22, 2026 07:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

rollup A PR which is a rollup S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants