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

compile error[E0310]: the parameter type S/K may not live long enough #200

Open
gigaimage opened this issue Oct 21, 2024 · 1 comment
Open

Comments

@gigaimage
Copy link

zeromq is one of the dependencies in cargo install deno
It fails with the following errors

 Compiling zeromq v0.4.0
error[E0310]: the parameter type `S` may not live long enough
   --> /Users/gigaimage/.cargo/registry/src/index.crates.io-6f17d22bba15001f/zeromq-0.4.0/src/fair_queue.rs:120:29
    |
120 |             let waker_ref = waker_ref(&waker);
    |                             ^^^^^^^^^^^^^^^^^
    |                             |
    |                             the parameter type `S` must be valid for the static lifetime...
    |                             ...so that the type `S` will meet its required lifetime bounds
    |
help: consider adding an explicit lifetime bound
    |
89  |     S: Stream<Item = T> + Send + 'static,
    |                                +++++++++

error[E0310]: the parameter type `K` may not live long enough
   --> /Users/gigaimage/.cargo/registry/src/index.crates.io-6f17d22bba15001f/zeromq-0.4.0/src/fair_queue.rs:120:29
    |
120 |             let waker_ref = waker_ref(&waker);
    |                             ^^^^^^^^^^^^^^^^^
    |                             |
    |                             the parameter type `K` must be valid for the static lifetime...
    |                             ...so that the type `K` will meet its required lifetime bounds
    |
help: consider adding an explicit lifetime bound
    |
90  |     K: Eq + Hash + Unpin + Clone + Send + Sync + 'static,
    |                                                +++++++++

For more information about this error, try `rustc --explain E0310`.
error: could not compile `zeromq` (lib) due to 2 previous errors
warning: build failed, waiting for other jobs to finish...
error: failed to compile `deno v2.0.2`, intermediate artifacts can be found at `/var/folders/_t/c8dp0d8s3p1_pm_m6dj3pr3w0000gn/T/cargo-installa251ik`.
To reuse those artifacts with a future compilation, set the environment variable `CARGO_TARGET_DIR` to that path.
 λ rustc --explain E0310
  A parameter type is missing a lifetime constraint or has a lifetime that does not live long enough.

  Erroneous code example:

  // This won't compile because T is not constrained to the static lifetime
  // the reference needs
  struct Foo<T> {
      foo: &'static T
  }

  Type parameters in type definitions have lifetimes associated with them that represent how long the data stored within them is guaranteed
  to live. This lifetime must be as long as the data needs to be alive, and missing the constraint that denotes this will cause this error.

  This will compile, because it has the constraint on the type parameter:

  struct Foo<T: 'static> {
      foo: &'static T
  }

Workaround as per deno gh: cargo install --locked deno

System config:
λ rustup show
Default host: x86_64-apple-darwin
rustup home: /Users/gigaimage/.rustup

nightly-x86_64-apple-darwin (default)
rustc 1.84.0-nightly (662180b34 2024-10-20)

λ cargo --version
cargo 1.84.0-nightly (cf53cc54b 2024-10-18)

MacOS : 12.7.6 Monterey

@davidlattimore
Copy link
Collaborator

This is fixed in 0.4.1, but you seem to be trying to compile 0.4.0

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

No branches or pull requests

2 participants