From 92f3ddcabd53ceab61f06b6438f8a11a75b72bed Mon Sep 17 00:00:00 2001 From: matt rice Date: Sat, 9 Nov 2024 12:22:23 +0000 Subject: [PATCH] Fix inference conflict with `serde_json` through `schemars` feature (#733) Initially marking as a draft, because this currently just fiddles with Cargo.toml to ensure that CI tests the feature. this shouldn't actually require any changes to our CI scripts to trigger, and as Daniel suggested, this uses a feature on with_winit rather than vello itself. Will follow up with the actual fix once I've confirmed CI fails. --------- Co-authored-by: Daniel McNab <36049421+DJMcNab@users.noreply.github.com> --- Cargo.lock | 44 ++++++++++++++++++++++++++++++++++ Cargo.toml | 4 ++++ examples/with_winit/Cargo.toml | 4 ++++ examples/with_winit/src/lib.rs | 9 +++++++ vello/src/scene.rs | 4 +++- 5 files changed, 64 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index 0af5a81f3..7837a2a2e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -631,6 +631,12 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f25c0e292a7ca6d6498557ff1df68f32c99850012b6ea401cf8daf771f22ff53" +[[package]] +name = "dyn-clone" +version = "1.0.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d6ef0072f8a535281e4876be788938b528e9a1d43900b82c2569af7da799125" + [[package]] name = "env_filter" version = "0.1.2" @@ -1145,6 +1151,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "89234b2cc610a7dd927ebde6b41dd1a5d4214cffaef4cf1fb2195d592f92518f" dependencies = [ "arrayvec", + "schemars", "smallvec", ] @@ -2010,6 +2017,31 @@ dependencies = [ "web-time", ] +[[package]] +name = "schemars" +version = "0.8.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09c024468a378b7e36765cd36702b7a90cc3cba11654f6685c8f233408e89e92" +dependencies = [ + "dyn-clone", + "schemars_derive", + "serde", + "serde_json", + "smallvec", +] + +[[package]] +name = "schemars_derive" +version = "0.8.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1eee588578aff73f856ab961cd2f79e36bc45d7ded33a7562adba4667aecc0e" +dependencies = [ + "proc-macro2", + "quote", + "serde_derive_internals", + "syn 2.0.85", +] + [[package]] name = "scoped-tls" version = "1.0.1" @@ -2086,6 +2118,17 @@ dependencies = [ "syn 2.0.85", ] +[[package]] +name = "serde_derive_internals" +version = "0.29.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "18d26a20a969b9e3fdf2fc2d9f21eda6c40e2de84c9408bb5d3b05d499aae711" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.85", +] + [[package]] name = "serde_json" version = "1.0.132" @@ -3331,6 +3374,7 @@ dependencies = [ "console_log", "env_logger", "getrandom", + "kurbo", "log", "notify-debouncer-mini", "pollster", diff --git a/Cargo.toml b/Cargo.toml index 624d17817..7ee90a60c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -44,7 +44,11 @@ vello_encoding = { version = "0.3.0", path = "vello_encoding" } vello_shaders = { version = "0.3.0", path = "vello_shaders" } bytemuck = { version = "1.18.0", features = ["derive"] } skrifa = "0.22.3" +# The version of kurbo used below should be kept in sync +# with the version of kurbo used by peniko. peniko = "0.2.0" +# FIXME: This can be removed once peniko supports the schemars feature. +kurbo = "0.11.1" futures-intrusive = "0.5.0" raw-window-handle = "0.6.2" smallvec = "1.13.2" diff --git a/examples/with_winit/Cargo.toml b/examples/with_winit/Cargo.toml index cf330c3ee..34d4c8860 100644 --- a/examples/with_winit/Cargo.toml +++ b/examples/with_winit/Cargo.toml @@ -16,6 +16,8 @@ default = ["wgpu-profiler"] # Enable the use of wgpu-profiler. This is an optional feature for times when we use a git dependency on # wgpu (which means the dependency used in wgpu-profiler would be incompatible) wgpu-profiler = ["dep:wgpu-profiler", "vello/wgpu-profiler"] +# Test for dependencies which implement std traits in ways that cause type inference issues. +_ci_dep_features_to_test = ["dep:kurbo", "kurbo/schemars"] [lints] workspace = true @@ -41,6 +43,8 @@ log = { workspace = true } # We're still using env-logger, but we want to use tracing spans to allow using # tracing_android_trace tracing = { version = "0.1.40", features = ["log-always"] } +# For _ci_dep_features_to_test feature tests. +kurbo = { workspace = true, optional = true } [target.'cfg(not(target_os = "android"))'.dependencies] # We use android_logger on Android diff --git a/examples/with_winit/src/lib.rs b/examples/with_winit/src/lib.rs index e3771e194..f13bbd651 100644 --- a/examples/with_winit/src/lib.rs +++ b/examples/with_winit/src/lib.rs @@ -945,3 +945,12 @@ fn android_main(app: AndroidApp) { run(event_loop, args, scenes, render_cx); } + +#[cfg(all(feature = "_ci_dep_features_to_test", test))] +#[test] +// This just tests that the "kurbo" dependency we enable schemars for +// aligns to the same version that vello's peniko dependency resolves to. +fn test_kurbo_schemars_with_peniko() { + use std::marker::PhantomData; + let _: PhantomData = PhantomData::; +} diff --git a/vello/src/scene.rs b/vello/src/scene.rs index d3b3e1930..83c5fc3eb 100644 --- a/vello/src/scene.rs +++ b/vello/src/scene.rs @@ -536,7 +536,9 @@ impl<'a> DrawGlyphs<'a> { EmojiLikeGlyph::Bitmap(bitmap) => { let image = match bitmap.data { bitmap::BitmapData::Bgra(data) => { - if bitmap.width * bitmap.height * 4 != data.len().try_into().unwrap() { + if bitmap.width * bitmap.height * 4 + != u32::try_from(data.len()).unwrap() + { // TODO: Error once? log::error!("Invalid font"); continue;