Skip to content

Conversation

benschulz
Copy link

Given a type alias as follows, clippy would detect a false positive for unused_unit.

type UnusedParensButNoUnit = Box<dyn (Fn())>;

changelog: [unused_unit]: fix false positive for Fn bounds

@rustbot
Copy link
Collaborator

rustbot commented Jun 3, 2025

r? @llogiq

rustbot has assigned @llogiq.
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 Jun 3, 2025
&& let AssocItemConstraintKind::Equality { term: Term::Ty(hir_ty) } = constraints[0].kind
&& args.span_ext.hi() != poly.span.hi()
&& !hir_ty.span.from_expansion()
&& args.span_ext.hi() != hir_ty.span.hi()
Copy link
Author

@benschulz benschulz Jun 3, 2025

Choose a reason for hiding this comment

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

Perhaps this should have been covered by !hir_ty.span.from_expansion(). Certainly, there are no explicit -> () tokens in the source. If this is the case, I'm happy to close this PR and file an issue upstream.

Copy link
Contributor

Choose a reason for hiding this comment

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

Those expansion checks are quite finicky; sometimes you have an expression without expansion but a subexpression expanded, etc. So as long as this appears to fix the issue, it's better than nothing.

}

mod pr14962 {
#[allow(unused_parens)]
Copy link
Member

Choose a reason for hiding this comment

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

Since this is a targeted lint, could you please use #[expect(unused_parens)] instead? That doubles as an extra free test for unused_parens that would force us to think about it if its behavior changes.

Copy link
Author

Choose a reason for hiding this comment

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

This does not actually emit a warning by rustc yet. I'm currently looking into why that is exactly. I can remove the attribute and change the name of the type alias if you want.

@llogiq llogiq added this pull request to the merge queue Jun 5, 2025
@llogiq
Copy link
Contributor

llogiq commented Jun 5, 2025

Thank you.

Merged via the queue into rust-lang:master with commit 6bb0c97 Jun 5, 2025
11 checks passed
@benschulz benschulz deleted the unused-unit-false-positive branch June 5, 2025 19:54
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.

4 participants