diff --git a/Cargo.lock b/Cargo.lock index 059b5e9f0caf..84b9132fddea 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -418,21 +418,21 @@ dependencies = [ name = "bindgen" version = "0.63.999" dependencies = [ - "bindgen 0.69.2", + "bindgen 0.69.4", ] [[package]] name = "bindgen" -version = "0.69.2" +version = "0.69.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4c69fae65a523209d34240b60abe0c42d33d1045d445c0839d8a4894a736e2d" +checksum = "a00dc851838a2120612785d195287475a3ac45514741da670b735818822129a0" dependencies = [ "bitflags 2.4.1", "cexpr", "clang-sys", + "itertools", "lazy_static", "lazycell", - "peeking_take_while", "proc-macro2", "quote", "regex", @@ -570,7 +570,7 @@ dependencies = [ name = "builtins-static" version = "0.1.0" dependencies = [ - "bindgen 0.69.2", + "bindgen 0.69.4", "mozilla-central-workspace-hack", "nom", "pkcs11-bindings", @@ -893,7 +893,7 @@ version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f3120ebb80a9de008e638ad833d4127d50ea3d3a960ea23ea69bc66d9358a028" dependencies = [ - "bindgen 0.69.2", + "bindgen 0.69.4", ] [[package]] @@ -2036,7 +2036,7 @@ name = "gecko-profiler" version = "0.1.0" dependencies = [ "bincode", - "bindgen 0.69.2", + "bindgen 0.69.4", "lazy_static", "mozbuild", "profiler-macros", @@ -2596,7 +2596,7 @@ name = "http3server" version = "0.1.1" dependencies = [ "base64 0.21.3", - "bindgen 0.69.2", + "bindgen 0.69.4", "cfg-if 1.0.0", "http", "hyper", @@ -3714,7 +3714,7 @@ name = "mozilla-central-workspace-hack" version = "0.1.0" dependencies = [ "arrayvec", - "bindgen 0.69.2", + "bindgen 0.69.4", "bitflags 2.4.1", "bytes", "cc", @@ -3885,7 +3885,7 @@ name = "neqo-crypto" version = "0.7.0" source = "git+https://github.com/mozilla/neqo?tag=v0.7.0#9489511f7c82786f55bc9c713cddbff825507ed7" dependencies = [ - "bindgen 0.69.2", + "bindgen 0.69.4", "log", "mozbuild", "neqo-common", @@ -4029,7 +4029,7 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4c17aec6d4e1822c023689899f09311592a36cbf6de8f85dfaf5f01976790d8d" dependencies = [ - "bindgen 0.69.2", + "bindgen 0.69.4", "mozbuild", "once_cell", "pkcs11-bindings", @@ -4299,12 +4299,6 @@ dependencies = [ "unicode-xid", ] -[[package]] -name = "peeking_take_while" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099" - [[package]] name = "percent-encoding" version = "2.3.1" @@ -4401,7 +4395,7 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d0fabbdbe64b22820753da90995b3a73d02907eaeeac6f2414962a566aaa18ea" dependencies = [ - "bindgen 0.69.2", + "bindgen 0.69.4", ] [[package]] @@ -5322,7 +5316,7 @@ dependencies = [ "app_units", "arrayvec", "atomic_refcell", - "bindgen 0.69.2", + "bindgen 0.69.4", "bitflags 2.4.1", "byteorder", "cssparser", diff --git a/supply-chain/audits.toml b/supply-chain/audits.toml index a56577487b03..4bd955a3188e 100644 --- a/supply-chain/audits.toml +++ b/supply-chain/audits.toml @@ -776,6 +776,11 @@ who = "Mike Hommey " criteria = "safe-to-deploy" delta = "0.69.1 -> 0.69.2" +[[audits.bindgen]] +who = "Emilio Cobos Álvarez " +criteria = "safe-to-deploy" +delta = "0.69.2 -> 0.69.4" + [[audits.bit-set]] who = "Aria Beingessner " criteria = "safe-to-deploy" diff --git a/third_party/rust/bindgen/.cargo-checksum.json b/third_party/rust/bindgen/.cargo-checksum.json index 27e2330cd3c7..24fa58273e3f 100644 --- a/third_party/rust/bindgen/.cargo-checksum.json +++ b/third_party/rust/bindgen/.cargo-checksum.json @@ -1 +1 @@ -{"files":{"Cargo.toml":"700e9df94a3086bebcb19c2b9bbcbca993778ccca161eb32a124623dfc9b0687","LICENSE":"c23953d9deb0a3312dbeaf6c128a657f3591acee45067612fa68405eaa4525db","README.md":"b2334e4077a9bc329516e3e0c7f89887c4f073647d95fb71b6917edf4c310ba3","build.rs":"4a9c4ac3759572e17de312a9d3f4ced3b6fd3c71811729e5a8d06bfbd1ac8f82","callbacks.rs":"cd5a1b0fc665b034d97615d0b6817cbef299dbf5276254c7e63f1c29674993ad","clang.rs":"5865e207df0c182c7433a08515cf1049d7885eb1273911cb2ea6155638b469a7","codegen/bitfield_unit.rs":"fddeaeab5859f4e82081865595b7705f5c0774d997df95fa5c655b81b9cae125","codegen/bitfield_unit_tests.rs":"9df86490de5e9d66ccea583dcb686dd440375dc1a3c3cf89a89d5de3883bf28a","codegen/dyngen.rs":"6d8bed53c6de66bc658b3186041c2b75549f49b0f0363ff18b87c8dcf2f5a05b","codegen/error.rs":"0c3d198f4866ccbbcd8b1136fc5cfd2507a9eca5ab85934af29a7e2a7d8d8c2a","codegen/helpers.rs":"0c28751565c90b4ab385ae2113cde02afa34225d85ae48fd296817aac36c5940","codegen/impl_debug.rs":"80df6136327b1ca8c7d1c2961290b5ab00b85b49b22c02f26a590bc68fb230af","codegen/impl_partialeq.rs":"db739d7ba6f5ba4033d6bf62c276f35217c20eab27230cf07dadf59e8b2f71bb","codegen/mod.rs":"d7f28d62feba79278ec2196c2fd23a9fbf28f28fcce55d209c5d8d6ea88e9673","codegen/postprocessing/merge_extern_blocks.rs":"284457a3c75e945217bab4e5a4280fef0fcc03c31e12cc5010aab87f34c0b6c7","codegen/postprocessing/mod.rs":"160a6d6701cabf2514e23570df1bd1b648c909cc27b7c583f21d98fe0c16722e","codegen/postprocessing/sort_semantically.rs":"f465d1e8cc119082eb79c164b5cd780a370821e8bf56585b287dd3b51fc4a542","codegen/serialize.rs":"c39112e01686f741eca4a89dca83a10e66c611b3d21d7c9548ba76f8c2d43a2b","codegen/struct_layout.rs":"07007251c91e0d4eb1e46535068d8c22881d248baa2e38cab96d72691927c2e4","deps.rs":"af3dd24a7808b5abf0c4ed4b10bbceb8eef32be980ff085b8a766d8f089af1a4","diagnostics.rs":"dc40cd5e9710922422c5c9420e2351f5d976e7a1d7275e4f4ce742cad9eb53f8","extra_assertions.rs":"fb4484c0e9fcbea9ec7265f5fbd01e2b33ac022b2b17e060dce7886819d57e40","features.rs":"29f2df89716a47a7d9dbd33b1ff4da61645e729a92772530bed3a04163afc08f","ir/analysis/derive.rs":"cba290e9c4ba271e90524149ad3b874f37843bfdfab12d513cc85d2665447fd5","ir/analysis/has_destructor.rs":"e7e95c3b0989b6375cd3eabaac85a36ecc2915a1fd3700c7d26fe04e8dc83ba3","ir/analysis/has_float.rs":"a56b97bf913f132c2c63dc202b45c692c416a8c9fdc6b2baeee30362fb0d4405","ir/analysis/has_type_param_in_array.rs":"788ebb4ba2cf46a22f1e4ff3005d51f38d414b72e95355f7ff4125521e2d9525","ir/analysis/has_vtable.rs":"83efa40ae89147170eabdff1387e60aba574ca4cd4cdef22692753594f09d6c6","ir/analysis/mod.rs":"9d949c27451da4ed72994b31c04ddeb89eeb342fd23ea572d3962d4ccf774841","ir/analysis/sizedness.rs":"f0a9302f3c6ad694d76cfab11dbaf5392ecaf7f04bc7b211a5a003776b963896","ir/analysis/template_params.rs":"3ff27e2198e292a348876aa1faba39cc4b1870a24a7e173feac0b3c592001e13","ir/annotations.rs":"5ed03d025862d0d21852a76c86a993772624e123fdc3752415d588a0b4e643ab","ir/comment.rs":"4c9c20b5a3da086211e92adec0822831dbc0b7ebee98fee313edcae9ae8d55ec","ir/comp.rs":"fb32715ed8fc14bee51c344a41c1f7a8a802d4a6dceb2775034ea33a88670df7","ir/context.rs":"a1c591532b44bc532c18f8e5afa0ba4aa94934db2de23f2c71dbdfcb384fd333","ir/derive.rs":"c21e470bb0091f20bfa366110880d48984fc3cf7071fdf36eccfa64f3eca231c","ir/dot.rs":"75bdfd83d9e754ba726f6a5529ba1d9ff46f5bf49bf237452985eb008fed0854","ir/enum_ty.rs":"f4bfa6d18ba4977fb66f5d5e4a7674eded93b761404d91cdd6fdd50029db455a","ir/function.rs":"8acde871c277069d94c96cf4dea68497b2d6253e66014db9655dd825906b19cc","ir/int.rs":"601736f0ad0949e40684a9ce89bafbfefa71743df6ee6c342e44888a0f141ae0","ir/item.rs":"9e79006baca2ff6072ffcf32479b8fab7a4d6ddb1a6900a007dd0531c8b43b23","ir/item_kind.rs":"33e21104b0bb824a696a52cd520567ae56158010a1df14777e68ac5f8ad7e8fa","ir/layout.rs":"8fbafc0eeee17abb703a18613be1066e38838d4b67f5916f714bf545e545bc1a","ir/mod.rs":"a3b98b1732111a980a795c72eaf1e09101e842ef2de76b4f2d4a7857f8d4cee4","ir/module.rs":"b2961ffa4acb0c19f084c5db084b8a17bda7158066782a73b80ee7d838789bf9","ir/objc.rs":"8f57a9180d57a690449f20ed1be80209db5f8a410bb067ae8bf5e0ecab16a5e4","ir/template.rs":"3f59efa9670ca90215d4374be869c9dbecb98a8d1041e7c6e4ab69a62bb982c2","ir/traversal.rs":"a4ec73d3533d4b93386153baf6a2ca846ee51228c76ed51105229d3ddcd74466","ir/ty.rs":"69300e7f8255627da1a3fe641ffe7215f7889d4b3c0fcbf7c366b78e3849d5cb","ir/var.rs":"40d18226706de0ee5f002d0b5617dbcba35de0605edd531c75e3a76d000f0f4f","lib.rs":"1c5b0c2f6e71895059a0c0bf3b9bc0d6ff1c32cf296c8547e1b63d58fe589319","log_stubs.rs":"9f974e041e35c8c7e29985d27ae5cd0858d68f8676d1dc005c6388d7d011707f","options/as_args.rs":"76efa4e662cc7f89ef1c1fe089d03a3c1c019ffe2aa0a30a4d49ed41e987d1c7","options/helpers.rs":"f4a7681e29b2dcc3be9249478c499d685b9e29d4f4ca4ae8bff7a91668cd8f15","options/mod.rs":"2df5cd073da0f5fc68707551f6c86a9795225195da8e630a7670e49d205dc05d","parse.rs":"fce3616e0464aa7414888e5d00d4df18c83bb3034a1c807d36a07a3c586e475a","regex_set.rs":"b411d64bc803947a3f69dcedcd7d03716aacbc7b1c5148b82de1cc469d9336d9","time.rs":"8efe317e7c6b5ba8e0865ce7b49ca775ee8a02590f4241ef62f647fa3c22b68e"},"package":"a4c69fae65a523209d34240b60abe0c42d33d1045d445c0839d8a4894a736e2d"} \ No newline at end of file +{"files":{"Cargo.toml":"bebb685bfd8df63474c92bfb7f787573ef78eb70920aceb38a8a746968380f96","LICENSE":"c23953d9deb0a3312dbeaf6c128a657f3591acee45067612fa68405eaa4525db","README.md":"b2334e4077a9bc329516e3e0c7f89887c4f073647d95fb71b6917edf4c310ba3","build.rs":"4a9c4ac3759572e17de312a9d3f4ced3b6fd3c71811729e5a8d06bfbd1ac8f82","callbacks.rs":"cd5a1b0fc665b034d97615d0b6817cbef299dbf5276254c7e63f1c29674993ad","clang.rs":"278ca0d89251df8a6b40bdccd27827e310d16872ff86fa23b60d581615607630","codegen/bitfield_unit.rs":"fddeaeab5859f4e82081865595b7705f5c0774d997df95fa5c655b81b9cae125","codegen/bitfield_unit_tests.rs":"9df86490de5e9d66ccea583dcb686dd440375dc1a3c3cf89a89d5de3883bf28a","codegen/dyngen.rs":"6d8bed53c6de66bc658b3186041c2b75549f49b0f0363ff18b87c8dcf2f5a05b","codegen/error.rs":"0c3d198f4866ccbbcd8b1136fc5cfd2507a9eca5ab85934af29a7e2a7d8d8c2a","codegen/helpers.rs":"443a2c3495185ced2a9d68c02204bebfa8c4186f4275bf9ed3af90c3a3e159d7","codegen/impl_debug.rs":"80df6136327b1ca8c7d1c2961290b5ab00b85b49b22c02f26a590bc68fb230af","codegen/impl_partialeq.rs":"db739d7ba6f5ba4033d6bf62c276f35217c20eab27230cf07dadf59e8b2f71bb","codegen/mod.rs":"206e4e2c14cec17c13d11e568557332b51ce1e41ce8128182de44dab69221662","codegen/postprocessing/merge_extern_blocks.rs":"284457a3c75e945217bab4e5a4280fef0fcc03c31e12cc5010aab87f34c0b6c7","codegen/postprocessing/mod.rs":"160a6d6701cabf2514e23570df1bd1b648c909cc27b7c583f21d98fe0c16722e","codegen/postprocessing/sort_semantically.rs":"f465d1e8cc119082eb79c164b5cd780a370821e8bf56585b287dd3b51fc4a542","codegen/serialize.rs":"1f1eb8b04fec9655dc302442451f9622ad6365eb37bf588a119a60e79f37002c","codegen/struct_layout.rs":"922cc71fb309716879aeea4775bbc29751ca5d431083ca83d7beb0a90862a302","deps.rs":"af3dd24a7808b5abf0c4ed4b10bbceb8eef32be980ff085b8a766d8f089af1a4","diagnostics.rs":"dc40cd5e9710922422c5c9420e2351f5d976e7a1d7275e4f4ce742cad9eb53f8","extra_assertions.rs":"fb4484c0e9fcbea9ec7265f5fbd01e2b33ac022b2b17e060dce7886819d57e40","features.rs":"b27adc6bb50e9aae50fd75568a7576382c6409f585b6be0047d7a9314c98d569","ir/analysis/derive.rs":"cba290e9c4ba271e90524149ad3b874f37843bfdfab12d513cc85d2665447fd5","ir/analysis/has_destructor.rs":"e7e95c3b0989b6375cd3eabaac85a36ecc2915a1fd3700c7d26fe04e8dc83ba3","ir/analysis/has_float.rs":"a56b97bf913f132c2c63dc202b45c692c416a8c9fdc6b2baeee30362fb0d4405","ir/analysis/has_type_param_in_array.rs":"788ebb4ba2cf46a22f1e4ff3005d51f38d414b72e95355f7ff4125521e2d9525","ir/analysis/has_vtable.rs":"83efa40ae89147170eabdff1387e60aba574ca4cd4cdef22692753594f09d6c6","ir/analysis/mod.rs":"9d949c27451da4ed72994b31c04ddeb89eeb342fd23ea572d3962d4ccf774841","ir/analysis/sizedness.rs":"f0a9302f3c6ad694d76cfab11dbaf5392ecaf7f04bc7b211a5a003776b963896","ir/analysis/template_params.rs":"3ff27e2198e292a348876aa1faba39cc4b1870a24a7e173feac0b3c592001e13","ir/annotations.rs":"5ed03d025862d0d21852a76c86a993772624e123fdc3752415d588a0b4e643ab","ir/comment.rs":"4c9c20b5a3da086211e92adec0822831dbc0b7ebee98fee313edcae9ae8d55ec","ir/comp.rs":"c048866353695ac8190ab03511123be82d34ca73fb865a2578cb5a2e04390431","ir/context.rs":"03175218512c42792aae7b56a764c0237a447664dda5f1a8269a42bed46d3be2","ir/derive.rs":"c21e470bb0091f20bfa366110880d48984fc3cf7071fdf36eccfa64f3eca231c","ir/dot.rs":"75bdfd83d9e754ba726f6a5529ba1d9ff46f5bf49bf237452985eb008fed0854","ir/enum_ty.rs":"f4bfa6d18ba4977fb66f5d5e4a7674eded93b761404d91cdd6fdd50029db455a","ir/function.rs":"0ecee923382b0a49265bc970ac90a73740ec5ba3c33466b2cfe8aa462df59bd5","ir/int.rs":"601736f0ad0949e40684a9ce89bafbfefa71743df6ee6c342e44888a0f141ae0","ir/item.rs":"65f2351dd3971d8a76470a78f5b6b1ebdda067ab5bae4641246aa986d9579e29","ir/item_kind.rs":"33e21104b0bb824a696a52cd520567ae56158010a1df14777e68ac5f8ad7e8fa","ir/layout.rs":"8fbafc0eeee17abb703a18613be1066e38838d4b67f5916f714bf545e545bc1a","ir/mod.rs":"a3b98b1732111a980a795c72eaf1e09101e842ef2de76b4f2d4a7857f8d4cee4","ir/module.rs":"b2961ffa4acb0c19f084c5db084b8a17bda7158066782a73b80ee7d838789bf9","ir/objc.rs":"8f57a9180d57a690449f20ed1be80209db5f8a410bb067ae8bf5e0ecab16a5e4","ir/template.rs":"3f59efa9670ca90215d4374be869c9dbecb98a8d1041e7c6e4ab69a62bb982c2","ir/traversal.rs":"a4ec73d3533d4b93386153baf6a2ca846ee51228c76ed51105229d3ddcd74466","ir/ty.rs":"fd71d11e89e085921317349e1912ab56e7335d870c2d25df9e13a8ffbd6430c9","ir/var.rs":"40d18226706de0ee5f002d0b5617dbcba35de0605edd531c75e3a76d000f0f4f","lib.rs":"7496f72a177b5965ed56a2ab9af0f64e70abbc53cc6c196a15e6760dd6235adf","log_stubs.rs":"9f974e041e35c8c7e29985d27ae5cd0858d68f8676d1dc005c6388d7d011707f","options/as_args.rs":"76efa4e662cc7f89ef1c1fe089d03a3c1c019ffe2aa0a30a4d49ed41e987d1c7","options/helpers.rs":"f4a7681e29b2dcc3be9249478c499d685b9e29d4f4ca4ae8bff7a91668cd8f15","options/mod.rs":"1805cec86c563633b29b57292287c9efd3b5c724132ec1c13acee57858942e74","parse.rs":"fce3616e0464aa7414888e5d00d4df18c83bb3034a1c807d36a07a3c586e475a","regex_set.rs":"b411d64bc803947a3f69dcedcd7d03716aacbc7b1c5148b82de1cc469d9336d9","time.rs":"8efe317e7c6b5ba8e0865ce7b49ca775ee8a02590f4241ef62f647fa3c22b68e"},"package":"a00dc851838a2120612785d195287475a3ac45514741da670b735818822129a0"} \ No newline at end of file diff --git a/third_party/rust/bindgen/Cargo.toml b/third_party/rust/bindgen/Cargo.toml index 9914cde30405..c4f5f568ae6d 100644 --- a/third_party/rust/bindgen/Cargo.toml +++ b/third_party/rust/bindgen/Cargo.toml @@ -13,7 +13,7 @@ edition = "2018" rust-version = "1.60.0" name = "bindgen" -version = "0.69.2" +version = "0.69.4" authors = [ "Jyun-Yan You ", "Emilio Cobos Álvarez ", @@ -79,6 +79,10 @@ version = "0.6" version = "1" features = ["clang_6_0"] +[dependencies.itertools] +version = ">=0.10,<0.13" +default-features = false + [dependencies.lazy_static] version = "1" @@ -89,9 +93,6 @@ version = "1" version = "0.4" optional = true -[dependencies.peeking_take_while] -version = "0.1.2" - [dependencies.prettyplease] version = "0.2.7" features = ["verbatim"] @@ -106,10 +107,10 @@ version = "1" default-features = false [dependencies.regex] -version = "1.5" +version = "1.5.1" features = [ "std", - "unicode", + "unicode-perl", ] default-features = false @@ -135,7 +136,7 @@ default-features = false [features] __cli = [] __testing_only_extra_assertions = [] -__testing_only_libclang_5 = [] +__testing_only_libclang_16 = [] __testing_only_libclang_9 = [] default = [ "logging", diff --git a/third_party/rust/bindgen/clang.rs b/third_party/rust/bindgen/clang.rs index 3438bfa2c4af..4a4ed89d6916 100644 --- a/third_party/rust/bindgen/clang.rs +++ b/third_party/rust/bindgen/clang.rs @@ -2297,6 +2297,15 @@ impl Drop for EvalResult { unsafe { clang_EvalResult_dispose(self.x) }; } } +/// ABI kinds as defined in +/// +#[derive(Debug, Eq, PartialEq, Copy, Clone)] +pub(crate) enum ABIKind { + /// All the regular targets like Linux, Mac, WASM, etc. implement the Itanium ABI + GenericItanium, + /// The ABI used when compiling for the MSVC target + Microsoft, +} /// Target information obtained from libclang. #[derive(Debug)] @@ -2305,6 +2314,8 @@ pub(crate) struct TargetInfo { pub(crate) triple: String, /// The width of the pointer _in bits_. pub(crate) pointer_width: usize, + /// The ABI of the target + pub(crate) abi: ABIKind, } impl TargetInfo { @@ -2320,9 +2331,17 @@ impl TargetInfo { } assert!(pointer_width > 0); assert_eq!(pointer_width % 8, 0); + + let abi = if triple.contains("msvc") { + ABIKind::Microsoft + } else { + ABIKind::GenericItanium + }; + TargetInfo { triple, pointer_width: pointer_width as usize, + abi, } } } diff --git a/third_party/rust/bindgen/codegen/helpers.rs b/third_party/rust/bindgen/codegen/helpers.rs index 7ef44fe0994d..48bfe56ddef5 100644 --- a/third_party/rust/bindgen/codegen/helpers.rs +++ b/third_party/rust/bindgen/codegen/helpers.rs @@ -232,6 +232,15 @@ pub(crate) mod ast_ty { // // Also, maybe this one shouldn't be the default? match (fk, ctx.options().convert_floats) { + (FloatKind::Float16, _) => { + // TODO: do f16 when rust lands it + ctx.generated_bindgen_float16(); + if ctx.options().enable_cxx_namespaces { + syn::parse_quote! { root::__BindgenFloat16 } + } else { + syn::parse_quote! { __BindgenFloat16 } + } + } (FloatKind::Float, true) => syn::parse_quote! { f32 }, (FloatKind::Double, true) => syn::parse_quote! { f64 }, (FloatKind::Float, false) => raw_type(ctx, "c_float"), diff --git a/third_party/rust/bindgen/codegen/mod.rs b/third_party/rust/bindgen/codegen/mod.rs index 8e1360634547..dd1486df7447 100644 --- a/third_party/rust/bindgen/codegen/mod.rs +++ b/third_party/rust/bindgen/codegen/mod.rs @@ -578,6 +578,9 @@ impl CodeGenerator for Module { if result.saw_incomplete_array { utils::prepend_incomplete_array_types(ctx, &mut *result); } + if ctx.need_bindgen_float16_type() { + utils::prepend_float16_type(&mut *result); + } if ctx.need_bindgen_complex_type() { utils::prepend_complex_type(&mut *result); } @@ -1974,6 +1977,7 @@ impl CodeGenerator for CompInfo { ty, &canonical_name, visibility, + packed, ); if !is_opaque { @@ -2193,7 +2197,14 @@ impl CodeGenerator for CompInfo { if let Some(comment) = item.comment(ctx) { attributes.push(attributes::doc(comment)); } - if packed && !is_opaque { + + // if a type has both a "packed" attribute and an "align(N)" attribute, then check if the + // "packed" attr is redundant, and do not include it if so. + if packed && + !is_opaque && + !(explicit_align.is_some() && + self.already_packed(ctx).unwrap_or(false)) + { let n = layout.map_or(1, |l| l.align); assert!(ctx.options().rust_features().repr_packed_n || n == 1); let packed_repr = if n == 1 { @@ -5136,6 +5147,20 @@ pub(crate) mod utils { result.extend(old_items); } + pub(crate) fn prepend_float16_type( + result: &mut Vec, + ) { + let float16_type = quote! { + #[derive(PartialEq, Copy, Clone, Hash, Debug, Default)] + #[repr(transparent)] + pub struct __BindgenFloat16(pub u16); + }; + + let items = vec![float16_type]; + let old_items = mem::replace(result, items); + result.extend(old_items); + } + pub(crate) fn prepend_complex_type( result: &mut Vec, ) { diff --git a/third_party/rust/bindgen/codegen/serialize.rs b/third_party/rust/bindgen/codegen/serialize.rs index 02c46802632b..9765a8bdf228 100644 --- a/third_party/rust/bindgen/codegen/serialize.rs +++ b/third_party/rust/bindgen/codegen/serialize.rs @@ -270,6 +270,7 @@ impl<'a> CSerialize<'a> for Type { write!(writer, "const ")?; } match float_kind { + FloatKind::Float16 => write!(writer, "_Float16")?, FloatKind::Float => write!(writer, "float")?, FloatKind::Double => write!(writer, "double")?, FloatKind::LongDouble => write!(writer, "long double")?, @@ -281,6 +282,7 @@ impl<'a> CSerialize<'a> for Type { write!(writer, "const ")?; } match float_kind { + FloatKind::Float16 => write!(writer, "_Float16 complex")?, FloatKind::Float => write!(writer, "float complex")?, FloatKind::Double => write!(writer, "double complex")?, FloatKind::LongDouble => { diff --git a/third_party/rust/bindgen/codegen/struct_layout.rs b/third_party/rust/bindgen/codegen/struct_layout.rs index 567306036133..f4596a1992f5 100644 --- a/third_party/rust/bindgen/codegen/struct_layout.rs +++ b/third_party/rust/bindgen/codegen/struct_layout.rs @@ -91,9 +91,9 @@ impl<'a> StructLayoutTracker<'a> { ty: &'a Type, name: &'a str, visibility: FieldVisibilityKind, + is_packed: bool, ) -> Self { let known_type_layout = ty.layout(ctx); - let is_packed = comp.is_packed(ctx, known_type_layout.as_ref()); let (is_rust_union, can_copy_union_fields) = comp.is_rust_union(ctx, known_type_layout.as_ref(), name); StructLayoutTracker { @@ -156,9 +156,7 @@ impl<'a> StructLayoutTracker<'a> { self.latest_field_layout = Some(layout); self.last_field_was_bitfield = true; - // NB: We intentionally don't update the max_field_align here, since our - // bitfields code doesn't necessarily guarantee it, so we need to - // actually generate the dummy alignment. + self.max_field_align = cmp::max(self.max_field_align, layout.align); } /// Returns a padding field if necessary for a given new field _before_ @@ -214,7 +212,10 @@ impl<'a> StructLayoutTracker<'a> { 0 } else if !self.is_packed { self.padding_bytes(field_layout) - } else if let Some(l) = self.known_type_layout { + } else if let Some(mut l) = self.known_type_layout { + if field_layout.align < l.align { + l.align = field_layout.align; + } self.padding_bytes(l) } else { 0 diff --git a/third_party/rust/bindgen/features.rs b/third_party/rust/bindgen/features.rs index 67c6fb4565ae..e5e206805335 100644 --- a/third_party/rust/bindgen/features.rs +++ b/third_party/rust/bindgen/features.rs @@ -95,9 +95,9 @@ macro_rules! define_rust_targets { // not stable. define_rust_targets! { Nightly => { - thiscall_abi: #42202, vectorcall_abi, }, + Stable_1_73(73) => { thiscall_abi: #42202 }, Stable_1_71(71) => { c_unwind_abi: #106075 }, Stable_1_68(68) => { abi_efiapi: #105795 }, Stable_1_64(64) => { core_ffi_c: #94503 }, diff --git a/third_party/rust/bindgen/ir/comp.rs b/third_party/rust/bindgen/ir/comp.rs index 89e77e160fe5..fed6ba8ac8ca 100644 --- a/third_party/rust/bindgen/ir/comp.rs +++ b/third_party/rust/bindgen/ir/comp.rs @@ -1,5 +1,7 @@ //! Compound types (unions and structs) in our intermediate representation. +use itertools::Itertools; + use super::analysis::Sizedness; use super::annotations::Annotations; use super::context::{BindgenContext, FunctionId, ItemId, TypeId, VarId}; @@ -15,7 +17,6 @@ use crate::ir::derive::CanDeriveCopy; use crate::parse::ParseError; use crate::HashMap; use crate::NonCopyUnionStyle; -use peeking_take_while::PeekableExt; use std::cmp; use std::io; use std::mem; @@ -1641,6 +1642,26 @@ impl CompInfo { false } + /// Return true if a compound type is "naturally packed". This means we can exclude the + /// "packed" attribute without changing the layout. + /// This is useful for types that need an "align(N)" attribute since rustc won't compile + /// structs that have both of those attributes. + pub(crate) fn already_packed(&self, ctx: &BindgenContext) -> Option { + let mut total_size: usize = 0; + + for field in self.fields().iter() { + let layout = field.layout(ctx)?; + + if layout.align != 0 && total_size % layout.align != 0 { + return Some(false); + } + + total_size += layout.size; + } + + Some(true) + } + /// Returns true if compound type has been forward declared pub(crate) fn is_forward_declaration(&self) -> bool { self.is_forward_declaration diff --git a/third_party/rust/bindgen/ir/context.rs b/third_party/rust/bindgen/ir/context.rs index c5e2832cc90d..517d3365b646 100644 --- a/third_party/rust/bindgen/ir/context.rs +++ b/third_party/rust/bindgen/ir/context.rs @@ -19,7 +19,7 @@ use super::module::{Module, ModuleKind}; use super::template::{TemplateInstantiation, TemplateParameters}; use super::traversal::{self, Edge, ItemTraversal}; use super::ty::{FloatKind, Type, TypeKind}; -use crate::clang::{self, Cursor}; +use crate::clang::{self, ABIKind, Cursor}; use crate::codegen::CodegenError; use crate::BindgenOptions; use crate::{Entry, HashMap, HashSet}; @@ -386,6 +386,9 @@ pub(crate) struct BindgenContext { /// Whether a bindgen complex was generated generated_bindgen_complex: Cell, + /// Whether a bindgen float16 was generated + generated_bindgen_float16: Cell, + /// The set of `ItemId`s that are allowlisted. This the very first thing /// computed after parsing our IR, and before running any of our analyses. allowlisted: Option, @@ -585,6 +588,7 @@ If you encounter an error missing from this list, please file an issue or a PR!" target_info, options, generated_bindgen_complex: Cell::new(false), + generated_bindgen_float16: Cell::new(false), allowlisted: None, blocklisted_types_implement_traits: Default::default(), codegen_items: None, @@ -622,6 +626,11 @@ If you encounter an error missing from this list, please file an issue or a PR!" self.target_info.pointer_width / 8 } + /// Returns the ABI, which is mostly useful for determining the mangling kind. + pub(crate) fn abi_kind(&self) -> ABIKind { + self.target_info.abi + } + /// Get the stack of partially parsed types that we are in the middle of /// parsing. pub(crate) fn currently_parsed_types(&self) -> &[PartialType] { @@ -2005,6 +2014,7 @@ If you encounter an error missing from this list, please file an issue or a PR!" CXType_ULongLong => TypeKind::Int(IntKind::ULongLong), CXType_Int128 => TypeKind::Int(IntKind::I128), CXType_UInt128 => TypeKind::Int(IntKind::U128), + CXType_Float16 | CXType_Half => TypeKind::Float(FloatKind::Float16), CXType_Float => TypeKind::Float(FloatKind::Float), CXType_Double => TypeKind::Float(FloatKind::Double), CXType_LongDouble => TypeKind::Float(FloatKind::LongDouble), @@ -2013,6 +2023,7 @@ If you encounter an error missing from this list, please file an issue or a PR!" let float_type = ty.elem_type().expect("Not able to resolve complex type?"); let float_kind = match float_type.kind() { + CXType_Float16 | CXType_Half => FloatKind::Float16, CXType_Float => FloatKind::Float, CXType_Double => FloatKind::Double, CXType_LongDouble => FloatKind::LongDouble, @@ -2528,6 +2539,16 @@ If you encounter an error missing from this list, please file an issue or a PR!" self.generated_bindgen_complex.get() } + /// Call if a bindgen float16 is generated + pub(crate) fn generated_bindgen_float16(&self) { + self.generated_bindgen_float16.set(true) + } + + /// Whether we need to generate the bindgen float16 type + pub(crate) fn need_bindgen_float16_type(&self) -> bool { + self.generated_bindgen_float16.get() + } + /// Compute which `enum`s have an associated `typedef` definition. fn compute_enum_typedef_combos(&mut self) { let _t = self.timer("compute_enum_typedef_combos"); diff --git a/third_party/rust/bindgen/ir/function.rs b/third_party/rust/bindgen/ir/function.rs index 5bfb70eff1d2..448bcd22ea8b 100644 --- a/third_party/rust/bindgen/ir/function.rs +++ b/third_party/rust/bindgen/ir/function.rs @@ -7,7 +7,7 @@ use super::item::Item; use super::traversal::{EdgeKind, Trace, Tracer}; use super::ty::TypeKind; use crate::callbacks::{ItemInfo, ItemKind}; -use crate::clang::{self, Attribute}; +use crate::clang::{self, ABIKind, Attribute}; use crate::parse::{ClangSubItemParser, ParseError, ParseResult}; use clang_sys::{self, CXCallingConv}; @@ -303,6 +303,7 @@ fn get_abi(cc: CXCallingConv) -> ClangAbi { CXCallingConv_X86VectorCall => ClangAbi::Known(Abi::Vectorcall), CXCallingConv_AAPCS => ClangAbi::Known(Abi::Aapcs), CXCallingConv_X86_64Win64 => ClangAbi::Known(Abi::Win64), + CXCallingConv_AArch64VectorCall => ClangAbi::Known(Abi::Vectorcall), other => ClangAbi::Unknown(other), } } @@ -323,11 +324,12 @@ pub(crate) fn cursor_mangling( return None; } + let is_itanium_abi = ctx.abi_kind() == ABIKind::GenericItanium; let is_destructor = cursor.kind() == clang_sys::CXCursor_Destructor; if let Ok(mut manglings) = cursor.cxx_manglings() { while let Some(m) = manglings.pop() { // Only generate the destructor group 1, see below. - if is_destructor && !m.ends_with("D1Ev") { + if is_itanium_abi && is_destructor && !m.ends_with("D1Ev") { continue; } @@ -340,7 +342,7 @@ pub(crate) fn cursor_mangling( return None; } - if is_destructor { + if is_itanium_abi && is_destructor { // With old (3.8-) libclang versions, and the Itanium ABI, clang returns // the "destructor group 0" symbol, which means that it'll try to free // memory, which definitely isn't what we want. @@ -503,10 +505,24 @@ impl FunctionSig { Default::default() }; - // This looks easy to break but the clang parser keeps the type spelling clean even if - // other attributes are added. - is_divergent = - is_divergent || ty.spelling().contains("__attribute__((noreturn))"); + // Check if the type contains __attribute__((noreturn)) outside of parentheses. This is + // somewhat fragile, but it seems to be the only way to get at this information as of + // libclang 9. + let ty_spelling = ty.spelling(); + let has_attribute_noreturn = ty_spelling + .match_indices("__attribute__((noreturn))") + .any(|(i, _)| { + let depth = ty_spelling[..i] + .bytes() + .filter_map(|ch| match ch { + b'(' => Some(1), + b')' => Some(-1), + _ => None, + }) + .sum::(); + depth == 0 + }); + is_divergent = is_divergent || has_attribute_noreturn; let is_method = kind == CXCursor_CXXMethod; let is_constructor = kind == CXCursor_Constructor; diff --git a/third_party/rust/bindgen/ir/item.rs b/third_party/rust/bindgen/ir/item.rs index dd587b088b9f..2941eb81e29e 100644 --- a/third_party/rust/bindgen/ir/item.rs +++ b/third_party/rust/bindgen/ir/item.rs @@ -668,8 +668,11 @@ impl Item { ItemKind::Function(..) => { ctx.options().blocklisted_functions.matches(&name) } - // TODO: Add constant / namespace blocklisting? - ItemKind::Var(..) | ItemKind::Module(..) => false, + ItemKind::Var(..) => { + ctx.options().blocklisted_vars.matches(&name) + } + // TODO: Add namespace blocklisting? + ItemKind::Module(..) => false, } } diff --git a/third_party/rust/bindgen/ir/ty.rs b/third_party/rust/bindgen/ir/ty.rs index 1aee0659708e..b7a429323e8f 100644 --- a/third_party/rust/bindgen/ir/ty.rs +++ b/third_party/rust/bindgen/ir/ty.rs @@ -558,6 +558,8 @@ impl TemplateParameters for TypeKind { /// The kind of float this type represents. #[derive(Debug, Copy, Clone, PartialEq, Eq)] pub(crate) enum FloatKind { + /// A half (`_Float16` or `__fp16`) + Float16, /// A `float`. Float, /// A `double`. diff --git a/third_party/rust/bindgen/lib.rs b/third_party/rust/bindgen/lib.rs index 54348e223259..c4ab11486ce5 100644 --- a/third_party/rust/bindgen/lib.rs +++ b/third_party/rust/bindgen/lib.rs @@ -440,13 +440,14 @@ impl Builder { impl BindgenOptions { fn build(&mut self) { - const REGEX_SETS_LEN: usize = 28; + const REGEX_SETS_LEN: usize = 29; let regex_sets: [_; REGEX_SETS_LEN] = [ &mut self.blocklisted_types, &mut self.blocklisted_functions, &mut self.blocklisted_items, &mut self.blocklisted_files, + &mut self.blocklisted_vars, &mut self.opaque_types, &mut self.allowlisted_vars, &mut self.allowlisted_types, @@ -483,6 +484,7 @@ impl BindgenOptions { "--blocklist-function", "--blocklist-item", "--blocklist-file", + "--blocklist-var", "--opaque-type", "--allowlist-type", "--allowlist-function", @@ -927,22 +929,24 @@ impl Bindings { /// Write these bindings as source text to the given `Write`able. pub fn write<'a>(&self, mut writer: Box) -> io::Result<()> { + const NL: &str = if cfg!(windows) { "\r\n" } else { "\n" }; + if !self.options.disable_header_comment { let version = option_env!("CARGO_PKG_VERSION").unwrap_or("(unknown version)"); - let header = format!( - "/* automatically generated by rust-bindgen {version} */\n\n", - ); - writer.write_all(header.as_bytes())?; + writeln!( + writer, + "/* automatically generated by rust-bindgen {version} */{NL}", + )?; } for line in self.options.raw_lines.iter() { writer.write_all(line.as_bytes())?; - writer.write_all("\n".as_bytes())?; + writer.write_all(NL.as_bytes())?; } if !self.options.raw_lines.is_empty() { - writer.write_all("\n".as_bytes())?; + writer.write_all(NL.as_bytes())?; } match self.format_tokens(&self.module) { @@ -1237,7 +1241,7 @@ fn get_target_dependent_env_var( /// use bindgen::builder; /// let bindings = builder() /// .header("path/to/input/header") -/// .parse_callbacks(Box::new(bindgen::CargoCallbacks)) +/// .parse_callbacks(Box::new(bindgen::CargoCallbacks::new())) /// .generate(); /// ``` #[derive(Debug)] diff --git a/third_party/rust/bindgen/options/mod.rs b/third_party/rust/bindgen/options/mod.rs index 3a82bcf397c8..1fc22416158f 100644 --- a/third_party/rust/bindgen/options/mod.rs +++ b/third_party/rust/bindgen/options/mod.rs @@ -222,6 +222,22 @@ options! { }, as_args: "--blocklist-file", }, + /// Variables that have been blocklisted and should not appear in the generated code. + blocklisted_vars: RegexSet { + methods: { + regex_option! { + /// Do not generate any bindings for the given variable. + /// + /// This option is not recursive, meaning that it will only block variables whose + /// names explicitly match the argument of this method. + pub fn blocklist_var>(mut self, arg: T) -> Builder { + self.options.blocklisted_vars.insert(arg); + self + } + } + }, + as_args: "--blocklist-var", + }, /// Types that should be treated as opaque structures in the generated code. opaque_types: RegexSet { methods: { diff --git a/third_party/rust/peeking_take_while/.cargo-checksum.json b/third_party/rust/peeking_take_while/.cargo-checksum.json deleted file mode 100644 index 763db27cb9d3..000000000000 --- a/third_party/rust/peeking_take_while/.cargo-checksum.json +++ /dev/null @@ -1 +0,0 @@ -{"files":{"Cargo.toml":"caf1a07b54869ad1b35394c5b9262fe1e8f63b7ab85bf517ad6d59c1ad1d64bc","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"7b63ecd5f1902af1b63729947373683c32745c16a10e8e6292e2e2dcd7e90ae0","README.md":"9f7659439d3e98a3aae69562648a651e49eeac7152f489deb77dd09c0c8010d0","src/lib.rs":"699149181f71aa88dc6585bd047fc29c6f5baba2b8bf5fbd1c5612966322b379"},"package":"19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099"} \ No newline at end of file diff --git a/third_party/rust/peeking_take_while/Cargo.toml b/third_party/rust/peeking_take_while/Cargo.toml deleted file mode 100644 index 40aeef2d79c7..000000000000 --- a/third_party/rust/peeking_take_while/Cargo.toml +++ /dev/null @@ -1,14 +0,0 @@ -[package] -authors = ["Nick Fitzgerald "] -description = "Like `Iterator::take_while`, but calls the predicate on a peeked value. This allows you to use `Iterator::by_ref` and `Iterator::take_while` together, and still get the first value for which the `take_while` predicate returned false after dropping the `by_ref`." -categories = ["rust-patterns"] -keywords = ["iterator", "take_while", "peek", "by_ref"] -license = "Apache-2.0/MIT" -name = "peeking_take_while" -readme = "./README.md" -repository = "https://github.com/fitzgen/peeking_take_while" -version = "0.1.2" - -[badges] -[badges.travis-ci] -repository = "fitzgen/peeking_take_while" diff --git a/third_party/rust/peeking_take_while/LICENSE-APACHE b/third_party/rust/peeking_take_while/LICENSE-APACHE deleted file mode 100644 index 16fe87b06e80..000000000000 --- a/third_party/rust/peeking_take_while/LICENSE-APACHE +++ /dev/null @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - -TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - -1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - -2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - -3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - -4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - -5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - -6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - -7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - -8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - -9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - -END OF TERMS AND CONDITIONS - -APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - -Copyright [yyyy] [name of copyright owner] - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. diff --git a/third_party/rust/peeking_take_while/LICENSE-MIT b/third_party/rust/peeking_take_while/LICENSE-MIT deleted file mode 100644 index e69282e381bc..000000000000 --- a/third_party/rust/peeking_take_while/LICENSE-MIT +++ /dev/null @@ -1,25 +0,0 @@ -Copyright (c) 2015 The Rust Project Developers - -Permission is hereby granted, free of charge, to any -person obtaining a copy of this software and associated -documentation files (the "Software"), to deal in the -Software without restriction, including without -limitation the rights to use, copy, modify, merge, -publish, distribute, sublicense, and/or sell copies of -the Software, and to permit persons to whom the Software -is furnished to do so, subject to the following -conditions: - -The above copyright notice and this permission notice -shall be included in all copies or substantial portions -of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF -ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED -TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A -PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT -SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR -IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -DEALINGS IN THE SOFTWARE. diff --git a/third_party/rust/peeking_take_while/README.md b/third_party/rust/peeking_take_while/README.md deleted file mode 100644 index c7486b724dae..000000000000 --- a/third_party/rust/peeking_take_while/README.md +++ /dev/null @@ -1,58 +0,0 @@ -# `peeking_take_while` - -[![Build Status](https://travis-ci.org/fitzgen/peeking_take_while.png?branch=master)](https://travis-ci.org/fitzgen/peeking_take_while) - -Provides the `peeking_take_while` iterator adaptor method. - -The `peeking_take_while` method is very similar to `take_while`, but behaves -differently when used with a borrowed iterator (perhaps returned by -`Iterator::by_ref`). - -`peeking_take_while` peeks at the next item in the iterator and runs the -predicate on that peeked item. This avoids consuming the first item yielded by -the underlying iterator for which the predicate returns `false`. On the other -hand, `take_while` will consume that first item for which the predicate returns -`false`, and it will be lost. - -```rust -extern crate peeking_take_while; - -// Bring the `peeking_take_while` method for peekable iterators into -// scope. -use peeking_take_while::PeekableExt; - -// Let's say we have two collections we want to iterate through: `xs` and -// `ys`. We want to perform one operation on all the leading contiguous -// elements that match some predicate, and a different thing with the rest of -// the elements. With the `xs`, we will use the normal `take_while`. With the -// `ys`, we will use `peeking_take_while`. - -let xs: Vec = (0..100).collect(); -let ys = xs.clone(); - -let mut iter_xs = xs.into_iter(); -let mut iter_ys = ys.into_iter().peekable(); - -{ - // Let's do one thing with all the items that are less than 10. - - let xs_less_than_ten = iter_xs.by_ref().take_while(|x| *x < 10); - for x in xs_less_than_ten { - do_things_with(x); - } - - let ys_less_than_ten = iter_ys.by_ref().peeking_take_while(|y| *y < 10); - for y in ys_less_than_ten { - do_things_with(y); - } -} - -// And now we will do some other thing with the items that are greater than -// or equal to 10. - -// ...except, when using plain old `take_while` we lost 10! -assert_eq!(iter_xs.next(), Some(11)); - -// However, when using `peeking_take_while` we did not! Great! -assert_eq!(iter_ys.next(), Some(10)); -``` diff --git a/third_party/rust/peeking_take_while/src/lib.rs b/third_party/rust/peeking_take_while/src/lib.rs deleted file mode 100644 index 67f36d84db12..000000000000 --- a/third_party/rust/peeking_take_while/src/lib.rs +++ /dev/null @@ -1,117 +0,0 @@ -//! # `peeking_take_while` -//! -//! Provides the `peeking_take_while` iterator adaptor method. -//! -//! The `peeking_take_while` method is very similar to `take_while`, but behaves -//! differently when used with a borrowed iterator (perhaps returned by -//! `Iterator::by_ref`). -//! -//! `peeking_take_while` peeks at the next item in the iterator and runs the -//! predicate on that peeked item. This avoids consuming the first item yielded -//! by the underlying iterator for which the predicate returns `false`. On the -//! other hand, `take_while` will consume that first item for which the -//! predicate returns `false`, and it will be lost. -//! -//! ``` -//! extern crate peeking_take_while; -//! -//! // Bring the `peeking_take_while` method for peekable iterators into -//! // scope. -//! use peeking_take_while::PeekableExt; -//! -//! # fn main() { -//! // Let's say we have two collections we want to iterate through: `xs` and -//! // `ys`. We want to perform one operation on all the leading contiguous -//! // elements that match some predicate, and a different thing with the rest of -//! // the elements. With the `xs`, we will use the normal `take_while`. With the -//! // `ys`, we will use `peeking_take_while`. -//! -//! let xs: Vec = (0..100).collect(); -//! let ys = xs.clone(); -//! -//! let mut iter_xs = xs.into_iter(); -//! let mut iter_ys = ys.into_iter().peekable(); -//! -//! { -//! // Let's do one thing with all the items that are less than 10. -//! # fn do_things_with(_: T) {} -//! -//! let xs_less_than_ten = iter_xs.by_ref().take_while(|x| *x < 10); -//! for x in xs_less_than_ten { -//! do_things_with(x); -//! } -//! -//! let ys_less_than_ten = iter_ys.by_ref().peeking_take_while(|y| *y < 10); -//! for y in ys_less_than_ten { -//! do_things_with(y); -//! } -//! } -//! -//! // And now we will do some other thing with the items that are greater than -//! // or equal to 10. -//! -//! // ...except, when using plain old `take_while` we lost 10! -//! assert_eq!(iter_xs.next(), Some(11)); -//! -//! // However, when using `peeking_take_while` we did not! Great! -//! assert_eq!(iter_ys.next(), Some(10)); -//! # } -//! ``` - -use std::iter::Peekable; - -/// The iterator returned by `peeking_take_while`. -/// -/// See the [module documentation](./index.html) for details. -pub struct PeekingTakeWhile<'a, I, P> - where I: 'a + Iterator -{ - iter: &'a mut Peekable, - predicate: P, -} - -impl<'a, I, P> Iterator for PeekingTakeWhile<'a, I, P> - where I: Iterator, - I::Item: ::std::fmt::Debug, - P: FnMut(&::Item) -> bool -{ - type Item = ::Item; - - fn next(&mut self) -> Option { - let predicate = &mut self.predicate; - if self.iter.peek().map_or(false, |x| !(predicate)(x)) { - None - } else { - self.iter.next() - } - } -} - -/// The `Iterator` extension trait that provides the `peeking_take_while` -/// method. -/// -/// See the [module documentation](./index.html) for details. -pub trait PeekableExt<'a, I>: Iterator - where I: 'a + Iterator -{ - /// The `Iterator` extension trait that provides the `peeking_take_while` - /// method. - /// - /// See the [module documentation](./index.html) for details. - fn peeking_take_while

(&'a mut self, predicate: P) -> PeekingTakeWhile<'a, I, P> - where Self: Sized, - P: FnMut(&::Item) -> bool; -} - -impl<'a, I> PeekableExt<'a, I> for Peekable - where I: 'a + Iterator -{ - fn peeking_take_while

(&'a mut self, predicate: P) -> PeekingTakeWhile - where P: FnMut(&::Item) -> bool - { - PeekingTakeWhile { - iter: self, - predicate: predicate, - } - } -}