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

Removing static compile method; use runtime instances instead #45

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Casuso
Copy link

@Casuso Casuso commented Nov 29, 2022

No description provided.

@cetra3
Copy link
Collaborator

cetra3 commented Dec 15, 2022

Hey thanks for the PR!

I feel like this would change the ergonomics of the library a little bit & interested to see the context/reason behind this change?

@khandar-william
Copy link

Could be related, I got the following compile error while using SP1 zkVM where the guest code contains jmespath

error[E0277]: `(dyn functions::Function + 'static)` cannot be sent between threads safely
   --> /home/builder/.cargo/registry/src/index.crates.io-6f17d22bba15001f/jmespath-0.3.0/src/lib.rs:124:1
    |
124 | / lazy_static! {
125 | |     pub static ref DEFAULT_RUNTIME: Runtime = {
126 | |         let mut runtime = Runtime::new();
127 | |         runtime.register_builtin_functions();
128 | |         runtime
129 | |     };
130 | | }
    | |_^ `(dyn functions::Function + 'static)` cannot be sent between threads safely
    |
    = help: the trait `Send` is not implemented for `(dyn functions::Function + 'static)`, which is required by `Lazy<Runtime>: Sync`
    = note: required for `Unique<(dyn functions::Function + 'static)>` to implement `Send`
note: required because it appears within the type `Box<(dyn functions::Function + 'static)>`
   --> /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/alloc/src/boxed.rs:196:12
    = note: required because it appears within the type `(std::string::String, Box<(dyn functions::Function + 'static)>)`
    = note: required for `hashbrown::raw::RawTable<(std::string::String, Box<(dyn functions::Function + 'static)>)>` to implement `Send`
note: required because it appears within the type `hashbrown::map::HashMap<std::string::String, Box<(dyn functions::Function + 'static)>, RandomState>`
   --> /rust/deps/hashbrown-0.14.3/src/map.rs:190:12
note: required because it appears within the type `HashMap<std::string::String, Box<(dyn functions::Function + 'static)>>`
   --> /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/collections/hash/map.rs:213:12
note: required because it appears within the type `Runtime`
   --> /home/builder/.cargo/registry/src/index.crates.io-6f17d22bba15001f/jmespath-0.3.0/src/runtime.rs:13:12
    |
13  | pub struct Runtime {
    |            ^^^^^^^
    = note: required for `spin::once::Once<Runtime>` to implement `Sync`
note: required because it appears within the type `Lazy<Runtime>`
   --> /home/builder/.cargo/registry/src/index.crates.io-6f17d22bba15001f/lazy_static-1.5.0/src/core_lazy.rs:12:12
    |
12  | pub struct Lazy<T: Sync>(Once<T>);
    |            ^^^^
    = note: shared static variables must have a type that implements `Sync`
    = note: this error originates in the macro `__lazy_static_create` which comes from the expansion of the macro `lazy_static` (in Nightly builds, run with -Z macro-backtrace for more info)

By removing the static DEFAULT_RUNTIME, I assume this error would disappear

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

Successfully merging this pull request may close these issues.

3 participants