Skip to content

Regression in nightly-2025-07-19: implementation of FnOnce is not general enough #147244

@dtolnay

Description

@dtolnay

This bisects to #143545 (nightly-2025-07-19 and stable 1.90.0). Previous versions compiled this successfully.

pub fn a() -> impl Future + Send {
    async {
        let queries = core::iter::empty().map(Thing::f);
        b(queries).await;
    }
}

async fn b(queries: impl IntoIterator) {
    c(queries).await;
}

fn c<'a, I>(_queries: I) -> impl Future
where
    I: IntoIterator,
    I::IntoIter: 'a,
{
    async {}
}

pub struct Thing<'a>(pub &'a ());

impl Thing<'_> {
    fn f(_: &Self) {}
}

fn main() {}
error: implementation of `FnOnce` is not general enough
 --> src/main.rs:2:5
  |
2 | /     async {
3 | |         let queries = core::iter::empty().map(Thing::f);
4 | |         b(queries).await;
5 | |     }
  | |_____^ implementation of `FnOnce` is not general enough
  |
  = note: `for<'a> fn(&'a Thing<'0>) {Thing::<'0>::f}` must implement `FnOnce<(&Thing<'1>,)>`, for any two lifetimes `'0` and `'1`...
  = note: ...but it actually implements `FnOnce<(&Thing<'_>,)>`

Metadata

Metadata

Labels

A-async-awaitArea: Async & AwaitC-bugCategory: This is a bug.P-highHigh priorityS-has-bisectionStatus: A bisection has been found for this issueS-has-mcveStatus: A Minimal Complete and Verifiable Example has been found for this issueT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions