-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Fix Option<&str> == Option<&String>
build error when using rust_decimal/rkyv feature
#11205
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks all good, thanks!
The change making this explicitly symmetrical sounds good. Surprised that this is the only place in the code base where this
Do I read that message correctly that if those other types are not visible (we don't |
The standard PartialEq impl for Option only applies to |
I am even more confused how this compiled fine before but not with
Right, |
When there are other possible PartialEq impls that could apply, the coercion won't happen. |
FYI @djkoloski. I am not familiar with rkyv so I don't know what impact on the API this would have, but I would recommend looking into removing the PartialEq impls linked above if possible. See also serde-rs/json#380 — we have found that PartialEq in this direction (standard_type == my_type) causes more problems than they are worth. |
…ell#11205) Without this change, projects which depend on both nu-command and rust_decimal's "rkyv" feature cause nu-command to fail to compile. ```toml [dependencies] nu-command = { path = "../nushell/crates/nu-command" } rust_decimal = { version = "1", features = ["rkyv"] } ``` ```console error[E0277]: can't compare `std::option::Option<&str>` with `std::option::Option<&std::string::String>` --> nushell/crates/nu-command/src/filters/join.rs:367:35 | 367 | let k_shared = shared_key == Some(k); | ^^ no implementation for `std::option::Option<&str> == std::option::Option<&std::string::String>` | = help: the trait `PartialEq<std::option::Option<&std::string::String>>` is not implemented for `std::option::Option<&str>` = help: the following other types implement trait `PartialEq<Rhs>`: <std::option::Option<Box<U>> as PartialEq<rkyv::niche::option_box::ArchivedOptionBox<T>>> <std::option::Option<T> as PartialEq> <std::option::Option<U> as PartialEq<rkyv::option::ArchivedOption<T>>> For more information about this error, try `rustc --explain E0277`. warning: `nu-command` (lib) generated 1 warning error: could not compile `nu-command` (lib) due to previous error; 1 warning emitted ```
…ell#11205) Without this change, projects which depend on both nu-command and rust_decimal's "rkyv" feature cause nu-command to fail to compile. ```toml [dependencies] nu-command = { path = "../nushell/crates/nu-command" } rust_decimal = { version = "1", features = ["rkyv"] } ``` ```console error[E0277]: can't compare `std::option::Option<&str>` with `std::option::Option<&std::string::String>` --> nushell/crates/nu-command/src/filters/join.rs:367:35 | 367 | let k_shared = shared_key == Some(k); | ^^ no implementation for `std::option::Option<&str> == std::option::Option<&std::string::String>` | = help: the trait `PartialEq<std::option::Option<&std::string::String>>` is not implemented for `std::option::Option<&str>` = help: the following other types implement trait `PartialEq<Rhs>`: <std::option::Option<Box<U>> as PartialEq<rkyv::niche::option_box::ArchivedOptionBox<T>>> <std::option::Option<T> as PartialEq> <std::option::Option<U> as PartialEq<rkyv::option::ArchivedOption<T>>> For more information about this error, try `rustc --explain E0277`. warning: `nu-command` (lib) generated 1 warning error: could not compile `nu-command` (lib) due to previous error; 1 warning emitted ```
Without this change, projects which depend on both nu-command and rust_decimal's "rkyv" feature cause nu-command to fail to compile.