Skip to content

Fix result_large_err and result_unit_err not triggering on async functions#17130

Merged
samueltardieu merged 5 commits into
rust-lang:masterfrom
Gri-ffin:fix-17070
Jun 2, 2026
Merged

Fix result_large_err and result_unit_err not triggering on async functions#17130
samueltardieu merged 5 commits into
rust-lang:masterfrom
Gri-ffin:fix-17070

Conversation

@Gri-ffin

@Gri-ffin Gri-ffin commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

fixes #17070

while working on the issue I also found that result_unit_err also had the same problem, which should also be fixed now.

changelog: fix [result_large_err] and [result_unit_err] not triggering on async functions.

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Jun 1, 2026
@rustbot

rustbot commented Jun 1, 2026

Copy link
Copy Markdown
Collaborator

r? @dswij

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

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: 8 candidates
  • 8 candidates expanded to 8 candidates
  • Random selection from Jarcho, dswij, llogiq, samueltardieu

@samueltardieu samueltardieu left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please add specific tests into tests/ui/result_unit_error.rs as well.

View changes since this review

Comment thread tests/ui/len_without_is_empty.rs Outdated
@@ -351,6 +351,7 @@ impl AsyncResultLenWithoutIsEmpty {

pub async fn len(&self) -> Result<usize, ()> {
//~^ len_without_is_empty
//~| result_unit_err

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

You're not testing for this lint here, so you should use #[expect(result_unit_err)] above the function.

Comment thread tests/ui/len_without_is_empty.rs Outdated
@@ -364,6 +365,7 @@ impl AsyncOptionLen {
}

pub async fn len(&self) -> Result<usize, ()> {
//~^ result_unit_err

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Ditto.

Comment thread clippy_lints/src/functions/result.rs Outdated
Comment on lines +45 to +46
if ty.is_diag_item(cx, sym::Result)
&& let ty::Adt(_, args) = ty.kind()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This would do less duplicated work:

Suggested change
if ty.is_diag_item(cx, sym::Result)
&& let ty::Adt(_, args) = ty.kind()
if let ty::Adt(adt_def, args) = ty.kind()
&& cx.tcx.is_diagnostic_item(sym::Result, adt_def.did())

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action from the author. (Use `@rustbot ready` to update this status) and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties labels Jun 2, 2026
@rustbot

rustbot commented Jun 2, 2026

Copy link
Copy Markdown
Collaborator

Reminder, once the PR becomes ready for a review, use @rustbot ready.

@samueltardieu samueltardieu assigned samueltardieu and unassigned dswij Jun 2, 2026
@Gri-ffin

Gri-ffin commented Jun 2, 2026

Copy link
Copy Markdown
Contributor Author

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties and removed S-waiting-on-author Status: This is awaiting some action from the author. (Use `@rustbot ready` to update this status) labels Jun 2, 2026
@samueltardieu samueltardieu added this pull request to the merge queue Jun 2, 2026
Merged via the queue into rust-lang:master with commit 9a3d32b Jun 2, 2026
11 checks passed
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Jun 2, 2026
@Gri-ffin Gri-ffin deleted the fix-17070 branch June 4, 2026 13:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

result_large_err doesn't trigger for async fn that returns a Result

4 participants