Skip to content

don't emit unused_results lint for tuples of "trivial" types #153191

Open
WaffleLapkin wants to merge 2 commits intorust-lang:mainfrom
WaffleLapkin:shouldnt_use_trivial_tuples
Open

don't emit unused_results lint for tuples of "trivial" types #153191
WaffleLapkin wants to merge 2 commits intorust-lang:mainfrom
WaffleLapkin:shouldnt_use_trivial_tuples

Conversation

@WaffleLapkin
Copy link
Member

@WaffleLapkin WaffleLapkin commented Feb 27, 2026

r? @jdonszelmann
Fixes #153144.

So it turns out #153018 had a sneaky behavior change in the way tuples are handled and the old behavior wasn't tested.

Consider these tuples:

((), ());
((), 1);

Neither of them is must_use, so they are potential candidates for unused_results. So the question is whatever said tuples are considered "trivial" and thus if they end up emitting unused_results or not.

Here is a comparison table between PRs:



stableAfter #153018After this PR
((), ()); // trivial
((), 1); // trivial
((), ()); //~ warn: unused_results
((), 1); //~ warn: unused_results
((), ()); // trivial
((), 1); //~ warn: unused_results

tuples are trivial if any of their fields are trivial

tuples are never trivial

tuples are trivial if all of their fields are trivial

@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 Feb 27, 2026
@WaffleLapkin WaffleLapkin force-pushed the shouldnt_use_trivial_tuples branch from 621c007 to 8958cb9 Compare February 27, 2026 16:41
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. 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.

unused_result lint generates warnings for tuples of "trivial" types (such as ((), ()))

3 participants