@@ -98,11 +98,39 @@ pub struct Crate {
9898 pub deps : Vec < Dependency > ,
9999 pub cksum : String ,
100100 pub features : HashMap < String , Vec < String > > ,
101+ /// This field contains features with new, extended syntax. Specifically,
102+ /// namespaced features (`dep:`) and weak dependencies (`pkg?/feat`).
103+ ///
104+ /// It is only populated if a feature uses the new syntax. Cargo merges it
105+ /// on top of the `features` field when reading the entries.
106+ ///
107+ /// This is separated from `features` because versions older than 1.19
108+ /// will fail to load due to not being able to parse the new syntax, even
109+ /// with a `Cargo.lock` file.
101110 #[ serde( skip_serializing_if = "Option::is_none" ) ]
102111 pub features2 : Option < HashMap < String , Vec < String > > > ,
103112 pub yanked : Option < bool > ,
104113 #[ serde( default ) ]
105114 pub links : Option < String > ,
115+ /// The schema version for this entry.
116+ ///
117+ /// If this is None, it defaults to version 1. Entries with unknown
118+ /// versions are ignored by cargo starting with 1.51.
119+ ///
120+ /// Version `2` format adds the `features2` field.
121+ ///
122+ /// This provides a method to safely introduce changes to index entries
123+ /// and allow older versions of cargo to ignore newer entries it doesn't
124+ /// understand. This is honored as of 1.51, so unfortunately older
125+ /// versions will ignore it, and potentially misinterpret version 2 and
126+ /// newer entries.
127+ ///
128+ /// The intent is that versions older than 1.51 will work with a
129+ /// pre-existing `Cargo.lock`, but they may not correctly process `cargo
130+ /// update` or build a lock from scratch. In that case, cargo may
131+ /// incorrectly select a new package that uses a new index format. A
132+ /// workaround is to downgrade any packages that are incompatible with the
133+ /// `--precise` flag of `cargo update`.
106134 #[ serde( skip_serializing_if = "Option::is_none" ) ]
107135 pub v : Option < u32 > ,
108136}
0 commit comments