#3088·serde

版本锁定的箱子会破坏回退解析器

作者: cuviper创建于 2026年7月24日更新于 2026年7月24日

$ cargo +1.70.0 new hello Created binary (application) hello package $ cd hello/ $ sed -i '/^edition/a Rust-version = "1.70"' Cargo.toml $ cargo +1.70.0 add serde_core@1 serde_derive@1 Updating crates.io index Adding serde_core v1 to dependencies. Features as of v1.0.220: + result + std - alloc - rc - unstable Adding serde_derive v1 to dependencies. Updating crates.io index $ CARGO_RESOLVER_INCOMPATIBLE_RUST_VERSIONS=fallback cargo +stable generate-lockfile Updating crates.io index Locking 6 packages to latest Rust 1.70 compatible versions Adding proc-macro2 v1.0.106 (available: v1.0.107, requires Rust 1.71) Adding quote v1.0.44 (available: v1.0.47, requires Rust 1.71) Adding serde_derive v1.0.229 (requires Rust 1.71) Adding syn v3.0.3 (requires Rust 1.71) Adding unicode-ident v1.0.22 (available: v1.0.24, requires Rust 1.71) $ cargo +1.70.0 check error: package syn v3.0.3 cannot be built because it requires rustc 1.71 or newer, while the currently active rustc version is 1.70.0 Either upgrade to rustc 1.71 or newer, or use cargo update -p [email protected] --precise ver where ver is the latest version of syn supporting rustc 1.70.0 I have to manually downgrade serde_core, still using the fallback resolver to limit syn:

$ CARGO_RESOLVER_INCOMPATIBLE_RUST_VERSIONS=fallback cargo +stable update -p serde_core --precise 1.0.228
    Updating crates.io index
 Downgrading serde_core v1.0.229 -> v1.0.228
 Downgrading serde_derive v1.0.229 -> v1.0.228 (available: v1.0.229, requires Rust 1.71)
 Downgrading syn v3.0.3 -> v2.0.114 (available: v2.0.119, requires Rust 1.71)
note: pass `--verbose` to see 3 unchanged dependencies behind latest
$ cargo +1.70.0 check
   Compiling proc-macro2 v1.0.106
   Compiling quote v1.0.44
   Compiling unicode-ident v1.0.22
   Compiling serde_core v1.0.228
   Compiling syn v2.0.114
   Compiling serde_derive v1.0.228
    Checking hello v0.1.0 ([...]/hello)
    Finished dev [unoptimized + debuginfo] target(s) in 1.77s