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

Add Send trait marker #21

Merged
merged 1 commit into from
Aug 6, 2019
Merged

Add Send trait marker #21

merged 1 commit into from
Aug 6, 2019

Conversation

mojzu
Copy link
Contributor

@mojzu mojzu commented Jul 1, 2019

Hi, after upgrading some dependencies of a project I'm working on I received the following compilation error:

error[E0277]: `(dyn matching::Matcher + 'static)` cannot be sent between threads safely
  --> /home/sam/.cargo/git/checkouts/zxcvbn-rs-e38ddaa4af95d3f0/213b5ee/src/matching/mod.rs:71:1
   |
71 | / lazy_static! {
72 | |     static ref MATCHERS: [Box<Matcher>; 8] = [
73 | |         Box::new(DictionaryMatch {}),
74 | |         Box::new(ReverseDictionaryMatch {}),
...  |
81 | |     ];
82 | | }
   | |_^ `(dyn matching::Matcher + 'static)` cannot be sent between threads safely
   |
   = help: the trait `std::marker::Send` is not implemented for `(dyn matching::Matcher + 'static)`
   = note: required because of the requirements on the impl of `std::marker::Send` for `std::ptr::Unique<(dyn matching::Matcher + 'static)>`
   = note: required because it appears within the type `std::boxed::Box<(dyn matching::Matcher + 'static)>`
   = note: required because it appears within the type `[std::boxed::Box<(dyn matching::Matcher + 'static)>; 8]`
   = note: required because of the requirements on the impl of `std::marker::Sync` for `spin::once::Once<[std::boxed::Box<(dyn matching::Matcher + 'static)>; 8]>`
   = note: required because it appears within the type `lazy_static::lazy::Lazy<[std::boxed::Box<(dyn matching::Matcher + 'static)>; 8]>`
   = note: shared static variables must have a type that implements `Sync`
   = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)

I was able to fix it by forking and adding the Send marker trait to Matcher. I'm still new to Rust so if this isn't correct please feel free to disregard this.

@tglman
Copy link

tglman commented Jul 13, 2019

Hi,

I've exactly the same compilation problem with the last rust stable (1.36.0), would be cool if this fix will be accepted and published.

Regards

@shssoichiro
Copy link
Owner

Thanks, and sorry for the delay on merging this!

@shssoichiro shssoichiro merged commit 4a4999c into shssoichiro:master Aug 6, 2019
@mojzu
Copy link
Contributor Author

mojzu commented Aug 6, 2019

Thanks for the merge. No problem about the delay, working out how to fix this was a good learning experience 👍

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