Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
tisonkun opened this issue Feb 8, 2025 · 0 comments
Open

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

tisonkun opened this issue Feb 8, 2025 · 0 comments
Labels
A-async-await Area: Async & Await A-borrow-checker Area: The borrow checker C-bug Category: This is a bug. needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@tisonkun
Copy link
Contributor

tisonkun commented Feb 8, 2025

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>

@tisonkun tisonkun added the C-bug Category: This is a bug. label Feb 8, 2025
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Feb 8, 2025
@jieyouxu jieyouxu added A-borrow-checker Area: The borrow checker T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. A-async-await Area: Async & Await labels Feb 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-async-await Area: Async & Await A-borrow-checker Area: The borrow checker C-bug Category: This is a bug. needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

3 participants