Skip to content

Conversation

@chenyukang
Copy link
Member

@chenyukang chenyukang commented Feb 2, 2026

Extends the unused_parens lint to detect unnecessary parentheses around method receivers like (x).method().

Fixes #151985

@rustbot
Copy link
Collaborator

rustbot commented Feb 2, 2026

compiler-builtins is developed in its own repository. If possible, consider making this change to rust-lang/compiler-builtins instead.

cc @tgross35

@rustbot rustbot added the A-compiler-builtins Area: compiler-builtins (https://github.com/rust-lang/compiler-builtins) label Feb 2, 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. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Feb 2, 2026
@rustbot
Copy link
Collaborator

rustbot commented Feb 2, 2026

r? @jieyouxu

rustbot has assigned @jieyouxu.
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
Copy link
Collaborator

rustbot commented Feb 2, 2026

⚠️ Warning ⚠️

  • There are issue links (such as #123) in the commit messages of the following commits.
    Please move them to the PR description, to avoid spamming the issues with references to the commit, and so this bot can automatically canonicalize them to avoid issues with subtree.

@chenyukang chenyukang closed this Feb 2, 2026
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Feb 2, 2026
@chenyukang chenyukang reopened this Feb 2, 2026
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Feb 2, 2026
@chenyukang chenyukang marked this pull request as draft February 2, 2026 08:36
@rustbot rustbot 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-review Status: Awaiting review from the assignee but also interested parties. labels Feb 2, 2026
@chenyukang chenyukang force-pushed the yukang-fix-151985-unused-parens-method-receiver branch from c1b3bf0 to c6acedc Compare February 2, 2026 08:39
},
alloc,
));
let uninit_ptr: NonNull<_> = (unsafe { &mut *uninit_raw_ptr }).into();
Copy link
Member Author

Choose a reason for hiding this comment

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

seems better add parens for unsafe block?

@rust-log-analyzer

This comment has been minimized.

@chenyukang chenyukang force-pushed the yukang-fix-151985-unused-parens-method-receiver branch from c6acedc to 89085e5 Compare February 2, 2026 08:57
@rust-log-analyzer

This comment has been minimized.

@chenyukang chenyukang force-pushed the yukang-fix-151985-unused-parens-method-receiver branch from 926cf7d to dc54301 Compare February 2, 2026 09:58
@rust-log-analyzer

This comment has been minimized.

@chenyukang chenyukang force-pushed the yukang-fix-151985-unused-parens-method-receiver branch from dc54301 to 5733cfa Compare February 2, 2026 11:06
@rust-log-analyzer

This comment has been minimized.

@chenyukang chenyukang force-pushed the yukang-fix-151985-unused-parens-method-receiver branch from 5733cfa to 39cd80f Compare February 2, 2026 11:36
@rust-log-analyzer

This comment has been minimized.

@chenyukang chenyukang force-pushed the yukang-fix-151985-unused-parens-method-receiver branch from 39cd80f to 823f304 Compare February 2, 2026 12:10
@rust-log-analyzer

This comment has been minimized.

@chenyukang chenyukang force-pushed the yukang-fix-151985-unused-parens-method-receiver branch from 823f304 to 4a5a8e7 Compare February 2, 2026 12:51
@rustbot rustbot added the T-rust-analyzer Relevant to the rust-analyzer team, which will review and decide on the PR/issue. label Feb 2, 2026
@rust-log-analyzer

This comment has been minimized.

@chenyukang chenyukang force-pushed the yukang-fix-151985-unused-parens-method-receiver branch from 4a5a8e7 to d657d00 Compare February 2, 2026 13:32
@rust-log-analyzer

This comment has been minimized.

@chenyukang chenyukang force-pushed the yukang-fix-151985-unused-parens-method-receiver branch from d657d00 to d18d47c Compare February 2, 2026 14:24
@rust-log-analyzer
Copy link
Collaborator

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

Click to see the possible cause of the failure (guessed by this bot)
REPOSITORY                                   TAG       IMAGE ID       CREATED      SIZE
ghcr.io/dependabot/dependabot-updater-core   latest    bcec0b4e062b   6 days ago   783MB
=> Removing docker images...
Deleted Images:
untagged: ghcr.io/dependabot/dependabot-updater-core:latest
untagged: ghcr.io/dependabot/dependabot-updater-core@sha256:b662be51f7b8ef7e2c8464428f14e49cb79c36aa9afb7ecb9221dfe0f507050c
deleted: sha256:bcec0b4e062b5ffe11cc1c2729558c0cd96621c0271ab5e97ff3a56e0c25045a
deleted: sha256:64e147d5e54d9be8b8aa322e511cda02296eda4b8b8d063c6a314833aca50e29
deleted: sha256:5cba409bb463f4e7fa1a19f695450170422582c1bc7c0e934d893b4e5f558bc6
deleted: sha256:cddc6ebd344b0111eaab170ead1dfda24acdfe865ed8a12599a34d338fa8e28b
deleted: sha256:2412c3f334d79134573cd45e657fb6cc0abd75bef3881458b0d498d936545c8d
---
tests/pass/shims/x86/rounding-error.rs ... ok
tests/pass/shims/x86/intrinsics-x86-gfni.rs ... ok

FAILED TEST: tests/pass/u128.rs
command: MIRI_ENV_VAR_TEST="0" MIRI_TEMP="/tmp/miri-uitest-p1BMJS" RUST_BACKTRACE="1" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/miri" "--error-format=json" "--sysroot=/checkout/obj/build/x86_64-unknown-linux-gnu/miri-sysroot" "-Dwarnings" "-Dunused" "-Ainternal_features" "-Zui-testing" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/tmp/miri_ui/0/tests/pass" "tests/pass/u128.rs" "--edition" "2021"

error: test got exit status: 1, but expected 0
 = note: compilation failed, but was expected to succeed

error: no output was expected
Execute `./miri test --bless` to update `tests/pass/u128.stderr` to the actual output
+++ <stderr output>
error: unnecessary parentheses around method receiver
##[error]  --> tests/pass/u128.rs:60:16
   |
LL |     assert_eq!((z).checked_mul(z), Some(0x734C_C2F2_A521));
   |                ^ ^
   |
   = note: `-D unused-parens` implied by `-D unused`
   = help: to override `-D unused` add `#[allow(unused_parens)]`
help: remove these parentheses
   |
LL -     assert_eq!((z).checked_mul(z), Some(0x734C_C2F2_A521));
LL +     assert_eq!(z .checked_mul(z), Some(0x734C_C2F2_A521));
   |

error: unnecessary parentheses around method receiver
##[error]  --> tests/pass/u128.rs:61:16
   |
LL |     assert_eq!((k).checked_mul(k), None);
   |                ^ ^
   |
help: remove these parentheses
   |
LL -     assert_eq!((k).checked_mul(k), None);
LL +     assert_eq!(k .checked_mul(k), None);
   |

error: aborting due to 2 previous errors



full stderr:
error: unnecessary parentheses around method receiver
##[error]  --> tests/pass/u128.rs:60:16
   |
LL |     assert_eq!((z).checked_mul(z), Some(0x734C_C2F2_A521));
   |                ^ ^
   |
   = note: `-D unused-parens` implied by `-D unused`
   = help: to override `-D unused` add `#[allow(unused_parens)]`
help: remove these parentheses
   |
LL -     assert_eq!((z).checked_mul(z), Some(0x734C_C2F2_A521));
LL +     assert_eq!(z .checked_mul(z), Some(0x734C_C2F2_A521));
   |

error: unnecessary parentheses around method receiver
##[error]  --> tests/pass/u128.rs:61:16
   |
LL |     assert_eq!((k).checked_mul(k), None);
   |                ^ ^
   |
