-
Notifications
You must be signed in to change notification settings - Fork 13.3k
rkyv in Rust 1.56: type annotations needed #90195
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Comments
Further information: This is using the |
Reproducer without macros, but still dependent on rkyv: #![allow(dead_code)]
#![allow(unused_variables)]
use rkyv::{Archive, Archived, Deserialize, Fallible};
const ARRAY_SIZE: usize = 32;
struct SomeStruct1 {
buffer_one: Option<[u8; ARRAY_SIZE]>,
buffer_two: Option<[u8; ARRAY_SIZE]>,
}
struct ArchivedSomeStruct1
where
Option<[u8; ARRAY_SIZE]>: ::rkyv::Archive,
Option<[u8; ARRAY_SIZE]>: ::rkyv::Archive,
{
buffer_one: ::rkyv::Archived<Option<[u8; ARRAY_SIZE]>>,
buffer_two: ::rkyv::Archived<Option<[u8; ARRAY_SIZE]>>,
}
struct SomeStruct1Resolver
where
Option<[u8; ARRAY_SIZE]>: ::rkyv::Archive,
Option<[u8; ARRAY_SIZE]>: ::rkyv::Archive,
{
buffer_one: ::rkyv::Resolver<Option<[u8; ARRAY_SIZE]>>,
buffer_two: ::rkyv::Resolver<Option<[u8; ARRAY_SIZE]>>,
}
impl Archive for SomeStruct1
where
Option<[u8; ARRAY_SIZE]>: ::rkyv::Archive,
Option<[u8; ARRAY_SIZE]>: ::rkyv::Archive,
{
type Archived = ArchivedSomeStruct1;
type Resolver = SomeStruct1Resolver;
#[allow(clippy::unit_arg)]
#[inline]
unsafe fn resolve(&self, pos: usize, resolver: Self::Resolver, out: *mut Self::Archived) {
unreachable!();
}
}
impl<__D: Fallible + ?Sized> Deserialize<SomeStruct1, __D> for Archived<SomeStruct1>
where
Option<[u8; ARRAY_SIZE]>: Archive,
Archived<Option<[u8; ARRAY_SIZE]>>: Deserialize<Option<[u8; ARRAY_SIZE]>, __D>,
Option<[u8; ARRAY_SIZE]>: Archive,
Archived<Option<[u8; ARRAY_SIZE]>>: Deserialize<Option<[u8; ARRAY_SIZE]>, __D>,
{
fn deserialize(
&self,
deserializer: &mut __D,
) -> ::core::result::Result<SomeStruct1, __D::Error> {
unreachable!();
}
}
fn main() {} |
Reduced: pub trait Archive {
type Archived;
}
impl<T> Archive for Option<T> {
type Archived = ();
}
pub type Archived<T> = <T as Archive>::Archived;
pub trait Deserialize<D> {}
const ARRAY_SIZE: usize = 32;
impl<__D> Deserialize<__D> for ()
where
Option<[u8; ARRAY_SIZE]>: Archive,
Option<[u8; ARRAY_SIZE]>: Archive,
Archived<Option<[u8; ARRAY_SIZE]>>: Deserialize<__D>,
{
} Also, if you remove one of the
@rustbot label regression-from-stable-to-stable (not sure what happened with rustbot and the labels above) |
@rustbot label -E-needs-mcve |
@rustbot claim |
Assigning priority as discussed in the Zulip thread of the Prioritization Working Group. @rustbot label -I-prioritize +P-high +T-compiler |
Ok, I know what is the problem and have a fix. Apparently when looking for Before #87280 |
Funny thing is it seems like it's fixed already in the master branch... Trying to bisect what fixed it to better understand if my change is needed after all. |
c6b6901 also fixes it. |
Use `is_global` in `candidate_should_be_dropped_in_favor_of` This manifistated in rust-lang#90195 with compiler being unable to keep one candidate for a trait impl, if where is a global impl and more than one trait bound in the where clause. Before rust-lang#87280 `candidate_should_be_dropped_in_favor_of` was using `TypeFoldable::is_global()` that was enough to discard the two `ParamCandidate`s. But rust-lang#87280 changed it to use `TypeFoldable::is_known_global()` instead, which is pessimistic, so now the compiler drops the global impl instead (because `is_known_global` is not sure) and then can't decide between the two `ParamCandidate`s. Switching it to use `is_global` again solves the issue. Fixes rust-lang#90195.
Prior to Rust 1.56, I could use
const usize
values when defining rkyv structs. However, in Rust 1.56, this is no longer allowed.Code
I tried this code:
I expected to see this happen: Prior to Rust 1.56, this compiled.
Instead, this happened: The following error appears:
Version it worked on
It most recently worked on: Rust 1.55
Version with regression
rustc --version --verbose
:The text was updated successfully, but these errors were encountered: