@@ -98,11 +98,39 @@ pub struct Crate {
98
98
pub deps : Vec < Dependency > ,
99
99
pub cksum : String ,
100
100
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.
101
110
#[ serde( skip_serializing_if = "Option::is_none" ) ]
102
111
pub features2 : Option < HashMap < String , Vec < String > > > ,
103
112
pub yanked : Option < bool > ,
104
113
#[ serde( default ) ]
105
114
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`.
106
134
#[ serde( skip_serializing_if = "Option::is_none" ) ]
107
135
pub v : Option < u32 > ,
108
136
}
0 commit comments