-
Notifications
You must be signed in to change notification settings - Fork 108
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
Dereference datacenter
of type &&str
when comparing with &str
#838
Conversation
This is interesting. I managed to minimize the problem. New project with the following
But this one does not:
The only difference in Cargo.lock is addition of
I'm not sure yet why that causes any difference when compiling our driver. @piodul wdyt? |
AFAIK the standard library uses the |
Apologizes for a lot of details, feel free to skip to the end. Did some more digging and tried to replicate the impl's resulting from enabling the Then tried multiple permutations of comparing // Ok
fn test_1(a: Option<String>, b: &&str) -> bool {
a.as_deref() == Some(b)
}
// Errors
fn test_2(a: Option<String>, b: &&str) -> bool {
let c = Some(b);
a.as_deref() == c
}
// Errors
fn test_3(a: Option<String>, b: &&str) -> bool {
let c: Option<&&str> = Some(b);
a.as_deref() == c
}
// Ok
fn test_4(a: Option<String>, b: &&str) -> bool {
let c: Option<&str> = Some(b);
a.as_deref() == c
} This seems to indicate that the inference for performing the dereference in I then tried adding Turns out you have to trigger compilation of I unsuccessfully tried to reproduce it in a single crate without deps, but failed. (playground) However, I did manage to reduce the error to just having use rkyv::AlignedVec;
fn does_not_compile() {
assert!(Some("") == Some(&""));
} I opened a repo for this and found rkyv/rkyv#328 which might be related. In any case, I think it is clear that this is not an issue stemming from |
Thanks for the effort. I think we can merge this workaround, but I'd like an issue to be opened in |
Yeah I opened an issue on rkyv! rkyv/rkyv#434 And also managed to track down which struct ArchivedOption<T>(T);
impl<T: PartialEq<U>, U> PartialEq<ArchivedOption<T>> for Option<U> {
fn eq(&self, _: &ArchivedOption<T>) -> bool {
todo!()
}
}
fn test() {
Some("") == Some(&"");
} You can even skip one of the generics: impl<T: PartialEq> PartialEq<ArchivedOption<T>> for Option<T> {
fn eq(&self, _other: &ArchivedOption<T>) -> bool {
todo!()
}
} |
I encountered a compile error when updating from
0.7.0
to0.10.1
:Two more similar errors
When building this repo by itself the error does not occur, which I do not understand, and I'd love to know why if anybody can figure it out. Here's the commit to reproduce.
Introducing these dereferences should not change anything for already working code, but should hopefully fix the issue encountered above.
Pre-review checklist
./docs/source/
.Fixes:
annotations to PR description.