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