archrelease: copy trunk to extra-x86_64
[arch-packages.git] / thunderbird / trunk / rustc_version-0.4.0.patch
blob9f50bca5c59881fd916154f9b8d27d0786598ccd
2 # HG changeset patch
3 # User Mike Hommey <mh+mozilla@glandium.org>
4 # Date 1654596092 0
5 # Node ID f52e2ad948e88e2c4ce83599d379aa4a1e57334e
6 # Parent 969171da8cc09d4eb7c070b0ecf33bc5cc504537
7 Bug 1772048 - Update rustc_version and semver crates. r=emilio,webdriver-reviewers,kinetik,whimboo
9 semver 1.0 doesn't and won't support Clone on semver::Error[1], so we
10 convert the mozversion error type to store the string version of the
11 error, which is an incompatible change requiring a version bump on the
12 crate.
14 1. https://github.com/dtolnay/semver/pull/280
16 Differential Revision: https://phabricator.services.mozilla.com/D147825
18 diff --git a/.cargo/config.in b/.cargo/config.in
19 --- a/.cargo/config.in
20 +++ b/.cargo/config.in
21 @@ -25,17 +25,17 @@ rev = "3bfc47d9a571d0842676043ba60716318
22 [source."https://github.com/mozilla/midir.git"]
23 git = "https://github.com/mozilla/midir.git"
24 replace-with = "vendored-sources"
25 rev = "4c11f0ffb5d6a10de4aff40a7b81218b33b94e6f"
27 [source."https://github.com/mozilla/cubeb-pulse-rs"]
28 git = "https://github.com/mozilla/cubeb-pulse-rs"
29 replace-with = "vendored-sources"
30 -rev = "df4dc0288b07b865440f4c7e41ca49ca9ccffc63"
31 +rev = "1f1fe1e08e01a9a534ec7f079702a583a0899ce7"
33 [source."https://github.com/mozilla/cubeb-coreaudio-rs"]
34 git = "https://github.com/mozilla/cubeb-coreaudio-rs"
35 replace-with = "vendored-sources"
36 rev = "44eca95823bb57e964cf7b6d9791ed2ccb4b2108"
38 [source."https://github.com/mozilla/audioipc"]
39 git = "https://github.com/mozilla/audioipc"
40 diff --git a/Cargo.lock b/Cargo.lock
41 --- a/Cargo.lock
42 +++ b/Cargo.lock
43 @@ -1157,17 +1157,17 @@ dependencies = [
44 "mach",
45 "ringbuf",
46 "triple_buffer",
49 [[package]]
50 name = "cubeb-pulse"
51 version = "0.4.0"
52 -source = "git+https://github.com/mozilla/cubeb-pulse-rs?rev=df4dc0288b07b865440f4c7e41ca49ca9ccffc63#df4dc0288b07b865440f4c7e41ca49ca9ccffc63"
53 +source = "git+https://github.com/mozilla/cubeb-pulse-rs?rev=1f1fe1e08e01a9a534ec7f079702a583a0899ce7#1f1fe1e08e01a9a534ec7f079702a583a0899ce7"
54 dependencies = [
55 "cubeb-backend",
56 "pulse",
57 "pulse-ffi",
58 "ringbuf",
59 "semver",
62 @@ -3399,17 +3399,17 @@ dependencies = [
63 "nsstring",
64 "url",
65 "uuid",
66 "xpcom",
69 [[package]]
70 name = "mozversion"
71 -version = "0.4.3"
72 +version = "0.5.0-alpha"
73 dependencies = [
74 "regex",
75 "rust-ini",
76 "semver",
79 [[package]]
80 name = "mozwer_s"
81 @@ -4122,26 +4122,26 @@ dependencies = [
82 "proc-macro2",
83 "quote",
84 "syn",
87 [[package]]
88 name = "pulse"
89 version = "0.3.0"
90 -source = "git+https://github.com/mozilla/cubeb-pulse-rs?rev=df4dc0288b07b865440f4c7e41ca49ca9ccffc63#df4dc0288b07b865440f4c7e41ca49ca9ccffc63"
91 +source = "git+https://github.com/mozilla/cubeb-pulse-rs?rev=1f1fe1e08e01a9a534ec7f079702a583a0899ce7#1f1fe1e08e01a9a534ec7f079702a583a0899ce7"
92 dependencies = [
93 "bitflags",
94 "pulse-ffi",
97 [[package]]
98 name = "pulse-ffi"
99 version = "0.1.0"
100 -source = "git+https://github.com/mozilla/cubeb-pulse-rs?rev=df4dc0288b07b865440f4c7e41ca49ca9ccffc63#df4dc0288b07b865440f4c7e41ca49ca9ccffc63"
101 +source = "git+https://github.com/mozilla/cubeb-pulse-rs?rev=1f1fe1e08e01a9a534ec7f079702a583a0899ce7#1f1fe1e08e01a9a534ec7f079702a583a0899ce7"
102 dependencies = [
103 "libc",
106 [[package]]
107 name = "qcms"
108 version = "0.2.0"
109 dependencies = [
110 @@ -4456,19 +4456,19 @@ checksum = "7ef03e0a2b150c7a90d01faf6254
111 [[package]]
112 name = "rustc-hash"
113 version = "1.1.0"
114 source = "registry+https://github.com/rust-lang/crates.io-index"
115 checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2"
117 [[package]]
118 name = "rustc_version"
119 -version = "0.2.3"
120 -source = "registry+https://github.com/rust-lang/crates.io-index"
121 -checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a"
122 +version = "0.4.0"
123 +source = "registry+https://github.com/rust-lang/crates.io-index"
124 +checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366"
125 dependencies = [
126 "semver",
129 [[package]]
130 name = "ryu"
131 version = "1.0.10"
132 source = "registry+https://github.com/rust-lang/crates.io-index"
133 @@ -4544,28 +4544,19 @@ dependencies = [
134 [[package]]
135 name = "self_cell"
136 version = "0.10.2"
137 source = "registry+https://github.com/rust-lang/crates.io-index"
138 checksum = "1ef965a420fe14fdac7dd018862966a4c14094f900e1650bbc71ddd7d580c8af"
140 [[package]]
141 name = "semver"
142 -version = "0.9.0"
143 -source = "registry+https://github.com/rust-lang/crates.io-index"
144 -checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403"
145 -dependencies = [
146 - "semver-parser",
149 -[[package]]
150 -name = "semver-parser"
151 -version = "0.7.0"
152 -source = "registry+https://github.com/rust-lang/crates.io-index"
153 -checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3"
154 +version = "1.0.9"
155 +source = "registry+https://github.com/rust-lang/crates.io-index"
156 +checksum = "8cb243bdfdb5936c8dc3c45762a19d12ab4550cdc753bc247637d4ec35a040fd"
158 [[package]]
159 name = "serde"
160 version = "1.0.136"
161 source = "registry+https://github.com/rust-lang/crates.io-index"
162 checksum = "ce31e24b01e1e524df96f1c2fdd054405f8d7376249a5110886fb4b658484789"
163 dependencies = [
164 "serde_derive",
165 diff --git a/gfx/qcms/Cargo.toml b/gfx/qcms/Cargo.toml
166 --- a/gfx/qcms/Cargo.toml
167 +++ b/gfx/qcms/Cargo.toml
168 @@ -17,9 +17,9 @@ c_bindings = ["libc"]
169 neon = []
170 iccv4-enabled = []
171 cmyk = []
173 [dependencies]
174 libc = {version = "0.2", optional = true }
176 [build-dependencies]
177 -rustc_version = "0.2"
178 +rustc_version = "0.4"
179 diff --git a/mozglue/static/rust/Cargo.toml b/mozglue/static/rust/Cargo.toml
180 --- a/mozglue/static/rust/Cargo.toml
181 +++ b/mozglue/static/rust/Cargo.toml
182 @@ -8,12 +8,12 @@ license = "MPL"
183 path = "lib.rs"
185 [dependencies]
186 arrayvec = "0.5"
188 [build-dependencies]
189 mozbuild = "0.1"
190 cc = "1"
191 -rustc_version = "0.2"
192 +rustc_version = "0.4"
194 [features]
195 moz_memory = []
196 diff --git a/testing/geckodriver/Cargo.toml b/testing/geckodriver/Cargo.toml
197 --- a/testing/geckodriver/Cargo.toml
198 +++ b/testing/geckodriver/Cargo.toml
199 @@ -15,17 +15,17 @@ chrono = "0.4.6"
200 clap = { version = "3.1", default-features = false, features = ["cargo", "std", "suggestions", "wrap_help"] }
201 hyper = "0.14"
202 lazy_static = "1.0"
203 log = { version = "0.4", features = ["std"] }
204 marionette = { path = "./marionette", version="0.2.0" }
205 mozdevice = { path = "../mozbase/rust/mozdevice", version="0.5.0" }
206 mozprofile = { path = "../mozbase/rust/mozprofile", version="0.8.0" }
207 mozrunner = { path = "../mozbase/rust/mozrunner", version="0.14.0" }
208 -mozversion = { path = "../mozbase/rust/mozversion", version="0.4.3" }
209 +mozversion = { path = "../mozbase/rust/mozversion", version="0.5.0-alpha" }
210 regex = { version="1.0", default-features = false, features = ["perf", "std"] }
211 serde = "1.0"
212 serde_derive = "1.0"
213 serde_json = "1.0"
214 serde_yaml = "0.8"
215 tempfile = "3"
216 url = "2.0"
217 uuid = { version = "0.8", features = ["v4"] }
218 diff --git a/testing/mozbase/rust/mozversion/Cargo.toml b/testing/mozbase/rust/mozversion/Cargo.toml
219 --- a/testing/mozbase/rust/mozversion/Cargo.toml
220 +++ b/testing/mozbase/rust/mozversion/Cargo.toml
221 @@ -1,14 +1,14 @@
222 [package]
223 name = "mozversion"
224 -version = "0.4.3"
225 +version = "0.5.0-alpha"
226 authors = ["Mozilla"]
227 description = "Utility for accessing Firefox version metadata"
228 keywords = ["mozilla", "firefox"]
229 repository = "https://hg.mozilla.org/mozilla-central/file/tip/testing/mozbase/rust/mozversion"
230 license = "MPL-2.0"
231 edition = "2018"
233 [dependencies]
234 regex = { version = "1", default-features = false, features = ["perf", "std"] }
235 rust-ini = "0.10"
236 -semver = "0.9"
237 +semver = "1.0"
238 diff --git a/testing/mozbase/rust/mozversion/src/lib.rs b/testing/mozbase/rust/mozversion/src/lib.rs
239 --- a/testing/mozbase/rust/mozversion/src/lib.rs
240 +++ b/testing/mozbase/rust/mozversion/src/lib.rs
241 @@ -101,18 +101,18 @@ impl Version {
242 // The way the semver crate handles prereleases isn't what we want here
243 // This should be fixed in the long term by implementing our own comparison
244 // operators, but for now just act as if prerelease metadata was missing,
245 // otherwise it is almost impossible to use this with nightly
246 semver::Version {
247 major: self.major,
248 minor: self.minor,
249 patch: self.patch,
250 - pre: vec![],
251 - build: vec![],
252 + pre: semver::Prerelease::EMPTY,
253 + build: semver::BuildMetadata::EMPTY,
257 pub fn matches(&self, version_req: &str) -> VersionResult<bool> {
258 let req = semver::VersionReq::parse(version_req)?;
259 Ok(req.matches(&self.to_semver()))
262 @@ -269,17 +269,17 @@ fn parse_binary_version(version_str: &st
264 #[derive(Clone, Debug)]
265 pub enum Error {
266 /// Error parsing a version string
267 VersionError(String),
268 /// Error reading application metadata
269 MetadataError(String),
270 /// Error processing a string as a semver comparator
271 - SemVerError(semver::ReqParseError),
272 + SemVerError(String),
275 impl Display for Error {
276 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
277 match *self {
278 Error::VersionError(ref x) => {
279 "VersionError: ".fmt(f)?;
280 x.fmt(f)
281 @@ -291,28 +291,25 @@ impl Display for Error {
282 Error::SemVerError(ref e) => {
283 "SemVerError: ".fmt(f)?;
284 e.fmt(f)
290 -impl From<semver::ReqParseError> for Error {
291 - fn from(err: semver::ReqParseError) -> Error {
292 - Error::SemVerError(err)
293 +impl From<semver::Error> for Error {
294 + fn from(err: semver::Error) -> Error {
295 + Error::SemVerError(err.to_string())
299 impl error::Error for Error {
300 fn cause(&self) -> Option<&dyn error::Error> {
301 - match *self {
302 - Error::SemVerError(ref e) => Some(e),
303 - Error::VersionError(_) | Error::MetadataError(_) => None,
305 + None
309 pub type VersionResult<T> = Result<T, Error>;
311 #[cfg(target_os = "macos")]
312 mod platform {
313 use std::path::{Path, PathBuf};
314 diff --git a/third_party/rust/cubeb-pulse/.cargo-checksum.json b/third_party/rust/cubeb-pulse/.cargo-checksum.json
315 --- a/third_party/rust/cubeb-pulse/.cargo-checksum.json
316 +++ b/third_party/rust/cubeb-pulse/.cargo-checksum.json
317 @@ -1,1 +1,1 @@
318 -{"files":{".editorconfig":"bf047bd1da10cabb99eea666d1e57c321eba4716dccb3e4ed0e2c5fe3ca53858",".github/workflows/build.yml":"95d0d2542c04f0c932f58591b92c3051db5c95657bf5f24b6a6110f7b667568d","AUTHORS":"0e0ac930a68ce2f6b876126b195add177f0d3886facb9260f4d9b69f1988f0cc","Cargo.toml":"d8f84d114794b79a02c8d93724951a0b924f4815e446d666e66877c7a90d0446","LICENSE":"44c6b5ae5ec3fe2fbc608b00e6f4896f4d2d5c7e525fcbaa3eaa3cf2f3d5a983","README.md":"0079450bb4b013bac065ed1750851e461a3710ebad1f323817da1cb82db0bc4f","src/backend/context.rs":"839fbbd90e501c9e455e6b46729f8c3cc03b368b6b45d02c82399660b7cf8289","src/backend/cork_state.rs":"4a0f1afc7d9f333dac89218cc56d7d32fbffb487cd48c1c9a4e03d79cb3b5e28","src/backend/intern.rs":"11ca424e4eb77f8eb9fd5a6717d1e791facf9743156a8534f0016fcf64d57b0f","src/backend/mod.rs":"d5da05348bf1a7f65c85b14372964a49dc4849f0aee96c75e2c18b51fb03fcaf","src/backend/stream.rs":"525e1f6be1990deef3c42d34fc4e25947be642ce242514f8e3428737146cc755","src/capi.rs":"fa0fa020f0d0efe55aa0fc3596405e8407bbe2cbe6c7a558345304e6da87994e","src/lib.rs":"b41bbdc562cbfb130ed7c1e53fe69944774f515705341d8ce48a2f82c8c0c2c5"},"package":null}
319 \ No newline at end of file
320 +{"files":{".editorconfig":"bf047bd1da10cabb99eea666d1e57c321eba4716dccb3e4ed0e2c5fe3ca53858",".github/workflows/build.yml":"95d0d2542c04f0c932f58591b92c3051db5c95657bf5f24b6a6110f7b667568d","AUTHORS":"0e0ac930a68ce2f6b876126b195add177f0d3886facb9260f4d9b69f1988f0cc","Cargo.toml":"13fe95ad27f37b8423958d78093ecff3ade9fffb28c5980604b624c2b617e5a7","LICENSE":"44c6b5ae5ec3fe2fbc608b00e6f4896f4d2d5c7e525fcbaa3eaa3cf2f3d5a983","README.md":"0079450bb4b013bac065ed1750851e461a3710ebad1f323817da1cb82db0bc4f","src/backend/context.rs":"839fbbd90e501c9e455e6b46729f8c3cc03b368b6b45d02c82399660b7cf8289","src/backend/cork_state.rs":"4a0f1afc7d9f333dac89218cc56d7d32fbffb487cd48c1c9a4e03d79cb3b5e28","src/backend/intern.rs":"11ca424e4eb77f8eb9fd5a6717d1e791facf9743156a8534f0016fcf64d57b0f","src/backend/mod.rs":"d5da05348bf1a7f65c85b14372964a49dc4849f0aee96c75e2c18b51fb03fcaf","src/backend/stream.rs":"e88a04ab7094b9df1bcdd07628369ec70ecb2062b91b0bd86f2642962814405c","src/capi.rs":"fa0fa020f0d0efe55aa0fc3596405e8407bbe2cbe6c7a558345304e6da87994e","src/lib.rs":"b41bbdc562cbfb130ed7c1e53fe69944774f515705341d8ce48a2f82c8c0c2c5"},"package":null}
321 \ No newline at end of file
322 diff --git a/third_party/rust/cubeb-pulse/Cargo.toml b/third_party/rust/cubeb-pulse/Cargo.toml
323 --- a/third_party/rust/cubeb-pulse/Cargo.toml
324 +++ b/third_party/rust/cubeb-pulse/Cargo.toml
325 @@ -10,10 +10,10 @@ pulse-dlopen = ["pulse-ffi/dlopen"]
327 [lib]
328 crate-type = ["staticlib", "rlib"]
330 [dependencies]
331 cubeb-backend = "0.10"
332 pulse-ffi = { path = "pulse-ffi" }
333 pulse = { path = "pulse-rs" }
334 -semver = "^0.9"
335 +semver = "1.0"
336 ringbuf = "0.2"
337 diff --git a/third_party/rust/cubeb-pulse/src/backend/stream.rs b/third_party/rust/cubeb-pulse/src/backend/stream.rs
338 --- a/third_party/rust/cubeb-pulse/src/backend/stream.rs
339 +++ b/third_party/rust/cubeb-pulse/src/backend/stream.rs
340 @@ -350,16 +350,25 @@ impl<'ctx> PulseStream<'ctx> {
341 ptr::null_mut(),
342 read_frames as c_long,
346 if got < 0 || got as usize != read_frames {
347 let _ = s.cancel_write();
348 stm.shutdown = true;
349 + if got < 0 {
350 + unsafe {
351 + stm.state_callback.unwrap()(
352 + stm as *mut _ as *mut _,
353 + stm.user_ptr,
354 + ffi::CUBEB_STATE_ERROR,
355 + );
358 break;
363 if read_size > 0 {
364 let _ = s.drop();
366 @@ -1064,16 +1073,23 @@ impl<'ctx> PulseStream<'ctx> {
367 read_ptr as *const _ as *mut _,
368 buffer,
369 (size / frame_size) as c_long,
370 ) as i64
372 if got < 0 {
373 let _ = stm.cancel_write();
374 self.shutdown = true;
375 + unsafe {
376 + self.state_callback.unwrap()(
377 + self as *const _ as *mut _,
378 + self.user_ptr,
379 + ffi::CUBEB_STATE_ERROR,
380 + );
382 return;
385 // If more iterations move offset of read buffer
386 if !input_data.is_null() {
387 let in_frame_size = self.input_sample_spec.frame_size();
388 read_offset += (size / frame_size) * in_frame_size;
390 diff --git a/third_party/rust/rustc_version/.cargo-checksum.json b/third_party/rust/rustc_version/.cargo-checksum.json
391 --- a/third_party/rust/rustc_version/.cargo-checksum.json
392 +++ b/third_party/rust/rustc_version/.cargo-checksum.json
393 @@ -1,1 +1,1 @@
394 -{"files":{"Cargo.toml":"80b9fb136c8c2945b4875b05b0f5a4b11e4722997e751f17d8d3f241d7c684db","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"c9a75f18b9ab2927829a208fc6aa2cf4e63b8420887ba29cdb265d6619ae82d5","README.md":"58bd14a1dfa1d828e6e99f35c3b7c2149d08e2d990d6ca93f92ab8ffb43275b7","src/errors.rs":"b28c2eeb1278fc3e8d68a64b177034faed67f6762335729d3a6d1e61be8fb034","src/lib.rs":"92a32673f77961724bc52b872781f06d22d166f06838c9582c5adae3c5214f51"},"package":"138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a"}
395 \ No newline at end of file
396 +{"files":{"Cargo.toml":"6a2e927f37b4897e75470e62face13eff0fe846c57f8fcfb98bcd5e0fe8ed0a2","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"c9a75f18b9ab2927829a208fc6aa2cf4e63b8420887ba29cdb265d6619ae82d5","README.md":"40f1138d4ddcfcfd0534429cea8dcbdcaf4a175aca1c26662f011f6e83d2fd7a","deny.toml":"22979f2da49546b27a5c892d5216bf74215987810a2d011b58870471883b9437","src/lib.rs":"bc18589948e3c04c3ffb491ffc3d4eccd8037c8e377d0bbae8aca2b21978b1de","tests/all.rs":"7b2969022feab85a948fafd331d9bb30d80357d01afaf7e0f723908e75f39e89"},"package":"bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366"}
397 \ No newline at end of file
398 diff --git a/third_party/rust/rustc_version/Cargo.toml b/third_party/rust/rustc_version/Cargo.toml
399 --- a/third_party/rust/rustc_version/Cargo.toml
400 +++ b/third_party/rust/rustc_version/Cargo.toml
401 @@ -1,26 +1,27 @@
402 # THIS FILE IS AUTOMATICALLY GENERATED BY CARGO
404 # When uploading crates to the registry Cargo will automatically
405 # "normalize" Cargo.toml files for maximal compatibility
406 # with all versions of Cargo and also rewrite `path` dependencies
407 -# to registry (e.g. crates.io) dependencies
408 +# to registry (e.g., crates.io) dependencies
410 # If you believe there's an error in this file please file an
411 # issue against the rust-lang/cargo repository. If you're
412 # editing this file be aware that the upstream Cargo.toml
413 # will likely look very different (and much more reasonable)
415 [package]
416 +edition = "2018"
417 name = "rustc_version"
418 -version = "0.2.3"
419 -authors = ["Marvin Löbel <loebel.marvin@gmail.com>"]
420 +version = "0.4.0"
421 +authors = ["Dirkjan Ochtman <dirkjan@ochtman.nl>", "Marvin Löbel <loebel.marvin@gmail.com>"]
422 description = "A library for querying the version of a installed rustc compiler"
423 documentation = "https://docs.rs/rustc_version/"
424 readme = "README.md"
425 keywords = ["version", "rustc"]
426 license = "MIT/Apache-2.0"
427 repository = "https://github.com/Kimundi/rustc-version-rs"
428 [dependencies.semver]
429 -version = "0.9"
430 -[badges.travis-ci]
431 -repository = "Kimundi/rustc-version-rs"
432 +version = "1.0"
433 +[dev-dependencies.doc-comment]
434 +version = "0.3"
435 diff --git a/third_party/rust/rustc_version/README.md b/third_party/rust/rustc_version/README.md
436 --- a/third_party/rust/rustc_version/README.md
437 +++ b/third_party/rust/rustc_version/README.md
438 @@ -1,40 +1,46 @@
439 rustc-version-rs
440 -==============
441 +================
443 +[![Documentation](https://docs.rs/rustc_version/badge.svg)](https://docs.rs/rustc_version/)
444 +[![Crates.io](https://img.shields.io/crates/v/rustc_version.svg)](https://crates.io/crates/rustc_version)
445 +[![Build status](https://github.com/Kimundi/rustc-version-rs/workflows/CI/badge.svg)](https://github.com/Kimundi/rustc-version-rs/actions?query=workflow%3ACI)
447 A library for querying the version of a `rustc` compiler.
449 This can be used by build scripts or other tools dealing with Rust sources
450 -to make decisions based on the version of the compiler.
451 +to make decisions based on the version of the compiler. Current MSRV is 1.32.0.
453 -[![Travis-CI Status](https://travis-ci.org/Kimundi/rustc-version-rs.png?branch=master)](https://travis-ci.org/Kimundi/rustc-version-rs)
454 +If this is of interest, also consider looking at these other crates:
456 +* [autocfg](https://crates.io/crates/autocfg/), which helps with feature detection instead of depending on compiler versions
457 +* [rustversion](https://github.com/dtolnay/rustversion) provides a procedural macro with no other dependencies
459 # Getting Started
461 [rustc-version-rs is available on crates.io](https://crates.io/crates/rustc_version).
462 It is recommended to look there for the newest released version, as well as links to the newest builds of the docs.
464 At the point of the last update of this README, the latest published version could be used like this:
466 Add the following dependency to your Cargo manifest...
468 ```toml
469 [build-dependencies]
470 rustc_version = "0.2"
473 -...and see the [docs](http://kimundi.github.io/rustc-version-rs/rustc_version/index.html) for how to use it.
474 +... and see the [docs](https://docs.rs/rustc_version) for how to use it.
476 # Example
478 ```rust
479 // This could be a cargo build script
481 -extern crate rustc_version;
482 use rustc_version::{version, version_meta, Channel, Version};
484 fn main() {
485 // Assert we haven't travelled back in time
486 assert!(version().unwrap().major >= 1);
488 // Set cfg flags depending on release channel
489 match version_meta().unwrap().channel {
490 diff --git a/third_party/rust/rustc_version/deny.toml b/third_party/rust/rustc_version/deny.toml
491 new file mode 100644
492 --- /dev/null
493 +++ b/third_party/rust/rustc_version/deny.toml
494 @@ -0,0 +1,3 @@
495 +[licenses]
496 +allow-osi-fsf-free = "either"
497 +copyleft = "deny"
498 diff --git a/third_party/rust/rustc_version/src/errors.rs b/third_party/rust/rustc_version/src/errors.rs
499 deleted file mode 100644
500 --- a/third_party/rust/rustc_version/src/errors.rs
501 +++ /dev/null
502 @@ -1,79 +0,0 @@
503 -use std::{self, error, fmt, io, str};
504 -use semver::{self, Identifier};
506 -/// The error type for this crate.
507 -#[derive(Debug)]
508 -pub enum Error {
509 - /// An error ocurrend when executing the `rustc` command.
510 - CouldNotExecuteCommand(io::Error),
511 - /// The output of `rustc -vV` was not valid utf-8.
512 - Utf8Error(str::Utf8Error),
513 - /// The output of `rustc -vV` was not in the expected format.
514 - UnexpectedVersionFormat,
515 - /// An error ocurred in parsing a `VersionReq`.
516 - ReqParseError(semver::ReqParseError),
517 - /// An error ocurred in parsing the semver.
518 - SemVerError(semver::SemVerError),
519 - /// The pre-release tag is unknown.
520 - UnknownPreReleaseTag(Identifier),
522 -use Error::*;
524 -impl fmt::Display for Error {
525 - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
526 - use std::error::Error;
527 - match *self {
528 - CouldNotExecuteCommand(ref e) => write!(f, "{}: {}", self.description(), e),
529 - Utf8Error(_) => write!(f, "{}", self.description()),
530 - UnexpectedVersionFormat => write!(f, "{}", self.description()),
531 - ReqParseError(ref e) => write!(f, "{}: {}", self.description(), e),
532 - SemVerError(ref e) => write!(f, "{}: {}", self.description(), e),
533 - UnknownPreReleaseTag(ref i) => write!(f, "{}: {}", self.description(), i),
538 -impl error::Error for Error {
539 - fn cause(&self) -> Option<&error::Error> {
540 - match *self {
541 - CouldNotExecuteCommand(ref e) => Some(e),
542 - Utf8Error(ref e) => Some(e),
543 - UnexpectedVersionFormat => None,
544 - ReqParseError(ref e) => Some(e),
545 - SemVerError(ref e) => Some(e),
546 - UnknownPreReleaseTag(_) => None,
550 - fn description(&self) -> &str {
551 - match *self {
552 - CouldNotExecuteCommand(_) => "could not execute command",
553 - Utf8Error(_) => "invalid UTF-8 output from `rustc -vV`",
554 - UnexpectedVersionFormat => "unexpected `rustc -vV` format",
555 - ReqParseError(_) => "error parsing version requirement",
556 - SemVerError(_) => "error parsing version",
557 - UnknownPreReleaseTag(_) => "unknown pre-release tag",
562 -macro_rules! impl_from {
563 - ($($err_ty:ty => $variant:ident),* $(,)*) => {
564 - $(
565 - impl From<$err_ty> for Error {
566 - fn from(e: $err_ty) -> Error {
567 - Error::$variant(e)
570 - )*
574 -impl_from! {
575 - str::Utf8Error => Utf8Error,
576 - semver::SemVerError => SemVerError,
577 - semver::ReqParseError => ReqParseError,
580 -/// The result type for this crate.
581 -pub type Result<T> = std::result::Result<T, Error>;
582 diff --git a/third_party/rust/rustc_version/src/lib.rs b/third_party/rust/rustc_version/src/lib.rs
583 --- a/third_party/rust/rustc_version/src/lib.rs
584 +++ b/third_party/rust/rustc_version/src/lib.rs
585 @@ -17,73 +17,138 @@
586 //! It calls `$RUSTC --version -v` and parses the output, falling
587 //! back to `rustc` if `$RUSTC` is not set.
589 //! # Example
591 //! ```rust
592 //! // This could be a cargo build script
594 -//! extern crate rustc_version;
595 //! use rustc_version::{version, version_meta, Channel, Version};
597 -//! fn main() {
598 -//! // Assert we haven't travelled back in time
599 -//! assert!(version().unwrap().major >= 1);
600 +//! // Assert we haven't travelled back in time
601 +//! assert!(version().unwrap().major >= 1);
603 -//! // Set cfg flags depending on release channel
604 -//! match version_meta().unwrap().channel {
605 -//! Channel::Stable => {
606 -//! println!("cargo:rustc-cfg=RUSTC_IS_STABLE");
607 -//! }
608 -//! Channel::Beta => {
609 -//! println!("cargo:rustc-cfg=RUSTC_IS_BETA");
610 -//! }
611 -//! Channel::Nightly => {
612 -//! println!("cargo:rustc-cfg=RUSTC_IS_NIGHTLY");
613 -//! }
614 -//! Channel::Dev => {
615 -//! println!("cargo:rustc-cfg=RUSTC_IS_DEV");
616 -//! }
617 +//! // Set cfg flags depending on release channel
618 +//! match version_meta().unwrap().channel {
619 +//! Channel::Stable => {
620 +//! println!("cargo:rustc-cfg=RUSTC_IS_STABLE");
621 +//! }
622 +//! Channel::Beta => {
623 +//! println!("cargo:rustc-cfg=RUSTC_IS_BETA");
624 //! }
625 +//! Channel::Nightly => {
626 +//! println!("cargo:rustc-cfg=RUSTC_IS_NIGHTLY");
627 +//! }
628 +//! Channel::Dev => {
629 +//! println!("cargo:rustc-cfg=RUSTC_IS_DEV");
630 +//! }
631 +//! }
633 -//! // Check for a minimum version
634 -//! if version().unwrap() >= Version::parse("1.4.0").unwrap() {
635 -//! println!("cargo:rustc-cfg=compiler_has_important_bugfix");
636 -//! }
637 +//! // Check for a minimum version
638 +//! if version().unwrap() >= Version::parse("1.4.0").unwrap() {
639 +//! println!("cargo:rustc-cfg=compiler_has_important_bugfix");
640 //! }
641 //! ```
643 -extern crate semver;
644 -use semver::Identifier;
645 +#[cfg(test)]
646 +#[macro_use]
647 +extern crate doc_comment;
649 +#[cfg(test)]
650 +doctest!("../README.md");
652 +use std::collections::HashMap;
653 use std::process::Command;
654 -use std::{env, str};
655 -use std::ffi::OsString;
656 +use std::{env, error, fmt, io, num, str};
657 +use std::{ffi::OsString, str::FromStr};
659 // Convenience re-export to allow version comparison without needing to add
660 // semver crate.
661 pub use semver::Version;
663 -mod errors;
664 -pub use errors::{Error, Result};
665 +use Error::*;
667 /// Release channel of the compiler.
668 #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug)]
669 pub enum Channel {
670 /// Development release channel
671 Dev,
672 /// Nightly release channel
673 Nightly,
674 /// Beta release channel
675 Beta,
676 /// Stable release channel
677 Stable,
680 -/// Rustc version plus metada like git short hash and build date.
681 +/// LLVM version
682 +///
683 +/// LLVM's version numbering scheme is not semver compatible until version 4.0
684 +///
685 +/// rustc [just prints the major and minor versions], so other parts of the version are not included.
686 +///
687 +/// [just prints the major and minor versions]: https://github.com/rust-lang/rust/blob/b5c9e2448c9ace53ad5c11585803894651b18b0a/compiler/rustc_codegen_llvm/src/llvm_util.rs#L173-L178
688 +#[derive(Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
689 +pub struct LlvmVersion {
690 + // fields must be ordered major, minor for comparison to be correct
691 + /// Major version
692 + pub major: u64,
693 + /// Minor version
694 + pub minor: u64,
695 + // TODO: expose micro version here
698 +impl fmt::Display for LlvmVersion {
699 + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
700 + write!(f, "{}.{}", self.major, self.minor)
704 +impl FromStr for LlvmVersion {
705 + type Err = LlvmVersionParseError;
707 + fn from_str(s: &str) -> Result<Self, Self::Err> {
708 + let mut parts = s
709 + .split('.')
710 + .map(|part| -> Result<u64, LlvmVersionParseError> {
711 + if part == "0" {
712 + Ok(0)
713 + } else if part.starts_with('0') {
714 + Err(LlvmVersionParseError::ComponentMustNotHaveLeadingZeros)
715 + } else if part.starts_with('-') || part.starts_with('+') {
716 + Err(LlvmVersionParseError::ComponentMustNotHaveSign)
717 + } else {
718 + Ok(part.parse()?)
720 + });
722 + let major = parts.next().unwrap()?;
723 + let mut minor = 0;
725 + if let Some(part) = parts.next() {
726 + minor = part?;
727 + } else if major < 4 {
728 + // LLVM versions earlier than 4.0 have significant minor versions, so require the minor version in this case.
729 + return Err(LlvmVersionParseError::MinorVersionRequiredBefore4);
732 + if let Some(Err(e)) = parts.next() {
733 + return Err(e);
736 + if parts.next().is_some() {
737 + return Err(LlvmVersionParseError::TooManyComponents);
740 + Ok(Self { major, minor })
744 +/// Rustc version plus metadata like git short hash and build date.
745 #[derive(Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
746 pub struct VersionMeta {
747 /// Version of the compiler
748 pub semver: Version,
750 /// Git short hash of the build of the compiler
751 pub commit_hash: Option<String>,
753 @@ -96,27 +161,37 @@ pub struct VersionMeta {
754 /// Release channel of the compiler
755 pub channel: Channel,
757 /// Host target triple of the compiler
758 pub host: String,
760 /// Short version string of the compiler
761 pub short_version_string: String,
763 + /// Version of LLVM used by the compiler
764 + pub llvm_version: Option<LlvmVersion>,
767 impl VersionMeta {
768 /// Returns the version metadata for `cmd`, which should be a `rustc` command.
769 - pub fn for_command(cmd: Command) -> Result<VersionMeta> {
770 - let mut cmd = cmd;
771 + pub fn for_command(mut cmd: Command) -> Result<VersionMeta> {
772 + let out = cmd
773 + .arg("-vV")
774 + .output()
775 + .map_err(Error::CouldNotExecuteCommand)?;
777 - let out = cmd.arg("-vV").output().map_err(Error::CouldNotExecuteCommand)?;
778 - let out = str::from_utf8(&out.stdout)?;
779 + if !out.status.success() {
780 + return Err(Error::CommandError {
781 + stdout: String::from_utf8_lossy(&out.stdout).into(),
782 + stderr: String::from_utf8_lossy(&out.stderr).into(),
783 + });
786 - version_meta_for(out)
787 + version_meta_for(str::from_utf8(&out.stdout)?)
791 /// Returns the `rustc` SemVer version.
792 pub fn version() -> Result<Version> {
793 Ok(version_meta()?.semver)
796 @@ -127,221 +202,216 @@ pub fn version_meta() -> Result<VersionM
798 VersionMeta::for_command(Command::new(cmd))
801 /// Parses a "rustc -vV" output string and returns
802 /// the SemVer version and additional metadata
803 /// like the git short hash and build date.
804 pub fn version_meta_for(verbose_version_string: &str) -> Result<VersionMeta> {
805 - let out: Vec<_> = verbose_version_string.lines().collect();
807 - if !(out.len() >= 6 && out.len() <= 8) {
808 - return Err(Error::UnexpectedVersionFormat);
810 + let mut map = HashMap::new();
811 + for (i, line) in verbose_version_string.lines().enumerate() {
812 + if i == 0 {
813 + map.insert("short", line);
814 + continue;
817 - let short_version_string = out[0];
818 + let mut parts = line.splitn(2, ": ");
819 + let key = match parts.next() {
820 + Some(key) => key,
821 + None => continue,
822 + };
824 - fn expect_prefix<'a>(line: &'a str, prefix: &str) -> Result<&'a str> {
825 - if line.starts_with(prefix) {
826 - Ok(&line[prefix.len()..])
827 - } else {
828 - Err(Error::UnexpectedVersionFormat)
829 + if let Some(value) = parts.next() {
830 + map.insert(key, value);
834 - let commit_hash = match expect_prefix(out[2], "commit-hash: ")? {
835 - "unknown" => None,
836 - hash => Some(hash.to_owned()),
837 - };
838 + let short_version_string = expect_key("short", &map)?;
839 + let host = expect_key("host", &map)?;
840 + let release = expect_key("release", &map)?;
841 + let semver: Version = release.parse()?;
843 - let commit_date = match expect_prefix(out[3], "commit-date: ")? {
844 - "unknown" => None,
845 - hash => Some(hash.to_owned()),
846 + let channel = match semver.pre.split('.').next().unwrap() {
847 + "" => Channel::Stable,
848 + "dev" => Channel::Dev,
849 + "beta" => Channel::Beta,
850 + "nightly" => Channel::Nightly,
851 + x => return Err(Error::UnknownPreReleaseTag(x.to_owned())),
854 - // Handle that the build date may or may not be present.
855 - let mut idx = 4;
856 - let mut build_date = None;
857 - if out[idx].starts_with("build-date") {
858 - build_date = match expect_prefix(out[idx], "build-date: ")? {
859 - "unknown" => None,
860 - s => Some(s.to_owned()),
861 - };
862 - idx += 1;
865 - let host = expect_prefix(out[idx], "host: ")?;
866 - idx += 1;
867 - let release = expect_prefix(out[idx], "release: ")?;
869 - let semver: Version = release.parse()?;
871 - let channel = if semver.pre.is_empty() {
872 - Channel::Stable
873 - } else {
874 - match semver.pre[0] {
875 - Identifier::AlphaNumeric(ref s) if s == "dev" => Channel::Dev,
876 - Identifier::AlphaNumeric(ref s) if s == "beta" => Channel::Beta,
877 - Identifier::AlphaNumeric(ref s) if s == "nightly" => Channel::Nightly,
878 - ref x => return Err(Error::UnknownPreReleaseTag(x.clone())),
880 + let commit_hash = expect_key_or_unknown("commit-hash", &map)?;
881 + let commit_date = expect_key_or_unknown("commit-date", &map)?;
882 + let build_date = map
883 + .get("build-date")
884 + .filter(|&v| *v != "unknown")
885 + .map(|&v| String::from(v));
886 + let llvm_version = match map.get("LLVM version") {
887 + Some(&v) => Some(v.parse()?),
888 + None => None,
891 Ok(VersionMeta {
892 - semver: semver,
893 - commit_hash: commit_hash,
894 - commit_date: commit_date,
895 - build_date: build_date,
896 - channel: channel,
897 - host: host.into(),
898 - short_version_string: short_version_string.into(),
899 + semver,
900 + commit_hash,
901 + commit_date,
902 + build_date,
903 + channel,
904 + host,
905 + short_version_string,
906 + llvm_version,
910 -#[test]
911 -fn smoketest() {
912 - let v = version().unwrap();
913 - assert!(v.major >= 1);
914 +fn expect_key_or_unknown(key: &str, map: &HashMap<&str, &str>) -> Result<Option<String>, Error> {
915 + match map.get(key) {
916 + Some(&v) if v == "unknown" => Ok(None),
917 + Some(&v) => Ok(Some(String::from(v))),
918 + None => Err(Error::UnexpectedVersionFormat),
922 - let v = version_meta().unwrap();
923 - assert!(v.semver.major >= 1);
925 - assert!(version().unwrap() >= Version::parse("1.0.0").unwrap());
926 +fn expect_key(key: &str, map: &HashMap<&str, &str>) -> Result<String, Error> {
927 + map.get(key)
928 + .map(|&v| String::from(v))
929 + .ok_or(Error::UnexpectedVersionFormat)
932 -#[test]
933 -fn parse_unexpected() {
934 - let res = version_meta_for(
935 -"rustc 1.0.0 (a59de37e9 2015-05-13) (built 2015-05-14)
936 -binary: rustc
937 -commit-hash: a59de37e99060162a2674e3ff45409ac73595c0e
938 -commit-date: 2015-05-13
939 -rust-birthday: 2015-05-14
940 -host: x86_64-unknown-linux-gnu
941 -release: 1.0.0");
942 +/// LLVM Version Parse Error
943 +#[derive(Debug)]
944 +pub enum LlvmVersionParseError {
945 + /// An error occurred in parsing a version component as an integer
946 + ParseIntError(num::ParseIntError),
947 + /// A version component must not have leading zeros
948 + ComponentMustNotHaveLeadingZeros,
949 + /// A version component has a sign
950 + ComponentMustNotHaveSign,
951 + /// Minor version component must be zero on LLVM versions later than 4.0
952 + MinorVersionMustBeZeroAfter4,
953 + /// Minor version component is required on LLVM versions earlier than 4.0
954 + MinorVersionRequiredBefore4,
955 + /// Too many components
956 + TooManyComponents,
959 - assert!(match res {
960 - Err(Error::UnexpectedVersionFormat) => true,
961 - _ => false,
962 - });
964 +impl From<num::ParseIntError> for LlvmVersionParseError {
965 + fn from(e: num::ParseIntError) -> Self {
966 + LlvmVersionParseError::ParseIntError(e)
970 -#[test]
971 -fn parse_1_0_0() {
972 - let version = version_meta_for(
973 -"rustc 1.0.0 (a59de37e9 2015-05-13) (built 2015-05-14)
974 -binary: rustc
975 -commit-hash: a59de37e99060162a2674e3ff45409ac73595c0e
976 -commit-date: 2015-05-13
977 -build-date: 2015-05-14
978 -host: x86_64-unknown-linux-gnu
979 -release: 1.0.0").unwrap();
981 - assert_eq!(version.semver, Version::parse("1.0.0").unwrap());
982 - assert_eq!(version.commit_hash, Some("a59de37e99060162a2674e3ff45409ac73595c0e".into()));
983 - assert_eq!(version.commit_date, Some("2015-05-13".into()));
984 - assert_eq!(version.build_date, Some("2015-05-14".into()));
985 - assert_eq!(version.channel, Channel::Stable);
986 - assert_eq!(version.host, "x86_64-unknown-linux-gnu");
987 - assert_eq!(version.short_version_string, "rustc 1.0.0 (a59de37e9 2015-05-13) (built 2015-05-14)");
988 +impl fmt::Display for LlvmVersionParseError {
989 + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
990 + match self {
991 + LlvmVersionParseError::ParseIntError(e) => {
992 + write!(f, "error parsing LLVM version component: {}", e)
994 + LlvmVersionParseError::ComponentMustNotHaveLeadingZeros => {
995 + write!(f, "a version component must not have leading zeros")
997 + LlvmVersionParseError::ComponentMustNotHaveSign => {
998 + write!(f, "a version component must not have a sign")
1000 + LlvmVersionParseError::MinorVersionMustBeZeroAfter4 => write!(
1001 + f,
1002 + "LLVM's minor version component must be 0 for versions greater than 4.0"
1003 + ),
1004 + LlvmVersionParseError::MinorVersionRequiredBefore4 => write!(
1005 + f,
1006 + "LLVM's minor version component is required for versions less than 4.0"
1007 + ),
1008 + LlvmVersionParseError::TooManyComponents => write!(f, "too many version components"),
1014 -#[test]
1015 -fn parse_unknown() {
1016 - let version = version_meta_for(
1017 -"rustc 1.3.0
1018 -binary: rustc
1019 -commit-hash: unknown
1020 -commit-date: unknown
1021 -host: x86_64-unknown-linux-gnu
1022 -release: 1.3.0").unwrap();
1024 - assert_eq!(version.semver, Version::parse("1.3.0").unwrap());
1025 - assert_eq!(version.commit_hash, None);
1026 - assert_eq!(version.commit_date, None);
1027 - assert_eq!(version.channel, Channel::Stable);
1028 - assert_eq!(version.host, "x86_64-unknown-linux-gnu");
1029 - assert_eq!(version.short_version_string, "rustc 1.3.0");
1030 +impl error::Error for LlvmVersionParseError {
1031 + fn source(&self) -> Option<&(dyn error::Error + 'static)> {
1032 + match self {
1033 + LlvmVersionParseError::ParseIntError(e) => Some(e),
1034 + LlvmVersionParseError::ComponentMustNotHaveLeadingZeros
1035 + | LlvmVersionParseError::ComponentMustNotHaveSign
1036 + | LlvmVersionParseError::MinorVersionMustBeZeroAfter4
1037 + | LlvmVersionParseError::MinorVersionRequiredBefore4
1038 + | LlvmVersionParseError::TooManyComponents => None,
1043 -#[test]
1044 -fn parse_nightly() {
1045 - let version = version_meta_for(
1046 -"rustc 1.5.0-nightly (65d5c0833 2015-09-29)
1047 -binary: rustc
1048 -commit-hash: 65d5c083377645a115c4ac23a620d3581b9562b6
1049 -commit-date: 2015-09-29
1050 -host: x86_64-unknown-linux-gnu
1051 -release: 1.5.0-nightly").unwrap();
1053 - assert_eq!(version.semver, Version::parse("1.5.0-nightly").unwrap());
1054 - assert_eq!(version.commit_hash, Some("65d5c083377645a115c4ac23a620d3581b9562b6".into()));
1055 - assert_eq!(version.commit_date, Some("2015-09-29".into()));
1056 - assert_eq!(version.channel, Channel::Nightly);
1057 - assert_eq!(version.host, "x86_64-unknown-linux-gnu");
1058 - assert_eq!(version.short_version_string, "rustc 1.5.0-nightly (65d5c0833 2015-09-29)");
1061 -#[test]
1062 -fn parse_stable() {
1063 - let version = version_meta_for(
1064 -"rustc 1.3.0 (9a92aaf19 2015-09-15)
1065 -binary: rustc
1066 -commit-hash: 9a92aaf19a64603b02b4130fe52958cc12488900
1067 -commit-date: 2015-09-15
1068 -host: x86_64-unknown-linux-gnu
1069 -release: 1.3.0").unwrap();
1071 - assert_eq!(version.semver, Version::parse("1.3.0").unwrap());
1072 - assert_eq!(version.commit_hash, Some("9a92aaf19a64603b02b4130fe52958cc12488900".into()));
1073 - assert_eq!(version.commit_date, Some("2015-09-15".into()));
1074 - assert_eq!(version.channel, Channel::Stable);
1075 - assert_eq!(version.host, "x86_64-unknown-linux-gnu");
1076 - assert_eq!(version.short_version_string, "rustc 1.3.0 (9a92aaf19 2015-09-15)");
1077 +/// The error type for this crate.
1078 +#[derive(Debug)]
1079 +pub enum Error {
1080 + /// An error occurred while trying to find the `rustc` to run.
1081 + CouldNotExecuteCommand(io::Error),
1082 + /// Error output from the command that was run.
1083 + CommandError {
1084 + /// stdout output from the command
1085 + stdout: String,
1086 + /// stderr output from the command
1087 + stderr: String,
1088 + },
1089 + /// The output of `rustc -vV` was not valid utf-8.
1090 + Utf8Error(str::Utf8Error),
1091 + /// The output of `rustc -vV` was not in the expected format.
1092 + UnexpectedVersionFormat,
1093 + /// An error occurred in parsing the semver.
1094 + SemVerError(semver::Error),
1095 + /// The pre-release tag is unknown.
1096 + UnknownPreReleaseTag(String),
1097 + /// An error occurred in parsing a `LlvmVersion`.
1098 + LlvmVersionError(LlvmVersionParseError),
1101 -#[test]
1102 -fn parse_1_16_0_nightly() {
1103 - let version = version_meta_for(
1104 -"rustc 1.16.0-nightly (5d994d8b7 2017-01-05)
1105 -binary: rustc
1106 -commit-hash: 5d994d8b7e482e87467d4a521911477bd8284ce3
1107 -commit-date: 2017-01-05
1108 -host: x86_64-unknown-linux-gnu
1109 -release: 1.16.0-nightly
1110 -LLVM version: 3.9").unwrap();
1112 - assert_eq!(version.semver, Version::parse("1.16.0-nightly").unwrap());
1113 - assert_eq!(version.commit_hash, Some("5d994d8b7e482e87467d4a521911477bd8284ce3".into()));
1114 - assert_eq!(version.commit_date, Some("2017-01-05".into()));
1115 - assert_eq!(version.channel, Channel::Nightly);
1116 - assert_eq!(version.host, "x86_64-unknown-linux-gnu");
1117 - assert_eq!(version.short_version_string, "rustc 1.16.0-nightly (5d994d8b7 2017-01-05)");
1118 +impl fmt::Display for Error {
1119 + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1120 + match *self {
1121 + CouldNotExecuteCommand(ref e) => write!(f, "could not execute command: {}", e),
1122 + CommandError {
1123 + ref stdout,
1124 + ref stderr,
1125 + } => write!(
1126 + f,
1127 + "error from command -- stderr:\n\n{}\n\nstderr:\n\n{}",
1128 + stderr, stdout,
1129 + ),
1130 + Utf8Error(_) => write!(f, "invalid UTF-8 output from `rustc -vV`"),
1131 + UnexpectedVersionFormat => write!(f, "unexpected `rustc -vV` format"),
1132 + SemVerError(ref e) => write!(f, "error parsing version: {}", e),
1133 + UnknownPreReleaseTag(ref i) => write!(f, "unknown pre-release tag: {}", i),
1134 + LlvmVersionError(ref e) => write!(f, "error parsing LLVM's version: {}", e),
1140 -#[test]
1141 -fn version_matches_replacement() {
1142 - let f = |s1: &str, s2: &str| {
1143 - let a = Version::parse(s1).unwrap();
1144 - let b = Version::parse(s2).unwrap();
1145 - println!("{} <= {} : {}", s1, s2, a <= b);
1146 - };
1148 - println!();
1149 +impl error::Error for Error {
1150 + fn source(&self) -> Option<&(dyn error::Error + 'static)> {
1151 + match *self {
1152 + CouldNotExecuteCommand(ref e) => Some(e),
1153 + CommandError { .. } => None,
1154 + Utf8Error(ref e) => Some(e),
1155 + UnexpectedVersionFormat => None,
1156 + SemVerError(ref e) => Some(e),
1157 + UnknownPreReleaseTag(_) => None,
1158 + LlvmVersionError(ref e) => Some(e),
1163 - f("1.5.0", "1.5.0");
1164 - f("1.5.0-nightly", "1.5.0");
1165 - f("1.5.0", "1.5.0-nightly");
1166 - f("1.5.0-nightly", "1.5.0-nightly");
1167 +macro_rules! impl_from {
1168 + ($($err_ty:ty => $variant:ident),* $(,)*) => {
1169 + $(
1170 + impl From<$err_ty> for Error {
1171 + fn from(e: $err_ty) -> Error {
1172 + Error::$variant(e)
1175 + )*
1179 - f("1.5.0", "1.6.0");
1180 - f("1.5.0-nightly", "1.6.0");
1181 - f("1.5.0", "1.6.0-nightly");
1182 - f("1.5.0-nightly", "1.6.0-nightly");
1183 +impl_from! {
1184 + str::Utf8Error => Utf8Error,
1185 + semver::Error => SemVerError,
1186 + LlvmVersionParseError => LlvmVersionError,
1189 - panic!();
1193 +/// The result type for this crate.
1194 +pub type Result<T, E = Error> = std::result::Result<T, E>;
1195 diff --git a/third_party/rust/rustc_version/tests/all.rs b/third_party/rust/rustc_version/tests/all.rs
1196 new file mode 100644
1197 --- /dev/null
1198 +++ b/third_party/rust/rustc_version/tests/all.rs
1199 @@ -0,0 +1,456 @@
1200 +#![allow(clippy::match_like_matches_macro)]
1202 +use std::process::Command;
1204 +use rustc_version::{
1205 + version, version_meta, version_meta_for, Channel, Error, LlvmVersion, LlvmVersionParseError,
1206 + Version, VersionMeta,
1209 +#[test]
1210 +fn rustc_error() {
1211 + let mut cmd = Command::new("rustc");
1212 + cmd.arg("--FOO");
1213 + let stderr = match VersionMeta::for_command(cmd) {
1214 + Err(Error::CommandError { stdout: _, stderr }) => stderr,
1215 + _ => panic!("command error expected"),
1216 + };
1217 + assert_eq!(stderr, "error: Unrecognized option: \'FOO\'\n\n");
1220 +#[test]
1221 +fn smoketest() {
1222 + let v = version().unwrap();
1223 + assert!(v.major >= 1);
1225 + let v = version_meta().unwrap();
1226 + assert!(v.semver.major >= 1);
1228 + assert!(version().unwrap() >= Version::parse("1.0.0").unwrap());
1231 +#[test]
1232 +fn parse_1_0_0() {
1233 + let version = version_meta_for(
1234 + "rustc 1.0.0 (a59de37e9 2015-05-13) (built 2015-05-14)
1235 +binary: rustc
1236 +commit-hash: a59de37e99060162a2674e3ff45409ac73595c0e
1237 +commit-date: 2015-05-13
1238 +build-date: 2015-05-14
1239 +host: x86_64-unknown-linux-gnu
1240 +release: 1.0.0",
1242 + .unwrap();
1244 + assert_eq!(version.semver, Version::parse("1.0.0").unwrap());
1245 + assert_eq!(
1246 + version.commit_hash,
1247 + Some("a59de37e99060162a2674e3ff45409ac73595c0e".into())
1248 + );
1249 + assert_eq!(version.commit_date, Some("2015-05-13".into()));
1250 + assert_eq!(version.build_date, Some("2015-05-14".into()));
1251 + assert_eq!(version.channel, Channel::Stable);
1252 + assert_eq!(version.host, "x86_64-unknown-linux-gnu");
1253 + assert_eq!(
1254 + version.short_version_string,
1255 + "rustc 1.0.0 (a59de37e9 2015-05-13) (built 2015-05-14)"
1256 + );
1257 + assert_eq!(version.llvm_version, None);
1260 +#[test]
1261 +fn parse_unknown() {
1262 + let version = version_meta_for(
1263 + "rustc 1.3.0
1264 +binary: rustc
1265 +commit-hash: unknown
1266 +commit-date: unknown
1267 +host: x86_64-unknown-linux-gnu
1268 +release: 1.3.0",
1270 + .unwrap();
1272 + assert_eq!(version.semver, Version::parse("1.3.0").unwrap());
1273 + assert_eq!(version.commit_hash, None);
1274 + assert_eq!(version.commit_date, None);
1275 + assert_eq!(version.channel, Channel::Stable);
1276 + assert_eq!(version.host, "x86_64-unknown-linux-gnu");
1277 + assert_eq!(version.short_version_string, "rustc 1.3.0");
1278 + assert_eq!(version.llvm_version, None);
1281 +#[test]
1282 +fn parse_nightly() {
1283 + let version = version_meta_for(
1284 + "rustc 1.5.0-nightly (65d5c0833 2015-09-29)
1285 +binary: rustc
1286 +commit-hash: 65d5c083377645a115c4ac23a620d3581b9562b6
1287 +commit-date: 2015-09-29
1288 +host: x86_64-unknown-linux-gnu
1289 +release: 1.5.0-nightly",
1291 + .unwrap();
1293 + assert_eq!(version.semver, Version::parse("1.5.0-nightly").unwrap());
1294 + assert_eq!(
1295 + version.commit_hash,
1296 + Some("65d5c083377645a115c4ac23a620d3581b9562b6".into())
1297 + );
1298 + assert_eq!(version.commit_date, Some("2015-09-29".into()));
1299 + assert_eq!(version.channel, Channel::Nightly);
1300 + assert_eq!(version.host, "x86_64-unknown-linux-gnu");
1301 + assert_eq!(
1302 + version.short_version_string,
1303 + "rustc 1.5.0-nightly (65d5c0833 2015-09-29)"
1304 + );
1305 + assert_eq!(version.llvm_version, None);
1308 +#[test]
1309 +fn parse_stable() {
1310 + let version = version_meta_for(
1311 + "rustc 1.3.0 (9a92aaf19 2015-09-15)
1312 +binary: rustc
1313 +commit-hash: 9a92aaf19a64603b02b4130fe52958cc12488900
1314 +commit-date: 2015-09-15
1315 +host: x86_64-unknown-linux-gnu
1316 +release: 1.3.0",
1318 + .unwrap();
1320 + assert_eq!(version.semver, Version::parse("1.3.0").unwrap());
1321 + assert_eq!(
1322 + version.commit_hash,
1323 + Some("9a92aaf19a64603b02b4130fe52958cc12488900".into())
1324 + );
1325 + assert_eq!(version.commit_date, Some("2015-09-15".into()));
1326 + assert_eq!(version.channel, Channel::Stable);
1327 + assert_eq!(version.host, "x86_64-unknown-linux-gnu");
1328 + assert_eq!(
1329 + version.short_version_string,
1330 + "rustc 1.3.0 (9a92aaf19 2015-09-15)"
1331 + );
1332 + assert_eq!(version.llvm_version, None);
1335 +#[test]
1336 +fn parse_1_16_0_nightly() {
1337 + let version = version_meta_for(
1338 + "rustc 1.16.0-nightly (5d994d8b7 2017-01-05)
1339 +binary: rustc
1340 +commit-hash: 5d994d8b7e482e87467d4a521911477bd8284ce3
1341 +commit-date: 2017-01-05
1342 +host: x86_64-unknown-linux-gnu
1343 +release: 1.16.0-nightly
1344 +LLVM version: 3.9",
1346 + .unwrap();
1348 + assert_eq!(version.semver, Version::parse("1.16.0-nightly").unwrap());
1349 + assert_eq!(
1350 + version.commit_hash,
1351 + Some("5d994d8b7e482e87467d4a521911477bd8284ce3".into())
1352 + );
1353 + assert_eq!(version.commit_date, Some("2017-01-05".into()));
1354 + assert_eq!(version.channel, Channel::Nightly);
1355 + assert_eq!(version.host, "x86_64-unknown-linux-gnu");
1356 + assert_eq!(
1357 + version.short_version_string,
1358 + "rustc 1.16.0-nightly (5d994d8b7 2017-01-05)"
1359 + );
1360 + assert_eq!(
1361 + version.llvm_version,
1362 + Some(LlvmVersion { major: 3, minor: 9 })
1363 + );
1366 +#[test]
1367 +fn parse_1_47_0_stable() {
1368 + let version = version_meta_for(
1369 + "rustc 1.47.0 (18bf6b4f0 2020-10-07)
1370 +binary: rustc
1371 +commit-hash: 18bf6b4f01a6feaf7259ba7cdae58031af1b7b39
1372 +commit-date: 2020-10-07
1373 +host: powerpc64le-unknown-linux-gnu
1374 +release: 1.47.0
1375 +LLVM version: 11.0",
1377 + .unwrap();
1379 + assert_eq!(version.semver, Version::parse("1.47.0").unwrap());
1380 + assert_eq!(
1381 + version.commit_hash,
1382 + Some("18bf6b4f01a6feaf7259ba7cdae58031af1b7b39".into())
1383 + );
1384 + assert_eq!(version.commit_date, Some("2020-10-07".into()));
1385 + assert_eq!(version.channel, Channel::Stable);
1386 + assert_eq!(version.host, "powerpc64le-unknown-linux-gnu");
1387 + assert_eq!(
1388 + version.short_version_string,
1389 + "rustc 1.47.0 (18bf6b4f0 2020-10-07)"
1390 + );
1391 + assert_eq!(
1392 + version.llvm_version,
1393 + Some(LlvmVersion {
1394 + major: 11,
1395 + minor: 0,
1396 + })
1397 + );
1400 +#[test]
1401 +fn parse_llvm_micro() {
1402 + let version = version_meta_for(
1403 + "rustc 1.51.0-nightly (4253153db 2021-01-17)
1404 +binary: rustc
1405 +commit-hash: 4253153db205251f72ea4493687a31e04a2a8ca0
1406 +commit-date: 2021-01-17
1407 +host: x86_64-pc-windows-msvc
1408 +release: 1.51.0-nightly
1409 +LLVM version: 11.0.1",
1411 + .unwrap();
1413 + assert_eq!(version.semver, Version::parse("1.51.0-nightly").unwrap());
1414 + assert_eq!(
1415 + version.commit_hash.unwrap(),
1416 + "4253153db205251f72ea4493687a31e04a2a8ca0"
1417 + );
1418 + assert_eq!(version.commit_date.unwrap(), "2021-01-17");
1419 + assert_eq!(version.host, "x86_64-pc-windows-msvc");
1420 + assert_eq!(
1421 + version.short_version_string,
1422 + "rustc 1.51.0-nightly (4253153db 2021-01-17)"
1423 + );
1424 + assert_eq!(
1425 + version.llvm_version,
1426 + Some(LlvmVersion {
1427 + major: 11,
1428 + minor: 0
1429 + })
1430 + );
1433 +#[test]
1434 +fn parse_debian_buster() {
1435 + let version = version_meta_for(
1436 + "rustc 1.41.1
1437 +binary: rustc
1438 +commit-hash: unknown
1439 +commit-date: unknown
1440 +host: powerpc64le-unknown-linux-gnu
1441 +release: 1.41.1
1442 +LLVM version: 7.0",
1444 + .unwrap();
1446 + assert_eq!(version.semver, Version::parse("1.41.1").unwrap());
1447 + assert_eq!(version.commit_hash, None);
1448 + assert_eq!(version.commit_date, None);
1449 + assert_eq!(version.channel, Channel::Stable);
1450 + assert_eq!(version.host, "powerpc64le-unknown-linux-gnu");
1451 + assert_eq!(version.short_version_string, "rustc 1.41.1");
1452 + assert_eq!(
1453 + version.llvm_version,
1454 + Some(LlvmVersion { major: 7, minor: 0 })
1455 + );
1458 +#[test]
1459 +fn parse_termux() {
1460 + let version = version_meta_for(
1461 + "rustc 1.46.0
1462 +binary: rustc
1463 +commit-hash: unknown
1464 +commit-date: unknown
1465 +host: aarch64-linux-android
1466 +release: 1.46.0
1467 +LLVM version: 10.0",
1469 + .unwrap();
1471 + assert_eq!(version.semver, Version::parse("1.46.0").unwrap());
1472 + assert_eq!(version.commit_hash, None);
1473 + assert_eq!(version.commit_date, None);
1474 + assert_eq!(version.channel, Channel::Stable);
1475 + assert_eq!(version.host, "aarch64-linux-android");
1476 + assert_eq!(version.short_version_string, "rustc 1.46.0");
1477 + assert_eq!(
1478 + version.llvm_version,
1479 + Some(LlvmVersion {
1480 + major: 10,
1481 + minor: 0,
1482 + })
1483 + );
1486 +#[test]
1487 +fn parse_llvm_version_empty() {
1488 + let res: Result<LlvmVersion, _> = "".parse();
1489 + assert!(match res {
1490 + Err(LlvmVersionParseError::ParseIntError(_)) => true,
1491 + _ => false,
1492 + });
1495 +#[test]
1496 +fn parse_llvm_version_invalid_char() {
1497 + let res: Result<LlvmVersion, _> = "A".parse();
1498 + assert!(match res {
1499 + Err(LlvmVersionParseError::ParseIntError(_)) => true,
1500 + _ => false,
1501 + });
1504 +#[test]
1505 +fn parse_llvm_version_overflow() {
1506 + let res: Result<LlvmVersion, _> = "9999999999999999999999999999999".parse();
1507 + assert!(match res {
1508 + Err(LlvmVersionParseError::ParseIntError(_)) => true,
1509 + _ => false,
1510 + });
1513 +#[test]
1514 +fn parse_llvm_version_leading_zero_on_zero() {
1515 + let res: Result<LlvmVersion, _> = "00".parse();
1516 + assert!(match res {
1517 + Err(LlvmVersionParseError::ComponentMustNotHaveLeadingZeros) => true,
1518 + _ => false,
1519 + });
1522 +#[test]
1523 +fn parse_llvm_version_leading_zero_on_nonzero() {
1524 + let res: Result<LlvmVersion, _> = "01".parse();
1525 + assert!(match res {
1526 + Err(LlvmVersionParseError::ComponentMustNotHaveLeadingZeros) => true,
1527 + _ => false,
1528 + });
1531 +#[test]
1532 +fn parse_llvm_version_4_components() {
1533 + let res: Result<LlvmVersion, _> = "4.0.0.0".parse();
1535 + assert!(match res {
1536 + Err(LlvmVersionParseError::TooManyComponents) => true,
1537 + _ => false,
1538 + });
1541 +#[test]
1542 +fn parse_llvm_version_component_sign_plus() {
1543 + let res: Result<LlvmVersion, _> = "1.+3".parse();
1545 + assert!(match res {
1546 + Err(LlvmVersionParseError::ComponentMustNotHaveSign) => true,
1547 + _ => false,
1548 + });
1551 +#[test]
1552 +fn parse_llvm_version_component_sign_minus() {
1553 + let res: Result<LlvmVersion, _> = "1.-3".parse();
1555 + assert!(match res {
1556 + Err(LlvmVersionParseError::ComponentMustNotHaveSign) => true,
1557 + _ => false,
1558 + });
1561 +#[test]
1562 +fn parse_llvm_version_3() {
1563 + let res: Result<LlvmVersion, _> = "3".parse();
1565 + assert!(match res {
1566 + Err(LlvmVersionParseError::MinorVersionRequiredBefore4) => true,
1567 + _ => false,
1568 + });
1571 +#[test]
1572 +fn parse_llvm_version_5() {
1573 + let v: LlvmVersion = "5".parse().unwrap();
1574 + assert_eq!(v, LlvmVersion { major: 5, minor: 0 });
1577 +#[test]
1578 +fn parse_llvm_version_5_0() {
1579 + let v: LlvmVersion = "5.0".parse().unwrap();
1580 + assert_eq!(v, LlvmVersion { major: 5, minor: 0 });
1583 +#[test]
1584 +fn parse_llvm_version_4_0() {
1585 + let v: LlvmVersion = "4.0".parse().unwrap();
1586 + assert_eq!(v, LlvmVersion { major: 4, minor: 0 });
1589 +#[test]
1590 +fn parse_llvm_version_3_0() {
1591 + let v: LlvmVersion = "3.0".parse().unwrap();
1592 + assert_eq!(v, LlvmVersion { major: 3, minor: 0 });
1595 +#[test]
1596 +fn parse_llvm_version_3_9() {
1597 + let v: LlvmVersion = "3.9".parse().unwrap();
1598 + assert_eq!(v, LlvmVersion { major: 3, minor: 9 });
1601 +#[test]
1602 +fn parse_llvm_version_11_0() {
1603 + let v: LlvmVersion = "11.0".parse().unwrap();
1604 + assert_eq!(
1605 + v,
1606 + LlvmVersion {
1607 + major: 11,
1608 + minor: 0
1610 + );
1613 +#[test]
1614 +fn parse_llvm_version_11() {
1615 + let v: LlvmVersion = "11".parse().unwrap();
1616 + assert_eq!(
1617 + v,
1618 + LlvmVersion {
1619 + major: 11,
1620 + minor: 0
1622 + );
1625 +#[test]
1626 +fn test_llvm_version_comparison() {
1627 + // check that field order is correct
1628 + assert!(LlvmVersion { major: 3, minor: 9 } < LlvmVersion { major: 4, minor: 0 });
1632 +#[test]
1633 +fn version_matches_replacement() {
1634 + let f = |s1: &str, s2: &str| {
1635 + let a = Version::parse(s1).unwrap();
1636 + let b = Version::parse(s2).unwrap();
1637 + println!("{} <= {} : {}", s1, s2, a <= b);
1638 + };
1640 + println!();
1642 + f("1.5.0", "1.5.0");
1643 + f("1.5.0-nightly", "1.5.0");
1644 + f("1.5.0", "1.5.0-nightly");
1645 + f("1.5.0-nightly", "1.5.0-nightly");
1647 + f("1.5.0", "1.6.0");
1648 + f("1.5.0-nightly", "1.6.0");
1649 + f("1.5.0", "1.6.0-nightly");
1650 + f("1.5.0-nightly", "1.6.0-nightly");
1652 + panic!();
1656 diff --git a/third_party/rust/semver-parser/.cargo-checksum.json b/third_party/rust/semver-parser/.cargo-checksum.json
1657 deleted file mode 100644
1658 --- a/third_party/rust/semver-parser/.cargo-checksum.json
1659 +++ /dev/null
1660 @@ -1,1 +0,0 @@
1661 -{"files":{"Cargo.toml":"67597114802114d2a7fdb457c1cf5f7e0c951b21e287c6a47b9a86b9028cf64d","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"d38feaa4f9468cd1e0ece22e0ad2eadfe6195a9a0a3843b7c722d5c7d81804fb","src/common.rs":"dc42336abd34e19ca9f732f33657e106f98dcc8c10d4c2564bc4f160cb31926e","src/lib.rs":"3ac8ef5a280344a25cb18ac386034c0fee8d64060fa14af5e25ed49f0cb2fd9e","src/range.rs":"3596f048d466d43887aff1e8c8c834476672a4627631ed35379c35466b5f02ec","src/recognize.rs":"9f16eda9fcd7d8af7eee4c3b89c611bd648040273fde6b35778f8a50b004c8b1","src/version.rs":"dbd91a4e4fd92a0aa9eb4f858ecbc1ecd680aa60572cc2ad2085e5c5c30e5b77"},"package":"388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3"}
1662 \ No newline at end of file
1663 diff --git a/third_party/rust/semver-parser/Cargo.toml b/third_party/rust/semver-parser/Cargo.toml
1664 deleted file mode 100644
1665 --- a/third_party/rust/semver-parser/Cargo.toml
1666 +++ /dev/null
1667 @@ -1,11 +0,0 @@
1668 -[package]
1669 -name = "semver-parser"
1670 -version = "0.7.0"
1671 -authors = ["Steve Klabnik <steve@steveklabnik.com>"]
1672 -license = "MIT/Apache-2.0"
1673 -repository = "https://github.com/steveklabnik/semver-parser"
1674 -homepage = "https://github.com/steveklabnik/semver-parser"
1675 -documentation = "https://docs.rs/semver-parser"
1676 -description = """
1677 -Parsing of the semver spec.
1678 -"""
1679 diff --git a/third_party/rust/semver-parser/LICENSE-APACHE b/third_party/rust/semver-parser/LICENSE-APACHE
1680 deleted file mode 100644
1681 --- a/third_party/rust/semver-parser/LICENSE-APACHE
1682 +++ /dev/null
1683 @@ -1,201 +0,0 @@
1684 - Apache License
1685 - Version 2.0, January 2004
1686 - http://www.apache.org/licenses/
1688 -TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1690 -1. Definitions.
1692 - "License" shall mean the terms and conditions for use, reproduction,
1693 - and distribution as defined by Sections 1 through 9 of this document.
1695 - "Licensor" shall mean the copyright owner or entity authorized by
1696 - the copyright owner that is granting the License.
1698 - "Legal Entity" shall mean the union of the acting entity and all
1699 - other entities that control, are controlled by, or are under common
1700 - control with that entity. For the purposes of this definition,
1701 - "control" means (i) the power, direct or indirect, to cause the
1702 - direction or management of such entity, whether by contract or
1703 - otherwise, or (ii) ownership of fifty percent (50%) or more of the
1704 - outstanding shares, or (iii) beneficial ownership of such entity.
1706 - "You" (or "Your") shall mean an individual or Legal Entity
1707 - exercising permissions granted by this License.
1709 - "Source" form shall mean the preferred form for making modifications,
1710 - including but not limited to software source code, documentation
1711 - source, and configuration files.
1713 - "Object" form shall mean any form resulting from mechanical
1714 - transformation or translation of a Source form, including but
1715 - not limited to compiled object code, generated documentation,
1716 - and conversions to other media types.
1718 - "Work" shall mean the work of authorship, whether in Source or
1719 - Object form, made available under the License, as indicated by a
1720 - copyright notice that is included in or attached to the work
1721 - (an example is provided in the Appendix below).
1723 - "Derivative Works" shall mean any work, whether in Source or Object
1724 - form, that is based on (or derived from) the Work and for which the
1725 - editorial revisions, annotations, elaborations, or other modifications
1726 - represent, as a whole, an original work of authorship. For the purposes
1727 - of this License, Derivative Works shall not include works that remain
1728 - separable from, or merely link (or bind by name) to the interfaces of,
1729 - the Work and Derivative Works thereof.
1731 - "Contribution" shall mean any work of authorship, including
1732 - the original version of the Work and any modifications or additions
1733 - to that Work or Derivative Works thereof, that is intentionally
1734 - submitted to Licensor for inclusion in the Work by the copyright owner
1735 - or by an individual or Legal Entity authorized to submit on behalf of
1736 - the copyright owner. For the purposes of this definition, "submitted"
1737 - means any form of electronic, verbal, or written communication sent
1738 - to the Licensor or its representatives, including but not limited to
1739 - communication on electronic mailing lists, source code control systems,
1740 - and issue tracking systems that are managed by, or on behalf of, the
1741 - Licensor for the purpose of discussing and improving the Work, but
1742 - excluding communication that is conspicuously marked or otherwise
1743 - designated in writing by the copyright owner as "Not a Contribution."
1745 - "Contributor" shall mean Licensor and any individual or Legal Entity
1746 - on behalf of whom a Contribution has been received by Licensor and
1747 - subsequently incorporated within the Work.
1749 -2. Grant of Copyright License. Subject to the terms and conditions of
1750 - this License, each Contributor hereby grants to You a perpetual,
1751 - worldwide, non-exclusive, no-charge, royalty-free, irrevocable
1752 - copyright license to reproduce, prepare Derivative Works of,
1753 - publicly display, publicly perform, sublicense, and distribute the
1754 - Work and such Derivative Works in Source or Object form.
1756 -3. Grant of Patent License. Subject to the terms and conditions of
1757 - this License, each Contributor hereby grants to You a perpetual,
1758 - worldwide, non-exclusive, no-charge, royalty-free, irrevocable
1759 - (except as stated in this section) patent license to make, have made,
1760 - use, offer to sell, sell, import, and otherwise transfer the Work,
1761 - where such license applies only to those patent claims licensable
1762 - by such Contributor that are necessarily infringed by their
1763 - Contribution(s) alone or by combination of their Contribution(s)
1764 - with the Work to which such Contribution(s) was submitted. If You
1765 - institute patent litigation against any entity (including a
1766 - cross-claim or counterclaim in a lawsuit) alleging that the Work
1767 - or a Contribution incorporated within the Work constitutes direct
1768 - or contributory patent infringement, then any patent licenses
1769 - granted to You under this License for that Work shall terminate
1770 - as of the date such litigation is filed.
1772 -4. Redistribution. You may reproduce and distribute copies of the
1773 - Work or Derivative Works thereof in any medium, with or without
1774 - modifications, and in Source or Object form, provided that You
1775 - meet the following conditions:
1777 - (a) You must give any other recipients of the Work or
1778 - Derivative Works a copy of this License; and
1780 - (b) You must cause any modified files to carry prominent notices
1781 - stating that You changed the files; and
1783 - (c) You must retain, in the Source form of any Derivative Works
1784 - that You distribute, all copyright, patent, trademark, and
1785 - attribution notices from the Source form of the Work,
1786 - excluding those notices that do not pertain to any part of
1787 - the Derivative Works; and
1789 - (d) If the Work includes a "NOTICE" text file as part of its
1790 - distribution, then any Derivative Works that You distribute must
1791 - include a readable copy of the attribution notices contained
1792 - within such NOTICE file, excluding those notices that do not
1793 - pertain to any part of the Derivative Works, in at least one
1794 - of the following places: within a NOTICE text file distributed
1795 - as part of the Derivative Works; within the Source form or
1796 - documentation, if provided along with the Derivative Works; or,
1797 - within a display generated by the Derivative Works, if and
1798 - wherever such third-party notices normally appear. The contents
1799 - of the NOTICE file are for informational purposes only and
1800 - do not modify the License. You may add Your own attribution
1801 - notices within Derivative Works that You distribute, alongside
1802 - or as an addendum to the NOTICE text from the Work, provided
1803 - that such additional attribution notices cannot be construed
1804 - as modifying the License.
1806 - You may add Your own copyright statement to Your modifications and
1807 - may provide additional or different license terms and conditions
1808 - for use, reproduction, or distribution of Your modifications, or
1809 - for any such Derivative Works as a whole, provided Your use,
1810 - reproduction, and distribution of the Work otherwise complies with
1811 - the conditions stated in this License.
1813 -5. Submission of Contributions. Unless You explicitly state otherwise,
1814 - any Contribution intentionally submitted for inclusion in the Work
1815 - by You to the Licensor shall be under the terms and conditions of
1816 - this License, without any additional terms or conditions.
1817 - Notwithstanding the above, nothing herein shall supersede or modify
1818 - the terms of any separate license agreement you may have executed
1819 - with Licensor regarding such Contributions.
1821 -6. Trademarks. This License does not grant permission to use the trade
1822 - names, trademarks, service marks, or product names of the Licensor,
1823 - except as required for reasonable and customary use in describing the
1824 - origin of the Work and reproducing the content of the NOTICE file.
1826 -7. Disclaimer of Warranty. Unless required by applicable law or
1827 - agreed to in writing, Licensor provides the Work (and each
1828 - Contributor provides its Contributions) on an "AS IS" BASIS,
1829 - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
1830 - implied, including, without limitation, any warranties or conditions
1831 - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
1832 - PARTICULAR PURPOSE. You are solely responsible for determining the
1833 - appropriateness of using or redistributing the Work and assume any
1834 - risks associated with Your exercise of permissions under this License.
1836 -8. Limitation of Liability. In no event and under no legal theory,
1837 - whether in tort (including negligence), contract, or otherwise,
1838 - unless required by applicable law (such as deliberate and grossly
1839 - negligent acts) or agreed to in writing, shall any Contributor be
1840 - liable to You for damages, including any direct, indirect, special,
1841 - incidental, or consequential damages of any character arising as a
1842 - result of this License or out of the use or inability to use the
1843 - Work (including but not limited to damages for loss of goodwill,
1844 - work stoppage, computer failure or malfunction, or any and all
1845 - other commercial damages or losses), even if such Contributor
1846 - has been advised of the possibility of such damages.
1848 -9. Accepting Warranty or Additional Liability. While redistributing
1849 - the Work or Derivative Works thereof, You may choose to offer,
1850 - and charge a fee for, acceptance of support, warranty, indemnity,
1851 - or other liability obligations and/or rights consistent with this
1852 - License. However, in accepting such obligations, You may act only
1853 - on Your own behalf and on Your sole responsibility, not on behalf
1854 - of any other Contributor, and only if You agree to indemnify,
1855 - defend, and hold each Contributor harmless for any liability
1856 - incurred by, or claims asserted against, such Contributor by reason
1857 - of your accepting any such warranty or additional liability.
1859 -END OF TERMS AND CONDITIONS
1861 -APPENDIX: How to apply the Apache License to your work.
1863 - To apply the Apache License to your work, attach the following
1864 - boilerplate notice, with the fields enclosed by brackets "[]"
1865 - replaced with your own identifying information. (Don't include
1866 - the brackets!) The text should be enclosed in the appropriate
1867 - comment syntax for the file format. We also recommend that a
1868 - file or class name and description of purpose be included on the
1869 - same "printed page" as the copyright notice for easier
1870 - identification within third-party archives.
1872 -Copyright [yyyy] [name of copyright owner]
1874 -Licensed under the Apache License, Version 2.0 (the "License");
1875 -you may not use this file except in compliance with the License.
1876 -You may obtain a copy of the License at
1878 - http://www.apache.org/licenses/LICENSE-2.0
1880 -Unless required by applicable law or agreed to in writing, software
1881 -distributed under the License is distributed on an "AS IS" BASIS,
1882 -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1883 -See the License for the specific language governing permissions and
1884 -limitations under the License.
1885 diff --git a/third_party/rust/semver-parser/LICENSE-MIT b/third_party/rust/semver-parser/LICENSE-MIT
1886 deleted file mode 100644
1887 --- a/third_party/rust/semver-parser/LICENSE-MIT
1888 +++ /dev/null
1889 @@ -1,25 +0,0 @@
1890 -Copyright (c) 2016 Steve Klabnik
1892 -Permission is hereby granted, free of charge, to any
1893 -person obtaining a copy of this software and associated
1894 -documentation files (the "Software"), to deal in the
1895 -Software without restriction, including without
1896 -limitation the rights to use, copy, modify, merge,
1897 -publish, distribute, sublicense, and/or sell copies of
1898 -the Software, and to permit persons to whom the Software
1899 -is furnished to do so, subject to the following
1900 -conditions:
1902 -The above copyright notice and this permission notice
1903 -shall be included in all copies or substantial portions
1904 -of the Software.
1906 -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
1907 -ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
1908 -TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
1909 -PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
1910 -SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
1911 -CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
1912 -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
1913 -IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
1914 -DEALINGS IN THE SOFTWARE.
1915 diff --git a/third_party/rust/semver-parser/src/common.rs b/third_party/rust/semver-parser/src/common.rs
1916 deleted file mode 100644
1917 --- a/third_party/rust/semver-parser/src/common.rs
1918 +++ /dev/null
1919 @@ -1,66 +0,0 @@
1920 -use version::Identifier;
1921 -use recognize::{Recognize, Alt, OneOrMore, Inclusive, OneByte};
1922 -use std::str::from_utf8;
1924 -// by the time we get here, we know that it's all valid characters, so this doesn't need to return
1925 -// a result or anything
1926 -fn parse_meta(s: &str) -> Vec<Identifier> {
1927 - // Originally, I wanted to implement this method via calling parse, but parse is tolerant of
1928 - // leading zeroes, and we want anything with leading zeroes to be considered alphanumeric, not
1929 - // numeric. So the strategy is to check with a recognizer first, and then call parse once
1930 - // we've determined that it's a number without a leading zero.
1931 - s.split(".")
1932 - .map(|part| {
1933 - // another wrinkle: we made sure that any number starts with a
1934 - // non-zero. But there's a problem: an actual zero is a number, yet
1935 - // gets left out by this heuristic. So let's also check for the
1936 - // single, lone zero.
1937 - if is_alpha_numeric(part) {
1938 - Identifier::AlphaNumeric(part.to_string())
1939 - } else {
1940 - // we can unwrap here because we know it is only digits due to the regex
1941 - Identifier::Numeric(part.parse().unwrap())
1943 - }).collect()
1946 -// parse optional metadata (preceded by the prefix character)
1947 -pub fn parse_optional_meta(s: &[u8], prefix_char: u8)-> Result<(Vec<Identifier>, usize), String> {
1948 - if let Some(len) = prefix_char.p(s) {
1949 - let start = len;
1950 - if let Some(len) = letters_numbers_dash_dot(&s[start..]) {
1951 - let end = start + len;
1952 - Ok((parse_meta(from_utf8(&s[start..end]).unwrap()), end))
1953 - } else {
1954 - Err("Error parsing prerelease".to_string())
1956 - } else {
1957 - Ok((Vec::new(), 0))
1961 -pub fn is_alpha_numeric(s: &str) -> bool {
1962 - if let Some((_val, len)) = numeric_identifier(s.as_bytes()) {
1963 - // Return true for number with leading zero
1964 - // Note: doing it this way also handily makes overflow fail over.
1965 - len != s.len()
1966 - } else {
1967 - true
1971 -// Note: could plumb overflow error up to return value as Result
1972 -pub fn numeric_identifier(s: &[u8]) -> Option<(u64, usize)> {
1973 - if let Some(len) = Alt(b'0', OneOrMore(Inclusive(b'0'..b'9'))).p(s) {
1974 - from_utf8(&s[0..len]).unwrap().parse().ok().map(|val| (val, len))
1975 - } else {
1976 - None
1980 -pub fn letters_numbers_dash_dot(s: &[u8]) -> Option<usize> {
1981 - OneOrMore(OneByte(|c| c == b'-' || c == b'.' ||
1982 - (b'0' <= c && c <= b'9') ||
1983 - (b'a' <= c && c <= b'z') ||
1984 - (b'A' <= c && c <= b'Z'))).p(s)
1986 diff --git a/third_party/rust/semver-parser/src/lib.rs b/third_party/rust/semver-parser/src/lib.rs
1987 deleted file mode 100644
1988 --- a/third_party/rust/semver-parser/src/lib.rs
1989 +++ /dev/null
1990 @@ -1,8 +0,0 @@
1991 -pub mod version;
1992 -pub mod range;
1994 -// for private stuff the two share
1995 -mod common;
1997 -// for recognizer combinators
1998 -mod recognize;
1999 diff --git a/third_party/rust/semver-parser/src/range.rs b/third_party/rust/semver-parser/src/range.rs
2000 deleted file mode 100644
2001 --- a/third_party/rust/semver-parser/src/range.rs
2002 +++ /dev/null
2003 @@ -1,696 +0,0 @@
2004 -use common::{self, numeric_identifier, letters_numbers_dash_dot};
2005 -use version::Identifier;
2006 -use std::str::{FromStr, from_utf8};
2007 -use recognize::*;
2009 -#[derive(Debug)]
2010 -pub struct VersionReq {
2011 - pub predicates: Vec<Predicate>,
2014 -#[derive(PartialEq,Debug)]
2015 -pub enum WildcardVersion {
2016 - Major,
2017 - Minor,
2018 - Patch,
2021 -#[derive(PartialEq,Debug)]
2022 -pub enum Op {
2023 - Ex, // Exact
2024 - Gt, // Greater than
2025 - GtEq, // Greater than or equal to
2026 - Lt, // Less than
2027 - LtEq, // Less than or equal to
2028 - Tilde, // e.g. ~1.0.0
2029 - Compatible, // compatible by definition of semver, indicated by ^
2030 - Wildcard(WildcardVersion), // x.y.*, x.*, *
2033 -impl FromStr for Op {
2034 - type Err = String;
2036 - fn from_str(s: &str) -> Result<Op, String> {
2037 - match s {
2038 - "=" => Ok(Op::Ex),
2039 - ">" => Ok(Op::Gt),
2040 - ">=" => Ok(Op::GtEq),
2041 - "<" => Ok(Op::Lt),
2042 - "<=" => Ok(Op::LtEq),
2043 - "~" => Ok(Op::Tilde),
2044 - "^" => Ok(Op::Compatible),
2045 - _ => Err(String::from("Could not parse Op")),
2050 -#[derive(PartialEq,Debug)]
2051 -pub struct Predicate {
2052 - pub op: Op,
2053 - pub major: u64,
2054 - pub minor: Option<u64>,
2055 - pub patch: Option<u64>,
2056 - pub pre: Vec<Identifier>,
2059 -fn numeric_or_wild(s: &[u8]) -> Option<(Option<u64>, usize)> {
2060 - if let Some((val, len)) = numeric_identifier(s) {
2061 - Some((Some(val), len))
2062 - } else if let Some(len) = OneOf(b"*xX").p(s) {
2063 - Some((None, len))
2064 - } else {
2065 - None
2069 -fn dot_numeric_or_wild(s: &[u8]) -> Option<(Option<u64>, usize)> {
2070 - b'.'.p(s).and_then(|len|
2071 - numeric_or_wild(&s[len..]).map(|(val, len2)| (val, len + len2))
2075 -fn operation(s: &[u8]) -> Option<(Op, usize)> {
2076 - if let Some(len) = "=".p(s) {
2077 - Some((Op::Ex, len))
2078 - } else if let Some(len) = ">=".p(s) {
2079 - Some((Op::GtEq, len))
2080 - } else if let Some(len) = ">".p(s) {
2081 - Some((Op::Gt, len))
2082 - } else if let Some(len) = "<=".p(s) {
2083 - Some((Op::LtEq, len))
2084 - } else if let Some(len) = "<".p(s) {
2085 - Some((Op::Lt, len))
2086 - } else if let Some(len) = "~".p(s) {
2087 - Some((Op::Tilde, len))
2088 - } else if let Some(len) = "^".p(s) {
2089 - Some((Op::Compatible, len))
2090 - } else {
2091 - None
2095 -fn whitespace(s: &[u8]) -> Option<usize> {
2096 - ZeroOrMore(OneOf(b"\t\r\n ")).p(s)
2099 -pub fn parse_predicate(range: &str) -> Result<Predicate, String> {
2100 - let s = range.trim().as_bytes();
2101 - let mut i = 0;
2102 - let mut operation = if let Some((op, len)) = operation(&s[i..]) {
2103 - i += len;
2104 - op
2105 - } else {
2106 - // operations default to Compatible
2107 - Op::Compatible
2108 - };
2109 - if let Some(len) = whitespace.p(&s[i..]) {
2110 - i += len;
2112 - let major = if let Some((major, len)) = numeric_identifier(&s[i..]) {
2113 - i += len;
2114 - major
2115 - } else {
2116 - return Err("Error parsing major version number: ".to_string());
2117 - };
2118 - let minor = if let Some((minor, len)) = dot_numeric_or_wild(&s[i..]) {
2119 - i += len;
2120 - if minor.is_none() {
2121 - operation = Op::Wildcard(WildcardVersion::Minor);
2123 - minor
2124 - } else {
2125 - None
2126 - };
2127 - let patch = if let Some((patch, len)) = dot_numeric_or_wild(&s[i..]) {
2128 - i += len;
2129 - if patch.is_none() {
2130 - operation = Op::Wildcard(WildcardVersion::Patch);
2132 - patch
2133 - } else {
2134 - None
2135 - };
2136 - let (pre, pre_len) = common::parse_optional_meta(&s[i..], b'-')?;
2137 - i += pre_len;
2138 - if let Some(len) = (b'+', letters_numbers_dash_dot).p(&s[i..]) {
2139 - i += len;
2141 - if i != s.len() {
2142 - return Err("Extra junk after valid predicate: ".to_string() +
2143 - from_utf8(&s[i..]).unwrap());
2145 - Ok(Predicate {
2146 - op: operation,
2147 - major: major,
2148 - minor: minor,
2149 - patch: patch,
2150 - pre: pre,
2151 - })
2154 -pub fn parse(ranges: &str) -> Result<VersionReq, String> {
2155 - // null is an error
2156 - if ranges == "\0" {
2157 - return Err(String::from("Null is not a valid VersionReq"));
2160 - // an empty range is a major version wildcard
2161 - // so is a lone * or x of either capitalization
2162 - if (ranges == "")
2163 - || (ranges == "*")
2164 - || (ranges == "x")
2165 - || (ranges == "X") {
2166 - return Ok(VersionReq {
2167 - predicates: vec![Predicate {
2168 - op: Op::Wildcard(WildcardVersion::Major),
2169 - major: 0,
2170 - minor: None,
2171 - patch: None,
2172 - pre: Vec::new(),
2173 - }],
2174 - });
2178 - let ranges = ranges.trim();
2180 - let predicates: Result<Vec<_>, String> = ranges
2181 - .split(",")
2182 - .map(|range| {
2183 - parse_predicate(range)
2184 - })
2185 - .collect();
2187 - let predicates = try!(predicates);
2189 - if predicates.len() == 0 {
2190 - return Err(String::from("VersionReq did not parse properly"));
2193 - Ok(VersionReq {
2194 - predicates: predicates,
2195 - })
2198 -#[cfg(test)]
2199 -mod tests {
2200 - use super::*;
2201 - use range;
2202 - use version::Identifier;
2204 - #[test]
2205 - fn test_parsing_default() {
2206 - let r = range::parse("1.0.0").unwrap();
2208 - assert_eq!(Predicate {
2209 - op: Op::Compatible,
2210 - major: 1,
2211 - minor: Some(0),
2212 - patch: Some(0),
2213 - pre: Vec::new(),
2214 - },
2215 - r.predicates[0]
2216 - );
2219 - #[test]
2220 - fn test_parsing_exact_01() {
2221 - let r = range::parse("=1.0.0").unwrap();
2223 - assert_eq!(Predicate {
2224 - op: Op::Ex,
2225 - major: 1,
2226 - minor: Some(0),
2227 - patch: Some(0),
2228 - pre: Vec::new(),
2229 - },
2230 - r.predicates[0]
2231 - );
2234 - #[test]
2235 - fn test_parsing_exact_02() {
2236 - let r = range::parse("=0.9.0").unwrap();
2238 - assert_eq!(Predicate {
2239 - op: Op::Ex,
2240 - major: 0,
2241 - minor: Some(9),
2242 - patch: Some(0),
2243 - pre: Vec::new(),
2244 - },
2245 - r.predicates[0]
2246 - );
2249 - #[test]
2250 - fn test_parsing_exact_03() {
2251 - let r = range::parse("=0.1.0-beta2.a").unwrap();
2253 - assert_eq!(Predicate {
2254 - op: Op::Ex,
2255 - major: 0,
2256 - minor: Some(1),
2257 - patch: Some(0),
2258 - pre: vec![Identifier::AlphaNumeric(String::from("beta2")),
2259 - Identifier::AlphaNumeric(String::from("a"))],
2260 - },
2261 - r.predicates[0]
2262 - );
2265 - #[test]
2266 - pub fn test_parsing_greater_than() {
2267 - let r = range::parse("> 1.0.0").unwrap();
2269 - assert_eq!(Predicate {
2270 - op: Op::Gt,
2271 - major: 1,
2272 - minor: Some(0),
2273 - patch: Some(0),
2274 - pre: Vec::new(),
2275 - },
2276 - r.predicates[0]
2277 - );
2280 - #[test]
2281 - pub fn test_parsing_greater_than_01() {
2282 - let r = range::parse(">= 1.0.0").unwrap();
2284 - assert_eq!(Predicate {
2285 - op: Op::GtEq,
2286 - major: 1,
2287 - minor: Some(0),
2288 - patch: Some(0),
2289 - pre: Vec::new(),
2290 - },
2291 - r.predicates[0]
2292 - );
2295 - #[test]
2296 - pub fn test_parsing_greater_than_02() {
2297 - let r = range::parse(">= 2.1.0-alpha2").unwrap();
2299 - assert_eq!(Predicate {
2300 - op: Op::GtEq,
2301 - major: 2,
2302 - minor: Some(1),
2303 - patch: Some(0),
2304 - pre: vec![Identifier::AlphaNumeric(String::from("alpha2"))],
2305 - },
2306 - r.predicates[0]
2307 - );
2310 - #[test]
2311 - pub fn test_parsing_less_than() {
2312 - let r = range::parse("< 1.0.0").unwrap();
2314 - assert_eq!(Predicate {
2315 - op: Op::Lt,
2316 - major: 1,
2317 - minor: Some(0),
2318 - patch: Some(0),
2319 - pre: Vec::new(),
2320 - },
2321 - r.predicates[0]
2322 - );
2325 - #[test]
2326 - pub fn test_parsing_less_than_eq() {
2327 - let r = range::parse("<= 2.1.0-alpha2").unwrap();
2329 - assert_eq!(Predicate {
2330 - op: Op::LtEq,
2331 - major: 2,
2332 - minor: Some(1),
2333 - patch: Some(0),
2334 - pre: vec![Identifier::AlphaNumeric(String::from("alpha2"))],
2335 - },
2336 - r.predicates[0]
2337 - );
2340 - #[test]
2341 - pub fn test_parsing_tilde() {
2342 - let r = range::parse("~1").unwrap();
2344 - assert_eq!(Predicate {
2345 - op: Op::Tilde,
2346 - major: 1,
2347 - minor: None,
2348 - patch: None,
2349 - pre: Vec::new(),
2350 - },
2351 - r.predicates[0]
2352 - );
2355 - #[test]
2356 - pub fn test_parsing_compatible() {
2357 - let r = range::parse("^0").unwrap();
2359 - assert_eq!(Predicate {
2360 - op: Op::Compatible,
2361 - major: 0,
2362 - minor: None,
2363 - patch: None,
2364 - pre: Vec::new(),
2365 - },
2366 - r.predicates[0]
2367 - );
2370 - #[test]
2371 - fn test_parsing_blank() {
2372 - let r = range::parse("").unwrap();
2374 - assert_eq!(Predicate {
2375 - op: Op::Wildcard(WildcardVersion::Major),
2376 - major: 0,
2377 - minor: None,
2378 - patch: None,
2379 - pre: Vec::new(),
2380 - },
2381 - r.predicates[0]
2382 - );
2385 - #[test]
2386 - fn test_parsing_wildcard() {
2387 - let r = range::parse("*").unwrap();
2389 - assert_eq!(Predicate {
2390 - op: Op::Wildcard(WildcardVersion::Major),
2391 - major: 0,
2392 - minor: None,
2393 - patch: None,
2394 - pre: Vec::new(),
2395 - },
2396 - r.predicates[0]
2397 - );
2400 - #[test]
2401 - fn test_parsing_x() {
2402 - let r = range::parse("x").unwrap();
2404 - assert_eq!(Predicate {
2405 - op: Op::Wildcard(WildcardVersion::Major),
2406 - major: 0,
2407 - minor: None,
2408 - patch: None,
2409 - pre: Vec::new(),
2410 - },
2411 - r.predicates[0]
2412 - );
2415 - #[test]
2416 - fn test_parsing_capital_x() {
2417 - let r = range::parse("X").unwrap();
2419 - assert_eq!(Predicate {
2420 - op: Op::Wildcard(WildcardVersion::Major),
2421 - major: 0,
2422 - minor: None,
2423 - patch: None,
2424 - pre: Vec::new(),
2425 - },
2426 - r.predicates[0]
2427 - );
2430 - #[test]
2431 - fn test_parsing_minor_wildcard_star() {
2432 - let r = range::parse("1.*").unwrap();
2434 - assert_eq!(Predicate {
2435 - op: Op::Wildcard(WildcardVersion::Minor),
2436 - major: 1,
2437 - minor: None,
2438 - patch: None,
2439 - pre: Vec::new(),
2440 - },
2441 - r.predicates[0]
2442 - );
2445 - #[test]
2446 - fn test_parsing_minor_wildcard_x() {
2447 - let r = range::parse("1.x").unwrap();
2449 - assert_eq!(Predicate {
2450 - op: Op::Wildcard(WildcardVersion::Minor),
2451 - major: 1,
2452 - minor: None,
2453 - patch: None,
2454 - pre: Vec::new(),
2455 - },
2456 - r.predicates[0]
2457 - );
2460 - #[test]
2461 - fn test_parsing_minor_wildcard_capital_x() {
2462 - let r = range::parse("1.X").unwrap();
2464 - assert_eq!(Predicate {
2465 - op: Op::Wildcard(WildcardVersion::Minor),
2466 - major: 1,
2467 - minor: None,
2468 - patch: None,
2469 - pre: Vec::new(),
2470 - },
2471 - r.predicates[0]
2472 - );
2475 - #[test]
2476 - fn test_parsing_patch_wildcard_star() {
2477 - let r = range::parse("1.2.*").unwrap();
2479 - assert_eq!(Predicate {
2480 - op: Op::Wildcard(WildcardVersion::Patch),
2481 - major: 1,
2482 - minor: Some(2),
2483 - patch: None,
2484 - pre: Vec::new(),
2485 - },
2486 - r.predicates[0]
2487 - );
2490 - #[test]
2491 - fn test_parsing_patch_wildcard_x() {
2492 - let r = range::parse("1.2.x").unwrap();
2494 - assert_eq!(Predicate {
2495 - op: Op::Wildcard(WildcardVersion::Patch),
2496 - major: 1,
2497 - minor: Some(2),
2498 - patch: None,
2499 - pre: Vec::new(),
2500 - },
2501 - r.predicates[0]
2502 - );
2505 - #[test]
2506 - fn test_parsing_patch_wildcard_capital_x() {
2507 - let r = range::parse("1.2.X").unwrap();
2509 - assert_eq!(Predicate {
2510 - op: Op::Wildcard(WildcardVersion::Patch),
2511 - major: 1,
2512 - minor: Some(2),
2513 - patch: None,
2514 - pre: Vec::new(),
2515 - },
2516 - r.predicates[0]
2517 - );
2520 - #[test]
2521 - pub fn test_multiple_01() {
2522 - let r = range::parse("> 0.0.9, <= 2.5.3").unwrap();
2524 - assert_eq!(Predicate {
2525 - op: Op::Gt,
2526 - major: 0,
2527 - minor: Some(0),
2528 - patch: Some(9),
2529 - pre: Vec::new(),
2530 - },
2531 - r.predicates[0]
2532 - );
2534 - assert_eq!(Predicate {
2535 - op: Op::LtEq,
2536 - major: 2,
2537 - minor: Some(5),
2538 - patch: Some(3),
2539 - pre: Vec::new(),
2540 - },
2541 - r.predicates[1]
2542 - );
2545 - #[test]
2546 - pub fn test_multiple_02() {
2547 - let r = range::parse("0.3.0, 0.4.0").unwrap();
2549 - assert_eq!(Predicate {
2550 - op: Op::Compatible,
2551 - major: 0,
2552 - minor: Some(3),
2553 - patch: Some(0),
2554 - pre: Vec::new(),
2555 - },
2556 - r.predicates[0]
2557 - );
2559 - assert_eq!(Predicate {
2560 - op: Op::Compatible,
2561 - major: 0,
2562 - minor: Some(4),
2563 - patch: Some(0),
2564 - pre: Vec::new(),
2565 - },
2566 - r.predicates[1]
2567 - );
2570 - #[test]
2571 - pub fn test_multiple_03() {
2572 - let r = range::parse("<= 0.2.0, >= 0.5.0").unwrap();
2574 - assert_eq!(Predicate {
2575 - op: Op::LtEq,
2576 - major: 0,
2577 - minor: Some(2),
2578 - patch: Some(0),
2579 - pre: Vec::new(),
2580 - },
2581 - r.predicates[0]
2582 - );
2584 - assert_eq!(Predicate {
2585 - op: Op::GtEq,
2586 - major: 0,
2587 - minor: Some(5),
2588 - patch: Some(0),
2589 - pre: Vec::new(),
2590 - },
2591 - r.predicates[1]
2592 - );
2595 - #[test]
2596 - pub fn test_multiple_04() {
2597 - let r = range::parse("0.1.0, 0.1.4, 0.1.6").unwrap();
2599 - assert_eq!(Predicate {
2600 - op: Op::Compatible,
2601 - major: 0,
2602 - minor: Some(1),
2603 - patch: Some(0),
2604 - pre: Vec::new(),
2605 - },
2606 - r.predicates[0]
2607 - );
2609 - assert_eq!(Predicate {
2610 - op: Op::Compatible,
2611 - major: 0,
2612 - minor: Some(1),
2613 - patch: Some(4),
2614 - pre: Vec::new(),
2615 - },
2616 - r.predicates[1]
2617 - );
2619 - assert_eq!(Predicate {
2620 - op: Op::Compatible,
2621 - major: 0,
2622 - minor: Some(1),
2623 - patch: Some(6),
2624 - pre: Vec::new(),
2625 - },
2626 - r.predicates[2]
2627 - );
2630 - #[test]
2631 - pub fn test_multiple_05() {
2632 - let r = range::parse(">=0.5.1-alpha3, <0.6").unwrap();
2634 - assert_eq!(Predicate {
2635 - op: Op::GtEq,
2636 - major: 0,
2637 - minor: Some(5),
2638 - patch: Some(1),
2639 - pre: vec![Identifier::AlphaNumeric(String::from("alpha3"))],
2640 - },
2641 - r.predicates[0]
2642 - );
2644 - assert_eq!(Predicate {
2645 - op: Op::Lt,
2646 - major: 0,
2647 - minor: Some(6),
2648 - patch: None,
2649 - pre: Vec::new(),
2650 - },
2651 - r.predicates[1]
2652 - );
2655 - #[test]
2656 - fn test_parse_build_metadata_with_predicate() {
2657 - assert_eq!(range::parse("^1.2.3+meta").unwrap().predicates[0].op,
2658 - Op::Compatible);
2659 - assert_eq!(range::parse("~1.2.3+meta").unwrap().predicates[0].op,
2660 - Op::Tilde);
2661 - assert_eq!(range::parse("=1.2.3+meta").unwrap().predicates[0].op,
2662 - Op::Ex);
2663 - assert_eq!(range::parse("<=1.2.3+meta").unwrap().predicates[0].op,
2664 - Op::LtEq);
2665 - assert_eq!(range::parse(">=1.2.3+meta").unwrap().predicates[0].op,
2666 - Op::GtEq);
2667 - assert_eq!(range::parse("<1.2.3+meta").unwrap().predicates[0].op,
2668 - Op::Lt);
2669 - assert_eq!(range::parse(">1.2.3+meta").unwrap().predicates[0].op,
2670 - Op::Gt);
2673 - #[test]
2674 - pub fn test_parse_errors() {
2675 - assert!(range::parse("\0").is_err());
2676 - assert!(range::parse(">= >= 0.0.2").is_err());
2677 - assert!(range::parse(">== 0.0.2").is_err());
2678 - assert!(range::parse("a.0.0").is_err());
2679 - assert!(range::parse("1.0.0-").is_err());
2680 - assert!(range::parse(">=").is_err());
2681 - assert!(range::parse("> 0.1.0,").is_err());
2682 - assert!(range::parse("> 0.3.0, ,").is_err());
2685 - #[test]
2686 - pub fn test_large_major_version() {
2687 - assert!(range::parse("18446744073709551617.0.0").is_err());
2690 - #[test]
2691 - pub fn test_large_minor_version() {
2692 - assert!(range::parse("0.18446744073709551617.0").is_err());
2695 - #[test]
2696 - pub fn test_large_patch_version() {
2697 - assert!(range::parse("0.0.18446744073709551617").is_err());
2700 diff --git a/third_party/rust/semver-parser/src/recognize.rs b/third_party/rust/semver-parser/src/recognize.rs
2701 deleted file mode 100644
2702 --- a/third_party/rust/semver-parser/src/recognize.rs
2703 +++ /dev/null
2704 @@ -1,154 +0,0 @@
2705 -// Copyright 2017 Google Inc. All rights reserved.
2707 -// Licensed under either of MIT or Apache License, Version 2.0,
2708 -// at your option.
2710 -// Use of this source code is governed by a MIT-style
2711 -// license that can be found in the LICENSE file or at
2712 -// https://opensource.org/licenses/MIT.
2714 -// Licensed under the Apache License, Version 2.0 (the "License");
2715 -// you may not use this file except in compliance with the License.
2716 -// You may obtain a copy of the License at
2718 -// http://www.apache.org/licenses/LICENSE-2.0
2720 -// Unless required by applicable law or agreed to in writing, software
2721 -// distributed under the License is distributed on an "AS IS" BASIS,
2722 -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2723 -// See the License for the specific language governing permissions and
2724 -// limitations under the License.
2726 -//! Simple recognizer combinators.
2728 -// This version is similar to a similar one in the "lang" module of
2729 -// xi-editor, but is stripped down to only the needed combinators.
2731 -use std::ops;
2733 -pub trait Recognize {
2734 - fn p(&self, s: &[u8]) -> Option<usize>;
2737 -impl<F: Fn(&[u8]) -> Option<usize>> Recognize for F {
2738 - #[inline(always)]
2739 - fn p(&self, s: &[u8]) -> Option<usize> {
2740 - self(s)
2744 -pub struct OneByte<F>(pub F);
2746 -impl<F: Fn(u8) -> bool> Recognize for OneByte<F> {
2747 - #[inline(always)]
2748 - fn p(&self, s: &[u8]) -> Option<usize> {
2749 - if s.is_empty() || !self.0(s[0]) {
2750 - None
2751 - } else {
2752 - Some(1)
2757 -impl Recognize for u8 {
2758 - #[inline(always)]
2759 - fn p(&self, s: &[u8]) -> Option<usize> {
2760 - OneByte(|b| b == *self).p(s)
2764 -/// Use Inclusive(a..b) to indicate an inclusive range. When a...b syntax becomes
2765 -/// stable, we can get rid of this and switch to that.
2766 -pub struct Inclusive<T>(pub T);
2768 -impl Recognize for Inclusive<ops::Range<u8>> {
2769 - #[inline(always)]
2770 - fn p(&self, s: &[u8]) -> Option<usize> {
2771 - OneByte(|x| x >= self.0.start && x <= self.0.end).p(s)
2775 -impl<'a> Recognize for &'a [u8] {
2776 - #[inline(always)]
2777 - fn p(&self, s: &[u8]) -> Option<usize> {
2778 - let len = self.len();
2779 - if s.len() >= len && &s[..len] == *self {
2780 - Some(len)
2781 - } else {
2782 - None
2787 -impl<'a> Recognize for &'a str {
2788 - #[inline(always)]
2789 - fn p(&self, s: &[u8]) -> Option<usize> {
2790 - self.as_bytes().p(s)
2794 -impl<P1: Recognize, P2: Recognize> Recognize for (P1, P2) {
2795 - #[inline(always)]
2796 - fn p(&self, s: &[u8]) -> Option<usize> {
2797 - self.0.p(s).and_then(|len1|
2798 - self.1.p(&s[len1..]).map(|len2|
2799 - len1 + len2))
2803 -/// Choice from two heterogeneous alternatives.
2804 -pub struct Alt<P1, P2>(pub P1, pub P2);
2806 -impl<P1: Recognize, P2: Recognize> Recognize for Alt<P1, P2> {
2807 - #[inline(always)]
2808 - fn p(&self, s: &[u8]) -> Option<usize> {
2809 - self.0.p(s).or_else(|| self.1.p(s))
2813 -/// Choice from a homogenous slice of parsers.
2814 -pub struct OneOf<'a, P: 'a>(pub &'a [P]);
2816 -impl<'a, P: Recognize> Recognize for OneOf<'a, P> {
2817 - #[inline]
2818 - fn p(&self, s: &[u8]) -> Option<usize> {
2819 - for ref p in self.0 {
2820 - if let Some(len) = p.p(s) {
2821 - return Some(len);
2824 - None
2828 -pub struct OneOrMore<P>(pub P);
2830 -impl<P: Recognize> Recognize for OneOrMore<P> {
2831 - #[inline]
2832 - fn p(&self, s: &[u8]) -> Option<usize> {
2833 - let mut i = 0;
2834 - let mut count = 0;
2835 - while let Some(len) = self.0.p(&s[i..]) {
2836 - i += len;
2837 - count += 1;
2839 - if count >= 1 {
2840 - Some(i)
2841 - } else {
2842 - None
2847 -pub struct ZeroOrMore<P>(pub P);
2849 -impl<P: Recognize> Recognize for ZeroOrMore<P> {
2850 - #[inline]
2851 - fn p(&self, s: &[u8]) -> Option<usize> {
2852 - let mut i = 0;
2853 - while let Some(len) = self.0.p(&s[i..]) {
2854 - i += len;
2856 - Some(i)
2859 diff --git a/third_party/rust/semver-parser/src/version.rs b/third_party/rust/semver-parser/src/version.rs
2860 deleted file mode 100644
2861 --- a/third_party/rust/semver-parser/src/version.rs
2862 +++ /dev/null
2863 @@ -1,365 +0,0 @@
2864 -use std::fmt;
2865 -use std::str::from_utf8;
2867 -use recognize::*;
2869 -use common::{self, numeric_identifier};
2871 -#[derive(Clone, Debug, PartialEq, Eq)]
2872 -pub struct Version {
2873 - pub major: u64,
2874 - pub minor: u64,
2875 - pub patch: u64,
2876 - pub pre: Vec<Identifier>,
2877 - pub build: Vec<Identifier>,
2880 -#[derive(Clone, Debug, PartialEq, Eq)]
2881 -pub enum Identifier {
2882 - /// An identifier that's solely numbers.
2883 - Numeric(u64),
2884 - /// An identifier with letters and numbers.
2885 - AlphaNumeric(String),
2888 -pub fn parse(version: &str) -> Result<Version, String> {
2889 - let s = version.trim().as_bytes();
2890 - let mut i = 0;
2891 - let major = if let Some((major, len)) = numeric_identifier(&s[i..]) {
2892 - i += len;
2893 - major
2894 - } else {
2895 - return Err("Error parsing major identifier".to_string());
2896 - };
2897 - if let Some(len) = b'.'.p(&s[i..]) {
2898 - i += len;
2899 - } else {
2900 - return Err("Expected dot".to_string());
2902 - let minor = if let Some((minor, len)) = numeric_identifier(&s[i..]) {
2903 - i += len;
2904 - minor
2905 - } else {
2906 - return Err("Error parsing minor identifier".to_string());
2907 - };
2908 - if let Some(len) = b'.'.p(&s[i..]) {
2909 - i += len;
2910 - } else {
2911 - return Err("Expected dot".to_string());
2913 - let patch = if let Some((patch, len)) = numeric_identifier(&s[i..]) {
2914 - i += len;
2915 - patch
2916 - } else {
2917 - return Err("Error parsing patch identifier".to_string());
2918 - };
2919 - let (pre, pre_len) = common::parse_optional_meta(&s[i..], b'-')?;
2920 - i += pre_len;
2921 - let (build, build_len) = common::parse_optional_meta(&s[i..], b'+')?;
2922 - i += build_len;
2923 - if i != s.len() {
2924 - return Err("Extra junk after valid version: ".to_string() +
2925 - from_utf8(&s[i..]).unwrap());
2927 - Ok(Version {
2928 - major: major,
2929 - minor: minor,
2930 - patch: patch,
2931 - pre: pre,
2932 - build: build,
2933 - })
2936 -impl fmt::Display for Version {
2937 - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
2938 - try!(write!(f, "{}.{}.{}", self.major, self.minor, self.patch));
2939 - if !self.pre.is_empty() {
2940 - let strs: Vec<_> =
2941 - self.pre.iter().map(ToString::to_string).collect();
2942 - try!(write!(f, "-{}", strs.join(".")));
2944 - if !self.build.is_empty() {
2945 - let strs: Vec<_> =
2946 - self.build.iter().map(ToString::to_string).collect();
2947 - try!(write!(f, "+{}", strs.join(".")));
2949 - Ok(())
2953 -impl fmt::Display for Identifier {
2954 - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
2955 - match *self {
2956 - Identifier::Numeric(ref id) => id.fmt(f),
2957 - Identifier::AlphaNumeric(ref id) => id.fmt(f),
2962 -#[cfg(test)]
2963 -mod tests {
2964 - use version;
2965 - use super::*;
2967 - #[test]
2968 - fn parse_empty() {
2969 - let version = "";
2971 - let parsed = version::parse(version);
2973 - assert!(parsed.is_err(), "empty string incorrectly considered a valid parse");
2976 - #[test]
2977 - fn parse_blank() {
2978 - let version = " ";
2980 - let parsed = version::parse(version);
2982 - assert!(parsed.is_err(), "blank string incorrectly considered a valid parse");
2985 - #[test]
2986 - fn parse_no_minor_patch() {
2987 - let version = "1";
2989 - let parsed = version::parse(version);
2991 - assert!(parsed.is_err(), format!("'{}' incorrectly considered a valid parse", version));
2994 - #[test]
2995 - fn parse_no_patch() {
2996 - let version = "1.2";
2998 - let parsed = version::parse(version);
3000 - assert!(parsed.is_err(), format!("'{}' incorrectly considered a valid parse", version));
3003 - #[test]
3004 - fn parse_empty_pre() {
3005 - let version = "1.2.3-";
3007 - let parsed = version::parse(version);
3009 - assert!(parsed.is_err(), format!("'{}' incorrectly considered a valid parse", version));
3012 - #[test]
3013 - fn parse_letters() {
3014 - let version = "a.b.c";
3016 - let parsed = version::parse(version);
3018 - assert!(parsed.is_err(), format!("'{}' incorrectly considered a valid parse", version));
3021 - #[test]
3022 - fn parse_with_letters() {
3023 - let version = "1.2.3 a.b.c";
3025 - let parsed = version::parse(version);
3027 - assert!(parsed.is_err(), format!("'{}' incorrectly considered a valid parse", version));
3030 - #[test]
3031 - fn parse_basic_version() {
3032 - let version = "1.2.3";
3034 - let parsed = version::parse(version).unwrap();
3036 - assert_eq!(1, parsed.major);
3037 - assert_eq!(2, parsed.minor);
3038 - assert_eq!(3, parsed.patch);
3041 - #[test]
3042 - fn parse_trims_input() {
3043 - let version = " 1.2.3 ";
3045 - let parsed = version::parse(version).unwrap();
3047 - assert_eq!(1, parsed.major);
3048 - assert_eq!(2, parsed.minor);
3049 - assert_eq!(3, parsed.patch);
3052 - #[test]
3053 - fn parse_no_major_leading_zeroes() {
3054 - let version = "01.0.0";
3056 - let parsed = version::parse(version);
3058 - assert!(parsed.is_err(), "01 incorrectly considered a valid major version");
3061 - #[test]
3062 - fn parse_no_minor_leading_zeroes() {
3063 - let version = "0.01.0";
3065 - let parsed = version::parse(version);
3067 - assert!(parsed.is_err(), "01 incorrectly considered a valid minor version");
3070 - #[test]
3071 - fn parse_no_patch_leading_zeroes() {
3072 - let version = "0.0.01";
3074 - let parsed = version::parse(version);
3076 - assert!(parsed.is_err(), "01 incorrectly considered a valid patch version");
3079 - #[test]
3080 - fn parse_no_major_overflow() {
3081 - let version = "98765432109876543210.0.0";
3083 - let parsed = version::parse(version);
3085 - assert!(parsed.is_err(), "98765432109876543210 incorrectly considered a valid major version");
3088 - #[test]
3089 - fn parse_no_minor_overflow() {
3090 - let version = "0.98765432109876543210.0";
3092 - let parsed = version::parse(version);
3094 - assert!(parsed.is_err(), "98765432109876543210 incorrectly considered a valid minor version");
3097 - #[test]
3098 - fn parse_no_patch_overflow() {
3099 - let version = "0.0.98765432109876543210";
3101 - let parsed = version::parse(version);
3103 - assert!(parsed.is_err(), "98765432109876543210 incorrectly considered a valid patch version");
3106 - #[test]
3107 - fn parse_basic_prerelease() {
3108 - let version = "1.2.3-pre";
3110 - let parsed = version::parse(version).unwrap();
3112 - let expected_pre = vec![Identifier::AlphaNumeric(String::from("pre"))];
3113 - assert_eq!(expected_pre, parsed.pre);
3116 - #[test]
3117 - fn parse_prerelease_alphanumeric() {
3118 - let version = "1.2.3-alpha1";
3120 - let parsed = version::parse(version).unwrap();
3122 - let expected_pre = vec![Identifier::AlphaNumeric(String::from("alpha1"))];
3123 - assert_eq!(expected_pre, parsed.pre);
3126 - #[test]
3127 - fn parse_prerelease_zero() {
3128 - let version = "1.2.3-pre.0";
3130 - let parsed = version::parse(version).unwrap();
3132 - let expected_pre = vec![Identifier::AlphaNumeric(String::from("pre")),
3133 - Identifier::Numeric(0)];
3134 - assert_eq!(expected_pre, parsed.pre);
3137 - #[test]
3138 - fn parse_basic_build() {
3139 - let version = "1.2.3+build";
3141 - let parsed = version::parse(version).unwrap();
3143 - let expected_build = vec![Identifier::AlphaNumeric(String::from("build"))];
3144 - assert_eq!(expected_build, parsed.build);
3147 - #[test]
3148 - fn parse_build_alphanumeric() {
3149 - let version = "1.2.3+build5";
3151 - let parsed = version::parse(version).unwrap();
3153 - let expected_build = vec![Identifier::AlphaNumeric(String::from("build5"))];
3154 - assert_eq!(expected_build, parsed.build);
3157 - #[test]
3158 - fn parse_pre_and_build() {
3159 - let version = "1.2.3-alpha1+build5";
3161 - let parsed = version::parse(version).unwrap();
3163 - let expected_pre = vec![Identifier::AlphaNumeric(String::from("alpha1"))];
3164 - assert_eq!(expected_pre, parsed.pre);
3166 - let expected_build = vec![Identifier::AlphaNumeric(String::from("build5"))];
3167 - assert_eq!(expected_build, parsed.build);
3170 - #[test]
3171 - fn parse_complex_metadata_01() {
3172 - let version = "1.2.3-1.alpha1.9+build5.7.3aedf ";
3174 - let parsed = version::parse(version).unwrap();
3176 - let expected_pre = vec![Identifier::Numeric(1),
3177 - Identifier::AlphaNumeric(String::from("alpha1")),
3178 - Identifier::Numeric(9)];
3179 - assert_eq!(expected_pre, parsed.pre);
3181 - let expected_build = vec![Identifier::AlphaNumeric(String::from("build5")),
3182 - Identifier::Numeric(7),
3183 - Identifier::AlphaNumeric(String::from("3aedf"))];
3184 - assert_eq!(expected_build, parsed.build);
3187 - #[test]
3188 - fn parse_complex_metadata_02() {
3189 - let version = "0.4.0-beta.1+0851523";
3191 - let parsed = version::parse(version).unwrap();
3193 - let expected_pre = vec![Identifier::AlphaNumeric(String::from("beta")),
3194 - Identifier::Numeric(1)];
3195 - assert_eq!(expected_pre, parsed.pre);
3197 - let expected_build = vec![Identifier::AlphaNumeric(String::from("0851523"))];
3198 - assert_eq!(expected_build, parsed.build);
3201 - #[test]
3202 - fn parse_metadata_overflow() {
3203 - let version = "0.4.0-beta.1+98765432109876543210";
3205 - let parsed = version::parse(version).unwrap();
3207 - let expected_pre = vec![Identifier::AlphaNumeric(String::from("beta")),
3208 - Identifier::Numeric(1)];
3209 - assert_eq!(expected_pre, parsed.pre);
3211 - let expected_build = vec![Identifier::AlphaNumeric(String::from("98765432109876543210"))];
3212 - assert_eq!(expected_build, parsed.build);
3215 - #[test]
3216 - fn parse_regression_01() {
3217 - let version = "0.0.0-WIP";
3219 - let parsed = version::parse(version).unwrap();
3221 - assert_eq!(0, parsed.major);
3222 - assert_eq!(0, parsed.minor);
3223 - assert_eq!(0, parsed.patch);
3225 - let expected_pre = vec![Identifier::AlphaNumeric(String::from("WIP"))];
3226 - assert_eq!(expected_pre, parsed.pre);
3229 diff --git a/third_party/rust/semver/.cargo-checksum.json b/third_party/rust/semver/.cargo-checksum.json
3230 --- a/third_party/rust/semver/.cargo-checksum.json
3231 +++ b/third_party/rust/semver/.cargo-checksum.json
3232 @@ -1,1 +1,1 @@
3233 -{"files":{"Cargo.toml":"a5b995796b5559de8975a6fee7166c9fda6c21b449ec90bef5f9baaeddd479a5","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"6485b8ed310d3f0340bf1ad1f47645069ce4069dcc6bb46c7d5c6faf41de1fdb","README.md":"c780d8c3c802c5fe2c316127900385010c3e57f71c851eea9e8ed8495e2030dd","src/lib.rs":"cb1725a8bb90c1043f187c6ba504d0a9d07793e2f39f5205f926c58849311770","src/version.rs":"ffdf9c628597b889f149f3b2b1245b97c774eae1ce7030bd19235eabecaaede0","src/version_req.rs":"40d20720f5fdc0b3d9e398e64eb448a65987229bd322cab0fedf0cf1843f3bd8","tests/deprecation.rs":"b5ec79e19d61968d05b96b876c449e54d43cbd1762c6e63c23c3470f9db56292","tests/regression.rs":"180b699ad029b81e6135d42f0a8e6d782177bc29a41132f875ee6f8607a46b56","tests/serde.rs":"cdbbefc576ffcc814c30dad9598ab87a7fd9d14c5f42f1349e1db6afc72f8fed"},"package":"1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403"}
3234 \ No newline at end of file
3235 +{"files":{"Cargo.toml":"2a2126f8fe5d20540ae6cfbf6649ed3af365ffb9a0a788a7552a6e7649a7a75f","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"23f18e03dc49df91622fe2a76176497404e46ced8a715d9d2b67a7446571cca3","README.md":"57659341319915482c0b83779fb7f3f0f3accb7a8b881965799116afb5e9f7e9","benches/parse.rs":"6531f66f80ce2fc83878f9bf84f94c42e96f1e709466f2b88be8d95a3cec1511","build.rs":"47b42941210d44567c8561107420d7825aa1d01332c2d2f8892d9e20646a1c77","src/backport.rs":"f8866548840434c8974f135528693f25aacc4ad03639c4e3aea3be351e13fdf8","src/display.rs":"9ba42f7a6579aa9c7dd72f2380036f5c9664592f3eacd09ea25cef291a3e64e5","src/error.rs":"3bb489f4a29f38d93370e64ae8d6e4e9b451a055cd7d392b6aeacab7eb3e1953","src/eval.rs":"b7e7ec976051b9f87ddf5cfdbaad64654d98d86ae0763f7d88b14eeaeac6013c","src/identifier.rs":"601231351ac58602b7d193cb0951b5146bd868b62aba938d5cbe52cf2b93414b","src/impls.rs":"79b5a2ac6ca3d4cb46adfb1494756079f53bef780dd81c3a8d3adf86f91395c8","src/lib.rs":"8e116a19e521909f3fa50206c078f1e23bf033dc8057ba6101f80d5bc5900fed","src/parse.rs":"93593f62cdae489feb4f2e8ae1fa93d90dca63db50669b6265346ffaaf687be5","src/serde.rs":"970d343a6bac21ddd965168d3cc2af9998796bf29bf545e8b37c6bcdd97d9710","tests/node/mod.rs":"2710d9b8daace2038b66db0f8f4cc522dee938e7cbc42d7739c31995343c32f4","tests/test_autotrait.rs":"070500c32ceee14a8a0110c04a01f98278b24614a0aec8c382dcea3da0343f58","tests/test_identifier.rs":"6c3da46c73df210527b60f1069131b15e2c65eb7b5d11793940d00cf66812f4d","tests/test_version.rs":"09e37c3df162205acf3683d1c760a6001e34e1c709fd4a1a265d82450e340003","tests/test_version_req.rs":"b6eea0258cc3b6d567a9f6c42693a97316345083495236c47e85374fd45f7cf0","tests/util/mod.rs":"db61c2cd86af864d8be4f2a3d5f25c86d7712201cc6ab47b715facf5f7f275b7"},"package":"8cb243bdfdb5936c8dc3c45762a19d12ab4550cdc753bc247637d4ec35a040fd"}
3236 \ No newline at end of file
3237 diff --git a/third_party/rust/semver/Cargo.toml b/third_party/rust/semver/Cargo.toml
3238 --- a/third_party/rust/semver/Cargo.toml
3239 +++ b/third_party/rust/semver/Cargo.toml
3240 @@ -1,45 +1,38 @@
3241 # THIS FILE IS AUTOMATICALLY GENERATED BY CARGO
3243 # When uploading crates to the registry Cargo will automatically
3244 # "normalize" Cargo.toml files for maximal compatibility
3245 # with all versions of Cargo and also rewrite `path` dependencies
3246 -# to registry (e.g. crates.io) dependencies
3247 +# to registry (e.g., crates.io) dependencies.
3249 -# If you believe there's an error in this file please file an
3250 -# issue against the rust-lang/cargo repository. If you're
3251 -# editing this file be aware that the upstream Cargo.toml
3252 -# will likely look very different (and much more reasonable)
3253 +# If you are reading this file be aware that the original Cargo.toml
3254 +# will likely look very different (and much more reasonable).
3255 +# See Cargo.toml.orig for the original contents.
3257 [package]
3258 +edition = "2018"
3259 +rust-version = "1.31"
3260 name = "semver"
3261 -version = "0.9.0"
3262 -authors = ["Steve Klabnik <steve@steveklabnik.com>", "The Rust Project Developers"]
3263 -description = "Semantic version parsing and comparison.\n"
3264 -homepage = "https://docs.rs/crate/semver/"
3265 -documentation = "https://docs.rs/crate/semver/"
3266 +version = "1.0.9"
3267 +authors = ["David Tolnay <dtolnay@gmail.com>"]
3268 +description = "Parser and evaluator for Cargo's flavor of Semantic Versioning"
3269 +documentation = "https://docs.rs/semver"
3270 readme = "README.md"
3271 -license = "MIT/Apache-2.0"
3272 -repository = "https://github.com/steveklabnik/semver"
3273 -[dependencies.semver-parser]
3274 -version = "0.7.0"
3275 +license = "MIT OR Apache-2.0"
3276 +repository = "https://github.com/dtolnay/semver"
3278 +[package.metadata.docs.rs]
3279 +targets = ["x86_64-unknown-linux-gnu"]
3280 +rustdoc-args = [
3281 + "--cfg",
3282 + "doc_cfg",
3285 [dependencies.serde]
3286 version = "1.0"
3287 optional = true
3288 -[dev-dependencies.crates-index]
3289 -version = "0.5.0"
3291 -[dev-dependencies.serde_json]
3292 -version = "1.0"
3294 -[dev-dependencies.serde_derive]
3295 -version = "1.0"
3297 -[dev-dependencies.tempdir]
3298 -version = "0.3.4"
3299 +default-features = false
3301 [features]
3302 -default = []
3303 -ci = ["serde"]
3304 -[badges.travis-ci]
3305 -repository = "steveklabnik/semver"
3306 +default = ["std"]
3307 +std = []
3308 diff --git a/third_party/rust/semver/LICENSE-MIT b/third_party/rust/semver/LICENSE-MIT
3309 --- a/third_party/rust/semver/LICENSE-MIT
3310 +++ b/third_party/rust/semver/LICENSE-MIT
3311 @@ -1,10 +1,8 @@
3312 -Copyright (c) 2014 The Rust Project Developers
3314 Permission is hereby granted, free of charge, to any
3315 person obtaining a copy of this software and associated
3316 documentation files (the "Software"), to deal in the
3317 Software without restriction, including without
3318 limitation the rights to use, copy, modify, merge,
3319 publish, distribute, sublicense, and/or sell copies of
3320 the Software, and to permit persons to whom the Software
3321 is furnished to do so, subject to the following
3322 diff --git a/third_party/rust/semver/README.md b/third_party/rust/semver/README.md
3323 --- a/third_party/rust/semver/README.md
3324 +++ b/third_party/rust/semver/README.md
3325 @@ -1,103 +1,84 @@
3326 semver
3327 ======
3329 -Semantic version parsing and comparison.
3331 -[![Build Status](https://api.travis-ci.org/steveklabnik/semver.svg?branch=master)](https://travis-ci.org/steveklabnik/semver)
3333 -[Documentation](https://steveklabnik.github.io/semver)
3335 -Semantic versioning (see http://semver.org/) is a set of rules for
3336 -assigning version numbers.
3337 +[<img alt="github" src="https://img.shields.io/badge/github-dtolnay/semver-8da0cb?style=for-the-badge&labelColor=555555&logo=github" height="20">](https://github.com/dtolnay/semver)
3338 +[<img alt="crates.io" src="https://img.shields.io/crates/v/semver.svg?style=for-the-badge&color=fc8d62&logo=rust" height="20">](https://crates.io/crates/semver)
3339 +[<img alt="docs.rs" src="https://img.shields.io/badge/docs.rs-semver-66c2a5?style=for-the-badge&labelColor=555555&logoColor=white&logo=data:image/svg+xml;base64,PHN2ZyByb2xlPSJpbWciIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgdmlld0JveD0iMCAwIDUxMiA1MTIiPjxwYXRoIGZpbGw9IiNmNWY1ZjUiIGQ9Ik00ODguNiAyNTAuMkwzOTIgMjE0VjEwNS41YzAtMTUtOS4zLTI4LjQtMjMuNC0zMy43bC0xMDAtMzcuNWMtOC4xLTMuMS0xNy4xLTMuMS0yNS4zIDBsLTEwMCAzNy41Yy0xNC4xIDUuMy0yMy40IDE4LjctMjMuNCAzMy43VjIxNGwtOTYuNiAzNi4yQzkuMyAyNTUuNSAwIDI2OC45IDAgMjgzLjlWMzk0YzAgMTMuNiA3LjcgMjYuMSAxOS45IDMyLjJsMTAwIDUwYzEwLjEgNS4xIDIyLjEgNS4xIDMyLjIgMGwxMDMuOS01MiAxMDMuOSA1MmMxMC4xIDUuMSAyMi4xIDUuMSAzMi4yIDBsMTAwLTUwYzEyLjItNi4xIDE5LjktMTguNiAxOS45LTMyLjJWMjgzLjljMC0xNS05LjMtMjguNC0yMy40LTMzLjd6TTM1OCAyMTQuOGwtODUgMzEuOXYtNjguMmw4NS0zN3Y3My4zek0xNTQgMTA0LjFsMTAyLTM4LjIgMTAyIDM4LjJ2LjZsLTEwMiA0MS40LTEwMi00MS40di0uNnptODQgMjkxLjFsLTg1IDQyLjV2LTc5LjFsODUtMzguOHY3NS40em0wLTExMmwtMTAyIDQxLjQtMTAyLTQxLjR2LS42bDEwMi0zOC4yIDEwMiAzOC4ydi42em0yNDAgMTEybC04NSA0Mi41di03OS4xbDg1LTM4Ljh2NzUuNHptMC0xMTJsLTEwMiA0MS40LTEwMi00MS40di0uNmwxMDItMzguMiAxMDIgMzguMnYuNnoiPjwvcGF0aD48L3N2Zz4K" height="20">](https://docs.rs/semver)
3340 +[<img alt="build status" src="https://img.shields.io/github/workflow/status/dtolnay/semver/CI/master?style=for-the-badge" height="20">](https://github.com/dtolnay/semver/actions?query=branch%3Amaster)
3342 -## SemVer and the Rust ecosystem
3344 -Rust itself follows the SemVer specification, as does its standard libraries. The two are
3345 -not tied together.
3346 +A parser and evaluator for Cargo's flavor of Semantic Versioning.
3348 -[Cargo](https://crates.io), Rust's package manager, uses SemVer to determine which versions of
3349 -packages you need installed.
3351 -## Installation
3353 -To use `semver`, add this to your `[dependencies]` section:
3354 +Semantic Versioning (see <https://semver.org>) is a guideline for how version
3355 +numbers are assigned and incremented. It is widely followed within the
3356 +Cargo/crates.io ecosystem for Rust.
3358 ```toml
3359 -semver = "0.7.0"
3360 -```
3362 -And this to your crate root:
3364 -```rust
3365 -extern crate semver;
3366 -```
3368 -## Versions
3370 -At its simplest, the `semver` crate allows you to construct `Version` objects using the `parse`
3371 -method:
3373 -```rust
3374 -use semver::Version;
3376 -assert!(Version::parse("1.2.3") == Ok(Version {
3377 - major: 1,
3378 - minor: 2,
3379 - patch: 3,
3380 - pre: vec!(),
3381 - build: vec!(),
3382 -}));
3383 +[dependencies]
3384 +semver = "1.0"
3387 -If you have multiple `Version`s, you can use the usual comparison operators to compare them:
3389 -```rust
3390 -use semver::Version;
3391 +*Compiler support: requires rustc 1.31+*
3393 -assert!(Version::parse("1.2.3-alpha") != Version::parse("1.2.3-beta"));
3394 -assert!(Version::parse("1.2.3-alpha2") > Version::parse("1.2.0"));
3395 -```
3397 -## Requirements
3398 +<br>
3400 -The `semver` crate also provides the ability to compare requirements, which are more complex
3401 -comparisons.
3403 -For example, creating a requirement that only matches versions greater than or
3404 -equal to 1.0.0:
3405 +## Example
3407 ```rust
3408 -use semver::Version;
3409 -use semver::VersionReq;
3410 +use semver::{BuildMetadata, Prerelease, Version, VersionReq};
3412 +fn main() {
3413 + let req = VersionReq::parse(">=1.2.3, <1.8.0").unwrap();
3415 -let r = VersionReq::parse(">= 1.0.0").unwrap();
3416 -let v = Version::parse("1.0.0").unwrap();
3417 + // Check whether this requirement matches version 1.2.3-alpha.1 (no)
3418 + let version = Version {
3419 + major: 1,
3420 + minor: 2,
3421 + patch: 3,
3422 + pre: Prerelease::new("alpha.1").unwrap(),
3423 + build: BuildMetadata::EMPTY,
3424 + };
3425 + assert!(!req.matches(&version));
3427 -assert!(r.to_string() == ">= 1.0.0".to_string());
3428 -assert!(r.matches(&v))
3429 + // Check whether it matches 1.3.0 (yes it does)
3430 + let version = Version::parse("1.3.0").unwrap();
3431 + assert!(req.matches(&version));
3435 -It also allows parsing of `~x.y.z` and `^x.y.z` requirements as defined at
3436 -https://www.npmjs.org/doc/misc/semver.html
3437 +<br>
3439 +## Scope of this crate
3441 -**Tilde requirements** specify a minimal version with some updates:
3442 +Besides Cargo, several other package ecosystems and package managers for other
3443 +languages also use SemVer:&ensp;RubyGems/Bundler for Ruby, npm for JavaScript,
3444 +Composer for PHP, CocoaPods for Objective-C...
3446 -```notrust
3447 -~1.2.3 := >=1.2.3 <1.3.0
3448 -~1.2 := >=1.2.0 <1.3.0
3449 -~1 := >=1.0.0 <2.0.0
3450 -```
3451 +The `semver` crate is specifically intended to implement Cargo's interpretation
3452 +of Semantic Versioning.
3454 +Where the various tools differ in their interpretation or implementation of the
3455 +spec, this crate follows the implementation choices made by Cargo. If you are
3456 +operating on version numbers from some other package ecosystem, you will want to
3457 +use a different semver library which is appropriate to that ecosystem.
3459 +The extent of Cargo's SemVer support is documented in the *[Specifying
3460 +Dependencies]* chapter of the Cargo reference.
3462 -**Caret requirements** allow SemVer compatible updates to a specified version,
3463 -`0.x` and `0.x+1` are not considered compatible, but `1.x` and `1.x+1` are.
3464 +[Specifying Dependencies]: https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html
3466 -`0.0.x` is not considered compatible with any other version.
3467 -Missing minor and patch versions are desugared to `0` but allow flexibility for that value.
3468 +<br>
3470 +#### License
3472 -```notrust
3473 -^1.2.3 := >=1.2.3 <2.0.0
3474 -^0.2.3 := >=0.2.3 <0.3.0
3475 -^0.0.3 := >=0.0.3 <0.0.4
3476 -^0.0 := >=0.0.0 <0.1.0
3477 -^0 := >=0.0.0 <1.0.0
3478 -```
3479 +<sup>
3480 +Licensed under either of <a href="LICENSE-APACHE">Apache License, Version
3481 +2.0</a> or <a href="LICENSE-MIT">MIT license</a> at your option.
3482 +</sup>
3484 +<br>
3486 +<sub>
3487 +Unless you explicitly state otherwise, any contribution intentionally submitted
3488 +for inclusion in this crate by you, as defined in the Apache-2.0 license, shall
3489 +be dual licensed as above, without any additional terms or conditions.
3490 +</sub>
3491 diff --git a/third_party/rust/semver/benches/parse.rs b/third_party/rust/semver/benches/parse.rs
3492 new file mode 100644
3493 --- /dev/null
3494 +++ b/third_party/rust/semver/benches/parse.rs
3495 @@ -0,0 +1,24 @@
3496 +#![feature(test)]
3498 +extern crate test;
3500 +use semver::{Prerelease, Version, VersionReq};
3501 +use test::{black_box, Bencher};
3503 +#[bench]
3504 +fn parse_prerelease(b: &mut Bencher) {
3505 + let text = "x.7.z.92";
3506 + b.iter(|| black_box(text).parse::<Prerelease>().unwrap());
3509 +#[bench]
3510 +fn parse_version(b: &mut Bencher) {
3511 + let text = "1.0.2021-beta+exp.sha.5114f85";
3512 + b.iter(|| black_box(text).parse::<Version>().unwrap());
3515 +#[bench]
3516 +fn parse_version_req(b: &mut Bencher) {
3517 + let text = ">=1.2.3, <2.0.0";
3518 + b.iter(|| black_box(text).parse::<VersionReq>().unwrap());
3520 diff --git a/third_party/rust/semver/build.rs b/third_party/rust/semver/build.rs
3521 new file mode 100644
3522 --- /dev/null
3523 +++ b/third_party/rust/semver/build.rs
3524 @@ -0,0 +1,73 @@
3525 +use std::env;
3526 +use std::process::Command;
3527 +use std::str;
3529 +fn main() {
3530 + let compiler = match rustc_minor_version() {
3531 + Some(compiler) => compiler,
3532 + None => return,
3533 + };
3535 + if compiler < 33 {
3536 + // Exhaustive integer patterns. On older compilers, a final `_` arm is
3537 + // required even if every possible integer value is otherwise covered.
3538 + // https://github.com/rust-lang/rust/issues/50907
3539 + println!("cargo:rustc-cfg=no_exhaustive_int_match");
3542 + if compiler < 36 {
3543 + // extern crate alloc.
3544 + // https://blog.rust-lang.org/2019/07/04/Rust-1.36.0.html#the-alloc-crate-is-stable
3545 + println!("cargo:rustc-cfg=no_alloc_crate");
3548 + if compiler < 39 {
3549 + // const Vec::new.
3550 + // https://doc.rust-lang.org/std/vec/struct.Vec.html#method.new
3551 + println!("cargo:rustc-cfg=no_const_vec_new");
3554 + if compiler < 40 {
3555 + // #[non_exhaustive].
3556 + // https://blog.rust-lang.org/2019/12/19/Rust-1.40.0.html#non_exhaustive-structs-enums-and-variants
3557 + println!("cargo:rustc-cfg=no_non_exhaustive");
3560 + if compiler < 45 {
3561 + // String::strip_prefix.
3562 + // https://doc.rust-lang.org/std/primitive.str.html#method.repeat
3563 + println!("cargo:rustc-cfg=no_str_strip_prefix");
3566 + if compiler < 46 {
3567 + // #[track_caller].
3568 + // https://blog.rust-lang.org/2020/08/27/Rust-1.46.0.html#track_caller
3569 + println!("cargo:rustc-cfg=no_track_caller");
3572 + if compiler < 52 {
3573 + // #![deny(unsafe_op_in_unsafe_fn)].
3574 + // https://github.com/rust-lang/rust/issues/71668
3575 + println!("cargo:rustc-cfg=no_unsafe_op_in_unsafe_fn_lint");
3578 + if compiler < 53 {
3579 + // Efficient intrinsics for count-leading-zeros and count-trailing-zeros
3580 + // on NonZero integers stabilized in 1.53.0. On many architectures these
3581 + // are more efficient than counting zeros on ordinary zeroable integers.
3582 + // https://doc.rust-lang.org/std/num/struct.NonZeroU64.html#method.leading_zeros
3583 + // https://doc.rust-lang.org/std/num/struct.NonZeroU64.html#method.trailing_zeros
3584 + println!("cargo:rustc-cfg=no_nonzero_bitscan");
3588 +fn rustc_minor_version() -> Option<u32> {
3589 + let rustc = env::var_os("RUSTC")?;
3590 + let output = Command::new(rustc).arg("--version").output().ok()?;
3591 + let version = str::from_utf8(&output.stdout).ok()?;
3592 + let mut pieces = version.split('.');
3593 + if pieces.next() != Some("rustc 1") {
3594 + return None;
3596 + pieces.next()?.parse().ok()
3598 diff --git a/third_party/rust/semver/src/backport.rs b/third_party/rust/semver/src/backport.rs
3599 new file mode 100644
3600 --- /dev/null
3601 +++ b/third_party/rust/semver/src/backport.rs
3602 @@ -0,0 +1,51 @@
3603 +#[cfg(no_str_strip_prefix)] // rustc <1.45
3604 +pub(crate) trait StripPrefixExt {
3605 + fn strip_prefix(&self, ch: char) -> Option<&str>;
3608 +#[cfg(no_str_strip_prefix)]
3609 +impl StripPrefixExt for str {
3610 + fn strip_prefix(&self, ch: char) -> Option<&str> {
3611 + if self.starts_with(ch) {
3612 + Some(&self[ch.len_utf8()..])
3613 + } else {
3614 + None
3619 +pub(crate) use crate::alloc::vec::Vec;
3621 +#[cfg(no_alloc_crate)] // rustc <1.36
3622 +pub(crate) mod alloc {
3623 + pub use std::vec;
3625 + pub mod alloc {
3626 + use std::mem;
3628 + pub struct Layout {
3629 + size: usize,
3632 + impl Layout {
3633 + pub unsafe fn from_size_align_unchecked(size: usize, align: usize) -> Self {
3634 + assert_eq!(align, 2);
3635 + Layout { size }
3639 + pub unsafe fn alloc(layout: Layout) -> *mut u8 {
3640 + let len_u16 = (layout.size + 1) / 2;
3641 + let mut vec = Vec::new();
3642 + vec.reserve_exact(len_u16);
3643 + let ptr: *mut u16 = vec.as_mut_ptr();
3644 + mem::forget(vec);
3645 + ptr as *mut u8
3648 + pub unsafe fn dealloc(ptr: *mut u8, layout: Layout) {
3649 + let len_u16 = (layout.size + 1) / 2;
3650 + unsafe { Vec::from_raw_parts(ptr as *mut u16, 0, len_u16) };
3654 diff --git a/third_party/rust/semver/src/display.rs b/third_party/rust/semver/src/display.rs
3655 new file mode 100644
3656 --- /dev/null
3657 +++ b/third_party/rust/semver/src/display.rs
3658 @@ -0,0 +1,165 @@
3659 +use crate::{BuildMetadata, Comparator, Op, Prerelease, Version, VersionReq};
3660 +use core::fmt::{self, Alignment, Debug, Display, Write};
3662 +impl Display for Version {
3663 + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
3664 + let do_display = |formatter: &mut fmt::Formatter| -> fmt::Result {
3665 + write!(formatter, "{}.{}.{}", self.major, self.minor, self.patch)?;
3666 + if !self.pre.is_empty() {
3667 + write!(formatter, "-{}", self.pre)?;
3669 + if !self.build.is_empty() {
3670 + write!(formatter, "+{}", self.build)?;
3672 + Ok(())
3673 + };
3675 + let do_len = || -> usize {
3676 + digits(self.major)
3677 + + 1
3678 + + digits(self.minor)
3679 + + 1
3680 + + digits(self.patch)
3681 + + !self.pre.is_empty() as usize
3682 + + self.pre.len()
3683 + + !self.build.is_empty() as usize
3684 + + self.build.len()
3685 + };
3687 + pad(formatter, do_display, do_len)
3691 +impl Display for VersionReq {
3692 + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
3693 + if self.comparators.is_empty() {
3694 + return formatter.write_str("*");
3696 + for (i, comparator) in self.comparators.iter().enumerate() {
3697 + if i > 0 {
3698 + formatter.write_str(", ")?;
3700 + write!(formatter, "{}", comparator)?;
3702 + Ok(())
3706 +impl Display for Comparator {
3707 + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
3708 + let op = match self.op {
3709 + Op::Exact => "=",
3710 + Op::Greater => ">",
3711 + Op::GreaterEq => ">=",
3712 + Op::Less => "<",
3713 + Op::LessEq => "<=",
3714 + Op::Tilde => "~",
3715 + Op::Caret => "^",
3716 + Op::Wildcard => "",
3717 + #[cfg(no_non_exhaustive)]
3718 + Op::__NonExhaustive => unreachable!(),
3719 + };
3720 + formatter.write_str(op)?;
3721 + write!(formatter, "{}", self.major)?;
3722 + if let Some(minor) = &self.minor {
3723 + write!(formatter, ".{}", minor)?;
3724 + if let Some(patch) = &self.patch {
3725 + write!(formatter, ".{}", patch)?;
3726 + if !self.pre.is_empty() {
3727 + write!(formatter, "-{}", self.pre)?;
3729 + } else if self.op == Op::Wildcard {
3730 + formatter.write_str(".*")?;
3732 + } else if self.op == Op::Wildcard {
3733 + formatter.write_str(".*")?;
3735 + Ok(())
3739 +impl Display for Prerelease {
3740 + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
3741 + formatter.write_str(self.as_str())
3745 +impl Display for BuildMetadata {
3746 + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
3747 + formatter.write_str(self.as_str())
3751 +impl Debug for Version {
3752 + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
3753 + let mut debug = formatter.debug_struct("Version");
3754 + debug
3755 + .field("major", &self.major)
3756 + .field("minor", &self.minor)
3757 + .field("patch", &self.patch);
3758 + if !self.pre.is_empty() {
3759 + debug.field("pre", &self.pre);
3761 + if !self.build.is_empty() {
3762 + debug.field("build", &self.build);
3764 + debug.finish()
3768 +impl Debug for Prerelease {
3769 + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
3770 + write!(formatter, "Prerelease(\"{}\")", self)
3774 +impl Debug for BuildMetadata {
3775 + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
3776 + write!(formatter, "BuildMetadata(\"{}\")", self)
3780 +fn pad(
3781 + formatter: &mut fmt::Formatter,
3782 + do_display: impl FnOnce(&mut fmt::Formatter) -> fmt::Result,
3783 + do_len: impl FnOnce() -> usize,
3784 +) -> fmt::Result {
3785 + let min_width = match formatter.width() {
3786 + Some(min_width) => min_width,
3787 + None => return do_display(formatter),
3788 + };
3790 + let len = do_len();
3791 + if len >= min_width {
3792 + return do_display(formatter);
3795 + let default_align = Alignment::Left;
3796 + let align = formatter.align().unwrap_or(default_align);
3797 + let padding = min_width - len;
3798 + let (pre_pad, post_pad) = match align {
3799 + Alignment::Left => (0, padding),
3800 + Alignment::Right => (padding, 0),
3801 + Alignment::Center => (padding / 2, (padding + 1) / 2),
3802 + };
3804 + let fill = formatter.fill();
3805 + for _ in 0..pre_pad {
3806 + formatter.write_char(fill)?;
3809 + do_display(formatter)?;
3811 + for _ in 0..post_pad {
3812 + formatter.write_char(fill)?;
3814 + Ok(())
3817 +fn digits(val: u64) -> usize {
3818 + if val < 10 {
3820 + } else {
3821 + 1 + digits(val / 10)
3824 diff --git a/third_party/rust/semver/src/error.rs b/third_party/rust/semver/src/error.rs
3825 new file mode 100644
3826 --- /dev/null
3827 +++ b/third_party/rust/semver/src/error.rs
3828 @@ -0,0 +1,124 @@
3829 +use crate::parse::Error;
3830 +use core::fmt::{self, Debug, Display};
3832 +pub(crate) enum ErrorKind {
3833 + UnexpectedEnd(Position),
3834 + UnexpectedChar(Position, char),
3835 + UnexpectedCharAfter(Position, char),
3836 + ExpectedCommaFound(Position, char),
3837 + LeadingZero(Position),
3838 + Overflow(Position),
3839 + EmptySegment(Position),
3840 + IllegalCharacter(Position),
3841 + WildcardNotTheOnlyComparator(char),
3842 + UnexpectedAfterWildcard,
3843 + ExcessiveComparators,
3846 +#[derive(Copy, Clone, Eq, PartialEq)]
3847 +pub(crate) enum Position {
3848 + Major,
3849 + Minor,
3850 + Patch,
3851 + Pre,
3852 + Build,
3855 +#[cfg(feature = "std")]
3856 +#[cfg_attr(doc_cfg, doc(cfg(feature = "std")))]
3857 +impl std::error::Error for Error {}
3859 +impl Display for Error {
3860 + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
3861 + match &self.kind {
3862 + ErrorKind::UnexpectedEnd(pos) => {
3863 + write!(formatter, "unexpected end of input while parsing {}", pos)
3865 + ErrorKind::UnexpectedChar(pos, ch) => {
3866 + write!(
3867 + formatter,
3868 + "unexpected character {} while parsing {}",
3869 + QuotedChar(*ch),
3870 + pos,
3873 + ErrorKind::UnexpectedCharAfter(pos, ch) => {
3874 + write!(
3875 + formatter,
3876 + "unexpected character {} after {}",
3877 + QuotedChar(*ch),
3878 + pos,
3881 + ErrorKind::ExpectedCommaFound(pos, ch) => {
3882 + write!(
3883 + formatter,
3884 + "expected comma after {}, found {}",
3885 + pos,
3886 + QuotedChar(*ch),
3889 + ErrorKind::LeadingZero(pos) => {
3890 + write!(formatter, "invalid leading zero in {}", pos)
3892 + ErrorKind::Overflow(pos) => {
3893 + write!(formatter, "value of {} exceeds u64::MAX", pos)
3895 + ErrorKind::EmptySegment(pos) => {
3896 + write!(formatter, "empty identifier segment in {}", pos)
3898 + ErrorKind::IllegalCharacter(pos) => {
3899 + write!(formatter, "unexpected character in {}", pos)
3901 + ErrorKind::WildcardNotTheOnlyComparator(ch) => {
3902 + write!(
3903 + formatter,
3904 + "wildcard req ({}) must be the only comparator in the version req",
3905 + ch,
3908 + ErrorKind::UnexpectedAfterWildcard => {
3909 + formatter.write_str("unexpected character after wildcard in version req")
3911 + ErrorKind::ExcessiveComparators => {
3912 + formatter.write_str("excessive number of version comparators")
3918 +impl Display for Position {
3919 + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
3920 + formatter.write_str(match self {
3921 + Position::Major => "major version number",
3922 + Position::Minor => "minor version number",
3923 + Position::Patch => "patch version number",
3924 + Position::Pre => "pre-release identifier",
3925 + Position::Build => "build metadata",
3926 + })
3930 +impl Debug for Error {
3931 + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
3932 + formatter.write_str("Error(\"")?;
3933 + Display::fmt(self, formatter)?;
3934 + formatter.write_str("\")")?;
3935 + Ok(())
3939 +struct QuotedChar(char);
3941 +impl Display for QuotedChar {
3942 + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
3943 + // Standard library versions prior to https://github.com/rust-lang/rust/pull/95345
3944 + // print character 0 as '\u{0}'. We prefer '\0' to keep error messages
3945 + // the same across all supported Rust versions.
3946 + if self.0 == '\0' {
3947 + formatter.write_str("'\\0'")
3948 + } else {
3949 + write!(formatter, "{:?}", self.0)
3953 diff --git a/third_party/rust/semver/src/eval.rs b/third_party/rust/semver/src/eval.rs
3954 new file mode 100644
3955 --- /dev/null
3956 +++ b/third_party/rust/semver/src/eval.rs
3957 @@ -0,0 +1,181 @@
3958 +use crate::{Comparator, Op, Version, VersionReq};
3960 +pub(crate) fn matches_req(req: &VersionReq, ver: &Version) -> bool {
3961 + for cmp in &req.comparators {
3962 + if !matches_impl(cmp, ver) {
3963 + return false;
3967 + if ver.pre.is_empty() {
3968 + return true;
3971 + // If a version has a prerelease tag (for example, 1.2.3-alpha.3) then it
3972 + // will only be allowed to satisfy req if at least one comparator with the
3973 + // same major.minor.patch also has a prerelease tag.
3974 + for cmp in &req.comparators {
3975 + if pre_is_compatible(cmp, ver) {
3976 + return true;
3980 + false
3983 +pub(crate) fn matches_comparator(cmp: &Comparator, ver: &Version) -> bool {
3984 + matches_impl(cmp, ver) && (ver.pre.is_empty() || pre_is_compatible(cmp, ver))
3987 +fn matches_impl(cmp: &Comparator, ver: &Version) -> bool {
3988 + match cmp.op {
3989 + Op::Exact | Op::Wildcard => matches_exact(cmp, ver),
3990 + Op::Greater => matches_greater(cmp, ver),
3991 + Op::GreaterEq => matches_exact(cmp, ver) || matches_greater(cmp, ver),
3992 + Op::Less => matches_less(cmp, ver),
3993 + Op::LessEq => matches_exact(cmp, ver) || matches_less(cmp, ver),
3994 + Op::Tilde => matches_tilde(cmp, ver),
3995 + Op::Caret => matches_caret(cmp, ver),
3996 + #[cfg(no_non_exhaustive)]
3997 + Op::__NonExhaustive => unreachable!(),
4001 +fn matches_exact(cmp: &Comparator, ver: &Version) -> bool {
4002 + if ver.major != cmp.major {
4003 + return false;
4006 + if let Some(minor) = cmp.minor {
4007 + if ver.minor != minor {
4008 + return false;
4012 + if let Some(patch) = cmp.patch {
4013 + if ver.patch != patch {
4014 + return false;
4018 + ver.pre == cmp.pre
4021 +fn matches_greater(cmp: &Comparator, ver: &Version) -> bool {
4022 + if ver.major != cmp.major {
4023 + return ver.major > cmp.major;
4026 + match cmp.minor {
4027 + None => return false,
4028 + Some(minor) => {
4029 + if ver.minor != minor {
4030 + return ver.minor > minor;
4035 + match cmp.patch {
4036 + None => return false,
4037 + Some(patch) => {
4038 + if ver.patch != patch {
4039 + return ver.patch > patch;
4044 + ver.pre > cmp.pre
4047 +fn matches_less(cmp: &Comparator, ver: &Version) -> bool {
4048 + if ver.major != cmp.major {
4049 + return ver.major < cmp.major;
4052 + match cmp.minor {
4053 + None => return false,
4054 + Some(minor) => {
4055 + if ver.minor != minor {
4056 + return ver.minor < minor;
4061 + match cmp.patch {
4062 + None => return false,
4063 + Some(patch) => {
4064 + if ver.patch != patch {
4065 + return ver.patch < patch;
4070 + ver.pre < cmp.pre
4073 +fn matches_tilde(cmp: &Comparator, ver: &Version) -> bool {
4074 + if ver.major != cmp.major {
4075 + return false;
4078 + if let Some(minor) = cmp.minor {
4079 + if ver.minor != minor {
4080 + return false;
4084 + if let Some(patch) = cmp.patch {
4085 + if ver.patch != patch {
4086 + return ver.patch > patch;
4090 + ver.pre >= cmp.pre
4093 +fn matches_caret(cmp: &Comparator, ver: &Version) -> bool {
4094 + if ver.major != cmp.major {
4095 + return false;
4098 + let minor = match cmp.minor {
4099 + None => return true,
4100 + Some(minor) => minor,
4101 + };
4103 + let patch = match cmp.patch {
4104 + None => {
4105 + if cmp.major > 0 {
4106 + return ver.minor >= minor;
4107 + } else {
4108 + return ver.minor == minor;
4111 + Some(patch) => patch,
4112 + };
4114 + if cmp.major > 0 {
4115 + if ver.minor != minor {
4116 + return ver.minor > minor;
4117 + } else if ver.patch != patch {
4118 + return ver.patch > patch;
4120 + } else if minor > 0 {
4121 + if ver.minor != minor {
4122 + return false;
4123 + } else if ver.patch != patch {
4124 + return ver.patch > patch;
4126 + } else if ver.minor != minor || ver.patch != patch {
4127 + return false;
4130 + ver.pre >= cmp.pre
4133 +fn pre_is_compatible(cmp: &Comparator, ver: &Version) -> bool {
4134 + cmp.major == ver.major
4135 + && cmp.minor == Some(ver.minor)
4136 + && cmp.patch == Some(ver.patch)
4137 + && !cmp.pre.is_empty()
4139 diff --git a/third_party/rust/semver/src/identifier.rs b/third_party/rust/semver/src/identifier.rs
4140 new file mode 100644
4141 --- /dev/null
4142 +++ b/third_party/rust/semver/src/identifier.rs
4143 @@ -0,0 +1,400 @@
4144 +// This module implements Identifier, a short-optimized string allowed to
4145 +// contain only the ASCII characters hyphen, dot, 0-9, A-Z, a-z.
4147 +// As of mid-2021, the distribution of pre-release lengths on crates.io is:
4149 +// length count length count length count
4150 +// 0 355929 11 81 24 2
4151 +// 1 208 12 48 25 6
4152 +// 2 236 13 55 26 10
4153 +// 3 1909 14 25 27 4
4154 +// 4 1284 15 15 28 1
4155 +// 5 1742 16 35 30 1
4156 +// 6 3440 17 9 31 5
4157 +// 7 5624 18 6 32 1
4158 +// 8 1321 19 12 36 2
4159 +// 9 179 20 2 37 379
4160 +// 10 65 23 11
4162 +// and the distribution of build metadata lengths is:
4164 +// length count length count length count
4165 +// 0 364445 8 7725 18 1
4166 +// 1 72 9 16 19 1
4167 +// 2 7 10 85 20 1
4168 +// 3 28 11 17 22 4
4169 +// 4 9 12 10 26 1
4170 +// 5 68 13 9 27 1
4171 +// 6 73 14 10 40 5
4172 +// 7 53 15 6
4174 +// Therefore it really behooves us to be able to use the entire 8 bytes of a
4175 +// pointer for inline storage. For both pre-release and build metadata there are
4176 +// vastly more strings with length exactly 8 bytes than the sum over all lengths
4177 +// longer than 8 bytes.
4179 +// To differentiate the inline representation from the heap allocated long
4180 +// representation, we'll allocate heap pointers with 2-byte alignment so that
4181 +// they are guaranteed to have an unset least significant bit. Then in the repr
4182 +// we store for pointers, we rotate a 1 into the most significant bit of the
4183 +// most significant byte, which is never set for an ASCII byte.
4185 +// Inline repr:
4187 +// 0xxxxxxx 0xxxxxxx 0xxxxxxx 0xxxxxxx 0xxxxxxx 0xxxxxxx 0xxxxxxx 0xxxxxxx
4189 +// Heap allocated repr:
4191 +// 1ppppppp pppppppp pppppppp pppppppp pppppppp pppppppp pppppppp pppppppp 0
4192 +// ^ most significant bit least significant bit of orig ptr, rotated out ^
4194 +// Since the most significant bit doubles as a sign bit for the similarly sized
4195 +// signed integer type, the CPU has an efficient instruction for inspecting it,
4196 +// meaning we can differentiate between an inline repr and a heap allocated repr
4197 +// in one instruction. Effectively an inline repr always looks like a positive
4198 +// i64 while a heap allocated repr always looks like a negative i64.
4200 +// For the inline repr, we store \0 padding on the end of the stored characters,
4201 +// and thus the string length is readily determined efficiently by a cttz (count
4202 +// trailing zeros) or bsf (bit scan forward) instruction.
4204 +// For the heap allocated repr, the length is encoded as a base-128 varint at
4205 +// the head of the allocation.
4207 +// Empty strings are stored as an all-1 bit pattern, corresponding to -1i64.
4208 +// Consequently the all-0 bit pattern is never a legal representation in any
4209 +// repr, leaving it available as a niche for downstream code. For example this
4210 +// allows size_of::<Version>() == size_of::<Option<Version>>().
4212 +use crate::alloc::alloc::{alloc, dealloc, Layout};
4213 +use core::mem;
4214 +use core::num::{NonZeroU64, NonZeroUsize};
4215 +use core::ptr::{self, NonNull};
4216 +use core::slice;
4217 +use core::str;
4219 +const PTR_BYTES: usize = mem::size_of::<NonNull<u8>>();
4221 +// If pointers are already 8 bytes or bigger, then 0. If pointers are smaller
4222 +// than 8 bytes, then Identifier will contain a byte array to raise its size up
4223 +// to 8 bytes total.
4224 +const TAIL_BYTES: usize = 8 * (PTR_BYTES < 8) as usize - PTR_BYTES * (PTR_BYTES < 8) as usize;
4226 +#[repr(C, align(8))]
4227 +pub(crate) struct Identifier {
4228 + head: NonNull<u8>,
4229 + tail: [u8; TAIL_BYTES],
4232 +impl Identifier {
4233 + pub(crate) const fn empty() -> Self {
4234 + // This is a separate constant because unsafe function calls are not
4235 + // allowed in a const fn body, only in a const, until later rustc than
4236 + // what we support.
4237 + const HEAD: NonNull<u8> = unsafe { NonNull::new_unchecked(!0 as *mut u8) };
4239 + // `mov rax, -1`
4240 + Identifier {
4241 + head: HEAD,
4242 + tail: [!0; TAIL_BYTES],
4246 + // SAFETY: string must be ASCII and not contain \0 bytes.
4247 + pub(crate) unsafe fn new_unchecked(string: &str) -> Self {
4248 + let len = string.len();
4249 + match len as u64 {
4250 + 0 => Self::empty(),
4251 + 1..=8 => {
4252 + let mut bytes = [0u8; mem::size_of::<Identifier>()];
4253 + // SAFETY: string is big enough to read len bytes, bytes is big
4254 + // enough to write len bytes, and they do not overlap.
4255 + unsafe { ptr::copy_nonoverlapping(string.as_ptr(), bytes.as_mut_ptr(), len) };
4256 + // SAFETY: the head field is nonzero because the input string
4257 + // was at least 1 byte of ASCII and did not contain \0.
4258 + unsafe { mem::transmute::<[u8; mem::size_of::<Identifier>()], Identifier>(bytes) }
4260 + 9..=0xff_ffff_ffff_ffff => {
4261 + // SAFETY: len is in a range that does not contain 0.
4262 + let size = bytes_for_varint(unsafe { NonZeroUsize::new_unchecked(len) }) + len;
4263 + let align = 2;
4264 + // SAFETY: align is not zero, align is a power of two, and
4265 + // rounding size up to align does not overflow usize::MAX.
4266 + let layout = unsafe { Layout::from_size_align_unchecked(size, align) };
4267 + // SAFETY: layout's size is nonzero.
4268 + let ptr = unsafe { alloc(layout) };
4269 + let mut write = ptr;
4270 + let mut varint_remaining = len;
4271 + while varint_remaining > 0 {
4272 + // SAFETY: size is bytes_for_varint(len) bytes + len bytes.
4273 + // This is writing the first bytes_for_varint(len) bytes.
4274 + unsafe { ptr::write(write, varint_remaining as u8 | 0x80) };
4275 + varint_remaining >>= 7;
4276 + // SAFETY: still in bounds of the same allocation.
4277 + write = unsafe { write.add(1) };
4279 + // SAFETY: size is bytes_for_varint(len) bytes + len bytes. This
4280 + // is writing to the last len bytes.
4281 + unsafe { ptr::copy_nonoverlapping(string.as_ptr(), write, len) };
4282 + Identifier {
4283 + head: ptr_to_repr(ptr),
4284 + tail: [0; TAIL_BYTES],
4287 + 0x100_0000_0000_0000..=0xffff_ffff_ffff_ffff => {
4288 + unreachable!("please refrain from storing >64 petabytes of text in semver version");
4290 + #[cfg(no_exhaustive_int_match)] // rustc <1.33
4291 + _ => unreachable!(),
4295 + pub(crate) fn is_empty(&self) -> bool {
4296 + // `cmp rdi, -1` -- basically: `repr as i64 == -1`
4297 + let empty = Self::empty();
4298 + let is_empty = self.head == empty.head && self.tail == empty.tail;
4299 + // The empty representation does nothing on Drop. We can't let this one
4300 + // drop normally because `impl Drop for Identifier` calls is_empty; that
4301 + // would be an infinite recursion.
4302 + mem::forget(empty);
4303 + is_empty
4306 + fn is_inline(&self) -> bool {
4307 + // `test rdi, rdi` -- basically: `repr as i64 >= 0`
4308 + self.head.as_ptr() as usize >> (PTR_BYTES * 8 - 1) == 0
4311 + fn is_empty_or_inline(&self) -> bool {
4312 + // `cmp rdi, -2` -- basically: `repr as i64 > -2`
4313 + self.is_empty() || self.is_inline()
4316 + pub(crate) fn as_str(&self) -> &str {
4317 + if self.is_empty() {
4318 + ""
4319 + } else if self.is_inline() {
4320 + // SAFETY: repr is in the inline representation.
4321 + unsafe { inline_as_str(self) }
4322 + } else {
4323 + // SAFETY: repr is in the heap allocated representation.
4324 + unsafe { ptr_as_str(&self.head) }
4329 +impl Clone for Identifier {
4330 + fn clone(&self) -> Self {
4331 + if self.is_empty_or_inline() {
4332 + Identifier {
4333 + head: self.head,
4334 + tail: self.tail,
4336 + } else {
4337 + let ptr = repr_to_ptr(self.head);
4338 + // SAFETY: ptr is one of our own heap allocations.
4339 + let len = unsafe { decode_len(ptr) };
4340 + let size = bytes_for_varint(len) + len.get();
4341 + let align = 2;
4342 + // SAFETY: align is not zero, align is a power of two, and rounding
4343 + // size up to align does not overflow usize::MAX. This is just
4344 + // duplicating a previous allocation where all of these guarantees
4345 + // were already made.
4346 + let layout = unsafe { Layout::from_size_align_unchecked(size, align) };
4347 + // SAFETY: layout's size is nonzero.
4348 + let clone = unsafe { alloc(layout) };
4349 + // SAFETY: new allocation cannot overlap the previous one (this was
4350 + // not a realloc). The argument ptrs are readable/writeable
4351 + // respectively for size bytes.
4352 + unsafe { ptr::copy_nonoverlapping(ptr, clone, size) }
4353 + Identifier {
4354 + head: ptr_to_repr(clone),
4355 + tail: [0; TAIL_BYTES],
4361 +impl Drop for Identifier {
4362 + fn drop(&mut self) {
4363 + if self.is_empty_or_inline() {
4364 + return;
4366 + let ptr = repr_to_ptr_mut(self.head);
4367 + // SAFETY: ptr is one of our own heap allocations.
4368 + let len = unsafe { decode_len(ptr) };
4369 + let size = bytes_for_varint(len) + len.get();
4370 + let align = 2;
4371 + // SAFETY: align is not zero, align is a power of two, and rounding
4372 + // size up to align does not overflow usize::MAX. These guarantees were
4373 + // made when originally allocating this memory.
4374 + let layout = unsafe { Layout::from_size_align_unchecked(size, align) };
4375 + // SAFETY: ptr was previously allocated by the same allocator with the
4376 + // same layout.
4377 + unsafe { dealloc(ptr, layout) }
4381 +impl PartialEq for Identifier {
4382 + fn eq(&self, rhs: &Self) -> bool {
4383 + if self.is_empty_or_inline() {
4384 + // Fast path (most common)
4385 + self.head == rhs.head && self.tail == rhs.tail
4386 + } else if rhs.is_empty_or_inline() {
4387 + false
4388 + } else {
4389 + // SAFETY: both reprs are in the heap allocated representation.
4390 + unsafe { ptr_as_str(&self.head) == ptr_as_str(&rhs.head) }
4395 +unsafe impl Send for Identifier {}
4396 +unsafe impl Sync for Identifier {}
4398 +// We use heap pointers that are 2-byte aligned, meaning they have an
4399 +// insignificant 0 in the least significant bit. We take advantage of that
4400 +// unneeded bit to rotate a 1 into the most significant bit to make the repr
4401 +// distinguishable from ASCII bytes.
4402 +fn ptr_to_repr(original: *mut u8) -> NonNull<u8> {
4403 + // `mov eax, 1`
4404 + // `shld rax, rdi, 63`
4405 + let modified = (original as usize | 1).rotate_right(1);
4407 + // `original + (modified - original)`, but being mindful of provenance.
4408 + let diff = modified.wrapping_sub(original as usize);
4409 + let modified = original.wrapping_add(diff);
4411 + // SAFETY: the most significant bit of repr is known to be set, so the value
4412 + // is not zero.
4413 + unsafe { NonNull::new_unchecked(modified) }
4416 +// Shift out the 1 previously placed into the most significant bit of the least
4417 +// significant byte. Shift in a low 0 bit to reconstruct the original 2-byte
4418 +// aligned pointer.
4419 +fn repr_to_ptr(modified: NonNull<u8>) -> *const u8 {
4420 + // `lea rax, [rdi + rdi]`
4421 + let modified = modified.as_ptr();
4422 + let original = (modified as usize) << 1;
4424 + // `modified + (original - modified)`, but being mindful of provenance.
4425 + let diff = original.wrapping_sub(modified as usize);
4426 + modified.wrapping_add(diff)
4429 +fn repr_to_ptr_mut(repr: NonNull<u8>) -> *mut u8 {
4430 + repr_to_ptr(repr) as *mut u8
4433 +// Compute the length of the inline string, assuming the argument is in short
4434 +// string representation. Short strings are stored as 1 to 8 nonzero ASCII
4435 +// bytes, followed by \0 padding for the remaining bytes.
4437 +// SAFETY: the identifier must indeed be in the inline representation.
4438 +unsafe fn inline_len(repr: &Identifier) -> NonZeroUsize {
4439 + // SAFETY: Identifier's layout is align(8) and at least size 8. We're doing
4440 + // an aligned read of the first 8 bytes from it. The bytes are not all zero
4441 + // because inline strings are at least 1 byte long and cannot contain \0.
4442 + let repr = unsafe { ptr::read(repr as *const Identifier as *const NonZeroU64) };
4444 + // Rustc >=1.53 has intrinsics for counting zeros on a non-zeroable integer.
4445 + // On many architectures these are more efficient than counting on ordinary
4446 + // zeroable integers (bsf vs cttz). On rustc <1.53 without those intrinsics,
4447 + // we count zeros in the u64 rather than the NonZeroU64.
4448 + #[cfg(no_nonzero_bitscan)]
4449 + let repr = repr.get();
4451 + #[cfg(target_endian = "little")]
4452 + let zero_bits_on_string_end = repr.leading_zeros();
4453 + #[cfg(target_endian = "big")]
4454 + let zero_bits_on_string_end = repr.trailing_zeros();
4456 + let nonzero_bytes = 8 - zero_bits_on_string_end as usize / 8;
4458 + // SAFETY: repr is nonzero, so it has at most 63 zero bits on either end,
4459 + // thus at least one nonzero byte.
4460 + unsafe { NonZeroUsize::new_unchecked(nonzero_bytes) }
4463 +// SAFETY: repr must be in the inline representation, i.e. at least 1 and at
4464 +// most 8 nonzero ASCII bytes padded on the end with \0 bytes.
4465 +unsafe fn inline_as_str(repr: &Identifier) -> &str {
4466 + let ptr = repr as *const Identifier as *const u8;
4467 + let len = unsafe { inline_len(repr) }.get();
4468 + // SAFETY: we are viewing the nonzero ASCII prefix of the inline repr's
4469 + // contents as a slice of bytes. Input/output lifetimes are correctly
4470 + // associated.
4471 + let slice = unsafe { slice::from_raw_parts(ptr, len) };
4472 + // SAFETY: the string contents are known to be only ASCII bytes, which are
4473 + // always valid UTF-8.
4474 + unsafe { str::from_utf8_unchecked(slice) }
4477 +// Decode varint. Varints consist of between one and eight base-128 digits, each
4478 +// of which is stored in a byte with most significant bit set. Adjacent to the
4479 +// varint in memory there is guaranteed to be at least 9 ASCII bytes, each of
4480 +// which has an unset most significant bit.
4482 +// SAFETY: ptr must be one of our own heap allocations, with the varint header
4483 +// already written.
4484 +unsafe fn decode_len(ptr: *const u8) -> NonZeroUsize {
4485 + // SAFETY: There is at least one byte of varint followed by at least 9 bytes
4486 + // of string content, which is at least 10 bytes total for the allocation,
4487 + // so reading the first two is no problem.
4488 + let [first, second] = unsafe { ptr::read(ptr as *const [u8; 2]) };
4489 + if second < 0x80 {
4490 + // SAFETY: the length of this heap allocated string has been encoded as
4491 + // one base-128 digit, so the length is at least 9 and at most 127. It
4492 + // cannot be zero.
4493 + unsafe { NonZeroUsize::new_unchecked((first & 0x7f) as usize) }
4494 + } else {
4495 + return unsafe { decode_len_cold(ptr) };
4497 + // Identifiers 128 bytes or longer. This is not exercised by any crate
4498 + // version currently published to crates.io.
4499 + #[cold]
4500 + #[inline(never)]
4501 + unsafe fn decode_len_cold(mut ptr: *const u8) -> NonZeroUsize {
4502 + let mut len = 0;
4503 + let mut shift = 0;
4504 + loop {
4505 + // SAFETY: varint continues while there are bytes having the
4506 + // most significant bit set, i.e. until we start hitting the
4507 + // ASCII string content with msb unset.
4508 + let byte = unsafe { *ptr };
4509 + if byte < 0x80 {
4510 + // SAFETY: the string length is known to be 128 bytes or
4511 + // longer.
4512 + return unsafe { NonZeroUsize::new_unchecked(len) };
4514 + // SAFETY: still in bounds of the same allocation.
4515 + ptr = unsafe { ptr.add(1) };
4516 + len += ((byte & 0x7f) as usize) << shift;
4517 + shift += 7;
4523 +// SAFETY: repr must be in the heap allocated representation, with varint header
4524 +// and string contents already written.
4525 +unsafe fn ptr_as_str(repr: &NonNull<u8>) -> &str {
4526 + let ptr = repr_to_ptr(*repr);
4527 + let len = unsafe { decode_len(ptr) };
4528 + let header = bytes_for_varint(len);
4529 + let slice = unsafe { slice::from_raw_parts(ptr.add(header), len.get()) };
4530 + // SAFETY: all identifier contents are ASCII bytes, which are always valid
4531 + // UTF-8.
4532 + unsafe { str::from_utf8_unchecked(slice) }
4535 +// Number of base-128 digits required for the varint representation of a length.
4536 +fn bytes_for_varint(len: NonZeroUsize) -> usize {
4537 + #[cfg(no_nonzero_bitscan)] // rustc <1.53
4538 + let len = len.get();
4540 + let usize_bits = mem::size_of::<usize>() * 8;
4541 + let len_bits = usize_bits - len.leading_zeros() as usize;
4542 + (len_bits + 6) / 7
4544 diff --git a/third_party/rust/semver/src/impls.rs b/third_party/rust/semver/src/impls.rs
4545 new file mode 100644
4546 --- /dev/null
4547 +++ b/third_party/rust/semver/src/impls.rs
4548 @@ -0,0 +1,156 @@
4549 +use crate::backport::*;
4550 +use crate::identifier::Identifier;
4551 +use crate::{BuildMetadata, Comparator, Prerelease, VersionReq};
4552 +use core::cmp::Ordering;
4553 +use core::hash::{Hash, Hasher};
4554 +use core::iter::FromIterator;
4555 +use core::ops::Deref;
4557 +impl Default for Identifier {
4558 + fn default() -> Self {
4559 + Identifier::empty()
4563 +impl Eq for Identifier {}
4565 +impl Hash for Identifier {
4566 + fn hash<H: Hasher>(&self, hasher: &mut H) {
4567 + self.as_str().hash(hasher);
4571 +impl Deref for Prerelease {
4572 + type Target = str;
4574 + fn deref(&self) -> &Self::Target {
4575 + self.identifier.as_str()
4579 +impl Deref for BuildMetadata {
4580 + type Target = str;
4582 + fn deref(&self) -> &Self::Target {
4583 + self.identifier.as_str()
4587 +impl PartialOrd for Prerelease {
4588 + fn partial_cmp(&self, rhs: &Self) -> Option<Ordering> {
4589 + Some(Ord::cmp(self, rhs))
4593 +impl PartialOrd for BuildMetadata {
4594 + fn partial_cmp(&self, rhs: &Self) -> Option<Ordering> {
4595 + Some(Ord::cmp(self, rhs))
4599 +impl Ord for Prerelease {
4600 + fn cmp(&self, rhs: &Self) -> Ordering {
4601 + match self.is_empty() {
4602 + true if rhs.is_empty() => return Ordering::Equal,
4603 + // A real release compares greater than prerelease.
4604 + true => return Ordering::Greater,
4605 + // Prerelease compares less than the real release.
4606 + false if rhs.is_empty() => return Ordering::Less,
4607 + false => {}
4610 + let lhs = self.as_str().split('.');
4611 + let mut rhs = rhs.as_str().split('.');
4613 + for lhs in lhs {
4614 + let rhs = match rhs.next() {
4615 + // Spec: "A larger set of pre-release fields has a higher
4616 + // precedence than a smaller set, if all of the preceding
4617 + // identifiers are equal."
4618 + None => return Ordering::Greater,
4619 + Some(rhs) => rhs,
4620 + };
4622 + let string_cmp = || Ord::cmp(lhs, rhs);
4623 + let is_ascii_digit = |b: u8| b.is_ascii_digit();
4624 + let ordering = match (
4625 + lhs.bytes().all(is_ascii_digit),
4626 + rhs.bytes().all(is_ascii_digit),
4627 + ) {
4628 + // Respect numeric ordering, for example 99 < 100. Spec says:
4629 + // "Identifiers consisting of only digits are compared
4630 + // numerically."
4631 + (true, true) => Ord::cmp(&lhs.len(), &rhs.len()).then_with(string_cmp),
4632 + // Spec: "Numeric identifiers always have lower precedence than
4633 + // non-numeric identifiers."
4634 + (true, false) => return Ordering::Less,
4635 + (false, true) => return Ordering::Greater,
4636 + // Spec: "Identifiers with letters or hyphens are compared
4637 + // lexically in ASCII sort order."
4638 + (false, false) => string_cmp(),
4639 + };
4641 + if ordering != Ordering::Equal {
4642 + return ordering;
4646 + if rhs.next().is_none() {
4647 + Ordering::Equal
4648 + } else {
4649 + Ordering::Less
4654 +impl Ord for BuildMetadata {
4655 + fn cmp(&self, rhs: &Self) -> Ordering {
4656 + let lhs = self.as_str().split('.');
4657 + let mut rhs = rhs.as_str().split('.');
4659 + for lhs in lhs {
4660 + let rhs = match rhs.next() {
4661 + None => return Ordering::Greater,
4662 + Some(rhs) => rhs,
4663 + };
4665 + let is_ascii_digit = |b: u8| b.is_ascii_digit();
4666 + let ordering = match (
4667 + lhs.bytes().all(is_ascii_digit),
4668 + rhs.bytes().all(is_ascii_digit),
4669 + ) {
4670 + (true, true) => {
4671 + // 0 < 00 < 1 < 01 < 001 < 2 < 02 < 002 < 10
4672 + let lhval = lhs.trim_start_matches('0');
4673 + let rhval = rhs.trim_start_matches('0');
4674 + Ord::cmp(&lhval.len(), &rhval.len())
4675 + .then_with(|| Ord::cmp(lhval, rhval))
4676 + .then_with(|| Ord::cmp(&lhs.len(), &rhs.len()))
4678 + (true, false) => return Ordering::Less,
4679 + (false, true) => return Ordering::Greater,
4680 + (false, false) => Ord::cmp(lhs, rhs),
4681 + };
4683 + if ordering != Ordering::Equal {
4684 + return ordering;
4688 + if rhs.next().is_none() {
4689 + Ordering::Equal
4690 + } else {
4691 + Ordering::Less
4696 +impl FromIterator<Comparator> for VersionReq {
4697 + fn from_iter<I>(iter: I) -> Self
4698 + where
4699 + I: IntoIterator<Item = Comparator>,
4701 + let comparators = Vec::from_iter(iter);
4702 + VersionReq { comparators }
4705 diff --git a/third_party/rust/semver/src/lib.rs b/third_party/rust/semver/src/lib.rs
4706 --- a/third_party/rust/semver/src/lib.rs
4707 +++ b/third_party/rust/semver/src/lib.rs
4708 @@ -1,182 +1,533 @@
4709 -// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
4710 -// file at the top-level directory of this distribution and at
4711 -// http://rust-lang.org/COPYRIGHT.
4713 -// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
4714 -// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
4715 -// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
4716 -// option. This file may not be copied, modified, or distributed
4717 -// except according to those terms.
4719 -//! Semantic version parsing and comparison.
4720 +//! [![github]](https://github.com/dtolnay/semver)&ensp;[![crates-io]](https://crates.io/crates/semver)&ensp;[![docs-rs]](https://docs.rs/semver)
4722 -//! Semantic versioning (see http://semver.org/) is a set of rules for
4723 -//! assigning version numbers.
4724 +//! [github]: https://img.shields.io/badge/github-8da0cb?style=for-the-badge&labelColor=555555&logo=github
4725 +//! [crates-io]: https://img.shields.io/badge/crates.io-fc8d62?style=for-the-badge&labelColor=555555&logo=rust
4726 +//! [docs-rs]: https://img.shields.io/badge/docs.rs-66c2a5?style=for-the-badge&labelColor=555555&logoColor=white&logo=data:image/svg+xml;base64,PHN2ZyByb2xlPSJpbWciIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgdmlld0JveD0iMCAwIDUxMiA1MTIiPjxwYXRoIGZpbGw9IiNmNWY1ZjUiIGQ9Ik00ODguNiAyNTAuMkwzOTIgMjE0VjEwNS41YzAtMTUtOS4zLTI4LjQtMjMuNC0zMy43bC0xMDAtMzcuNWMtOC4xLTMuMS0xNy4xLTMuMS0yNS4zIDBsLTEwMCAzNy41Yy0xNC4xIDUuMy0yMy40IDE4LjctMjMuNCAzMy43VjIxNGwtOTYuNiAzNi4yQzkuMyAyNTUuNSAwIDI2OC45IDAgMjgzLjlWMzk0YzAgMTMuNiA3LjcgMjYuMSAxOS45IDMyLjJsMTAwIDUwYzEwLjEgNS4xIDIyLjEgNS4xIDMyLjIgMGwxMDMuOS01MiAxMDMuOSA1MmMxMC4xIDUuMSAyMi4xIDUuMSAzMi4yIDBsMTAwLTUwYzEyLjItNi4xIDE5LjktMTguNiAxOS45LTMyLjJWMjgzLjljMC0xNS05LjMtMjguNC0yMy40LTMzLjd6TTM1OCAyMTQuOGwtODUgMzEuOXYtNjguMmw4NS0zN3Y3My4zek0xNTQgMTA0LjFsMTAyLTM4LjIgMTAyIDM4LjJ2LjZsLTEwMiA0MS40LTEwMi00MS40di0uNnptODQgMjkxLjFsLTg1IDQyLjV2LTc5LjFsODUtMzguOHY3NS40em0wLTExMmwtMTAyIDQxLjQtMTAyLTQxLjR2LS42bDEwMi0zOC4yIDEwMiAzOC4ydi42em0yNDAgMTEybC04NSA0Mi41di03OS4xbDg1LTM4Ljh2NzUuNHptMC0xMTJsLTEwMiA0MS40LTEwMi00MS40di0uNmwxMDItMzguMiAxMDIgMzguMnYuNnoiPjwvcGF0aD48L3N2Zz4K
4728 -//! ## SemVer overview
4729 -//!
4730 -//! Given a version number MAJOR.MINOR.PATCH, increment the:
4731 +//! <br>
4733 -//! 1. MAJOR version when you make incompatible API changes,
4734 -//! 2. MINOR version when you add functionality in a backwards-compatible
4735 -//! manner, and
4736 -//! 3. PATCH version when you make backwards-compatible bug fixes.
4737 -//!
4738 -//! Additional labels for pre-release and build metadata are available as
4739 -//! extensions to the MAJOR.MINOR.PATCH format.
4740 -//!
4741 -//! Any references to 'the spec' in this documentation refer to [version 2.0 of
4742 -//! the SemVer spec](http://semver.org/spec/v2.0.0.html).
4743 +//! A parser and evaluator for Cargo's flavor of Semantic Versioning.
4745 -//! ## SemVer and the Rust ecosystem
4746 -//!
4747 -//! Rust itself follows the SemVer specification, as does its standard
4748 -//! libraries. The two are not tied together.
4749 +//! Semantic Versioning (see <https://semver.org>) is a guideline for how
4750 +//! version numbers are assigned and incremented. It is widely followed within
4751 +//! the Cargo/crates.io ecosystem for Rust.
4753 -//! [Cargo](http://crates.io), Rust's package manager, uses SemVer to determine
4754 -//! which versions of packages you need installed.
4755 +//! <br>
4757 -//! ## Versions
4758 -//!
4759 -//! At its simplest, the `semver` crate allows you to construct `Version`
4760 -//! objects using the `parse` method:
4761 +//! # Example
4763 -//! ```{rust}
4764 -//! use semver::Version;
4765 +//! ```
4766 +//! use semver::{BuildMetadata, Prerelease, Version, VersionReq};
4768 -//! assert!(Version::parse("1.2.3") == Ok(Version {
4769 -//! major: 1,
4770 -//! minor: 2,
4771 -//! patch: 3,
4772 -//! pre: vec!(),
4773 -//! build: vec!(),
4774 -//! }));
4775 -//! ```
4776 -//!
4777 -//! If you have multiple `Version`s, you can use the usual comparison operators
4778 -//! to compare them:
4779 -//!
4780 -//! ```{rust}
4781 -//! use semver::Version;
4782 -//!
4783 -//! assert!(Version::parse("1.2.3-alpha") != Version::parse("1.2.3-beta"));
4784 -//! assert!(Version::parse("1.2.3-alpha2") > Version::parse("1.2.0"));
4785 -//! ```
4786 +//! fn main() {
4787 +//! let req = VersionReq::parse(">=1.2.3, <1.8.0").unwrap();
4789 -//! If you explicitly need to modify a Version, SemVer also allows you to
4790 -//! increment the major, minor, and patch numbers in accordance with the spec.
4791 -//!
4792 -//! Please note that in order to do this, you must use a mutable Version:
4793 -//!
4794 -//! ```{rust}
4795 -//! use semver::Version;
4796 -//!
4797 -//! let mut bugfix_release = Version::parse("1.0.0").unwrap();
4798 -//! bugfix_release.increment_patch();
4799 +//! // Check whether this requirement matches version 1.2.3-alpha.1 (no)
4800 +//! let version = Version {
4801 +//! major: 1,
4802 +//! minor: 2,
4803 +//! patch: 3,
4804 +//! pre: Prerelease::new("alpha.1").unwrap(),
4805 +//! build: BuildMetadata::EMPTY,
4806 +//! };
4807 +//! assert!(!req.matches(&version));
4809 -//! assert_eq!(Ok(bugfix_release), Version::parse("1.0.1"));
4810 -//! ```
4811 -//!
4812 -//! When incrementing the minor version number, the patch number resets to zero
4813 -//! (in accordance with section 7 of the spec)
4814 -//!
4815 -//! ```{rust}
4816 -//! use semver::Version;
4817 -//!
4818 -//! let mut feature_release = Version::parse("1.4.6").unwrap();
4819 -//! feature_release.increment_minor();
4820 -//!
4821 -//! assert_eq!(Ok(feature_release), Version::parse("1.5.0"));
4822 +//! // Check whether it matches 1.3.0 (yes it does)
4823 +//! let version = Version::parse("1.3.0").unwrap();
4824 +//! assert!(req.matches(&version));
4825 +//! }
4826 //! ```
4828 -//! Similarly, when incrementing the major version number, the patch and minor
4829 -//! numbers reset to zero (in accordance with section 8 of the spec)
4830 +//! <br><br>
4832 -//! ```{rust}
4833 -//! use semver::Version;
4834 -//!
4835 -//! let mut chrome_release = Version::parse("41.5.5377").unwrap();
4836 -//! chrome_release.increment_major();
4837 +//! # Scope of this crate
4839 -//! assert_eq!(Ok(chrome_release), Version::parse("42.0.0"));
4840 -//! ```
4841 -//!
4842 -//! ## Requirements
4843 -//!
4844 -//! The `semver` crate also provides the ability to compare requirements, which
4845 -//! are more complex comparisons.
4846 -//!
4847 -//! For example, creating a requirement that only matches versions greater than
4848 -//! or equal to 1.0.0:
4849 +//! Besides Cargo, several other package ecosystems and package managers for
4850 +//! other languages also use SemVer:&ensp;RubyGems/Bundler for Ruby, npm for
4851 +//! JavaScript, Composer for PHP, CocoaPods for Objective-C...
4853 -//! ```{rust}
4854 -//! # #![allow(unstable)]
4855 -//! use semver::Version;
4856 -//! use semver::VersionReq;
4857 -//!
4858 -//! let r = VersionReq::parse(">= 1.0.0").unwrap();
4859 -//! let v = Version::parse("1.0.0").unwrap();
4860 +//! The `semver` crate is specifically intended to implement Cargo's
4861 +//! interpretation of Semantic Versioning.
4863 -//! assert!(r.to_string() == ">= 1.0.0".to_string());
4864 -//! assert!(r.matches(&v))
4865 -//! ```
4866 -//!
4867 -//! It also allows parsing of `~x.y.z` and `^x.y.z` requirements as defined at
4868 -//! https://www.npmjs.org/doc/misc/semver.html
4869 +//! Where the various tools differ in their interpretation or implementation of
4870 +//! the spec, this crate follows the implementation choices made by Cargo. If
4871 +//! you are operating on version numbers from some other package ecosystem, you
4872 +//! will want to use a different semver library which is appropriate to that
4873 +//! ecosystem.
4875 -//! **Tilde requirements** specify a minimal version with some updates:
4876 -//!
4877 -//! ```notrust
4878 -//! ~1.2.3 := >=1.2.3 <1.3.0
4879 -//! ~1.2 := >=1.2.0 <1.3.0
4880 -//! ~1 := >=1.0.0 <2.0.0
4881 -//! ```
4882 +//! The extent of Cargo's SemVer support is documented in the *[Specifying
4883 +//! Dependencies]* chapter of the Cargo reference.
4885 -//! **Caret requirements** allow SemVer compatible updates to a specified
4886 -//! verion, `0.x` and `0.x+1` are not considered compatible, but `1.x` and
4887 -//! `1.x+1` are.
4888 -//!
4889 -//! `0.0.x` is not considered compatible with any other version.
4890 -//! Missing minor and patch versions are desugared to `0` but allow flexibility
4891 -//! for that value.
4892 -//!
4893 -//! ```notrust
4894 -//! ^1.2.3 := >=1.2.3 <2.0.0
4895 -//! ^0.2.3 := >=0.2.3 <0.3.0
4896 -//! ^0.0.3 := >=0.0.3 <0.0.4
4897 -//! ^0.0 := >=0.0.0 <0.1.0
4898 -//! ^0 := >=0.0.0 <1.0.0
4899 -//! ```
4900 -//!
4901 -//! **Wildcard requirements** allows parsing of version requirements of the
4902 -//! formats `*`, `x.*` and `x.y.*`.
4903 -//!
4904 -//! ```notrust
4905 -//! * := >=0.0.0
4906 -//! 1.* := >=1.0.0 <2.0.0
4907 -//! 1.2.* := >=1.2.0 <1.3.0
4908 -//! ```
4909 +//! [Specifying Dependencies]: https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html
4911 +#![doc(html_root_url = "https://docs.rs/semver/1.0.9")]
4912 +#![cfg_attr(doc_cfg, feature(doc_cfg))]
4913 +#![cfg_attr(all(not(feature = "std"), not(no_alloc_crate)), no_std)]
4914 +#![cfg_attr(not(no_unsafe_op_in_unsafe_fn_lint), deny(unsafe_op_in_unsafe_fn))]
4915 +#![cfg_attr(no_unsafe_op_in_unsafe_fn_lint, allow(unused_unsafe))]
4916 +#![cfg_attr(no_str_strip_prefix, allow(unstable_name_collisions))]
4917 +#![allow(
4918 + clippy::cast_lossless,
4919 + clippy::cast_possible_truncation,
4920 + clippy::doc_markdown,
4921 + clippy::items_after_statements,
4922 + clippy::manual_map,
4923 + clippy::match_bool,
4924 + clippy::missing_errors_doc,
4925 + clippy::must_use_candidate,
4926 + clippy::needless_doctest_main,
4927 + clippy::option_if_let_else,
4928 + clippy::ptr_as_ptr,
4929 + clippy::redundant_else,
4930 + clippy::semicolon_if_nothing_returned, // https://github.com/rust-lang/rust-clippy/issues/7324
4931 + clippy::similar_names,
4932 + clippy::unnested_or_patterns,
4933 + clippy::unseparated_literal_suffix,
4934 + clippy::wildcard_imports
4937 +#[cfg(not(no_alloc_crate))]
4938 +extern crate alloc;
4940 +mod backport;
4941 +mod display;
4942 +mod error;
4943 +mod eval;
4944 +mod identifier;
4945 +mod impls;
4946 +mod parse;
4948 +#[cfg(feature = "serde")]
4949 +mod serde;
4951 +use crate::alloc::vec::Vec;
4952 +use crate::identifier::Identifier;
4953 +use core::str::FromStr;
4955 +#[allow(unused_imports)]
4956 +use crate::backport::*;
4958 +pub use crate::parse::Error;
4960 +/// **SemVer version** as defined by <https://semver.org>.
4961 +///
4962 +/// # Syntax
4963 +///
4964 +/// - The major, minor, and patch numbers may be any integer 0 through u64::MAX.
4965 +/// When representing a SemVer version as a string, each number is written as
4966 +/// a base 10 integer. For example, `1.0.119`.
4967 +///
4968 +/// - Leading zeros are forbidden in those positions. For example `1.01.00` is
4969 +/// invalid as a SemVer version.
4970 +///
4971 +/// - The pre-release identifier, if present, must conform to the syntax
4972 +/// documented for [`Prerelease`].
4973 +///
4974 +/// - The build metadata, if present, must conform to the syntax documented for
4975 +/// [`BuildMetadata`].
4976 +///
4977 +/// - Whitespace is not allowed anywhere in the version.
4978 +///
4979 +/// # Total ordering
4980 +///
4981 +/// Given any two SemVer versions, one is less than, greater than, or equal to
4982 +/// the other. Versions may be compared against one another using Rust's usual
4983 +/// comparison operators.
4984 +///
4985 +/// - The major, minor, and patch number are compared numerically from left to
4986 +/// right, lexicographically ordered as a 3-tuple of integers. So for example
4987 +/// version `1.5.0` is less than version `1.19.0`, despite the fact that
4988 +/// "1.19.0" &lt; "1.5.0" as ASCIIbetically compared strings and 1.19 &lt; 1.5
4989 +/// as real numbers.
4990 +///
4991 +/// - When major, minor, and patch are equal, a pre-release version is
4992 +/// considered less than the ordinary release:&ensp;version `1.0.0-alpha.1` is
4993 +/// less than version `1.0.0`.
4994 +///
4995 +/// - Two pre-releases of the same major, minor, patch are compared by
4996 +/// lexicographic ordering of dot-separated components of the pre-release
4997 +/// string.
4998 +///
4999 +/// - Identifiers consisting of only digits are compared
5000 +/// numerically:&ensp;`1.0.0-pre.8` is less than `1.0.0-pre.12`.
5001 +///
5002 +/// - Identifiers that contain a letter or hyphen are compared in ASCII sort
5003 +/// order:&ensp;`1.0.0-pre12` is less than `1.0.0-pre8`.
5004 +///
5005 +/// - Any numeric identifier is always less than any non-numeric
5006 +/// identifier:&ensp;`1.0.0-pre.1` is less than `1.0.0-pre.x`.
5007 +///
5008 +/// Example:&ensp;`1.0.0-alpha`&ensp;&lt;&ensp;`1.0.0-alpha.1`&ensp;&lt;&ensp;`1.0.0-alpha.beta`&ensp;&lt;&ensp;`1.0.0-beta`&ensp;&lt;&ensp;`1.0.0-beta.2`&ensp;&lt;&ensp;`1.0.0-beta.11`&ensp;&lt;&ensp;`1.0.0-rc.1`&ensp;&lt;&ensp;`1.0.0`
5009 +#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
5010 +pub struct Version {
5011 + pub major: u64,
5012 + pub minor: u64,
5013 + pub patch: u64,
5014 + pub pre: Prerelease,
5015 + pub build: BuildMetadata,
5018 +/// **SemVer version requirement** describing the intersection of some version
5019 +/// comparators, such as `>=1.2.3, <1.8`.
5020 +///
5021 +/// # Syntax
5022 +///
5023 +/// - Either `*` (meaning "any"), or one or more comma-separated comparators.
5024 +///
5025 +/// - A [`Comparator`] is an operator ([`Op`]) and a partial version, separated
5026 +/// by optional whitespace. For example `>=1.0.0` or `>=1.0`.
5027 +///
5028 +/// - Build metadata is syntactically permitted on the partial versions, but is
5029 +/// completely ignored, as it's never relevant to whether any comparator
5030 +/// matches a particular version.
5031 +///
5032 +/// - Whitespace is permitted around commas and around operators. Whitespace is
5033 +/// not permitted within a partial version, i.e. anywhere between the major
5034 +/// version number and its minor, patch, pre-release, or build metadata.
5035 +#[derive(Clone, Eq, PartialEq, Hash, Debug)]
5036 +#[cfg_attr(no_const_vec_new, derive(Default))]
5037 +pub struct VersionReq {
5038 + pub comparators: Vec<Comparator>,
5041 +/// A pair of comparison operator and partial version, such as `>=1.2`. Forms
5042 +/// one piece of a VersionReq.
5043 +#[derive(Clone, Eq, PartialEq, Hash, Debug)]
5044 +pub struct Comparator {
5045 + pub op: Op,
5046 + pub major: u64,
5047 + pub minor: Option<u64>,
5048 + /// Patch is only allowed if minor is Some.
5049 + pub patch: Option<u64>,
5050 + /// Non-empty pre-release is only allowed if patch is Some.
5051 + pub pre: Prerelease,
5054 +/// SemVer comparison operator: `=`, `>`, `>=`, `<`, `<=`, `~`, `^`, `*`.
5055 +///
5056 +/// # Op::Exact
5057 +/// - &ensp;**`=I.J.K`**&emsp;&mdash;&emsp;exactly the version I.J.K
5058 +/// - &ensp;**`=I.J`**&emsp;&mdash;&emsp;equivalent to `>=I.J.0, <I.(J+1).0`
5059 +/// - &ensp;**`=I`**&emsp;&mdash;&emsp;equivalent to `>=I.0.0, <(I+1).0.0`
5060 +///
5061 +/// # Op::Greater
5062 +/// - &ensp;**`>I.J.K`**
5063 +/// - &ensp;**`>I.J`**&emsp;&mdash;&emsp;equivalent to `>=I.(J+1).0`
5064 +/// - &ensp;**`>I`**&emsp;&mdash;&emsp;equivalent to `>=(I+1).0.0`
5065 +///
5066 +/// # Op::GreaterEq
5067 +/// - &ensp;**`>=I.J.K`**
5068 +/// - &ensp;**`>=I.J`**&emsp;&mdash;&emsp;equivalent to `>=I.J.0`
5069 +/// - &ensp;**`>=I`**&emsp;&mdash;&emsp;equivalent to `>=I.0.0`
5070 +///
5071 +/// # Op::Less
5072 +/// - &ensp;**`<I.J.K`**
5073 +/// - &ensp;**`<I.J`**&emsp;&mdash;&emsp;equivalent to `<I.J.0`
5074 +/// - &ensp;**`<I`**&emsp;&mdash;&emsp;equivalent to `<I.0.0`
5075 +///
5076 +/// # Op::LessEq
5077 +/// - &ensp;**`<=I.J.K`**
5078 +/// - &ensp;**`<=I.J`**&emsp;&mdash;&emsp;equivalent to `<I.(J+1).0`
5079 +/// - &ensp;**`<=I`**&emsp;&mdash;&emsp;equivalent to `<(I+1).0.0`
5080 +///
5081 +/// # Op::Tilde&emsp;("patch" updates)
5082 +/// *Tilde requirements allow the **patch** part of the semver version (the third number) to increase.*
5083 +/// - &ensp;**`~I.J.K`**&emsp;&mdash;&emsp;equivalent to `>=I.J.K, <I.(J+1).0`
5084 +/// - &ensp;**`~I.J`**&emsp;&mdash;&emsp;equivalent to `=I.J`
5085 +/// - &ensp;**`~I`**&emsp;&mdash;&emsp;equivalent to `=I`
5086 +///
5087 +/// # Op::Caret&emsp;("compatible" updates)
5088 +/// *Caret requirements allow parts that are **right of the first nonzero** part of the semver version to increase.*
5089 +/// - &ensp;**`^I.J.K`**&ensp;(for I\>0)&emsp;&mdash;&emsp;equivalent to `>=I.J.K, <(I+1).0.0`
5090 +/// - &ensp;**`^0.J.K`**&ensp;(for J\>0)&emsp;&mdash;&emsp;equivalent to `>=0.J.K, <0.(J+1).0`
5091 +/// - &ensp;**`^0.0.K`**&emsp;&mdash;&emsp;equivalent to `=0.0.K`
5092 +/// - &ensp;**`^I.J`**&ensp;(for I\>0 or J\>0)&emsp;&mdash;&emsp;equivalent to `^I.J.0`
5093 +/// - &ensp;**`^0.0`**&emsp;&mdash;&emsp;equivalent to `=0.0`
5094 +/// - &ensp;**`^I`**&emsp;&mdash;&emsp;equivalent to `=I`
5095 +///
5096 +/// # Op::Wildcard
5097 +/// - &ensp;**`I.J.*`**&emsp;&mdash;&emsp;equivalent to `=I.J`
5098 +/// - &ensp;**`I.*`**&ensp;or&ensp;**`I.*.*`**&emsp;&mdash;&emsp;equivalent to `=I`
5099 +#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
5100 +#[cfg_attr(not(no_non_exhaustive), non_exhaustive)]
5101 +pub enum Op {
5102 + Exact,
5103 + Greater,
5104 + GreaterEq,
5105 + Less,
5106 + LessEq,
5107 + Tilde,
5108 + Caret,
5109 + Wildcard,
5111 + #[cfg(no_non_exhaustive)] // rustc <1.40
5112 + #[doc(hidden)]
5113 + __NonExhaustive,
5116 -#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
5117 - html_favicon_url = "https://www.rust-lang.org/favicon.ico")]
5118 -#![deny(missing_docs)]
5119 -#![cfg_attr(test, deny(warnings))]
5120 +/// Optional pre-release identifier on a version string. This comes after `-` in
5121 +/// a SemVer version, like `1.0.0-alpha.1`
5122 +///
5123 +/// # Examples
5124 +///
5125 +/// Some real world pre-release idioms drawn from crates.io:
5126 +///
5127 +/// - **[mio]** <code>0.7.0-<b>alpha.1</b></code> &mdash; the most common style
5128 +/// for numbering pre-releases.
5129 +///
5130 +/// - **[pest]** <code>1.0.0-<b>beta.8</b></code>,&ensp;<code>1.0.0-<b>rc.0</b></code>
5131 +/// &mdash; this crate makes a distinction between betas and release
5132 +/// candidates.
5133 +///
5134 +/// - **[sassers]** <code>0.11.0-<b>shitshow</b></code> &mdash; ???.
5135 +///
5136 +/// - **[atomic-utils]** <code>0.0.0-<b>reserved</b></code> &mdash; a squatted
5137 +/// crate name.
5138 +///
5139 +/// [mio]: https://crates.io/crates/mio
5140 +/// [pest]: https://crates.io/crates/pest
5141 +/// [atomic-utils]: https://crates.io/crates/atomic-utils
5142 +/// [sassers]: https://crates.io/crates/sassers
5143 +///
5144 +/// *Tip:* Be aware that if you are planning to number your own pre-releases,
5145 +/// you should prefer to separate the numeric part from any non-numeric
5146 +/// identifiers by using a dot in between. That is, prefer pre-releases
5147 +/// `alpha.1`, `alpha.2`, etc rather than `alpha1`, `alpha2` etc. The SemVer
5148 +/// spec's rule for pre-release precedence has special treatment of numeric
5149 +/// components in the pre-release string, but only if there are no non-digit
5150 +/// characters in the same dot-separated component. So you'd have `alpha.2` &lt;
5151 +/// `alpha.11` as intended, but `alpha11` &lt; `alpha2`.
5152 +///
5153 +/// # Syntax
5154 +///
5155 +/// Pre-release strings are a series of dot separated identifiers immediately
5156 +/// following the patch version. Identifiers must comprise only ASCII
5157 +/// alphanumerics and hyphens: `0-9`, `A-Z`, `a-z`, `-`. Identifiers must not be
5158 +/// empty. Numeric identifiers must not include leading zeros.
5159 +///
5160 +/// # Total ordering
5161 +///
5162 +/// Pre-releases have a total order defined by the SemVer spec. It uses
5163 +/// lexicographic ordering of dot-separated components. Identifiers consisting
5164 +/// of only digits are compared numerically. Otherwise, identifiers are compared
5165 +/// in ASCII sort order. Any numeric identifier is always less than any
5166 +/// non-numeric identifier.
5167 +///
5168 +/// Example:&ensp;`alpha`&ensp;&lt;&ensp;`alpha.85`&ensp;&lt;&ensp;`alpha.90`&ensp;&lt;&ensp;`alpha.200`&ensp;&lt;&ensp;`alpha.0a`&ensp;&lt;&ensp;`alpha.1a0`&ensp;&lt;&ensp;`alpha.a`&ensp;&lt;&ensp;`beta`
5169 +#[derive(Default, Clone, Eq, PartialEq, Hash)]
5170 +pub struct Prerelease {
5171 + identifier: Identifier,
5174 -extern crate semver_parser;
5176 -// Serialization and deserialization support for version numbers
5177 -#[cfg(feature = "serde")]
5178 -extern crate serde;
5179 +/// Optional build metadata identifier. This comes after `+` in a SemVer
5180 +/// version, as in `0.8.1+zstd.1.5.0`.
5181 +///
5182 +/// # Examples
5183 +///
5184 +/// Some real world build metadata idioms drawn from crates.io:
5185 +///
5186 +/// - **[libgit2-sys]** <code>0.12.20+<b>1.1.0</b></code> &mdash; for this
5187 +/// crate, the build metadata indicates the version of the C libgit2 library
5188 +/// that the Rust crate is built against.
5189 +///
5190 +/// - **[mashup]** <code>0.1.13+<b>deprecated</b></code> &mdash; just the word
5191 +/// "deprecated" for a crate that has been superseded by another. Eventually
5192 +/// people will take notice of this in Cargo's build output where it lists the
5193 +/// crates being compiled.
5194 +///
5195 +/// - **[google-bigquery2]** <code>2.0.4+<b>20210327</b></code> &mdash; this
5196 +/// library is automatically generated from an official API schema, and the
5197 +/// build metadata indicates the date on which that schema was last captured.
5198 +///
5199 +/// - **[fbthrift-git]** <code>0.0.6+<b>c7fcc0e</b></code> &mdash; this crate is
5200 +/// published from snapshots of a big company monorepo. In monorepo
5201 +/// development, there is no concept of versions, and all downstream code is
5202 +/// just updated atomically in the same commit that breaking changes to a
5203 +/// library are landed. Therefore for crates.io purposes, every published
5204 +/// version must be assumed to be incompatible with the previous. The build
5205 +/// metadata provides the source control hash of the snapshotted code.
5206 +///
5207 +/// [libgit2-sys]: https://crates.io/crates/libgit2-sys
5208 +/// [mashup]: https://crates.io/crates/mashup
5209 +/// [google-bigquery2]: https://crates.io/crates/google-bigquery2
5210 +/// [fbthrift-git]: https://crates.io/crates/fbthrift-git
5211 +///
5212 +/// # Syntax
5213 +///
5214 +/// Build metadata is a series of dot separated identifiers immediately
5215 +/// following the patch or pre-release version. Identifiers must comprise only
5216 +/// ASCII alphanumerics and hyphens: `0-9`, `A-Z`, `a-z`, `-`. Identifiers must
5217 +/// not be empty. Leading zeros *are* allowed, unlike any other place in the
5218 +/// SemVer grammar.
5219 +///
5220 +/// # Total ordering
5221 +///
5222 +/// Build metadata is ignored in evaluating `VersionReq`; it plays no role in
5223 +/// whether a `Version` matches any one of the comparison operators.
5224 +///
5225 +/// However for comparing build metadatas among one another, they do have a
5226 +/// total order which is determined by lexicographic ordering of dot-separated
5227 +/// components. Identifiers consisting of only digits are compared numerically.
5228 +/// Otherwise, identifiers are compared in ASCII sort order. Any numeric
5229 +/// identifier is always less than any non-numeric identifier.
5230 +///
5231 +/// Example:&ensp;`demo`&ensp;&lt;&ensp;`demo.85`&ensp;&lt;&ensp;`demo.90`&ensp;&lt;&ensp;`demo.090`&ensp;&lt;&ensp;`demo.200`&ensp;&lt;&ensp;`demo.1a0`&ensp;&lt;&ensp;`demo.a`&ensp;&lt;&ensp;`memo`
5232 +#[derive(Default, Clone, Eq, PartialEq, Hash)]
5233 +pub struct BuildMetadata {
5234 + identifier: Identifier,
5237 -// We take the common approach of keeping our own module system private, and
5238 -// just re-exporting the interface that we want.
5239 +impl Version {
5240 + /// Create `Version` with an empty pre-release and build metadata.
5241 + ///
5242 + /// Equivalent to:
5243 + ///
5244 + /// ```
5245 + /// # use semver::{BuildMetadata, Prerelease, Version};
5246 + /// #
5247 + /// # const fn new(major: u64, minor: u64, patch: u64) -> Version {
5248 + /// Version {
5249 + /// major,
5250 + /// minor,
5251 + /// patch,
5252 + /// pre: Prerelease::EMPTY,
5253 + /// build: BuildMetadata::EMPTY,
5254 + /// }
5255 + /// # }
5256 + /// ```
5257 + pub const fn new(major: u64, minor: u64, patch: u64) -> Self {
5258 + Version {
5259 + major,
5260 + minor,
5261 + patch,
5262 + pre: Prerelease::EMPTY,
5263 + build: BuildMetadata::EMPTY,
5267 + /// Create `Version` by parsing from string representation.
5268 + ///
5269 + /// # Errors
5270 + ///
5271 + /// Possible reasons for the parse to fail include:
5272 + ///
5273 + /// - `1.0` &mdash; too few numeric components. A SemVer version must have
5274 + /// exactly three. If you are looking at something that has fewer than
5275 + /// three numbers in it, it's possible it is a `VersionReq` instead (with
5276 + /// an implicit default `^` comparison operator).
5277 + ///
5278 + /// - `1.0.01` &mdash; a numeric component has a leading zero.
5279 + ///
5280 + /// - `1.0.unknown` &mdash; unexpected character in one of the components.
5281 + ///
5282 + /// - `1.0.0-` or `1.0.0+` &mdash; the pre-release or build metadata are
5283 + /// indicated present but empty.
5284 + ///
5285 + /// - `1.0.0-alpha_123` &mdash; pre-release or build metadata have something
5286 + /// outside the allowed characters, which are `0-9`, `A-Z`, `a-z`, `-`,
5287 + /// and `.` (dot).
5288 + ///
5289 + /// - `23456789999999999999.0.0` &mdash; overflow of a u64.
5290 + pub fn parse(text: &str) -> Result<Self, Error> {
5291 + Version::from_str(text)
5295 +impl VersionReq {
5296 + /// A `VersionReq` with no constraint on the version numbers it matches.
5297 + /// Equivalent to `VersionReq::parse("*").unwrap()`.
5298 + ///
5299 + /// In terms of comparators this is equivalent to `>=0.0.0`.
5300 + ///
5301 + /// Counterintuitively a `*` VersionReq does not match every possible
5302 + /// version number. In particular, in order for *any* `VersionReq` to match
5303 + /// a pre-release version, the `VersionReq` must contain at least one
5304 + /// `Comparator` that has an explicit major, minor, and patch version
5305 + /// identical to the pre-release being matched, and that has a nonempty
5306 + /// pre-release component. Since `*` is not written with an explicit major,
5307 + /// minor, and patch version, and does not contain a nonempty pre-release
5308 + /// component, it does not match any pre-release versions.
5309 + #[cfg(not(no_const_vec_new))] // rustc <1.39
5310 + pub const STAR: Self = VersionReq {
5311 + comparators: Vec::new(),
5312 + };
5314 -pub use version::{Version, Identifier, SemVerError};
5315 -pub use version::Identifier::{Numeric, AlphaNumeric};
5316 -pub use version_req::{VersionReq, ReqParseError};
5317 + /// Create `VersionReq` by parsing from string representation.
5318 + ///
5319 + /// # Errors
5320 + ///
5321 + /// Possible reasons for the parse to fail include:
5322 + ///
5323 + /// - `>a.b` &mdash; unexpected characters in the partial version.
5324 + ///
5325 + /// - `@1.0.0` &mdash; unrecognized comparison operator.
5326 + ///
5327 + /// - `^1.0.0, ` &mdash; unexpected end of input.
5328 + ///
5329 + /// - `>=1.0 <2.0` &mdash; missing comma between comparators.
5330 + ///
5331 + /// - `*.*` &mdash; unsupported wildcard syntax.
5332 + pub fn parse(text: &str) -> Result<Self, Error> {
5333 + VersionReq::from_str(text)
5336 + /// Evaluate whether the given `Version` satisfies the version requirement
5337 + /// described by `self`.
5338 + pub fn matches(&self, version: &Version) -> bool {
5339 + eval::matches_req(self, version)
5343 +/// The default VersionReq is the same as [`VersionReq::STAR`].
5344 +#[cfg(not(no_const_vec_new))]
5345 +impl Default for VersionReq {
5346 + fn default() -> Self {
5347 + VersionReq::STAR
5351 +impl Comparator {
5352 + pub fn parse(text: &str) -> Result<Self, Error> {
5353 + Comparator::from_str(text)
5356 -// SemVer-compliant versions.
5357 -mod version;
5358 + pub fn matches(&self, version: &Version) -> bool {
5359 + eval::matches_comparator(self, version)
5363 +impl Prerelease {
5364 + pub const EMPTY: Self = Prerelease {
5365 + identifier: Identifier::empty(),
5366 + };
5368 + pub fn new(text: &str) -> Result<Self, Error> {
5369 + Prerelease::from_str(text)
5372 + pub fn as_str(&self) -> &str {
5373 + self.identifier.as_str()
5376 -// advanced version comparisons
5377 -mod version_req;
5378 + pub fn is_empty(&self) -> bool {
5379 + self.identifier.is_empty()
5383 +impl BuildMetadata {
5384 + pub const EMPTY: Self = BuildMetadata {
5385 + identifier: Identifier::empty(),
5386 + };
5388 + pub fn new(text: &str) -> Result<Self, Error> {
5389 + BuildMetadata::from_str(text)
5392 + pub fn as_str(&self) -> &str {
5393 + self.identifier.as_str()
5396 + pub fn is_empty(&self) -> bool {
5397 + self.identifier.is_empty()
5400 diff --git a/third_party/rust/semver/src/parse.rs b/third_party/rust/semver/src/parse.rs
5401 new file mode 100644
5402 --- /dev/null
5403 +++ b/third_party/rust/semver/src/parse.rs
5404 @@ -0,0 +1,405 @@
5405 +use crate::backport::*;
5406 +use crate::error::{ErrorKind, Position};
5407 +use crate::identifier::Identifier;
5408 +use crate::{BuildMetadata, Comparator, Op, Prerelease, Version, VersionReq};
5409 +use core::str::FromStr;
5411 +/// Error parsing a SemVer version or version requirement.
5412 +///
5413 +/// # Example
5414 +///
5415 +/// ```
5416 +/// use semver::Version;
5417 +///
5418 +/// fn main() {
5419 +/// let err = Version::parse("1.q.r").unwrap_err();
5420 +///
5421 +/// // "unexpected character 'q' while parsing minor version number"
5422 +/// eprintln!("{}", err);
5423 +/// }
5424 +/// ```
5425 +pub struct Error {
5426 + pub(crate) kind: ErrorKind,
5429 +impl FromStr for Version {
5430 + type Err = Error;
5432 + fn from_str(text: &str) -> Result<Self, Self::Err> {
5433 + let mut pos = Position::Major;
5434 + let (major, text) = numeric_identifier(text, pos)?;
5435 + let text = dot(text, pos)?;
5437 + pos = Position::Minor;
5438 + let (minor, text) = numeric_identifier(text, pos)?;
5439 + let text = dot(text, pos)?;
5441 + pos = Position::Patch;
5442 + let (patch, text) = numeric_identifier(text, pos)?;
5444 + if text.is_empty() {
5445 + return Ok(Version::new(major, minor, patch));
5448 + let (pre, text) = if let Some(text) = text.strip_prefix('-') {
5449 + pos = Position::Pre;
5450 + let (pre, text) = prerelease_identifier(text)?;
5451 + if pre.is_empty() {
5452 + return Err(Error::new(ErrorKind::EmptySegment(pos)));
5454 + (pre, text)
5455 + } else {
5456 + (Prerelease::EMPTY, text)
5457 + };
5459 + let (build, text) = if let Some(text) = text.strip_prefix('+') {
5460 + pos = Position::Build;
5461 + let (build, text) = build_identifier(text)?;
5462 + if build.is_empty() {
5463 + return Err(Error::new(ErrorKind::EmptySegment(pos)));
5465 + (build, text)
5466 + } else {
5467 + (BuildMetadata::EMPTY, text)
5468 + };
5470 + if let Some(unexpected) = text.chars().next() {
5471 + return Err(Error::new(ErrorKind::UnexpectedCharAfter(pos, unexpected)));
5474 + Ok(Version {
5475 + major,
5476 + minor,
5477 + patch,
5478 + pre,
5479 + build,
5480 + })
5484 +impl FromStr for VersionReq {
5485 + type Err = Error;
5487 + fn from_str(text: &str) -> Result<Self, Self::Err> {
5488 + let text = text.trim_start_matches(' ');
5489 + if let Some((ch, text)) = wildcard(text) {
5490 + let rest = text.trim_start_matches(' ');
5491 + if rest.is_empty() {
5492 + #[cfg(not(no_const_vec_new))]
5493 + return Ok(VersionReq::STAR);
5494 + #[cfg(no_const_vec_new)] // rustc <1.39
5495 + return Ok(VersionReq {
5496 + comparators: Vec::new(),
5497 + });
5498 + } else if rest.starts_with(',') {
5499 + return Err(Error::new(ErrorKind::WildcardNotTheOnlyComparator(ch)));
5500 + } else {
5501 + return Err(Error::new(ErrorKind::UnexpectedAfterWildcard));
5505 + let depth = 0;
5506 + let mut comparators = Vec::new();
5507 + let len = version_req(text, &mut comparators, depth)?;
5508 + unsafe { comparators.set_len(len) }
5509 + Ok(VersionReq { comparators })
5513 +impl FromStr for Comparator {
5514 + type Err = Error;
5516 + fn from_str(text: &str) -> Result<Self, Self::Err> {
5517 + let text = text.trim_start_matches(' ');
5518 + let (comparator, pos, rest) = comparator(text)?;
5519 + if !rest.is_empty() {
5520 + let unexpected = rest.chars().next().unwrap();
5521 + return Err(Error::new(ErrorKind::UnexpectedCharAfter(pos, unexpected)));
5523 + Ok(comparator)
5527 +impl FromStr for Prerelease {
5528 + type Err = Error;
5530 + fn from_str(text: &str) -> Result<Self, Self::Err> {
5531 + let (pre, rest) = prerelease_identifier(text)?;
5532 + if !rest.is_empty() {
5533 + return Err(Error::new(ErrorKind::IllegalCharacter(Position::Pre)));
5535 + Ok(pre)
5539 +impl FromStr for BuildMetadata {
5540 + type Err = Error;
5542 + fn from_str(text: &str) -> Result<Self, Self::Err> {
5543 + let (build, rest) = build_identifier(text)?;
5544 + if !rest.is_empty() {
5545 + return Err(Error::new(ErrorKind::IllegalCharacter(Position::Build)));
5547 + Ok(build)
5551 +impl Error {
5552 + fn new(kind: ErrorKind) -> Self {
5553 + Error { kind }
5557 +impl Op {
5558 + const DEFAULT: Self = Op::Caret;
5561 +fn numeric_identifier(input: &str, pos: Position) -> Result<(u64, &str), Error> {
5562 + let mut len = 0;
5563 + let mut value = 0u64;
5565 + while let Some(&digit) = input.as_bytes().get(len) {
5566 + if digit < b'0' || digit > b'9' {
5567 + break;
5569 + if value == 0 && len > 0 {
5570 + return Err(Error::new(ErrorKind::LeadingZero(pos)));
5572 + match value
5573 + .checked_mul(10)
5574 + .and_then(|value| value.checked_add((digit - b'0') as u64))
5576 + Some(sum) => value = sum,
5577 + None => return Err(Error::new(ErrorKind::Overflow(pos))),
5579 + len += 1;
5582 + if len > 0 {
5583 + Ok((value, &input[len..]))
5584 + } else if let Some(unexpected) = input[len..].chars().next() {
5585 + Err(Error::new(ErrorKind::UnexpectedChar(pos, unexpected)))
5586 + } else {
5587 + Err(Error::new(ErrorKind::UnexpectedEnd(pos)))
5591 +fn wildcard(input: &str) -> Option<(char, &str)> {
5592 + if let Some(rest) = input.strip_prefix('*') {
5593 + Some(('*', rest))
5594 + } else if let Some(rest) = input.strip_prefix('x') {
5595 + Some(('x', rest))
5596 + } else if let Some(rest) = input.strip_prefix('X') {
5597 + Some(('X', rest))
5598 + } else {
5599 + None
5603 +fn dot(input: &str, pos: Position) -> Result<&str, Error> {
5604 + if let Some(rest) = input.strip_prefix('.') {
5605 + Ok(rest)
5606 + } else if let Some(unexpected) = input.chars().next() {
5607 + Err(Error::new(ErrorKind::UnexpectedCharAfter(pos, unexpected)))
5608 + } else {
5609 + Err(Error::new(ErrorKind::UnexpectedEnd(pos)))
5613 +fn prerelease_identifier(input: &str) -> Result<(Prerelease, &str), Error> {
5614 + let (string, rest) = identifier(input, Position::Pre)?;
5615 + let identifier = unsafe { Identifier::new_unchecked(string) };
5616 + Ok((Prerelease { identifier }, rest))
5619 +fn build_identifier(input: &str) -> Result<(BuildMetadata, &str), Error> {
5620 + let (string, rest) = identifier(input, Position::Build)?;
5621 + let identifier = unsafe { Identifier::new_unchecked(string) };
5622 + Ok((BuildMetadata { identifier }, rest))
5625 +fn identifier(input: &str, pos: Position) -> Result<(&str, &str), Error> {
5626 + let mut accumulated_len = 0;
5627 + let mut segment_len = 0;
5628 + let mut segment_has_nondigit = false;
5630 + loop {
5631 + match input.as_bytes().get(accumulated_len + segment_len) {
5632 + Some(b'A'..=b'Z') | Some(b'a'..=b'z') | Some(b'-') => {
5633 + segment_len += 1;
5634 + segment_has_nondigit = true;
5636 + Some(b'0'..=b'9') => {
5637 + segment_len += 1;
5639 + boundary => {
5640 + if segment_len == 0 {
5641 + if accumulated_len == 0 && boundary != Some(&b'.') {
5642 + return Ok(("", input));
5643 + } else {
5644 + return Err(Error::new(ErrorKind::EmptySegment(pos)));
5647 + if pos == Position::Pre
5648 + && segment_len > 1
5649 + && !segment_has_nondigit
5650 + && input[accumulated_len..].starts_with('0')
5652 + return Err(Error::new(ErrorKind::LeadingZero(pos)));
5654 + accumulated_len += segment_len;
5655 + if boundary == Some(&b'.') {
5656 + accumulated_len += 1;
5657 + segment_len = 0;
5658 + segment_has_nondigit = false;
5659 + } else {
5660 + return Ok(input.split_at(accumulated_len));
5667 +fn op(input: &str) -> (Op, &str) {
5668 + let bytes = input.as_bytes();
5669 + if bytes.get(0) == Some(&b'=') {
5670 + (Op::Exact, &input[1..])
5671 + } else if bytes.get(0) == Some(&b'>') {
5672 + if bytes.get(1) == Some(&b'=') {
5673 + (Op::GreaterEq, &input[2..])
5674 + } else {
5675 + (Op::Greater, &input[1..])
5677 + } else if bytes.get(0) == Some(&b'<') {
5678 + if bytes.get(1) == Some(&b'=') {
5679 + (Op::LessEq, &input[2..])
5680 + } else {
5681 + (Op::Less, &input[1..])
5683 + } else if bytes.get(0) == Some(&b'~') {
5684 + (Op::Tilde, &input[1..])
5685 + } else if bytes.get(0) == Some(&b'^') {
5686 + (Op::Caret, &input[1..])
5687 + } else {
5688 + (Op::DEFAULT, input)
5692 +fn comparator(input: &str) -> Result<(Comparator, Position, &str), Error> {
5693 + let (mut op, text) = op(input);
5694 + let default_op = input.len() == text.len();
5695 + let text = text.trim_start_matches(' ');
5697 + let mut pos = Position::Major;
5698 + let (major, text) = numeric_identifier(text, pos)?;
5699 + let mut has_wildcard = false;
5701 + let (minor, text) = if let Some(text) = text.strip_prefix('.') {
5702 + pos = Position::Minor;
5703 + if let Some((_, text)) = wildcard(text) {
5704 + has_wildcard = true;
5705 + if default_op {
5706 + op = Op::Wildcard;
5708 + (None, text)
5709 + } else {
5710 + let (minor, text) = numeric_identifier(text, pos)?;
5711 + (Some(minor), text)
5713 + } else {
5714 + (None, text)
5715 + };
5717 + let (patch, text) = if let Some(text) = text.strip_prefix('.') {
5718 + pos = Position::Patch;
5719 + if let Some((_, text)) = wildcard(text) {
5720 + if default_op {
5721 + op = Op::Wildcard;
5723 + (None, text)
5724 + } else if has_wildcard {
5725 + return Err(Error::new(ErrorKind::UnexpectedAfterWildcard));
5726 + } else {
5727 + let (patch, text) = numeric_identifier(text, pos)?;
5728 + (Some(patch), text)
5730 + } else {
5731 + (None, text)
5732 + };
5734 + let (pre, text) = if patch.is_some() && text.starts_with('-') {
5735 + pos = Position::Pre;
5736 + let text = &text[1..];
5737 + let (pre, text) = prerelease_identifier(text)?;
5738 + if pre.is_empty() {
5739 + return Err(Error::new(ErrorKind::EmptySegment(pos)));
5741 + (pre, text)
5742 + } else {
5743 + (Prerelease::EMPTY, text)
5744 + };
5746 + let text = if patch.is_some() && text.starts_with('+') {
5747 + pos = Position::Build;
5748 + let text = &text[1..];
5749 + let (build, text) = build_identifier(text)?;
5750 + if build.is_empty() {
5751 + return Err(Error::new(ErrorKind::EmptySegment(pos)));
5753 + text
5754 + } else {
5755 + text
5756 + };
5758 + let text = text.trim_start_matches(' ');
5760 + let comparator = Comparator {
5761 + op,
5762 + major,
5763 + minor,
5764 + patch,
5765 + pre,
5766 + };
5768 + Ok((comparator, pos, text))
5771 +fn version_req(input: &str, out: &mut Vec<Comparator>, depth: usize) -> Result<usize, Error> {
5772 + let (comparator, pos, text) = match comparator(input) {
5773 + Ok(success) => success,
5774 + Err(mut error) => {
5775 + if let Some((ch, mut rest)) = wildcard(input) {
5776 + rest = rest.trim_start_matches(' ');
5777 + if rest.is_empty() || rest.starts_with(',') {
5778 + error.kind = ErrorKind::WildcardNotTheOnlyComparator(ch);
5781 + return Err(error);
5783 + };
5785 + if text.is_empty() {
5786 + out.reserve_exact(depth + 1);
5787 + unsafe { out.as_mut_ptr().add(depth).write(comparator) }
5788 + return Ok(depth + 1);
5791 + let text = if let Some(text) = text.strip_prefix(',') {
5792 + text.trim_start_matches(' ')
5793 + } else {
5794 + let unexpected = text.chars().next().unwrap();
5795 + return Err(Error::new(ErrorKind::ExpectedCommaFound(pos, unexpected)));
5796 + };
5798 + const MAX_COMPARATORS: usize = 32;
5799 + if depth + 1 == MAX_COMPARATORS {
5800 + return Err(Error::new(ErrorKind::ExcessiveComparators));
5803 + // Recurse to collect parsed Comparator objects on the stack. We perform a
5804 + // single allocation to allocate exactly the right sized Vec only once the
5805 + // total number of comparators is known.
5806 + let len = version_req(text, out, depth + 1)?;
5807 + unsafe { out.as_mut_ptr().add(depth).write(comparator) }
5808 + Ok(len)
5810 diff --git a/third_party/rust/semver/src/serde.rs b/third_party/rust/semver/src/serde.rs
5811 new file mode 100644
5812 --- /dev/null
5813 +++ b/third_party/rust/semver/src/serde.rs
5814 @@ -0,0 +1,74 @@
5815 +use crate::{Version, VersionReq};
5816 +use core::fmt;
5817 +use serde::de::{Deserialize, Deserializer, Error, Visitor};
5818 +use serde::ser::{Serialize, Serializer};
5820 +impl Serialize for Version {
5821 + fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
5822 + where
5823 + S: Serializer,
5825 + serializer.collect_str(self)
5829 +impl Serialize for VersionReq {
5830 + fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
5831 + where
5832 + S: Serializer,
5834 + serializer.collect_str(self)
5838 +impl<'de> Deserialize<'de> for Version {
5839 + fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
5840 + where
5841 + D: Deserializer<'de>,
5843 + struct VersionVisitor;
5845 + impl<'de> Visitor<'de> for VersionVisitor {
5846 + type Value = Version;
5848 + fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
5849 + formatter.write_str("semver version")
5852 + fn visit_str<E>(self, string: &str) -> Result<Self::Value, E>
5853 + where
5854 + E: Error,
5856 + string.parse().map_err(Error::custom)
5860 + deserializer.deserialize_str(VersionVisitor)
5864 +impl<'de> Deserialize<'de> for VersionReq {
5865 + fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
5866 + where
5867 + D: Deserializer<'de>,
5869 + struct VersionReqVisitor;
5871 + impl<'de> Visitor<'de> for VersionReqVisitor {
5872 + type Value = VersionReq;
5874 + fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
5875 + formatter.write_str("semver version")
5878 + fn visit_str<E>(self, string: &str) -> Result<Self::Value, E>
5879 + where
5880 + E: Error,
5882 + string.parse().map_err(Error::custom)
5886 + deserializer.deserialize_str(VersionReqVisitor)
5889 diff --git a/third_party/rust/semver/src/version.rs b/third_party/rust/semver/src/version.rs
5890 deleted file mode 100644
5891 --- a/third_party/rust/semver/src/version.rs
5892 +++ /dev/null
5893 @@ -1,759 +0,0 @@
5894 -// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
5895 -// file at the top-level directory of this distribution and at
5896 -// http://rust-lang.org/COPYRIGHT.
5898 -// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
5899 -// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
5900 -// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
5901 -// option. This file may not be copied, modified, or distributed
5902 -// except according to those terms.
5904 -//! The `version` module gives you tools to create and compare SemVer-compliant
5905 -//! versions.
5907 -use std::cmp::{self, Ordering};
5908 -use std::fmt;
5909 -use std::hash;
5910 -use std::error::Error;
5912 -use std::result;
5913 -use std::str;
5915 -use semver_parser;
5917 -#[cfg(feature = "serde")]
5918 -use serde::ser::{Serialize, Serializer};
5919 -#[cfg(feature = "serde")]
5920 -use serde::de::{self, Deserialize, Deserializer, Visitor};
5922 -/// An identifier in the pre-release or build metadata.
5923 -///
5924 -/// See sections 9 and 10 of the spec for more about pre-release identifers and
5925 -/// build metadata.
5926 -#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
5927 -pub enum Identifier {
5928 - /// An identifier that's solely numbers.
5929 - Numeric(u64),
5930 - /// An identifier with letters and numbers.
5931 - AlphaNumeric(String),
5934 -impl From<semver_parser::version::Identifier> for Identifier {
5935 - fn from(other: semver_parser::version::Identifier) -> Identifier {
5936 - match other {
5937 - semver_parser::version::Identifier::Numeric(n) => Identifier::Numeric(n),
5938 - semver_parser::version::Identifier::AlphaNumeric(s) => Identifier::AlphaNumeric(s),
5943 -impl fmt::Display for Identifier {
5944 - #[inline]
5945 - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
5946 - match *self {
5947 - Identifier::Numeric(ref n) => fmt::Display::fmt(n, f),
5948 - Identifier::AlphaNumeric(ref s) => fmt::Display::fmt(s, f),
5953 -#[cfg(feature = "serde")]
5954 -impl Serialize for Identifier {
5955 - fn serialize<S>(&self, serializer: S) -> result::Result<S::Ok, S::Error>
5956 - where S: Serializer
5958 - // Serialize Identifier as a number or string.
5959 - match *self {
5960 - Identifier::Numeric(n) => serializer.serialize_u64(n),
5961 - Identifier::AlphaNumeric(ref s) => serializer.serialize_str(s),
5966 -#[cfg(feature = "serde")]
5967 -impl<'de> Deserialize<'de> for Identifier {
5968 - fn deserialize<D>(deserializer: D) -> result::Result<Self, D::Error>
5969 - where D: Deserializer<'de>
5971 - struct IdentifierVisitor;
5973 - // Deserialize Identifier from a number or string.
5974 - impl<'de> Visitor<'de> for IdentifierVisitor {
5975 - type Value = Identifier;
5977 - fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
5978 - formatter.write_str("a SemVer pre-release or build identifier")
5981 - fn visit_u64<E>(self, numeric: u64) -> result::Result<Self::Value, E>
5982 - where E: de::Error
5984 - Ok(Identifier::Numeric(numeric))
5987 - fn visit_str<E>(self, alphanumeric: &str) -> result::Result<Self::Value, E>
5988 - where E: de::Error
5990 - Ok(Identifier::AlphaNumeric(alphanumeric.to_owned()))
5994 - deserializer.deserialize_any(IdentifierVisitor)
5998 -/// Represents a version number conforming to the semantic versioning scheme.
5999 -#[derive(Clone, Eq, Debug)]
6000 -pub struct Version {
6001 - /// The major version, to be incremented on incompatible changes.
6002 - pub major: u64,
6003 - /// The minor version, to be incremented when functionality is added in a
6004 - /// backwards-compatible manner.
6005 - pub minor: u64,
6006 - /// The patch version, to be incremented when backwards-compatible bug
6007 - /// fixes are made.
6008 - pub patch: u64,
6009 - /// The pre-release version identifier, if one exists.
6010 - pub pre: Vec<Identifier>,
6011 - /// The build metadata, ignored when determining version precedence.
6012 - pub build: Vec<Identifier>,
6015 -impl From<semver_parser::version::Version> for Version {
6016 - fn from(other: semver_parser::version::Version) -> Version {
6017 - Version {
6018 - major: other.major,
6019 - minor: other.minor,
6020 - patch: other.patch,
6021 - pre: other.pre.into_iter().map(From::from).collect(),
6022 - build: other.build.into_iter().map(From::from).collect(),
6027 -#[cfg(feature = "serde")]
6028 -impl Serialize for Version {
6029 - fn serialize<S>(&self, serializer: S) -> result::Result<S::Ok, S::Error>
6030 - where S: Serializer
6032 - // Serialize Version as a string.
6033 - serializer.collect_str(self)
6037 -#[cfg(feature = "serde")]
6038 -impl<'de> Deserialize<'de> for Version {
6039 - fn deserialize<D>(deserializer: D) -> result::Result<Self, D::Error>
6040 - where D: Deserializer<'de>
6042 - struct VersionVisitor;
6044 - // Deserialize Version from a string.
6045 - impl<'de> Visitor<'de> for VersionVisitor {
6046 - type Value = Version;
6048 - fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
6049 - formatter.write_str("a SemVer version as a string")
6052 - fn visit_str<E>(self, v: &str) -> result::Result<Self::Value, E>
6053 - where E: de::Error
6055 - Version::parse(v).map_err(de::Error::custom)
6059 - deserializer.deserialize_str(VersionVisitor)
6063 -/// An error type for this crate
6064 -///
6065 -/// Currently, just a generic error. Will make this nicer later.
6066 -#[derive(Clone,PartialEq,Debug,PartialOrd)]
6067 -pub enum SemVerError {
6068 - /// An error ocurred while parsing.
6069 - ParseError(String),
6072 -impl fmt::Display for SemVerError {
6073 - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
6074 - match self {
6075 - &SemVerError::ParseError(ref m) => write!(f, "{}", m),
6080 -impl Error for SemVerError {
6081 - fn description(&self) -> &str {
6082 - match self {
6083 - &SemVerError::ParseError(ref m) => m,
6088 -/// A Result type for errors
6089 -pub type Result<T> = result::Result<T, SemVerError>;
6091 -impl Version {
6093 - /// Contructs the simple case without pre or build.
6094 - pub fn new(major: u64, minor: u64, patch: u64) -> Version {
6095 - Version {
6096 - major: major,
6097 - minor: minor,
6098 - patch: patch,
6099 - pre: Vec::new(),
6100 - build: Vec::new()
6104 - /// Parse a string into a semver object.
6105 - pub fn parse(version: &str) -> Result<Version> {
6106 - let res = semver_parser::version::parse(version);
6108 - match res {
6109 - // Convert plain String error into proper ParseError
6110 - Err(e) => Err(SemVerError::ParseError(e)),
6111 - Ok(v) => Ok(From::from(v)),
6115 - /// Clears the build metadata
6116 - fn clear_metadata(&mut self) {
6117 - self.build = Vec::new();
6118 - self.pre = Vec::new();
6121 - /// Increments the patch number for this Version (Must be mutable)
6122 - pub fn increment_patch(&mut self) {
6123 - self.patch += 1;
6124 - self.clear_metadata();
6127 - /// Increments the minor version number for this Version (Must be mutable)
6128 - ///
6129 - /// As instructed by section 7 of the spec, the patch number is reset to 0.
6130 - pub fn increment_minor(&mut self) {
6131 - self.minor += 1;
6132 - self.patch = 0;
6133 - self.clear_metadata();
6136 - /// Increments the major version number for this Version (Must be mutable)
6137 - ///
6138 - /// As instructed by section 8 of the spec, the minor and patch numbers are
6139 - /// reset to 0
6140 - pub fn increment_major(&mut self) {
6141 - self.major += 1;
6142 - self.minor = 0;
6143 - self.patch = 0;
6144 - self.clear_metadata();
6147 - /// Checks to see if the current Version is in pre-release status
6148 - pub fn is_prerelease(&self) -> bool {
6149 - !self.pre.is_empty()
6153 -impl str::FromStr for Version {
6154 - type Err = SemVerError;
6156 - fn from_str(s: &str) -> Result<Version> {
6157 - Version::parse(s)
6161 -impl fmt::Display for Version {
6162 - #[inline]
6163 - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
6164 - try!(write!(f, "{}.{}.{}", self.major, self.minor, self.patch));
6165 - if !self.pre.is_empty() {
6166 - try!(write!(f, "-"));
6167 - for (i, x) in self.pre.iter().enumerate() {
6168 - if i != 0 {
6169 - try!(write!(f, "."))
6171 - try!(write!(f, "{}", x));
6174 - if !self.build.is_empty() {
6175 - try!(write!(f, "+"));
6176 - for (i, x) in self.build.iter().enumerate() {
6177 - if i != 0 {
6178 - try!(write!(f, "."))
6180 - try!(write!(f, "{}", x));
6183 - Ok(())
6187 -impl cmp::PartialEq for Version {
6188 - #[inline]
6189 - fn eq(&self, other: &Version) -> bool {
6190 - // We should ignore build metadata here, otherwise versions v1 and v2
6191 - // can exist such that !(v1 < v2) && !(v1 > v2) && v1 != v2, which
6192 - // violate strict total ordering rules.
6193 - self.major == other.major && self.minor == other.minor && self.patch == other.patch &&
6194 - self.pre == other.pre
6198 -impl cmp::PartialOrd for Version {
6199 - fn partial_cmp(&self, other: &Version) -> Option<Ordering> {
6200 - Some(self.cmp(other))
6204 -impl cmp::Ord for Version {
6205 - fn cmp(&self, other: &Version) -> Ordering {
6206 - match self.major.cmp(&other.major) {
6207 - Ordering::Equal => {}
6208 - r => return r,
6211 - match self.minor.cmp(&other.minor) {
6212 - Ordering::Equal => {}
6213 - r => return r,
6216 - match self.patch.cmp(&other.patch) {
6217 - Ordering::Equal => {}
6218 - r => return r,
6221 - // NB: semver spec says 0.0.0-pre < 0.0.0
6222 - // but the version of ord defined for vec
6223 - // says that [] < [pre] so we alter it here
6224 - match (self.pre.len(), other.pre.len()) {
6225 - (0, 0) => Ordering::Equal,
6226 - (0, _) => Ordering::Greater,
6227 - (_, 0) => Ordering::Less,
6228 - (_, _) => self.pre.cmp(&other.pre),
6233 -impl hash::Hash for Version {
6234 - fn hash<H: hash::Hasher>(&self, into: &mut H) {
6235 - self.major.hash(into);
6236 - self.minor.hash(into);
6237 - self.patch.hash(into);
6238 - self.pre.hash(into);
6242 -impl From<(u64,u64,u64)> for Version {
6243 - fn from(tuple: (u64,u64,u64)) -> Version {
6244 - let (major, minor, patch) = tuple;
6245 - Version::new(major, minor, patch)
6249 -#[cfg(test)]
6250 -mod tests {
6251 - use std::result;
6252 - use super::Version;
6253 - use super::Identifier;
6254 - use super::SemVerError;
6256 - #[test]
6257 - fn test_parse() {
6258 - fn parse_error(e: &str) -> result::Result<Version, SemVerError> {
6259 - return Err(SemVerError::ParseError(e.to_string()));
6262 - assert_eq!(Version::parse(""),
6263 - parse_error("Error parsing major identifier"));
6264 - assert_eq!(Version::parse(" "),
6265 - parse_error("Error parsing major identifier"));
6266 - assert_eq!(Version::parse("1"),
6267 - parse_error("Expected dot"));
6268 - assert_eq!(Version::parse("1.2"),
6269 - parse_error("Expected dot"));
6270 - assert_eq!(Version::parse("1.2.3-"),
6271 - parse_error("Error parsing prerelease"));
6272 - assert_eq!(Version::parse("a.b.c"),
6273 - parse_error("Error parsing major identifier"));
6274 - assert_eq!(Version::parse("1.2.3 abc"),
6275 - parse_error("Extra junk after valid version: abc"));
6277 - assert_eq!(Version::parse("1.2.3"),
6278 - Ok(Version {
6279 - major: 1,
6280 - minor: 2,
6281 - patch: 3,
6282 - pre: Vec::new(),
6283 - build: Vec::new(),
6284 - }));
6286 - assert_eq!(Version::parse("1.2.3"),
6287 - Ok(Version::new(1,2,3)));
6289 - assert_eq!(Version::parse(" 1.2.3 "),
6290 - Ok(Version {
6291 - major: 1,
6292 - minor: 2,
6293 - patch: 3,
6294 - pre: Vec::new(),
6295 - build: Vec::new(),
6296 - }));
6297 - assert_eq!(Version::parse("1.2.3-alpha1"),
6298 - Ok(Version {
6299 - major: 1,
6300 - minor: 2,
6301 - patch: 3,
6302 - pre: vec![Identifier::AlphaNumeric(String::from("alpha1"))],
6303 - build: Vec::new(),
6304 - }));
6305 - assert_eq!(Version::parse(" 1.2.3-alpha1 "),
6306 - Ok(Version {
6307 - major: 1,
6308 - minor: 2,
6309 - patch: 3,
6310 - pre: vec![Identifier::AlphaNumeric(String::from("alpha1"))],
6311 - build: Vec::new(),
6312 - }));
6313 - assert_eq!(Version::parse("1.2.3+build5"),
6314 - Ok(Version {
6315 - major: 1,
6316 - minor: 2,
6317 - patch: 3,
6318 - pre: Vec::new(),
6319 - build: vec![Identifier::AlphaNumeric(String::from("build5"))],
6320 - }));
6321 - assert_eq!(Version::parse(" 1.2.3+build5 "),
6322 - Ok(Version {
6323 - major: 1,
6324 - minor: 2,
6325 - patch: 3,
6326 - pre: Vec::new(),
6327 - build: vec![Identifier::AlphaNumeric(String::from("build5"))],
6328 - }));
6329 - assert_eq!(Version::parse("1.2.3-alpha1+build5"),
6330 - Ok(Version {
6331 - major: 1,
6332 - minor: 2,
6333 - patch: 3,
6334 - pre: vec![Identifier::AlphaNumeric(String::from("alpha1"))],
6335 - build: vec![Identifier::AlphaNumeric(String::from("build5"))],
6336 - }));
6337 - assert_eq!(Version::parse(" 1.2.3-alpha1+build5 "),
6338 - Ok(Version {
6339 - major: 1,
6340 - minor: 2,
6341 - patch: 3,
6342 - pre: vec![Identifier::AlphaNumeric(String::from("alpha1"))],
6343 - build: vec![Identifier::AlphaNumeric(String::from("build5"))],
6344 - }));
6345 - assert_eq!(Version::parse("1.2.3-1.alpha1.9+build5.7.3aedf "),
6346 - Ok(Version {
6347 - major: 1,
6348 - minor: 2,
6349 - patch: 3,
6350 - pre: vec![Identifier::Numeric(1),
6351 - Identifier::AlphaNumeric(String::from("alpha1")),
6352 - Identifier::Numeric(9),
6353 - ],
6354 - build: vec![Identifier::AlphaNumeric(String::from("build5")),
6355 - Identifier::Numeric(7),
6356 - Identifier::AlphaNumeric(String::from("3aedf")),
6357 - ],
6358 - }));
6359 - assert_eq!(Version::parse("0.4.0-beta.1+0851523"),
6360 - Ok(Version {
6361 - major: 0,
6362 - minor: 4,
6363 - patch: 0,
6364 - pre: vec![Identifier::AlphaNumeric(String::from("beta")),
6365 - Identifier::Numeric(1),
6366 - ],
6367 - build: vec![Identifier::AlphaNumeric(String::from("0851523"))],
6368 - }));
6372 - #[test]
6373 - fn test_increment_patch() {
6374 - let mut buggy_release = Version::parse("0.1.0").unwrap();
6375 - buggy_release.increment_patch();
6376 - assert_eq!(buggy_release, Version::parse("0.1.1").unwrap());
6379 - #[test]
6380 - fn test_increment_minor() {
6381 - let mut feature_release = Version::parse("1.4.6").unwrap();
6382 - feature_release.increment_minor();
6383 - assert_eq!(feature_release, Version::parse("1.5.0").unwrap());
6386 - #[test]
6387 - fn test_increment_major() {
6388 - let mut chrome_release = Version::parse("46.1.246773").unwrap();
6389 - chrome_release.increment_major();
6390 - assert_eq!(chrome_release, Version::parse("47.0.0").unwrap());
6393 - #[test]
6394 - fn test_increment_keep_prerelease() {
6395 - let mut release = Version::parse("1.0.0-alpha").unwrap();
6396 - release.increment_patch();
6398 - assert_eq!(release, Version::parse("1.0.1").unwrap());
6400 - release.increment_minor();
6402 - assert_eq!(release, Version::parse("1.1.0").unwrap());
6404 - release.increment_major();
6406 - assert_eq!(release, Version::parse("2.0.0").unwrap());
6410 - #[test]
6411 - fn test_increment_clear_metadata() {
6412 - let mut release = Version::parse("1.0.0+4442").unwrap();
6413 - release.increment_patch();
6415 - assert_eq!(release, Version::parse("1.0.1").unwrap());
6416 - release = Version::parse("1.0.1+hello").unwrap();
6418 - release.increment_minor();
6420 - assert_eq!(release, Version::parse("1.1.0").unwrap());
6421 - release = Version::parse("1.1.3747+hello").unwrap();
6423 - release.increment_major();
6425 - assert_eq!(release, Version::parse("2.0.0").unwrap());
6428 - #[test]
6429 - fn test_eq() {
6430 - assert_eq!(Version::parse("1.2.3"), Version::parse("1.2.3"));
6431 - assert_eq!(Version::parse("1.2.3-alpha1"),
6432 - Version::parse("1.2.3-alpha1"));
6433 - assert_eq!(Version::parse("1.2.3+build.42"),
6434 - Version::parse("1.2.3+build.42"));
6435 - assert_eq!(Version::parse("1.2.3-alpha1+42"),
6436 - Version::parse("1.2.3-alpha1+42"));
6437 - assert_eq!(Version::parse("1.2.3+23"), Version::parse("1.2.3+42"));
6440 - #[test]
6441 - fn test_ne() {
6442 - assert!(Version::parse("0.0.0") != Version::parse("0.0.1"));
6443 - assert!(Version::parse("0.0.0") != Version::parse("0.1.0"));
6444 - assert!(Version::parse("0.0.0") != Version::parse("1.0.0"));
6445 - assert!(Version::parse("1.2.3-alpha") != Version::parse("1.2.3-beta"));
6448 - #[test]
6449 - fn test_show() {
6450 - assert_eq!(format!("{}", Version::parse("1.2.3").unwrap()),
6451 - "1.2.3".to_string());
6452 - assert_eq!(format!("{}", Version::parse("1.2.3-alpha1").unwrap()),
6453 - "1.2.3-alpha1".to_string());
6454 - assert_eq!(format!("{}", Version::parse("1.2.3+build.42").unwrap()),
6455 - "1.2.3+build.42".to_string());
6456 - assert_eq!(format!("{}", Version::parse("1.2.3-alpha1+42").unwrap()),
6457 - "1.2.3-alpha1+42".to_string());
6460 - #[test]
6461 - fn test_to_string() {
6462 - assert_eq!(Version::parse("1.2.3").unwrap().to_string(),
6463 - "1.2.3".to_string());
6464 - assert_eq!(Version::parse("1.2.3-alpha1").unwrap().to_string(),
6465 - "1.2.3-alpha1".to_string());
6466 - assert_eq!(Version::parse("1.2.3+build.42").unwrap().to_string(),
6467 - "1.2.3+build.42".to_string());
6468 - assert_eq!(Version::parse("1.2.3-alpha1+42").unwrap().to_string(),
6469 - "1.2.3-alpha1+42".to_string());
6472 - #[test]
6473 - fn test_lt() {
6474 - assert!(Version::parse("0.0.0") < Version::parse("1.2.3-alpha2"));
6475 - assert!(Version::parse("1.0.0") < Version::parse("1.2.3-alpha2"));
6476 - assert!(Version::parse("1.2.0") < Version::parse("1.2.3-alpha2"));
6477 - assert!(Version::parse("1.2.3-alpha1") < Version::parse("1.2.3"));
6478 - assert!(Version::parse("1.2.3-alpha1") < Version::parse("1.2.3-alpha2"));
6479 - assert!(!(Version::parse("1.2.3-alpha2") < Version::parse("1.2.3-alpha2")));
6480 - assert!(!(Version::parse("1.2.3+23") < Version::parse("1.2.3+42")));
6483 - #[test]
6484 - fn test_le() {
6485 - assert!(Version::parse("0.0.0") <= Version::parse("1.2.3-alpha2"));
6486 - assert!(Version::parse("1.0.0") <= Version::parse("1.2.3-alpha2"));
6487 - assert!(Version::parse("1.2.0") <= Version::parse("1.2.3-alpha2"));
6488 - assert!(Version::parse("1.2.3-alpha1") <= Version::parse("1.2.3-alpha2"));
6489 - assert!(Version::parse("1.2.3-alpha2") <= Version::parse("1.2.3-alpha2"));
6490 - assert!(Version::parse("1.2.3+23") <= Version::parse("1.2.3+42"));
6493 - #[test]
6494 - fn test_gt() {
6495 - assert!(Version::parse("1.2.3-alpha2") > Version::parse("0.0.0"));
6496 - assert!(Version::parse("1.2.3-alpha2") > Version::parse("1.0.0"));
6497 - assert!(Version::parse("1.2.3-alpha2") > Version::parse("1.2.0"));
6498 - assert!(Version::parse("1.2.3-alpha2") > Version::parse("1.2.3-alpha1"));
6499 - assert!(Version::parse("1.2.3") > Version::parse("1.2.3-alpha2"));
6500 - assert!(!(Version::parse("1.2.3-alpha2") > Version::parse("1.2.3-alpha2")));
6501 - assert!(!(Version::parse("1.2.3+23") > Version::parse("1.2.3+42")));
6504 - #[test]
6505 - fn test_ge() {
6506 - assert!(Version::parse("1.2.3-alpha2") >= Version::parse("0.0.0"));
6507 - assert!(Version::parse("1.2.3-alpha2") >= Version::parse("1.0.0"));
6508 - assert!(Version::parse("1.2.3-alpha2") >= Version::parse("1.2.0"));
6509 - assert!(Version::parse("1.2.3-alpha2") >= Version::parse("1.2.3-alpha1"));
6510 - assert!(Version::parse("1.2.3-alpha2") >= Version::parse("1.2.3-alpha2"));
6511 - assert!(Version::parse("1.2.3+23") >= Version::parse("1.2.3+42"));
6514 - #[test]
6515 - fn test_prerelease_check() {
6516 - assert!(Version::parse("1.0.0").unwrap().is_prerelease() == false);
6517 - assert!(Version::parse("0.0.1").unwrap().is_prerelease() == false);
6518 - assert!(Version::parse("4.1.4-alpha").unwrap().is_prerelease());
6519 - assert!(Version::parse("1.0.0-beta294296").unwrap().is_prerelease());
6522 - #[test]
6523 - fn test_spec_order() {
6524 - let vs = ["1.0.0-alpha",
6525 - "1.0.0-alpha.1",
6526 - "1.0.0-alpha.beta",
6527 - "1.0.0-beta",
6528 - "1.0.0-beta.2",
6529 - "1.0.0-beta.11",
6530 - "1.0.0-rc.1",
6531 - "1.0.0"];
6532 - let mut i = 1;
6533 - while i < vs.len() {
6534 - let a = Version::parse(vs[i - 1]);
6535 - let b = Version::parse(vs[i]);
6536 - assert!(a < b, "nope {:?} < {:?}", a, b);
6537 - i += 1;
6541 - #[test]
6542 - fn test_from_str() {
6543 - assert_eq!("1.2.3".parse(),
6544 - Ok(Version {
6545 - major: 1,
6546 - minor: 2,
6547 - patch: 3,
6548 - pre: Vec::new(),
6549 - build: Vec::new(),
6550 - }));
6551 - assert_eq!(" 1.2.3 ".parse(),
6552 - Ok(Version {
6553 - major: 1,
6554 - minor: 2,
6555 - patch: 3,
6556 - pre: Vec::new(),
6557 - build: Vec::new(),
6558 - }));
6559 - assert_eq!("1.2.3-alpha1".parse(),
6560 - Ok(Version {
6561 - major: 1,
6562 - minor: 2,
6563 - patch: 3,
6564 - pre: vec![Identifier::AlphaNumeric(String::from("alpha1"))],
6565 - build: Vec::new(),
6566 - }));
6567 - assert_eq!(" 1.2.3-alpha1 ".parse(),
6568 - Ok(Version {
6569 - major: 1,
6570 - minor: 2,
6571 - patch: 3,
6572 - pre: vec![Identifier::AlphaNumeric(String::from("alpha1"))],
6573 - build: Vec::new(),
6574 - }));
6575 - assert_eq!("1.2.3+build5".parse(),
6576 - Ok(Version {
6577 - major: 1,
6578 - minor: 2,
6579 - patch: 3,
6580 - pre: Vec::new(),
6581 - build: vec![Identifier::AlphaNumeric(String::from("build5"))],
6582 - }));
6583 - assert_eq!(" 1.2.3+build5 ".parse(),
6584 - Ok(Version {
6585 - major: 1,
6586 - minor: 2,
6587 - patch: 3,
6588 - pre: Vec::new(),
6589 - build: vec![Identifier::AlphaNumeric(String::from("build5"))],
6590 - }));
6591 - assert_eq!("1.2.3-alpha1+build5".parse(),
6592 - Ok(Version {
6593 - major: 1,
6594 - minor: 2,
6595 - patch: 3,
6596 - pre: vec![Identifier::AlphaNumeric(String::from("alpha1"))],
6597 - build: vec![Identifier::AlphaNumeric(String::from("build5"))],
6598 - }));
6599 - assert_eq!(" 1.2.3-alpha1+build5 ".parse(),
6600 - Ok(Version {
6601 - major: 1,
6602 - minor: 2,
6603 - patch: 3,
6604 - pre: vec![Identifier::AlphaNumeric(String::from("alpha1"))],
6605 - build: vec![Identifier::AlphaNumeric(String::from("build5"))],
6606 - }));
6607 - assert_eq!("1.2.3-1.alpha1.9+build5.7.3aedf ".parse(),
6608 - Ok(Version {
6609 - major: 1,
6610 - minor: 2,
6611 - patch: 3,
6612 - pre: vec![Identifier::Numeric(1),
6613 - Identifier::AlphaNumeric(String::from("alpha1")),
6614 - Identifier::Numeric(9),
6615 - ],
6616 - build: vec![Identifier::AlphaNumeric(String::from("build5")),
6617 - Identifier::Numeric(7),
6618 - Identifier::AlphaNumeric(String::from("3aedf")),
6619 - ],
6620 - }));
6621 - assert_eq!("0.4.0-beta.1+0851523".parse(),
6622 - Ok(Version {
6623 - major: 0,
6624 - minor: 4,
6625 - patch: 0,
6626 - pre: vec![Identifier::AlphaNumeric(String::from("beta")),
6627 - Identifier::Numeric(1),
6628 - ],
6629 - build: vec![Identifier::AlphaNumeric(String::from("0851523"))],
6630 - }));
6634 - #[test]
6635 - fn test_from_str_errors() {
6636 - fn parse_error(e: &str) -> result::Result<Version, SemVerError> {
6637 - return Err(SemVerError::ParseError(e.to_string()));
6640 - assert_eq!("".parse(), parse_error("Error parsing major identifier"));
6641 - assert_eq!(" ".parse(), parse_error("Error parsing major identifier"));
6642 - assert_eq!("1".parse(), parse_error("Expected dot"));
6643 - assert_eq!("1.2".parse(),
6644 - parse_error("Expected dot"));
6645 - assert_eq!("1.2.3-".parse(),
6646 - parse_error("Error parsing prerelease"));
6647 - assert_eq!("a.b.c".parse(),
6648 - parse_error("Error parsing major identifier"));
6649 - assert_eq!("1.2.3 abc".parse(),
6650 - parse_error("Extra junk after valid version: abc"));
6653 diff --git a/third_party/rust/semver/src/version_req.rs b/third_party/rust/semver/src/version_req.rs
6654 deleted file mode 100644
6655 --- a/third_party/rust/semver/src/version_req.rs
6656 +++ /dev/null
6657 @@ -1,895 +0,0 @@
6658 -// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
6659 -// file at the top-level directory of this distribution and at
6660 -// http://rust-lang.org/COPYRIGHT.
6662 -// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6663 -// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
6664 -// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
6665 -// option. This file may not be copied, modified, or distributed
6666 -// except according to those terms.
6668 -use std::error::Error;
6669 -use std::fmt;
6670 -use std::result;
6671 -use std::str;
6673 -use Version;
6674 -use version::Identifier;
6675 -use semver_parser;
6677 -#[cfg(feature = "serde")]
6678 -use serde::ser::{Serialize, Serializer};
6679 -#[cfg(feature = "serde")]
6680 -use serde::de::{self, Deserialize, Deserializer, Visitor};
6682 -use self::Op::{Ex, Gt, GtEq, Lt, LtEq, Tilde, Compatible, Wildcard};
6683 -use self::WildcardVersion::{Major, Minor, Patch};
6684 -use self::ReqParseError::*;
6686 -/// A `VersionReq` is a struct containing a list of predicates that can apply to ranges of version
6687 -/// numbers. Matching operations can then be done with the `VersionReq` against a particular
6688 -/// version to see if it satisfies some or all of the constraints.
6689 -#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
6690 -pub struct VersionReq {
6691 - predicates: Vec<Predicate>,
6694 -impl From<semver_parser::range::VersionReq> for VersionReq {
6695 - fn from(other: semver_parser::range::VersionReq) -> VersionReq {
6696 - VersionReq { predicates: other.predicates.into_iter().map(From::from).collect() }
6700 -#[cfg(feature = "serde")]
6701 -impl Serialize for VersionReq {
6702 - fn serialize<S>(&self, serializer: S) -> result::Result<S::Ok, S::Error>
6703 - where S: Serializer
6705 - // Serialize VersionReq as a string.
6706 - serializer.collect_str(self)
6710 -#[cfg(feature = "serde")]
6711 -impl<'de> Deserialize<'de> for VersionReq {
6712 - fn deserialize<D>(deserializer: D) -> result::Result<Self, D::Error>
6713 - where D: Deserializer<'de>
6715 - struct VersionReqVisitor;
6717 - /// Deserialize `VersionReq` from a string.
6718 - impl<'de> Visitor<'de> for VersionReqVisitor {
6719 - type Value = VersionReq;
6721 - fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
6722 - formatter.write_str("a SemVer version requirement as a string")
6725 - fn visit_str<E>(self, v: &str) -> result::Result<Self::Value, E>
6726 - where E: de::Error
6728 - VersionReq::parse(v).map_err(de::Error::custom)
6732 - deserializer.deserialize_str(VersionReqVisitor)
6736 -#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
6737 -enum WildcardVersion {
6738 - Major,
6739 - Minor,
6740 - Patch,
6743 -#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
6744 -enum Op {
6745 - Ex, // Exact
6746 - Gt, // Greater than
6747 - GtEq, // Greater than or equal to
6748 - Lt, // Less than
6749 - LtEq, // Less than or equal to
6750 - Tilde, // e.g. ~1.0.0
6751 - Compatible, // compatible by definition of semver, indicated by ^
6752 - Wildcard(WildcardVersion), // x.y.*, x.*, *
6755 -impl From<semver_parser::range::Op> for Op {
6756 - fn from(other: semver_parser::range::Op) -> Op {
6757 - use semver_parser::range;
6758 - match other {
6759 - range::Op::Ex => Op::Ex,
6760 - range::Op::Gt => Op::Gt,
6761 - range::Op::GtEq => Op::GtEq,
6762 - range::Op::Lt => Op::Lt,
6763 - range::Op::LtEq => Op::LtEq,
6764 - range::Op::Tilde => Op::Tilde,
6765 - range::Op::Compatible => Op::Compatible,
6766 - range::Op::Wildcard(version) => {
6767 - match version {
6768 - range::WildcardVersion::Major => Op::Wildcard(WildcardVersion::Major),
6769 - range::WildcardVersion::Minor => Op::Wildcard(WildcardVersion::Minor),
6770 - range::WildcardVersion::Patch => Op::Wildcard(WildcardVersion::Patch),
6777 -#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
6778 -struct Predicate {
6779 - op: Op,
6780 - major: u64,
6781 - minor: Option<u64>,
6782 - patch: Option<u64>,
6783 - pre: Vec<Identifier>,
6786 -impl From<semver_parser::range::Predicate> for Predicate {
6787 - fn from(other: semver_parser::range::Predicate) -> Predicate {
6788 - Predicate {
6789 - op: From::from(other.op),
6790 - major: other.major,
6791 - minor: other.minor,
6792 - patch: other.patch,
6793 - pre: other.pre.into_iter().map(From::from).collect(),
6798 -/// A `ReqParseError` is returned from methods which parse a string into a `VersionReq`. Each
6799 -/// enumeration is one of the possible errors that can occur.
6800 -#[derive(Clone, Debug, PartialEq)]
6801 -pub enum ReqParseError {
6802 - /// The given version requirement is invalid.
6803 - InvalidVersionRequirement,
6804 - /// You have already provided an operation, such as `=`, `~`, or `^`. Only use one.
6805 - OpAlreadySet,
6806 - /// The sigil you have written is not correct.
6807 - InvalidSigil,
6808 - /// All components of a version must be numeric.
6809 - VersionComponentsMustBeNumeric,
6810 - /// There was an error parsing an identifier.
6811 - InvalidIdentifier,
6812 - /// At least a major version is required.
6813 - MajorVersionRequired,
6814 - /// An unimplemented version requirement.
6815 - UnimplementedVersionRequirement,
6816 - /// This form of requirement is deprecated.
6817 - DeprecatedVersionRequirement(VersionReq),
6820 -impl fmt::Display for ReqParseError {
6821 - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
6822 - self.description().fmt(f)
6826 -impl Error for ReqParseError {
6827 - fn description(&self) -> &str {
6828 - match self {
6829 - &InvalidVersionRequirement => "the given version requirement is invalid",
6830 - &OpAlreadySet => {
6831 - "you have already provided an operation, such as =, ~, or ^; only use one"
6832 - },
6833 - &InvalidSigil => "the sigil you have written is not correct",
6834 - &VersionComponentsMustBeNumeric => "version components must be numeric",
6835 - &InvalidIdentifier => "invalid identifier",
6836 - &MajorVersionRequired => "at least a major version number is required",
6837 - &UnimplementedVersionRequirement => {
6838 - "the given version requirement is not implemented, yet"
6839 - },
6840 - &DeprecatedVersionRequirement(_) => "This requirement is deprecated",
6845 -impl From<String> for ReqParseError {
6846 - fn from(other: String) -> ReqParseError {
6847 - match &*other {
6848 - "Null is not a valid VersionReq" => ReqParseError::InvalidVersionRequirement,
6849 - "VersionReq did not parse properly." => ReqParseError::OpAlreadySet,
6850 - _ => ReqParseError::InvalidVersionRequirement,
6855 -impl VersionReq {
6856 - /// `any()` is a factory method which creates a `VersionReq` with no constraints. In other
6857 - /// words, any version will match against it.
6858 - ///
6859 - /// # Examples
6860 - ///
6861 - /// ```
6862 - /// use semver::VersionReq;
6863 - ///
6864 - /// let anything = VersionReq::any();
6865 - /// ```
6866 - pub fn any() -> VersionReq {
6867 - VersionReq { predicates: vec![] }
6870 - /// `parse()` is the main constructor of a `VersionReq`. It takes a string like `"^1.2.3"`
6871 - /// and turns it into a `VersionReq` that matches that particular constraint.
6872 - ///
6873 - /// A `Result` is returned which contains a `ReqParseError` if there was a problem parsing the
6874 - /// `VersionReq`.
6875 - ///
6876 - /// # Examples
6877 - ///
6878 - /// ```
6879 - /// use semver::VersionReq;
6880 - ///
6881 - /// let version = VersionReq::parse("=1.2.3");
6882 - /// let version = VersionReq::parse(">1.2.3");
6883 - /// let version = VersionReq::parse("<1.2.3");
6884 - /// let version = VersionReq::parse("~1.2.3");
6885 - /// let version = VersionReq::parse("^1.2.3");
6886 - /// let version = VersionReq::parse("1.2.3"); // synonym for ^1.2.3
6887 - /// let version = VersionReq::parse("<=1.2.3");
6888 - /// let version = VersionReq::parse(">=1.2.3");
6889 - /// ```
6890 - ///
6891 - /// This example demonstrates error handling, and will panic.
6892 - ///
6893 - /// ```should-panic
6894 - /// use semver::VersionReq;
6895 - ///
6896 - /// let version = match VersionReq::parse("not a version") {
6897 - /// Ok(version) => version,
6898 - /// Err(e) => panic!("There was a problem parsing: {}", e),
6899 - /// }
6900 - /// ```
6901 - pub fn parse(input: &str) -> Result<VersionReq, ReqParseError> {
6902 - let res = semver_parser::range::parse(input);
6904 - if let Ok(v) = res {
6905 - return Ok(From::from(v));
6908 - return match VersionReq::parse_deprecated(input) {
6909 - Some(v) => {
6910 - Err(ReqParseError::DeprecatedVersionRequirement(v))
6912 - None => Err(From::from(res.err().unwrap())),
6916 - fn parse_deprecated(version: &str) -> Option<VersionReq> {
6917 - return match version {
6918 - ".*" => Some(VersionReq::any()),
6919 - "0.1.0." => Some(VersionReq::parse("0.1.0").unwrap()),
6920 - "0.3.1.3" => Some(VersionReq::parse("0.3.13").unwrap()),
6921 - "0.2*" => Some(VersionReq::parse("0.2.*").unwrap()),
6922 - "*.0" => Some(VersionReq::any()),
6923 - _ => None,
6927 - /// `exact()` is a factory method which creates a `VersionReq` with one exact constraint.
6928 - ///
6929 - /// # Examples
6930 - ///
6931 - /// ```
6932 - /// use semver::VersionReq;
6933 - /// use semver::Version;
6934 - ///
6935 - /// let version = Version { major: 1, minor: 1, patch: 1, pre: vec![], build: vec![] };
6936 - /// let exact = VersionReq::exact(&version);
6937 - /// ```
6938 - pub fn exact(version: &Version) -> VersionReq {
6939 - VersionReq { predicates: vec![Predicate::exact(version)] }
6942 - /// `matches()` matches a given `Version` against this `VersionReq`.
6943 - ///
6944 - /// # Examples
6945 - ///
6946 - /// ```
6947 - /// use semver::VersionReq;
6948 - /// use semver::Version;
6949 - ///
6950 - /// let version = Version { major: 1, minor: 1, patch: 1, pre: vec![], build: vec![] };
6951 - /// let exact = VersionReq::exact(&version);
6952 - ///
6953 - /// assert!(exact.matches(&version));
6954 - /// ```
6955 - pub fn matches(&self, version: &Version) -> bool {
6956 - // no predicates means anything matches
6957 - if self.predicates.is_empty() {
6958 - return true;
6961 - self.predicates.iter().all(|p| p.matches(version)) &&
6962 - self.predicates.iter().any(|p| p.pre_tag_is_compatible(version))
6966 -impl str::FromStr for VersionReq {
6967 - type Err = ReqParseError;
6969 - fn from_str(s: &str) -> Result<VersionReq, ReqParseError> {
6970 - VersionReq::parse(s)
6974 -impl Predicate {
6975 - fn exact(version: &Version) -> Predicate {
6976 - Predicate {
6977 - op: Ex,
6978 - major: version.major,
6979 - minor: Some(version.minor),
6980 - patch: Some(version.patch),
6981 - pre: version.pre.clone(),
6985 - /// `matches()` takes a `Version` and determines if it matches this particular `Predicate`.
6986 - pub fn matches(&self, ver: &Version) -> bool {
6987 - match self.op {
6988 - Ex => self.is_exact(ver),
6989 - Gt => self.is_greater(ver),
6990 - GtEq => self.is_exact(ver) || self.is_greater(ver),
6991 - Lt => !self.is_exact(ver) && !self.is_greater(ver),
6992 - LtEq => !self.is_greater(ver),
6993 - Tilde => self.matches_tilde(ver),
6994 - Compatible => self.is_compatible(ver),
6995 - Wildcard(_) => self.matches_wildcard(ver),
6999 - fn is_exact(&self, ver: &Version) -> bool {
7000 - if self.major != ver.major {
7001 - return false;
7004 - match self.minor {
7005 - Some(minor) => {
7006 - if minor != ver.minor {
7007 - return false;
7010 - None => return true,
7013 - match self.patch {
7014 - Some(patch) => {
7015 - if patch != ver.patch {
7016 - return false;
7019 - None => return true,
7022 - if self.pre != ver.pre {
7023 - return false;
7026 - true
7029 - // https://docs.npmjs.com/misc/semver#prerelease-tags
7030 - fn pre_tag_is_compatible(&self, ver: &Version) -> bool {
7031 - // If a version has a prerelease tag (for example, 1.2.3-alpha.3) then it will
7032 - // only be
7033 - // allowed to satisfy comparator sets if at least one comparator with the same
7034 - // [major,
7035 - // minor, patch] tuple also has a prerelease tag.
7036 - !ver.is_prerelease() ||
7037 - (self.major == ver.major && self.minor == Some(ver.minor) &&
7038 - self.patch == Some(ver.patch) && !self.pre.is_empty())
7041 - fn is_greater(&self, ver: &Version) -> bool {
7042 - if self.major != ver.major {
7043 - return ver.major > self.major;
7046 - match self.minor {
7047 - Some(minor) => {
7048 - if minor != ver.minor {
7049 - return ver.minor > minor;
7052 - None => return false,
7055 - match self.patch {
7056 - Some(patch) => {
7057 - if patch != ver.patch {
7058 - return ver.patch > patch;
7061 - None => return false,
7064 - if !self.pre.is_empty() {
7065 - return ver.pre.is_empty() || ver.pre > self.pre;
7068 - false
7071 - // see https://www.npmjs.org/doc/misc/semver.html for behavior
7072 - fn matches_tilde(&self, ver: &Version) -> bool {
7073 - let minor = match self.minor {
7074 - Some(n) => n,
7075 - None => return self.major == ver.major,
7076 - };
7078 - match self.patch {
7079 - Some(patch) => {
7080 - self.major == ver.major && minor == ver.minor &&
7081 - (ver.patch > patch || (ver.patch == patch && self.pre_is_compatible(ver)))
7083 - None => self.major == ver.major && minor == ver.minor,
7087 - // see https://www.npmjs.org/doc/misc/semver.html for behavior
7088 - fn is_compatible(&self, ver: &Version) -> bool {
7089 - if self.major != ver.major {
7090 - return false;
7093 - let minor = match self.minor {
7094 - Some(n) => n,
7095 - None => return self.major == ver.major,
7096 - };
7098 - match self.patch {
7099 - Some(patch) => {
7100 - if self.major == 0 {
7101 - if minor == 0 {
7102 - ver.minor == minor && ver.patch == patch && self.pre_is_compatible(ver)
7103 - } else {
7104 - ver.minor == minor &&
7105 - (ver.patch > patch || (ver.patch == patch && self.pre_is_compatible(ver)))
7107 - } else {
7108 - ver.minor > minor ||
7109 - (ver.minor == minor &&
7110 - (ver.patch > patch || (ver.patch == patch && self.pre_is_compatible(ver))))
7113 - None => {
7114 - if self.major == 0 {
7115 - ver.minor == minor
7116 - } else {
7117 - ver.minor >= minor
7123 - fn pre_is_compatible(&self, ver: &Version) -> bool {
7124 - ver.pre.is_empty() || ver.pre >= self.pre
7127 - // see https://www.npmjs.org/doc/misc/semver.html for behavior
7128 - fn matches_wildcard(&self, ver: &Version) -> bool {
7129 - match self.op {
7130 - Wildcard(Major) => true,
7131 - Wildcard(Minor) => self.major == ver.major,
7132 - Wildcard(Patch) => {
7133 - match self.minor {
7134 - Some(minor) => self.major == ver.major && minor == ver.minor,
7135 - None => {
7136 - // minor and patch version astericks mean match on major
7137 - self.major == ver.major
7141 - _ => false, // unreachable
7146 -impl fmt::Display for VersionReq {
7147 - fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
7148 - if self.predicates.is_empty() {
7149 - try!(write!(fmt, "*"));
7150 - } else {
7151 - for (i, ref pred) in self.predicates.iter().enumerate() {
7152 - if i == 0 {
7153 - try!(write!(fmt, "{}", pred));
7154 - } else {
7155 - try!(write!(fmt, ", {}", pred));
7160 - Ok(())
7164 -impl fmt::Display for Predicate {
7165 - fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
7166 - match self.op {
7167 - Wildcard(Major) => try!(write!(fmt, "*")),
7168 - Wildcard(Minor) => try!(write!(fmt, "{}.*", self.major)),
7169 - Wildcard(Patch) => {
7170 - if let Some(minor) = self.minor {
7171 - try!(write!(fmt, "{}.{}.*", self.major, minor))
7172 - } else {
7173 - try!(write!(fmt, "{}.*.*", self.major))
7176 - _ => {
7177 - try!(write!(fmt, "{}{}", self.op, self.major));
7179 - match self.minor {
7180 - Some(v) => try!(write!(fmt, ".{}", v)),
7181 - None => (),
7184 - match self.patch {
7185 - Some(v) => try!(write!(fmt, ".{}", v)),
7186 - None => (),
7189 - if !self.pre.is_empty() {
7190 - try!(write!(fmt, "-"));
7191 - for (i, x) in self.pre.iter().enumerate() {
7192 - if i != 0 {
7193 - try!(write!(fmt, "."))
7195 - try!(write!(fmt, "{}", x));
7201 - Ok(())
7205 -impl fmt::Display for Op {
7206 - fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
7207 - match *self {
7208 - Ex => try!(write!(fmt, "= ")),
7209 - Gt => try!(write!(fmt, "> ")),
7210 - GtEq => try!(write!(fmt, ">= ")),
7211 - Lt => try!(write!(fmt, "< ")),
7212 - LtEq => try!(write!(fmt, "<= ")),
7213 - Tilde => try!(write!(fmt, "~")),
7214 - Compatible => try!(write!(fmt, "^")),
7215 - // gets handled specially in Predicate::fmt
7216 - Wildcard(_) => try!(write!(fmt, "")),
7218 - Ok(())
7222 -#[cfg(test)]
7223 -mod test {
7224 - use super::{VersionReq, Op};
7225 - use super::super::version::Version;
7226 - use std::hash::{Hash, Hasher};
7228 - fn req(s: &str) -> VersionReq {
7229 - VersionReq::parse(s).unwrap()
7232 - fn version(s: &str) -> Version {
7233 - match Version::parse(s) {
7234 - Ok(v) => v,
7235 - Err(e) => panic!("`{}` is not a valid version. Reason: {:?}", s, e),
7239 - fn assert_match(req: &VersionReq, vers: &[&str]) {
7240 - for ver in vers.iter() {
7241 - assert!(req.matches(&version(*ver)), "did not match {}", ver);
7245 - fn assert_not_match(req: &VersionReq, vers: &[&str]) {
7246 - for ver in vers.iter() {
7247 - assert!(!req.matches(&version(*ver)), "matched {}", ver);
7251 - fn calculate_hash<T: Hash>(t: T) -> u64 {
7252 - use std::collections::hash_map::DefaultHasher;
7254 - let mut s = DefaultHasher::new();
7255 - t.hash(&mut s);
7256 - s.finish()
7259 - #[test]
7260 - fn test_parsing_default() {
7261 - let r = req("1.0.0");
7263 - assert_eq!(r.to_string(), "^1.0.0".to_string());
7265 - assert_match(&r, &["1.0.0", "1.0.1"]);
7266 - assert_not_match(&r, &["0.9.9", "0.10.0", "0.1.0"]);
7269 - #[test]
7270 - fn test_parsing_exact() {
7271 - let r = req("=1.0.0");
7273 - assert!(r.to_string() == "= 1.0.0".to_string());
7274 - assert_eq!(r.to_string(), "= 1.0.0".to_string());
7276 - assert_match(&r, &["1.0.0"]);
7277 - assert_not_match(&r, &["1.0.1", "0.9.9", "0.10.0", "0.1.0", "1.0.0-pre"]);
7279 - let r = req("=0.9.0");
7281 - assert_eq!(r.to_string(), "= 0.9.0".to_string());
7283 - assert_match(&r, &["0.9.0"]);
7284 - assert_not_match(&r, &["0.9.1", "1.9.0", "0.0.9"]);
7286 - let r = req("=0.1.0-beta2.a");
7288 - assert_eq!(r.to_string(), "= 0.1.0-beta2.a".to_string());
7290 - assert_match(&r, &["0.1.0-beta2.a"]);
7291 - assert_not_match(&r, &["0.9.1", "0.1.0", "0.1.1-beta2.a", "0.1.0-beta2"]);
7294 - #[test]
7295 - fn test_parse_metadata_see_issue_88_see_issue_88() {
7296 - for op in &[Op::Compatible, Op::Ex, Op::Gt, Op::GtEq, Op::Lt, Op::LtEq, Op::Tilde] {
7297 - req(&format!("{} 1.2.3+meta", op));
7301 - #[test]
7302 - pub fn test_parsing_greater_than() {
7303 - let r = req(">= 1.0.0");
7305 - assert_eq!(r.to_string(), ">= 1.0.0".to_string());
7307 - assert_match(&r, &["1.0.0", "2.0.0"]);
7308 - assert_not_match(&r, &["0.1.0", "0.0.1", "1.0.0-pre", "2.0.0-pre"]);
7310 - let r = req(">= 2.1.0-alpha2");
7312 - assert_match(&r, &["2.1.0-alpha2", "2.1.0-alpha3", "2.1.0", "3.0.0"]);
7313 - assert_not_match(&r,
7314 - &["2.0.0", "2.1.0-alpha1", "2.0.0-alpha2", "3.0.0-alpha2"]);
7317 - #[test]
7318 - pub fn test_parsing_less_than() {
7319 - let r = req("< 1.0.0");
7321 - assert_eq!(r.to_string(), "< 1.0.0".to_string());
7323 - assert_match(&r, &["0.1.0", "0.0.1"]);
7324 - assert_not_match(&r, &["1.0.0", "1.0.0-beta", "1.0.1", "0.9.9-alpha"]);
7326 - let r = req("<= 2.1.0-alpha2");
7328 - assert_match(&r, &["2.1.0-alpha2", "2.1.0-alpha1", "2.0.0", "1.0.0"]);
7329 - assert_not_match(&r,
7330 - &["2.1.0", "2.2.0-alpha1", "2.0.0-alpha2", "1.0.0-alpha2"]);
7333 - #[test]
7334 - pub fn test_multiple() {
7335 - let r = req("> 0.0.9, <= 2.5.3");
7336 - assert_eq!(r.to_string(), "> 0.0.9, <= 2.5.3".to_string());
7337 - assert_match(&r, &["0.0.10", "1.0.0", "2.5.3"]);
7338 - assert_not_match(&r, &["0.0.8", "2.5.4"]);
7340 - let r = req("0.3.0, 0.4.0");
7341 - assert_eq!(r.to_string(), "^0.3.0, ^0.4.0".to_string());
7342 - assert_not_match(&r, &["0.0.8", "0.3.0", "0.4.0"]);
7344 - let r = req("<= 0.2.0, >= 0.5.0");
7345 - assert_eq!(r.to_string(), "<= 0.2.0, >= 0.5.0".to_string());
7346 - assert_not_match(&r, &["0.0.8", "0.3.0", "0.5.1"]);
7348 - let r = req("0.1.0, 0.1.4, 0.1.6");
7349 - assert_eq!(r.to_string(), "^0.1.0, ^0.1.4, ^0.1.6".to_string());
7350 - assert_match(&r, &["0.1.6", "0.1.9"]);
7351 - assert_not_match(&r, &["0.1.0", "0.1.4", "0.2.0"]);
7353 - assert!(VersionReq::parse("> 0.1.0,").is_err());
7354 - assert!(VersionReq::parse("> 0.3.0, ,").is_err());
7356 - let r = req(">=0.5.1-alpha3, <0.6");
7357 - assert_eq!(r.to_string(), ">= 0.5.1-alpha3, < 0.6".to_string());
7358 - assert_match(&r,
7359 - &["0.5.1-alpha3", "0.5.1-alpha4", "0.5.1-beta", "0.5.1", "0.5.5"]);
7360 - assert_not_match(&r,
7361 - &["0.5.1-alpha1", "0.5.2-alpha3", "0.5.5-pre", "0.5.0-pre"]);
7362 - assert_not_match(&r, &["0.6.0", "0.6.0-pre"]);
7365 - #[test]
7366 - pub fn test_parsing_tilde() {
7367 - let r = req("~1");
7368 - assert_match(&r, &["1.0.0", "1.0.1", "1.1.1"]);
7369 - assert_not_match(&r, &["0.9.1", "2.9.0", "0.0.9"]);
7371 - let r = req("~1.2");
7372 - assert_match(&r, &["1.2.0", "1.2.1"]);
7373 - assert_not_match(&r, &["1.1.1", "1.3.0", "0.0.9"]);
7375 - let r = req("~1.2.2");
7376 - assert_match(&r, &["1.2.2", "1.2.4"]);
7377 - assert_not_match(&r, &["1.2.1", "1.9.0", "1.0.9", "2.0.1", "0.1.3"]);
7379 - let r = req("~1.2.3-beta.2");
7380 - assert_match(&r, &["1.2.3", "1.2.4", "1.2.3-beta.2", "1.2.3-beta.4"]);
7381 - assert_not_match(&r, &["1.3.3", "1.1.4", "1.2.3-beta.1", "1.2.4-beta.2"]);
7384 - #[test]
7385 - pub fn test_parsing_compatible() {
7386 - let r = req("^1");
7387 - assert_match(&r, &["1.1.2", "1.1.0", "1.2.1", "1.0.1"]);
7388 - assert_not_match(&r, &["0.9.1", "2.9.0", "0.1.4"]);
7389 - assert_not_match(&r, &["1.0.0-beta1", "0.1.0-alpha", "1.0.1-pre"]);
7391 - let r = req("^1.1");
7392 - assert_match(&r, &["1.1.2", "1.1.0", "1.2.1"]);
7393 - assert_not_match(&r, &["0.9.1", "2.9.0", "1.0.1", "0.1.4"]);
7395 - let r = req("^1.1.2");
7396 - assert_match(&r, &["1.1.2", "1.1.4", "1.2.1"]);
7397 - assert_not_match(&r, &["0.9.1", "2.9.0", "1.1.1", "0.0.1"]);
7398 - assert_not_match(&r, &["1.1.2-alpha1", "1.1.3-alpha1", "2.9.0-alpha1"]);
7400 - let r = req("^0.1.2");
7401 - assert_match(&r, &["0.1.2", "0.1.4"]);
7402 - assert_not_match(&r, &["0.9.1", "2.9.0", "1.1.1", "0.0.1"]);
7403 - assert_not_match(&r, &["0.1.2-beta", "0.1.3-alpha", "0.2.0-pre"]);
7405 - let r = req("^0.5.1-alpha3");
7406 - assert_match(&r,
7407 - &["0.5.1-alpha3", "0.5.1-alpha4", "0.5.1-beta", "0.5.1", "0.5.5"]);
7408 - assert_not_match(&r,
7409 - &["0.5.1-alpha1", "0.5.2-alpha3", "0.5.5-pre", "0.5.0-pre", "0.6.0"]);
7411 - let r = req("^0.0.2");
7412 - assert_match(&r, &["0.0.2"]);
7413 - assert_not_match(&r, &["0.9.1", "2.9.0", "1.1.1", "0.0.1", "0.1.4"]);
7415 - let r = req("^0.0");
7416 - assert_match(&r, &["0.0.2", "0.0.0"]);
7417 - assert_not_match(&r, &["0.9.1", "2.9.0", "1.1.1", "0.1.4"]);
7419 - let r = req("^0");
7420 - assert_match(&r, &["0.9.1", "0.0.2", "0.0.0"]);
7421 - assert_not_match(&r, &["2.9.0", "1.1.1"]);
7423 - let r = req("^1.4.2-beta.5");
7424 - assert_match(&r,
7425 - &["1.4.2", "1.4.3", "1.4.2-beta.5", "1.4.2-beta.6", "1.4.2-c"]);
7426 - assert_not_match(&r,
7427 - &["0.9.9", "2.0.0", "1.4.2-alpha", "1.4.2-beta.4", "1.4.3-beta.5"]);
7430 - #[test]
7431 - pub fn test_parsing_wildcard() {
7432 - let r = req("");
7433 - assert_match(&r, &["0.9.1", "2.9.0", "0.0.9", "1.0.1", "1.1.1"]);
7434 - assert_not_match(&r, &[]);
7435 - let r = req("*");
7436 - assert_match(&r, &["0.9.1", "2.9.0", "0.0.9", "1.0.1", "1.1.1"]);
7437 - assert_not_match(&r, &[]);
7438 - let r = req("x");
7439 - assert_match(&r, &["0.9.1", "2.9.0", "0.0.9", "1.0.1", "1.1.1"]);
7440 - assert_not_match(&r, &[]);
7441 - let r = req("X");
7442 - assert_match(&r, &["0.9.1", "2.9.0", "0.0.9", "1.0.1", "1.1.1"]);
7443 - assert_not_match(&r, &[]);
7445 - let r = req("1.*");
7446 - assert_match(&r, &["1.2.0", "1.2.1", "1.1.1", "1.3.0"]);
7447 - assert_not_match(&r, &["0.0.9"]);
7448 - let r = req("1.x");
7449 - assert_match(&r, &["1.2.0", "1.2.1", "1.1.1", "1.3.0"]);
7450 - assert_not_match(&r, &["0.0.9"]);
7451 - let r = req("1.X");
7452 - assert_match(&r, &["1.2.0", "1.2.1", "1.1.1", "1.3.0"]);
7453 - assert_not_match(&r, &["0.0.9"]);
7455 - let r = req("1.2.*");
7456 - assert_match(&r, &["1.2.0", "1.2.2", "1.2.4"]);
7457 - assert_not_match(&r, &["1.9.0", "1.0.9", "2.0.1", "0.1.3"]);
7458 - let r = req("1.2.x");
7459 - assert_match(&r, &["1.2.0", "1.2.2", "1.2.4"]);
7460 - assert_not_match(&r, &["1.9.0", "1.0.9", "2.0.1", "0.1.3"]);
7461 - let r = req("1.2.X");
7462 - assert_match(&r, &["1.2.0", "1.2.2", "1.2.4"]);
7463 - assert_not_match(&r, &["1.9.0", "1.0.9", "2.0.1", "0.1.3"]);
7466 - #[test]
7467 - pub fn test_any() {
7468 - let r = VersionReq::any();
7469 - assert_match(&r, &["0.0.1", "0.1.0", "1.0.0"]);
7472 - #[test]
7473 - pub fn test_pre() {
7474 - let r = req("=2.1.1-really.0");
7475 - assert_match(&r, &["2.1.1-really.0"]);
7478 - // #[test]
7479 - // pub fn test_parse_errors() {
7480 - // assert_eq!(Err(InvalidVersionRequirement), VersionReq::parse("\0"));
7481 - // assert_eq!(Err(OpAlreadySet), VersionReq::parse(">= >= 0.0.2"));
7482 - // assert_eq!(Err(InvalidSigil), VersionReq::parse(">== 0.0.2"));
7483 - // assert_eq!(Err(VersionComponentsMustBeNumeric),
7484 - // VersionReq::parse("a.0.0"));
7485 - // assert_eq!(Err(InvalidIdentifier), VersionReq::parse("1.0.0-"));
7486 - // assert_eq!(Err(MajorVersionRequired), VersionReq::parse(">="));
7487 - // }
7489 - #[test]
7490 - pub fn test_from_str() {
7491 - assert_eq!("1.0.0".parse::<VersionReq>().unwrap().to_string(),
7492 - "^1.0.0".to_string());
7493 - assert_eq!("=1.0.0".parse::<VersionReq>().unwrap().to_string(),
7494 - "= 1.0.0".to_string());
7495 - assert_eq!("~1".parse::<VersionReq>().unwrap().to_string(),
7496 - "~1".to_string());
7497 - assert_eq!("~1.2".parse::<VersionReq>().unwrap().to_string(),
7498 - "~1.2".to_string());
7499 - assert_eq!("^1".parse::<VersionReq>().unwrap().to_string(),
7500 - "^1".to_string());
7501 - assert_eq!("^1.1".parse::<VersionReq>().unwrap().to_string(),
7502 - "^1.1".to_string());
7503 - assert_eq!("*".parse::<VersionReq>().unwrap().to_string(),
7504 - "*".to_string());
7505 - assert_eq!("1.*".parse::<VersionReq>().unwrap().to_string(),
7506 - "1.*".to_string());
7507 - assert_eq!("< 1.0.0".parse::<VersionReq>().unwrap().to_string(),
7508 - "< 1.0.0".to_string());
7511 - // #[test]
7512 - // pub fn test_from_str_errors() {
7513 - // assert_eq!(Err(InvalidVersionRequirement), "\0".parse::<VersionReq>());
7514 - // assert_eq!(Err(OpAlreadySet), ">= >= 0.0.2".parse::<VersionReq>());
7515 - // assert_eq!(Err(InvalidSigil), ">== 0.0.2".parse::<VersionReq>());
7516 - // assert_eq!(Err(VersionComponentsMustBeNumeric),
7517 - // "a.0.0".parse::<VersionReq>());
7518 - // assert_eq!(Err(InvalidIdentifier), "1.0.0-".parse::<VersionReq>());
7519 - // assert_eq!(Err(MajorVersionRequired), ">=".parse::<VersionReq>());
7520 - // }
7522 - #[test]
7523 - fn test_cargo3202() {
7524 - let v = "0.*.*".parse::<VersionReq>().unwrap();
7525 - assert_eq!("0.*.*", format!("{}", v.predicates[0]));
7527 - let v = "0.0.*".parse::<VersionReq>().unwrap();
7528 - assert_eq!("0.0.*", format!("{}", v.predicates[0]));
7530 - let r = req("0.*.*");
7531 - assert_match(&r, &["0.5.0"]);
7534 - #[test]
7535 - fn test_eq_hash() {
7536 - assert!(req("^1") == req("^1"));
7537 - assert!(calculate_hash(req("^1")) == calculate_hash(req("^1")));
7538 - assert!(req("^1") != req("^2"));
7541 - #[test]
7542 - fn test_ordering() {
7543 - assert!(req("=1") < req("*"));
7544 - assert!(req(">1") < req("*"));
7545 - assert!(req(">=1") < req("*"));
7546 - assert!(req("<1") < req("*"));
7547 - assert!(req("<=1") < req("*"));
7548 - assert!(req("~1") < req("*"));
7549 - assert!(req("^1") < req("*"));
7550 - assert!(req("*") == req("*"));
7553 diff --git a/third_party/rust/semver/tests/deprecation.rs b/third_party/rust/semver/tests/deprecation.rs
7554 deleted file mode 100644
7555 --- a/third_party/rust/semver/tests/deprecation.rs
7556 +++ /dev/null
7557 @@ -1,22 +0,0 @@
7558 -extern crate semver;
7560 -#[test]
7561 -fn test_regressions() {
7562 - use semver::VersionReq;
7563 - use semver::ReqParseError;
7565 - let versions = vec![
7566 - (".*", VersionReq::any()),
7567 - ("0.1.0.", VersionReq::parse("0.1.0").unwrap()),
7568 - ("0.3.1.3", VersionReq::parse("0.3.13").unwrap()),
7569 - ("0.2*", VersionReq::parse("0.2.*").unwrap()),
7570 - ("*.0", VersionReq::any()),
7571 - ];
7573 - for (version, requirement) in versions.into_iter() {
7574 - let parsed = VersionReq::parse(version);
7575 - let error = parsed.err().unwrap();
7577 - assert_eq!(ReqParseError::DeprecatedVersionRequirement(requirement), error);
7580 diff --git a/third_party/rust/semver/tests/node/mod.rs b/third_party/rust/semver/tests/node/mod.rs
7581 new file mode 100644
7582 --- /dev/null
7583 +++ b/third_party/rust/semver/tests/node/mod.rs
7584 @@ -0,0 +1,43 @@
7585 +#![cfg(test_node_semver)]
7587 +use semver::Version;
7588 +use std::fmt::{self, Display};
7589 +use std::process::Command;
7591 +#[derive(Default, Eq, PartialEq, Hash, Debug)]
7592 +pub(super) struct VersionReq(semver::VersionReq);
7594 +impl VersionReq {
7595 + pub(super) const STAR: Self = VersionReq(semver::VersionReq::STAR);
7597 + pub(super) fn matches(&self, version: &Version) -> bool {
7598 + let out = Command::new("node")
7599 + .arg("-e")
7600 + .arg(format!(
7601 + "console.log(require('semver').satisfies('{}', '{}'))",
7602 + version,
7603 + self.to_string().replace(',', ""),
7604 + ))
7605 + .output()
7606 + .unwrap();
7607 + if out.stdout == b"true\n" {
7608 + true
7609 + } else if out.stdout == b"false\n" {
7610 + false
7611 + } else {
7612 + let s = String::from_utf8_lossy(&out.stdout) + String::from_utf8_lossy(&out.stderr);
7613 + panic!("unexpected output: {}", s);
7618 +impl Display for VersionReq {
7619 + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
7620 + Display::fmt(&self.0, formatter)
7624 +#[cfg_attr(not(no_track_caller), track_caller)]
7625 +pub(super) fn req(text: &str) -> VersionReq {
7626 + VersionReq(crate::util::req(text))
7628 diff --git a/third_party/rust/semver/tests/regression.rs b/third_party/rust/semver/tests/regression.rs
7629 deleted file mode 100644
7630 --- a/third_party/rust/semver/tests/regression.rs
7631 +++ /dev/null
7632 @@ -1,25 +0,0 @@
7633 -extern crate semver;
7634 -extern crate crates_index;
7635 -extern crate tempdir;
7637 -// This test checks to see if every existing crate parses successfully. Important to not break the
7638 -// Rust universe!
7640 -#[cfg(feature = "ci")]
7641 -#[test]
7642 -fn test_regressions() {
7643 - use tempdir::TempDir;
7644 - use crates_index::Index;
7645 - use semver::Version;
7647 - let dir = TempDir::new("semver").unwrap();
7648 - let index = Index::new(dir.into_path());
7649 - index.clone().unwrap();
7651 - for krate in index.crates() {
7652 - for version in krate.versions() {
7653 - let v = version.version();
7654 - assert!(Version::parse(v).is_ok(), "failed: {} ({})", version.name(), v);
7658 diff --git a/third_party/rust/semver/tests/serde.rs b/third_party/rust/semver/tests/serde.rs
7659 deleted file mode 100644
7660 --- a/third_party/rust/semver/tests/serde.rs
7661 +++ /dev/null
7662 @@ -1,90 +0,0 @@
7663 -#![cfg(feature = "serde")]
7665 -#[macro_use]
7666 -extern crate serde_derive;
7668 -extern crate semver;
7669 -extern crate serde_json;
7671 -use semver::{Identifier, Version, VersionReq};
7673 -#[derive(Serialize, Deserialize, PartialEq, Debug)]
7674 -struct Identified {
7675 - name: String,
7676 - identifier: Identifier,
7679 -#[derive(Serialize, Deserialize, PartialEq, Debug)]
7680 -struct Versioned {
7681 - name: String,
7682 - vers: Version,
7685 -#[test]
7686 -fn serialize_identifier() {
7687 - let id = Identified {
7688 - name: "serde".to_owned(),
7689 - identifier: Identifier::Numeric(100),
7690 - };
7691 - let j = serde_json::to_string(&id).unwrap();
7692 - assert_eq!(j, r#"{"name":"serde","identifier":100}"#);
7694 - let id = Identified {
7695 - name: "serde".to_owned(),
7696 - identifier: Identifier::AlphaNumeric("b100".to_owned()),
7697 - };
7698 - let j = serde_json::to_string(&id).unwrap();
7699 - assert_eq!(j, r#"{"name":"serde","identifier":"b100"}"#);
7702 -#[test]
7703 -fn deserialize_identifier() {
7704 - let j = r#"{"name":"serde","identifier":100}"#;
7705 - let id = serde_json::from_str::<Identified>(j).unwrap();
7706 - let expected = Identified {
7707 - name: "serde".to_owned(),
7708 - identifier: Identifier::Numeric(100),
7709 - };
7710 - assert_eq!(id, expected);
7712 - let j = r#"{"name":"serde","identifier":"b100"}"#;
7713 - let id = serde_json::from_str::<Identified>(j).unwrap();
7714 - let expected = Identified {
7715 - name: "serde".to_owned(),
7716 - identifier: Identifier::AlphaNumeric("b100".to_owned()),
7717 - };
7718 - assert_eq!(id, expected);
7721 -#[test]
7722 -fn serialize_version() {
7723 - let v = Versioned {
7724 - name: "serde".to_owned(),
7725 - vers: Version::parse("1.0.0").unwrap(),
7726 - };
7727 - let j = serde_json::to_string(&v).unwrap();
7728 - assert_eq!(j, r#"{"name":"serde","vers":"1.0.0"}"#);
7731 -#[test]
7732 -fn deserialize_version() {
7733 - let j = r#"{"name":"serde","vers":"1.0.0"}"#;
7734 - let v = serde_json::from_str::<Versioned>(j).unwrap();
7735 - let expected = Versioned {
7736 - name: "serde".to_owned(),
7737 - vers: Version::parse("1.0.0").unwrap(),
7738 - };
7739 - assert_eq!(v, expected);
7742 -#[test]
7743 -fn serialize_versionreq() {
7744 - let v = VersionReq::exact(&Version::parse("1.0.0").unwrap());
7746 - assert_eq!(serde_json::to_string(&v).unwrap(), r#""= 1.0.0""#);
7749 -#[test]
7750 -fn deserialize_versionreq() {
7751 - assert_eq!("1.0.0".parse::<VersionReq>().unwrap(), serde_json::from_str(r#""1.0.0""#).unwrap());
7753 diff --git a/third_party/rust/semver/tests/test_autotrait.rs b/third_party/rust/semver/tests/test_autotrait.rs
7754 new file mode 100644
7755 --- /dev/null
7756 +++ b/third_party/rust/semver/tests/test_autotrait.rs
7757 @@ -0,0 +1,12 @@
7758 +fn assert_send_sync<T: Send + Sync>() {}
7760 +#[test]
7761 +fn test() {
7762 + assert_send_sync::<semver::BuildMetadata>();
7763 + assert_send_sync::<semver::Comparator>();
7764 + assert_send_sync::<semver::Error>();
7765 + assert_send_sync::<semver::Prerelease>();
7766 + assert_send_sync::<semver::Version>();
7767 + assert_send_sync::<semver::VersionReq>();
7768 + assert_send_sync::<semver::Op>();
7770 diff --git a/third_party/rust/semver/tests/test_identifier.rs b/third_party/rust/semver/tests/test_identifier.rs
7771 new file mode 100644
7772 --- /dev/null
7773 +++ b/third_party/rust/semver/tests/test_identifier.rs
7774 @@ -0,0 +1,45 @@
7775 +#![allow(
7776 + clippy::eq_op,
7777 + clippy::needless_pass_by_value,
7778 + clippy::toplevel_ref_arg,
7779 + clippy::wildcard_imports
7782 +mod util;
7784 +use crate::util::*;
7785 +use semver::Prerelease;
7787 +#[test]
7788 +fn test_new() {
7789 + fn test(identifier: Prerelease, expected: &str) {
7790 + assert_eq!(identifier.is_empty(), expected.is_empty());
7791 + assert_eq!(identifier.len(), expected.len());
7792 + assert_eq!(identifier.as_str(), expected);
7793 + assert_eq!(identifier, identifier);
7794 + assert_eq!(identifier, identifier.clone());
7797 + let ref mut string = String::new();
7798 + let limit = if cfg!(miri) { 40 } else { 280 }; // miri is slow
7799 + for _ in 0..limit {
7800 + test(prerelease(string), string);
7801 + string.push('1');
7804 + if !cfg!(miri) {
7805 + let ref string = string.repeat(20000);
7806 + test(prerelease(string), string);
7810 +#[test]
7811 +fn test_eq() {
7812 + assert_eq!(prerelease("-"), prerelease("-"));
7813 + assert_ne!(prerelease("a"), prerelease("aa"));
7814 + assert_ne!(prerelease("aa"), prerelease("a"));
7815 + assert_ne!(prerelease("aaaaaaaaa"), prerelease("a"));
7816 + assert_ne!(prerelease("a"), prerelease("aaaaaaaaa"));
7817 + assert_ne!(prerelease("aaaaaaaaa"), prerelease("bbbbbbbbb"));
7818 + assert_ne!(build_metadata("1"), build_metadata("001"));
7820 diff --git a/third_party/rust/semver/tests/test_version.rs b/third_party/rust/semver/tests/test_version.rs
7821 new file mode 100644
7822 --- /dev/null
7823 +++ b/third_party/rust/semver/tests/test_version.rs
7824 @@ -0,0 +1,241 @@
7825 +#![allow(
7826 + clippy::nonminimal_bool,
7827 + clippy::too_many_lines,
7828 + clippy::wildcard_imports
7831 +mod util;
7833 +use crate::util::*;
7834 +use semver::{BuildMetadata, Prerelease, Version};
7836 +#[test]
7837 +fn test_parse() {
7838 + let err = version_err("");
7839 + assert_to_string(
7840 + err,
7841 + "unexpected end of input while parsing major version number",
7842 + );
7844 + let err = version_err(" ");
7845 + assert_to_string(
7846 + err,
7847 + "unexpected character ' ' while parsing major version number",
7848 + );
7850 + let err = version_err("1");
7851 + assert_to_string(
7852 + err,
7853 + "unexpected end of input while parsing major version number",
7854 + );
7856 + let err = version_err("1.2");
7857 + assert_to_string(
7858 + err,
7859 + "unexpected end of input while parsing minor version number",
7860 + );
7862 + let err = version_err("1.2.3-");
7863 + assert_to_string(err, "empty identifier segment in pre-release identifier");
7865 + let err = version_err("a.b.c");
7866 + assert_to_string(
7867 + err,
7868 + "unexpected character 'a' while parsing major version number",
7869 + );
7871 + let err = version_err("1.2.3 abc");
7872 + assert_to_string(err, "unexpected character ' ' after patch version number");
7874 + let err = version_err("1.2.3-01");
7875 + assert_to_string(err, "invalid leading zero in pre-release identifier");
7877 + let parsed = version("1.2.3");
7878 + let expected = Version::new(1, 2, 3);
7879 + assert_eq!(parsed, expected);
7880 + let expected = Version {
7881 + major: 1,
7882 + minor: 2,
7883 + patch: 3,
7884 + pre: Prerelease::EMPTY,
7885 + build: BuildMetadata::EMPTY,
7886 + };
7887 + assert_eq!(parsed, expected);
7889 + let parsed = version("1.2.3-alpha1");
7890 + let expected = Version {
7891 + major: 1,
7892 + minor: 2,
7893 + patch: 3,
7894 + pre: prerelease("alpha1"),
7895 + build: BuildMetadata::EMPTY,
7896 + };
7897 + assert_eq!(parsed, expected);
7899 + let parsed = version("1.2.3+build5");
7900 + let expected = Version {
7901 + major: 1,
7902 + minor: 2,
7903 + patch: 3,
7904 + pre: Prerelease::EMPTY,
7905 + build: build_metadata("build5"),
7906 + };
7907 + assert_eq!(parsed, expected);
7909 + let parsed = version("1.2.3+5build");
7910 + let expected = Version {
7911 + major: 1,
7912 + minor: 2,
7913 + patch: 3,
7914 + pre: Prerelease::EMPTY,
7915 + build: build_metadata("5build"),
7916 + };
7917 + assert_eq!(parsed, expected);
7919 + let parsed = version("1.2.3-alpha1+build5");
7920 + let expected = Version {
7921 + major: 1,
7922 + minor: 2,
7923 + patch: 3,
7924 + pre: prerelease("alpha1"),
7925 + build: build_metadata("build5"),
7926 + };
7927 + assert_eq!(parsed, expected);
7929 + let parsed = version("1.2.3-1.alpha1.9+build5.7.3aedf");
7930 + let expected = Version {
7931 + major: 1,
7932 + minor: 2,
7933 + patch: 3,
7934 + pre: prerelease("1.alpha1.9"),
7935 + build: build_metadata("build5.7.3aedf"),
7936 + };
7937 + assert_eq!(parsed, expected);
7939 + let parsed = version("1.2.3-0a.alpha1.9+05build.7.3aedf");
7940 + let expected = Version {
7941 + major: 1,
7942 + minor: 2,
7943 + patch: 3,
7944 + pre: prerelease("0a.alpha1.9"),
7945 + build: build_metadata("05build.7.3aedf"),
7946 + };
7947 + assert_eq!(parsed, expected);
7949 + let parsed = version("0.4.0-beta.1+0851523");
7950 + let expected = Version {
7951 + major: 0,
7952 + minor: 4,
7953 + patch: 0,
7954 + pre: prerelease("beta.1"),
7955 + build: build_metadata("0851523"),
7956 + };
7957 + assert_eq!(parsed, expected);
7959 + // for https://nodejs.org/dist/index.json, where some older npm versions are "1.1.0-beta-10"
7960 + let parsed = version("1.1.0-beta-10");
7961 + let expected = Version {
7962 + major: 1,
7963 + minor: 1,
7964 + patch: 0,
7965 + pre: prerelease("beta-10"),
7966 + build: BuildMetadata::EMPTY,
7967 + };
7968 + assert_eq!(parsed, expected);
7971 +#[test]
7972 +fn test_eq() {
7973 + assert_eq!(version("1.2.3"), version("1.2.3"));
7974 + assert_eq!(version("1.2.3-alpha1"), version("1.2.3-alpha1"));
7975 + assert_eq!(version("1.2.3+build.42"), version("1.2.3+build.42"));
7976 + assert_eq!(version("1.2.3-alpha1+42"), version("1.2.3-alpha1+42"));
7979 +#[test]
7980 +fn test_ne() {
7981 + assert_ne!(version("0.0.0"), version("0.0.1"));
7982 + assert_ne!(version("0.0.0"), version("0.1.0"));
7983 + assert_ne!(version("0.0.0"), version("1.0.0"));
7984 + assert_ne!(version("1.2.3-alpha"), version("1.2.3-beta"));
7985 + assert_ne!(version("1.2.3+23"), version("1.2.3+42"));
7988 +#[test]
7989 +fn test_display() {
7990 + assert_to_string(version("1.2.3"), "1.2.3");
7991 + assert_to_string(version("1.2.3-alpha1"), "1.2.3-alpha1");
7992 + assert_to_string(version("1.2.3+build.42"), "1.2.3+build.42");
7993 + assert_to_string(version("1.2.3-alpha1+42"), "1.2.3-alpha1+42");
7996 +#[test]
7997 +fn test_lt() {
7998 + assert!(version("0.0.0") < version("1.2.3-alpha2"));
7999 + assert!(version("1.0.0") < version("1.2.3-alpha2"));
8000 + assert!(version("1.2.0") < version("1.2.3-alpha2"));
8001 + assert!(version("1.2.3-alpha1") < version("1.2.3"));
8002 + assert!(version("1.2.3-alpha1") < version("1.2.3-alpha2"));
8003 + assert!(!(version("1.2.3-alpha2") < version("1.2.3-alpha2")));
8004 + assert!(version("1.2.3+23") < version("1.2.3+42"));
8007 +#[test]
8008 +fn test_le() {
8009 + assert!(version("0.0.0") <= version("1.2.3-alpha2"));
8010 + assert!(version("1.0.0") <= version("1.2.3-alpha2"));
8011 + assert!(version("1.2.0") <= version("1.2.3-alpha2"));
8012 + assert!(version("1.2.3-alpha1") <= version("1.2.3-alpha2"));
8013 + assert!(version("1.2.3-alpha2") <= version("1.2.3-alpha2"));
8014 + assert!(version("1.2.3+23") <= version("1.2.3+42"));
8017 +#[test]
8018 +fn test_gt() {
8019 + assert!(version("1.2.3-alpha2") > version("0.0.0"));
8020 + assert!(version("1.2.3-alpha2") > version("1.0.0"));
8021 + assert!(version("1.2.3-alpha2") > version("1.2.0"));
8022 + assert!(version("1.2.3-alpha2") > version("1.2.3-alpha1"));
8023 + assert!(version("1.2.3") > version("1.2.3-alpha2"));
8024 + assert!(!(version("1.2.3-alpha2") > version("1.2.3-alpha2")));
8025 + assert!(!(version("1.2.3+23") > version("1.2.3+42")));
8028 +#[test]
8029 +fn test_ge() {
8030 + assert!(version("1.2.3-alpha2") >= version("0.0.0"));
8031 + assert!(version("1.2.3-alpha2") >= version("1.0.0"));
8032 + assert!(version("1.2.3-alpha2") >= version("1.2.0"));
8033 + assert!(version("1.2.3-alpha2") >= version("1.2.3-alpha1"));
8034 + assert!(version("1.2.3-alpha2") >= version("1.2.3-alpha2"));
8035 + assert!(!(version("1.2.3+23") >= version("1.2.3+42")));
8038 +#[test]
8039 +fn test_spec_order() {
8040 + let vs = [
8041 + "1.0.0-alpha",
8042 + "1.0.0-alpha.1",
8043 + "1.0.0-alpha.beta",
8044 + "1.0.0-beta",
8045 + "1.0.0-beta.2",
8046 + "1.0.0-beta.11",
8047 + "1.0.0-rc.1",
8048 + "1.0.0",
8049 + ];
8050 + let mut i = 1;
8051 + while i < vs.len() {
8052 + let a = version(vs[i - 1]);
8053 + let b = version(vs[i]);
8054 + assert!(a < b, "nope {:?} < {:?}", a, b);
8055 + i += 1;
8059 +#[test]
8060 +fn test_align() {
8061 + let version = version("1.2.3-rc1");
8062 + assert_eq!("1.2.3-rc1 ", format!("{:20}", version));
8063 + assert_eq!("*****1.2.3-rc1******", format!("{:*^20}", version));
8064 + assert_eq!(" 1.2.3-rc1", format!("{:>20}", version));
8066 diff --git a/third_party/rust/semver/tests/test_version_req.rs b/third_party/rust/semver/tests/test_version_req.rs
8067 new file mode 100644
8068 --- /dev/null
8069 +++ b/third_party/rust/semver/tests/test_version_req.rs
8070 @@ -0,0 +1,443 @@
8071 +#![allow(
8072 + clippy::missing_panics_doc,
8073 + clippy::shadow_unrelated,
8074 + clippy::toplevel_ref_arg,
8075 + clippy::wildcard_imports
8078 +mod node;
8079 +mod util;
8081 +use crate::util::*;
8082 +use std::collections::hash_map::DefaultHasher;
8083 +use std::hash::{Hash, Hasher};
8085 +#[cfg(test_node_semver)]
8086 +use node::{req, VersionReq};
8087 +#[cfg(not(test_node_semver))]
8088 +use semver::VersionReq;
8090 +#[cfg_attr(not(no_track_caller), track_caller)]
8091 +fn assert_match_all(req: &VersionReq, versions: &[&str]) {
8092 + for string in versions {
8093 + let parsed = version(string);
8094 + assert!(req.matches(&parsed), "did not match {}", string);
8098 +#[cfg_attr(not(no_track_caller), track_caller)]
8099 +fn assert_match_none(req: &VersionReq, versions: &[&str]) {
8100 + for string in versions {
8101 + let parsed = version(string);
8102 + assert!(!req.matches(&parsed), "matched {}", string);
8106 +#[test]
8107 +fn test_basic() {
8108 + let ref r = req("1.0.0");
8109 + assert_to_string(r, "^1.0.0");
8110 + assert_match_all(r, &["1.0.0", "1.1.0", "1.0.1"]);
8111 + assert_match_none(r, &["0.9.9", "0.10.0", "0.1.0", "1.0.0-pre", "1.0.1-pre"]);
8114 +#[test]
8115 +#[cfg(not(no_const_vec_new))]
8116 +fn test_default() {
8117 + let ref r = VersionReq::default();
8118 + assert_eq!(r, &VersionReq::STAR);
8121 +#[test]
8122 +fn test_exact() {
8123 + let ref r = req("=1.0.0");
8124 + assert_to_string(r, "=1.0.0");
8125 + assert_match_all(r, &["1.0.0"]);
8126 + assert_match_none(r, &["1.0.1", "0.9.9", "0.10.0", "0.1.0", "1.0.0-pre"]);
8128 + let ref r = req("=0.9.0");
8129 + assert_to_string(r, "=0.9.0");
8130 + assert_match_all(r, &["0.9.0"]);
8131 + assert_match_none(r, &["0.9.1", "1.9.0", "0.0.9", "0.9.0-pre"]);
8133 + let ref r = req("=0.0.2");
8134 + assert_to_string(r, "=0.0.2");
8135 + assert_match_all(r, &["0.0.2"]);
8136 + assert_match_none(r, &["0.0.1", "0.0.3", "0.0.2-pre"]);
8138 + let ref r = req("=0.1.0-beta2.a");
8139 + assert_to_string(r, "=0.1.0-beta2.a");
8140 + assert_match_all(r, &["0.1.0-beta2.a"]);
8141 + assert_match_none(r, &["0.9.1", "0.1.0", "0.1.1-beta2.a", "0.1.0-beta2"]);
8143 + let ref r = req("=0.1.0+meta");
8144 + assert_to_string(r, "=0.1.0");
8145 + assert_match_all(r, &["0.1.0", "0.1.0+meta", "0.1.0+any"]);
8148 +#[test]
8149 +pub fn test_greater_than() {
8150 + let ref r = req(">= 1.0.0");
8151 + assert_to_string(r, ">=1.0.0");
8152 + assert_match_all(r, &["1.0.0", "2.0.0"]);
8153 + assert_match_none(r, &["0.1.0", "0.0.1", "1.0.0-pre", "2.0.0-pre"]);
8155 + let ref r = req(">= 2.1.0-alpha2");
8156 + assert_to_string(r, ">=2.1.0-alpha2");
8157 + assert_match_all(r, &["2.1.0-alpha2", "2.1.0-alpha3", "2.1.0", "3.0.0"]);
8158 + assert_match_none(
8159 + r,
8160 + &["2.0.0", "2.1.0-alpha1", "2.0.0-alpha2", "3.0.0-alpha2"],
8161 + );
8164 +#[test]
8165 +pub fn test_less_than() {
8166 + let ref r = req("< 1.0.0");
8167 + assert_to_string(r, "<1.0.0");
8168 + assert_match_all(r, &["0.1.0", "0.0.1"]);
8169 + assert_match_none(r, &["1.0.0", "1.0.0-beta", "1.0.1", "0.9.9-alpha"]);
8171 + let ref r = req("<= 2.1.0-alpha2");
8172 + assert_match_all(r, &["2.1.0-alpha2", "2.1.0-alpha1", "2.0.0", "1.0.0"]);
8173 + assert_match_none(
8174 + r,
8175 + &["2.1.0", "2.2.0-alpha1", "2.0.0-alpha2", "1.0.0-alpha2"],
8176 + );
8178 + let ref r = req(">1.0.0-alpha, <1.0.0");
8179 + assert_match_all(r, &["1.0.0-beta"]);
8181 + let ref r = req(">1.0.0-alpha, <1.0");
8182 + assert_match_none(r, &["1.0.0-beta"]);
8184 + let ref r = req(">1.0.0-alpha, <1");
8185 + assert_match_none(r, &["1.0.0-beta"]);
8188 +#[test]
8189 +pub fn test_multiple() {
8190 + let ref r = req("> 0.0.9, <= 2.5.3");
8191 + assert_to_string(r, ">0.0.9, <=2.5.3");
8192 + assert_match_all(r, &["0.0.10", "1.0.0", "2.5.3"]);
8193 + assert_match_none(r, &["0.0.8", "2.5.4"]);
8195 + let ref r = req("0.3.0, 0.4.0");
8196 + assert_to_string(r, "^0.3.0, ^0.4.0");
8197 + assert_match_none(r, &["0.0.8", "0.3.0", "0.4.0"]);
8199 + let ref r = req("<= 0.2.0, >= 0.5.0");
8200 + assert_to_string(r, "<=0.2.0, >=0.5.0");
8201 + assert_match_none(r, &["0.0.8", "0.3.0", "0.5.1"]);
8203 + let ref r = req("0.1.0, 0.1.4, 0.1.6");
8204 + assert_to_string(r, "^0.1.0, ^0.1.4, ^0.1.6");
8205 + assert_match_all(r, &["0.1.6", "0.1.9"]);
8206 + assert_match_none(r, &["0.1.0", "0.1.4", "0.2.0"]);
8208 + let err = req_err("> 0.1.0,");
8209 + assert_to_string(
8210 + err,
8211 + "unexpected end of input while parsing major version number",
8212 + );
8214 + let err = req_err("> 0.3.0, ,");
8215 + assert_to_string(
8216 + err,
8217 + "unexpected character ',' while parsing major version number",
8218 + );
8220 + let ref r = req(">=0.5.1-alpha3, <0.6");
8221 + assert_to_string(r, ">=0.5.1-alpha3, <0.6");
8222 + assert_match_all(
8223 + r,
8224 + &[
8225 + "0.5.1-alpha3",
8226 + "0.5.1-alpha4",
8227 + "0.5.1-beta",
8228 + "0.5.1",
8229 + "0.5.5",
8230 + ],
8231 + );
8232 + assert_match_none(
8233 + r,
8234 + &["0.5.1-alpha1", "0.5.2-alpha3", "0.5.5-pre", "0.5.0-pre"],
8235 + );
8236 + assert_match_none(r, &["0.6.0", "0.6.0-pre"]);
8238 + // https://github.com/steveklabnik/semver/issues/56
8239 + let err = req_err("1.2.3 - 2.3.4");
8240 + assert_to_string(err, "expected comma after patch version number, found '-'");
8243 +#[test]
8244 +pub fn test_whitespace_delimited_comparator_sets() {
8245 + // https://github.com/steveklabnik/semver/issues/55
8246 + let err = req_err("> 0.0.9 <= 2.5.3");
8247 + assert_to_string(err, "expected comma after patch version number, found '<'");
8250 +#[test]
8251 +pub fn test_tilde() {
8252 + let ref r = req("~1");
8253 + assert_match_all(r, &["1.0.0", "1.0.1", "1.1.1"]);
8254 + assert_match_none(r, &["0.9.1", "2.9.0", "0.0.9"]);
8256 + let ref r = req("~1.2");
8257 + assert_match_all(r, &["1.2.0", "1.2.1"]);
8258 + assert_match_none(r, &["1.1.1", "1.3.0", "0.0.9"]);
8260 + let ref r = req("~1.2.2");
8261 + assert_match_all(r, &["1.2.2", "1.2.4"]);
8262 + assert_match_none(r, &["1.2.1", "1.9.0", "1.0.9", "2.0.1", "0.1.3"]);
8264 + let ref r = req("~1.2.3-beta.2");
8265 + assert_match_all(r, &["1.2.3", "1.2.4", "1.2.3-beta.2", "1.2.3-beta.4"]);
8266 + assert_match_none(r, &["1.3.3", "1.1.4", "1.2.3-beta.1", "1.2.4-beta.2"]);
8269 +#[test]
8270 +pub fn test_caret() {
8271 + let ref r = req("^1");
8272 + assert_match_all(r, &["1.1.2", "1.1.0", "1.2.1", "1.0.1"]);
8273 + assert_match_none(r, &["0.9.1", "2.9.0", "0.1.4"]);
8274 + assert_match_none(r, &["1.0.0-beta1", "0.1.0-alpha", "1.0.1-pre"]);
8276 + let ref r = req("^1.1");
8277 + assert_match_all(r, &["1.1.2", "1.1.0", "1.2.1"]);
8278 + assert_match_none(r, &["0.9.1", "2.9.0", "1.0.1", "0.1.4"]);
8280 + let ref r = req("^1.1.2");
8281 + assert_match_all(r, &["1.1.2", "1.1.4", "1.2.1"]);
8282 + assert_match_none(r, &["0.9.1", "2.9.0", "1.1.1", "0.0.1"]);
8283 + assert_match_none(r, &["1.1.2-alpha1", "1.1.3-alpha1", "2.9.0-alpha1"]);
8285 + let ref r = req("^0.1.2");
8286 + assert_match_all(r, &["0.1.2", "0.1.4"]);
8287 + assert_match_none(r, &["0.9.1", "2.9.0", "1.1.1", "0.0.1"]);
8288 + assert_match_none(r, &["0.1.2-beta", "0.1.3-alpha", "0.2.0-pre"]);
8290 + let ref r = req("^0.5.1-alpha3");
8291 + assert_match_all(
8292 + r,
8293 + &[
8294 + "0.5.1-alpha3",
8295 + "0.5.1-alpha4",
8296 + "0.5.1-beta",
8297 + "0.5.1",
8298 + "0.5.5",
8299 + ],
8300 + );
8301 + assert_match_none(
8302 + r,
8303 + &[
8304 + "0.5.1-alpha1",
8305 + "0.5.2-alpha3",
8306 + "0.5.5-pre",
8307 + "0.5.0-pre",
8308 + "0.6.0",
8309 + ],
8310 + );
8312 + let ref r = req("^0.0.2");
8313 + assert_match_all(r, &["0.0.2"]);
8314 + assert_match_none(r, &["0.9.1", "2.9.0", "1.1.1", "0.0.1", "0.1.4"]);
8316 + let ref r = req("^0.0");
8317 + assert_match_all(r, &["0.0.2", "0.0.0"]);
8318 + assert_match_none(r, &["0.9.1", "2.9.0", "1.1.1", "0.1.4"]);
8320 + let ref r = req("^0");
8321 + assert_match_all(r, &["0.9.1", "0.0.2", "0.0.0"]);
8322 + assert_match_none(r, &["2.9.0", "1.1.1"]);
8324 + let ref r = req("^1.4.2-beta.5");
8325 + assert_match_all(
8326 + r,
8327 + &["1.4.2", "1.4.3", "1.4.2-beta.5", "1.4.2-beta.6", "1.4.2-c"],
8328 + );
8329 + assert_match_none(
8330 + r,
8331 + &[
8332 + "0.9.9",
8333 + "2.0.0",
8334 + "1.4.2-alpha",
8335 + "1.4.2-beta.4",
8336 + "1.4.3-beta.5",
8337 + ],
8338 + );
8341 +#[test]
8342 +pub fn test_wildcard() {
8343 + let err = req_err("");
8344 + assert_to_string(
8345 + err,
8346 + "unexpected end of input while parsing major version number",
8347 + );
8349 + let ref r = req("*");
8350 + assert_match_all(r, &["0.9.1", "2.9.0", "0.0.9", "1.0.1", "1.1.1"]);
8351 + assert_match_none(r, &["1.0.0-pre"]);
8353 + for s in &["x", "X"] {
8354 + assert_eq!(*r, req(s));
8357 + let ref r = req("1.*");
8358 + assert_match_all(r, &["1.2.0", "1.2.1", "1.1.1", "1.3.0"]);
8359 + assert_match_none(r, &["0.0.9", "1.2.0-pre"]);
8361 + for s in &["1.x", "1.X", "1.*.*"] {
8362 + assert_eq!(*r, req(s));
8365 + let ref r = req("1.2.*");
8366 + assert_match_all(r, &["1.2.0", "1.2.2", "1.2.4"]);
8367 + assert_match_none(r, &["1.9.0", "1.0.9", "2.0.1", "0.1.3", "1.2.2-pre"]);
8369 + for s in &["1.2.x", "1.2.X"] {
8370 + assert_eq!(*r, req(s));
8374 +#[test]
8375 +pub fn test_logical_or() {
8376 + // https://github.com/steveklabnik/semver/issues/57
8377 + let err = req_err("=1.2.3 || =2.3.4");
8378 + assert_to_string(err, "expected comma after patch version number, found '|'");
8380 + let err = req_err("1.1 || =1.2.3");
8381 + assert_to_string(err, "expected comma after minor version number, found '|'");
8383 + let err = req_err("6.* || 8.* || >= 10.*");
8384 + assert_to_string(err, "expected comma after minor version number, found '|'");
8387 +#[test]
8388 +pub fn test_any() {
8389 + #[cfg(not(no_const_vec_new))]
8390 + let ref r = VersionReq::STAR;
8391 + #[cfg(no_const_vec_new)]
8392 + let ref r = VersionReq {
8393 + comparators: Vec::new(),
8394 + };
8395 + assert_match_all(r, &["0.0.1", "0.1.0", "1.0.0"]);
8398 +#[test]
8399 +pub fn test_pre() {
8400 + let ref r = req("=2.1.1-really.0");
8401 + assert_match_all(r, &["2.1.1-really.0"]);
8404 +#[test]
8405 +pub fn test_parse_errors() {
8406 + let err = req_err("\0");
8407 + assert_to_string(
8408 + err,
8409 + "unexpected character '\\0' while parsing major version number",
8410 + );
8412 + let err = req_err(">= >= 0.0.2");
8413 + assert_to_string(
8414 + err,
8415 + "unexpected character '>' while parsing major version number",
8416 + );
8418 + let err = req_err(">== 0.0.2");
8419 + assert_to_string(
8420 + err,
8421 + "unexpected character '=' while parsing major version number",
8422 + );
8424 + let err = req_err("a.0.0");
8425 + assert_to_string(
8426 + err,
8427 + "unexpected character 'a' while parsing major version number",
8428 + );
8430 + let err = req_err("1.0.0-");
8431 + assert_to_string(err, "empty identifier segment in pre-release identifier");
8433 + let err = req_err(">=");
8434 + assert_to_string(
8435 + err,
8436 + "unexpected end of input while parsing major version number",
8437 + );
8440 +#[test]
8441 +fn test_cargo3202() {
8442 + let ref r = req("0.*.*");
8443 + assert_to_string(r, "0.*");
8444 + assert_match_all(r, &["0.5.0"]);
8446 + let ref r = req("0.0.*");
8447 + assert_to_string(r, "0.0.*");
8450 +#[test]
8451 +fn test_digit_after_wildcard() {
8452 + let err = req_err("*.1");
8453 + assert_to_string(err, "unexpected character after wildcard in version req");
8455 + let err = req_err("1.*.1");
8456 + assert_to_string(err, "unexpected character after wildcard in version req");
8458 + let err = req_err(">=1.*.1");
8459 + assert_to_string(err, "unexpected character after wildcard in version req");
8462 +#[test]
8463 +fn test_eq_hash() {
8464 + fn calculate_hash(value: impl Hash) -> u64 {
8465 + let mut hasher = DefaultHasher::new();
8466 + value.hash(&mut hasher);
8467 + hasher.finish()
8470 + assert!(req("^1") == req("^1"));
8471 + assert!(calculate_hash(req("^1")) == calculate_hash(req("^1")));
8472 + assert!(req("^1") != req("^2"));
8475 +#[test]
8476 +fn test_leading_digit_in_pre_and_build() {
8477 + for op in &["=", ">", ">=", "<", "<=", "~", "^"] {
8478 + // digit then alpha
8479 + req(&format!("{} 1.2.3-1a", op));
8480 + req(&format!("{} 1.2.3+1a", op));
8482 + // digit then alpha (leading zero)
8483 + req(&format!("{} 1.2.3-01a", op));
8484 + req(&format!("{} 1.2.3+01", op));
8486 + // multiple
8487 + req(&format!("{} 1.2.3-1+1", op));
8488 + req(&format!("{} 1.2.3-1-1+1-1-1", op));
8489 + req(&format!("{} 1.2.3-1a+1a", op));
8490 + req(&format!("{} 1.2.3-1a-1a+1a-1a-1a", op));
8494 +#[test]
8495 +fn test_wildcard_and_another() {
8496 + let err = req_err("*, 0.20.0-any");
8497 + assert_to_string(
8498 + err,
8499 + "wildcard req (*) must be the only comparator in the version req",
8500 + );
8502 + let err = req_err("0.20.0-any, *");
8503 + assert_to_string(
8504 + err,
8505 + "wildcard req (*) must be the only comparator in the version req",
8506 + );
8508 + let err = req_err("0.20.0-any, *, 1.0");
8509 + assert_to_string(
8510 + err,
8511 + "wildcard req (*) must be the only comparator in the version req",
8512 + );
8514 diff --git a/third_party/rust/semver/tests/util/mod.rs b/third_party/rust/semver/tests/util/mod.rs
8515 new file mode 100644
8516 --- /dev/null
8517 +++ b/third_party/rust/semver/tests/util/mod.rs
8518 @@ -0,0 +1,39 @@
8519 +#![allow(dead_code)]
8521 +use semver::{BuildMetadata, Error, Prerelease, Version, VersionReq};
8522 +use std::fmt::Display;
8524 +#[cfg_attr(not(no_track_caller), track_caller)]
8525 +pub(super) fn version(text: &str) -> Version {
8526 + Version::parse(text).unwrap()
8529 +#[cfg_attr(not(no_track_caller), track_caller)]
8530 +pub(super) fn version_err(text: &str) -> Error {
8531 + Version::parse(text).unwrap_err()
8534 +#[cfg_attr(not(no_track_caller), track_caller)]
8535 +pub(super) fn req(text: &str) -> VersionReq {
8536 + VersionReq::parse(text).unwrap()
8539 +#[cfg_attr(not(no_track_caller), track_caller)]
8540 +pub(super) fn req_err(text: &str) -> Error {
8541 + VersionReq::parse(text).unwrap_err()
8544 +#[cfg_attr(not(no_track_caller), track_caller)]
8545 +pub(super) fn prerelease(text: &str) -> Prerelease {
8546 + Prerelease::new(text).unwrap()
8549 +#[cfg_attr(not(no_track_caller), track_caller)]
8550 +pub(super) fn build_metadata(text: &str) -> BuildMetadata {
8551 + BuildMetadata::new(text).unwrap()
8554 +#[cfg_attr(not(no_track_caller), track_caller)]
8555 +pub(super) fn assert_to_string(value: impl Display, expected: &str) {
8556 + assert_eq!(value.to_string(), expected);
8558 diff --git a/toolkit/library/rust/shared/Cargo.toml b/toolkit/library/rust/shared/Cargo.toml
8559 --- a/toolkit/library/rust/shared/Cargo.toml
8560 +++ b/toolkit/library/rust/shared/Cargo.toml
8561 @@ -16,17 +16,17 @@ nsstring = { path = "../../../../xpcom/r
8562 netwerk_helper = { path = "../../../../netwerk/base/rust-helper" }
8563 xpcom = { path = "../../../../xpcom/rust/xpcom" }
8564 prefs_parser = { path = "../../../../modules/libpref/parser" }
8565 static_prefs = { path = "../../../../modules/libpref/init/static_prefs" }
8566 profiler_helper = { path = "../../../../tools/profiler/rust-helper", optional = true }
8567 mozurl = { path = "../../../../netwerk/base/mozurl" }
8568 webrender_bindings = { path = "../../../../gfx/webrender_bindings" }
8569 cubeb-coreaudio = { git = "https://github.com/mozilla/cubeb-coreaudio-rs", rev = "44eca95823bb57e964cf7b6d9791ed2ccb4b2108", optional = true }
8570 -cubeb-pulse = { git = "https://github.com/mozilla/cubeb-pulse-rs", rev="df4dc0288b07b865440f4c7e41ca49ca9ccffc63", optional = true, features=["pulse-dlopen"] }
8571 +cubeb-pulse = { git = "https://github.com/mozilla/cubeb-pulse-rs", rev="1f1fe1e08e01a9a534ec7f079702a583a0899ce7", optional = true, features=["pulse-dlopen"] }
8572 cubeb-sys = { version = "0.10", optional = true, features=["gecko-in-tree"] }
8573 audioipc2-client = { git = "https://github.com/kinetiknz/audioipc-2", rev = "85e9839059f4bf8f68130825b8fd02c39a6a51b9", optional = true } # macos (v2) branch
8574 audioipc2-server = { git = "https://github.com/kinetiknz/audioipc-2", rev = "85e9839059f4bf8f68130825b8fd02c39a6a51b9", optional = true } # macos (v2) branch
8575 audioipc-client = { git = "https://github.com/mozilla/audioipc-2", rev = "c144368c4e084ec0f076af6262970655c2d99e8d", optional = true }
8576 audioipc-server = { git = "https://github.com/mozilla/audioipc-2", rev = "c144368c4e084ec0f076af6262970655c2d99e8d", optional = true }
8577 encoding_glue = { path = "../../../../intl/encoding_glue" }
8578 authenticator = "0.3.1"
8579 gkrust_utils = { path = "../../../../xpcom/rust/gkrust_utils" }
8580 diff --git a/xpcom/rust/gkrust_utils/Cargo.toml b/xpcom/rust/gkrust_utils/Cargo.toml
8581 --- a/xpcom/rust/gkrust_utils/Cargo.toml
8582 +++ b/xpcom/rust/gkrust_utils/Cargo.toml
8583 @@ -1,8 +1,8 @@
8584 [package]
8585 name = "gkrust_utils"
8586 version = "0.1.0"
8587 authors = ["Jonathan Kingston <jkt@mozilla.com>"]
8589 [dependencies]
8590 -semver = "0.9"
8591 +semver = "1.0"
8592 nsstring = { path = "../nsstring" }
8594 diff --git a/third_party/rust/packed_simd_2/Cargo.toml b/third_party/rust/packed_simd_2/Cargo.toml
8595 --- a/third_party/rust/packed_simd_2/Cargo.toml
8596 +++ b/third_party/rust/packed_simd_2/Cargo.toml
8597 @@ -24,7 +24,7 @@ codecov = { repository = "rust-lang/pack
8598 core_arch = { version = "0.1.5", optional = true }
8600 [build-dependencies]
8601 -rustc_version = "0.2"
8602 +rustc_version = "0.4"
8604 [features]
8605 default = []
8606 diff --git a/third_party/rust/packed_simd_2/.cargo-checksum.json b/third_party/rust/packed_simd_2/.cargo-checksum.json
8607 --- a/third_party/rust/packed_simd_2/.cargo-checksum.json
8608 +++ b/third_party/rust/packed_simd_2/.cargo-checksum.json
8609 @@ -1,1 +1,1 @@
8610 -{"files":{".appveyor.yml":"f1ed01850e0d725f9498f52a1a63ddf40702ad6e0bf5b2d7c4c04d76e96794a3",".travis.yml":"30a61a5ec53355fc1f3585e1690280308c2b7961701abc11e8389b235b647178","Cargo.toml":"e76b42f3247fccb7174046c499bfaae5430d83cadeb8140259fcae34613483cf","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"6485b8ed310d3f0340bf1ad1f47645069ce4069dcc6bb46c7d5c6faf41de1fdb","README.md":"fa4dd64f66972217d35b7653338c9e2011ccd8f3008ae7c0103272d4287f9b1d","bors.toml":"dee881dc69b9b7834e4eba5d95c3ed5a416d4628815a167d6a22d4cb4fb064b8","build.rs":"a766fba121243a9b617432c592873801adb74c3a2f4a24d9d45859b8ce9357fc","ci/all.sh":"2ae6b2445b4db83833e40b37efd0016c6b9879ee988b9b3ef94db5439a3e1606","ci/android-install-ndk.sh":"0f1746108cc30bf9b9ba45bcde7b19fc1a8bdf5b0258035b4eb8dc69b75efac4","ci/android-install-sdk.sh":"3490432022c5c8f5a115c084f7a9aca1626f96c0c87ffb62019228c4346b47e4","ci/android-sysimage.sh":"ebf4e5daa1f0fe1b2092b79f0f3f161c4c4275cb744e52352c4d81ab451e4c5a","ci/benchmark.sh":"b61d19ef6b90deba8fb79dee74c8b062d94844676293da346da87bb78a9a49a4","ci/deploy_and_run_on_ios_simulator.rs":"ec8ecf82d92072676aa47f0d1a3d021b60a7ae3531153ef12d2ff4541fc294dc","ci/docker/aarch64-linux-android/Dockerfile":"ace2e7d33c87bc0f6d3962a4a3408c04557646f7f51ab99cfbf574906796b016","ci/docker/aarch64-unknown-linux-gnu/Dockerfile":"da88c0d50f16dc08448c7fdf1fa5ed2cbe576acf9e7dd85b5b818621b2a8c702","ci/docker/arm-linux-androideabi/Dockerfile":"370e55d3330a413a3ccf677b3afb3e0ef9018a5fab263faa97ae8ac017fc2286","ci/docker/arm-unknown-linux-gnueabi/Dockerfile":"bb5f8ae890707c128652290ffc544447643bf12037ddd73c6ad6989f848cb380","ci/docker/arm-unknown-linux-gnueabihf/Dockerfile":"1afaefcbc05b740859acd4e067bc92439be6bcbe8f2e9678474fb434bcd398d9","ci/docker/armv7-unknown-linux-gnueabihf/Dockerfile":"8282ea707a94109beed47a57574755e2d58401735904a03f85fb64c578c53b4f","ci/docker/i586-unknown-linux-gnu/Dockerfile":"49792922269f371bd29da4727e9085101b27be67a6b97755d0196c63317f7abb","ci/docker/i686-unknown-linux-gnu/Dockerfile":"49792922269f371bd29da4727e9085101b27be67a6b97755d0196c63317f7abb","ci/docker/mips-unknown-linux-gnu/Dockerfile":"b2ebc25797612c4f8395fe9d407725156044955bfbcf442036b7f55b43a5f9da","ci/docker/mips64-unknown-linux-gnuabi64/Dockerfile":"b0c1692ac65bc56dd30494b1993d8e929c48cc9c4b92029b7c7592af6d4f9220","ci/docker/mips64el-unknown-linux-gnuabi64/Dockerfile":"4e9249c179300138141d0b2b7401b11897f64aed69f541f078c1db4594df2827","ci/docker/mipsel-unknown-linux-musl/Dockerfile":"3164c52b0dcbb01afa78292b15b5c43503ccf0491cf6eb801ec2bf22ae274e52","ci/docker/powerpc-unknown-linux-gnu/Dockerfile":"786f799d0b56eb54d7b6c4b00e1aed4ce81776e14e44767e083c89d014b72004","ci/docker/powerpc64-unknown-linux-gnu/Dockerfile":"e8bc363837cd9c2d8b22402acb8c1c329efc11ba5d12170603d2fe2eae9da059","ci/docker/powerpc64le-unknown-linux-gnu/Dockerfile":"47998d45b781d797b9e6085ebe898d90de0c952b54537a8db4e8d7503eb032d9","ci/docker/s390x-unknown-linux-gnu/Dockerfile":"93fb44df3d7fd31ead158570667c97b5076a05c3d968af4a84bc13819a8f2db8","ci/docker/sparc64-unknown-linux-gnu/Dockerfile":"da1c39a3ff1fe22e41395fa7c8934e90b4c1788e551b9aec6e38bfd94effc437","ci/docker/thumbv7neon-linux-androideabi/Dockerfile":"c2decd5591bd7a09378901bef629cd944acf052eb55e4f35b79eb9cb4d62246a","ci/docker/thumbv7neon-unknown-linux-gnueabihf/Dockerfile":"51955a8bf3c4d440f47382af6f5426ebff94ab01a04da36175babda9a057740f","ci/docker/wasm32-unknown-unknown/Dockerfile":"5a022299f56730cf8c432a07391e95e199cfa36dc8da2a96c9d185c8de93e913","ci/docker/x86_64-linux-android/Dockerfile":"685040273cf350d5509e580ac451555efa19790c8723ca2af066adadc6880ad2","ci/docker/x86_64-unknown-linux-gnu-emulated/Dockerfile":"44b6203d9290bfdc53d81219f0937e1110847a23dd982ec8c4de388354f01536","ci/docker/x86_64-unknown-linux-gnu/Dockerfile":"7f4e3ca5fa288ea70edb4d1f75309708cd30b192e2e4444e61c4d5b3b58f89cf","ci/dox.sh":"434e9611c52e389312d2b03564adf09429f10cc76fe66a8644adb104903b87b7","ci/linux-s390x.sh":"d6b732d7795b4ba131326aff893bca6228a7d2eb0e9402f135705413dbbe0dce","ci/linux-sparc64.sh":"c92966838b1ab7ad3b7a344833ee726aba6b647cf5952e56f0ad1ba420b13325","ci/lld-shim.rs":"3d7f71ec23a49e2b67f694a0168786f9a954dda15f5a138815d966643fd3fcc3","ci/max_line_width.sh":"0a1518bba4c9ecaa55694cb2e9930d0e19c265baabf73143f17f9cf285aaa5bb","ci/run-docker.sh":"92e036390ad9b0d16f109579df1b5ced2e72e9afea40c7d011400ebd3a2a90de","ci/run.sh":"41dd6a60efaaeae9661a01370cce98b631f78392859a0cf68c946c0a16edf5f7","ci/run_examples.sh":"d1a23c6c35374a0678ba5114b9b8fefd8be0a79e774872a8bf0898d1baca18d0","ci/runtest-android.rs":"145a8e9799a5223975061fe7e586ade5669ee4877a7d7a4cf6b4ab48e8e36c7c","ci/setup_benchmarks.sh":"fae3960023f6f3d1388cd2ad22fdbab4b075f1f29dd4292d7994a20783beb6cf","ci/test-runner-linux":"c8aa6025cff5306f4f31d0c61dc5f9d4dd5a1d189ab613ef8d4c367c694d9ccd","contributing.md":"2d2629310ad4d464c482bdbb5819f0d6ce223c576aeef2cdce6a1f6857085ea5","perf-guide/.gitignore":"fe82c7da551079d832cf74200b0b359b4df9828cb4a0416fa7384f07a2ae6a13","perf-guide/book.toml":"115a98284126c6b180178b44713314cc494f08a71662ee2ce15cf67f17a51064","perf-guide/src/SUMMARY.md":"3e03bffc991fdc2050f3d51842d72d9d21ea6abab56a3baf3b2d5973a78b89e1","perf-guide/src/ascii.css":"29afb08833b2fe2250f0412e1fa1161a2432a0820a14953c87124407417c741a","perf-guide/src/bound_checks.md":"5e4991ff58a183ef0cd9fdc1feb4cd12d083b44bdf87393bbb0927808ef3ce7d","perf-guide/src/float-math/approx.md":"8c09032fa2d795a0c5db1775826c850d28eb2627846d0965c60ee72de63735ad","perf-guide/src/float-math/fma.md":"311076ba4b741d604a82e74b83a8d7e8c318fcbd7f64c4392d1cf5af95c60243","perf-guide/src/float-math/fp.md":"04153e775ab6e4f0d7837bcc515230d327b04edfa34c84ce9c9e10ebaeef2be8","perf-guide/src/float-math/svml.md":"0798873b8eedaeda5fed62dc91645b57c20775a02d3cd74d8bd06958f1516506","perf-guide/src/introduction.md":"9f5a19e9e6751f25d2daad39891a0cc600974527ec4c8305843f9618910671bd","perf-guide/src/prof/linux.md":"447731eb5de7d69166728fdbc5ecb0c0c9db678ea493b45a592d67dd002184c0","perf-guide/src/prof/mca.md":"f56d54f3d20e7aa4d32052186e8237b03d65971eb5d112802b442570ff11d344","perf-guide/src/prof/profiling.md":"8a650c0fd6ede0964789bb6577557eeef1d8226a896788602ce61528e260e43c","perf-guide/src/target-feature/attribute.md":"615f88dca0a707b6c416fa605435dd6e1fb5361cc639429cbf68cd87624bd78b","perf-guide/src/target-feature/features.md":"17077760ff24c006b606dd21889c53d87228f4311f3ba3a574f9afdeacd86165","perf-guide/src/target-feature/inlining.md":"7ed1d7068d8173a00d84c16cfe5871cd68b9f04f8d0cca2d01ebc84957ebf2f6","perf-guide/src/target-feature/practice.md":"c4b371842e0086df178488fec97f20def8f0c62ee588bcd25fd948b9b1fa227e","perf-guide/src/target-feature/runtime.md":"835425f5ee597fb3e51d36e725a81ebee29f4561231d19563cd4da81dbb1cfcb","perf-guide/src/target-feature/rustflags.md":"01197acf6f0adec8db32b8591811f69cecb6555a2b05dc5d5ec27d0e3f7b065e","perf-guide/src/vert-hor-ops.md":"c6211c0ee91e60552ec592d89d9d957eedc21dee3cbd89e1ad6765ea06a27471","rustfmt.toml":"d99a43f3f8ef9e425cf01c333fba9f0051f888f5d87ab4e8f63c2f7d0fe6620f","src/api.rs":"bb1795e9657a8298d37d2349b45443f08e9e455399ad4b727018600728478c10","src/api/bit_manip.rs":"c47a4d0f7451f7e35d07715e4f39a472e07457fd456fdb726864a4f6887252a3","src/api/bitmask.rs":"6d2beefd62ee5d9c8eb060bee6abc641616bf828c99f82abf97b21bf004e894b","src/api/cast.rs":"03b94a3d316ac7b7be7068810044911e965e889a0ace7bae762749ca74a92747","src/api/cast/macros.rs":"b0a14d0c83ad2ebb7a275180f6d9e3f2bc312ba57a7d3d6c39fad4e0f20f9408","src/api/cast/v128.rs":"edd0994efac4379dff26e178423a52dbb3ffeb38b1fc97cae975d744c00b4fb6","src/api/cast/v16.rs":"96bd98c2d21b0663abe6c0ab33005b1fa693f3db7ee6795351391343863484da","src/api/cast/v256.rs":"8c31fe91f5e78ef737dfba6979cc1240210cb094a89d284fe459bf8a991ca24b","src/api/cast/v32.rs":"a99a79dd84d2a5e6adf9db98705675915bd03fd1287d489c7fe38e84d7e4a086","src/api/cast/v512.rs":"c0dd526f41ed7b8a71c3743d91267554ec0a0c75834ccc2e3ecb0ef3004af642","src/api/cast/v64.rs":"6572fdba2a1241a6cd666d3f0cce3306cd2cb7e5e236172e59d5d4351c8a88af","src/api/cmp.rs":"357c3a2a09c6d4611c32dd7fa95be2fae933d513e229026ec9b44451a77b884e","src/api/cmp/eq.rs":"60f70f355bae4cb5b17db53204cacc3890f70670611c17df638d4c04f7cc8075","src/api/cmp/ord.rs":"589f7234761c294fa5df8f525bc4acd5a47cdb602207d524a0d4e19804cd9695","src/api/cmp/partial_eq.rs":"902ccb8aa01fd5738b30ba0b712669c21d4801958907e03bad23432c7dba0198","src/api/cmp/partial_ord.rs":"9db0c37d7434cdfc62d8d66912e972fa3d8c115ab2af051a6f45e414bd3e4f1c","src/api/cmp/vertical.rs":"de3d62f38eba817299aa16f1e1939954c9a447e316509397465c2830852ba053","src/api/default.rs":"67bf21c134127d12a7028c8b88a57f0ceee8ccbd74976da8ca74eb9f16a174d5","src/api/fmt.rs":"67fb804bb86b6cd77cf8cd492b5733ce437071b66fe3297278b8a6552c325dda","src/api/fmt/binary.rs":"02b2b287f7404f8a983813cf70c87108c8da3835578b63ab303116885f609413","src/api/fmt/debug.rs":"56e1c3bdc092747344fffaafff9da7163ee7827857f6fb7cb1c9923eca4f6fa0","src/api/fmt/lower_hex.rs":"558fd592f7f485712fb051509cecc7174a21e6bf62e5ce64766e75afc97bb8e1","src/api/fmt/octal.rs":"3b2e70877a4f368c7704f8e254236c014c365c74d93371c1feb5f030e6c66422","src/api/fmt/upper_hex.rs":"2a442f666bc80e22d41f903f881238fe114dd49344c3ed69849250e853cafc5d","src/api/from.rs":"2e599d8329cb05eaf06224cc441355c4b7b51254fc19256619333be8c149d444","src/api/from/from_array.rs":"dd3fc64fb17d6184bb60343f8da26a05edf0e5f3c14caf55d49fa15e21d948dc","src/api/from/from_vector.rs":"9764371aa9e6005aace74dea14f59e5611a095b7cf42707940924749282c52f0","src/api/hash.rs":"5076ece87969592c876486f5b1ea8affbeaec379d1a14a30859e0aa5592019de","src/api/into_bits.rs":"1ee15923352786b9ab4a31fa506762297116b18cfdb8e72853abc8ad001651d2","src/api/into_bits/arch_specific.rs":"e7445021f3908326bfee758835e5fc5ad56aa1baa77fc1c58abe4350c66c670a","src/api/into_bits/macros.rs":"bb4fe99be2af6a21d805efab44c8e4e61a7b2adb42a65504a0cf26d13efdadcd","src/api/into_bits/v128.rs":"145a44922b09a5ca5b62d88a461d327d399a997a15db4b11d7b17e554a9fa4c0","src/api/into_bits/v16.rs":"f4f4f61ba88aa51b158ec56ca3dce234349aea0daf2b3029a14ab5125d1e41e5","src/api/into_bits/v256.rs":"8cea9c5d9809f11323cb7cdc53b83df593fd17caf926251e412ae9777bed547f","src/api/into_bits/v32.rs":"905ba683d342fa32f4202b80bb46530807bd0a5b588f6c2e8c9f475223c47775","src/api/into_bits/v512.rs":"e25afa1fbf088a5d58e7d75d197b6cd4c56637ea28542ba18e46a451f29d04e7","src/api/into_bits/v64.rs":"d6238022ccff7b92e55b3f6017fc269acb6f36330a6d7e8fb389853a0f1b6478","src/api/math.rs":"8b2a2fc651917a850539f993aa0b9e5bf4da67b11685285b8de8cdca311719ec","src/api/math/float.rs":"61d2794d68262a1090ae473bd30793b5f65cf732f32a6694a3af2ce5d9225616","src/api/math/float/abs.rs":"5b6b2701e2e11135b7ce58a05052ea8120e10e4702c95d046b9d21b827b26bf8","src/api/math/float/consts.rs":"6302c9261da4291d144d5bb53493cdd073498feb40955fb6860ea3c4d06c978a","src/api/math/float/cos.rs":"4c2dd7173728ef189314f1576c9486e03be21b7da98843b2f9011282a7979e31","src/api/math/float/exp.rs":"7c6d5f1e304f498a01cfa23b92380c815d7da0ad94eae3483783bc377d287eef","src/api/math/float/ln.rs":"54c7583f3df793b39ff57534fade27b41bb992439e5dc178252f5ca3190a3e54","src/api/math/float/mul_add.rs":"62cac77660d20159276d4c9ef066eb90c81cbddb808e8e157182c607625ad2eb","src/api/math/float/mul_adde.rs":"bae056ee9f3a70df39ec3c3b2f6437c65303888a7b843ef1a5bcf1f5aca0e602","src/api/math/float/powf.rs":"9ddb938984b36d39d82a82f862f80df8f7fb013f1d222d45698d41d88472f568","src/api/math/float/recpre.rs":"589225794ff1dbf31158dff660e6d4509ecc8befbb57c633900dea5ac0b840d6","src/api/math/float/rsqrte.rs":"a32abdcc318d7ccc8448231f54d75b884b7cbeb03a7d595713ab6243036f4dbf","src/api/math/float/sin.rs":"cbd3622b7df74f19691743001c8cf747a201f8977ad90542fee915f37dcd1e49","src/api/math/float/sqrt.rs":"0c66d5d63fb08e4d99c6b82a8828e41173aff1ac9fa1a2764a11fac217ccf2ac","src/api/math/float/sqrte.rs":"731e1c9f321b662accdd27dacb3aac2e8043b7aecb2f2161dde733bd9f025362","src/api/minimal.rs":"1f22bcc528555444e76de569ec0ae2029b9ae9d04805efeafa93369c8098036b","src/api/minimal/iuf.rs":"819cff26d3e196f807645bcc1d79eb27d9f175edb89910f2274d52a1e913cd11","src/api/minimal/mask.rs":"0cae10ae1fc65f5070e686c0c79bfba27b86b33d6c399367bd4848fb367dcec4","src/api/minimal/ptr.rs":"f65ebf21866a863485344432d9a7a9b7418f7fad5fdf841a4e2fa56ec0766ad0","src/api/ops.rs":"3e273b277a0f3019d42c3c59ca94a5afd4885d5ae6d2182e5089bbeec9de42ee","src/api/ops/scalar_arithmetic.rs":"d2d5ad897a59dd0787544f927e0e7ca4072c3e58b0f4a2324083312b0d5a21d7","src/api/ops/scalar_bitwise.rs":"482204e459ca6be79568e1c9f70adbe2d2151412ddf122fb2161be8ebb51c40c","src/api/ops/scalar_mask_bitwise.rs":"c250f52042e37b22d57256c80d4604104cfd2fbe2a2e127c676267270ca5d350","src/api/ops/scalar_shifts.rs":"c4773d435c3f9da4454327e6fbb2b5b41a1c0ebb1cca7372e69dc7a344a1b6e4","src/api/ops/vector_arithmetic.rs":"ddca15d09ddeef502c2ed66117a62300ca65d87e959e8b622d767bdf1c307910","src/api/ops/vector_bitwise.rs":"b3968f7005b649edcc22a54e2379b14d5ee19045f2e784029805781ae043b5ee","src/api/ops/vector_float_min_max.rs":"76bf8cb607e2c442923c1da1061a6b80d742d607408033c2a3761161114cf2a0","src/api/ops/vector_int_min_max.rs":"a378789c6ff9b32a51fbd0a97ffd36ed102cd1fe6a067d2b02017c1df342def6","src/api/ops/vector_mask_bitwise.rs":"5052d18517d765415d40327e6e8e55a312daaca0a5e2aec959bfa54b1675f9c8","src/api/ops/vector_neg.rs":"5c62f6b0221983cdbd23cd0a3af3672e6ba1255f0dfe8b19aae6fbd6503e231b","src/api/ops/vector_rotates.rs":"ee319eaaa449dc50ea8ef05b89d38519c6faa6753dfdce432ea7bb8520e4e8e7","src/api/ops/vector_shifts.rs":"e510be14127c0ffd58a2573a39701da3557d66bedec09837ac8bbd44d579da00","src/api/ptr.rs":"8a793251bed6130dcfb2f1519ceaa18b751bbb15875928d0fb6deb5a5e07523a","src/api/ptr/gather_scatter.rs":"3d614f9d5b4ca201a9f7e46af4405e1d2c28ecee1620297c23b52e37b92cc0ea","src/api/reductions.rs":"ae5baca81352ecd44526d6c30c0a1feeda475ec73ddd3c3ec6b14e944e5448ee","src/api/reductions/bitwise.rs":"8bf910ae226188bd15fc7e125f058cd2566b6186fcd0cd8fd020f352c39ce139","src/api/reductions/float_arithmetic.rs":"47a5679896db2cbb56c31372fe42143da015b6beae7db5d2f3a0309ddf427ae1","src/api/reductions/integer_arithmetic.rs":"c2df3cf7493cca4174f2c65aea422a3d20d8a23af03f8d57cef72c19fee8f20d","src/api/reductions/mask.rs":"db83327a950e33a317f37fd33ca4e20c347fb415975ec024f3e23da8509425af","src/api/reductions/min_max.rs":"6af8c9aa45c69961b1b6fc205395f4767d4421869fb105fb3d563c5605fc13cd","src/api/select.rs":"6b07e7e8026df561f7307221a896f0fbb272536f41b9109040ac094c24c69331","src/api/shuffle.rs":"26458aec2557bfab41b7765f72aefbff3a7ee08cdc689981a81f133f58ee368b","src/api/shuffle1_dyn.rs":"bfea5a91905b31444e9ef7ca6eddb7a9606b7e22d3f71bb842eb2795a0346620","src/api/slice.rs":"ee87484e8af329547b9a5d4f2a69e8bed6ea10bbd96270d706083843d4eea2ac","src/api/slice/from_slice.rs":"9b6f01ace2d12ef45c84608bb7aad3a122e2cc319b2d99170fc332a568b8de63","src/api/slice/write_to_slice.rs":"244b6bd6ccffa6e5a195f8b1abc66d94251b6d16b2ec3fe4d76d32caec68261e","src/api/swap_bytes.rs":"4a6792a2e49a77475e1b237592b4b2804dbddb79c474331acd0dd71b36934259","src/codegen.rs":"db4f232fb9f5728db310b87dc8c4733be48afacab1053798c06106bef9a42b05","src/codegen/bit_manip.rs":"525ea6ff7ad1e043b6f6136992166f1803ed5563b7f6fc292c1c40257d20e264","src/codegen/llvm.rs":"b4ccbc0bad90038f00fc3c158736462d01d0053df3afa00f9169e67d1a264444","src/codegen/math.rs":"dfcf02ad34e2fdfe22c3f1cc2822001cc895e65031b4d06e585e5047839febb7","src/codegen/math/float.rs":"2c1cbce155bc527ce34d472c0fef6bc3dadb79cd7a357dd7aa5b1ebeb1d77a13","src/codegen/math/float/abs.rs":"d5aaadcf540bdb9b4264dca6471a255fd7bf509e763bef0239c0144a68466fea","src/codegen/math/float/cos.rs":"17f28d2900c852dca221fa9c92a9cd5fe7fd2df8d427bbc60216c749b2be013d","src/codegen/math/float/cos_pi.rs":"dbaf9f443f9846a491d4ec52210a7b5835dd593b03366e3135b05c37d70f9d6c","src/codegen/math/float/exp.rs":"d300058a4bcc7ae7976f216f81902cd73a9e603ad63880dff3bbc866c27a9f37","src/codegen/math/float/ln.rs":"c851e211e43f8256093ba75b03ae0c307c9962ee66d94f09b4dd80068190cbdf","src/codegen/math/float/macros.rs":"fc9924869ed85e4795983af228cacf23158f4f35919adce16c920ad4a3f0a009","src/codegen/math/float/mul_add.rs":"041a5b69d5991d93ef795351b17560c10faf80b78fd26ad7df42a239b32cf9de","src/codegen/math/float/mul_adde.rs":"d71d5f0f3333b62a7439b823cb7adf5340ea1555ce820fb4a3f4cb922f73f5f5","src/codegen/math/float/powf.rs":"9742c3877f1a5509ca5c9492a40884b6579ba6dd11c26b7112e63f70666b395d","src/codegen/math/float/sin.rs":"0e9868d35531566509f3a01d85d5253045eb4afa8525d8407dcc1f5f33c56036","src/codegen/math/float/sin_cos_pi.rs":"8e6b6142d7dd240cdb36669722e82ab9810a2261e86e659f7d97a942ad8b1258","src/codegen/math/float/sin_pi.rs":"bb6d39db8f921e03a301fc5206ac1a61a97def8a2cb83b87ccf189f3fc48d548","src/codegen/math/float/sqrt.rs":"e6ebb0c5f428efad1f672b9a8fe4e58534dbf1ea5a8fe092ce5ce76b52fe89cb","src/codegen/math/float/sqrte.rs":"23acfaea38d0e081a6d9021c1094e813d0cfd12c58c1eca9662aade5e625d51c","src/codegen/pointer_sized_int.rs":"6ca13c214b6cf7e0929dbe18e96a16fc0bb7d8799608df29c4c8115490f99e01","src/codegen/reductions.rs":"8eb18ebac76985d2aa30262a2edd8cb004230b511a765d657525f677a585c12c","src/codegen/reductions/mask.rs":"e67f35a1f4d156a4894a2d6ea5a935b4d898cf70eefb2715f5c1cc165e776c11","src/codegen/reductions/mask/aarch64.rs":"84b101c17cad1ede4eb6d38cada0ac7da239dba8cea3badd3829b967e558431f","src/codegen/reductions/mask/arm.rs":"aaa07129bd078ae7e677cf8b8e67ec9f30536606a0c7ed1baaa18fd1793bb218","src/codegen/reductions/mask/fallback.rs":"3eb9319d2c7cf19216b607b8459612c4e027b643cf11b036937d36896bf76786","src/codegen/reductions/mask/fallback_impl.rs":"76547f396e55ef403327c77c314cf8db8c7a5c9b9819bfb925abeacf130249e5","src/codegen/reductions/mask/x86.rs":"36dcd8af4ab99730a078ed113d3955f74eb1a2876e2e6d9f224e0ff462c216d1","src/codegen/reductions/mask/x86/avx.rs":"3a40868b38c86e35aefb96d7578de6322efe89d8135e0366359b54ddd06f861a","src/codegen/reductions/mask/x86/avx2.rs":"677aed3f056285285daa3adff8bc65e739630b4424defa6d9665e160f027507e","src/codegen/reductions/mask/x86/sse.rs":"8522f6ed03f6c32dd577d4298df477c08aeaaa38563706f29096e1911ed731f2","src/codegen/reductions/mask/x86/sse2.rs":"54ec56e49b0c6841eccb719e4f310d65fe767c04136b2ec20bd8b9d7d9897b9e","src/codegen/shuffle.rs":"1ec2930f4e1acc43ac30b518af298d466a79e9e75734a51c380b7810efd1a27f","src/codegen/shuffle1_dyn.rs":"3f13ca1597378758d05106bf5ff3715eee531f3cb6d88f48b9182bd6c9386b51","src/codegen/swap_bytes.rs":"c67c86e91ca3fc77539e0efcea081a3c62548cccf503963ae408f2e86f4e6a21","src/codegen/v128.rs":"94226b31ec403d18d9d2fe06713f147c9c79e9b5f9105089088266313f843185","src/codegen/v16.rs":"ddec4ffb66b6f7aaffb9a1780c5ddba82557abd74f45073d335047e04cf74924","src/codegen/v256.rs":"6b63917f0444118d6b1595bff2045e59b97c4d24012bd575f69f1f0efc5a0241","src/codegen/v32.rs":"3477b3c5540aed86e61e2f5807dd31db947413cec9181c587d93ed6ec74f0eba","src/codegen/v512.rs":"5854f99d3aabc4cd42b28a20d9ce447756dc2ba024a409a69b6a8ae1f1842fc5","src/codegen/v64.rs":"e9e89caebfe63d10c0cbca61e4dfdba3b7e02ee0989170f80beed23237ddd950","src/codegen/vPtr.rs":"f0753b405cdc865bdf8e82c6505f299ea1f96136239ebbaf7f9ce93d310764b8","src/codegen/vSize.rs":"c89f5fdeb28ac4c8272ed1816fce03d9d95308cc32bb2533bd8b20cd5ac102ac","src/lib.rs":"b6f846d5d30cf6b035a2d18039aba7b2045cf89384733d643572bd68873ae064","src/masks.rs":"70fc0abe4c2907ce2a491c574e1cfb9f3423385da2e1a923a48c9c13f8ba6ed8","src/sealed.rs":"ae7fdeaf5d84cd7710ed730ca72ca7eaba93df6cb0acb183e5c0a7327acf197f","src/testing.rs":"896669c08d8c801448a4d2fadc9d633eda0fbe879d229997e2a182e31278e469","src/testing/macros.rs":"403bbc5ecb7c786fe36156df302d0c07a8122408dbb15f7474d7682224ba1106","src/testing/utils.rs":"41912a92266dfe884647fc035e4242fd746100df8e839808ae0397af3759a3c8","src/v128.rs":"16cf9a8e7156b899ee9b9cd3f2dba9d13ec63289bea8c3ee9ae2e43ad9510288","src/v16.rs":"cb6465cf1e00bf530183af1819b9fe3d7eec978f8765d5e85d9b58a39a4b4045","src/v256.rs":"fe235017da18c7f3c361831c60e3173ad304d8ea1e95d64ebebc79da2d708511","src/v32.rs":"145d347855bac59b2de6508f9e594654e6c330423af9edc0e2ac8f4d1abdf45e","src/v512.rs":"f372f277f3e62eb5c945bb1c460333fdb17b6974fcc876633788ff53bded9599","src/v64.rs":"0b8079881b71575e3414be0b7f8f7eaba65281ba6732f2b2f61f73e95b6f48f7","src/vPtr.rs":"8b3e433d487180bb4304ff71245ecad90f0010f43e139a72027b672abe58facc","src/vSize.rs":"eda5aa020706cbf94d15bada41a0c2a35fc8f3f37cb7c2cd6f34d201399a495e","tests/endianness.rs":"2783d727e8ff8789211e03120634cd3ad9f8972fc484012681b5b63cf89408a7"},"package":null}
8611 \ No newline at end of file
8612 +{"files":{".appveyor.yml":"f1ed01850e0d725f9498f52a1a63ddf40702ad6e0bf5b2d7c4c04d76e96794a3",".travis.yml":"30a61a5ec53355fc1f3585e1690280308c2b7961701abc11e8389b235b647178","Cargo.toml":"2cab084b3d55d0b307788b02a6206a3ec39fee027535dc62d6421bce70e2e2c1","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"6485b8ed310d3f0340bf1ad1f47645069ce4069dcc6bb46c7d5c6faf41de1fdb","README.md":"fa4dd64f66972217d35b7653338c9e2011ccd8f3008ae7c0103272d4287f9b1d","bors.toml":"dee881dc69b9b7834e4eba5d95c3ed5a416d4628815a167d6a22d4cb4fb064b8","build.rs":"a766fba121243a9b617432c592873801adb74c3a2f4a24d9d45859b8ce9357fc","ci/all.sh":"2ae6b2445b4db83833e40b37efd0016c6b9879ee988b9b3ef94db5439a3e1606","ci/android-install-ndk.sh":"0f1746108cc30bf9b9ba45bcde7b19fc1a8bdf5b0258035b4eb8dc69b75efac4","ci/android-install-sdk.sh":"3490432022c5c8f5a115c084f7a9aca1626f96c0c87ffb62019228c4346b47e4","ci/android-sysimage.sh":"ebf4e5daa1f0fe1b2092b79f0f3f161c4c4275cb744e52352c4d81ab451e4c5a","ci/benchmark.sh":"b61d19ef6b90deba8fb79dee74c8b062d94844676293da346da87bb78a9a49a4","ci/deploy_and_run_on_ios_simulator.rs":"ec8ecf82d92072676aa47f0d1a3d021b60a7ae3531153ef12d2ff4541fc294dc","ci/docker/aarch64-linux-android/Dockerfile":"ace2e7d33c87bc0f6d3962a4a3408c04557646f7f51ab99cfbf574906796b016","ci/docker/aarch64-unknown-linux-gnu/Dockerfile":"da88c0d50f16dc08448c7fdf1fa5ed2cbe576acf9e7dd85b5b818621b2a8c702","ci/docker/arm-linux-androideabi/Dockerfile":"370e55d3330a413a3ccf677b3afb3e0ef9018a5fab263faa97ae8ac017fc2286","ci/docker/arm-unknown-linux-gnueabi/Dockerfile":"bb5f8ae890707c128652290ffc544447643bf12037ddd73c6ad6989f848cb380","ci/docker/arm-unknown-linux-gnueabihf/Dockerfile":"1afaefcbc05b740859acd4e067bc92439be6bcbe8f2e9678474fb434bcd398d9","ci/docker/armv7-unknown-linux-gnueabihf/Dockerfile":"8282ea707a94109beed47a57574755e2d58401735904a03f85fb64c578c53b4f","ci/docker/i586-unknown-linux-gnu/Dockerfile":"49792922269f371bd29da4727e9085101b27be67a6b97755d0196c63317f7abb","ci/docker/i686-unknown-linux-gnu/Dockerfile":"49792922269f371bd29da4727e9085101b27be67a6b97755d0196c63317f7abb","ci/docker/mips-unknown-linux-gnu/Dockerfile":"b2ebc25797612c4f8395fe9d407725156044955bfbcf442036b7f55b43a5f9da","ci/docker/mips64-unknown-linux-gnuabi64/Dockerfile":"b0c1692ac65bc56dd30494b1993d8e929c48cc9c4b92029b7c7592af6d4f9220","ci/docker/mips64el-unknown-linux-gnuabi64/Dockerfile":"4e9249c179300138141d0b2b7401b11897f64aed69f541f078c1db4594df2827","ci/docker/mipsel-unknown-linux-musl/Dockerfile":"3164c52b0dcbb01afa78292b15b5c43503ccf0491cf6eb801ec2bf22ae274e52","ci/docker/powerpc-unknown-linux-gnu/Dockerfile":"786f799d0b56eb54d7b6c4b00e1aed4ce81776e14e44767e083c89d014b72004","ci/docker/powerpc64-unknown-linux-gnu/Dockerfile":"e8bc363837cd9c2d8b22402acb8c1c329efc11ba5d12170603d2fe2eae9da059","ci/docker/powerpc64le-unknown-linux-gnu/Dockerfile":"47998d45b781d797b9e6085ebe898d90de0c952b54537a8db4e8d7503eb032d9","ci/docker/s390x-unknown-linux-gnu/Dockerfile":"93fb44df3d7fd31ead158570667c97b5076a05c3d968af4a84bc13819a8f2db8","ci/docker/sparc64-unknown-linux-gnu/Dockerfile":"da1c39a3ff1fe22e41395fa7c8934e90b4c1788e551b9aec6e38bfd94effc437","ci/docker/thumbv7neon-linux-androideabi/Dockerfile":"c2decd5591bd7a09378901bef629cd944acf052eb55e4f35b79eb9cb4d62246a","ci/docker/thumbv7neon-unknown-linux-gnueabihf/Dockerfile":"51955a8bf3c4d440f47382af6f5426ebff94ab01a04da36175babda9a057740f","ci/docker/wasm32-unknown-unknown/Dockerfile":"5a022299f56730cf8c432a07391e95e199cfa36dc8da2a96c9d185c8de93e913","ci/docker/x86_64-linux-android/Dockerfile":"685040273cf350d5509e580ac451555efa19790c8723ca2af066adadc6880ad2","ci/docker/x86_64-unknown-linux-gnu-emulated/Dockerfile":"44b6203d9290bfdc53d81219f0937e1110847a23dd982ec8c4de388354f01536","ci/docker/x86_64-unknown-linux-gnu/Dockerfile":"7f4e3ca5fa288ea70edb4d1f75309708cd30b192e2e4444e61c4d5b3b58f89cf","ci/dox.sh":"434e9611c52e389312d2b03564adf09429f10cc76fe66a8644adb104903b87b7","ci/linux-s390x.sh":"d6b732d7795b4ba131326aff893bca6228a7d2eb0e9402f135705413dbbe0dce","ci/linux-sparc64.sh":"c92966838b1ab7ad3b7a344833ee726aba6b647cf5952e56f0ad1ba420b13325","ci/lld-shim.rs":"3d7f71ec23a49e2b67f694a0168786f9a954dda15f5a138815d966643fd3fcc3","ci/max_line_width.sh":"0a1518bba4c9ecaa55694cb2e9930d0e19c265baabf73143f17f9cf285aaa5bb","ci/run-docker.sh":"92e036390ad9b0d16f109579df1b5ced2e72e9afea40c7d011400ebd3a2a90de","ci/run.sh":"41dd6a60efaaeae9661a01370cce98b631f78392859a0cf68c946c0a16edf5f7","ci/run_examples.sh":"d1a23c6c35374a0678ba5114b9b8fefd8be0a79e774872a8bf0898d1baca18d0","ci/runtest-android.rs":"145a8e9799a5223975061fe7e586ade5669ee4877a7d7a4cf6b4ab48e8e36c7c","ci/setup_benchmarks.sh":"fae3960023f6f3d1388cd2ad22fdbab4b075f1f29dd4292d7994a20783beb6cf","ci/test-runner-linux":"c8aa6025cff5306f4f31d0c61dc5f9d4dd5a1d189ab613ef8d4c367c694d9ccd","contributing.md":"2d2629310ad4d464c482bdbb5819f0d6ce223c576aeef2cdce6a1f6857085ea5","perf-guide/.gitignore":"fe82c7da551079d832cf74200b0b359b4df9828cb4a0416fa7384f07a2ae6a13","perf-guide/book.toml":"115a98284126c6b180178b44713314cc494f08a71662ee2ce15cf67f17a51064","perf-guide/src/SUMMARY.md":"3e03bffc991fdc2050f3d51842d72d9d21ea6abab56a3baf3b2d5973a78b89e1","perf-guide/src/ascii.css":"29afb08833b2fe2250f0412e1fa1161a2432a0820a14953c87124407417c741a","perf-guide/src/bound_checks.md":"5e4991ff58a183ef0cd9fdc1feb4cd12d083b44bdf87393bbb0927808ef3ce7d","perf-guide/src/float-math/approx.md":"8c09032fa2d795a0c5db1775826c850d28eb2627846d0965c60ee72de63735ad","perf-guide/src/float-math/fma.md":"311076ba4b741d604a82e74b83a8d7e8c318fcbd7f64c4392d1cf5af95c60243","perf-guide/src/float-math/fp.md":"04153e775ab6e4f0d7837bcc515230d327b04edfa34c84ce9c9e10ebaeef2be8","perf-guide/src/float-math/svml.md":"0798873b8eedaeda5fed62dc91645b57c20775a02d3cd74d8bd06958f1516506","perf-guide/src/introduction.md":"9f5a19e9e6751f25d2daad39891a0cc600974527ec4c8305843f9618910671bd","perf-guide/src/prof/linux.md":"447731eb5de7d69166728fdbc5ecb0c0c9db678ea493b45a592d67dd002184c0","perf-guide/src/prof/mca.md":"f56d54f3d20e7aa4d32052186e8237b03d65971eb5d112802b442570ff11d344","perf-guide/src/prof/profiling.md":"8a650c0fd6ede0964789bb6577557eeef1d8226a896788602ce61528e260e43c","perf-guide/src/target-feature/attribute.md":"615f88dca0a707b6c416fa605435dd6e1fb5361cc639429cbf68cd87624bd78b","perf-guide/src/target-feature/features.md":"17077760ff24c006b606dd21889c53d87228f4311f3ba3a574f9afdeacd86165","perf-guide/src/target-feature/inlining.md":"7ed1d7068d8173a00d84c16cfe5871cd68b9f04f8d0cca2d01ebc84957ebf2f6","perf-guide/src/target-feature/practice.md":"c4b371842e0086df178488fec97f20def8f0c62ee588bcd25fd948b9b1fa227e","perf-guide/src/target-feature/runtime.md":"835425f5ee597fb3e51d36e725a81ebee29f4561231d19563cd4da81dbb1cfcb","perf-guide/src/target-feature/rustflags.md":"01197acf6f0adec8db32b8591811f69cecb6555a2b05dc5d5ec27d0e3f7b065e","perf-guide/src/vert-hor-ops.md":"c6211c0ee91e60552ec592d89d9d957eedc21dee3cbd89e1ad6765ea06a27471","rustfmt.toml":"d99a43f3f8ef9e425cf01c333fba9f0051f888f5d87ab4e8f63c2f7d0fe6620f","src/api.rs":"bb1795e9657a8298d37d2349b45443f08e9e455399ad4b727018600728478c10","src/api/bit_manip.rs":"c47a4d0f7451f7e35d07715e4f39a472e07457fd456fdb726864a4f6887252a3","src/api/bitmask.rs":"6d2beefd62ee5d9c8eb060bee6abc641616bf828c99f82abf97b21bf004e894b","src/api/cast.rs":"03b94a3d316ac7b7be7068810044911e965e889a0ace7bae762749ca74a92747","src/api/cast/macros.rs":"b0a14d0c83ad2ebb7a275180f6d9e3f2bc312ba57a7d3d6c39fad4e0f20f9408","src/api/cast/v128.rs":"edd0994efac4379dff26e178423a52dbb3ffeb38b1fc97cae975d744c00b4fb6","src/api/cast/v16.rs":"96bd98c2d21b0663abe6c0ab33005b1fa693f3db7ee6795351391343863484da","src/api/cast/v256.rs":"8c31fe91f5e78ef737dfba6979cc1240210cb094a89d284fe459bf8a991ca24b","src/api/cast/v32.rs":"a99a79dd84d2a5e6adf9db98705675915bd03fd1287d489c7fe38e84d7e4a086","src/api/cast/v512.rs":"c0dd526f41ed7b8a71c3743d91267554ec0a0c75834ccc2e3ecb0ef3004af642","src/api/cast/v64.rs":"6572fdba2a1241a6cd666d3f0cce3306cd2cb7e5e236172e59d5d4351c8a88af","src/api/cmp.rs":"357c3a2a09c6d4611c32dd7fa95be2fae933d513e229026ec9b44451a77b884e","src/api/cmp/eq.rs":"60f70f355bae4cb5b17db53204cacc3890f70670611c17df638d4c04f7cc8075","src/api/cmp/ord.rs":"589f7234761c294fa5df8f525bc4acd5a47cdb602207d524a0d4e19804cd9695","src/api/cmp/partial_eq.rs":"902ccb8aa01fd5738b30ba0b712669c21d4801958907e03bad23432c7dba0198","src/api/cmp/partial_ord.rs":"9db0c37d7434cdfc62d8d66912e972fa3d8c115ab2af051a6f45e414bd3e4f1c","src/api/cmp/vertical.rs":"de3d62f38eba817299aa16f1e1939954c9a447e316509397465c2830852ba053","src/api/default.rs":"67bf21c134127d12a7028c8b88a57f0ceee8ccbd74976da8ca74eb9f16a174d5","src/api/fmt.rs":"67fb804bb86b6cd77cf8cd492b5733ce437071b66fe3297278b8a6552c325dda","src/api/fmt/binary.rs":"02b2b287f7404f8a983813cf70c87108c8da3835578b63ab303116885f609413","src/api/fmt/debug.rs":"56e1c3bdc092747344fffaafff9da7163ee7827857f6fb7cb1c9923eca4f6fa0","src/api/fmt/lower_hex.rs":"558fd592f7f485712fb051509cecc7174a21e6bf62e5ce64766e75afc97bb8e1","src/api/fmt/octal.rs":"3b2e70877a4f368c7704f8e254236c014c365c74d93371c1feb5f030e6c66422","src/api/fmt/upper_hex.rs":"2a442f666bc80e22d41f903f881238fe114dd49344c3ed69849250e853cafc5d","src/api/from.rs":"2e599d8329cb05eaf06224cc441355c4b7b51254fc19256619333be8c149d444","src/api/from/from_array.rs":"dd3fc64fb17d6184bb60343f8da26a05edf0e5f3c14caf55d49fa15e21d948dc","src/api/from/from_vector.rs":"9764371aa9e6005aace74dea14f59e5611a095b7cf42707940924749282c52f0","src/api/hash.rs":"5076ece87969592c876486f5b1ea8affbeaec379d1a14a30859e0aa5592019de","src/api/into_bits.rs":"1ee15923352786b9ab4a31fa506762297116b18cfdb8e72853abc8ad001651d2","src/api/into_bits/arch_specific.rs":"e7445021f3908326bfee758835e5fc5ad56aa1baa77fc1c58abe4350c66c670a","src/api/into_bits/macros.rs":"bb4fe99be2af6a21d805efab44c8e4e61a7b2adb42a65504a0cf26d13efdadcd","src/api/into_bits/v128.rs":"145a44922b09a5ca5b62d88a461d327d399a997a15db4b11d7b17e554a9fa4c0","src/api/into_bits/v16.rs":"f4f4f61ba88aa51b158ec56ca3dce234349aea0daf2b3029a14ab5125d1e41e5","src/api/into_bits/v256.rs":"8cea9c5d9809f11323cb7cdc53b83df593fd17caf926251e412ae9777bed547f","src/api/into_bits/v32.rs":"905ba683d342fa32f4202b80bb46530807bd0a5b588f6c2e8c9f475223c47775","src/api/into_bits/v512.rs":"e25afa1fbf088a5d58e7d75d197b6cd4c56637ea28542ba18e46a451f29d04e7","src/api/into_bits/v64.rs":"d6238022ccff7b92e55b3f6017fc269acb6f36330a6d7e8fb389853a0f1b6478","src/api/math.rs":"8b2a2fc651917a850539f993aa0b9e5bf4da67b11685285b8de8cdca311719ec","src/api/math/float.rs":"61d2794d68262a1090ae473bd30793b5f65cf732f32a6694a3af2ce5d9225616","src/api/math/float/abs.rs":"5b6b2701e2e11135b7ce58a05052ea8120e10e4702c95d046b9d21b827b26bf8","src/api/math/float/consts.rs":"6302c9261da4291d144d5bb53493cdd073498feb40955fb6860ea3c4d06c978a","src/api/math/float/cos.rs":"4c2dd7173728ef189314f1576c9486e03be21b7da98843b2f9011282a7979e31","src/api/math/float/exp.rs":"7c6d5f1e304f498a01cfa23b92380c815d7da0ad94eae3483783bc377d287eef","src/api/math/float/ln.rs":"54c7583f3df793b39ff57534fade27b41bb992439e5dc178252f5ca3190a3e54","src/api/math/float/mul_add.rs":"62cac77660d20159276d4c9ef066eb90c81cbddb808e8e157182c607625ad2eb","src/api/math/float/mul_adde.rs":"bae056ee9f3a70df39ec3c3b2f6437c65303888a7b843ef1a5bcf1f5aca0e602","src/api/math/float/powf.rs":"9ddb938984b36d39d82a82f862f80df8f7fb013f1d222d45698d41d88472f568","src/api/math/float/recpre.rs":"589225794ff1dbf31158dff660e6d4509ecc8befbb57c633900dea5ac0b840d6","src/api/math/float/rsqrte.rs":"a32abdcc318d7ccc8448231f54d75b884b7cbeb03a7d595713ab6243036f4dbf","src/api/math/float/sin.rs":"cbd3622b7df74f19691743001c8cf747a201f8977ad90542fee915f37dcd1e49","src/api/math/float/sqrt.rs":"0c66d5d63fb08e4d99c6b82a8828e41173aff1ac9fa1a2764a11fac217ccf2ac","src/api/math/float/sqrte.rs":"731e1c9f321b662accdd27dacb3aac2e8043b7aecb2f2161dde733bd9f025362","src/api/minimal.rs":"1f22bcc528555444e76de569ec0ae2029b9ae9d04805efeafa93369c8098036b","src/api/minimal/iuf.rs":"819cff26d3e196f807645bcc1d79eb27d9f175edb89910f2274d52a1e913cd11","src/api/minimal/mask.rs":"0cae10ae1fc65f5070e686c0c79bfba27b86b33d6c399367bd4848fb367dcec4","src/api/minimal/ptr.rs":"f65ebf21866a863485344432d9a7a9b7418f7fad5fdf841a4e2fa56ec0766ad0","src/api/ops.rs":"3e273b277a0f3019d42c3c59ca94a5afd4885d5ae6d2182e5089bbeec9de42ee","src/api/ops/scalar_arithmetic.rs":"d2d5ad897a59dd0787544f927e0e7ca4072c3e58b0f4a2324083312b0d5a21d7","src/api/ops/scalar_bitwise.rs":"482204e459ca6be79568e1c9f70adbe2d2151412ddf122fb2161be8ebb51c40c","src/api/ops/scalar_mask_bitwise.rs":"c250f52042e37b22d57256c80d4604104cfd2fbe2a2e127c676267270ca5d350","src/api/ops/scalar_shifts.rs":"c4773d435c3f9da4454327e6fbb2b5b41a1c0ebb1cca7372e69dc7a344a1b6e4","src/api/ops/vector_arithmetic.rs":"ddca15d09ddeef502c2ed66117a62300ca65d87e959e8b622d767bdf1c307910","src/api/ops/vector_bitwise.rs":"b3968f7005b649edcc22a54e2379b14d5ee19045f2e784029805781ae043b5ee","src/api/ops/vector_float_min_max.rs":"76bf8cb607e2c442923c1da1061a6b80d742d607408033c2a3761161114cf2a0","src/api/ops/vector_int_min_max.rs":"a378789c6ff9b32a51fbd0a97ffd36ed102cd1fe6a067d2b02017c1df342def6","src/api/ops/vector_mask_bitwise.rs":"5052d18517d765415d40327e6e8e55a312daaca0a5e2aec959bfa54b1675f9c8","src/api/ops/vector_neg.rs":"5c62f6b0221983cdbd23cd0a3af3672e6ba1255f0dfe8b19aae6fbd6503e231b","src/api/ops/vector_rotates.rs":"ee319eaaa449dc50ea8ef05b89d38519c6faa6753dfdce432ea7bb8520e4e8e7","src/api/ops/vector_shifts.rs":"e510be14127c0ffd58a2573a39701da3557d66bedec09837ac8bbd44d579da00","src/api/ptr.rs":"8a793251bed6130dcfb2f1519ceaa18b751bbb15875928d0fb6deb5a5e07523a","src/api/ptr/gather_scatter.rs":"3d614f9d5b4ca201a9f7e46af4405e1d2c28ecee1620297c23b52e37b92cc0ea","src/api/reductions.rs":"ae5baca81352ecd44526d6c30c0a1feeda475ec73ddd3c3ec6b14e944e5448ee","src/api/reductions/bitwise.rs":"8bf910ae226188bd15fc7e125f058cd2566b6186fcd0cd8fd020f352c39ce139","src/api/reductions/float_arithmetic.rs":"47a5679896db2cbb56c31372fe42143da015b6beae7db5d2f3a0309ddf427ae1","src/api/reductions/integer_arithmetic.rs":"c2df3cf7493cca4174f2c65aea422a3d20d8a23af03f8d57cef72c19fee8f20d","src/api/reductions/mask.rs":"db83327a950e33a317f37fd33ca4e20c347fb415975ec024f3e23da8509425af","src/api/reductions/min_max.rs":"6af8c9aa45c69961b1b6fc205395f4767d4421869fb105fb3d563c5605fc13cd","src/api/select.rs":"6b07e7e8026df561f7307221a896f0fbb272536f41b9109040ac094c24c69331","src/api/shuffle.rs":"26458aec2557bfab41b7765f72aefbff3a7ee08cdc689981a81f133f58ee368b","src/api/shuffle1_dyn.rs":"bfea5a91905b31444e9ef7ca6eddb7a9606b7e22d3f71bb842eb2795a0346620","src/api/slice.rs":"ee87484e8af329547b9a5d4f2a69e8bed6ea10bbd96270d706083843d4eea2ac","src/api/slice/from_slice.rs":"9b6f01ace2d12ef45c84608bb7aad3a122e2cc319b2d99170fc332a568b8de63","src/api/slice/write_to_slice.rs":"244b6bd6ccffa6e5a195f8b1abc66d94251b6d16b2ec3fe4d76d32caec68261e","src/api/swap_bytes.rs":"4a6792a2e49a77475e1b237592b4b2804dbddb79c474331acd0dd71b36934259","src/codegen.rs":"db4f232fb9f5728db310b87dc8c4733be48afacab1053798c06106bef9a42b05","src/codegen/bit_manip.rs":"525ea6ff7ad1e043b6f6136992166f1803ed5563b7f6fc292c1c40257d20e264","src/codegen/llvm.rs":"b4ccbc0bad90038f00fc3c158736462d01d0053df3afa00f9169e67d1a264444","src/codegen/math.rs":"dfcf02ad34e2fdfe22c3f1cc2822001cc895e65031b4d06e585e5047839febb7","src/codegen/math/float.rs":"2c1cbce155bc527ce34d472c0fef6bc3dadb79cd7a357dd7aa5b1ebeb1d77a13","src/codegen/math/float/abs.rs":"d5aaadcf540bdb9b4264dca6471a255fd7bf509e763bef0239c0144a68466fea","src/codegen/math/float/cos.rs":"17f28d2900c852dca221fa9c92a9cd5fe7fd2df8d427bbc60216c749b2be013d","src/codegen/math/float/cos_pi.rs":"dbaf9f443f9846a491d4ec52210a7b5835dd593b03366e3135b05c37d70f9d6c","src/codegen/math/float/exp.rs":"d300058a4bcc7ae7976f216f81902cd73a9e603ad63880dff3bbc866c27a9f37","src/codegen/math/float/ln.rs":"c851e211e43f8256093ba75b03ae0c307c9962ee66d94f09b4dd80068190cbdf","src/codegen/math/float/macros.rs":"fc9924869ed85e4795983af228cacf23158f4f35919adce16c920ad4a3f0a009","src/codegen/math/float/mul_add.rs":"041a5b69d5991d93ef795351b17560c10faf80b78fd26ad7df42a239b32cf9de","src/codegen/math/float/mul_adde.rs":"d71d5f0f3333b62a7439b823cb7adf5340ea1555ce820fb4a3f4cb922f73f5f5","src/codegen/math/float/powf.rs":"9742c3877f1a5509ca5c9492a40884b6579ba6dd11c26b7112e63f70666b395d","src/codegen/math/float/sin.rs":"0e9868d35531566509f3a01d85d5253045eb4afa8525d8407dcc1f5f33c56036","src/codegen/math/float/sin_cos_pi.rs":"8e6b6142d7dd240cdb36669722e82ab9810a2261e86e659f7d97a942ad8b1258","src/codegen/math/float/sin_pi.rs":"bb6d39db8f921e03a301fc5206ac1a61a97def8a2cb83b87ccf189f3fc48d548","src/codegen/math/float/sqrt.rs":"e6ebb0c5f428efad1f672b9a8fe4e58534dbf1ea5a8fe092ce5ce76b52fe89cb","src/codegen/math/float/sqrte.rs":"23acfaea38d0e081a6d9021c1094e813d0cfd12c58c1eca9662aade5e625d51c","src/codegen/pointer_sized_int.rs":"6ca13c214b6cf7e0929dbe18e96a16fc0bb7d8799608df29c4c8115490f99e01","src/codegen/reductions.rs":"8eb18ebac76985d2aa30262a2edd8cb004230b511a765d657525f677a585c12c","src/codegen/reductions/mask.rs":"e67f35a1f4d156a4894a2d6ea5a935b4d898cf70eefb2715f5c1cc165e776c11","src/codegen/reductions/mask/aarch64.rs":"84b101c17cad1ede4eb6d38cada0ac7da239dba8cea3badd3829b967e558431f","src/codegen/reductions/mask/arm.rs":"aaa07129bd078ae7e677cf8b8e67ec9f30536606a0c7ed1baaa18fd1793bb218","src/codegen/reductions/mask/fallback.rs":"3eb9319d2c7cf19216b607b8459612c4e027b643cf11b036937d36896bf76786","src/codegen/reductions/mask/fallback_impl.rs":"76547f396e55ef403327c77c314cf8db8c7a5c9b9819bfb925abeacf130249e5","src/codegen/reductions/mask/x86.rs":"36dcd8af4ab99730a078ed113d3955f74eb1a2876e2e6d9f224e0ff462c216d1","src/codegen/reductions/mask/x86/avx.rs":"3a40868b38c86e35aefb96d7578de6322efe89d8135e0366359b54ddd06f861a","src/codegen/reductions/mask/x86/avx2.rs":"677aed3f056285285daa3adff8bc65e739630b4424defa6d9665e160f027507e","src/codegen/reductions/mask/x86/sse.rs":"8522f6ed03f6c32dd577d4298df477c08aeaaa38563706f29096e1911ed731f2","src/codegen/reductions/mask/x86/sse2.rs":"54ec56e49b0c6841eccb719e4f310d65fe767c04136b2ec20bd8b9d7d9897b9e","src/codegen/shuffle.rs":"1ec2930f4e1acc43ac30b518af298d466a79e9e75734a51c380b7810efd1a27f","src/codegen/shuffle1_dyn.rs":"3f13ca1597378758d05106bf5ff3715eee531f3cb6d88f48b9182bd6c9386b51","src/codegen/swap_bytes.rs":"c67c86e91ca3fc77539e0efcea081a3c62548cccf503963ae408f2e86f4e6a21","src/codegen/v128.rs":"94226b31ec403d18d9d2fe06713f147c9c79e9b5f9105089088266313f843185","src/codegen/v16.rs":"ddec4ffb66b6f7aaffb9a1780c5ddba82557abd74f45073d335047e04cf74924","src/codegen/v256.rs":"6b63917f0444118d6b1595bff2045e59b97c4d24012bd575f69f1f0efc5a0241","src/codegen/v32.rs":"3477b3c5540aed86e61e2f5807dd31db947413cec9181c587d93ed6ec74f0eba","src/codegen/v512.rs":"5854f99d3aabc4cd42b28a20d9ce447756dc2ba024a409a69b6a8ae1f1842fc5","src/codegen/v64.rs":"e9e89caebfe63d10c0cbca61e4dfdba3b7e02ee0989170f80beed23237ddd950","src/codegen/vPtr.rs":"f0753b405cdc865bdf8e82c6505f299ea1f96136239ebbaf7f9ce93d310764b8","src/codegen/vSize.rs":"c89f5fdeb28ac4c8272ed1816fce03d9d95308cc32bb2533bd8b20cd5ac102ac","src/lib.rs":"b6f846d5d30cf6b035a2d18039aba7b2045cf89384733d643572bd68873ae064","src/masks.rs":"70fc0abe4c2907ce2a491c574e1cfb9f3423385da2e1a923a48c9c13f8ba6ed8","src/sealed.rs":"ae7fdeaf5d84cd7710ed730ca72ca7eaba93df6cb0acb183e5c0a7327acf197f","src/testing.rs":"896669c08d8c801448a4d2fadc9d633eda0fbe879d229997e2a182e31278e469","src/testing/macros.rs":"403bbc5ecb7c786fe36156df302d0c07a8122408dbb15f7474d7682224ba1106","src/testing/utils.rs":"41912a92266dfe884647fc035e4242fd746100df8e839808ae0397af3759a3c8","src/v128.rs":"16cf9a8e7156b899ee9b9cd3f2dba9d13ec63289bea8c3ee9ae2e43ad9510288","src/v16.rs":"cb6465cf1e00bf530183af1819b9fe3d7eec978f8765d5e85d9b58a39a4b4045","src/v256.rs":"fe235017da18c7f3c361831c60e3173ad304d8ea1e95d64ebebc79da2d708511","src/v32.rs":"145d347855bac59b2de6508f9e594654e6c330423af9edc0e2ac8f4d1abdf45e","src/v512.rs":"f372f277f3e62eb5c945bb1c460333fdb17b6974fcc876633788ff53bded9599","src/v64.rs":"0b8079881b71575e3414be0b7f8f7eaba65281ba6732f2b2f61f73e95b6f48f7","src/vPtr.rs":"8b3e433d487180bb4304ff71245ecad90f0010f43e139a72027b672abe58facc","src/vSize.rs":"eda5aa020706cbf94d15bada41a0c2a35fc8f3f37cb7c2cd6f34d201399a495e","tests/endianness.rs":"2783d727e8ff8789211e03120634cd3ad9f8972fc484012681b5b63cf89408a7"},"package":null}
8613 \ No newline at end of file