Skip to content

Conversation

@Wassasin
Copy link

@Wassasin Wassasin commented Jan 7, 2026

changelog: [large_futures]: changed lint such that it applies to all expressions of type Future.

Currently large_futures is only applicable to expressions on awaits that are a call to a function of which the type is larger than a given threshold.

This means that the lint does not apply if in the code await is never called on the future. Examples of this include running block_on or similar functions, or if the future is passed to an executor. Also it is possible to create futures that are not explicit functions, like async {} blocks, or types that impl Future directly.

This PR attempts to make this lint applicable to all expressions of the type Future. It will try to find the 'deepest' expression in a branch of the expression tree for which this holds, and does not emit a message for any shallower elements in that branch.

Note that this PR currently fails testing as the UI toolkit seems to be very confused about the emitted spans. Multiple messages seem to be emitted for the same span, and the diagnostics do not seem to match at all. Any help concerning this is very appreciated. Example:

error: there were 2 unmatched diagnostics
  --> tests/ui/large_futures.rs:14:9
   |
14 |         big_fut([0u8; 1024 * 16]).await;
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^
   |         |
   |         Error[clippy::large_futures]: usage of large future with a size of 16385 bytes
   |         Error[clippy::large_futures]: usage of large future with a size of 16385 bytes

Relevant code:

async fn wait() {
    let f = async {
        big_fut([0u8; 1024 * 16]).await;
        //~^ large_futures
    };
    f.await
    //~^ large_futures
}

@github-actions
Copy link

github-actions bot commented Jan 7, 2026

Lintcheck changes for 343d882

Lint Added Removed Changed
clippy::large_futures 1 0 0

This comment will be updated if you push new changes

@Wassasin Wassasin marked this pull request as ready for review January 7, 2026 15:22
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Jan 7, 2026
@rustbot
Copy link
Collaborator

rustbot commented Jan 7, 2026

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

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.

3 participants