help: remove these parentheses
   |
LL -     assert_eq!((k).checked_mul(k), None);
LL +     assert_eq!(k .checked_mul(k), None);
   |

error: aborting due to 2 previous errors


---
Location:
   /cargo/registry/src/index.crates.io-1949cf8c6b5b557f/ui_test-0.30.3/src/lib.rs:365

  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ BACKTRACE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
   1: <color_eyre[c347bb8439eedf52]::config::EyreHook>::into_eyre_hook::{closure#0}<unknown>
      at <unknown source file>:<unknown line>
   2: <eyre[b6a35a05bd5c1b8b]::Report>::from_adhoc::<&str><unknown>
      at <unknown source file>:<unknown line>
   3: ui_test[4e0397377b429e93]::run_tests_generic::<ui_test[4e0397377b429e93]::default_file_filter, ui[7bc7edd0f8f5024a]::run_tests::{closure#1}, alloc[d3205064c01c8e3c]::boxed::Box<dyn ui_test[4e0397377b429e93]::status_emitter::StatusEmitter>><unknown>
      at <unknown source file>:<unknown line>
   4: ui[7bc7edd0f8f5024a]::ui<unknown>
      at <unknown source file>:<unknown line>
   5: ui[7bc7edd0f8f5024a]::main<unknown>
      at <unknown source file>:<unknown line>
   6: std[f28e0ef05a2fcfdc]::sys::backtrace::__rust_begin_short_backtrace::<fn() -> core[9864d63c68801c6d]::result::Result<(), eyre[b6a35a05bd5c1b8b]::Report>, core[9864d63c68801c6d]::result::Result<(), eyre[b6a35a05bd5c1b8b]::Report>><unknown>
      at <unknown source file>:<unknown line>
   7: std[f28e0ef05a2fcfdc]::rt::lang_start::<core[9864d63c68801c6d]::result::Result<(), eyre[b6a35a05bd5c1b8b]::Report>>::{closure#0}<unknown>
      at <unknown source file>:<unknown line>
   8: std[f28e0ef05a2fcfdc]::rt::lang_start_internal<unknown>
      at <unknown source file>:<unknown line>
   9: main<unknown>
      at <unknown source file>:<unknown line>
  10: __libc_start_main<unknown>
      at <unknown source file>:<unknown line>
  11: _start<unknown>
      at <unknown source file>:<unknown line>

Run with COLORBT_SHOW_HIDDEN=1 environment variable to disable frame filtering.
Run with RUST_BACKTRACE=full to include source snippets.
error: test failed, to rerun pass `--test ui`

Caused by:
  process didn't exit successfully: `/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps/ui-399d57cbacaa656d` (exit status: 1)
Bootstrap failed while executing `test --stage 2 src/tools/miri src/tools/miri/cargo-miri`
Command `/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo test -Zwarnings --target x86_64-unknown-linux-gnu -Zbinary-dep-depinfo -j 4 -Zroot-dir=/checkout --locked --color=always --profile=release --manifest-path /checkout/src/tools/miri/Cargo.toml -- [workdir=/checkout]` failed with exit code 1
Created at: src/bootstrap/src/core/build_steps/tool.rs:191:21
Executed at: src/bootstrap/src/core/build_steps/test.rs:738:19

Command has failed. Rerun with -v to see more details.
Build completed unsuccessfully in 0:40:48
  local time: Mon Feb  2 15:12:55 UTC 2026
  network time: Mon, 02 Feb 2026 15:12:55 GMT
##[error]Process completed with exit code 1.
##[group]Run echo "disk usage:"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-compiler-builtins Area: compiler-builtins (https://github.com/rust-lang/compiler-builtins) 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. T-libs Relevant to the library team, which will review and decide on the PR/issue. T-rust-analyzer Relevant to the rust-analyzer team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

unused_parens does not lint parentheses around method receiver

4 participants