@@ -57,11 +57,39 @@ pub struct Crate {
5757 pub deps : Vec < Dependency > ,
5858 pub cksum : String ,
5959 pub features : HashMap < String , Vec < String > > ,
60+ /// This field contains features with new, extended syntax. Specifically,
61+ /// namespaced features (`dep:`) and weak dependencies (`pkg?/feat`).
62+ ///
63+ /// It is only populated if a feature uses the new syntax. Cargo merges it
64+ /// on top of the `features` field when reading the entries.
65+ ///
66+ /// This is separated from `features` because versions older than 1.19
67+ /// will fail to load due to not being able to parse the new syntax, even
68+ /// with a `Cargo.lock` file.
6069 #[ serde( skip_serializing_if = "Option::is_none" ) ]
6170 pub features2 : Option < HashMap < String , Vec < String > > > ,
6271 pub yanked : Option < bool > ,
6372 #[ serde( default ) ]
6473 pub links : Option < String > ,
74+ /// The schema version for this entry.
75+ ///
76+ /// If this is None, it defaults to version 1. Entries with unknown
77+ /// versions are ignored by cargo starting with 1.51.
78+ ///
79+ /// Version `2` format adds the `features2` field.
80+ ///
81+ /// This provides a method to safely introduce changes to index entries
82+ /// and allow older versions of cargo to ignore newer entries it doesn't
83+ /// understand. This is honored as of 1.51, so unfortunately older
84+ /// versions will ignore it, and potentially misinterpret version 2 and
85+ /// newer entries.
86+ ///
87+ /// The intent is that versions older than 1.51 will work with a
88+ /// pre-existing `Cargo.lock`, but they may not correctly process `cargo
89+ /// update` or build a lock from scratch. In that case, cargo may
90+ /// incorrectly select a new package that uses a new index format. A
91+ /// workaround is to downgrade any packages that are incompatible with the
92+ /// `--precise` flag of `cargo update`.
6593 #[ serde( skip_serializing_if = "Option::is_none" ) ]
6694 pub v : Option < u32 > ,
6795}
0 commit comments