Skip to content

"implementation is not general enough" even if only 'static is used. #136726

Open
@tisonkun

Description

Check fast/fastimer#22 as a small reproduction.

I expected to see this happen:

Since the trait MakeDelay is implemented for &'static MakeTokioDelay and the use point can ensure that only &'static MakeTokioDelay is used, it should compiled.

Actually, with the tricky workaround to eliminate 'static in type (but still in field), the compiler is happy to compile the code.

Instead, this happened:

error: implementation of `MakeDelay` is not general enough
  --> fastimer-tokio/tests/lifetime.rs:49:17
   |
49 |       let spawn = rt1.spawn(async move {
   |  _________________^
50 | |         let mut interval = fastimer::interval(Duration::from_secs(1), timer());
51 | |         for _ in 0..3 {
52 | |             interval.tick().await;
53 | |         }
54 | |     });
   | |______^ implementation of `MakeDelay` is not general enough
   |
   = note: `&'0 MakeTokioDelay` must implement `MakeDelay`, for any lifetime `'0`...
   = note: ...but `MakeDelay` is actually implemented for the type `&'static MakeTokioDelay`

Meta

rustc --version --verbose:

rustc 1.84.0 (9fc6b4312 2025-01-07)
binary: rustc
commit-hash: 9fc6b43126469e3858e2fe86cafb4f0fd5068869
commit-date: 2025-01-07
host: aarch64-apple-darwin
release: 1.84.0
LLVM version: 19.1.5

Can reproduce with:

rustc 1.86.0-nightly (854f22563 2025-01-31)
binary: rustc
commit-hash: 854f22563c8daf92709fae18ee6aed52953835cd
commit-date: 2025-01-31
host: aarch64-apple-darwin
release: 1.86.0-nightly
LLVM version: 19.1.7
Backtrace

<backtrace>

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    A-async-awaitArea: Async & AwaitA-borrow-checkerArea: The borrow checkerC-bugCategory: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions