servo / stylo

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[BUG] Improper dependencies in Stylo

sepcnt opened this issue · comments

Description:

While working with Stylo, I encountered a trait bound error. The error message indicates that the trait serde::Serialize is not implemented for Url, which is required by servo_arc::Arc<Url>: serde::Serialize.

Error Details:

The error occurs in the file ~\.cargo\git\checkouts\stylo-d5871ad1ba1940d3\e2a4834\style\servo\url.rs at line 211. Here is the relevant code and error message:

211 | #[derive(Clone, Debug, Deserialize, MallocSizeOf, PartialEq, Serialize)]
    |                                                              ^^^^^^^^^ the trait `serde::Serialize` is not implemented for `Url`, which is required by `servo_arc::Arc<Url>: serde::Serialize`
...
216 |     Valid(#[ignore_malloc_size_of = "Arc"] Arc<Url>),
    |           ----------------------------------------- required by a bound introduced by this call

Expected Behavior:

The Url type should be serializable as it is used within an Arc in the Valid variant of an enum (or similar data structure).

Actual Behavior:

The compiler throws a trait bound error because Url does not implement serde::Serialize.

I think the "servo" feature (or the "serde" feature) of stylo needs to enable the "serde" feature of the "url" crate. This probably doesn't affect servo because it is already enabling that feature itself.

Also webrender_api may not in malloc_size_of/servo feature set but malloc_size_of/webrender_api

#[cfg(feature = "webrender_api")]
extern crate webrender_api;

This issue is fixed by #9.