diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:20:39 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:20:39 +0000 |
commit | 1376c5a617be5c25655d0d7cb63e3beaa5a6e026 (patch) | |
tree | 3bb8d61aee02bc7a15eab3f36e3b921afc2075d0 /vendor/syn | |
parent | Releasing progress-linux version 1.69.0+dfsg1-1~progress7.99u1. (diff) | |
download | rustc-1376c5a617be5c25655d0d7cb63e3beaa5a6e026.tar.xz rustc-1376c5a617be5c25655d0d7cb63e3beaa5a6e026.zip |
Merging upstream version 1.70.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/syn')
90 files changed, 10515 insertions, 12409 deletions
diff --git a/vendor/syn/.cargo-checksum.json b/vendor/syn/.cargo-checksum.json index edd04e5cd..e9aa3eafe 100644 --- a/vendor/syn/.cargo-checksum.json +++ b/vendor/syn/.cargo-checksum.json @@ -1 +1 @@ -{"files":{"Cargo.toml":"1ff565970239963d56cbfdd20476fd265fcf2d050fc5ed92a298686321985230","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"23f18e03dc49df91622fe2a76176497404e46ced8a715d9d2b67a7446571cca3","README.md":"ea9f2b6340b302b5608d2bedcda7e2d707f3eaebf4cc983c02d55071ead7096f","benches/file.rs":"3d737ef3878f6e242b003af9bd539e565f98439a12ee44d9548d84e3fdd7af0c","benches/rust.rs":"11ac9fe898a7bf1bd63e8a8cc9c08bd795b01f0248215cff99afaaf28ce87fab","build.rs":"b815649fd2929d3debd93a58f5da2fb8eba506047a6a5ba538347305828a87b0","src/attr.rs":"234d9cebe2c5e92cd0f5e1117bf5755037e2e905788a337000a65d4bd82b63aa","src/await.rs":"8aa22e3c201cb2bdb6b4817fa00901f308ab06817607aa7b884c58c957705969","src/bigint.rs":"efc7f64959980653d73fe4f8bc2a3a2904dc05f45b02c6dc15cd316fa3d7c338","src/buffer.rs":"4d15f35273d485261be4f1a765ae03abc1daee9fc9dac5fb4f9b624d6b22cb58","src/custom_keyword.rs":"5c706fc3611e73d16b8c019d7ecb848a86b1ccfcd9e556f80bb6e6a4abe058a8","src/custom_punctuation.rs":"8a666298e774b0d326642f0f73284f6677d0d0a7c9e4a712c9c98d010b4d8a2c","src/data.rs":"75d2c2b5d6a01bf8a6fa2845e41663d8045a78b4b191f1a1bd7c93619d20017a","src/derive.rs":"ee24a202be2d36ccdff576dd9cd765e94b33ef2286946e6725d75b08e777d462","src/discouraged.rs":"6c6a9298f8d24f578da119557bc588f3bd928f7b79fca27d6bdfe3e786dd005f","src/drops.rs":"013385f1dd95663f1afab41abc1e2eea04181998644828935ca564c74d6462ae","src/error.rs":"b30e738fdab7d10e126350e09f7ad907bf4dc14e684b9ed9eeea001c7ee356e0","src/export.rs":"0cf50d70c32d5fddba8b1193032df62e560237c113df3e86ba26b565cc82838e","src/expr.rs":"5eea3828f3291b0ce5463ed5f0c23fc8a39aeceae68a3247ae02ae467dd35a98","src/ext.rs":"1f648cff1d705a1cea64b32b77482b97a82d2fe0aaf63b40cade91e5c02dc969","src/file.rs":"f86697655222ae294215114f4eae8e6b0b5e2a935d6c479ff8f8f889c4efd2e2","src/gen/clone.rs":"76e89fe155fedf43bc4a252af7e35319b82ce455f584bad8698fdc3f9b7f5d4e","src/gen/debug.rs":"4b05e474e864ce6bf1a5a6ab48ee6c0ecdf41a0d750237990cf2e31963bc1208","src/gen/eq.rs":"79f84836fdcd5cfa352f38055dab7c3246c7757650946c1c701234b11021652a","src/gen/fold.rs":"fcd6a05c8c8e0c36e7ede8593002528b553c8b648fbed452106fd6a8a8c9212a","src/gen/hash.rs":"575e8beae303c1eabda12bf76cbd82672268c502a8ebb8517aab18b40fdbc44e","src/gen/visit.rs":"ced9f6c17d2b3eb3553faab710cb2b3d44d6bca7d1862c8c5da09c3d45debecb","src/gen/visit_mut.rs":"966ea340c53461bf8a1c6bed3c882e4ab8b8907fd18ac35531266f7891ae5f46","src/gen_helper.rs":"ea6c66388365971db6a2fc86cbb208f7eacde77e245bc8623f27a3642a3d7741","src/generics.rs":"b81ce0d3ea0f7accef4590d5181cecc4589395865abaea60b0470da727f17340","src/group.rs":"166f0fbb365471ffa3e4f554b72c2b460cbf7e3a1f9bec6c01ef6bbbcd751041","src/ident.rs":"2443e43561abea7eea577b141422258237a663499c839923d8a5ca6fea2470db","src/item.rs":"419c4d6135a7ca7b8f94b5ba038b6af8fcb3939ae807153a19e3c82e9b01e0b7","src/lib.rs":"8c152481907905472fc3e4aae63f82ed78d4d16cf8cc286675727668760c7f2e","src/lifetime.rs":"b18862ef1e690037a4f308ea897debad7bc5038584e3b26c6d8809752ea0e3c2","src/lit.rs":"fc06ddd523f7f9971d8abdb4c8d5d51030ffb3d6810615d5575ae210a7800695","src/lookahead.rs":"e2c2b6d55906421e83dab51463b58bc6dcb582f1bff9303c8b62afefb8d71e5f","src/mac.rs":"004cb89f9697564f6c9ee837e08ead68463ef946fb4c13c6c105adf2ba364b2b","src/macros.rs":"936f503c2fcde602f05220954ecaf87625c6138d0af13d33d56c7b6530110084","src/op.rs":"9d499022902743a6a0a19223b356449a979b90e60552d0446497d72750e646a4","src/parse.rs":"7b2f8caddf25a5734cbcdf7cbf043cbf9afbc07b484966cd59ddfcec9f970fb3","src/parse_macro_input.rs":"a5d16859b782bb6a2754c1066468a2f1ea05b57390caa32175bb84064973be7b","src/parse_quote.rs":"d7d996f1382c68b5fbfd4b7327ce1d389cd43c3bb3c4f382a35994d0bb79d8ab","src/pat.rs":"b2de04ae6c01df50eab9d1c3908287aca8424adc2007b926c7bcf74d1f64d40a","src/path.rs":"58a4fb3b1ff76d32cfd84a3914f8cadbf55b363c1929222b362b7465385520ac","src/print.rs":"da6529c1d9d21aaf6c835f66b4e67eacb7cf91a10eb5e9a2143b49bf99b3b5e1","src/punctuated.rs":"44c29523dee76605be2531674fe21ed2f1bbd02559aac8b7a49c70af23129ca1","src/reserved.rs":"e70e028bd55cfa43e23cab4ba29e4dc53a3d91eff685ef2b6e57efc2b87a3428","src/sealed.rs":"896a495a5340eec898527f18bd4ddca408ea03ea0ee3af30074ff48deace778d","src/span.rs":"748c51c6feb223c26d3b1701f5bb98aee823666c775c98106cfa24fe29d8cec1","src/spanned.rs":"3ca016a943637653ab98e373dfb826a120f3c159867346fa38a844439944eb39","src/stmt.rs":"601a6914f1e0bf97ae0d31d474a531d195b8c251a4ded11aa8746ac0018d367b","src/thread.rs":"815eca6bd64f4eef7c447f0809e84108f5428ff50225224b373efd8fbb696874","src/token.rs":"5e423a696f80e281c322f37c87577f9fdc28607e9c007e24896a2b12da62d5ad","src/tt.rs":"32402645b6e82ef1e882945721b59b5fb7b0ee337d1972876362ecacef643d0f","src/ty.rs":"9befd22f8c8ac731b7f68008552a1335797a3ef19184190eec0e103e4ebe18a7","src/verbatim.rs":"96d4280e4556a1841b8dcb306bc35a94d18f71dceb63f3c27a4fe7f776191760","src/whitespace.rs":"e63dd0aa3d34029f17766a8b09c1a6e4479e36c552c8b7023d710a399333aace","tests/common/eq.rs":"e930fb0bdcec3e787986b56785b1db580e5a26a5131df2f2b91a6da37069de15","tests/common/mod.rs":"432ad35577f836a20b517d8c26ed994ac25fe73ef2f461c67688b61b99762015","tests/common/parse.rs":"81580f23583723f7a2a337c4d13ebc021057cd825562fb4e474caa7cc641fed9","tests/debug/gen.rs":"1b7f875344cb04a7dd3df62deac2f410a9d107c097986e68006d87465f5f5306","tests/debug/mod.rs":"3a6bb799f478101f71c84c6f1a854a58afe2f9db43c39017909346ca20262d94","tests/macros/mod.rs":"aff805b35cfd55aef6a1359ff747e4023afcb08d69d86aff4c19465d29dda088","tests/regression.rs":"86731134bfb9bb693d9a4fc62393027de80a8bf031109ea6c7ea475b1ebdde8d","tests/regression/issue1108.rs":"adcc55a42239d344da74216ed85fc14153ddd6ca4dec4872d8339604ba78c185","tests/regression/issue1235.rs":"a2266b10c3f7c7af5734817ab0a3e8b309b51e7d177b63f26e67e6b744d280b0","tests/repo/mod.rs":"159c2c4b6416d26ac42ffc35f6cb587c4c1e2b0f24de9aa42b0337a534d7d86d","tests/repo/progress.rs":"c08d0314a7f3ecf760d471f27da3cd2a500aeb9f1c8331bffb2aa648f9fabf3f","tests/test_asyncness.rs":"cff01db49d28ab23b0b258bc6c0a5cc4071be4fe7248eef344a5d79d2fb649b7","tests/test_attribute.rs":"0ffd99384e1a52ae17d9fed5c4053e411e8f9018decef07ffa621d1faa7329d8","tests/test_derive_input.rs":"62bb86aaaaf730187a46ff700a8e3b2d1a163039b109b6a483aa44ed2b6806fe","tests/test_expr.rs":"41eb343829ad36cdea40cd06d45a90765e7fe6f1e47dd550daf1b6096c3a7b44","tests/test_generics.rs":"54b7d2afc19aa6e9049585f4c8f7d3f0c29ac3bd11a2c769e9df76f18a4f5ecb","tests/test_grouping.rs":"6276c3c73bba649dec5c97904ad2492879f918bc887a2c425d095c654ca0d925","tests/test_ident.rs":"9eb53d1e21edf23e7c9e14dc74dcc2b2538e9221e19dbcc0a44e3acc2e90f3f6","tests/test_item.rs":"a3642c80066f1e7787becfd0278af90a6b7968d6c1249e25e81663aa454cfb2a","tests/test_iterators.rs":"9cf6fde17853ce7d5617e1de9ef901c47ca35c0f1c2dd668c0d0604d7b48598c","tests/test_lit.rs":"19740ea9cd4a980bcab9b0dcaa4b032bb6ebb137fa5e4237140b97da1d9679fa","tests/test_meta.rs":"65d4586d131f6cac66694ca5e936748ec4e7f7423af6d8da509240e6be14800b","tests/test_parse_buffer.rs":"68d857f776396d064fcc0023c37093c2fbf75ee68e8241d4014d00d1423c18e9","tests/test_parse_stream.rs":"bf1db6fab7ac396fa61012faccbe6ffbc9c3d795ed2900be75e91c5b09b0c62f","tests/test_pat.rs":"d4465f4fc3fd5d6e534ba8efabe1e0ed6da89de4ac7c96effa6bfb880c4287cf","tests/test_path.rs":"71092a5ae2c9143b92a8fe15a92d39958b3c28bd4d4275cfb2d22cbdd53ada07","tests/test_precedence.rs":"736eee861c4c7a3d7d4387d2fb1b5eced1541790d34974f72b0a5532797e73c3","tests/test_receiver.rs":"084eca59984b9a18651da52f2c4407355da3de1335916a12477652999e2d01cc","tests/test_round_trip.rs":"c3c415413d5177a728c7cbbfb7ef44aebbc6a2c821dd56695156e9e33636fd57","tests/test_shebang.rs":"f5772cadad5b56e3112cb16308b779f92bce1c3a48091fc9933deb2276a69331","tests/test_should_parse.rs":"1d3535698a446e2755bfc360676bdb161841a1f454cdef6e7556c6d06a95c89d","tests/test_size.rs":"6720d55569808244ab011364c39931f06aa509cd05f98ab908b0670e8501b3c8","tests/test_stmt.rs":"0601fc32131b5501dfcdc4b4248d46bf21e0a98a49eb19439e1a46869dfb30b7","tests/test_token_trees.rs":"43e56a701817e3c3bfd0cae54a457dd7a38ccb3ca19da41e2b995fdf20e6ed18","tests/test_ty.rs":"f71d7f7f1c038aaabea8dd4c03c0d5752c76d570f8b4885a81659825bbb4d576","tests/test_visibility.rs":"7456fcb3a6634db509748aededff9c2d8b242d511a3e5ee3022e40b232892704","tests/zzz_stable.rs":"2a862e59cb446235ed99aec0e6ada8e16d3ecc30229b29d825b7c0bbc2602989"},"package":"1f4064b5b16e03ae50984a5a8ed5d4f8803e6bc1fd170a3cda91a1be4b18e3f5"}
\ No newline at end of file +{"files":{"Cargo.toml":"c1b6d19b197753cc601931a339bd69184fbc2b334cfe1e528dacc5234f0952e0","LICENSE-APACHE":"62c7a1e35f56406896d7aa7ca52d0cc0d272ac022b5d2796e7d6905db8a3636a","LICENSE-MIT":"23f18e03dc49df91622fe2a76176497404e46ced8a715d9d2b67a7446571cca3","README.md":"33fd74d909172770aaf840c519f7c59ef185a4a8d21c1e5e4dcd6a398e7e1e61","benches/file.rs":"0a0527c78d849148cbb6118b4d36f72da7d4add865ba1a410e0a1be9e8dbfe0e","benches/rust.rs":"d152728d0ec01dd92cd803f7b9ad5f43ecb6adecb352c10e2d1f4b24049fb5e6","src/attr.rs":"bd5ffae18a363162f7d9c12a1b6c1d023070cbf1b060c98ebc38ef79f1de9c67","src/bigint.rs":"0299829b2f7a1a798fe2f7bc1680e4a10f9b6f4a852d09af4da2deab466c4242","src/buffer.rs":"634fed0b398163581d27b4693a481ffcef891c8e274d9b4574482a644ef9fce9","src/custom_keyword.rs":"b82199b98f67ed5c0025f5e8791b8c9a755522e54aa5ab8fbab2b01b36fdb400","src/custom_punctuation.rs":"39b38bc18553aa902a5ce842f503390c30e259b4404d5fb63d2401af7c73b527","src/data.rs":"7d217b0252a0d14b2db308ac00f48ba24a831e01a49b893f5b3ee6b580dab4cb","src/derive.rs":"3132e7f064725c7ca43f26daee93ec78037d46a935c6b0758af905cff450c15c","src/discouraged.rs":"482970b03bdee3cbc30c034f644e3293b25387db46300da5d8d8efd97dad8507","src/drops.rs":"013385f1dd95663f1afab41abc1e2eea04181998644828935ca564c74d6462ae","src/error.rs":"f48a24c90e362164cfedbfc5a3cb24d75bdab281276dee36b69a12707dd49bc7","src/export.rs":"6785b6329d7bc0a5b0efbf9d28af7cdbdfe279ae9a0e21ef177b144ed6188b66","src/expr.rs":"880c35b530f9afa1a94cedfb4b87f5cd7c790b9743d3e3b2f650c161db41ce94","src/ext.rs":"3cf2d869812e5be894aa1c48bf074da262143fb2df1c9ac1b5ee965bf2a96a1c","src/file.rs":"a4d510dd0e2756bd54983dfa747601918c801e987cbf92deab44cdca6a201aeb","src/gen/clone.rs":"46540509dc99bb849014948a0c5b02ea372d5feceae5ea391c29f226f06516eb","src/gen/debug.rs":"32b2076b755f021428a0fb268a94057e1bcb1cd400feb895946703d7919b843a","src/gen/eq.rs":"aa5455b2cc0d9846d119ce001e821872df911f65133b993e3801a42e8f635f2a","src/gen/fold.rs":"45ac5b6915d5214fa1e9af84621584443f599f838ed936fa8bda3b68a9cc4b6a","src/gen/hash.rs":"4ca8239c681ea5fd7b16bb61bff9034bff09680c088f5a16e90e99013e55742f","src/gen/visit.rs":"0a10ef3a2c5cae7aed83e8ffb5da9f9c85e0fdbae82025cc411f6328bf7fda9e","src/gen/visit_mut.rs":"1f6cfa463da0f970063e70831e3ff6b07d725c77c6e20ece17c0731d90d5b4a4","src/gen_helper.rs":"750caab67ba0ba11a95ea28cd38026485227bb4aa114cdb497472386f60fdb35","src/generics.rs":"d080112c1d3084e9d701ab628cfa77881ed9398c638ba40c7e4135d9b3f1e784","src/group.rs":"fb7f24019ab612ba85f091c4edda3b2f0154f39caa18c9a139ee600afffbeefa","src/ident.rs":"711647537aee87d7249bbcdeb2cc90d146937998dd435395c85c6b18a10b5e07","src/item.rs":"b31c1afb235d4e38d4c8624620a2e00d6e5c74e157daa83adb55dffabf3296ca","src/lib.rs":"6702797f3f54a52fa1f30278d42978e3d42cfdaef49b9d35ef41fcf0f9705384","src/lifetime.rs":"531ef74507eaf942a3aedfac83bbdbc17463102a6c806f675a83a0d6dc612c52","src/lit.rs":"72214440bdfa844aa86853aec42cd6900dff47a3cab4bc8d83ad205a115c09ce","src/lookahead.rs":"376092f91a1c32e1b277db0a6790fdda151c9ec51bd971fe6a6545b5b9e73b5d","src/mac.rs":"b1cf73f34a27a8f1429125e726623a524fb5dce875eb68ead3beaffa976442c3","src/macros.rs":"4e464104c590200213635624706d83e4a0ddd5aedd826ab4aabb390000f35ae0","src/meta.rs":"3184c17a1a0c65084eb3182b423860a81cc9b0c5b3355849563b17340d7c7fbf","src/op.rs":"fe5db7c3373b956234ea8a1a7d129a06e5aef5db77c44c1c2fedb4aaa667ac56","src/parse.rs":"07dafec0038234eba0c15845bd85f3250f41dce6d013f49e2364666bb9732bae","src/parse_macro_input.rs":"4a753b2a6dbfefd6dc93852d66b4f6d73ebd6b8b9be74019fc476f429b9a892d","src/parse_quote.rs":"60eff4d03bf4f5977be86f49faad16d6713121f69bedd868f951bbcabf443d66","src/pat.rs":"15ace4b29add6b7ecdac19bc697e923918f9619e5ec5aea939e91efa84babcfa","src/path.rs":"8dcedaab7ca9e9bc901fb74079e35bfca6ff9e45bc5ca75af1008c087a2c24c8","src/print.rs":"22910bf0521ab868ebd7c62601c55912d12cfb400c65723e08e5cfa3a2d111c0","src/punctuated.rs":"bb8fcdc261caed419b690b623ed375b95c31fccce29a2220a36bd7a8c7384749","src/restriction.rs":"62efbc127d7e7316dd1070c0e976872de6238b2602bba1fb35df18511b4e7199","src/sealed.rs":"6ece3b3dcb30f6bb98b93d83759ca7712ee8592bef9c0511141039c38765db0e","src/span.rs":"4c13579eaf94803bcdb98696e4c3e26fd5cfb7ad46e5a727ed087e5935530a59","src/spanned.rs":"311f4ca8ab9d436df8861a8ea3411d8eff0920354457e124ac85d0579c074981","src/stmt.rs":"acd8ad6406a8e0c11de789f4907d127bdbe8fdf2be68de957298905492ec195c","src/thread.rs":"32f1d8a9890a15920bb939e51647a6630c0661c3fae282834394e4437b8aa5df","src/token.rs":"8b0b4535972fb7b3640e27cb54f80d0e61f27334f2c4c2226c6bae7958299527","src/tt.rs":"32490509abcc4a5a3c7eb5628337172b3b49d30697d2f7b7df4d8045255c13da","src/ty.rs":"8d0435cde79d9599f9ead756b3a36a22cb9302db6572d61092fecaec10d6bc91","src/verbatim.rs":"8d2a42a0aad2a5e69d9b32ba7fb3564fce003fe0862dbc01e106f15d951f3060","src/whitespace.rs":"718a80c12cdd145358e2690f0f68ff7779a91ec17ce9fde9bb755f635fce69ad","tests/common/eq.rs":"9359e9b74dc04cbfd55d1a525bd1dc8fdd1d51dad692fd37f73063a2d4d9dca6","tests/common/mod.rs":"432ad35577f836a20b517d8c26ed994ac25fe73ef2f461c67688b61b99762015","tests/common/parse.rs":"246ddf1d303a9dbbc380e8d0689bd851cef3c3146d09d2627175deb9203b003d","tests/debug/gen.rs":"0b689be01a4f4a0d168617b0f867f248a9e3d211e259926e6ec6c10a59776d81","tests/debug/mod.rs":"dd87563bbd359401790a9c4185178539929ff9fa35a6998657af82a85731fe4c","tests/macros/mod.rs":"aff805b35cfd55aef6a1359ff747e4023afcb08d69d86aff4c19465d29dda088","tests/regression.rs":"e9565ea0efecb4136f099164ffcfa26e1996b0a27fb9c6659e90ad9bdd42e7b6","tests/regression/issue1108.rs":"f32db35244a674e22ff824ca9e5bbec2184e287b59f022db68c418b5878a2edc","tests/regression/issue1235.rs":"a2266b10c3f7c7af5734817ab0a3e8b309b51e7d177b63f26e67e6b744d280b0","tests/repo/mod.rs":"ab9f194ed7a7279b9ad32cf01c50dc0f2f0d45725a0037ce76084817f016e8db","tests/repo/progress.rs":"c08d0314a7f3ecf760d471f27da3cd2a500aeb9f1c8331bffb2aa648f9fabf3f","tests/test_asyncness.rs":"3868181f25f7470476077f80a442a7804b6b9b371ad5917f4fd18b1002714c64","tests/test_attribute.rs":"b35550a43bbd187bb330997ba36f90c65d8fc489135b1d32ef4547f145cb7612","tests/test_derive_input.rs":"c215245c4d09052661ac5b65b34e950ea47622847bdffe648d380470f12db8f2","tests/test_expr.rs":"1d8688c51d4e8dd5a288722ec8c074320081756fcc83812f23109dffe0caddbf","tests/test_generics.rs":"b77741aa38e6ac7e1a9082faf168e7b7b92fbabf9f3fd07306676339a67394df","tests/test_grouping.rs":"ecbe3324878b2e2be42640a3dec198620cff18731fcb95ee7e94eacd11d2fec1","tests/test_ident.rs":"9eb53d1e21edf23e7c9e14dc74dcc2b2538e9221e19dbcc0a44e3acc2e90f3f6","tests/test_item.rs":"7f0255b61d0a6921313c09aaba470beefc55f1d4e66d1e24cfac7a3f63b035d8","tests/test_iterators.rs":"f4dacb5f3a8e0473dfb0d27f05270d41e79eddb4759b1fad3e88e379b4731e17","tests/test_lit.rs":"7297fed48ca248689f112f67b6f024f2f2784e29c6cd33185ac659c350834b01","tests/test_meta.rs":"3e1bb60b4bd56adb1e04b0e2d867404f0d81f7bf69caf7d8a70fc7090e079e84","tests/test_parse_buffer.rs":"3ed83ea2e50f84b80c0b543aac4bfbd379610d0911c0baa1eb94bb925bda7341","tests/test_parse_stream.rs":"a7e186272c89a239cae03053b5a039cdc073cdb46fad64b178fe76fde98405d5","tests/test_pat.rs":"fe94e084ee478d41cccea4eeb3e975386a70d36ff7cbb902ba0c767d536aab6e","tests/test_path.rs":"0033e1082b576bb3217ebd4546423d6f86fde7ee7ba3aba8c57bf137d2b42f47","tests/test_precedence.rs":"9bd073caba1d56d1256d13ae4b7f825b04f9b399a7b31634db7ea72d6d5d96bf","tests/test_receiver.rs":"af64117acd66fbf42edc476f731ecd20c88009d9cb641dbd7a1d6384ae99ae73","tests/test_round_trip.rs":"15f2ed76f7af6696cb4df7153bcfafb9c514ca6a3ab0e8beb3f78def25427c92","tests/test_shebang.rs":"06d3acabed004767d8b3a0389bde7485a6719cad6a0d0b4ac2c7439b03586651","tests/test_should_parse.rs":"1d3535698a446e2755bfc360676bdb161841a1f454cdef6e7556c6d06a95c89d","tests/test_size.rs":"a4db2760e9438ef1a26d70238c2b5044de02878403fd424b4c9913b5ee45e004","tests/test_stmt.rs":"42a3707056da0ce3a01f8fb13e8b7631f9be6066627ac376e1874742419ad2cc","tests/test_token_trees.rs":"d012da9c3c861073711b006bf6ffdc073821fb9fb0a08733628cdae57124d1f5","tests/test_ty.rs":"f7f21f76e9e798669f09a95c380e26ae5959ee8ac5f3b765b1a799cc9505d075","tests/test_visibility.rs":"cf4c93997cd88821ef7f8e2dd5d1586175cce4614407cd3bdf371ecc4d8abc44","tests/zzz_stable.rs":"2a862e59cb446235ed99aec0e6ada8e16d3ecc30229b29d825b7c0bbc2602989"},"package":"bcc02725fd69ab9f26eab07fad303e2497fad6fb9eba4f96c4d1687bdf704ad9"}
\ No newline at end of file diff --git a/vendor/syn/Cargo.toml b/vendor/syn/Cargo.toml index c2a36013e..813a576f0 100644 --- a/vendor/syn/Cargo.toml +++ b/vendor/syn/Cargo.toml @@ -10,14 +10,13 @@ # See Cargo.toml.orig for the original contents. [package] -edition = "2018" -rust-version = "1.31" +edition = "2021" +rust-version = "1.56" name = "syn" -version = "1.0.107" +version = "2.0.8" authors = ["David Tolnay <dtolnay@gmail.com>"] include = [ "/benches/**", - "/build.rs", "/Cargo.toml", "/LICENSE-APACHE", "/LICENSE-MIT", @@ -41,11 +40,11 @@ repository = "https://github.com/dtolnay/syn" [package.metadata.docs.rs] all-features = true -targets = ["x86_64-unknown-linux-gnu"] rustdoc-args = [ "--cfg", "doc_cfg", ] +targets = ["x86_64-unknown-linux-gnu"] [package.metadata.playground] features = [ @@ -75,42 +74,45 @@ required-features = [ ] [dependencies.proc-macro2] -version = "1.0.46" +version = "1.0.52" default-features = false [dependencies.quote] -version = "1.0" +version = "1.0.25" optional = true default-features = false [dependencies.unicode-ident] -version = "1.0" +version = "1" [dev-dependencies.anyhow] -version = "1.0" +version = "1" [dev-dependencies.automod] -version = "1.0" +version = "1" [dev-dependencies.flate2] -version = "1.0" +version = "1" [dev-dependencies.insta] -version = "1.0" +version = "1" [dev-dependencies.rayon] -version = "1.0" +version = "1" [dev-dependencies.ref-cast] -version = "1.0" +version = "1" [dev-dependencies.regex] -version = "1.0" +version = "1" [dev-dependencies.reqwest] version = "0.11" features = ["blocking"] +[dev-dependencies.rustversion] +version = "1" + [dev-dependencies.syn-test-suite] version = "0" @@ -118,7 +120,7 @@ version = "0" version = "0.4.16" [dev-dependencies.termcolor] -version = "1.0" +version = "1" [dev-dependencies.walkdir] version = "2.1" diff --git a/vendor/syn/LICENSE-APACHE b/vendor/syn/LICENSE-APACHE index 16fe87b06..1b5ec8b78 100644 --- a/vendor/syn/LICENSE-APACHE +++ b/vendor/syn/LICENSE-APACHE @@ -174,28 +174,3 @@ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 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/vendor/syn/README.md b/vendor/syn/README.md index eeef83dd5..24aea1700 100644 --- a/vendor/syn/README.md +++ b/vendor/syn/README.md @@ -46,7 +46,7 @@ contains some APIs that may be useful more generally. [`syn::DeriveInput`]: https://docs.rs/syn/1.0/syn/struct.DeriveInput.html [parser functions]: https://docs.rs/syn/1.0/syn/parse/index.html -*Version requirement: Syn supports rustc 1.31 and up.* +*Version requirement: Syn supports rustc 1.56 and up.* [*Release notes*](https://github.com/dtolnay/syn/releases) @@ -76,7 +76,7 @@ tokens back to the compiler to compile into the user's crate. ```toml [dependencies] -syn = "1.0" +syn = "2.0" quote = "1.0" [lib] @@ -104,9 +104,8 @@ pub fn my_macro(input: TokenStream) -> TokenStream { ``` The [`heapsize`] example directory shows a complete working implementation of a -derive macro. It works on any Rust compiler 1.31+. The example derives a -`HeapSize` trait which computes an estimate of the amount of heap memory owned -by a value. +derive macro. The example derives a `HeapSize` trait which computes an estimate +of the amount of heap memory owned by a value. [`heapsize`]: examples/heapsize diff --git a/vendor/syn/benches/file.rs b/vendor/syn/benches/file.rs index bd4a247df..b42472396 100644 --- a/vendor/syn/benches/file.rs +++ b/vendor/syn/benches/file.rs @@ -4,8 +4,11 @@ #![recursion_limit = "1024"] #![allow( clippy::items_after_statements, + clippy::manual_let_else, + clippy::match_like_matches_macro, clippy::missing_panics_doc, - clippy::must_use_candidate + clippy::must_use_candidate, + clippy::uninlined_format_args )] extern crate test; @@ -14,10 +17,9 @@ extern crate test; #[path = "../tests/macros/mod.rs"] mod macros; -#[path = "../tests/common/mod.rs"] -mod common; +#[allow(dead_code)] #[path = "../tests/repo/mod.rs"] -pub mod repo; +mod repo; use proc_macro2::{Span, TokenStream}; use std::fs; diff --git a/vendor/syn/benches/rust.rs b/vendor/syn/benches/rust.rs index e3f8f550a..fa72cc94b 100644 --- a/vendor/syn/benches/rust.rs +++ b/vendor/syn/benches/rust.rs @@ -5,14 +5,19 @@ #![cfg_attr(not(syn_only), feature(rustc_private))] #![recursion_limit = "1024"] -#![allow(clippy::cast_lossless, clippy::unnecessary_wraps)] +#![allow( + clippy::cast_lossless, + clippy::let_underscore_untyped, + clippy::manual_let_else, + clippy::match_like_matches_macro, + clippy::uninlined_format_args, + clippy::unnecessary_wraps +)] #[macro_use] #[path = "../tests/macros/mod.rs"] mod macros; -#[path = "../tests/common/mod.rs"] -mod common; #[path = "../tests/repo/mod.rs"] mod repo; @@ -38,6 +43,7 @@ mod syn_parse { #[cfg(not(syn_only))] mod librustc_parse { extern crate rustc_data_structures; + extern crate rustc_driver; extern crate rustc_error_messages; extern crate rustc_errors; extern crate rustc_parse; @@ -91,7 +97,7 @@ mod librustc_parse { #[cfg(not(syn_only))] mod read_from_disk { pub fn bench(content: &str) -> Result<(), ()> { - _ = content; + let _ = content; Ok(()) } } diff --git a/vendor/syn/build.rs b/vendor/syn/build.rs deleted file mode 100644 index 1a2c077bf..000000000 --- a/vendor/syn/build.rs +++ /dev/null @@ -1,51 +0,0 @@ -use std::env; -use std::process::Command; -use std::str; - -// The rustc-cfg strings below are *not* public API. Please let us know by -// opening a GitHub issue if your build environment requires some way to enable -// these cfgs other than by executing our build script. -fn main() { - let compiler = match rustc_version() { - Some(compiler) => compiler, - None => return, - }; - - if compiler.minor < 36 { - println!("cargo:rustc-cfg=syn_omit_await_from_token_macro"); - } - - if compiler.minor < 39 { - println!("cargo:rustc-cfg=syn_no_const_vec_new"); - } - - if compiler.minor < 40 { - println!("cargo:rustc-cfg=syn_no_non_exhaustive"); - } - - if compiler.minor < 56 { - println!("cargo:rustc-cfg=syn_no_negative_literal_parse"); - } - - if !compiler.nightly { - println!("cargo:rustc-cfg=syn_disable_nightly_tests"); - } -} - -struct Compiler { - minor: u32, - nightly: bool, -} - -fn rustc_version() -> Option<Compiler> { - let rustc = env::var_os("RUSTC")?; - let output = Command::new(rustc).arg("--version").output().ok()?; - let version = str::from_utf8(&output.stdout).ok()?; - let mut pieces = version.split('.'); - if pieces.next() != Some("rustc 1") { - return None; - } - let minor = pieces.next()?.parse().ok()?; - let nightly = version.contains("nightly") || version.ends_with("-dev"); - Some(Compiler { minor, nightly }) -} diff --git a/vendor/syn/src/attr.rs b/vendor/syn/src/attr.rs index bace94f43..34d5515a5 100644 --- a/vendor/syn/src/attr.rs +++ b/vendor/syn/src/attr.rs @@ -1,19 +1,15 @@ use super::*; -use crate::punctuated::Punctuated; use proc_macro2::TokenStream; use std::iter; use std::slice; #[cfg(feature = "parsing")] -use crate::parse::{Parse, ParseBuffer, ParseStream, Parser, Result}; +use crate::meta::{self, ParseNestedMeta}; #[cfg(feature = "parsing")] -use crate::punctuated::Pair; +use crate::parse::{Parse, ParseStream, Parser, Result}; ast_struct! { - /// An attribute like `#[repr(transparent)]`. - /// - /// *This type is available only if Syn is built with the `"derive"` or `"full"` - /// feature.* + /// An attribute, like `#[repr(transparent)]`. /// /// <br> /// @@ -23,27 +19,52 @@ ast_struct! { /// /// - Outer attributes like `#[repr(transparent)]`. These appear outside or /// in front of the item they describe. + /// /// - Inner attributes like `#![feature(proc_macro)]`. These appear inside /// of the item they describe, usually a module. - /// - Outer doc comments like `/// # Example`. - /// - Inner doc comments like `//! Please file an issue`. - /// - Outer block comments `/** # Example */`. - /// - Inner block comments `/*! Please file an issue */`. + /// + /// - Outer one-line doc comments like `/// Example`. + /// + /// - Inner one-line doc comments like `//! Please file an issue`. + /// + /// - Outer documentation blocks `/** Example */`. + /// + /// - Inner documentation blocks `/*! Please file an issue */`. /// /// The `style` field of type `AttrStyle` distinguishes whether an attribute - /// is outer or inner. Doc comments and block comments are promoted to - /// attributes, as this is how they are processed by the compiler and by - /// `macro_rules!` macros. + /// is outer or inner. + /// + /// Every attribute has a `path` that indicates the intended interpretation + /// of the rest of the attribute's contents. The path and the optional + /// additional contents are represented together in the `meta` field of the + /// attribute in three possible varieties: + /// + /// - Meta::Path — attributes whose information content conveys just a + /// path, for example the `#[test]` attribute. /// - /// The `path` field gives the possibly colon-delimited path against which - /// the attribute is resolved. It is equal to `"doc"` for desugared doc - /// comments. The `tokens` field contains the rest of the attribute body as - /// tokens. + /// - Meta::List — attributes that carry arbitrary tokens after the + /// path, surrounded by a delimiter (parenthesis, bracket, or brace). For + /// example `#[derive(Copy)]` or `#[precondition(x < 5)]`. + /// + /// - Meta::NameValue — attributes with an `=` sign after the path, + /// followed by a Rust expression. For example `#[path = + /// "sys/windows.rs"]`. + /// + /// All doc comments are represented in the NameValue style with a path of + /// "doc", as this is how they are processed by the compiler and by + /// `macro_rules!` macros. /// /// ```text - /// #[derive(Copy)] #[crate::precondition x < 5] - /// ^^^^^^~~~~~~ ^^^^^^^^^^^^^^^^^^^ ~~~~~ - /// path tokens path tokens + /// #[derive(Copy, Clone)] + /// ~~~~~~Path + /// ^^^^^^^^^^^^^^^^^^^Meta::List + /// + /// #[path = "sys/windows.rs"] + /// ~~~~Path + /// ^^^^^^^^^^^^^^^^^^^^^^^Meta::NameValue + /// + /// #[test] + /// ^^^^Meta::Path /// ``` /// /// <br> @@ -93,18 +114,13 @@ ast_struct! { /// /// The grammar of attributes in Rust is very flexible, which makes the /// syntax tree not that useful on its own. In particular, arguments of the - /// attribute are held in an arbitrary `tokens: TokenStream`. Macros are - /// expected to check the `path` of the attribute, decide whether they - /// recognize it, and then parse the remaining tokens according to whatever - /// grammar they wish to require for that kind of attribute. - /// - /// If the attribute you are parsing is expected to conform to the - /// conventional structured form of attribute, use [`parse_meta()`] to - /// obtain that structured representation. If the attribute follows some - /// other grammar of its own, use [`parse_args()`] to parse that into the - /// expected data structure. - /// - /// [`parse_meta()`]: Attribute::parse_meta + /// `Meta::List` variety of attribute are held in an arbitrary `tokens: + /// TokenStream`. Macros are expected to check the `path` of the attribute, + /// decide whether they recognize it, and then parse the remaining tokens + /// according to whatever grammar they wish to require for that kind of + /// attribute. Use [`parse_args()`] to parse those tokens into the expected + /// data structure. + /// /// [`parse_args()`]: Attribute::parse_args /// /// <p><br></p> @@ -150,65 +166,49 @@ ast_struct! { pub pound_token: Token![#], pub style: AttrStyle, pub bracket_token: token::Bracket, - pub path: Path, - pub tokens: TokenStream, + pub meta: Meta, } } impl Attribute { - /// Parses the content of the attribute, consisting of the path and tokens, - /// as a [`Meta`] if possible. + /// Returns the path that identifies the interpretation of this attribute. /// - /// *This function is available only if Syn is built with the `"parsing"` - /// feature.* - #[cfg(feature = "parsing")] - #[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))] - pub fn parse_meta(&self) -> Result<Meta> { - fn clone_ident_segment(segment: &PathSegment) -> PathSegment { - PathSegment { - ident: segment.ident.clone(), - arguments: PathArguments::None, - } - } - - let path = Path { - leading_colon: self - .path - .leading_colon - .as_ref() - .map(|colon| Token![::](colon.spans)), - segments: self - .path - .segments - .pairs() - .map(|pair| match pair { - Pair::Punctuated(seg, punct) => { - Pair::Punctuated(clone_ident_segment(seg), Token![::](punct.spans)) - } - Pair::End(seg) => Pair::End(clone_ident_segment(seg)), - }) - .collect(), - }; - - let parser = |input: ParseStream| parsing::parse_meta_after_path(path, input); - parse::Parser::parse2(parser, self.tokens.clone()) + /// For example this would return the `test` in `#[test]`, the `derive` in + /// `#[derive(Copy)]`, and the `path` in `#[path = "sys/windows.rs"]`. + pub fn path(&self) -> &Path { + self.meta.path() } /// Parse the arguments to the attribute as a syntax tree. /// - /// This is similar to `syn::parse2::<T>(attr.tokens)` except that: + /// This is similar to pulling out the `TokenStream` from `Meta::List` and + /// doing `syn::parse2::<T>(meta_list.tokens)`, except that using + /// `parse_args` the error message has a more useful span when `tokens` is + /// empty. /// - /// - the surrounding delimiters are *not* included in the input to the - /// parser; and - /// - the error message has a more useful span when `tokens` is empty. + /// The surrounding delimiters are *not* included in the input to the + /// parser. /// /// ```text /// #[my_attr(value < 5)] /// ^^^^^^^^^ what gets parsed /// ``` /// - /// *This function is available only if Syn is built with the `"parsing"` - /// feature.* + /// # Example + /// + /// ``` + /// use syn::{parse_quote, Attribute, Expr}; + /// + /// let attr: Attribute = parse_quote! { + /// #[precondition(value < 5)] + /// }; + /// + /// if attr.path().is_ident("precondition") { + /// let precondition: Expr = attr.parse_args()?; + /// // ... + /// } + /// # anyhow::Ok(()) + /// ``` #[cfg(feature = "parsing")] #[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))] pub fn parse_args<T: Parse>(&self) -> Result<T> { @@ -217,22 +217,182 @@ impl Attribute { /// Parse the arguments to the attribute using the given parser. /// - /// *This function is available only if Syn is built with the `"parsing"` - /// feature.* + /// # Example + /// + /// ``` + /// use syn::{parse_quote, Attribute}; + /// + /// let attr: Attribute = parse_quote! { + /// #[inception { #[brrrrrrraaaaawwwwrwrrrmrmrmmrmrmmmmm] }] + /// }; + /// + /// let bwom = attr.parse_args_with(Attribute::parse_outer)?; + /// + /// // Attribute does not have a Parse impl, so we couldn't directly do: + /// // let bwom: Attribute = attr.parse_args()?; + /// # anyhow::Ok(()) + /// ``` #[cfg(feature = "parsing")] #[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))] pub fn parse_args_with<F: Parser>(&self, parser: F) -> Result<F::Output> { - let parser = |input: ParseStream| { - let args = enter_args(self, input)?; - parse::parse_stream(parser, &args) - }; - parser.parse2(self.tokens.clone()) + match &self.meta { + Meta::Path(path) => Err(crate::error::new2( + path.segments.first().unwrap().ident.span(), + path.segments.last().unwrap().ident.span(), + format!( + "expected attribute arguments in parentheses: {}[{}(...)]", + parsing::DisplayAttrStyle(&self.style), + parsing::DisplayPath(path), + ), + )), + Meta::NameValue(meta) => Err(Error::new( + meta.eq_token.span, + format_args!( + "expected parentheses: {}[{}(...)]", + parsing::DisplayAttrStyle(&self.style), + parsing::DisplayPath(&meta.path), + ), + )), + Meta::List(meta) => meta.parse_args_with(parser), + } + } + + /// Parse the arguments to the attribute, expecting it to follow the + /// conventional structure used by most of Rust's built-in attributes. + /// + /// The [*Meta Item Attribute Syntax*][syntax] section in the Rust reference + /// explains the convention in more detail. Not all attributes follow this + /// convention, so [`parse_args()`][Self::parse_args] is available if you + /// need to parse arbitrarily goofy attribute syntax. + /// + /// [syntax]: https://doc.rust-lang.org/reference/attributes.html#meta-item-attribute-syntax + /// + /// # Example + /// + /// We'll parse a struct, and then parse some of Rust's `#[repr]` attribute + /// syntax. + /// + /// ``` + /// use syn::{parenthesized, parse_quote, token, ItemStruct, LitInt}; + /// + /// let input: ItemStruct = parse_quote! { + /// #[repr(C, align(4))] + /// pub struct MyStruct(u16, u32); + /// }; + /// + /// let mut repr_c = false; + /// let mut repr_transparent = false; + /// let mut repr_align = None::<usize>; + /// let mut repr_packed = None::<usize>; + /// for attr in &input.attrs { + /// if attr.path().is_ident("repr") { + /// attr.parse_nested_meta(|meta| { + /// // #[repr(C)] + /// if meta.path.is_ident("C") { + /// repr_c = true; + /// return Ok(()); + /// } + /// + /// // #[repr(transparent)] + /// if meta.path.is_ident("transparent") { + /// repr_transparent = true; + /// return Ok(()); + /// } + /// + /// // #[repr(align(N))] + /// if meta.path.is_ident("align") { + /// let content; + /// parenthesized!(content in meta.input); + /// let lit: LitInt = content.parse()?; + /// let n: usize = lit.base10_parse()?; + /// repr_align = Some(n); + /// return Ok(()); + /// } + /// + /// // #[repr(packed)] or #[repr(packed(N))], omitted N means 1 + /// if meta.path.is_ident("packed") { + /// if meta.input.peek(token::Paren) { + /// let content; + /// parenthesized!(content in meta.input); + /// let lit: LitInt = content.parse()?; + /// let n: usize = lit.base10_parse()?; + /// repr_packed = Some(n); + /// } else { + /// repr_packed = Some(1); + /// } + /// return Ok(()); + /// } + /// + /// Err(meta.error("unrecognized repr")) + /// })?; + /// } + /// } + /// # anyhow::Ok(()) + /// ``` + /// + /// # Alternatives + /// + /// In some cases, for attributes which have nested layers of structured + /// content, the following less flexible approach might be more convenient: + /// + /// ``` + /// # use syn::{parse_quote, ItemStruct}; + /// # + /// # let input: ItemStruct = parse_quote! { + /// # #[repr(C, align(4))] + /// # pub struct MyStruct(u16, u32); + /// # }; + /// # + /// use syn::punctuated::Punctuated; + /// use syn::{parenthesized, token, Error, LitInt, Meta, Token}; + /// + /// let mut repr_c = false; + /// let mut repr_transparent = false; + /// let mut repr_align = None::<usize>; + /// let mut repr_packed = None::<usize>; + /// for attr in &input.attrs { + /// if attr.path().is_ident("repr") { + /// let nested = attr.parse_args_with(Punctuated::<Meta, Token![,]>::parse_terminated)?; + /// for meta in nested { + /// match meta { + /// // #[repr(C)] + /// Meta::Path(path) if path.is_ident("C") => { + /// repr_c = true; + /// } + /// + /// // #[repr(align(N))] + /// Meta::List(meta) if meta.path.is_ident("align") => { + /// let lit: LitInt = meta.parse_args()?; + /// let n: usize = lit.base10_parse()?; + /// repr_align = Some(n); + /// } + /// + /// /* ... */ + /// + /// _ => { + /// return Err(Error::new_spanned(meta, "unrecognized repr")); + /// } + /// } + /// } + /// } + /// } + /// # Ok(()) + /// ``` + #[cfg(feature = "parsing")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))] + pub fn parse_nested_meta( + &self, + logic: impl FnMut(ParseNestedMeta) -> Result<()>, + ) -> Result<()> { + self.parse_args_with(meta::parser(logic)) } /// Parses zero or more outer attributes from the stream. /// - /// *This function is available only if Syn is built with the `"parsing"` - /// feature.* + /// # Example + /// + /// See + /// [*Parsing from tokens to Attribute*](#parsing-from-tokens-to-attribute). #[cfg(feature = "parsing")] #[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))] pub fn parse_outer(input: ParseStream) -> Result<Vec<Self>> { @@ -245,8 +405,10 @@ impl Attribute { /// Parses zero or more inner attributes from the stream. /// - /// *This function is available only if Syn is built with the `"parsing"` - /// feature.* + /// # Example + /// + /// See + /// [*Parsing from tokens to Attribute*](#parsing-from-tokens-to-attribute). #[cfg(feature = "parsing")] #[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))] pub fn parse_inner(input: ParseStream) -> Result<Vec<Self>> { @@ -256,65 +418,10 @@ impl Attribute { } } -#[cfg(feature = "parsing")] -fn expected_parentheses(attr: &Attribute) -> String { - let style = match attr.style { - AttrStyle::Outer => "#", - AttrStyle::Inner(_) => "#!", - }; - - let mut path = String::new(); - for segment in &attr.path.segments { - if !path.is_empty() || attr.path.leading_colon.is_some() { - path += "::"; - } - path += &segment.ident.to_string(); - } - - format!("{}[{}(...)]", style, path) -} - -#[cfg(feature = "parsing")] -fn enter_args<'a>(attr: &Attribute, input: ParseStream<'a>) -> Result<ParseBuffer<'a>> { - if input.is_empty() { - let expected = expected_parentheses(attr); - let msg = format!("expected attribute arguments in parentheses: {}", expected); - return Err(crate::error::new2( - attr.pound_token.span, - attr.bracket_token.span, - msg, - )); - } else if input.peek(Token![=]) { - let expected = expected_parentheses(attr); - let msg = format!("expected parentheses: {}", expected); - return Err(input.error(msg)); - }; - - let content; - if input.peek(token::Paren) { - parenthesized!(content in input); - } else if input.peek(token::Bracket) { - bracketed!(content in input); - } else if input.peek(token::Brace) { - braced!(content in input); - } else { - return Err(input.error("unexpected token in attribute arguments")); - } - - if input.is_empty() { - Ok(content) - } else { - Err(input.error("unexpected token in attribute arguments")) - } -} - ast_enum! { /// Distinguishes between attributes that decorate an item and attributes /// that are contained within an item. /// - /// *This type is available only if Syn is built with the `"derive"` or `"full"` - /// feature.* - /// /// # Outer attributes /// /// - `#[repr(transparent)]` @@ -336,9 +443,6 @@ ast_enum! { ast_enum_of_structs! { /// Content of a compile-time structured attribute. /// - /// *This type is available only if Syn is built with the `"derive"` or `"full"` - /// feature.* - /// /// ## Path /// /// A meta path is like the `test` in `#[test]`. @@ -371,32 +475,26 @@ ast_enum_of_structs! { ast_struct! { /// A structured list within an attribute, like `derive(Copy, Clone)`. - /// - /// *This type is available only if Syn is built with the `"derive"` or - /// `"full"` feature.* #[cfg_attr(doc_cfg, doc(cfg(any(feature = "full", feature = "derive"))))] pub struct MetaList { pub path: Path, - pub paren_token: token::Paren, - pub nested: Punctuated<NestedMeta, Token![,]>, + pub delimiter: MacroDelimiter, + pub tokens: TokenStream, } } ast_struct! { /// A name-value pair within an attribute, like `feature = "nightly"`. - /// - /// *This type is available only if Syn is built with the `"derive"` or - /// `"full"` feature.* #[cfg_attr(doc_cfg, doc(cfg(any(feature = "full", feature = "derive"))))] pub struct MetaNameValue { pub path: Path, pub eq_token: Token![=], - pub lit: Lit, + pub value: Expr, } } impl Meta { - /// Returns the identifier that begins this structured meta item. + /// Returns the path that begins this structured meta item. /// /// For example this would return the `test` in `#[test]`, the `derive` in /// `#[derive(Copy)]`, and the `path` in `#[path = "sys/windows.rs"]`. @@ -407,63 +505,84 @@ impl Meta { Meta::NameValue(meta) => &meta.path, } } + + /// Error if this is a `Meta::List` or `Meta::NameValue`. + #[cfg(feature = "parsing")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))] + pub fn require_path_only(&self) -> Result<&Path> { + let error_span = match self { + Meta::Path(path) => return Ok(path), + Meta::List(meta) => meta.delimiter.span().open(), + Meta::NameValue(meta) => meta.eq_token.span, + }; + Err(Error::new(error_span, "unexpected token in attribute")) + } + + /// Error if this is a `Meta::Path` or `Meta::NameValue`. + #[cfg(feature = "parsing")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))] + pub fn require_list(&self) -> Result<&MetaList> { + match self { + Meta::List(meta) => Ok(meta), + Meta::Path(path) => Err(crate::error::new2( + path.segments.first().unwrap().ident.span(), + path.segments.last().unwrap().ident.span(), + format!( + "expected attribute arguments in parentheses: `{}(...)`", + parsing::DisplayPath(path), + ), + )), + Meta::NameValue(meta) => Err(Error::new(meta.eq_token.span, "expected `(`")), + } + } + + /// Error if this is a `Meta::Path` or `Meta::List`. + #[cfg(feature = "parsing")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))] + pub fn require_name_value(&self) -> Result<&MetaNameValue> { + match self { + Meta::NameValue(meta) => Ok(meta), + Meta::Path(path) => Err(crate::error::new2( + path.segments.first().unwrap().ident.span(), + path.segments.last().unwrap().ident.span(), + format!( + "expected a value for this attribute: `{} = ...`", + parsing::DisplayPath(path), + ), + )), + Meta::List(meta) => Err(Error::new(meta.delimiter.span().open(), "expected `=`")), + } + } } -ast_enum_of_structs! { - /// Element of a compile-time attribute list. - /// - /// *This type is available only if Syn is built with the `"derive"` or `"full"` - /// feature.* - #[cfg_attr(doc_cfg, doc(cfg(any(feature = "full", feature = "derive"))))] - pub enum NestedMeta { - /// A structured meta item, like the `Copy` in `#[derive(Copy)]` which - /// would be a nested `Meta::Path`. - Meta(Meta), +impl MetaList { + /// See [`Attribute::parse_args`]. + #[cfg(feature = "parsing")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))] + pub fn parse_args<T: Parse>(&self) -> Result<T> { + self.parse_args_with(T::parse) + } - /// A Rust literal, like the `"new_name"` in `#[rename("new_name")]`. - Lit(Lit), + /// See [`Attribute::parse_args_with`]. + #[cfg(feature = "parsing")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))] + pub fn parse_args_with<F: Parser>(&self, parser: F) -> Result<F::Output> { + let scope = self.delimiter.span().close(); + crate::parse::parse_scoped(parser, scope, self.tokens.clone()) + } + + /// See [`Attribute::parse_nested_meta`]. + #[cfg(feature = "parsing")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))] + pub fn parse_nested_meta( + &self, + logic: impl FnMut(ParseNestedMeta) -> Result<()>, + ) -> Result<()> { + self.parse_args_with(meta::parser(logic)) } } -/// Conventional argument type associated with an invocation of an attribute -/// macro. -/// -/// For example if we are developing an attribute macro that is intended to be -/// invoked on function items as follows: -/// -/// ``` -/// # const IGNORE: &str = stringify! { -/// #[my_attribute(path = "/v1/refresh")] -/// # }; -/// pub fn refresh() { -/// /* ... */ -/// } -/// ``` -/// -/// The implementation of this macro would want to parse its attribute arguments -/// as type `AttributeArgs`. -/// -/// ``` -/// # extern crate proc_macro; -/// # -/// use proc_macro::TokenStream; -/// use syn::{parse_macro_input, AttributeArgs, ItemFn}; -/// -/// # const IGNORE: &str = stringify! { -/// #[proc_macro_attribute] -/// # }; -/// pub fn my_attribute(args: TokenStream, input: TokenStream) -> TokenStream { -/// let args = parse_macro_input!(args as AttributeArgs); -/// let input = parse_macro_input!(input as ItemFn); -/// -/// /* ... */ -/// # "".parse().unwrap() -/// } -/// ``` -#[cfg_attr(doc_cfg, doc(cfg(any(feature = "full", feature = "derive"))))] -pub type AttributeArgs = Vec<NestedMeta>; - -pub trait FilterAttrs<'a> { +pub(crate) trait FilterAttrs<'a> { type Ret: Iterator<Item = &'a Attribute>; fn outer(self) -> Self::Ret; @@ -495,69 +614,43 @@ impl<'a> FilterAttrs<'a> for &'a [Attribute] { } #[cfg(feature = "parsing")] -pub mod parsing { +pub(crate) mod parsing { use super::*; - use crate::ext::IdentExt; + use crate::parse::discouraged::Speculative; use crate::parse::{Parse, ParseStream, Result}; + use std::fmt::{self, Display}; - pub fn parse_inner(input: ParseStream, attrs: &mut Vec<Attribute>) -> Result<()> { + pub(crate) fn parse_inner(input: ParseStream, attrs: &mut Vec<Attribute>) -> Result<()> { while input.peek(Token![#]) && input.peek2(Token![!]) { attrs.push(input.call(parsing::single_parse_inner)?); } Ok(()) } - pub fn single_parse_inner(input: ParseStream) -> Result<Attribute> { + pub(crate) fn single_parse_inner(input: ParseStream) -> Result<Attribute> { let content; Ok(Attribute { pound_token: input.parse()?, style: AttrStyle::Inner(input.parse()?), bracket_token: bracketed!(content in input), - path: content.call(Path::parse_mod_style)?, - tokens: content.parse()?, + meta: content.parse()?, }) } - pub fn single_parse_outer(input: ParseStream) -> Result<Attribute> { + pub(crate) fn single_parse_outer(input: ParseStream) -> Result<Attribute> { let content; Ok(Attribute { pound_token: input.parse()?, style: AttrStyle::Outer, bracket_token: bracketed!(content in input), - path: content.call(Path::parse_mod_style)?, - tokens: content.parse()?, - }) - } - - // Like Path::parse_mod_style but accepts keywords in the path. - fn parse_meta_path(input: ParseStream) -> Result<Path> { - Ok(Path { - leading_colon: input.parse()?, - segments: { - let mut segments = Punctuated::new(); - while input.peek(Ident::peek_any) { - let ident = Ident::parse_any(input)?; - segments.push_value(PathSegment::from(ident)); - if !input.peek(Token![::]) { - break; - } - let punct = input.parse()?; - segments.push_punct(punct); - } - if segments.is_empty() { - return Err(input.error("expected path")); - } else if segments.trailing_punct() { - return Err(input.error("expected path segment")); - } - segments - }, + meta: content.parse()?, }) } #[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))] impl Parse for Meta { fn parse(input: ParseStream) -> Result<Self> { - let path = input.call(parse_meta_path)?; + let path = input.call(Path::parse_mod_style)?; parse_meta_after_path(path, input) } } @@ -565,7 +658,7 @@ pub mod parsing { #[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))] impl Parse for MetaList { fn parse(input: ParseStream) -> Result<Self> { - let path = input.call(parse_meta_path)?; + let path = input.call(Path::parse_mod_style)?; parse_meta_list_after_path(path, input) } } @@ -573,28 +666,13 @@ pub mod parsing { #[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))] impl Parse for MetaNameValue { fn parse(input: ParseStream) -> Result<Self> { - let path = input.call(parse_meta_path)?; + let path = input.call(Path::parse_mod_style)?; parse_meta_name_value_after_path(path, input) } } - #[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))] - impl Parse for NestedMeta { - fn parse(input: ParseStream) -> Result<Self> { - if input.peek(Lit) && !(input.peek(LitBool) && input.peek2(Token![=])) { - input.parse().map(NestedMeta::Lit) - } else if input.peek(Ident::peek_any) - || input.peek(Token![::]) && input.peek3(Ident::peek_any) - { - input.parse().map(NestedMeta::Meta) - } else { - Err(input.error("expected identifier or literal")) - } - } - } - - pub fn parse_meta_after_path(path: Path, input: ParseStream) -> Result<Meta> { - if input.peek(token::Paren) { + pub(crate) fn parse_meta_after_path(path: Path, input: ParseStream) -> Result<Meta> { + if input.peek(token::Paren) || input.peek(token::Bracket) || input.peek(token::Brace) { parse_meta_list_after_path(path, input).map(Meta::List) } else if input.peek(Token![=]) { parse_meta_name_value_after_path(path, input).map(Meta::NameValue) @@ -604,21 +682,60 @@ pub mod parsing { } fn parse_meta_list_after_path(path: Path, input: ParseStream) -> Result<MetaList> { - let content; + let (delimiter, tokens) = mac::parse_delimiter(input)?; Ok(MetaList { path, - paren_token: parenthesized!(content in input), - nested: content.parse_terminated(NestedMeta::parse)?, + delimiter, + tokens, }) } fn parse_meta_name_value_after_path(path: Path, input: ParseStream) -> Result<MetaNameValue> { + let eq_token: Token![=] = input.parse()?; + let ahead = input.fork(); + let lit: Option<Lit> = ahead.parse()?; + let value = if let (Some(lit), true) = (lit, ahead.is_empty()) { + input.advance_to(&ahead); + Expr::Lit(ExprLit { + attrs: Vec::new(), + lit, + }) + } else if input.peek(Token![#]) && input.peek2(token::Bracket) { + return Err(input.error("unexpected attribute inside of attribute")); + } else { + input.parse()? + }; Ok(MetaNameValue { path, - eq_token: input.parse()?, - lit: input.parse()?, + eq_token, + value, }) } + + pub(super) struct DisplayAttrStyle<'a>(pub &'a AttrStyle); + + impl<'a> Display for DisplayAttrStyle<'a> { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str(match self.0 { + AttrStyle::Outer => "#", + AttrStyle::Inner(_) => "#!", + }) + } + } + + pub(super) struct DisplayPath<'a>(pub &'a Path); + + impl<'a> Display for DisplayPath<'a> { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + for (i, segment) in self.0.segments.iter().enumerate() { + if i > 0 || self.0.leading_colon.is_some() { + formatter.write_str("::")?; + } + write!(formatter, "{}", segment.ident)?; + } + Ok(()) + } + } } #[cfg(feature = "printing")] @@ -635,8 +752,7 @@ mod printing { b.to_tokens(tokens); } self.bracket_token.surround(tokens, |tokens| { - self.path.to_tokens(tokens); - self.tokens.to_tokens(tokens); + self.meta.to_tokens(tokens); }); } } @@ -645,9 +761,7 @@ mod printing { impl ToTokens for MetaList { fn to_tokens(&self, tokens: &mut TokenStream) { self.path.to_tokens(tokens); - self.paren_token.surround(tokens, |tokens| { - self.nested.to_tokens(tokens); - }); + self.delimiter.surround(tokens, self.tokens.clone()); } } @@ -656,7 +770,7 @@ mod printing { fn to_tokens(&self, tokens: &mut TokenStream) { self.path.to_tokens(tokens); self.eq_token.to_tokens(tokens); - self.lit.to_tokens(tokens); + self.value.to_tokens(tokens); } } } diff --git a/vendor/syn/src/await.rs b/vendor/syn/src/await.rs deleted file mode 100644 index 038c6a5d1..000000000 --- a/vendor/syn/src/await.rs +++ /dev/null @@ -1,2 +0,0 @@ -// See include!("await.rs") in token.rs. -export_token_macro! {[await]} diff --git a/vendor/syn/src/bigint.rs b/vendor/syn/src/bigint.rs index 5397d6bee..66aaa9372 100644 --- a/vendor/syn/src/bigint.rs +++ b/vendor/syn/src/bigint.rs @@ -1,16 +1,16 @@ use std::ops::{AddAssign, MulAssign}; // For implementing base10_digits() accessor on LitInt. -pub struct BigInt { +pub(crate) struct BigInt { digits: Vec<u8>, } impl BigInt { - pub fn new() -> Self { + pub(crate) fn new() -> Self { BigInt { digits: Vec::new() } } - pub fn to_string(&self) -> String { + pub(crate) fn to_string(&self) -> String { let mut repr = String::with_capacity(self.digits.len()); let mut has_nonzero = false; diff --git a/vendor/syn/src/buffer.rs b/vendor/syn/src/buffer.rs index 0d5cf30d5..e16f2adea 100644 --- a/vendor/syn/src/buffer.rs +++ b/vendor/syn/src/buffer.rs @@ -1,7 +1,5 @@ //! A stably addressed token buffer supporting efficient traversal based on a //! cheaply copyable cursor. -//! -//! *This module is available only if Syn is built with the `"parsing"` feature.* // This module is heavily commented as it contains most of the unsafe code in // Syn, and caution should be used when editing it. The public-facing interface @@ -13,6 +11,7 @@ ))] use crate::proc_macro as pm; use crate::Lifetime; +use proc_macro2::extra::DelimSpan; use proc_macro2::{Delimiter, Group, Ident, Literal, Punct, Spacing, Span, TokenStream, TokenTree}; use std::cmp::Ordering; use std::marker::PhantomData; @@ -33,8 +32,6 @@ enum Entry { /// A buffer that can be efficiently traversed multiple times, unlike /// `TokenStream` which requires a deep copy in order to traverse more than /// once. -/// -/// *This type is available only if Syn is built with the `"parsing"` feature.* pub struct TokenBuffer { // NOTE: Do not implement clone on this - while the current design could be // cloned, other designs which could be desirable may not be cloneable. @@ -63,13 +60,11 @@ impl TokenBuffer { /// Creates a `TokenBuffer` containing all the tokens from the input /// `proc_macro::TokenStream`. - /// - /// *This method is available only if Syn is built with both the `"parsing"` and - /// `"proc-macro"` features.* #[cfg(all( not(all(target_arch = "wasm32", any(target_os = "unknown", target_os = "wasi"))), feature = "proc-macro" ))] + #[cfg_attr(doc_cfg, doc(cfg(feature = "proc-macro")))] pub fn new(stream: pm::TokenStream) -> Self { Self::new2(stream.into()) } @@ -101,11 +96,6 @@ impl TokenBuffer { /// /// An empty `Cursor` can be created directly, or one may create a `TokenBuffer` /// object and get a cursor to its first token with `begin()`. -/// -/// Two cursors are equal if they have the same location in the same input -/// stream, and have the same scope. -/// -/// *This type is available only if Syn is built with the `"parsing"` feature.* pub struct Cursor<'a> { // The current entry which the `Cursor` is pointing at. ptr: *const Entry, @@ -199,7 +189,7 @@ impl<'a> Cursor<'a> { /// If the cursor is pointing at a `Group` with the given delimiter, returns /// a cursor into that group and one pointing to the next `TokenTree`. - pub fn group(mut self, delim: Delimiter) -> Option<(Cursor<'a>, Span, Cursor<'a>)> { + pub fn group(mut self, delim: Delimiter) -> Option<(Cursor<'a>, DelimSpan, Cursor<'a>)> { // If we're not trying to enter a none-delimited group, we want to // ignore them. We have to make sure to _not_ ignore them when we want // to enter them, of course. For obvious reasons. @@ -209,16 +199,40 @@ impl<'a> Cursor<'a> { if let Entry::Group(group, end_offset) = self.entry() { if group.delimiter() == delim { + let span = group.delim_span(); let end_of_group = unsafe { self.ptr.add(*end_offset) }; let inside_of_group = unsafe { Cursor::create(self.ptr.add(1), end_of_group) }; let after_group = unsafe { Cursor::create(end_of_group, self.scope) }; - return Some((inside_of_group, group.span(), after_group)); + return Some((inside_of_group, span, after_group)); } } None } + pub(crate) fn any_group(self) -> Option<(Cursor<'a>, Delimiter, DelimSpan, Cursor<'a>)> { + if let Entry::Group(group, end_offset) = self.entry() { + let delimiter = group.delimiter(); + let span = group.delim_span(); + let end_of_group = unsafe { self.ptr.add(*end_offset) }; + let inside_of_group = unsafe { Cursor::create(self.ptr.add(1), end_of_group) }; + let after_group = unsafe { Cursor::create(end_of_group, self.scope) }; + return Some((inside_of_group, delimiter, span, after_group)); + } + + None + } + + pub(crate) fn any_group_token(self) -> Option<(Group, Cursor<'a>)> { + if let Entry::Group(group, end_offset) = self.entry() { + let end_of_group = unsafe { self.ptr.add(*end_offset) }; + let after_group = unsafe { Cursor::create(end_of_group, self.scope) }; + return Some((group.clone(), after_group)); + } + + None + } + /// If the cursor is pointing at a `Ident`, returns it along with a cursor /// pointing at the next `TokenTree`. pub fn ident(mut self) -> Option<(Ident, Cursor<'a>)> { @@ -313,6 +327,33 @@ impl<'a> Cursor<'a> { } } + /// Returns the `Span` of the token immediately prior to the position of + /// this cursor, or of the current token if there is no previous one. + #[cfg(any(feature = "full", feature = "derive"))] + pub(crate) fn prev_span(mut self) -> Span { + if start_of_buffer(self) < self.ptr { + self.ptr = unsafe { self.ptr.offset(-1) }; + if let Entry::End(_) = self.entry() { + // Locate the matching Group begin token. + let mut depth = 1; + loop { + self.ptr = unsafe { self.ptr.offset(-1) }; + match self.entry() { + Entry::Group(group, _) => { + depth -= 1; + if depth == 0 { + return group.span(); + } + } + Entry::End(_) => depth += 1, + Entry::Literal(_) | Entry::Ident(_) | Entry::Punct(_) => {} + } + } + } + } + self.span() + } + /// Skip over the next token without cloning it. Returns `None` if this /// cursor points to eof. /// @@ -368,11 +409,13 @@ pub(crate) fn same_scope(a: Cursor, b: Cursor) -> bool { } pub(crate) fn same_buffer(a: Cursor, b: Cursor) -> bool { + start_of_buffer(a) == start_of_buffer(b) +} + +fn start_of_buffer(cursor: Cursor) -> *const Entry { unsafe { - match (&*a.scope, &*b.scope) { - (Entry::End(a_offset), Entry::End(b_offset)) => { - a.scope.offset(*a_offset) == b.scope.offset(*b_offset) - } + match &*cursor.scope { + Entry::End(offset) => cursor.scope.offset(*offset), _ => unreachable!(), } } diff --git a/vendor/syn/src/custom_keyword.rs b/vendor/syn/src/custom_keyword.rs index a3ec9d4cb..379d159e7 100644 --- a/vendor/syn/src/custom_keyword.rs +++ b/vendor/syn/src/custom_keyword.rs @@ -96,26 +96,28 @@ macro_rules! custom_keyword { #[doc(hidden)] #[allow(dead_code, non_snake_case)] - pub fn $ident<__S: $crate::__private::IntoSpans<[$crate::__private::Span; 1]>>( + pub fn $ident<__S: $crate::__private::IntoSpans<$crate::__private::Span>>( span: __S, ) -> $ident { $ident { - span: $crate::__private::IntoSpans::into_spans(span)[0], + span: $crate::__private::IntoSpans::into_spans(span), } } - impl $crate::__private::Default for $ident { - fn default() -> Self { - $ident { - span: $crate::__private::Span::call_site(), + const _: () = { + impl $crate::__private::Default for $ident { + fn default() -> Self { + $ident { + span: $crate::__private::Span::call_site(), + } } } - } - $crate::impl_parse_for_custom_keyword!($ident); - $crate::impl_to_tokens_for_custom_keyword!($ident); - $crate::impl_clone_for_custom_keyword!($ident); - $crate::impl_extra_traits_for_custom_keyword!($ident); + $crate::impl_parse_for_custom_keyword!($ident); + $crate::impl_to_tokens_for_custom_keyword!($ident); + $crate::impl_clone_for_custom_keyword!($ident); + $crate::impl_extra_traits_for_custom_keyword!($ident); + }; }; } @@ -129,14 +131,14 @@ macro_rules! impl_parse_for_custom_keyword { impl $crate::token::CustomToken for $ident { fn peek(cursor: $crate::buffer::Cursor) -> $crate::__private::bool { if let $crate::__private::Some((ident, _rest)) = cursor.ident() { - ident == stringify!($ident) + ident == $crate::__private::stringify!($ident) } else { false } } fn display() -> &'static $crate::__private::str { - concat!("`", stringify!($ident), "`") + $crate::__private::concat!("`", $crate::__private::stringify!($ident), "`") } } @@ -144,14 +146,14 @@ macro_rules! impl_parse_for_custom_keyword { fn parse(input: $crate::parse::ParseStream) -> $crate::parse::Result<$ident> { input.step(|cursor| { if let $crate::__private::Some((ident, rest)) = cursor.ident() { - if ident == stringify!($ident) { + if ident == $crate::__private::stringify!($ident) { return $crate::__private::Ok(($ident { span: ident.span() }, rest)); } } - $crate::__private::Err(cursor.error(concat!( + $crate::__private::Err(cursor.error($crate::__private::concat!( "expected `", - stringify!($ident), - "`" + $crate::__private::stringify!($ident), + "`", ))) }) } @@ -175,7 +177,7 @@ macro_rules! impl_to_tokens_for_custom_keyword { ($ident:ident) => { impl $crate::__private::ToTokens for $ident { fn to_tokens(&self, tokens: &mut $crate::__private::TokenStream2) { - let ident = $crate::Ident::new(stringify!($ident), self.span); + let ident = $crate::Ident::new($crate::__private::stringify!($ident), self.span); $crate::__private::TokenStreamExt::append(tokens, ident); } } @@ -225,7 +227,11 @@ macro_rules! impl_extra_traits_for_custom_keyword { fn fmt(&self, f: &mut $crate::__private::Formatter) -> $crate::__private::fmt::Result { $crate::__private::Formatter::write_str( f, - concat!("Keyword [", stringify!($ident), "]"), + $crate::__private::concat!( + "Keyword [", + $crate::__private::stringify!($ident), + "]", + ), ) } } diff --git a/vendor/syn/src/custom_punctuation.rs b/vendor/syn/src/custom_punctuation.rs index 118a8453d..e8cbcd2fe 100644 --- a/vendor/syn/src/custom_punctuation.rs +++ b/vendor/syn/src/custom_punctuation.rs @@ -92,16 +92,18 @@ macro_rules! custom_punctuation { } } - impl $crate::__private::Default for $ident { - fn default() -> Self { - $ident($crate::__private::Span::call_site()) + const _: () = { + impl $crate::__private::Default for $ident { + fn default() -> Self { + $ident($crate::__private::Span::call_site()) + } } - } - $crate::impl_parse_for_custom_punctuation!($ident, $($tt)+); - $crate::impl_to_tokens_for_custom_punctuation!($ident, $($tt)+); - $crate::impl_clone_for_custom_punctuation!($ident, $($tt)+); - $crate::impl_extra_traits_for_custom_punctuation!($ident, $($tt)+); + $crate::impl_parse_for_custom_punctuation!($ident, $($tt)+); + $crate::impl_to_tokens_for_custom_punctuation!($ident, $($tt)+); + $crate::impl_clone_for_custom_punctuation!($ident, $($tt)+); + $crate::impl_extra_traits_for_custom_punctuation!($ident, $($tt)+); + }; }; } @@ -113,18 +115,18 @@ macro_rules! impl_parse_for_custom_punctuation { ($ident:ident, $($tt:tt)+) => { impl $crate::token::CustomToken for $ident { fn peek(cursor: $crate::buffer::Cursor) -> bool { - $crate::token::parsing::peek_punct(cursor, $crate::stringify_punct!($($tt)+)) + $crate::__private::peek_punct(cursor, $crate::stringify_punct!($($tt)+)) } fn display() -> &'static $crate::__private::str { - concat!("`", $crate::stringify_punct!($($tt)+), "`") + $crate::__private::concat!("`", $crate::stringify_punct!($($tt)+), "`") } } impl $crate::parse::Parse for $ident { fn parse(input: $crate::parse::ParseStream) -> $crate::parse::Result<$ident> { let spans: $crate::custom_punctuation_repr!($($tt)+) = - $crate::token::parsing::punct(input, $crate::stringify_punct!($($tt)+))?; + $crate::__private::parse_punct(input, $crate::stringify_punct!($($tt)+))?; Ok($ident(spans)) } } @@ -147,7 +149,7 @@ macro_rules! impl_to_tokens_for_custom_punctuation { ($ident:ident, $($tt:tt)+) => { impl $crate::__private::ToTokens for $ident { fn to_tokens(&self, tokens: &mut $crate::__private::TokenStream2) { - $crate::token::printing::punct($crate::stringify_punct!($($tt)+), &self.spans, tokens) + $crate::__private::print_punct($crate::stringify_punct!($($tt)+), &self.spans, tokens) } } }; @@ -194,7 +196,7 @@ macro_rules! impl_extra_traits_for_custom_punctuation { ($ident:ident, $($tt:tt)+) => { impl $crate::__private::Debug for $ident { fn fmt(&self, f: &mut $crate::__private::Formatter) -> $crate::__private::fmt::Result { - $crate::__private::Formatter::write_str(f, stringify!($ident)) + $crate::__private::Formatter::write_str(f, $crate::__private::stringify!($ident)) } } @@ -295,6 +297,6 @@ macro_rules! custom_punctuation_unexpected { #[macro_export] macro_rules! stringify_punct { ($($tt:tt)+) => { - concat!($(stringify!($tt)),+) + $crate::__private::concat!($($crate::__private::stringify!($tt)),+) }; } diff --git a/vendor/syn/src/data.rs b/vendor/syn/src/data.rs index 3b466618f..185f88ba0 100644 --- a/vendor/syn/src/data.rs +++ b/vendor/syn/src/data.rs @@ -3,12 +3,8 @@ use crate::punctuated::Punctuated; ast_struct! { /// An enum variant. - /// - /// *This type is available only if Syn is built with the `"derive"` or `"full"` - /// feature.* #[cfg_attr(doc_cfg, doc(cfg(any(feature = "full", feature = "derive"))))] pub struct Variant { - /// Attributes tagged on the variant. pub attrs: Vec<Attribute>, /// Name of the variant. @@ -25,9 +21,6 @@ ast_struct! { ast_enum_of_structs! { /// Data stored within an enum variant or struct. /// - /// *This type is available only if Syn is built with the `"derive"` or `"full"` - /// feature.* - /// /// # Syntax tree enum /// /// This type is a [syntax tree enum]. @@ -50,9 +43,6 @@ ast_enum_of_structs! { ast_struct! { /// Named fields of a struct or struct variant such as `Point { x: f64, /// y: f64 }`. - /// - /// *This type is available only if Syn is built with the `"derive"` or - /// `"full"` feature.* #[cfg_attr(doc_cfg, doc(cfg(any(feature = "full", feature = "derive"))))] pub struct FieldsNamed { pub brace_token: token::Brace, @@ -62,9 +52,6 @@ ast_struct! { ast_struct! { /// Unnamed fields of a tuple struct or tuple variant such as `Some(T)`. - /// - /// *This type is available only if Syn is built with the `"derive"` or - /// `"full"` feature.* #[cfg_attr(doc_cfg, doc(cfg(any(feature = "full", feature = "derive"))))] pub struct FieldsUnnamed { pub paren_token: token::Paren, @@ -147,17 +134,14 @@ impl<'a> IntoIterator for &'a mut Fields { ast_struct! { /// A field of a struct or enum variant. - /// - /// *This type is available only if Syn is built with the `"derive"` or `"full"` - /// feature.* #[cfg_attr(doc_cfg, doc(cfg(any(feature = "full", feature = "derive"))))] pub struct Field { - /// Attributes tagged on the field. pub attrs: Vec<Attribute>, - /// Visibility of the field. pub vis: Visibility, + pub mutability: FieldMutability, + /// Name of the field, if any. /// /// Fields of tuple structs have no names. @@ -165,82 +149,14 @@ ast_struct! { pub colon_token: Option<Token![:]>, - /// Type of the field. pub ty: Type, } } -ast_enum_of_structs! { - /// The visibility level of an item: inherited or `pub` or - /// `pub(restricted)`. - /// - /// *This type is available only if Syn is built with the `"derive"` or `"full"` - /// feature.* - /// - /// # Syntax tree enum - /// - /// This type is a [syntax tree enum]. - /// - /// [syntax tree enum]: Expr#syntax-tree-enums - #[cfg_attr(doc_cfg, doc(cfg(any(feature = "full", feature = "derive"))))] - pub enum Visibility { - /// A public visibility level: `pub`. - Public(VisPublic), - - /// A crate-level visibility: `crate`. - Crate(VisCrate), - - /// A visibility level restricted to some path: `pub(self)` or - /// `pub(super)` or `pub(crate)` or `pub(in some::module)`. - Restricted(VisRestricted), - - /// An inherited visibility, which usually means private. - Inherited, - } -} - -ast_struct! { - /// A public visibility level: `pub`. - /// - /// *This type is available only if Syn is built with the `"derive"` or - /// `"full"` feature.* - #[cfg_attr(doc_cfg, doc(cfg(any(feature = "full", feature = "derive"))))] - pub struct VisPublic { - pub pub_token: Token![pub], - } -} - -ast_struct! { - /// A crate-level visibility: `crate`. - /// - /// *This type is available only if Syn is built with the `"derive"` or - /// `"full"` feature.* - #[cfg_attr(doc_cfg, doc(cfg(any(feature = "full", feature = "derive"))))] - pub struct VisCrate { - pub crate_token: Token![crate], - } -} - -ast_struct! { - /// A visibility level restricted to some path: `pub(self)` or - /// `pub(super)` or `pub(crate)` or `pub(in some::module)`. - /// - /// *This type is available only if Syn is built with the `"derive"` or - /// `"full"` feature.* - #[cfg_attr(doc_cfg, doc(cfg(any(feature = "full", feature = "derive"))))] - pub struct VisRestricted { - pub pub_token: Token![pub], - pub paren_token: token::Paren, - pub in_token: Option<Token![in]>, - pub path: Box<Path>, - } -} - #[cfg(feature = "parsing")] -pub mod parsing { +pub(crate) mod parsing { use super::*; use crate::ext::IdentExt; - use crate::parse::discouraged::Speculative; use crate::parse::{Parse, ParseStream, Result}; #[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))] @@ -278,7 +194,7 @@ pub mod parsing { let content; Ok(FieldsNamed { brace_token: braced!(content in input), - named: content.parse_terminated(Field::parse_named)?, + named: content.parse_terminated(Field::parse_named, Token![,])?, }) } } @@ -289,7 +205,7 @@ pub mod parsing { let content; Ok(FieldsUnnamed { paren_token: parenthesized!(content in input), - unnamed: content.parse_terminated(Field::parse_unnamed)?, + unnamed: content.parse_terminated(Field::parse_unnamed, Token![,])?, }) } } @@ -301,6 +217,7 @@ pub mod parsing { Ok(Field { attrs: input.call(Attribute::parse_outer)?, vis: input.parse()?, + mutability: FieldMutability::None, ident: Some(if input.peek(Token![_]) { input.call(Ident::parse_any) } else { @@ -317,100 +234,13 @@ pub mod parsing { Ok(Field { attrs: input.call(Attribute::parse_outer)?, vis: input.parse()?, + mutability: FieldMutability::None, ident: None, colon_token: None, ty: input.parse()?, }) } } - - #[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))] - impl Parse for Visibility { - fn parse(input: ParseStream) -> Result<Self> { - // Recognize an empty None-delimited group, as produced by a $:vis - // matcher that matched no tokens. - if input.peek(token::Group) { - let ahead = input.fork(); - let group = crate::group::parse_group(&ahead)?; - if group.content.is_empty() { - input.advance_to(&ahead); - return Ok(Visibility::Inherited); - } - } - - if input.peek(Token![pub]) { - Self::parse_pub(input) - } else if input.peek(Token![crate]) { - Self::parse_crate(input) - } else { - Ok(Visibility::Inherited) - } - } - } - - impl Visibility { - fn parse_pub(input: ParseStream) -> Result<Self> { - let pub_token = input.parse::<Token![pub]>()?; - - if input.peek(token::Paren) { - let ahead = input.fork(); - - let content; - let paren_token = parenthesized!(content in ahead); - if content.peek(Token![crate]) - || content.peek(Token![self]) - || content.peek(Token![super]) - { - let path = content.call(Ident::parse_any)?; - - // Ensure there are no additional tokens within `content`. - // Without explicitly checking, we may misinterpret a tuple - // field as a restricted visibility, causing a parse error. - // e.g. `pub (crate::A, crate::B)` (Issue #720). - if content.is_empty() { - input.advance_to(&ahead); - return Ok(Visibility::Restricted(VisRestricted { - pub_token, - paren_token, - in_token: None, - path: Box::new(Path::from(path)), - })); - } - } else if content.peek(Token![in]) { - let in_token: Token![in] = content.parse()?; - let path = content.call(Path::parse_mod_style)?; - - input.advance_to(&ahead); - return Ok(Visibility::Restricted(VisRestricted { - pub_token, - paren_token, - in_token: Some(in_token), - path: Box::new(path), - })); - } - } - - Ok(Visibility::Public(VisPublic { pub_token })) - } - - fn parse_crate(input: ParseStream) -> Result<Self> { - if input.peek2(Token![::]) { - Ok(Visibility::Inherited) - } else { - Ok(Visibility::Crate(VisCrate { - crate_token: input.parse()?, - })) - } - } - - #[cfg(feature = "full")] - pub(crate) fn is_some(&self) -> bool { - match self { - Visibility::Inherited => false, - _ => true, - } - } - } } #[cfg(feature = "printing")] @@ -463,31 +293,4 @@ mod printing { self.ty.to_tokens(tokens); } } - - #[cfg_attr(doc_cfg, doc(cfg(feature = "printing")))] - impl ToTokens for VisPublic { - fn to_tokens(&self, tokens: &mut TokenStream) { - self.pub_token.to_tokens(tokens); - } - } - - #[cfg_attr(doc_cfg, doc(cfg(feature = "printing")))] - impl ToTokens for VisCrate { - fn to_tokens(&self, tokens: &mut TokenStream) { - self.crate_token.to_tokens(tokens); - } - } - - #[cfg_attr(doc_cfg, doc(cfg(feature = "printing")))] - impl ToTokens for VisRestricted { - fn to_tokens(&self, tokens: &mut TokenStream) { - self.pub_token.to_tokens(tokens); - self.paren_token.surround(tokens, |tokens| { - // TODO: If we have a path which is not "self" or "super" or - // "crate", automatically add the "in" token. - self.in_token.to_tokens(tokens); - self.path.to_tokens(tokens); - }); - } - } } diff --git a/vendor/syn/src/derive.rs b/vendor/syn/src/derive.rs index af9bb91b7..25fa4c910 100644 --- a/vendor/syn/src/derive.rs +++ b/vendor/syn/src/derive.rs @@ -3,32 +3,19 @@ use crate::punctuated::Punctuated; ast_struct! { /// Data structure sent to a `proc_macro_derive` macro. - /// - /// *This type is available only if Syn is built with the `"derive"` feature.* #[cfg_attr(doc_cfg, doc(cfg(feature = "derive")))] pub struct DeriveInput { - /// Attributes tagged on the whole struct or enum. pub attrs: Vec<Attribute>, - - /// Visibility of the struct or enum. pub vis: Visibility, - - /// Name of the struct or enum. pub ident: Ident, - - /// Generics required to complete the definition. pub generics: Generics, - - /// Data within the struct or enum. pub data: Data, } } -ast_enum_of_structs! { +ast_enum! { /// The storage of a struct, enum or union data structure. /// - /// *This type is available only if Syn is built with the `"derive"` feature.* - /// /// # Syntax tree enum /// /// This type is a [syntax tree enum]. @@ -36,24 +23,14 @@ ast_enum_of_structs! { /// [syntax tree enum]: Expr#syntax-tree-enums #[cfg_attr(doc_cfg, doc(cfg(feature = "derive")))] pub enum Data { - /// A struct input to a `proc_macro_derive` macro. Struct(DataStruct), - - /// An enum input to a `proc_macro_derive` macro. Enum(DataEnum), - - /// An untagged union input to a `proc_macro_derive` macro. Union(DataUnion), } - - do_not_generate_to_tokens } ast_struct! { /// A struct input to a `proc_macro_derive` macro. - /// - /// *This type is available only if Syn is built with the `"derive"` - /// feature.* #[cfg_attr(doc_cfg, doc(cfg(feature = "derive")))] pub struct DataStruct { pub struct_token: Token![struct], @@ -64,9 +41,6 @@ ast_struct! { ast_struct! { /// An enum input to a `proc_macro_derive` macro. - /// - /// *This type is available only if Syn is built with the `"derive"` - /// feature.* #[cfg_attr(doc_cfg, doc(cfg(feature = "derive")))] pub struct DataEnum { pub enum_token: Token![enum], @@ -77,9 +51,6 @@ ast_struct! { ast_struct! { /// An untagged union input to a `proc_macro_derive` macro. - /// - /// *This type is available only if Syn is built with the `"derive"` - /// feature.* #[cfg_attr(doc_cfg, doc(cfg(feature = "derive")))] pub struct DataUnion { pub union_token: Token![union], @@ -88,7 +59,7 @@ ast_struct! { } #[cfg(feature = "parsing")] -pub mod parsing { +pub(crate) mod parsing { use super::*; use crate::parse::{Parse, ParseStream, Result}; @@ -161,7 +132,7 @@ pub mod parsing { } } - pub fn data_struct( + pub(crate) fn data_struct( input: ParseStream, ) -> Result<(Option<WhereClause>, Fields, Option<Token![;]>)> { let mut lookahead = input.lookahead1(); @@ -197,7 +168,7 @@ pub mod parsing { } } - pub fn data_enum( + pub(crate) fn data_enum( input: ParseStream, ) -> Result<( Option<WhereClause>, @@ -208,12 +179,12 @@ pub mod parsing { let content; let brace = braced!(content in input); - let variants = content.parse_terminated(Variant::parse)?; + let variants = content.parse_terminated(Variant::parse, Token![,])?; Ok((where_clause, brace, variants)) } - pub fn data_union(input: ParseStream) -> Result<(Option<WhereClause>, FieldsNamed)> { + pub(crate) fn data_union(input: ParseStream) -> Result<(Option<WhereClause>, FieldsNamed)> { let where_clause = input.parse()?; let fields = input.parse()?; Ok((where_clause, fields)) diff --git a/vendor/syn/src/discouraged.rs b/vendor/syn/src/discouraged.rs index a46129b6a..fb98d6332 100644 --- a/vendor/syn/src/discouraged.rs +++ b/vendor/syn/src/discouraged.rs @@ -1,6 +1,7 @@ //! Extensions to the parsing API with niche applicability. use super::*; +use proc_macro2::extra::DelimSpan; /// Extensions to the `ParseStream` API to support speculative parsing. pub trait Speculative { @@ -192,3 +193,27 @@ impl<'a> Speculative for ParseBuffer<'a> { .set(unsafe { mem::transmute::<Cursor, Cursor<'static>>(fork.cursor()) }); } } + +/// Extensions to the `ParseStream` API to support manipulating invisible +/// delimiters the same as if they were visible. +pub trait AnyDelimiter { + /// Returns the delimiter, the span of the delimiter token, and the nested + /// contents for further parsing. + fn parse_any_delimiter(&self) -> Result<(Delimiter, DelimSpan, ParseBuffer)>; +} + +impl<'a> AnyDelimiter for ParseBuffer<'a> { + fn parse_any_delimiter(&self) -> Result<(Delimiter, DelimSpan, ParseBuffer)> { + self.step(|cursor| { + if let Some((content, delimiter, span, rest)) = cursor.any_group() { + let scope = crate::buffer::close_span_of_group(*cursor); + let nested = crate::parse::advance_step_cursor(cursor, content); + let unexpected = crate::parse::get_unexpected(self); + let content = crate::parse::new_parse_buffer(scope, nested, unexpected); + Ok(((delimiter, span, content), rest)) + } else { + Err(cursor.error("expected any delimiter")) + } + }) + } +} diff --git a/vendor/syn/src/error.rs b/vendor/syn/src/error.rs index e301367d5..7eebd243c 100644 --- a/vendor/syn/src/error.rs +++ b/vendor/syn/src/error.rs @@ -7,7 +7,6 @@ use proc_macro2::{ #[cfg(feature = "printing")] use quote::ToTokens; use std::fmt::{self, Debug, Display}; -use std::iter::FromIterator; use std::slice; use std::vec; @@ -34,18 +33,34 @@ pub type Result<T> = std::result::Result<T, Error>; /// # extern crate proc_macro; /// # /// use proc_macro::TokenStream; -/// use syn::{parse_macro_input, AttributeArgs, ItemFn}; +/// use syn::parse::{Parse, ParseStream, Result}; +/// use syn::{parse_macro_input, ItemFn}; /// /// # const IGNORE: &str = stringify! { /// #[proc_macro_attribute] /// # }; /// pub fn my_attr(args: TokenStream, input: TokenStream) -> TokenStream { -/// let args = parse_macro_input!(args as AttributeArgs); +/// let args = parse_macro_input!(args as MyAttrArgs); /// let input = parse_macro_input!(input as ItemFn); /// /// /* ... */ /// # TokenStream::new() /// } +/// +/// struct MyAttrArgs { +/// # _k: [(); { stringify! { +/// ... +/// # }; 0 }] +/// } +/// +/// impl Parse for MyAttrArgs { +/// fn parse(input: ParseStream) -> Result<Self> { +/// # stringify! { +/// ... +/// # }; +/// # unimplemented!() +/// } +/// } /// ``` /// /// For errors that arise later than the initial parsing stage, the @@ -89,14 +104,21 @@ pub struct Error { struct ErrorMessage { // Span is implemented as an index into a thread-local interner to keep the // size small. It is not safe to access from a different thread. We want - // errors to be Send and Sync to play nicely with the Failure crate, so pin - // the span we're given to its original thread and assume it is - // Span::call_site if accessed from any other thread. - start_span: ThreadBound<Span>, - end_span: ThreadBound<Span>, + // errors to be Send and Sync to play nicely with ecosystem crates for error + // handling, so pin the span we're given to its original thread and assume + // it is Span::call_site if accessed from any other thread. + span: ThreadBound<SpanRange>, message: String, } +// Cannot use std::ops::Range<Span> because that does not implement Copy, +// whereas ThreadBound<T> requires a Copy impl as a way to ensure no Drop impls +// are involved. +struct SpanRange { + start: Span, + end: Span, +} + #[cfg(test)] struct _Test where @@ -139,8 +161,10 @@ impl Error { fn new(span: Span, message: String) -> Error { Error { messages: vec![ErrorMessage { - start_span: ThreadBound::new(span), - end_span: ThreadBound::new(span), + span: ThreadBound::new(SpanRange { + start: span, + end: span, + }), message, }], } @@ -170,8 +194,7 @@ impl Error { let end = iter.last().map_or(start, |t| t.span()); Error { messages: vec![ErrorMessage { - start_span: ThreadBound::new(start), - end_span: ThreadBound::new(end), + span: ThreadBound::new(SpanRange { start, end }), message, }], } @@ -184,11 +207,7 @@ impl Error { /// if called from a different thread than the one on which the `Error` was /// originally created. pub fn span(&self) -> Span { - let start = match self.messages[0].start_span.get() { - Some(span) => *span, - None => return Span::call_site(), - }; - let end = match self.messages[0].end_span.get() { + let SpanRange { start, end } = match self.messages[0].span.get() { Some(span) => *span, None => return Span::call_site(), }; @@ -254,12 +273,10 @@ impl Error { impl ErrorMessage { fn to_compile_error(&self) -> TokenStream { - let start = self - .start_span - .get() - .cloned() - .unwrap_or_else(Span::call_site); - let end = self.end_span.get().cloned().unwrap_or_else(Span::call_site); + let (start, end) = match self.span.get() { + Some(range) => (range.start, range.end), + None => (Span::call_site(), Span::call_site()), + }; // compile_error!($message) TokenStream::from_iter(vec![ @@ -285,7 +302,7 @@ impl ErrorMessage { } #[cfg(feature = "parsing")] -pub fn new_at<T: Display>(scope: Span, cursor: Cursor, message: T) -> Error { +pub(crate) fn new_at<T: Display>(scope: Span, cursor: Cursor, message: T) -> Error { if cursor.eof() { Error::new(scope, format!("unexpected end of input, {}", message)) } else { @@ -295,14 +312,13 @@ pub fn new_at<T: Display>(scope: Span, cursor: Cursor, message: T) -> Error { } #[cfg(all(feature = "parsing", any(feature = "full", feature = "derive")))] -pub fn new2<T: Display>(start: Span, end: Span, message: T) -> Error { +pub(crate) fn new2<T: Display>(start: Span, end: Span, message: T) -> Error { return new2(start, end, message.to_string()); fn new2(start: Span, end: Span, message: String) -> Error { Error { messages: vec![ErrorMessage { - start_span: ThreadBound::new(start), - end_span: ThreadBound::new(end), + span: ThreadBound::new(SpanRange { start, end }), message, }], } @@ -347,20 +363,21 @@ impl Clone for Error { impl Clone for ErrorMessage { fn clone(&self) -> Self { - let start = self - .start_span - .get() - .cloned() - .unwrap_or_else(Span::call_site); - let end = self.end_span.get().cloned().unwrap_or_else(Span::call_site); ErrorMessage { - start_span: ThreadBound::new(start), - end_span: ThreadBound::new(end), + span: self.span.clone(), message: self.message.clone(), } } } +impl Clone for SpanRange { + fn clone(&self) -> Self { + *self + } +} + +impl Copy for SpanRange {} + impl std::error::Error for Error {} impl From<LexError> for Error { diff --git a/vendor/syn/src/export.rs b/vendor/syn/src/export.rs index f478d091e..c1c16f9ed 100644 --- a/vendor/syn/src/export.rs +++ b/vendor/syn/src/export.rs @@ -1,14 +1,16 @@ pub use std::clone::Clone; pub use std::cmp::{Eq, PartialEq}; +pub use std::concat; pub use std::default::Default; pub use std::fmt::{self, Debug, Formatter}; pub use std::hash::{Hash, Hasher}; pub use std::marker::Copy; pub use std::option::Option::{None, Some}; pub use std::result::Result::{Err, Ok}; +pub use std::stringify; #[cfg(feature = "printing")] -pub extern crate quote; +pub use quote; pub use proc_macro2::{Span, TokenStream as TokenStream2}; @@ -17,6 +19,15 @@ pub use crate::group::{parse_braces, parse_brackets, parse_parens}; pub use crate::span::IntoSpans; +#[cfg(all(feature = "parsing", feature = "printing"))] +pub use crate::parse_quote::parse as parse_quote; + +#[cfg(feature = "parsing")] +pub use crate::token::parsing::{peek_punct, punct as parse_punct}; + +#[cfg(feature = "printing")] +pub use crate::token::printing::punct as print_punct; + #[cfg(all( not(all(target_arch = "wasm32", any(target_os = "unknown", target_os = "wasi"))), feature = "proc-macro" diff --git a/vendor/syn/src/expr.rs b/vendor/syn/src/expr.rs index 93a59b0e2..8caccb33f 100644 --- a/vendor/syn/src/expr.rs +++ b/vendor/syn/src/expr.rs @@ -1,7 +1,5 @@ use super::*; use crate::punctuated::Punctuated; -#[cfg(feature = "full")] -use crate::reserved::Reserved; use proc_macro2::{Span, TokenStream}; #[cfg(feature = "printing")] use quote::IdentFragment; @@ -87,7 +85,7 @@ ast_enum_of_structs! { /// see names getting repeated in your code, like accessing /// `receiver.receiver` or `pat.pat` or `cond.cond`. #[cfg_attr(doc_cfg, doc(cfg(any(feature = "full", feature = "derive"))))] - #[cfg_attr(not(syn_no_non_exhaustive), non_exhaustive)] + #[non_exhaustive] pub enum Expr { /// A slice literal expression: `[a, b, c, d]`. Array(ExprArray), @@ -95,24 +93,18 @@ ast_enum_of_structs! { /// An assignment expression: `a = compute()`. Assign(ExprAssign), - /// A compound assignment expression: `counter += 1`. - AssignOp(ExprAssignOp), - /// An async block: `async { ... }`. Async(ExprAsync), /// An await expression: `fut.await`. Await(ExprAwait), - /// A binary operation: `a + b`, `a * b`. + /// A binary operation: `a + b`, `a += b`. Binary(ExprBinary), /// A blocked scope: `{ ... }`. Block(ExprBlock), - /// A box expression: `box f`. - Box(ExprBox), - /// A `break`, with an optional label to break and an optional /// expression. Break(ExprBreak), @@ -126,6 +118,9 @@ ast_enum_of_structs! { /// A closure expression: `|a, b| a + b`. Closure(ExprClosure), + /// A const block: `const { ... }`. + Const(ExprConst), + /// A `continue`, with an optional label. Continue(ExprContinue), @@ -153,6 +148,9 @@ ast_enum_of_structs! { /// A square bracketed indexing expression: `vector[2]`. Index(ExprIndex), + /// The inferred value of a const generic argument, denoted `_`. + Infer(ExprInfer), + /// A `let` guard: `let Some(x) = opt`. Let(ExprLet), @@ -207,9 +205,6 @@ ast_enum_of_structs! { /// A tuple expression: `(a, b, c, d)`. Tuple(ExprTuple), - /// A type ascription expression: `foo: f64`. - Type(ExprType), - /// A unary operation: `!x`, `*x`. Unary(ExprUnary), @@ -225,8 +220,6 @@ ast_enum_of_structs! { /// A yield expression: `yield expr`. Yield(ExprYield), - // Not public API. - // // For testing exhaustiveness in downstream code, use the following idiom: // // match expr { @@ -243,16 +236,11 @@ ast_enum_of_structs! { // a variant. You will be notified by a test failure when a variant is // added, so that you can add code to handle it, but your library will // continue to compile and work for downstream users in the interim. - #[cfg(syn_no_non_exhaustive)] - #[doc(hidden)] - __NonExhaustive, } } ast_struct! { /// A slice literal expression: `[a, b, c, d]`. - /// - /// *This type is available only if Syn is built with the `"full"` feature.* #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub struct ExprArray #full { pub attrs: Vec<Attribute>, @@ -263,8 +251,6 @@ ast_struct! { ast_struct! { /// An assignment expression: `a = compute()`. - /// - /// *This type is available only if Syn is built with the `"full"` feature.* #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub struct ExprAssign #full { pub attrs: Vec<Attribute>, @@ -275,22 +261,7 @@ ast_struct! { } ast_struct! { - /// A compound assignment expression: `counter += 1`. - /// - /// *This type is available only if Syn is built with the `"full"` feature.* - #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] - pub struct ExprAssignOp #full { - pub attrs: Vec<Attribute>, - pub left: Box<Expr>, - pub op: BinOp, - pub right: Box<Expr>, - } -} - -ast_struct! { /// An async block: `async { ... }`. - /// - /// *This type is available only if Syn is built with the `"full"` feature.* #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub struct ExprAsync #full { pub attrs: Vec<Attribute>, @@ -302,22 +273,17 @@ ast_struct! { ast_struct! { /// An await expression: `fut.await`. - /// - /// *This type is available only if Syn is built with the `"full"` feature.* #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub struct ExprAwait #full { pub attrs: Vec<Attribute>, pub base: Box<Expr>, pub dot_token: Token![.], - pub await_token: token::Await, + pub await_token: Token![await], } } ast_struct! { - /// A binary operation: `a + b`, `a * b`. - /// - /// *This type is available only if Syn is built with the `"derive"` or - /// `"full"` feature.* + /// A binary operation: `a + b`, `a += b`. #[cfg_attr(doc_cfg, doc(cfg(any(feature = "full", feature = "derive"))))] pub struct ExprBinary { pub attrs: Vec<Attribute>, @@ -329,8 +295,6 @@ ast_struct! { ast_struct! { /// A blocked scope: `{ ... }`. - /// - /// *This type is available only if Syn is built with the `"full"` feature.* #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub struct ExprBlock #full { pub attrs: Vec<Attribute>, @@ -340,22 +304,8 @@ ast_struct! { } ast_struct! { - /// A box expression: `box f`. - /// - /// *This type is available only if Syn is built with the `"full"` feature.* - #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] - pub struct ExprBox #full { - pub attrs: Vec<Attribute>, - pub box_token: Token![box], - pub expr: Box<Expr>, - } -} - -ast_struct! { /// A `break`, with an optional label to break and an optional /// expression. - /// - /// *This type is available only if Syn is built with the `"full"` feature.* #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub struct ExprBreak #full { pub attrs: Vec<Attribute>, @@ -367,9 +317,6 @@ ast_struct! { ast_struct! { /// A function call expression: `invoke(a, b)`. - /// - /// *This type is available only if Syn is built with the `"derive"` or - /// `"full"` feature.* #[cfg_attr(doc_cfg, doc(cfg(any(feature = "full", feature = "derive"))))] pub struct ExprCall { pub attrs: Vec<Attribute>, @@ -381,9 +328,6 @@ ast_struct! { ast_struct! { /// A cast expression: `foo as f64`. - /// - /// *This type is available only if Syn is built with the `"derive"` or - /// `"full"` feature.* #[cfg_attr(doc_cfg, doc(cfg(any(feature = "full", feature = "derive"))))] pub struct ExprCast { pub attrs: Vec<Attribute>, @@ -395,11 +339,11 @@ ast_struct! { ast_struct! { /// A closure expression: `|a, b| a + b`. - /// - /// *This type is available only if Syn is built with the `"full"` feature.* #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub struct ExprClosure #full { pub attrs: Vec<Attribute>, + pub lifetimes: Option<BoundLifetimes>, + pub constness: Option<Token![const]>, pub movability: Option<Token![static]>, pub asyncness: Option<Token![async]>, pub capture: Option<Token![move]>, @@ -412,9 +356,16 @@ ast_struct! { } ast_struct! { + /// A const block: `const { ... }`. + pub struct ExprConst #full { + pub attrs: Vec<Attribute>, + pub const_token: Token![const], + pub block: Block, + } +} + +ast_struct! { /// A `continue`, with an optional label. - /// - /// *This type is available only if Syn is built with the `"full"` feature.* #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub struct ExprContinue #full { pub attrs: Vec<Attribute>, @@ -426,8 +377,6 @@ ast_struct! { ast_struct! { /// Access of a named struct field (`obj.k`) or unnamed tuple struct /// field (`obj.0`). - /// - /// *This type is available only if Syn is built with the `"full"` feature.* #[cfg_attr(doc_cfg, doc(cfg(any(feature = "full", feature = "derive"))))] pub struct ExprField { pub attrs: Vec<Attribute>, @@ -439,14 +388,12 @@ ast_struct! { ast_struct! { /// A for loop: `for pat in expr { ... }`. - /// - /// *This type is available only if Syn is built with the `"full"` feature.* #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub struct ExprForLoop #full { pub attrs: Vec<Attribute>, pub label: Option<Label>, pub for_token: Token![for], - pub pat: Pat, + pub pat: Box<Pat>, pub in_token: Token![in], pub expr: Box<Expr>, pub body: Block, @@ -459,10 +406,8 @@ ast_struct! { /// This variant is important for faithfully representing the precedence /// of expressions and is related to `None`-delimited spans in a /// `TokenStream`. - /// - /// *This type is available only if Syn is built with the `"full"` feature.* #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] - pub struct ExprGroup #full { + pub struct ExprGroup { pub attrs: Vec<Attribute>, pub group_token: token::Group, pub expr: Box<Expr>, @@ -475,8 +420,6 @@ ast_struct! { /// /// The `else` branch expression may only be an `If` or `Block` /// expression, not any of the other types of expression. - /// - /// *This type is available only if Syn is built with the `"full"` feature.* #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub struct ExprIf #full { pub attrs: Vec<Attribute>, @@ -489,9 +432,6 @@ ast_struct! { ast_struct! { /// A square bracketed indexing expression: `vector[2]`. - /// - /// *This type is available only if Syn is built with the `"derive"` or - /// `"full"` feature.* #[cfg_attr(doc_cfg, doc(cfg(any(feature = "full", feature = "derive"))))] pub struct ExprIndex { pub attrs: Vec<Attribute>, @@ -502,14 +442,20 @@ ast_struct! { } ast_struct! { + /// The inferred value of a const generic argument, denoted `_`. + pub struct ExprInfer #full { + pub attrs: Vec<Attribute>, + pub underscore_token: Token![_], + } +} + +ast_struct! { /// A `let` guard: `let Some(x) = opt`. - /// - /// *This type is available only if Syn is built with the `"full"` feature.* #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub struct ExprLet #full { pub attrs: Vec<Attribute>, pub let_token: Token![let], - pub pat: Pat, + pub pat: Box<Pat>, pub eq_token: Token![=], pub expr: Box<Expr>, } @@ -517,9 +463,6 @@ ast_struct! { ast_struct! { /// A literal in place of an expression: `1`, `"foo"`. - /// - /// *This type is available only if Syn is built with the `"derive"` or - /// `"full"` feature.* #[cfg_attr(doc_cfg, doc(cfg(any(feature = "full", feature = "derive"))))] pub struct ExprLit { pub attrs: Vec<Attribute>, @@ -529,8 +472,6 @@ ast_struct! { ast_struct! { /// Conditionless loop: `loop { ... }`. - /// - /// *This type is available only if Syn is built with the `"full"` feature.* #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub struct ExprLoop #full { pub attrs: Vec<Attribute>, @@ -542,10 +483,7 @@ ast_struct! { ast_struct! { /// A macro invocation expression: `format!("{}", q)`. - /// - /// *This type is available only if Syn is built with the `"full"` feature.* - #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] - pub struct ExprMacro #full { + pub struct ExprMacro { pub attrs: Vec<Attribute>, pub mac: Macro, } @@ -553,8 +491,6 @@ ast_struct! { ast_struct! { /// A `match` expression: `match n { Some(n) => {}, None => {} }`. - /// - /// *This type is available only if Syn is built with the `"full"` feature.* #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub struct ExprMatch #full { pub attrs: Vec<Attribute>, @@ -567,15 +503,13 @@ ast_struct! { ast_struct! { /// A method call expression: `x.foo::<T>(a, b)`. - /// - /// *This type is available only if Syn is built with the `"full"` feature.* #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub struct ExprMethodCall #full { pub attrs: Vec<Attribute>, pub receiver: Box<Expr>, pub dot_token: Token![.], pub method: Ident, - pub turbofish: Option<MethodTurbofish>, + pub turbofish: Option<AngleBracketedGenericArguments>, pub paren_token: token::Paren, pub args: Punctuated<Expr, Token![,]>, } @@ -583,8 +517,6 @@ ast_struct! { ast_struct! { /// A parenthesized expression: `(a + b)`. - /// - /// *This type is available only if Syn is built with the `"full"` feature.* #[cfg_attr(doc_cfg, doc(cfg(any(feature = "full", feature = "derive"))))] pub struct ExprParen { pub attrs: Vec<Attribute>, @@ -598,9 +530,6 @@ ast_struct! { /// parameters and a qualified self-type. /// /// A plain identifier like `x` is a path of length 1. - /// - /// *This type is available only if Syn is built with the `"derive"` or - /// `"full"` feature.* #[cfg_attr(doc_cfg, doc(cfg(any(feature = "full", feature = "derive"))))] pub struct ExprPath { pub attrs: Vec<Attribute>, @@ -611,26 +540,21 @@ ast_struct! { ast_struct! { /// A range expression: `1..2`, `1..`, `..2`, `1..=2`, `..=2`. - /// - /// *This type is available only if Syn is built with the `"full"` feature.* #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub struct ExprRange #full { pub attrs: Vec<Attribute>, - pub from: Option<Box<Expr>>, + pub start: Option<Box<Expr>>, pub limits: RangeLimits, - pub to: Option<Box<Expr>>, + pub end: Option<Box<Expr>>, } } ast_struct! { /// A referencing operation: `&a` or `&mut a`. - /// - /// *This type is available only if Syn is built with the `"full"` feature.* #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub struct ExprReference #full { pub attrs: Vec<Attribute>, pub and_token: Token![&], - pub raw: Reserved, pub mutability: Option<Token![mut]>, pub expr: Box<Expr>, } @@ -638,8 +562,6 @@ ast_struct! { ast_struct! { /// An array literal constructed from one repeated element: `[0u8; N]`. - /// - /// *This type is available only if Syn is built with the `"full"` feature.* #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub struct ExprRepeat #full { pub attrs: Vec<Attribute>, @@ -652,8 +574,6 @@ ast_struct! { ast_struct! { /// A `return`, with an optional value to be returned. - /// - /// *This type is available only if Syn is built with the `"full"` feature.* #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub struct ExprReturn #full { pub attrs: Vec<Attribute>, @@ -667,11 +587,10 @@ ast_struct! { /// /// The `rest` provides the value of the remaining fields as in `S { a: /// 1, b: 1, ..rest }`. - /// - /// *This type is available only if Syn is built with the `"full"` feature.* #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub struct ExprStruct #full { pub attrs: Vec<Attribute>, + pub qself: Option<QSelf>, pub path: Path, pub brace_token: token::Brace, pub fields: Punctuated<FieldValue, Token![,]>, @@ -682,8 +601,6 @@ ast_struct! { ast_struct! { /// A try-expression: `expr?`. - /// - /// *This type is available only if Syn is built with the `"full"` feature.* #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub struct ExprTry #full { pub attrs: Vec<Attribute>, @@ -694,8 +611,6 @@ ast_struct! { ast_struct! { /// A try block: `try { ... }`. - /// - /// *This type is available only if Syn is built with the `"full"` feature.* #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub struct ExprTryBlock #full { pub attrs: Vec<Attribute>, @@ -706,8 +621,6 @@ ast_struct! { ast_struct! { /// A tuple expression: `(a, b, c, d)`. - /// - /// *This type is available only if Syn is built with the `"full"` feature.* #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub struct ExprTuple #full { pub attrs: Vec<Attribute>, @@ -717,23 +630,7 @@ ast_struct! { } ast_struct! { - /// A type ascription expression: `foo: f64`. - /// - /// *This type is available only if Syn is built with the `"full"` feature.* - #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] - pub struct ExprType #full { - pub attrs: Vec<Attribute>, - pub expr: Box<Expr>, - pub colon_token: Token![:], - pub ty: Box<Type>, - } -} - -ast_struct! { /// A unary operation: `!x`, `*x`. - /// - /// *This type is available only if Syn is built with the `"derive"` or - /// `"full"` feature.* #[cfg_attr(doc_cfg, doc(cfg(any(feature = "full", feature = "derive"))))] pub struct ExprUnary { pub attrs: Vec<Attribute>, @@ -744,8 +641,6 @@ ast_struct! { ast_struct! { /// An unsafe block: `unsafe { ... }`. - /// - /// *This type is available only if Syn is built with the `"full"` feature.* #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub struct ExprUnsafe #full { pub attrs: Vec<Attribute>, @@ -756,8 +651,6 @@ ast_struct! { ast_struct! { /// A while loop: `while expr { ... }`. - /// - /// *This type is available only if Syn is built with the `"full"` feature.* #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub struct ExprWhile #full { pub attrs: Vec<Attribute>, @@ -770,8 +663,6 @@ ast_struct! { ast_struct! { /// A yield expression: `yield expr`. - /// - /// *This type is available only if Syn is built with the `"full"` feature.* #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub struct ExprYield #full { pub attrs: Vec<Attribute>, @@ -781,7 +672,7 @@ ast_struct! { } impl Expr { - #[cfg(all(feature = "parsing", not(syn_no_const_vec_new)))] + #[cfg(feature = "parsing")] const DUMMY: Self = Expr::Path(ExprPath { attrs: Vec::new(), qself: None, @@ -794,49 +685,45 @@ impl Expr { #[cfg(all(feature = "parsing", feature = "full"))] pub(crate) fn replace_attrs(&mut self, new: Vec<Attribute>) -> Vec<Attribute> { match self { - Expr::Box(ExprBox { attrs, .. }) - | Expr::Array(ExprArray { attrs, .. }) - | Expr::Call(ExprCall { attrs, .. }) - | Expr::MethodCall(ExprMethodCall { attrs, .. }) - | Expr::Tuple(ExprTuple { attrs, .. }) + Expr::Array(ExprArray { attrs, .. }) + | Expr::Assign(ExprAssign { attrs, .. }) + | Expr::Async(ExprAsync { attrs, .. }) + | Expr::Await(ExprAwait { attrs, .. }) | Expr::Binary(ExprBinary { attrs, .. }) - | Expr::Unary(ExprUnary { attrs, .. }) - | Expr::Lit(ExprLit { attrs, .. }) + | Expr::Block(ExprBlock { attrs, .. }) + | Expr::Break(ExprBreak { attrs, .. }) + | Expr::Call(ExprCall { attrs, .. }) | Expr::Cast(ExprCast { attrs, .. }) - | Expr::Type(ExprType { attrs, .. }) - | Expr::Let(ExprLet { attrs, .. }) - | Expr::If(ExprIf { attrs, .. }) - | Expr::While(ExprWhile { attrs, .. }) - | Expr::ForLoop(ExprForLoop { attrs, .. }) - | Expr::Loop(ExprLoop { attrs, .. }) - | Expr::Match(ExprMatch { attrs, .. }) | Expr::Closure(ExprClosure { attrs, .. }) - | Expr::Unsafe(ExprUnsafe { attrs, .. }) - | Expr::Block(ExprBlock { attrs, .. }) - | Expr::Assign(ExprAssign { attrs, .. }) - | Expr::AssignOp(ExprAssignOp { attrs, .. }) + | Expr::Const(ExprConst { attrs, .. }) + | Expr::Continue(ExprContinue { attrs, .. }) | Expr::Field(ExprField { attrs, .. }) + | Expr::ForLoop(ExprForLoop { attrs, .. }) + | Expr::Group(ExprGroup { attrs, .. }) + | Expr::If(ExprIf { attrs, .. }) | Expr::Index(ExprIndex { attrs, .. }) - | Expr::Range(ExprRange { attrs, .. }) + | Expr::Infer(ExprInfer { attrs, .. }) + | Expr::Let(ExprLet { attrs, .. }) + | Expr::Lit(ExprLit { attrs, .. }) + | Expr::Loop(ExprLoop { attrs, .. }) + | Expr::Macro(ExprMacro { attrs, .. }) + | Expr::Match(ExprMatch { attrs, .. }) + | Expr::MethodCall(ExprMethodCall { attrs, .. }) + | Expr::Paren(ExprParen { attrs, .. }) | Expr::Path(ExprPath { attrs, .. }) + | Expr::Range(ExprRange { attrs, .. }) | Expr::Reference(ExprReference { attrs, .. }) - | Expr::Break(ExprBreak { attrs, .. }) - | Expr::Continue(ExprContinue { attrs, .. }) + | Expr::Repeat(ExprRepeat { attrs, .. }) | Expr::Return(ExprReturn { attrs, .. }) - | Expr::Macro(ExprMacro { attrs, .. }) | Expr::Struct(ExprStruct { attrs, .. }) - | Expr::Repeat(ExprRepeat { attrs, .. }) - | Expr::Paren(ExprParen { attrs, .. }) - | Expr::Group(ExprGroup { attrs, .. }) | Expr::Try(ExprTry { attrs, .. }) - | Expr::Async(ExprAsync { attrs, .. }) - | Expr::Await(ExprAwait { attrs, .. }) | Expr::TryBlock(ExprTryBlock { attrs, .. }) + | Expr::Tuple(ExprTuple { attrs, .. }) + | Expr::Unary(ExprUnary { attrs, .. }) + | Expr::Unsafe(ExprUnsafe { attrs, .. }) + | Expr::While(ExprWhile { attrs, .. }) | Expr::Yield(ExprYield { attrs, .. }) => mem::replace(attrs, new), Expr::Verbatim(_) => Vec::new(), - - #[cfg(syn_no_non_exhaustive)] - _ => unreachable!(), } } } @@ -844,9 +731,6 @@ impl Expr { ast_enum! { /// A struct or tuple struct field accessed in a struct literal or field /// expression. - /// - /// *This type is available only if Syn is built with the `"derive"` or `"full"` - /// feature.* #[cfg_attr(doc_cfg, doc(cfg(any(feature = "full", feature = "derive"))))] pub enum Member { /// A named field like `self.x`. @@ -914,9 +798,6 @@ impl IdentFragment for Member { ast_struct! { /// The index of an unnamed tuple struct field. - /// - /// *This type is available only if Syn is built with the `"derive"` or `"full"` - /// feature.* #[cfg_attr(doc_cfg, doc(cfg(any(feature = "full", feature = "derive"))))] pub struct Index { pub index: u32, @@ -961,54 +842,16 @@ impl IdentFragment for Index { #[cfg(feature = "full")] ast_struct! { - /// The `::<>` explicit type parameters passed to a method call: - /// `parse::<u64>()`. - /// - /// *This type is available only if Syn is built with the `"full"` feature.* - #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] - pub struct MethodTurbofish { - pub colon2_token: Token![::], - pub lt_token: Token![<], - pub args: Punctuated<GenericMethodArgument, Token![,]>, - pub gt_token: Token![>], - } -} - -#[cfg(feature = "full")] -ast_enum! { - /// An individual generic argument to a method, like `T`. - /// - /// *This type is available only if Syn is built with the `"full"` feature.* - #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] - pub enum GenericMethodArgument { - /// A type argument. - Type(Type), - /// A const expression. Must be inside of a block. - /// - /// NOTE: Identity expressions are represented as Type arguments, as - /// they are indistinguishable syntactically. - Const(Expr), - } -} - -#[cfg(feature = "full")] -ast_struct! { /// A field-value pair in a struct literal. - /// - /// *This type is available only if Syn is built with the `"full"` feature.* #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub struct FieldValue { - /// Attributes tagged on the field. pub attrs: Vec<Attribute>, - - /// Name or index of the field. pub member: Member, /// The colon in `Struct { x: x }`. If written in shorthand like /// `Struct { x }`, there is no colon. pub colon_token: Option<Token![:]>, - /// Value of the field. pub expr: Expr, } } @@ -1016,8 +859,6 @@ ast_struct! { #[cfg(feature = "full")] ast_struct! { /// A lifetime labeling a `for`, `while`, or `loop`. - /// - /// *This type is available only if Syn is built with the `"full"` feature.* #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub struct Label { pub name: Lifetime, @@ -1027,7 +868,7 @@ ast_struct! { #[cfg(feature = "full")] ast_struct! { - /// One arm of a `match` expression: `0...10 => { return true; }`. + /// One arm of a `match` expression: `0..=10 => { return true; }`. /// /// As in: /// @@ -1035,7 +876,7 @@ ast_struct! { /// # fn f() -> bool { /// # let n = 0; /// match n { - /// 0...10 => { + /// 0..=10 => { /// return true; /// } /// // ... @@ -1044,8 +885,6 @@ ast_struct! { /// # false /// # } /// ``` - /// - /// *This type is available only if Syn is built with the `"full"` feature.* #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub struct Arm { pub attrs: Vec<Attribute>, @@ -1060,8 +899,6 @@ ast_struct! { #[cfg(feature = "full")] ast_enum! { /// Limit types of a range, inclusive or exclusive. - /// - /// *This type is available only if Syn is built with the `"full"` feature.* #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub enum RangeLimits { /// Inclusive at the beginning, exclusive at the end. @@ -1074,30 +911,57 @@ ast_enum! { #[cfg(any(feature = "parsing", feature = "printing"))] #[cfg(feature = "full")] pub(crate) fn requires_terminator(expr: &Expr) -> bool { - // see https://github.com/rust-lang/rust/blob/2679c38fc/src/librustc_ast/util/classify.rs#L7-L25 - match *expr { - Expr::Unsafe(..) - | Expr::Block(..) - | Expr::If(..) - | Expr::Match(..) - | Expr::While(..) - | Expr::Loop(..) - | Expr::ForLoop(..) - | Expr::Async(..) - | Expr::TryBlock(..) => false, - _ => true, + // see https://github.com/rust-lang/rust/blob/9a19e7604/compiler/rustc_ast/src/util/classify.rs#L7-L26 + match expr { + Expr::If(_) + | Expr::Match(_) + | Expr::Block(_) | Expr::Unsafe(_) // both under ExprKind::Block in rustc + | Expr::While(_) + | Expr::Loop(_) + | Expr::ForLoop(_) + | Expr::TryBlock(_) + | Expr::Const(_) => false, + Expr::Array(_) + | Expr::Assign(_) + | Expr::Async(_) + | Expr::Await(_) + | Expr::Binary(_) + | Expr::Break(_) + | Expr::Call(_) + | Expr::Cast(_) + | Expr::Closure(_) + | Expr::Continue(_) + | Expr::Field(_) + | Expr::Group(_) + | Expr::Index(_) + | Expr::Infer(_) + | Expr::Let(_) + | Expr::Lit(_) + | Expr::Macro(_) + | Expr::MethodCall(_) + | Expr::Paren(_) + | Expr::Path(_) + | Expr::Range(_) + | Expr::Reference(_) + | Expr::Repeat(_) + | Expr::Return(_) + | Expr::Struct(_) + | Expr::Try(_) + | Expr::Tuple(_) + | Expr::Unary(_) + | Expr::Yield(_) + | Expr::Verbatim(_) => true } } #[cfg(feature = "parsing")] pub(crate) mod parsing { use super::*; + use crate::parse::discouraged::Speculative; #[cfg(feature = "full")] use crate::parse::ParseBuffer; use crate::parse::{Parse, ParseStream, Result}; use crate::path; - #[cfg(feature = "full")] - use proc_macro2::TokenTree; use std::cmp::Ordering; crate::custom_keyword!(raw); @@ -1107,7 +971,8 @@ pub(crate) mod parsing { // // Struct literals are ambiguous in certain positions // https://github.com/rust-lang/rfcs/pull/92 - pub struct AllowStruct(bool); + #[cfg(feature = "full")] + pub(crate) struct AllowStruct(bool); enum Precedence { Any, @@ -1127,7 +992,7 @@ pub(crate) mod parsing { impl Precedence { fn of(op: &BinOp) -> Self { - match *op { + match op { BinOp::Add(_) | BinOp::Sub(_) => Precedence::Arithmetic, BinOp::Mul(_) | BinOp::Div(_) | BinOp::Rem(_) => Precedence::Term, BinOp::And(_) => Precedence::And, @@ -1142,16 +1007,16 @@ pub(crate) mod parsing { | BinOp::Ne(_) | BinOp::Ge(_) | BinOp::Gt(_) => Precedence::Compare, - BinOp::AddEq(_) - | BinOp::SubEq(_) - | BinOp::MulEq(_) - | BinOp::DivEq(_) - | BinOp::RemEq(_) - | BinOp::BitXorEq(_) - | BinOp::BitAndEq(_) - | BinOp::BitOrEq(_) - | BinOp::ShlEq(_) - | BinOp::ShrEq(_) => Precedence::Assign, + BinOp::AddAssign(_) + | BinOp::SubAssign(_) + | BinOp::MulAssign(_) + | BinOp::DivAssign(_) + | BinOp::RemAssign(_) + | BinOp::BitXorAssign(_) + | BinOp::BitAndAssign(_) + | BinOp::BitOrAssign(_) + | BinOp::ShlAssign(_) + | BinOp::ShrAssign(_) => Precedence::Assign, } } } @@ -1159,7 +1024,11 @@ pub(crate) mod parsing { #[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))] impl Parse for Expr { fn parse(input: ParseStream) -> Result<Self> { - ambiguous_expr(input, AllowStruct(true)) + ambiguous_expr( + input, + #[cfg(feature = "full")] + AllowStruct(true), + ) } } @@ -1251,8 +1120,10 @@ pub(crate) mod parsing { } } + #[cfg(feature = "full")] impl Copy for AllowStruct {} + #[cfg(feature = "full")] impl Clone for AllowStruct { fn clone(&self) -> Self { *self @@ -1289,13 +1160,12 @@ pub(crate) mod parsing { base: Precedence, ) -> Result<Expr> { loop { - if input - .fork() - .parse::<BinOp>() - .ok() - .map_or(false, |op| Precedence::of(&op) >= base) - { - let op: BinOp = input.parse()?; + let ahead = input.fork(); + if let Some(op) = match ahead.parse::<BinOp>() { + Ok(op) if Precedence::of(&op) >= base => Some(op), + _ => None, + } { + input.advance_to(&ahead); let precedence = Precedence::of(&op); let mut rhs = unary_expr(input, allow_struct)?; loop { @@ -1306,21 +1176,12 @@ pub(crate) mod parsing { break; } } - lhs = if precedence == Precedence::Assign { - Expr::AssignOp(ExprAssignOp { - attrs: Vec::new(), - left: Box::new(lhs), - op, - right: Box::new(rhs), - }) - } else { - Expr::Binary(ExprBinary { - attrs: Vec::new(), - left: Box::new(lhs), - op, - right: Box::new(rhs), - }) - }; + lhs = Expr::Binary(ExprBinary { + attrs: Vec::new(), + left: Box::new(lhs), + op, + right: Box::new(rhs), + }); } else if Precedence::Assign >= base && input.peek(Token![=]) && !input.peek(Token![==]) @@ -1344,11 +1205,12 @@ pub(crate) mod parsing { }); } else if Precedence::Range >= base && input.peek(Token![..]) { let limits: RangeLimits = input.parse()?; - let rhs = if input.is_empty() - || input.peek(Token![,]) - || input.peek(Token![;]) - || input.peek(Token![.]) && !input.peek(Token![..]) - || !allow_struct.0 && input.peek(token::Brace) + let rhs = if matches!(limits, RangeLimits::HalfOpen(_)) + && (input.is_empty() + || input.peek(Token![,]) + || input.peek(Token![;]) + || input.peek(Token![.]) && !input.peek(Token![..]) + || !allow_struct.0 && input.peek(token::Brace)) { None } else { @@ -1365,9 +1227,9 @@ pub(crate) mod parsing { }; lhs = Expr::Range(ExprRange { attrs: Vec::new(), - from: Some(Box::new(lhs)), + start: Some(Box::new(lhs)), limits, - to: rhs.map(Box::new), + end: rhs.map(Box::new), }); } else if Precedence::Cast >= base && input.peek(Token![as]) { let as_token: Token![as] = input.parse()?; @@ -1381,18 +1243,6 @@ pub(crate) mod parsing { as_token, ty: Box::new(ty), }); - } else if Precedence::Cast >= base && input.peek(Token![:]) && !input.peek(Token![::]) { - let colon_token: Token![:] = input.parse()?; - let allow_plus = false; - let allow_group_generic = false; - let ty = ty::parsing::ambig_ty(input, allow_plus, allow_group_generic)?; - check_cast(input)?; - lhs = Expr::Type(ExprType { - attrs: Vec::new(), - expr: Box::new(lhs), - colon_token, - ty: Box::new(ty), - }); } else { break; } @@ -1401,26 +1251,20 @@ pub(crate) mod parsing { } #[cfg(not(feature = "full"))] - fn parse_expr( - input: ParseStream, - mut lhs: Expr, - allow_struct: AllowStruct, - base: Precedence, - ) -> Result<Expr> { + fn parse_expr(input: ParseStream, mut lhs: Expr, base: Precedence) -> Result<Expr> { loop { - if input - .fork() - .parse::<BinOp>() - .ok() - .map_or(false, |op| Precedence::of(&op) >= base) - { - let op: BinOp = input.parse()?; + let ahead = input.fork(); + if let Some(op) = match ahead.parse::<BinOp>() { + Ok(op) if Precedence::of(&op) >= base => Some(op), + _ => None, + } { + input.advance_to(&ahead); let precedence = Precedence::of(&op); - let mut rhs = unary_expr(input, allow_struct)?; + let mut rhs = unary_expr(input)?; loop { let next = peek_precedence(input); if next > precedence || next == precedence && precedence == Precedence::Assign { - rhs = parse_expr(input, rhs, allow_struct, next)?; + rhs = parse_expr(input, rhs, next)?; } else { break; } @@ -1467,9 +1311,22 @@ pub(crate) mod parsing { } // Parse an arbitrary expression. - fn ambiguous_expr(input: ParseStream, allow_struct: AllowStruct) -> Result<Expr> { - let lhs = unary_expr(input, allow_struct)?; - parse_expr(input, lhs, allow_struct, Precedence::Any) + fn ambiguous_expr( + input: ParseStream, + #[cfg(feature = "full")] allow_struct: AllowStruct, + ) -> Result<Expr> { + let lhs = unary_expr( + input, + #[cfg(feature = "full")] + allow_struct, + )?; + parse_expr( + input, + lhs, + #[cfg(feature = "full")] + allow_struct, + Precedence::Any, + ) } #[cfg(feature = "full")] @@ -1523,13 +1380,10 @@ pub(crate) mod parsing { Ok(Expr::Reference(ExprReference { attrs, and_token, - raw: Reserved::default(), mutability, expr, })) } - } else if input.peek(Token![box]) { - expr_box(input, attrs, allow_struct).map(Expr::Box) } else if input.peek(Token![*]) || input.peek(Token![!]) || input.peek(Token![-]) { expr_unary(input, attrs, allow_struct).map(Expr::Unary) } else { @@ -1538,15 +1392,15 @@ pub(crate) mod parsing { } #[cfg(not(feature = "full"))] - fn unary_expr(input: ParseStream, allow_struct: AllowStruct) -> Result<Expr> { + fn unary_expr(input: ParseStream) -> Result<Expr> { if input.peek(Token![*]) || input.peek(Token![!]) || input.peek(Token![-]) { Ok(Expr::Unary(ExprUnary { attrs: Vec::new(), op: input.parse()?, - expr: Box::new(unary_expr(input, allow_struct)?), + expr: Box::new(unary_expr(input)?), })) } else { - trailer_expr(input, allow_struct) + trailer_expr(input) } } @@ -1586,7 +1440,7 @@ pub(crate) mod parsing { attrs: Vec::new(), func: Box::new(e), paren_token: parenthesized!(content in input), - args: content.parse_terminated(Expr::parse)?, + args: content.parse_terminated(Expr::parse, Token![,])?, }); } else if input.peek(Token![.]) && !input.peek(Token![..]) @@ -1597,7 +1451,14 @@ pub(crate) mod parsing { { let mut dot_token: Token![.] = input.parse()?; - let await_token: Option<token::Await> = input.parse()?; + let float_token: Option<LitFloat> = input.parse()?; + if let Some(float_token) = float_token { + if multi_index(&mut e, &mut dot_token, float_token)? { + continue; + } + } + + let await_token: Option<Token![await]> = input.parse()?; if let Some(await_token) = await_token { e = Expr::Await(ExprAwait { attrs: Vec::new(), @@ -1608,16 +1469,9 @@ pub(crate) mod parsing { continue; } - let float_token: Option<LitFloat> = input.parse()?; - if let Some(float_token) = float_token { - if multi_index(&mut e, &mut dot_token, float_token)? { - continue; - } - } - let member: Member = input.parse()?; let turbofish = if member.is_named() && input.peek(Token![::]) { - Some(input.parse::<MethodTurbofish>()?) + Some(AngleBracketedGenericArguments::parse_turbofish(input)?) } else { None }; @@ -1632,7 +1486,7 @@ pub(crate) mod parsing { method, turbofish, paren_token: parenthesized!(content in input), - args: content.parse_terminated(Expr::parse)?, + args: content.parse_terminated(Expr::parse, Token![,])?, }); continue; } @@ -1666,8 +1520,8 @@ pub(crate) mod parsing { } #[cfg(not(feature = "full"))] - fn trailer_expr(input: ParseStream, allow_struct: AllowStruct) -> Result<Expr> { - let mut e = atom_expr(input, allow_struct)?; + fn trailer_expr(input: ParseStream) -> Result<Expr> { + let mut e = atom_expr(input)?; loop { if input.peek(token::Paren) { @@ -1676,9 +1530,11 @@ pub(crate) mod parsing { attrs: Vec::new(), func: Box::new(e), paren_token: parenthesized!(content in input), - args: content.parse_terminated(Expr::parse)?, + args: content.parse_terminated(Expr::parse, Token![,])?, }); - } else if input.peek(Token![.]) && !input.peek(Token![..]) && !input.peek2(token::Await) + } else if input.peek(Token![.]) + && !input.peek(Token![..]) + && !input.peek2(Token![await]) { let mut dot_token: Token![.] = input.parse()?; let float_token: Option<LitFloat> = input.parse()?; @@ -1728,20 +1584,15 @@ pub(crate) mod parsing { } else if input.peek(Token![try]) && input.peek2(token::Brace) { input.parse().map(Expr::TryBlock) } else if input.peek(Token![|]) - || input.peek(Token![async]) && (input.peek2(Token![|]) || input.peek2(Token![move])) - || input.peek(Token![static]) || input.peek(Token![move]) + || input.peek(Token![for]) + && input.peek2(Token![<]) + && (input.peek3(Lifetime) || input.peek3(Token![>])) + || input.peek(Token![const]) && !input.peek2(token::Brace) + || input.peek(Token![static]) + || input.peek(Token![async]) && (input.peek2(Token![|]) || input.peek2(Token![move])) { expr_closure(input, allow_struct).map(Expr::Closure) - } else if input.peek(Token![for]) - && input.peek2(Token![<]) - && (input.peek3(Lifetime) || input.peek3(Token![>])) - { - let begin = input.fork(); - input.parse::<BoundLifetimes>()?; - expr_closure(input, allow_struct)?; - let verbatim = verbatim::between(begin, input); - Ok(Expr::Verbatim(verbatim)) } else if input.peek(Ident) || input.peek(Token![::]) || input.peek(Token![<]) @@ -1749,6 +1600,7 @@ pub(crate) mod parsing { || input.peek(Token![Self]) || input.peek(Token![super]) || input.peek(Token![crate]) + || input.peek(Token![try]) && (input.peek2(Token![!]) || input.peek2(Token![::])) { path_or_macro_or_struct(input, allow_struct) } else if input.peek(token::Paren) { @@ -1778,15 +1630,13 @@ pub(crate) mod parsing { } else if input.peek(Token![unsafe]) { input.parse().map(Expr::Unsafe) } else if input.peek(Token![const]) { - input.call(expr_const).map(Expr::Verbatim) + input.parse().map(Expr::Const) } else if input.peek(token::Brace) { input.parse().map(Expr::Block) } else if input.peek(Token![..]) { expr_range(input, allow_struct).map(Expr::Range) } else if input.peek(Token![_]) { - Ok(Expr::Verbatim(TokenStream::from( - input.parse::<TokenTree>()?, - ))) + input.parse().map(Expr::Infer) } else if input.peek(Lifetime) { let the_label: Label = input.parse()?; let mut expr = if input.peek(Token![while]) { @@ -1814,8 +1664,14 @@ pub(crate) mod parsing { } #[cfg(not(feature = "full"))] - fn atom_expr(input: ParseStream, _allow_struct: AllowStruct) -> Result<Expr> { - if input.peek(Lit) { + fn atom_expr(input: ParseStream) -> Result<Expr> { + if input.peek(token::Group) + && !input.peek2(Token![::]) + && !input.peek2(Token![!]) + && !input.peek2(token::Brace) + { + input.call(expr_group).map(Expr::Group) + } else if input.peek(Lit) { input.parse().map(Expr::Lit) } else if input.peek(token::Paren) { input.call(expr_paren).map(Expr::Paren) @@ -1827,56 +1683,50 @@ pub(crate) mod parsing { || input.peek(Token![super]) || input.peek(Token![crate]) { - input.parse().map(Expr::Path) + path_or_macro_or_struct(input) + } else if input.is_empty() { + Err(input.error("expected an expression")) } else { Err(input.error("unsupported expression; enable syn's features=[\"full\"]")) } } - #[cfg(feature = "full")] - fn path_or_macro_or_struct(input: ParseStream, allow_struct: AllowStruct) -> Result<Expr> { - let begin = input.fork(); - let expr: ExprPath = input.parse()?; - - if expr.qself.is_none() && input.peek(Token![!]) && !input.peek(Token![!=]) { - let mut contains_arguments = false; - for segment in &expr.path.segments { - match segment.arguments { - PathArguments::None => {} - PathArguments::AngleBracketed(_) | PathArguments::Parenthesized(_) => { - contains_arguments = true; - } - } - } + fn path_or_macro_or_struct( + input: ParseStream, + #[cfg(feature = "full")] allow_struct: AllowStruct, + ) -> Result<Expr> { + let (qself, path) = path::parsing::qpath(input, true)?; - if !contains_arguments { - let bang_token: Token![!] = input.parse()?; - let (delimiter, tokens) = mac::parse_delimiter(input)?; - return Ok(Expr::Macro(ExprMacro { - attrs: Vec::new(), - mac: Macro { - path: expr.path, - bang_token, - delimiter, - tokens, - }, - })); - } + if qself.is_none() + && input.peek(Token![!]) + && !input.peek(Token![!=]) + && path.is_mod_style() + { + let bang_token: Token![!] = input.parse()?; + let (delimiter, tokens) = mac::parse_delimiter(input)?; + return Ok(Expr::Macro(ExprMacro { + attrs: Vec::new(), + mac: Macro { + path, + bang_token, + delimiter, + tokens, + }, + })); } + #[cfg(feature = "full")] if allow_struct.0 && input.peek(token::Brace) { - let expr_struct = expr_struct_helper(input, expr.path)?; - if expr.qself.is_some() { - Ok(Expr::Verbatim(verbatim::between(begin, input))) - } else { - Ok(Expr::Struct(expr_struct)) - } - } else { - Ok(Expr::Path(expr)) + return expr_struct_helper(input, qself, path).map(Expr::Struct); } + + Ok(Expr::Path(ExprPath { + attrs: Vec::new(), + qself, + path, + })) } - #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))] impl Parse for ExprMacro { fn parse(input: ParseStream) -> Result<Self> { @@ -2031,8 +1881,8 @@ pub(crate) mod parsing { Expr::TryBlock(input.parse()?) } else if input.peek(Token![unsafe]) { Expr::Unsafe(input.parse()?) - } else if input.peek(Token![const]) { - Expr::Verbatim(input.call(expr_const)?) + } else if input.peek(Token![const]) && input.peek2(token::Brace) { + Expr::Const(input.parse()?) } else if input.peek(token::Brace) { Expr::Block(input.parse()?) } else { @@ -2070,7 +1920,6 @@ pub(crate) mod parsing { } } - #[cfg(feature = "full")] fn expr_group(input: ParseStream) -> Result<ExprGroup> { let group = crate::group::parse_group(input)?; Ok(ExprGroup { @@ -2099,58 +1948,12 @@ pub(crate) mod parsing { #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))] - impl Parse for GenericMethodArgument { - fn parse(input: ParseStream) -> Result<Self> { - if input.peek(Lit) { - let lit = input.parse()?; - return Ok(GenericMethodArgument::Const(Expr::Lit(lit))); - } - - if input.peek(token::Brace) { - let block: ExprBlock = input.parse()?; - return Ok(GenericMethodArgument::Const(Expr::Block(block))); - } - - input.parse().map(GenericMethodArgument::Type) - } - } - - #[cfg(feature = "full")] - #[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))] - impl Parse for MethodTurbofish { - fn parse(input: ParseStream) -> Result<Self> { - Ok(MethodTurbofish { - colon2_token: input.parse()?, - lt_token: input.parse()?, - args: { - let mut args = Punctuated::new(); - loop { - if input.peek(Token![>]) { - break; - } - let value: GenericMethodArgument = input.parse()?; - args.push_value(value); - if input.peek(Token![>]) { - break; - } - let punct = input.parse()?; - args.push_punct(punct); - } - args - }, - gt_token: input.parse()?, - }) - } - } - - #[cfg(feature = "full")] - #[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))] impl Parse for ExprLet { fn parse(input: ParseStream) -> Result<Self> { Ok(ExprLet { attrs: Vec::new(), let_token: input.parse()?, - pat: pat::parsing::multi_pat_with_leading_vert(input)?, + pat: Box::new(Pat::parse_multi_with_leading_vert(input)?), eq_token: input.parse()?, expr: Box::new({ let allow_struct = AllowStruct(false); @@ -2204,13 +2007,24 @@ pub(crate) mod parsing { #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))] + impl Parse for ExprInfer { + fn parse(input: ParseStream) -> Result<Self> { + Ok(ExprInfer { + attrs: input.call(Attribute::parse_outer)?, + underscore_token: input.parse()?, + }) + } + } + + #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))] impl Parse for ExprForLoop { fn parse(input: ParseStream) -> Result<Self> { let mut attrs = input.call(Attribute::parse_outer)?; let label: Option<Label> = input.parse()?; let for_token: Token![for] = input.parse()?; - let pat = pat::parsing::multi_pat_with_leading_vert(input)?; + let pat = Pat::parse_multi_with_leading_vert(input)?; let in_token: Token![in] = input.parse()?; let expr: Expr = input.call(Expr::parse_without_eager_brace)?; @@ -2224,7 +2038,7 @@ pub(crate) mod parsing { attrs, label, for_token, - pat, + pat: Box::new(pat), in_token, expr: Box::new(expr), body: Block { brace_token, stmts }, @@ -2308,7 +2122,6 @@ pub(crate) mod parsing { impl_by_parsing_expr! { ExprAssign, Assign, "expected assignment expression", - ExprAssignOp, AssignOp, "expected compound assignment expression", ExprAwait, Await, "expected await expression", ExprBinary, Binary, "expected binary operation", ExprCall, Call, "expected function call expression", @@ -2319,30 +2132,6 @@ pub(crate) mod parsing { ExprRange, Range, "expected range expression", ExprTry, Try, "expected try expression", ExprTuple, Tuple, "expected tuple expression", - ExprType, Type, "expected type ascription expression", - } - - #[cfg(feature = "full")] - #[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))] - impl Parse for ExprBox { - fn parse(input: ParseStream) -> Result<Self> { - let attrs = Vec::new(); - let allow_struct = AllowStruct(true); - expr_box(input, attrs, allow_struct) - } - } - - #[cfg(feature = "full")] - fn expr_box( - input: ParseStream, - attrs: Vec<Attribute>, - allow_struct: AllowStruct, - ) -> Result<ExprBox> { - Ok(ExprBox { - attrs, - box_token: input.parse()?, - expr: Box::new(unary_expr(input, allow_struct)?), - }) } #[cfg(feature = "full")] @@ -2385,7 +2174,6 @@ pub(crate) mod parsing { Ok(ExprReference { attrs: Vec::new(), and_token: input.parse()?, - raw: Reserved::default(), mutability: input.parse()?, expr: Box::new(unary_expr(input, allow_struct)?), }) @@ -2442,6 +2230,8 @@ pub(crate) mod parsing { #[cfg(feature = "full")] fn expr_closure(input: ParseStream, allow_struct: AllowStruct) -> Result<ExprClosure> { + let lifetimes: Option<BoundLifetimes> = input.parse()?; + let constness: Option<Token![const]> = input.parse()?; let movability: Option<Token![static]> = input.parse()?; let asyncness: Option<Token![async]> = input.parse()?; let capture: Option<Token![move]> = input.parse()?; @@ -2481,6 +2271,8 @@ pub(crate) mod parsing { Ok(ExprClosure { attrs: Vec::new(), + lifetimes, + constness, movability, asyncness, capture, @@ -2508,7 +2300,7 @@ pub(crate) mod parsing { #[cfg(feature = "full")] fn closure_arg(input: ParseStream) -> Result<Pat> { let attrs = input.call(Attribute::parse_outer)?; - let mut pat: Pat = input.parse()?; + let mut pat = Pat::parse_single(input)?; if input.peek(Token![:]) { Ok(Pat::Type(PatType { @@ -2519,11 +2311,12 @@ pub(crate) mod parsing { })) } else { match &mut pat { - Pat::Box(pat) => pat.attrs = attrs, + Pat::Const(pat) => pat.attrs = attrs, Pat::Ident(pat) => pat.attrs = attrs, Pat::Lit(pat) => pat.attrs = attrs, Pat::Macro(pat) => pat.attrs = attrs, Pat::Or(pat) => pat.attrs = attrs, + Pat::Paren(pat) => pat.attrs = attrs, Pat::Path(pat) => pat.attrs = attrs, Pat::Range(pat) => pat.attrs = attrs, Pat::Reference(pat) => pat.attrs = attrs, @@ -2535,9 +2328,6 @@ pub(crate) mod parsing { Pat::Type(_) => unreachable!(), Pat::Verbatim(_) => {} Pat::Wild(pat) => pat.attrs = attrs, - - #[cfg(syn_no_non_exhaustive)] - _ => unreachable!(), } Ok(pat) } @@ -2569,6 +2359,25 @@ pub(crate) mod parsing { #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))] + impl Parse for ExprConst { + fn parse(input: ParseStream) -> Result<Self> { + let const_token: Token![const] = input.parse()?; + + let content; + let brace_token = braced!(content in input); + let inner_attrs = content.call(Attribute::parse_inner)?; + let stmts = content.call(Block::parse_within)?; + + Ok(ExprConst { + attrs: inner_attrs, + const_token, + block: Block { brace_token, stmts }, + }) + } + } + + #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))] impl Parse for Label { fn parse(input: ParseStream) -> Result<Self> { Ok(Label { @@ -2678,13 +2487,17 @@ pub(crate) mod parsing { #[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))] impl Parse for ExprStruct { fn parse(input: ParseStream) -> Result<Self> { - let path: Path = input.parse()?; - expr_struct_helper(input, path) + let (qself, path) = path::parsing::qpath(input, true)?; + expr_struct_helper(input, qself, path) } } #[cfg(feature = "full")] - fn expr_struct_helper(input: ParseStream, path: Path) -> Result<ExprStruct> { + fn expr_struct_helper( + input: ParseStream, + qself: Option<QSelf>, + path: Path, + ) -> Result<ExprStruct> { let content; let brace_token = braced!(content in input); @@ -2693,8 +2506,9 @@ pub(crate) mod parsing { if content.peek(Token![..]) { return Ok(ExprStruct { attrs: Vec::new(), - brace_token, + qself, path, + brace_token, fields, dot2_token: Some(content.parse()?), rest: if content.is_empty() { @@ -2715,8 +2529,9 @@ pub(crate) mod parsing { Ok(ExprStruct { attrs: Vec::new(), - brace_token, + qself, path, + brace_token, fields, dot2_token: None, rest: None, @@ -2743,19 +2558,6 @@ pub(crate) mod parsing { } #[cfg(feature = "full")] - pub(crate) fn expr_const(input: ParseStream) -> Result<TokenStream> { - let begin = input.fork(); - input.parse::<Token![const]>()?; - - let content; - braced!(content in input); - content.call(Attribute::parse_inner)?; - content.call(Block::parse_within)?; - - Ok(verbatim::between(begin, input)) - } - - #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))] impl Parse for ExprBlock { fn parse(input: ParseStream) -> Result<Self> { @@ -2777,23 +2579,24 @@ pub(crate) mod parsing { #[cfg(feature = "full")] fn expr_range(input: ParseStream, allow_struct: AllowStruct) -> Result<ExprRange> { + let limits: RangeLimits = input.parse()?; + let end = if matches!(limits, RangeLimits::HalfOpen(_)) + && (input.is_empty() + || input.peek(Token![,]) + || input.peek(Token![;]) + || input.peek(Token![.]) && !input.peek(Token![..]) + || !allow_struct.0 && input.peek(token::Brace)) + { + None + } else { + let to = ambiguous_expr(input, allow_struct)?; + Some(Box::new(to)) + }; Ok(ExprRange { attrs: Vec::new(), - from: None, - limits: input.parse()?, - to: { - if input.is_empty() - || input.peek(Token![,]) - || input.peek(Token![;]) - || input.peek(Token![.]) && !input.peek(Token![..]) - || !allow_struct.0 && input.peek(token::Brace) - { - None - } else { - let to = ambiguous_expr(input, allow_struct)?; - Some(Box::new(to)) - } - }, + start: None, + limits, + end, }) } @@ -2802,12 +2605,32 @@ pub(crate) mod parsing { impl Parse for RangeLimits { fn parse(input: ParseStream) -> Result<Self> { let lookahead = input.lookahead1(); - if lookahead.peek(Token![..=]) { + let dot_dot = lookahead.peek(Token![..]); + let dot_dot_eq = dot_dot && lookahead.peek(Token![..=]); + let dot_dot_dot = dot_dot && input.peek(Token![...]); + if dot_dot_eq { + input.parse().map(RangeLimits::Closed) + } else if dot_dot && !dot_dot_dot { + input.parse().map(RangeLimits::HalfOpen) + } else { + Err(lookahead.error()) + } + } + } + + #[cfg(feature = "full")] + impl RangeLimits { + pub(crate) fn parse_obsolete(input: ParseStream) -> Result<Self> { + let lookahead = input.lookahead1(); + let dot_dot = lookahead.peek(Token![..]); + let dot_dot_eq = dot_dot && lookahead.peek(Token![..=]); + let dot_dot_dot = dot_dot && input.peek(Token![...]); + if dot_dot_eq { input.parse().map(RangeLimits::Closed) - } else if lookahead.peek(Token![...]) { + } else if dot_dot_dot { let dot3: Token![...] = input.parse()?; Ok(RangeLimits::Closed(Token![..=](dot3.spans))) - } else if lookahead.peek(Token![..]) { + } else if dot_dot { input.parse().map(RangeLimits::HalfOpen) } else { Err(lookahead.error()) @@ -2849,7 +2672,7 @@ pub(crate) mod parsing { let requires_comma; Ok(Arm { attrs: input.call(Attribute::parse_outer)?, - pat: pat::parsing::multi_pat_with_leading_vert(input)?, + pat: Pat::parse_multi_with_leading_vert(input)?, guard: { if input.peek(Token![if]) { let if_token: Token![if] = input.parse()?; @@ -2902,10 +2725,7 @@ pub(crate) mod parsing { } for part in float_repr.split('.') { let index = crate::parse_str(part).map_err(|err| Error::new(float.span(), err))?; - #[cfg(not(syn_no_const_vec_new))] let base = mem::replace(e, Expr::DUMMY); - #[cfg(syn_no_const_vec_new)] - let base = mem::replace(e, Expr::Verbatim(TokenStream::new())); *e = Expr::Field(ExprField { attrs: Vec::new(), base: Box::new(base), @@ -2920,7 +2740,7 @@ pub(crate) mod parsing { #[cfg(feature = "full")] impl Member { fn is_named(&self) -> bool { - match *self { + match self { Member::Named(_) => true, Member::Unnamed(_) => false, } @@ -2929,7 +2749,7 @@ pub(crate) mod parsing { fn check_cast(input: ParseStream) -> Result<()> { let kind = if input.peek(Token![.]) && !input.peek(Token![..]) { - if input.peek2(token::Await) { + if input.peek2(Token![await]) { "`.await`" } else if input.peek2(Ident) && (input.peek3(token::Paren) || input.peek3(Token![::])) { "a method call" @@ -2986,16 +2806,6 @@ pub(crate) mod printing { #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "printing")))] - impl ToTokens for ExprBox { - fn to_tokens(&self, tokens: &mut TokenStream) { - outer_attrs_to_tokens(&self.attrs, tokens); - self.box_token.to_tokens(tokens); - self.expr.to_tokens(tokens); - } - } - - #[cfg(feature = "full")] - #[cfg_attr(doc_cfg, doc(cfg(feature = "printing")))] impl ToTokens for ExprArray { fn to_tokens(&self, tokens: &mut TokenStream) { outer_attrs_to_tokens(&self.attrs, tokens); @@ -3005,94 +2815,81 @@ pub(crate) mod printing { } } + #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "printing")))] - impl ToTokens for ExprCall { + impl ToTokens for ExprAssign { fn to_tokens(&self, tokens: &mut TokenStream) { outer_attrs_to_tokens(&self.attrs, tokens); - self.func.to_tokens(tokens); - self.paren_token.surround(tokens, |tokens| { - self.args.to_tokens(tokens); - }); + self.left.to_tokens(tokens); + self.eq_token.to_tokens(tokens); + self.right.to_tokens(tokens); } } #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "printing")))] - impl ToTokens for ExprMethodCall { + impl ToTokens for ExprAsync { fn to_tokens(&self, tokens: &mut TokenStream) { outer_attrs_to_tokens(&self.attrs, tokens); - self.receiver.to_tokens(tokens); - self.dot_token.to_tokens(tokens); - self.method.to_tokens(tokens); - self.turbofish.to_tokens(tokens); - self.paren_token.surround(tokens, |tokens| { - self.args.to_tokens(tokens); - }); + self.async_token.to_tokens(tokens); + self.capture.to_tokens(tokens); + self.block.to_tokens(tokens); } } #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "printing")))] - impl ToTokens for MethodTurbofish { + impl ToTokens for ExprAwait { fn to_tokens(&self, tokens: &mut TokenStream) { - self.colon2_token.to_tokens(tokens); - self.lt_token.to_tokens(tokens); - self.args.to_tokens(tokens); - self.gt_token.to_tokens(tokens); + outer_attrs_to_tokens(&self.attrs, tokens); + self.base.to_tokens(tokens); + self.dot_token.to_tokens(tokens); + self.await_token.to_tokens(tokens); } } - #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "printing")))] - impl ToTokens for GenericMethodArgument { + impl ToTokens for ExprBinary { fn to_tokens(&self, tokens: &mut TokenStream) { - match self { - GenericMethodArgument::Type(t) => t.to_tokens(tokens), - GenericMethodArgument::Const(c) => c.to_tokens(tokens), - } + outer_attrs_to_tokens(&self.attrs, tokens); + self.left.to_tokens(tokens); + self.op.to_tokens(tokens); + self.right.to_tokens(tokens); } } #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "printing")))] - impl ToTokens for ExprTuple { + impl ToTokens for ExprBlock { fn to_tokens(&self, tokens: &mut TokenStream) { outer_attrs_to_tokens(&self.attrs, tokens); - self.paren_token.surround(tokens, |tokens| { - self.elems.to_tokens(tokens); - // If we only have one argument, we need a trailing comma to - // distinguish ExprTuple from ExprParen. - if self.elems.len() == 1 && !self.elems.trailing_punct() { - <Token![,]>::default().to_tokens(tokens); - } + self.label.to_tokens(tokens); + self.block.brace_token.surround(tokens, |tokens| { + inner_attrs_to_tokens(&self.attrs, tokens); + tokens.append_all(&self.block.stmts); }); } } + #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "printing")))] - impl ToTokens for ExprBinary { - fn to_tokens(&self, tokens: &mut TokenStream) { - outer_attrs_to_tokens(&self.attrs, tokens); - self.left.to_tokens(tokens); - self.op.to_tokens(tokens); - self.right.to_tokens(tokens); - } - } - - #[cfg_attr(doc_cfg, doc(cfg(feature = "printing")))] - impl ToTokens for ExprUnary { + impl ToTokens for ExprBreak { fn to_tokens(&self, tokens: &mut TokenStream) { outer_attrs_to_tokens(&self.attrs, tokens); - self.op.to_tokens(tokens); + self.break_token.to_tokens(tokens); + self.label.to_tokens(tokens); self.expr.to_tokens(tokens); } } #[cfg_attr(doc_cfg, doc(cfg(feature = "printing")))] - impl ToTokens for ExprLit { + impl ToTokens for ExprCall { fn to_tokens(&self, tokens: &mut TokenStream) { outer_attrs_to_tokens(&self.attrs, tokens); - self.lit.to_tokens(tokens); + self.func.to_tokens(tokens); + self.paren_token.surround(tokens, |tokens| { + self.args.to_tokens(tokens); + }); } } @@ -3108,71 +2905,52 @@ pub(crate) mod printing { #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "printing")))] - impl ToTokens for ExprType { + impl ToTokens for ExprClosure { fn to_tokens(&self, tokens: &mut TokenStream) { outer_attrs_to_tokens(&self.attrs, tokens); - self.expr.to_tokens(tokens); - self.colon_token.to_tokens(tokens); - self.ty.to_tokens(tokens); - } - } - - #[cfg(feature = "full")] - fn maybe_wrap_else(tokens: &mut TokenStream, else_: &Option<(Token![else], Box<Expr>)>) { - if let Some((else_token, else_)) = else_ { - else_token.to_tokens(tokens); - - // If we are not one of the valid expressions to exist in an else - // clause, wrap ourselves in a block. - match **else_ { - Expr::If(_) | Expr::Block(_) => { - else_.to_tokens(tokens); - } - _ => { - token::Brace::default().surround(tokens, |tokens| { - else_.to_tokens(tokens); - }); - } - } + self.lifetimes.to_tokens(tokens); + self.constness.to_tokens(tokens); + self.movability.to_tokens(tokens); + self.asyncness.to_tokens(tokens); + self.capture.to_tokens(tokens); + self.or1_token.to_tokens(tokens); + self.inputs.to_tokens(tokens); + self.or2_token.to_tokens(tokens); + self.output.to_tokens(tokens); + self.body.to_tokens(tokens); } } #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "printing")))] - impl ToTokens for ExprLet { + impl ToTokens for ExprConst { fn to_tokens(&self, tokens: &mut TokenStream) { outer_attrs_to_tokens(&self.attrs, tokens); - self.let_token.to_tokens(tokens); - self.pat.to_tokens(tokens); - self.eq_token.to_tokens(tokens); - wrap_bare_struct(tokens, &self.expr); + self.const_token.to_tokens(tokens); + self.block.brace_token.surround(tokens, |tokens| { + inner_attrs_to_tokens(&self.attrs, tokens); + tokens.append_all(&self.block.stmts); + }); } } #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "printing")))] - impl ToTokens for ExprIf { + impl ToTokens for ExprContinue { fn to_tokens(&self, tokens: &mut TokenStream) { outer_attrs_to_tokens(&self.attrs, tokens); - self.if_token.to_tokens(tokens); - wrap_bare_struct(tokens, &self.cond); - self.then_branch.to_tokens(tokens); - maybe_wrap_else(tokens, &self.else_branch); + self.continue_token.to_tokens(tokens); + self.label.to_tokens(tokens); } } - #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "printing")))] - impl ToTokens for ExprWhile { + impl ToTokens for ExprField { fn to_tokens(&self, tokens: &mut TokenStream) { outer_attrs_to_tokens(&self.attrs, tokens); - self.label.to_tokens(tokens); - self.while_token.to_tokens(tokens); - wrap_bare_struct(tokens, &self.cond); - self.body.brace_token.surround(tokens, |tokens| { - inner_attrs_to_tokens(&self.attrs, tokens); - tokens.append_all(&self.body.stmts); - }); + self.base.to_tokens(tokens); + self.dot_token.to_tokens(tokens); + self.member.to_tokens(tokens); } } @@ -3193,328 +2971,334 @@ pub(crate) mod printing { } } - #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "printing")))] - impl ToTokens for ExprLoop { + impl ToTokens for ExprGroup { fn to_tokens(&self, tokens: &mut TokenStream) { outer_attrs_to_tokens(&self.attrs, tokens); - self.label.to_tokens(tokens); - self.loop_token.to_tokens(tokens); - self.body.brace_token.surround(tokens, |tokens| { - inner_attrs_to_tokens(&self.attrs, tokens); - tokens.append_all(&self.body.stmts); + self.group_token.surround(tokens, |tokens| { + self.expr.to_tokens(tokens); }); } } #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "printing")))] - impl ToTokens for ExprMatch { + impl ToTokens for ExprIf { fn to_tokens(&self, tokens: &mut TokenStream) { outer_attrs_to_tokens(&self.attrs, tokens); - self.match_token.to_tokens(tokens); - wrap_bare_struct(tokens, &self.expr); - self.brace_token.surround(tokens, |tokens| { - inner_attrs_to_tokens(&self.attrs, tokens); - for (i, arm) in self.arms.iter().enumerate() { - arm.to_tokens(tokens); - // Ensure that we have a comma after a non-block arm, except - // for the last one. - let is_last = i == self.arms.len() - 1; - if !is_last && requires_terminator(&arm.body) && arm.comma.is_none() { - <Token![,]>::default().to_tokens(tokens); - } + self.if_token.to_tokens(tokens); + wrap_bare_struct(tokens, &self.cond); + self.then_branch.to_tokens(tokens); + if let Some((else_token, else_)) = &self.else_branch { + else_token.to_tokens(tokens); + // If we are not one of the valid expressions to exist in an else + // clause, wrap ourselves in a block. + match **else_ { + Expr::If(_) | Expr::Block(_) => else_.to_tokens(tokens), + _ => token::Brace::default().surround(tokens, |tokens| else_.to_tokens(tokens)), } - }); + } } } - #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "printing")))] - impl ToTokens for ExprAsync { + impl ToTokens for ExprIndex { fn to_tokens(&self, tokens: &mut TokenStream) { outer_attrs_to_tokens(&self.attrs, tokens); - self.async_token.to_tokens(tokens); - self.capture.to_tokens(tokens); - self.block.to_tokens(tokens); + self.expr.to_tokens(tokens); + self.bracket_token.surround(tokens, |tokens| { + self.index.to_tokens(tokens); + }); } } #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "printing")))] - impl ToTokens for ExprAwait { + impl ToTokens for ExprInfer { fn to_tokens(&self, tokens: &mut TokenStream) { outer_attrs_to_tokens(&self.attrs, tokens); - self.base.to_tokens(tokens); - self.dot_token.to_tokens(tokens); - self.await_token.to_tokens(tokens); + self.underscore_token.to_tokens(tokens); } } #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "printing")))] - impl ToTokens for ExprTryBlock { + impl ToTokens for ExprLet { fn to_tokens(&self, tokens: &mut TokenStream) { outer_attrs_to_tokens(&self.attrs, tokens); - self.try_token.to_tokens(tokens); - self.block.to_tokens(tokens); + self.let_token.to_tokens(tokens); + self.pat.to_tokens(tokens); + self.eq_token.to_tokens(tokens); + wrap_bare_struct(tokens, &self.expr); } } - #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "printing")))] - impl ToTokens for ExprYield { + impl ToTokens for ExprLit { fn to_tokens(&self, tokens: &mut TokenStream) { outer_attrs_to_tokens(&self.attrs, tokens); - self.yield_token.to_tokens(tokens); - self.expr.to_tokens(tokens); + self.lit.to_tokens(tokens); } } #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "printing")))] - impl ToTokens for ExprClosure { + impl ToTokens for ExprLoop { fn to_tokens(&self, tokens: &mut TokenStream) { outer_attrs_to_tokens(&self.attrs, tokens); - self.movability.to_tokens(tokens); - self.asyncness.to_tokens(tokens); - self.capture.to_tokens(tokens); - self.or1_token.to_tokens(tokens); - self.inputs.to_tokens(tokens); - self.or2_token.to_tokens(tokens); - self.output.to_tokens(tokens); - self.body.to_tokens(tokens); + self.label.to_tokens(tokens); + self.loop_token.to_tokens(tokens); + self.body.brace_token.surround(tokens, |tokens| { + inner_attrs_to_tokens(&self.attrs, tokens); + tokens.append_all(&self.body.stmts); + }); } } - #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "printing")))] - impl ToTokens for ExprUnsafe { + impl ToTokens for ExprMacro { fn to_tokens(&self, tokens: &mut TokenStream) { outer_attrs_to_tokens(&self.attrs, tokens); - self.unsafe_token.to_tokens(tokens); - self.block.brace_token.surround(tokens, |tokens| { - inner_attrs_to_tokens(&self.attrs, tokens); - tokens.append_all(&self.block.stmts); - }); + self.mac.to_tokens(tokens); } } #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "printing")))] - impl ToTokens for ExprBlock { + impl ToTokens for ExprMatch { fn to_tokens(&self, tokens: &mut TokenStream) { outer_attrs_to_tokens(&self.attrs, tokens); - self.label.to_tokens(tokens); - self.block.brace_token.surround(tokens, |tokens| { + self.match_token.to_tokens(tokens); + wrap_bare_struct(tokens, &self.expr); + self.brace_token.surround(tokens, |tokens| { inner_attrs_to_tokens(&self.attrs, tokens); - tokens.append_all(&self.block.stmts); + for (i, arm) in self.arms.iter().enumerate() { + arm.to_tokens(tokens); + // Ensure that we have a comma after a non-block arm, except + // for the last one. + let is_last = i == self.arms.len() - 1; + if !is_last && requires_terminator(&arm.body) && arm.comma.is_none() { + <Token![,]>::default().to_tokens(tokens); + } + } }); } } #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "printing")))] - impl ToTokens for ExprAssign { + impl ToTokens for ExprMethodCall { fn to_tokens(&self, tokens: &mut TokenStream) { outer_attrs_to_tokens(&self.attrs, tokens); - self.left.to_tokens(tokens); - self.eq_token.to_tokens(tokens); - self.right.to_tokens(tokens); + self.receiver.to_tokens(tokens); + self.dot_token.to_tokens(tokens); + self.method.to_tokens(tokens); + self.turbofish.to_tokens(tokens); + self.paren_token.surround(tokens, |tokens| { + self.args.to_tokens(tokens); + }); } } - #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "printing")))] - impl ToTokens for ExprAssignOp { + impl ToTokens for ExprParen { fn to_tokens(&self, tokens: &mut TokenStream) { outer_attrs_to_tokens(&self.attrs, tokens); - self.left.to_tokens(tokens); - self.op.to_tokens(tokens); - self.right.to_tokens(tokens); + self.paren_token.surround(tokens, |tokens| { + self.expr.to_tokens(tokens); + }); } } #[cfg_attr(doc_cfg, doc(cfg(feature = "printing")))] - impl ToTokens for ExprField { + impl ToTokens for ExprPath { fn to_tokens(&self, tokens: &mut TokenStream) { outer_attrs_to_tokens(&self.attrs, tokens); - self.base.to_tokens(tokens); - self.dot_token.to_tokens(tokens); - self.member.to_tokens(tokens); - } - } - - #[cfg_attr(doc_cfg, doc(cfg(feature = "printing")))] - impl ToTokens for Member { - fn to_tokens(&self, tokens: &mut TokenStream) { - match self { - Member::Named(ident) => ident.to_tokens(tokens), - Member::Unnamed(index) => index.to_tokens(tokens), - } + path::printing::print_path(tokens, &self.qself, &self.path); } } + #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "printing")))] - impl ToTokens for Index { + impl ToTokens for ExprRange { fn to_tokens(&self, tokens: &mut TokenStream) { - let mut lit = Literal::i64_unsuffixed(i64::from(self.index)); - lit.set_span(self.span); - tokens.append(lit); + outer_attrs_to_tokens(&self.attrs, tokens); + self.start.to_tokens(tokens); + self.limits.to_tokens(tokens); + self.end.to_tokens(tokens); } } + #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "printing")))] - impl ToTokens for ExprIndex { + impl ToTokens for ExprReference { fn to_tokens(&self, tokens: &mut TokenStream) { outer_attrs_to_tokens(&self.attrs, tokens); + self.and_token.to_tokens(tokens); + self.mutability.to_tokens(tokens); self.expr.to_tokens(tokens); - self.bracket_token.surround(tokens, |tokens| { - self.index.to_tokens(tokens); - }); } } #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "printing")))] - impl ToTokens for RangeLimits { + impl ToTokens for ExprRepeat { fn to_tokens(&self, tokens: &mut TokenStream) { - match self { - RangeLimits::HalfOpen(t) => t.to_tokens(tokens), - RangeLimits::Closed(t) => t.to_tokens(tokens), - } + outer_attrs_to_tokens(&self.attrs, tokens); + self.bracket_token.surround(tokens, |tokens| { + self.expr.to_tokens(tokens); + self.semi_token.to_tokens(tokens); + self.len.to_tokens(tokens); + }); } } #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "printing")))] - impl ToTokens for ExprRange { + impl ToTokens for ExprReturn { fn to_tokens(&self, tokens: &mut TokenStream) { outer_attrs_to_tokens(&self.attrs, tokens); - self.from.to_tokens(tokens); - self.limits.to_tokens(tokens); - self.to.to_tokens(tokens); + self.return_token.to_tokens(tokens); + self.expr.to_tokens(tokens); } } + #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "printing")))] - impl ToTokens for ExprPath { + impl ToTokens for ExprStruct { fn to_tokens(&self, tokens: &mut TokenStream) { outer_attrs_to_tokens(&self.attrs, tokens); path::printing::print_path(tokens, &self.qself, &self.path); + self.brace_token.surround(tokens, |tokens| { + self.fields.to_tokens(tokens); + if let Some(dot2_token) = &self.dot2_token { + dot2_token.to_tokens(tokens); + } else if self.rest.is_some() { + Token![..](Span::call_site()).to_tokens(tokens); + } + self.rest.to_tokens(tokens); + }); } } #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "printing")))] - impl ToTokens for ExprReference { + impl ToTokens for ExprTry { fn to_tokens(&self, tokens: &mut TokenStream) { outer_attrs_to_tokens(&self.attrs, tokens); - self.and_token.to_tokens(tokens); - self.mutability.to_tokens(tokens); self.expr.to_tokens(tokens); + self.question_token.to_tokens(tokens); } } #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "printing")))] - impl ToTokens for ExprBreak { + impl ToTokens for ExprTryBlock { fn to_tokens(&self, tokens: &mut TokenStream) { outer_attrs_to_tokens(&self.attrs, tokens); - self.break_token.to_tokens(tokens); - self.label.to_tokens(tokens); - self.expr.to_tokens(tokens); + self.try_token.to_tokens(tokens); + self.block.to_tokens(tokens); } } #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "printing")))] - impl ToTokens for ExprContinue { + impl ToTokens for ExprTuple { fn to_tokens(&self, tokens: &mut TokenStream) { outer_attrs_to_tokens(&self.attrs, tokens); - self.continue_token.to_tokens(tokens); - self.label.to_tokens(tokens); + self.paren_token.surround(tokens, |tokens| { + self.elems.to_tokens(tokens); + // If we only have one argument, we need a trailing comma to + // distinguish ExprTuple from ExprParen. + if self.elems.len() == 1 && !self.elems.trailing_punct() { + <Token![,]>::default().to_tokens(tokens); + } + }); } } - #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "printing")))] - impl ToTokens for ExprReturn { + impl ToTokens for ExprUnary { fn to_tokens(&self, tokens: &mut TokenStream) { outer_attrs_to_tokens(&self.attrs, tokens); - self.return_token.to_tokens(tokens); + self.op.to_tokens(tokens); self.expr.to_tokens(tokens); } } #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "printing")))] - impl ToTokens for ExprMacro { + impl ToTokens for ExprUnsafe { fn to_tokens(&self, tokens: &mut TokenStream) { outer_attrs_to_tokens(&self.attrs, tokens); - self.mac.to_tokens(tokens); + self.unsafe_token.to_tokens(tokens); + self.block.brace_token.surround(tokens, |tokens| { + inner_attrs_to_tokens(&self.attrs, tokens); + tokens.append_all(&self.block.stmts); + }); } } #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "printing")))] - impl ToTokens for ExprStruct { + impl ToTokens for ExprWhile { fn to_tokens(&self, tokens: &mut TokenStream) { outer_attrs_to_tokens(&self.attrs, tokens); - self.path.to_tokens(tokens); - self.brace_token.surround(tokens, |tokens| { - self.fields.to_tokens(tokens); - if let Some(dot2_token) = &self.dot2_token { - dot2_token.to_tokens(tokens); - } else if self.rest.is_some() { - Token![..](Span::call_site()).to_tokens(tokens); - } - self.rest.to_tokens(tokens); + self.label.to_tokens(tokens); + self.while_token.to_tokens(tokens); + wrap_bare_struct(tokens, &self.cond); + self.body.brace_token.surround(tokens, |tokens| { + inner_attrs_to_tokens(&self.attrs, tokens); + tokens.append_all(&self.body.stmts); }); } } #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "printing")))] - impl ToTokens for ExprRepeat { + impl ToTokens for ExprYield { fn to_tokens(&self, tokens: &mut TokenStream) { outer_attrs_to_tokens(&self.attrs, tokens); - self.bracket_token.surround(tokens, |tokens| { - self.expr.to_tokens(tokens); - self.semi_token.to_tokens(tokens); - self.len.to_tokens(tokens); - }); + self.yield_token.to_tokens(tokens); + self.expr.to_tokens(tokens); } } #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "printing")))] - impl ToTokens for ExprGroup { + impl ToTokens for Arm { fn to_tokens(&self, tokens: &mut TokenStream) { - outer_attrs_to_tokens(&self.attrs, tokens); - self.group_token.surround(tokens, |tokens| { - self.expr.to_tokens(tokens); - }); + tokens.append_all(&self.attrs); + self.pat.to_tokens(tokens); + if let Some((if_token, guard)) = &self.guard { + if_token.to_tokens(tokens); + guard.to_tokens(tokens); + } + self.fat_arrow_token.to_tokens(tokens); + self.body.to_tokens(tokens); + self.comma.to_tokens(tokens); } } + #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "printing")))] - impl ToTokens for ExprParen { + impl ToTokens for FieldValue { fn to_tokens(&self, tokens: &mut TokenStream) { outer_attrs_to_tokens(&self.attrs, tokens); - self.paren_token.surround(tokens, |tokens| { + self.member.to_tokens(tokens); + if let Some(colon_token) = &self.colon_token { + colon_token.to_tokens(tokens); self.expr.to_tokens(tokens); - }); + } } } - #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "printing")))] - impl ToTokens for ExprTry { + impl ToTokens for Index { fn to_tokens(&self, tokens: &mut TokenStream) { - outer_attrs_to_tokens(&self.attrs, tokens); - self.expr.to_tokens(tokens); - self.question_token.to_tokens(tokens); + let mut lit = Literal::i64_unsuffixed(i64::from(self.index)); + lit.set_span(self.span); + tokens.append(lit); } } @@ -3527,32 +3311,24 @@ pub(crate) mod printing { } } - #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "printing")))] - impl ToTokens for FieldValue { + impl ToTokens for Member { fn to_tokens(&self, tokens: &mut TokenStream) { - outer_attrs_to_tokens(&self.attrs, tokens); - self.member.to_tokens(tokens); - if let Some(colon_token) = &self.colon_token { - colon_token.to_tokens(tokens); - self.expr.to_tokens(tokens); + match self { + Member::Named(ident) => ident.to_tokens(tokens), + Member::Unnamed(index) => index.to_tokens(tokens), } } } #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "printing")))] - impl ToTokens for Arm { + impl ToTokens for RangeLimits { fn to_tokens(&self, tokens: &mut TokenStream) { - tokens.append_all(&self.attrs); - self.pat.to_tokens(tokens); - if let Some((if_token, guard)) = &self.guard { - if_token.to_tokens(tokens); - guard.to_tokens(tokens); + match self { + RangeLimits::HalfOpen(t) => t.to_tokens(tokens), + RangeLimits::Closed(t) => t.to_tokens(tokens), } - self.fat_arrow_token.to_tokens(tokens); - self.body.to_tokens(tokens); - self.comma.to_tokens(tokens); } } } diff --git a/vendor/syn/src/ext.rs b/vendor/syn/src/ext.rs index 98d5550f4..9ee567251 100644 --- a/vendor/syn/src/ext.rs +++ b/vendor/syn/src/ext.rs @@ -1,6 +1,4 @@ //! Extension traits to provide parsing methods on foreign types. -//! -//! *This module is available only if Syn is built with the `"parsing"` feature.* use crate::buffer::Cursor; use crate::parse::Peek; @@ -13,8 +11,6 @@ use proc_macro2::Ident; /// /// This trait is sealed and cannot be implemented for types outside of Syn. It /// is implemented only for `proc_macro2::Ident`. -/// -/// *This trait is available only if Syn is built with the `"parsing"` feature.* pub trait IdentExt: Sized + private::Sealed { /// Parses any identifier including keywords. /// @@ -96,8 +92,8 @@ impl IdentExt for Ident { fn unraw(&self) -> Ident { let string = self.to_string(); - if string.starts_with("r#") { - Ident::new(&string[2..], self.span()) + if let Some(string) = string.strip_prefix("r#") { + Ident::new(string, self.span()) } else { self.clone() } diff --git a/vendor/syn/src/file.rs b/vendor/syn/src/file.rs index 280484f98..2d9f298cc 100644 --- a/vendor/syn/src/file.rs +++ b/vendor/syn/src/file.rs @@ -3,7 +3,7 @@ use super::*; ast_struct! { /// A complete file of Rust source code. /// - /// *This type is available only if Syn is built with the `"full"` feature.* + /// Typically `File` objects are created with [`parse_file`]. /// /// # Example /// @@ -86,7 +86,7 @@ ast_struct! { } #[cfg(feature = "parsing")] -pub mod parsing { +pub(crate) mod parsing { use super::*; use crate::parse::{Parse, ParseStream, Result}; diff --git a/vendor/syn/src/gen/clone.rs b/vendor/syn/src/gen/clone.rs index a413e3ec7..d275f5114 100644 --- a/vendor/syn/src/gen/clone.rs +++ b/vendor/syn/src/gen/clone.rs @@ -41,6 +41,30 @@ impl Clone for Arm { } #[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(doc_cfg, doc(cfg(feature = "clone-impls")))] +impl Clone for AssocConst { + fn clone(&self) -> Self { + AssocConst { + ident: self.ident.clone(), + generics: self.generics.clone(), + eq_token: self.eq_token.clone(), + value: self.value.clone(), + } + } +} +#[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(feature = "clone-impls")))] +impl Clone for AssocType { + fn clone(&self) -> Self { + AssocType { + ident: self.ident.clone(), + generics: self.generics.clone(), + eq_token: self.eq_token.clone(), + ty: self.ty.clone(), + } + } +} +#[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(feature = "clone-impls")))] impl Copy for AttrStyle {} #[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(doc_cfg, doc(cfg(feature = "clone-impls")))] @@ -57,8 +81,7 @@ impl Clone for Attribute { pound_token: self.pound_token.clone(), style: self.style.clone(), bracket_token: self.bracket_token.clone(), - path: self.path.clone(), - tokens: self.tokens.clone(), + meta: self.meta.clone(), } } } @@ -75,23 +98,24 @@ impl Clone for BareFnArg { } #[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(doc_cfg, doc(cfg(feature = "clone-impls")))] -impl Copy for BinOp {} -#[cfg(any(feature = "derive", feature = "full"))] -#[cfg_attr(doc_cfg, doc(cfg(feature = "clone-impls")))] -impl Clone for BinOp { +impl Clone for BareVariadic { fn clone(&self) -> Self { - *self + BareVariadic { + attrs: self.attrs.clone(), + name: self.name.clone(), + dots: self.dots.clone(), + comma: self.comma.clone(), + } } } #[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(doc_cfg, doc(cfg(feature = "clone-impls")))] -impl Clone for Binding { +impl Copy for BinOp {} +#[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(feature = "clone-impls")))] +impl Clone for BinOp { fn clone(&self) -> Self { - Binding { - ident: self.ident.clone(), - eq_token: self.eq_token.clone(), - ty: self.ty.clone(), - } + *self } } #[cfg(feature = "full")] @@ -137,6 +161,7 @@ impl Clone for Constraint { fn clone(&self) -> Self { Constraint { ident: self.ident.clone(), + generics: self.generics.clone(), colon_token: self.colon_token.clone(), bounds: self.bounds.clone(), } @@ -208,8 +233,6 @@ impl Clone for Expr { #[cfg(feature = "full")] Expr::Assign(v0) => Expr::Assign(v0.clone()), #[cfg(feature = "full")] - Expr::AssignOp(v0) => Expr::AssignOp(v0.clone()), - #[cfg(feature = "full")] Expr::Async(v0) => Expr::Async(v0.clone()), #[cfg(feature = "full")] Expr::Await(v0) => Expr::Await(v0.clone()), @@ -217,29 +240,29 @@ impl Clone for Expr { #[cfg(feature = "full")] Expr::Block(v0) => Expr::Block(v0.clone()), #[cfg(feature = "full")] - Expr::Box(v0) => Expr::Box(v0.clone()), - #[cfg(feature = "full")] Expr::Break(v0) => Expr::Break(v0.clone()), Expr::Call(v0) => Expr::Call(v0.clone()), Expr::Cast(v0) => Expr::Cast(v0.clone()), #[cfg(feature = "full")] Expr::Closure(v0) => Expr::Closure(v0.clone()), #[cfg(feature = "full")] + Expr::Const(v0) => Expr::Const(v0.clone()), + #[cfg(feature = "full")] Expr::Continue(v0) => Expr::Continue(v0.clone()), Expr::Field(v0) => Expr::Field(v0.clone()), #[cfg(feature = "full")] Expr::ForLoop(v0) => Expr::ForLoop(v0.clone()), - #[cfg(feature = "full")] Expr::Group(v0) => Expr::Group(v0.clone()), #[cfg(feature = "full")] Expr::If(v0) => Expr::If(v0.clone()), Expr::Index(v0) => Expr::Index(v0.clone()), #[cfg(feature = "full")] + Expr::Infer(v0) => Expr::Infer(v0.clone()), + #[cfg(feature = "full")] Expr::Let(v0) => Expr::Let(v0.clone()), Expr::Lit(v0) => Expr::Lit(v0.clone()), #[cfg(feature = "full")] Expr::Loop(v0) => Expr::Loop(v0.clone()), - #[cfg(feature = "full")] Expr::Macro(v0) => Expr::Macro(v0.clone()), #[cfg(feature = "full")] Expr::Match(v0) => Expr::Match(v0.clone()), @@ -263,8 +286,6 @@ impl Clone for Expr { Expr::TryBlock(v0) => Expr::TryBlock(v0.clone()), #[cfg(feature = "full")] Expr::Tuple(v0) => Expr::Tuple(v0.clone()), - #[cfg(feature = "full")] - Expr::Type(v0) => Expr::Type(v0.clone()), Expr::Unary(v0) => Expr::Unary(v0.clone()), #[cfg(feature = "full")] Expr::Unsafe(v0) => Expr::Unsafe(v0.clone()), @@ -273,7 +294,7 @@ impl Clone for Expr { Expr::While(v0) => Expr::While(v0.clone()), #[cfg(feature = "full")] Expr::Yield(v0) => Expr::Yield(v0.clone()), - #[cfg(any(syn_no_non_exhaustive, not(feature = "full")))] + #[cfg(not(feature = "full"))] _ => unreachable!(), } } @@ -303,18 +324,6 @@ impl Clone for ExprAssign { } #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "clone-impls")))] -impl Clone for ExprAssignOp { - fn clone(&self) -> Self { - ExprAssignOp { - attrs: self.attrs.clone(), - left: self.left.clone(), - op: self.op.clone(), - right: self.right.clone(), - } - } -} -#[cfg(feature = "full")] -#[cfg_attr(doc_cfg, doc(cfg(feature = "clone-impls")))] impl Clone for ExprAsync { fn clone(&self) -> Self { ExprAsync { @@ -362,17 +371,6 @@ impl Clone for ExprBlock { } #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "clone-impls")))] -impl Clone for ExprBox { - fn clone(&self) -> Self { - ExprBox { - attrs: self.attrs.clone(), - box_token: self.box_token.clone(), - expr: self.expr.clone(), - } - } -} -#[cfg(feature = "full")] -#[cfg_attr(doc_cfg, doc(cfg(feature = "clone-impls")))] impl Clone for ExprBreak { fn clone(&self) -> Self { ExprBreak { @@ -413,6 +411,8 @@ impl Clone for ExprClosure { fn clone(&self) -> Self { ExprClosure { attrs: self.attrs.clone(), + lifetimes: self.lifetimes.clone(), + constness: self.constness.clone(), movability: self.movability.clone(), asyncness: self.asyncness.clone(), capture: self.capture.clone(), @@ -426,6 +426,17 @@ impl Clone for ExprClosure { } #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "clone-impls")))] +impl Clone for ExprConst { + fn clone(&self) -> Self { + ExprConst { + attrs: self.attrs.clone(), + const_token: self.const_token.clone(), + block: self.block.clone(), + } + } +} +#[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "clone-impls")))] impl Clone for ExprContinue { fn clone(&self) -> Self { ExprContinue { @@ -462,7 +473,7 @@ impl Clone for ExprForLoop { } } } -#[cfg(feature = "full")] +#[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(doc_cfg, doc(cfg(feature = "clone-impls")))] impl Clone for ExprGroup { fn clone(&self) -> Self { @@ -500,6 +511,16 @@ impl Clone for ExprIndex { } #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "clone-impls")))] +impl Clone for ExprInfer { + fn clone(&self) -> Self { + ExprInfer { + attrs: self.attrs.clone(), + underscore_token: self.underscore_token.clone(), + } + } +} +#[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "clone-impls")))] impl Clone for ExprLet { fn clone(&self) -> Self { ExprLet { @@ -533,7 +554,7 @@ impl Clone for ExprLoop { } } } -#[cfg(feature = "full")] +#[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(doc_cfg, doc(cfg(feature = "clone-impls")))] impl Clone for ExprMacro { fn clone(&self) -> Self { @@ -599,9 +620,9 @@ impl Clone for ExprRange { fn clone(&self) -> Self { ExprRange { attrs: self.attrs.clone(), - from: self.from.clone(), + start: self.start.clone(), limits: self.limits.clone(), - to: self.to.clone(), + end: self.end.clone(), } } } @@ -612,7 +633,6 @@ impl Clone for ExprReference { ExprReference { attrs: self.attrs.clone(), and_token: self.and_token.clone(), - raw: self.raw.clone(), mutability: self.mutability.clone(), expr: self.expr.clone(), } @@ -648,6 +668,7 @@ impl Clone for ExprStruct { fn clone(&self) -> Self { ExprStruct { attrs: self.attrs.clone(), + qself: self.qself.clone(), path: self.path.clone(), brace_token: self.brace_token.clone(), fields: self.fields.clone(), @@ -689,18 +710,6 @@ impl Clone for ExprTuple { } } } -#[cfg(feature = "full")] -#[cfg_attr(doc_cfg, doc(cfg(feature = "clone-impls")))] -impl Clone for ExprType { - fn clone(&self) -> Self { - ExprType { - attrs: self.attrs.clone(), - expr: self.expr.clone(), - colon_token: self.colon_token.clone(), - ty: self.ty.clone(), - } - } -} #[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(doc_cfg, doc(cfg(feature = "clone-impls")))] impl Clone for ExprUnary { @@ -754,12 +763,22 @@ impl Clone for Field { Field { attrs: self.attrs.clone(), vis: self.vis.clone(), + mutability: self.mutability.clone(), ident: self.ident.clone(), colon_token: self.colon_token.clone(), ty: self.ty.clone(), } } } +#[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(feature = "clone-impls")))] +impl Clone for FieldMutability { + fn clone(&self) -> Self { + match self { + FieldMutability::None => FieldMutability::None, + } + } +} #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "clone-impls")))] impl Clone for FieldPat { @@ -846,8 +865,6 @@ impl Clone for ForeignItem { ForeignItem::Type(v0) => ForeignItem::Type(v0.clone()), ForeignItem::Macro(v0) => ForeignItem::Macro(v0.clone()), ForeignItem::Verbatim(v0) => ForeignItem::Verbatim(v0.clone()), - #[cfg(syn_no_non_exhaustive)] - _ => unreachable!(), } } } @@ -899,6 +916,7 @@ impl Clone for ForeignItemType { vis: self.vis.clone(), type_token: self.type_token.clone(), ident: self.ident.clone(), + generics: self.generics.clone(), semi_token: self.semi_token.clone(), } } @@ -911,28 +929,19 @@ impl Clone for GenericArgument { GenericArgument::Lifetime(v0) => GenericArgument::Lifetime(v0.clone()), GenericArgument::Type(v0) => GenericArgument::Type(v0.clone()), GenericArgument::Const(v0) => GenericArgument::Const(v0.clone()), - GenericArgument::Binding(v0) => GenericArgument::Binding(v0.clone()), + GenericArgument::AssocType(v0) => GenericArgument::AssocType(v0.clone()), + GenericArgument::AssocConst(v0) => GenericArgument::AssocConst(v0.clone()), GenericArgument::Constraint(v0) => GenericArgument::Constraint(v0.clone()), } } } -#[cfg(feature = "full")] -#[cfg_attr(doc_cfg, doc(cfg(feature = "clone-impls")))] -impl Clone for GenericMethodArgument { - fn clone(&self) -> Self { - match self { - GenericMethodArgument::Type(v0) => GenericMethodArgument::Type(v0.clone()), - GenericMethodArgument::Const(v0) => GenericMethodArgument::Const(v0.clone()), - } - } -} #[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(doc_cfg, doc(cfg(feature = "clone-impls")))] impl Clone for GenericParam { fn clone(&self) -> Self { match self { - GenericParam::Type(v0) => GenericParam::Type(v0.clone()), GenericParam::Lifetime(v0) => GenericParam::Lifetime(v0.clone()), + GenericParam::Type(v0) => GenericParam::Type(v0.clone()), GenericParam::Const(v0) => GenericParam::Const(v0.clone()), } } @@ -955,12 +964,10 @@ impl Clone for ImplItem { fn clone(&self) -> Self { match self { ImplItem::Const(v0) => ImplItem::Const(v0.clone()), - ImplItem::Method(v0) => ImplItem::Method(v0.clone()), + ImplItem::Fn(v0) => ImplItem::Fn(v0.clone()), ImplItem::Type(v0) => ImplItem::Type(v0.clone()), ImplItem::Macro(v0) => ImplItem::Macro(v0.clone()), ImplItem::Verbatim(v0) => ImplItem::Verbatim(v0.clone()), - #[cfg(syn_no_non_exhaustive)] - _ => unreachable!(), } } } @@ -974,6 +981,7 @@ impl Clone for ImplItemConst { defaultness: self.defaultness.clone(), const_token: self.const_token.clone(), ident: self.ident.clone(), + generics: self.generics.clone(), colon_token: self.colon_token.clone(), ty: self.ty.clone(), eq_token: self.eq_token.clone(), @@ -984,25 +992,25 @@ impl Clone for ImplItemConst { } #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "clone-impls")))] -impl Clone for ImplItemMacro { +impl Clone for ImplItemFn { fn clone(&self) -> Self { - ImplItemMacro { + ImplItemFn { attrs: self.attrs.clone(), - mac: self.mac.clone(), - semi_token: self.semi_token.clone(), + vis: self.vis.clone(), + defaultness: self.defaultness.clone(), + sig: self.sig.clone(), + block: self.block.clone(), } } } #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "clone-impls")))] -impl Clone for ImplItemMethod { +impl Clone for ImplItemMacro { fn clone(&self) -> Self { - ImplItemMethod { + ImplItemMacro { attrs: self.attrs.clone(), - vis: self.vis.clone(), - defaultness: self.defaultness.clone(), - sig: self.sig.clone(), - block: self.block.clone(), + mac: self.mac.clone(), + semi_token: self.semi_token.clone(), } } } @@ -1023,6 +1031,13 @@ impl Clone for ImplItemType { } } } +#[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "clone-impls")))] +impl Clone for ImplRestriction { + fn clone(&self) -> Self { + match *self {} + } +} #[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(doc_cfg, doc(cfg(feature = "clone-impls")))] impl Clone for Index { @@ -1045,7 +1060,6 @@ impl Clone for Item { Item::ForeignMod(v0) => Item::ForeignMod(v0.clone()), Item::Impl(v0) => Item::Impl(v0.clone()), Item::Macro(v0) => Item::Macro(v0.clone()), - Item::Macro2(v0) => Item::Macro2(v0.clone()), Item::Mod(v0) => Item::Mod(v0.clone()), Item::Static(v0) => Item::Static(v0.clone()), Item::Struct(v0) => Item::Struct(v0.clone()), @@ -1055,8 +1069,6 @@ impl Clone for Item { Item::Union(v0) => Item::Union(v0.clone()), Item::Use(v0) => Item::Use(v0.clone()), Item::Verbatim(v0) => Item::Verbatim(v0.clone()), - #[cfg(syn_no_non_exhaustive)] - _ => unreachable!(), } } } @@ -1069,6 +1081,7 @@ impl Clone for ItemConst { vis: self.vis.clone(), const_token: self.const_token.clone(), ident: self.ident.clone(), + generics: self.generics.clone(), colon_token: self.colon_token.clone(), ty: self.ty.clone(), eq_token: self.eq_token.clone(), @@ -1125,6 +1138,7 @@ impl Clone for ItemForeignMod { fn clone(&self) -> Self { ItemForeignMod { attrs: self.attrs.clone(), + unsafety: self.unsafety.clone(), abi: self.abi.clone(), brace_token: self.brace_token.clone(), items: self.items.clone(), @@ -1162,24 +1176,12 @@ impl Clone for ItemMacro { } #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "clone-impls")))] -impl Clone for ItemMacro2 { - fn clone(&self) -> Self { - ItemMacro2 { - attrs: self.attrs.clone(), - vis: self.vis.clone(), - macro_token: self.macro_token.clone(), - ident: self.ident.clone(), - rules: self.rules.clone(), - } - } -} -#[cfg(feature = "full")] -#[cfg_attr(doc_cfg, doc(cfg(feature = "clone-impls")))] impl Clone for ItemMod { fn clone(&self) -> Self { ItemMod { attrs: self.attrs.clone(), vis: self.vis.clone(), + unsafety: self.unsafety.clone(), mod_token: self.mod_token.clone(), ident: self.ident.clone(), content: self.content.clone(), @@ -1229,6 +1231,7 @@ impl Clone for ItemTrait { vis: self.vis.clone(), unsafety: self.unsafety.clone(), auto_token: self.auto_token.clone(), + restriction: self.restriction.clone(), trait_token: self.trait_token.clone(), ident: self.ident.clone(), generics: self.generics.clone(), @@ -1311,9 +1314,9 @@ impl Clone for Label { } #[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(doc_cfg, doc(cfg(feature = "clone-impls")))] -impl Clone for LifetimeDef { +impl Clone for LifetimeParam { fn clone(&self) -> Self { - LifetimeDef { + LifetimeParam { attrs: self.attrs.clone(), lifetime: self.lifetime.clone(), colon_token: self.colon_token.clone(), @@ -1358,6 +1361,17 @@ impl Clone for Local { } } } +#[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "clone-impls")))] +impl Clone for LocalInit { + fn clone(&self) -> Self { + LocalInit { + eq_token: self.eq_token.clone(), + expr: self.expr.clone(), + diverge: self.diverge.clone(), + } + } +} #[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(doc_cfg, doc(cfg(feature = "clone-impls")))] impl Clone for Macro { @@ -1408,8 +1422,8 @@ impl Clone for MetaList { fn clone(&self) -> Self { MetaList { path: self.path.clone(), - paren_token: self.paren_token.clone(), - nested: self.nested.clone(), + delimiter: self.delimiter.clone(), + tokens: self.tokens.clone(), } } } @@ -1420,29 +1434,7 @@ impl Clone for MetaNameValue { MetaNameValue { path: self.path.clone(), eq_token: self.eq_token.clone(), - lit: self.lit.clone(), - } - } -} -#[cfg(feature = "full")] -#[cfg_attr(doc_cfg, doc(cfg(feature = "clone-impls")))] -impl Clone for MethodTurbofish { - fn clone(&self) -> Self { - MethodTurbofish { - colon2_token: self.colon2_token.clone(), - lt_token: self.lt_token.clone(), - args: self.args.clone(), - gt_token: self.gt_token.clone(), - } - } -} -#[cfg(any(feature = "derive", feature = "full"))] -#[cfg_attr(doc_cfg, doc(cfg(feature = "clone-impls")))] -impl Clone for NestedMeta { - fn clone(&self) -> Self { - match self { - NestedMeta::Meta(v0) => NestedMeta::Meta(v0.clone()), - NestedMeta::Lit(v0) => NestedMeta::Lit(v0.clone()), + value: self.value.clone(), } } } @@ -1462,11 +1454,12 @@ impl Clone for ParenthesizedGenericArguments { impl Clone for Pat { fn clone(&self) -> Self { match self { - Pat::Box(v0) => Pat::Box(v0.clone()), + Pat::Const(v0) => Pat::Const(v0.clone()), Pat::Ident(v0) => Pat::Ident(v0.clone()), Pat::Lit(v0) => Pat::Lit(v0.clone()), Pat::Macro(v0) => Pat::Macro(v0.clone()), Pat::Or(v0) => Pat::Or(v0.clone()), + Pat::Paren(v0) => Pat::Paren(v0.clone()), Pat::Path(v0) => Pat::Path(v0.clone()), Pat::Range(v0) => Pat::Range(v0.clone()), Pat::Reference(v0) => Pat::Reference(v0.clone()), @@ -1478,19 +1471,6 @@ impl Clone for Pat { Pat::Type(v0) => Pat::Type(v0.clone()), Pat::Verbatim(v0) => Pat::Verbatim(v0.clone()), Pat::Wild(v0) => Pat::Wild(v0.clone()), - #[cfg(syn_no_non_exhaustive)] - _ => unreachable!(), - } - } -} -#[cfg(feature = "full")] -#[cfg_attr(doc_cfg, doc(cfg(feature = "clone-impls")))] -impl Clone for PatBox { - fn clone(&self) -> Self { - PatBox { - attrs: self.attrs.clone(), - box_token: self.box_token.clone(), - pat: self.pat.clone(), } } } @@ -1509,26 +1489,6 @@ impl Clone for PatIdent { } #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "clone-impls")))] -impl Clone for PatLit { - fn clone(&self) -> Self { - PatLit { - attrs: self.attrs.clone(), - expr: self.expr.clone(), - } - } -} -#[cfg(feature = "full")] -#[cfg_attr(doc_cfg, doc(cfg(feature = "clone-impls")))] -impl Clone for PatMacro { - fn clone(&self) -> Self { - PatMacro { - attrs: self.attrs.clone(), - mac: self.mac.clone(), - } - } -} -#[cfg(feature = "full")] -#[cfg_attr(doc_cfg, doc(cfg(feature = "clone-impls")))] impl Clone for PatOr { fn clone(&self) -> Self { PatOr { @@ -1540,24 +1500,12 @@ impl Clone for PatOr { } #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "clone-impls")))] -impl Clone for PatPath { - fn clone(&self) -> Self { - PatPath { - attrs: self.attrs.clone(), - qself: self.qself.clone(), - path: self.path.clone(), - } - } -} -#[cfg(feature = "full")] -#[cfg_attr(doc_cfg, doc(cfg(feature = "clone-impls")))] -impl Clone for PatRange { +impl Clone for PatParen { fn clone(&self) -> Self { - PatRange { + PatParen { attrs: self.attrs.clone(), - lo: self.lo.clone(), - limits: self.limits.clone(), - hi: self.hi.clone(), + paren_token: self.paren_token.clone(), + pat: self.pat.clone(), } } } @@ -1600,10 +1548,11 @@ impl Clone for PatStruct { fn clone(&self) -> Self { PatStruct { attrs: self.attrs.clone(), + qself: self.qself.clone(), path: self.path.clone(), brace_token: self.brace_token.clone(), fields: self.fields.clone(), - dot2_token: self.dot2_token.clone(), + rest: self.rest.clone(), } } } @@ -1624,8 +1573,10 @@ impl Clone for PatTupleStruct { fn clone(&self) -> Self { PatTupleStruct { attrs: self.attrs.clone(), + qself: self.qself.clone(), path: self.path.clone(), - pat: self.pat.clone(), + paren_token: self.paren_token.clone(), + elems: self.elems.clone(), } } } @@ -1686,17 +1637,6 @@ impl Clone for PathSegment { } #[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(doc_cfg, doc(cfg(feature = "clone-impls")))] -impl Clone for PredicateEq { - fn clone(&self) -> Self { - PredicateEq { - lhs_ty: self.lhs_ty.clone(), - eq_token: self.eq_token.clone(), - rhs_ty: self.rhs_ty.clone(), - } - } -} -#[cfg(any(feature = "derive", feature = "full"))] -#[cfg_attr(doc_cfg, doc(cfg(feature = "clone-impls")))] impl Clone for PredicateLifetime { fn clone(&self) -> Self { PredicateLifetime { @@ -1750,6 +1690,8 @@ impl Clone for Receiver { reference: self.reference.clone(), mutability: self.mutability.clone(), self_token: self.self_token.clone(), + colon_token: self.colon_token.clone(), + ty: self.ty.clone(), } } } @@ -1784,13 +1726,34 @@ impl Clone for Signature { } #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "clone-impls")))] +impl Clone for StaticMutability { + fn clone(&self) -> Self { + match self { + StaticMutability::Mut(v0) => StaticMutability::Mut(v0.clone()), + StaticMutability::None => StaticMutability::None, + } + } +} +#[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "clone-impls")))] impl Clone for Stmt { fn clone(&self) -> Self { match self { Stmt::Local(v0) => Stmt::Local(v0.clone()), Stmt::Item(v0) => Stmt::Item(v0.clone()), - Stmt::Expr(v0) => Stmt::Expr(v0.clone()), - Stmt::Semi(v0, v1) => Stmt::Semi(v0.clone(), v1.clone()), + Stmt::Expr(v0, v1) => Stmt::Expr(v0.clone(), v1.clone()), + Stmt::Macro(v0) => Stmt::Macro(v0.clone()), + } + } +} +#[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "clone-impls")))] +impl Clone for StmtMacro { + fn clone(&self) -> Self { + StmtMacro { + attrs: self.attrs.clone(), + mac: self.mac.clone(), + semi_token: self.semi_token.clone(), } } } @@ -1822,12 +1785,10 @@ impl Clone for TraitItem { fn clone(&self) -> Self { match self { TraitItem::Const(v0) => TraitItem::Const(v0.clone()), - TraitItem::Method(v0) => TraitItem::Method(v0.clone()), + TraitItem::Fn(v0) => TraitItem::Fn(v0.clone()), TraitItem::Type(v0) => TraitItem::Type(v0.clone()), TraitItem::Macro(v0) => TraitItem::Macro(v0.clone()), TraitItem::Verbatim(v0) => TraitItem::Verbatim(v0.clone()), - #[cfg(syn_no_non_exhaustive)] - _ => unreachable!(), } } } @@ -1839,6 +1800,7 @@ impl Clone for TraitItemConst { attrs: self.attrs.clone(), const_token: self.const_token.clone(), ident: self.ident.clone(), + generics: self.generics.clone(), colon_token: self.colon_token.clone(), ty: self.ty.clone(), default: self.default.clone(), @@ -1848,23 +1810,23 @@ impl Clone for TraitItemConst { } #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "clone-impls")))] -impl Clone for TraitItemMacro { +impl Clone for TraitItemFn { fn clone(&self) -> Self { - TraitItemMacro { + TraitItemFn { attrs: self.attrs.clone(), - mac: self.mac.clone(), + sig: self.sig.clone(), + default: self.default.clone(), semi_token: self.semi_token.clone(), } } } #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "clone-impls")))] -impl Clone for TraitItemMethod { +impl Clone for TraitItemMacro { fn clone(&self) -> Self { - TraitItemMethod { + TraitItemMacro { attrs: self.attrs.clone(), - sig: self.sig.clone(), - default: self.default.clone(), + mac: self.mac.clone(), semi_token: self.semi_token.clone(), } } @@ -1905,8 +1867,6 @@ impl Clone for Type { Type::TraitObject(v0) => Type::TraitObject(v0.clone()), Type::Tuple(v0) => Type::Tuple(v0.clone()), Type::Verbatim(v0) => Type::Verbatim(v0.clone()), - #[cfg(syn_no_non_exhaustive)] - _ => unreachable!(), } } } @@ -2004,6 +1964,7 @@ impl Clone for TypeParamBound { match self { TypeParamBound::Trait(v0) => TypeParamBound::Trait(v0.clone()), TypeParamBound::Lifetime(v0) => TypeParamBound::Lifetime(v0.clone()), + TypeParamBound::Verbatim(v0) => TypeParamBound::Verbatim(v0.clone()), } } } @@ -2154,13 +2115,15 @@ impl Clone for UseTree { } } } -#[cfg(any(feature = "derive", feature = "full"))] +#[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "clone-impls")))] impl Clone for Variadic { fn clone(&self) -> Self { Variadic { attrs: self.attrs.clone(), + pat: self.pat.clone(), dots: self.dots.clone(), + comma: self.comma.clone(), } } } @@ -2178,24 +2141,6 @@ impl Clone for Variant { } #[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(doc_cfg, doc(cfg(feature = "clone-impls")))] -impl Clone for VisCrate { - fn clone(&self) -> Self { - VisCrate { - crate_token: self.crate_token.clone(), - } - } -} -#[cfg(any(feature = "derive", feature = "full"))] -#[cfg_attr(doc_cfg, doc(cfg(feature = "clone-impls")))] -impl Clone for VisPublic { - fn clone(&self) -> Self { - VisPublic { - pub_token: self.pub_token.clone(), - } - } -} -#[cfg(any(feature = "derive", feature = "full"))] -#[cfg_attr(doc_cfg, doc(cfg(feature = "clone-impls")))] impl Clone for VisRestricted { fn clone(&self) -> Self { VisRestricted { @@ -2212,7 +2157,6 @@ impl Clone for Visibility { fn clone(&self) -> Self { match self { Visibility::Public(v0) => Visibility::Public(v0.clone()), - Visibility::Crate(v0) => Visibility::Crate(v0.clone()), Visibility::Restricted(v0) => Visibility::Restricted(v0.clone()), Visibility::Inherited => Visibility::Inherited, } @@ -2233,9 +2177,8 @@ impl Clone for WhereClause { impl Clone for WherePredicate { fn clone(&self) -> Self { match self { - WherePredicate::Type(v0) => WherePredicate::Type(v0.clone()), WherePredicate::Lifetime(v0) => WherePredicate::Lifetime(v0.clone()), - WherePredicate::Eq(v0) => WherePredicate::Eq(v0.clone()), + WherePredicate::Type(v0) => WherePredicate::Type(v0.clone()), } } } diff --git a/vendor/syn/src/gen/debug.rs b/vendor/syn/src/gen/debug.rs index a1f0afa79..837fe99f4 100644 --- a/vendor/syn/src/gen/debug.rs +++ b/vendor/syn/src/gen/debug.rs @@ -17,12 +17,17 @@ impl Debug for Abi { #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Debug for AngleBracketedGenericArguments { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let mut formatter = formatter.debug_struct("AngleBracketedGenericArguments"); - formatter.field("colon2_token", &self.colon2_token); - formatter.field("lt_token", &self.lt_token); - formatter.field("args", &self.args); - formatter.field("gt_token", &self.gt_token); - formatter.finish() + impl AngleBracketedGenericArguments { + fn debug(&self, formatter: &mut fmt::Formatter, name: &str) -> fmt::Result { + let mut formatter = formatter.debug_struct(name); + formatter.field("colon2_token", &self.colon2_token); + formatter.field("lt_token", &self.lt_token); + formatter.field("args", &self.args); + formatter.field("gt_token", &self.gt_token); + formatter.finish() + } + } + self.debug(formatter, "AngleBracketedGenericArguments") } } #[cfg(feature = "full")] @@ -41,8 +46,33 @@ impl Debug for Arm { } #[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] +impl Debug for AssocConst { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + let mut formatter = formatter.debug_struct("AssocConst"); + formatter.field("ident", &self.ident); + formatter.field("generics", &self.generics); + formatter.field("eq_token", &self.eq_token); + formatter.field("value", &self.value); + formatter.finish() + } +} +#[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] +impl Debug for AssocType { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + let mut formatter = formatter.debug_struct("AssocType"); + formatter.field("ident", &self.ident); + formatter.field("generics", &self.generics); + formatter.field("eq_token", &self.eq_token); + formatter.field("ty", &self.ty); + formatter.finish() + } +} +#[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Debug for AttrStyle { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("AttrStyle::")?; match self { AttrStyle::Outer => formatter.write_str("Outer"), AttrStyle::Inner(v0) => { @@ -61,8 +91,7 @@ impl Debug for Attribute { formatter.field("pound_token", &self.pound_token); formatter.field("style", &self.style); formatter.field("bracket_token", &self.bracket_token); - formatter.field("path", &self.path); - formatter.field("tokens", &self.tokens); + formatter.field("meta", &self.meta); formatter.finish() } } @@ -79,8 +108,21 @@ impl Debug for BareFnArg { } #[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] +impl Debug for BareVariadic { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + let mut formatter = formatter.debug_struct("BareVariadic"); + formatter.field("attrs", &self.attrs); + formatter.field("name", &self.name); + formatter.field("dots", &self.dots); + formatter.field("comma", &self.comma); + formatter.finish() + } +} +#[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Debug for BinOp { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("BinOp::")?; match self { BinOp::Add(v0) => { let mut formatter = formatter.debug_tuple("Add"); @@ -172,70 +214,59 @@ impl Debug for BinOp { formatter.field(v0); formatter.finish() } - BinOp::AddEq(v0) => { - let mut formatter = formatter.debug_tuple("AddEq"); + BinOp::AddAssign(v0) => { + let mut formatter = formatter.debug_tuple("AddAssign"); formatter.field(v0); formatter.finish() } - BinOp::SubEq(v0) => { - let mut formatter = formatter.debug_tuple("SubEq"); + BinOp::SubAssign(v0) => { + let mut formatter = formatter.debug_tuple("SubAssign"); formatter.field(v0); formatter.finish() } - BinOp::MulEq(v0) => { - let mut formatter = formatter.debug_tuple("MulEq"); + BinOp::MulAssign(v0) => { + let mut formatter = formatter.debug_tuple("MulAssign"); formatter.field(v0); formatter.finish() } - BinOp::DivEq(v0) => { - let mut formatter = formatter.debug_tuple("DivEq"); + BinOp::DivAssign(v0) => { + let mut formatter = formatter.debug_tuple("DivAssign"); formatter.field(v0); formatter.finish() } - BinOp::RemEq(v0) => { - let mut formatter = formatter.debug_tuple("RemEq"); + BinOp::RemAssign(v0) => { + let mut formatter = formatter.debug_tuple("RemAssign"); formatter.field(v0); formatter.finish() } - BinOp::BitXorEq(v0) => { - let mut formatter = formatter.debug_tuple("BitXorEq"); + BinOp::BitXorAssign(v0) => { + let mut formatter = formatter.debug_tuple("BitXorAssign"); formatter.field(v0); formatter.finish() } - BinOp::BitAndEq(v0) => { - let mut formatter = formatter.debug_tuple("BitAndEq"); + BinOp::BitAndAssign(v0) => { + let mut formatter = formatter.debug_tuple("BitAndAssign"); formatter.field(v0); formatter.finish() } - BinOp::BitOrEq(v0) => { - let mut formatter = formatter.debug_tuple("BitOrEq"); + BinOp::BitOrAssign(v0) => { + let mut formatter = formatter.debug_tuple("BitOrAssign"); formatter.field(v0); formatter.finish() } - BinOp::ShlEq(v0) => { - let mut formatter = formatter.debug_tuple("ShlEq"); + BinOp::ShlAssign(v0) => { + let mut formatter = formatter.debug_tuple("ShlAssign"); formatter.field(v0); formatter.finish() } - BinOp::ShrEq(v0) => { - let mut formatter = formatter.debug_tuple("ShrEq"); + BinOp::ShrAssign(v0) => { + let mut formatter = formatter.debug_tuple("ShrAssign"); formatter.field(v0); formatter.finish() } } } } -#[cfg(any(feature = "derive", feature = "full"))] -#[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] -impl Debug for Binding { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let mut formatter = formatter.debug_struct("Binding"); - formatter.field("ident", &self.ident); - formatter.field("eq_token", &self.eq_token); - formatter.field("ty", &self.ty); - formatter.finish() - } -} #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Debug for Block { @@ -279,6 +310,7 @@ impl Debug for Constraint { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { let mut formatter = formatter.debug_struct("Constraint"); formatter.field("ident", &self.ident); + formatter.field("generics", &self.generics); formatter.field("colon_token", &self.colon_token); formatter.field("bounds", &self.bounds); formatter.finish() @@ -288,22 +320,11 @@ impl Debug for Constraint { #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Debug for Data { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("Data::")?; match self { - Data::Struct(v0) => { - let mut formatter = formatter.debug_tuple("Struct"); - formatter.field(v0); - formatter.finish() - } - Data::Enum(v0) => { - let mut formatter = formatter.debug_tuple("Enum"); - formatter.field(v0); - formatter.finish() - } - Data::Union(v0) => { - let mut formatter = formatter.debug_tuple("Union"); - formatter.field(v0); - formatter.finish() - } + Data::Struct(v0) => v0.debug(formatter, "Struct"), + Data::Enum(v0) => v0.debug(formatter, "Enum"), + Data::Union(v0) => v0.debug(formatter, "Union"), } } } @@ -311,32 +332,47 @@ impl Debug for Data { #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Debug for DataEnum { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let mut formatter = formatter.debug_struct("DataEnum"); - formatter.field("enum_token", &self.enum_token); - formatter.field("brace_token", &self.brace_token); - formatter.field("variants", &self.variants); - formatter.finish() + impl DataEnum { + fn debug(&self, formatter: &mut fmt::Formatter, name: &str) -> fmt::Result { + let mut formatter = formatter.debug_struct(name); + formatter.field("enum_token", &self.enum_token); + formatter.field("brace_token", &self.brace_token); + formatter.field("variants", &self.variants); + formatter.finish() + } + } + self.debug(formatter, "DataEnum") } } #[cfg(feature = "derive")] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Debug for DataStruct { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let mut formatter = formatter.debug_struct("DataStruct"); - formatter.field("struct_token", &self.struct_token); - formatter.field("fields", &self.fields); - formatter.field("semi_token", &self.semi_token); - formatter.finish() + impl DataStruct { + fn debug(&self, formatter: &mut fmt::Formatter, name: &str) -> fmt::Result { + let mut formatter = formatter.debug_struct(name); + formatter.field("struct_token", &self.struct_token); + formatter.field("fields", &self.fields); + formatter.field("semi_token", &self.semi_token); + formatter.finish() + } + } + self.debug(formatter, "DataStruct") } } #[cfg(feature = "derive")] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Debug for DataUnion { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let mut formatter = formatter.debug_struct("DataUnion"); - formatter.field("union_token", &self.union_token); - formatter.field("fields", &self.fields); - formatter.finish() + impl DataUnion { + fn debug(&self, formatter: &mut fmt::Formatter, name: &str) -> fmt::Result { + let mut formatter = formatter.debug_struct(name); + formatter.field("union_token", &self.union_token); + formatter.field("fields", &self.fields); + formatter.finish() + } + } + self.debug(formatter, "DataUnion") } } #[cfg(feature = "derive")] @@ -356,238 +392,79 @@ impl Debug for DeriveInput { #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Debug for Expr { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("Expr::")?; match self { #[cfg(feature = "full")] - Expr::Array(v0) => { - let mut formatter = formatter.debug_tuple("Array"); - formatter.field(v0); - formatter.finish() - } + Expr::Array(v0) => v0.debug(formatter, "Array"), #[cfg(feature = "full")] - Expr::Assign(v0) => { - let mut formatter = formatter.debug_tuple("Assign"); - formatter.field(v0); - formatter.finish() - } + Expr::Assign(v0) => v0.debug(formatter, "Assign"), #[cfg(feature = "full")] - Expr::AssignOp(v0) => { - let mut formatter = formatter.debug_tuple("AssignOp"); - formatter.field(v0); - formatter.finish() - } + Expr::Async(v0) => v0.debug(formatter, "Async"), #[cfg(feature = "full")] - Expr::Async(v0) => { - let mut formatter = formatter.debug_tuple("Async"); - formatter.field(v0); - formatter.finish() - } + Expr::Await(v0) => v0.debug(formatter, "Await"), + Expr::Binary(v0) => v0.debug(formatter, "Binary"), #[cfg(feature = "full")] - Expr::Await(v0) => { - let mut formatter = formatter.debug_tuple("Await"); - formatter.field(v0); - formatter.finish() - } - Expr::Binary(v0) => { - let mut formatter = formatter.debug_tuple("Binary"); - formatter.field(v0); - formatter.finish() - } + Expr::Block(v0) => v0.debug(formatter, "Block"), #[cfg(feature = "full")] - Expr::Block(v0) => { - let mut formatter = formatter.debug_tuple("Block"); - formatter.field(v0); - formatter.finish() - } + Expr::Break(v0) => v0.debug(formatter, "Break"), + Expr::Call(v0) => v0.debug(formatter, "Call"), + Expr::Cast(v0) => v0.debug(formatter, "Cast"), #[cfg(feature = "full")] - Expr::Box(v0) => { - let mut formatter = formatter.debug_tuple("Box"); - formatter.field(v0); - formatter.finish() - } + Expr::Closure(v0) => v0.debug(formatter, "Closure"), #[cfg(feature = "full")] - Expr::Break(v0) => { - let mut formatter = formatter.debug_tuple("Break"); - formatter.field(v0); - formatter.finish() - } - Expr::Call(v0) => { - let mut formatter = formatter.debug_tuple("Call"); - formatter.field(v0); - formatter.finish() - } - Expr::Cast(v0) => { - let mut formatter = formatter.debug_tuple("Cast"); - formatter.field(v0); - formatter.finish() - } + Expr::Const(v0) => v0.debug(formatter, "Const"), #[cfg(feature = "full")] - Expr::Closure(v0) => { - let mut formatter = formatter.debug_tuple("Closure"); - formatter.field(v0); - formatter.finish() - } + Expr::Continue(v0) => v0.debug(formatter, "Continue"), + Expr::Field(v0) => v0.debug(formatter, "Field"), #[cfg(feature = "full")] - Expr::Continue(v0) => { - let mut formatter = formatter.debug_tuple("Continue"); - formatter.field(v0); - formatter.finish() - } - Expr::Field(v0) => { - let mut formatter = formatter.debug_tuple("Field"); - formatter.field(v0); - formatter.finish() - } + Expr::ForLoop(v0) => v0.debug(formatter, "ForLoop"), + Expr::Group(v0) => v0.debug(formatter, "Group"), #[cfg(feature = "full")] - Expr::ForLoop(v0) => { - let mut formatter = formatter.debug_tuple("ForLoop"); - formatter.field(v0); - formatter.finish() - } + Expr::If(v0) => v0.debug(formatter, "If"), + Expr::Index(v0) => v0.debug(formatter, "Index"), #[cfg(feature = "full")] - Expr::Group(v0) => { - let mut formatter = formatter.debug_tuple("Group"); - formatter.field(v0); - formatter.finish() - } + Expr::Infer(v0) => v0.debug(formatter, "Infer"), #[cfg(feature = "full")] - Expr::If(v0) => { - let mut formatter = formatter.debug_tuple("If"); - formatter.field(v0); - formatter.finish() - } - Expr::Index(v0) => { - let mut formatter = formatter.debug_tuple("Index"); - formatter.field(v0); - formatter.finish() - } + Expr::Let(v0) => v0.debug(formatter, "Let"), + Expr::Lit(v0) => v0.debug(formatter, "Lit"), #[cfg(feature = "full")] - Expr::Let(v0) => { - let mut formatter = formatter.debug_tuple("Let"); - formatter.field(v0); - formatter.finish() - } - Expr::Lit(v0) => { - let mut formatter = formatter.debug_tuple("Lit"); - formatter.field(v0); - formatter.finish() - } + Expr::Loop(v0) => v0.debug(formatter, "Loop"), + Expr::Macro(v0) => v0.debug(formatter, "Macro"), #[cfg(feature = "full")] - Expr::Loop(v0) => { - let mut formatter = formatter.debug_tuple("Loop"); - formatter.field(v0); - formatter.finish() - } + Expr::Match(v0) => v0.debug(formatter, "Match"), #[cfg(feature = "full")] - Expr::Macro(v0) => { - let mut formatter = formatter.debug_tuple("Macro"); - formatter.field(v0); - formatter.finish() - } + Expr::MethodCall(v0) => v0.debug(formatter, "MethodCall"), + Expr::Paren(v0) => v0.debug(formatter, "Paren"), + Expr::Path(v0) => v0.debug(formatter, "Path"), #[cfg(feature = "full")] - Expr::Match(v0) => { - let mut formatter = formatter.debug_tuple("Match"); - formatter.field(v0); - formatter.finish() - } + Expr::Range(v0) => v0.debug(formatter, "Range"), #[cfg(feature = "full")] - Expr::MethodCall(v0) => { - let mut formatter = formatter.debug_tuple("MethodCall"); - formatter.field(v0); - formatter.finish() - } - Expr::Paren(v0) => { - let mut formatter = formatter.debug_tuple("Paren"); - formatter.field(v0); - formatter.finish() - } - Expr::Path(v0) => { - let mut formatter = formatter.debug_tuple("Path"); - formatter.field(v0); - formatter.finish() - } + Expr::Reference(v0) => v0.debug(formatter, "Reference"), #[cfg(feature = "full")] - Expr::Range(v0) => { - let mut formatter = formatter.debug_tuple("Range"); - formatter.field(v0); - formatter.finish() - } + Expr::Repeat(v0) => v0.debug(formatter, "Repeat"), #[cfg(feature = "full")] - Expr::Reference(v0) => { - let mut formatter = formatter.debug_tuple("Reference"); - formatter.field(v0); - formatter.finish() - } + Expr::Return(v0) => v0.debug(formatter, "Return"), #[cfg(feature = "full")] - Expr::Repeat(v0) => { - let mut formatter = formatter.debug_tuple("Repeat"); - formatter.field(v0); - formatter.finish() - } - #[cfg(feature = "full")] - Expr::Return(v0) => { - let mut formatter = formatter.debug_tuple("Return"); - formatter.field(v0); - formatter.finish() - } - #[cfg(feature = "full")] - Expr::Struct(v0) => { - let mut formatter = formatter.debug_tuple("Struct"); - formatter.field(v0); - formatter.finish() - } - #[cfg(feature = "full")] - Expr::Try(v0) => { - let mut formatter = formatter.debug_tuple("Try"); - formatter.field(v0); - formatter.finish() - } + Expr::Struct(v0) => v0.debug(formatter, "Struct"), #[cfg(feature = "full")] - Expr::TryBlock(v0) => { - let mut formatter = formatter.debug_tuple("TryBlock"); - formatter.field(v0); - formatter.finish() - } + Expr::Try(v0) => v0.debug(formatter, "Try"), #[cfg(feature = "full")] - Expr::Tuple(v0) => { - let mut formatter = formatter.debug_tuple("Tuple"); - formatter.field(v0); - formatter.finish() - } + Expr::TryBlock(v0) => v0.debug(formatter, "TryBlock"), #[cfg(feature = "full")] - Expr::Type(v0) => { - let mut formatter = formatter.debug_tuple("Type"); - formatter.field(v0); - formatter.finish() - } - Expr::Unary(v0) => { - let mut formatter = formatter.debug_tuple("Unary"); - formatter.field(v0); - formatter.finish() - } + Expr::Tuple(v0) => v0.debug(formatter, "Tuple"), + Expr::Unary(v0) => v0.debug(formatter, "Unary"), #[cfg(feature = "full")] - Expr::Unsafe(v0) => { - let mut formatter = formatter.debug_tuple("Unsafe"); - formatter.field(v0); - formatter.finish() - } + Expr::Unsafe(v0) => v0.debug(formatter, "Unsafe"), Expr::Verbatim(v0) => { let mut formatter = formatter.debug_tuple("Verbatim"); formatter.field(v0); formatter.finish() } #[cfg(feature = "full")] - Expr::While(v0) => { - let mut formatter = formatter.debug_tuple("While"); - formatter.field(v0); - formatter.finish() - } + Expr::While(v0) => v0.debug(formatter, "While"), #[cfg(feature = "full")] - Expr::Yield(v0) => { - let mut formatter = formatter.debug_tuple("Yield"); - formatter.field(v0); - formatter.finish() - } - #[cfg(any(syn_no_non_exhaustive, not(feature = "full")))] + Expr::Yield(v0) => v0.debug(formatter, "Yield"), + #[cfg(not(feature = "full"))] _ => unreachable!(), } } @@ -596,469 +473,647 @@ impl Debug for Expr { #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Debug for ExprArray { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let mut formatter = formatter.debug_struct("ExprArray"); - formatter.field("attrs", &self.attrs); - formatter.field("bracket_token", &self.bracket_token); - formatter.field("elems", &self.elems); - formatter.finish() + impl ExprArray { + fn debug(&self, formatter: &mut fmt::Formatter, name: &str) -> fmt::Result { + let mut formatter = formatter.debug_struct(name); + formatter.field("attrs", &self.attrs); + formatter.field("bracket_token", &self.bracket_token); + formatter.field("elems", &self.elems); + formatter.finish() + } + } + self.debug(formatter, "ExprArray") } } #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Debug for ExprAssign { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let mut formatter = formatter.debug_struct("ExprAssign"); - formatter.field("attrs", &self.attrs); - formatter.field("left", &self.left); - formatter.field("eq_token", &self.eq_token); - formatter.field("right", &self.right); - formatter.finish() - } -} -#[cfg(feature = "full")] -#[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] -impl Debug for ExprAssignOp { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let mut formatter = formatter.debug_struct("ExprAssignOp"); - formatter.field("attrs", &self.attrs); - formatter.field("left", &self.left); - formatter.field("op", &self.op); - formatter.field("right", &self.right); - formatter.finish() + impl ExprAssign { + fn debug(&self, formatter: &mut fmt::Formatter, name: &str) -> fmt::Result { + let mut formatter = formatter.debug_struct(name); + formatter.field("attrs", &self.attrs); + formatter.field("left", &self.left); + formatter.field("eq_token", &self.eq_token); + formatter.field("right", &self.right); + formatter.finish() + } + } + self.debug(formatter, "ExprAssign") } } #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Debug for ExprAsync { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let mut formatter = formatter.debug_struct("ExprAsync"); - formatter.field("attrs", &self.attrs); - formatter.field("async_token", &self.async_token); - formatter.field("capture", &self.capture); - formatter.field("block", &self.block); - formatter.finish() + impl ExprAsync { + fn debug(&self, formatter: &mut fmt::Formatter, name: &str) -> fmt::Result { + let mut formatter = formatter.debug_struct(name); + formatter.field("attrs", &self.attrs); + formatter.field("async_token", &self.async_token); + formatter.field("capture", &self.capture); + formatter.field("block", &self.block); + formatter.finish() + } + } + self.debug(formatter, "ExprAsync") } } #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Debug for ExprAwait { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let mut formatter = formatter.debug_struct("ExprAwait"); - formatter.field("attrs", &self.attrs); - formatter.field("base", &self.base); - formatter.field("dot_token", &self.dot_token); - formatter.field("await_token", &self.await_token); - formatter.finish() + impl ExprAwait { + fn debug(&self, formatter: &mut fmt::Formatter, name: &str) -> fmt::Result { + let mut formatter = formatter.debug_struct(name); + formatter.field("attrs", &self.attrs); + formatter.field("base", &self.base); + formatter.field("dot_token", &self.dot_token); + formatter.field("await_token", &self.await_token); + formatter.finish() + } + } + self.debug(formatter, "ExprAwait") } } #[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Debug for ExprBinary { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let mut formatter = formatter.debug_struct("ExprBinary"); - formatter.field("attrs", &self.attrs); - formatter.field("left", &self.left); - formatter.field("op", &self.op); - formatter.field("right", &self.right); - formatter.finish() + impl ExprBinary { + fn debug(&self, formatter: &mut fmt::Formatter, name: &str) -> fmt::Result { + let mut formatter = formatter.debug_struct(name); + formatter.field("attrs", &self.attrs); + formatter.field("left", &self.left); + formatter.field("op", &self.op); + formatter.field("right", &self.right); + formatter.finish() + } + } + self.debug(formatter, "ExprBinary") } } #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Debug for ExprBlock { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let mut formatter = formatter.debug_struct("ExprBlock"); - formatter.field("attrs", &self.attrs); - formatter.field("label", &self.label); - formatter.field("block", &self.block); - formatter.finish() - } -} -#[cfg(feature = "full")] -#[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] -impl Debug for ExprBox { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let mut formatter = formatter.debug_struct("ExprBox"); - formatter.field("attrs", &self.attrs); - formatter.field("box_token", &self.box_token); - formatter.field("expr", &self.expr); - formatter.finish() + impl ExprBlock { + fn debug(&self, formatter: &mut fmt::Formatter, name: &str) -> fmt::Result { + let mut formatter = formatter.debug_struct(name); + formatter.field("attrs", &self.attrs); + formatter.field("label", &self.label); + formatter.field("block", &self.block); + formatter.finish() + } + } + self.debug(formatter, "ExprBlock") } } #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Debug for ExprBreak { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let mut formatter = formatter.debug_struct("ExprBreak"); - formatter.field("attrs", &self.attrs); - formatter.field("break_token", &self.break_token); - formatter.field("label", &self.label); - formatter.field("expr", &self.expr); - formatter.finish() + impl ExprBreak { + fn debug(&self, formatter: &mut fmt::Formatter, name: &str) -> fmt::Result { + let mut formatter = formatter.debug_struct(name); + formatter.field("attrs", &self.attrs); + formatter.field("break_token", &self.break_token); + formatter.field("label", &self.label); + formatter.field("expr", &self.expr); + formatter.finish() + } + } + self.debug(formatter, "ExprBreak") } } #[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Debug for ExprCall { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let mut formatter = formatter.debug_struct("ExprCall"); - formatter.field("attrs", &self.attrs); - formatter.field("func", &self.func); - formatter.field("paren_token", &self.paren_token); - formatter.field("args", &self.args); - formatter.finish() + impl ExprCall { + fn debug(&self, formatter: &mut fmt::Formatter, name: &str) -> fmt::Result { + let mut formatter = formatter.debug_struct(name); + formatter.field("attrs", &self.attrs); + formatter.field("func", &self.func); + formatter.field("paren_token", &self.paren_token); + formatter.field("args", &self.args); + formatter.finish() + } + } + self.debug(formatter, "ExprCall") } } #[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Debug for ExprCast { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let mut formatter = formatter.debug_struct("ExprCast"); - formatter.field("attrs", &self.attrs); - formatter.field("expr", &self.expr); - formatter.field("as_token", &self.as_token); - formatter.field("ty", &self.ty); - formatter.finish() + impl ExprCast { + fn debug(&self, formatter: &mut fmt::Formatter, name: &str) -> fmt::Result { + let mut formatter = formatter.debug_struct(name); + formatter.field("attrs", &self.attrs); + formatter.field("expr", &self.expr); + formatter.field("as_token", &self.as_token); + formatter.field("ty", &self.ty); + formatter.finish() + } + } + self.debug(formatter, "ExprCast") } } #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Debug for ExprClosure { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let mut formatter = formatter.debug_struct("ExprClosure"); - formatter.field("attrs", &self.attrs); - formatter.field("movability", &self.movability); - formatter.field("asyncness", &self.asyncness); - formatter.field("capture", &self.capture); - formatter.field("or1_token", &self.or1_token); - formatter.field("inputs", &self.inputs); - formatter.field("or2_token", &self.or2_token); - formatter.field("output", &self.output); - formatter.field("body", &self.body); - formatter.finish() + impl ExprClosure { + fn debug(&self, formatter: &mut fmt::Formatter, name: &str) -> fmt::Result { + let mut formatter = formatter.debug_struct(name); + formatter.field("attrs", &self.attrs); + formatter.field("lifetimes", &self.lifetimes); + formatter.field("constness", &self.constness); + formatter.field("movability", &self.movability); + formatter.field("asyncness", &self.asyncness); + formatter.field("capture", &self.capture); + formatter.field("or1_token", &self.or1_token); + formatter.field("inputs", &self.inputs); + formatter.field("or2_token", &self.or2_token); + formatter.field("output", &self.output); + formatter.field("body", &self.body); + formatter.finish() + } + } + self.debug(formatter, "ExprClosure") + } +} +#[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] +impl Debug for ExprConst { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + impl ExprConst { + fn debug(&self, formatter: &mut fmt::Formatter, name: &str) -> fmt::Result { + let mut formatter = formatter.debug_struct(name); + formatter.field("attrs", &self.attrs); + formatter.field("const_token", &self.const_token); + formatter.field("block", &self.block); + formatter.finish() + } + } + self.debug(formatter, "ExprConst") } } #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Debug for ExprContinue { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let mut formatter = formatter.debug_struct("ExprContinue"); - formatter.field("attrs", &self.attrs); - formatter.field("continue_token", &self.continue_token); - formatter.field("label", &self.label); - formatter.finish() + impl ExprContinue { + fn debug(&self, formatter: &mut fmt::Formatter, name: &str) -> fmt::Result { + let mut formatter = formatter.debug_struct(name); + formatter.field("attrs", &self.attrs); + formatter.field("continue_token", &self.continue_token); + formatter.field("label", &self.label); + formatter.finish() + } + } + self.debug(formatter, "ExprContinue") } } #[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Debug for ExprField { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let mut formatter = formatter.debug_struct("ExprField"); - formatter.field("attrs", &self.attrs); - formatter.field("base", &self.base); - formatter.field("dot_token", &self.dot_token); - formatter.field("member", &self.member); - formatter.finish() + impl ExprField { + fn debug(&self, formatter: &mut fmt::Formatter, name: &str) -> fmt::Result { + let mut formatter = formatter.debug_struct(name); + formatter.field("attrs", &self.attrs); + formatter.field("base", &self.base); + formatter.field("dot_token", &self.dot_token); + formatter.field("member", &self.member); + formatter.finish() + } + } + self.debug(formatter, "ExprField") } } #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Debug for ExprForLoop { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let mut formatter = formatter.debug_struct("ExprForLoop"); - formatter.field("attrs", &self.attrs); - formatter.field("label", &self.label); - formatter.field("for_token", &self.for_token); - formatter.field("pat", &self.pat); - formatter.field("in_token", &self.in_token); - formatter.field("expr", &self.expr); - formatter.field("body", &self.body); - formatter.finish() + impl ExprForLoop { + fn debug(&self, formatter: &mut fmt::Formatter, name: &str) -> fmt::Result { + let mut formatter = formatter.debug_struct(name); + formatter.field("attrs", &self.attrs); + formatter.field("label", &self.label); + formatter.field("for_token", &self.for_token); + formatter.field("pat", &self.pat); + formatter.field("in_token", &self.in_token); + formatter.field("expr", &self.expr); + formatter.field("body", &self.body); + formatter.finish() + } + } + self.debug(formatter, "ExprForLoop") } } -#[cfg(feature = "full")] +#[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Debug for ExprGroup { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let mut formatter = formatter.debug_struct("ExprGroup"); - formatter.field("attrs", &self.attrs); - formatter.field("group_token", &self.group_token); - formatter.field("expr", &self.expr); - formatter.finish() + impl ExprGroup { + fn debug(&self, formatter: &mut fmt::Formatter, name: &str) -> fmt::Result { + let mut formatter = formatter.debug_struct(name); + formatter.field("attrs", &self.attrs); + formatter.field("group_token", &self.group_token); + formatter.field("expr", &self.expr); + formatter.finish() + } + } + self.debug(formatter, "ExprGroup") } } #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Debug for ExprIf { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let mut formatter = formatter.debug_struct("ExprIf"); - formatter.field("attrs", &self.attrs); - formatter.field("if_token", &self.if_token); - formatter.field("cond", &self.cond); - formatter.field("then_branch", &self.then_branch); - formatter.field("else_branch", &self.else_branch); - formatter.finish() + impl ExprIf { + fn debug(&self, formatter: &mut fmt::Formatter, name: &str) -> fmt::Result { + let mut formatter = formatter.debug_struct(name); + formatter.field("attrs", &self.attrs); + formatter.field("if_token", &self.if_token); + formatter.field("cond", &self.cond); + formatter.field("then_branch", &self.then_branch); + formatter.field("else_branch", &self.else_branch); + formatter.finish() + } + } + self.debug(formatter, "ExprIf") } } #[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Debug for ExprIndex { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let mut formatter = formatter.debug_struct("ExprIndex"); - formatter.field("attrs", &self.attrs); - formatter.field("expr", &self.expr); - formatter.field("bracket_token", &self.bracket_token); - formatter.field("index", &self.index); - formatter.finish() + impl ExprIndex { + fn debug(&self, formatter: &mut fmt::Formatter, name: &str) -> fmt::Result { + let mut formatter = formatter.debug_struct(name); + formatter.field("attrs", &self.attrs); + formatter.field("expr", &self.expr); + formatter.field("bracket_token", &self.bracket_token); + formatter.field("index", &self.index); + formatter.finish() + } + } + self.debug(formatter, "ExprIndex") + } +} +#[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] +impl Debug for ExprInfer { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + impl ExprInfer { + fn debug(&self, formatter: &mut fmt::Formatter, name: &str) -> fmt::Result { + let mut formatter = formatter.debug_struct(name); + formatter.field("attrs", &self.attrs); + formatter.field("underscore_token", &self.underscore_token); + formatter.finish() + } + } + self.debug(formatter, "ExprInfer") } } #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Debug for ExprLet { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let mut formatter = formatter.debug_struct("ExprLet"); - formatter.field("attrs", &self.attrs); - formatter.field("let_token", &self.let_token); - formatter.field("pat", &self.pat); - formatter.field("eq_token", &self.eq_token); - formatter.field("expr", &self.expr); - formatter.finish() + impl ExprLet { + fn debug(&self, formatter: &mut fmt::Formatter, name: &str) -> fmt::Result { + let mut formatter = formatter.debug_struct(name); + formatter.field("attrs", &self.attrs); + formatter.field("let_token", &self.let_token); + formatter.field("pat", &self.pat); + formatter.field("eq_token", &self.eq_token); + formatter.field("expr", &self.expr); + formatter.finish() + } + } + self.debug(formatter, "ExprLet") } } #[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Debug for ExprLit { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let mut formatter = formatter.debug_struct("ExprLit"); - formatter.field("attrs", &self.attrs); - formatter.field("lit", &self.lit); - formatter.finish() + impl ExprLit { + fn debug(&self, formatter: &mut fmt::Formatter, name: &str) -> fmt::Result { + let mut formatter = formatter.debug_struct(name); + formatter.field("attrs", &self.attrs); + formatter.field("lit", &self.lit); + formatter.finish() + } + } + self.debug(formatter, "ExprLit") } } #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Debug for ExprLoop { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let mut formatter = formatter.debug_struct("ExprLoop"); - formatter.field("attrs", &self.attrs); - formatter.field("label", &self.label); - formatter.field("loop_token", &self.loop_token); - formatter.field("body", &self.body); - formatter.finish() + impl ExprLoop { + fn debug(&self, formatter: &mut fmt::Formatter, name: &str) -> fmt::Result { + let mut formatter = formatter.debug_struct(name); + formatter.field("attrs", &self.attrs); + formatter.field("label", &self.label); + formatter.field("loop_token", &self.loop_token); + formatter.field("body", &self.body); + formatter.finish() + } + } + self.debug(formatter, "ExprLoop") } } -#[cfg(feature = "full")] +#[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Debug for ExprMacro { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let mut formatter = formatter.debug_struct("ExprMacro"); - formatter.field("attrs", &self.attrs); - formatter.field("mac", &self.mac); - formatter.finish() + impl ExprMacro { + fn debug(&self, formatter: &mut fmt::Formatter, name: &str) -> fmt::Result { + let mut formatter = formatter.debug_struct(name); + formatter.field("attrs", &self.attrs); + formatter.field("mac", &self.mac); + formatter.finish() + } + } + self.debug(formatter, "ExprMacro") } } #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Debug for ExprMatch { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let mut formatter = formatter.debug_struct("ExprMatch"); - formatter.field("attrs", &self.attrs); - formatter.field("match_token", &self.match_token); - formatter.field("expr", &self.expr); - formatter.field("brace_token", &self.brace_token); - formatter.field("arms", &self.arms); - formatter.finish() + impl ExprMatch { + fn debug(&self, formatter: &mut fmt::Formatter, name: &str) -> fmt::Result { + let mut formatter = formatter.debug_struct(name); + formatter.field("attrs", &self.attrs); + formatter.field("match_token", &self.match_token); + formatter.field("expr", &self.expr); + formatter.field("brace_token", &self.brace_token); + formatter.field("arms", &self.arms); + formatter.finish() + } + } + self.debug(formatter, "ExprMatch") } } #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Debug for ExprMethodCall { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let mut formatter = formatter.debug_struct("ExprMethodCall"); - formatter.field("attrs", &self.attrs); - formatter.field("receiver", &self.receiver); - formatter.field("dot_token", &self.dot_token); - formatter.field("method", &self.method); - formatter.field("turbofish", &self.turbofish); - formatter.field("paren_token", &self.paren_token); - formatter.field("args", &self.args); - formatter.finish() + impl ExprMethodCall { + fn debug(&self, formatter: &mut fmt::Formatter, name: &str) -> fmt::Result { + let mut formatter = formatter.debug_struct(name); + formatter.field("attrs", &self.attrs); + formatter.field("receiver", &self.receiver); + formatter.field("dot_token", &self.dot_token); + formatter.field("method", &self.method); + formatter.field("turbofish", &self.turbofish); + formatter.field("paren_token", &self.paren_token); + formatter.field("args", &self.args); + formatter.finish() + } + } + self.debug(formatter, "ExprMethodCall") } } #[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Debug for ExprParen { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let mut formatter = formatter.debug_struct("ExprParen"); - formatter.field("attrs", &self.attrs); - formatter.field("paren_token", &self.paren_token); - formatter.field("expr", &self.expr); - formatter.finish() + impl ExprParen { + fn debug(&self, formatter: &mut fmt::Formatter, name: &str) -> fmt::Result { + let mut formatter = formatter.debug_struct(name); + formatter.field("attrs", &self.attrs); + formatter.field("paren_token", &self.paren_token); + formatter.field("expr", &self.expr); + formatter.finish() + } + } + self.debug(formatter, "ExprParen") } } #[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Debug for ExprPath { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let mut formatter = formatter.debug_struct("ExprPath"); - formatter.field("attrs", &self.attrs); - formatter.field("qself", &self.qself); - formatter.field("path", &self.path); - formatter.finish() + impl ExprPath { + fn debug(&self, formatter: &mut fmt::Formatter, name: &str) -> fmt::Result { + let mut formatter = formatter.debug_struct(name); + formatter.field("attrs", &self.attrs); + formatter.field("qself", &self.qself); + formatter.field("path", &self.path); + formatter.finish() + } + } + self.debug(formatter, "ExprPath") } } #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Debug for ExprRange { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let mut formatter = formatter.debug_struct("ExprRange"); - formatter.field("attrs", &self.attrs); - formatter.field("from", &self.from); - formatter.field("limits", &self.limits); - formatter.field("to", &self.to); - formatter.finish() + impl ExprRange { + fn debug(&self, formatter: &mut fmt::Formatter, name: &str) -> fmt::Result { + let mut formatter = formatter.debug_struct(name); + formatter.field("attrs", &self.attrs); + formatter.field("start", &self.start); + formatter.field("limits", &self.limits); + formatter.field("end", &self.end); + formatter.finish() + } + } + self.debug(formatter, "ExprRange") } } #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Debug for ExprReference { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let mut formatter = formatter.debug_struct("ExprReference"); - formatter.field("attrs", &self.attrs); - formatter.field("and_token", &self.and_token); - formatter.field("raw", &self.raw); - formatter.field("mutability", &self.mutability); - formatter.field("expr", &self.expr); - formatter.finish() + impl ExprReference { + fn debug(&self, formatter: &mut fmt::Formatter, name: &str) -> fmt::Result { + let mut formatter = formatter.debug_struct(name); + formatter.field("attrs", &self.attrs); + formatter.field("and_token", &self.and_token); + formatter.field("mutability", &self.mutability); + formatter.field("expr", &self.expr); + formatter.finish() + } + } + self.debug(formatter, "ExprReference") } } #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Debug for ExprRepeat { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let mut formatter = formatter.debug_struct("ExprRepeat"); - formatter.field("attrs", &self.attrs); - formatter.field("bracket_token", &self.bracket_token); - formatter.field("expr", &self.expr); - formatter.field("semi_token", &self.semi_token); - formatter.field("len", &self.len); - formatter.finish() + impl ExprRepeat { + fn debug(&self, formatter: &mut fmt::Formatter, name: &str) -> fmt::Result { + let mut formatter = formatter.debug_struct(name); + formatter.field("attrs", &self.attrs); + formatter.field("bracket_token", &self.bracket_token); + formatter.field("expr", &self.expr); + formatter.field("semi_token", &self.semi_token); + formatter.field("len", &self.len); + formatter.finish() + } + } + self.debug(formatter, "ExprRepeat") } } #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Debug for ExprReturn { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let mut formatter = formatter.debug_struct("ExprReturn"); - formatter.field("attrs", &self.attrs); - formatter.field("return_token", &self.return_token); - formatter.field("expr", &self.expr); - formatter.finish() + impl ExprReturn { + fn debug(&self, formatter: &mut fmt::Formatter, name: &str) -> fmt::Result { + let mut formatter = formatter.debug_struct(name); + formatter.field("attrs", &self.attrs); + formatter.field("return_token", &self.return_token); + formatter.field("expr", &self.expr); + formatter.finish() + } + } + self.debug(formatter, "ExprReturn") } } #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Debug for ExprStruct { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let mut formatter = formatter.debug_struct("ExprStruct"); - formatter.field("attrs", &self.attrs); - formatter.field("path", &self.path); - formatter.field("brace_token", &self.brace_token); - formatter.field("fields", &self.fields); - formatter.field("dot2_token", &self.dot2_token); - formatter.field("rest", &self.rest); - formatter.finish() + impl ExprStruct { + fn debug(&self, formatter: &mut fmt::Formatter, name: &str) -> fmt::Result { + let mut formatter = formatter.debug_struct(name); + formatter.field("attrs", &self.attrs); + formatter.field("qself", &self.qself); + formatter.field("path", &self.path); + formatter.field("brace_token", &self.brace_token); + formatter.field("fields", &self.fields); + formatter.field("dot2_token", &self.dot2_token); + formatter.field("rest", &self.rest); + formatter.finish() + } + } + self.debug(formatter, "ExprStruct") } } #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Debug for ExprTry { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let mut formatter = formatter.debug_struct("ExprTry"); - formatter.field("attrs", &self.attrs); - formatter.field("expr", &self.expr); - formatter.field("question_token", &self.question_token); - formatter.finish() + impl ExprTry { + fn debug(&self, formatter: &mut fmt::Formatter, name: &str) -> fmt::Result { + let mut formatter = formatter.debug_struct(name); + formatter.field("attrs", &self.attrs); + formatter.field("expr", &self.expr); + formatter.field("question_token", &self.question_token); + formatter.finish() + } + } + self.debug(formatter, "ExprTry") } } #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Debug for ExprTryBlock { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let mut formatter = formatter.debug_struct("ExprTryBlock"); - formatter.field("attrs", &self.attrs); - formatter.field("try_token", &self.try_token); - formatter.field("block", &self.block); - formatter.finish() + impl ExprTryBlock { + fn debug(&self, formatter: &mut fmt::Formatter, name: &str) -> fmt::Result { + let mut formatter = formatter.debug_struct(name); + formatter.field("attrs", &self.attrs); + formatter.field("try_token", &self.try_token); + formatter.field("block", &self.block); + formatter.finish() + } + } + self.debug(formatter, "ExprTryBlock") } } #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Debug for ExprTuple { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let mut formatter = formatter.debug_struct("ExprTuple"); - formatter.field("attrs", &self.attrs); - formatter.field("paren_token", &self.paren_token); - formatter.field("elems", &self.elems); - formatter.finish() - } -} -#[cfg(feature = "full")] -#[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] -impl Debug for ExprType { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let mut formatter = formatter.debug_struct("ExprType"); - formatter.field("attrs", &self.attrs); - formatter.field("expr", &self.expr); - formatter.field("colon_token", &self.colon_token); - formatter.field("ty", &self.ty); - formatter.finish() + impl ExprTuple { + fn debug(&self, formatter: &mut fmt::Formatter, name: &str) -> fmt::Result { + let mut formatter = formatter.debug_struct(name); + formatter.field("attrs", &self.attrs); + formatter.field("paren_token", &self.paren_token); + formatter.field("elems", &self.elems); + formatter.finish() + } + } + self.debug(formatter, "ExprTuple") } } #[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Debug for ExprUnary { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let mut formatter = formatter.debug_struct("ExprUnary"); - formatter.field("attrs", &self.attrs); - formatter.field("op", &self.op); - formatter.field("expr", &self.expr); - formatter.finish() + impl ExprUnary { + fn debug(&self, formatter: &mut fmt::Formatter, name: &str) -> fmt::Result { + let mut formatter = formatter.debug_struct(name); + formatter.field("attrs", &self.attrs); + formatter.field("op", &self.op); + formatter.field("expr", &self.expr); + formatter.finish() + } + } + self.debug(formatter, "ExprUnary") } } #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Debug for ExprUnsafe { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let mut formatter = formatter.debug_struct("ExprUnsafe"); - formatter.field("attrs", &self.attrs); - formatter.field("unsafe_token", &self.unsafe_token); - formatter.field("block", &self.block); - formatter.finish() + impl ExprUnsafe { + fn debug(&self, formatter: &mut fmt::Formatter, name: &str) -> fmt::Result { + let mut formatter = formatter.debug_struct(name); + formatter.field("attrs", &self.attrs); + formatter.field("unsafe_token", &self.unsafe_token); + formatter.field("block", &self.block); + formatter.finish() + } + } + self.debug(formatter, "ExprUnsafe") } } #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Debug for ExprWhile { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let mut formatter = formatter.debug_struct("ExprWhile"); - formatter.field("attrs", &self.attrs); - formatter.field("label", &self.label); - formatter.field("while_token", &self.while_token); - formatter.field("cond", &self.cond); - formatter.field("body", &self.body); - formatter.finish() + impl ExprWhile { + fn debug(&self, formatter: &mut fmt::Formatter, name: &str) -> fmt::Result { + let mut formatter = formatter.debug_struct(name); + formatter.field("attrs", &self.attrs); + formatter.field("label", &self.label); + formatter.field("while_token", &self.while_token); + formatter.field("cond", &self.cond); + formatter.field("body", &self.body); + formatter.finish() + } + } + self.debug(formatter, "ExprWhile") } } #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Debug for ExprYield { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let mut formatter = formatter.debug_struct("ExprYield"); - formatter.field("attrs", &self.attrs); - formatter.field("yield_token", &self.yield_token); - formatter.field("expr", &self.expr); - formatter.finish() + impl ExprYield { + fn debug(&self, formatter: &mut fmt::Formatter, name: &str) -> fmt::Result { + let mut formatter = formatter.debug_struct(name); + formatter.field("attrs", &self.attrs); + formatter.field("yield_token", &self.yield_token); + formatter.field("expr", &self.expr); + formatter.finish() + } + } + self.debug(formatter, "ExprYield") } } #[cfg(any(feature = "derive", feature = "full"))] @@ -1068,12 +1123,23 @@ impl Debug for Field { let mut formatter = formatter.debug_struct("Field"); formatter.field("attrs", &self.attrs); formatter.field("vis", &self.vis); + formatter.field("mutability", &self.mutability); formatter.field("ident", &self.ident); formatter.field("colon_token", &self.colon_token); formatter.field("ty", &self.ty); formatter.finish() } } +#[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] +impl Debug for FieldMutability { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("FieldMutability::")?; + match self { + FieldMutability::None => formatter.write_str("None"), + } + } +} #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Debug for FieldPat { @@ -1102,17 +1168,10 @@ impl Debug for FieldValue { #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Debug for Fields { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("Fields::")?; match self { - Fields::Named(v0) => { - let mut formatter = formatter.debug_tuple("Named"); - formatter.field(v0); - formatter.finish() - } - Fields::Unnamed(v0) => { - let mut formatter = formatter.debug_tuple("Unnamed"); - formatter.field(v0); - formatter.finish() - } + Fields::Named(v0) => v0.debug(formatter, "Named"), + Fields::Unnamed(v0) => v0.debug(formatter, "Unnamed"), Fields::Unit => formatter.write_str("Unit"), } } @@ -1121,20 +1180,30 @@ impl Debug for Fields { #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Debug for FieldsNamed { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let mut formatter = formatter.debug_struct("FieldsNamed"); - formatter.field("brace_token", &self.brace_token); - formatter.field("named", &self.named); - formatter.finish() + impl FieldsNamed { + fn debug(&self, formatter: &mut fmt::Formatter, name: &str) -> fmt::Result { + let mut formatter = formatter.debug_struct(name); + formatter.field("brace_token", &self.brace_token); + formatter.field("named", &self.named); + formatter.finish() + } + } + self.debug(formatter, "FieldsNamed") } } #[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Debug for FieldsUnnamed { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let mut formatter = formatter.debug_struct("FieldsUnnamed"); - formatter.field("paren_token", &self.paren_token); - formatter.field("unnamed", &self.unnamed); - formatter.finish() + impl FieldsUnnamed { + fn debug(&self, formatter: &mut fmt::Formatter, name: &str) -> fmt::Result { + let mut formatter = formatter.debug_struct(name); + formatter.field("paren_token", &self.paren_token); + formatter.field("unnamed", &self.unnamed); + formatter.finish() + } + } + self.debug(formatter, "FieldsUnnamed") } } #[cfg(feature = "full")] @@ -1152,6 +1221,7 @@ impl Debug for File { #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Debug for FnArg { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("FnArg::")?; match self { FnArg::Receiver(v0) => { let mut formatter = formatter.debug_tuple("Receiver"); @@ -1170,34 +1240,17 @@ impl Debug for FnArg { #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Debug for ForeignItem { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("ForeignItem::")?; match self { - ForeignItem::Fn(v0) => { - let mut formatter = formatter.debug_tuple("Fn"); - formatter.field(v0); - formatter.finish() - } - ForeignItem::Static(v0) => { - let mut formatter = formatter.debug_tuple("Static"); - formatter.field(v0); - formatter.finish() - } - ForeignItem::Type(v0) => { - let mut formatter = formatter.debug_tuple("Type"); - formatter.field(v0); - formatter.finish() - } - ForeignItem::Macro(v0) => { - let mut formatter = formatter.debug_tuple("Macro"); - formatter.field(v0); - formatter.finish() - } + ForeignItem::Fn(v0) => v0.debug(formatter, "Fn"), + ForeignItem::Static(v0) => v0.debug(formatter, "Static"), + ForeignItem::Type(v0) => v0.debug(formatter, "Type"), + ForeignItem::Macro(v0) => v0.debug(formatter, "Macro"), ForeignItem::Verbatim(v0) => { let mut formatter = formatter.debug_tuple("Verbatim"); formatter.field(v0); formatter.finish() } - #[cfg(syn_no_non_exhaustive)] - _ => unreachable!(), } } } @@ -1205,58 +1258,80 @@ impl Debug for ForeignItem { #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Debug for ForeignItemFn { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let mut formatter = formatter.debug_struct("ForeignItemFn"); - formatter.field("attrs", &self.attrs); - formatter.field("vis", &self.vis); - formatter.field("sig", &self.sig); - formatter.field("semi_token", &self.semi_token); - formatter.finish() + impl ForeignItemFn { + fn debug(&self, formatter: &mut fmt::Formatter, name: &str) -> fmt::Result { + let mut formatter = formatter.debug_struct(name); + formatter.field("attrs", &self.attrs); + formatter.field("vis", &self.vis); + formatter.field("sig", &self.sig); + formatter.field("semi_token", &self.semi_token); + formatter.finish() + } + } + self.debug(formatter, "ForeignItemFn") } } #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Debug for ForeignItemMacro { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let mut formatter = formatter.debug_struct("ForeignItemMacro"); - formatter.field("attrs", &self.attrs); - formatter.field("mac", &self.mac); - formatter.field("semi_token", &self.semi_token); - formatter.finish() + impl ForeignItemMacro { + fn debug(&self, formatter: &mut fmt::Formatter, name: &str) -> fmt::Result { + let mut formatter = formatter.debug_struct(name); + formatter.field("attrs", &self.attrs); + formatter.field("mac", &self.mac); + formatter.field("semi_token", &self.semi_token); + formatter.finish() + } + } + self.debug(formatter, "ForeignItemMacro") } } #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Debug for ForeignItemStatic { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let mut formatter = formatter.debug_struct("ForeignItemStatic"); - formatter.field("attrs", &self.attrs); - formatter.field("vis", &self.vis); - formatter.field("static_token", &self.static_token); - formatter.field("mutability", &self.mutability); - formatter.field("ident", &self.ident); - formatter.field("colon_token", &self.colon_token); - formatter.field("ty", &self.ty); - formatter.field("semi_token", &self.semi_token); - formatter.finish() + impl ForeignItemStatic { + fn debug(&self, formatter: &mut fmt::Formatter, name: &str) -> fmt::Result { + let mut formatter = formatter.debug_struct(name); + formatter.field("attrs", &self.attrs); + formatter.field("vis", &self.vis); + formatter.field("static_token", &self.static_token); + formatter.field("mutability", &self.mutability); + formatter.field("ident", &self.ident); + formatter.field("colon_token", &self.colon_token); + formatter.field("ty", &self.ty); + formatter.field("semi_token", &self.semi_token); + formatter.finish() + } + } + self.debug(formatter, "ForeignItemStatic") } } #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Debug for ForeignItemType { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let mut formatter = formatter.debug_struct("ForeignItemType"); - formatter.field("attrs", &self.attrs); - formatter.field("vis", &self.vis); - formatter.field("type_token", &self.type_token); - formatter.field("ident", &self.ident); - formatter.field("semi_token", &self.semi_token); - formatter.finish() + impl ForeignItemType { + fn debug(&self, formatter: &mut fmt::Formatter, name: &str) -> fmt::Result { + let mut formatter = formatter.debug_struct(name); + formatter.field("attrs", &self.attrs); + formatter.field("vis", &self.vis); + formatter.field("type_token", &self.type_token); + formatter.field("ident", &self.ident); + formatter.field("generics", &self.generics); + formatter.field("semi_token", &self.semi_token); + formatter.finish() + } + } + self.debug(formatter, "ForeignItemType") } } #[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Debug for GenericArgument { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("GenericArgument::")?; match self { GenericArgument::Lifetime(v0) => { let mut formatter = formatter.debug_tuple("Lifetime"); @@ -1273,31 +1348,18 @@ impl Debug for GenericArgument { formatter.field(v0); formatter.finish() } - GenericArgument::Binding(v0) => { - let mut formatter = formatter.debug_tuple("Binding"); + GenericArgument::AssocType(v0) => { + let mut formatter = formatter.debug_tuple("AssocType"); formatter.field(v0); formatter.finish() } - GenericArgument::Constraint(v0) => { - let mut formatter = formatter.debug_tuple("Constraint"); - formatter.field(v0); - formatter.finish() - } - } - } -} -#[cfg(feature = "full")] -#[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] -impl Debug for GenericMethodArgument { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - match self { - GenericMethodArgument::Type(v0) => { - let mut formatter = formatter.debug_tuple("Type"); + GenericArgument::AssocConst(v0) => { + let mut formatter = formatter.debug_tuple("AssocConst"); formatter.field(v0); formatter.finish() } - GenericMethodArgument::Const(v0) => { - let mut formatter = formatter.debug_tuple("Const"); + GenericArgument::Constraint(v0) => { + let mut formatter = formatter.debug_tuple("Constraint"); formatter.field(v0); formatter.finish() } @@ -1308,14 +1370,15 @@ impl Debug for GenericMethodArgument { #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Debug for GenericParam { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("GenericParam::")?; match self { - GenericParam::Type(v0) => { - let mut formatter = formatter.debug_tuple("Type"); + GenericParam::Lifetime(v0) => { + let mut formatter = formatter.debug_tuple("Lifetime"); formatter.field(v0); formatter.finish() } - GenericParam::Lifetime(v0) => { - let mut formatter = formatter.debug_tuple("Lifetime"); + GenericParam::Type(v0) => { + let mut formatter = formatter.debug_tuple("Type"); formatter.field(v0); formatter.finish() } @@ -1343,34 +1406,17 @@ impl Debug for Generics { #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Debug for ImplItem { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("ImplItem::")?; match self { - ImplItem::Const(v0) => { - let mut formatter = formatter.debug_tuple("Const"); - formatter.field(v0); - formatter.finish() - } - ImplItem::Method(v0) => { - let mut formatter = formatter.debug_tuple("Method"); - formatter.field(v0); - formatter.finish() - } - ImplItem::Type(v0) => { - let mut formatter = formatter.debug_tuple("Type"); - formatter.field(v0); - formatter.finish() - } - ImplItem::Macro(v0) => { - let mut formatter = formatter.debug_tuple("Macro"); - formatter.field(v0); - formatter.finish() - } + ImplItem::Const(v0) => v0.debug(formatter, "Const"), + ImplItem::Fn(v0) => v0.debug(formatter, "Fn"), + ImplItem::Type(v0) => v0.debug(formatter, "Type"), + ImplItem::Macro(v0) => v0.debug(formatter, "Macro"), ImplItem::Verbatim(v0) => { let mut formatter = formatter.debug_tuple("Verbatim"); formatter.field(v0); formatter.finish() } - #[cfg(syn_no_non_exhaustive)] - _ => unreachable!(), } } } @@ -1378,59 +1424,87 @@ impl Debug for ImplItem { #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Debug for ImplItemConst { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let mut formatter = formatter.debug_struct("ImplItemConst"); - formatter.field("attrs", &self.attrs); - formatter.field("vis", &self.vis); - formatter.field("defaultness", &self.defaultness); - formatter.field("const_token", &self.const_token); - formatter.field("ident", &self.ident); - formatter.field("colon_token", &self.colon_token); - formatter.field("ty", &self.ty); - formatter.field("eq_token", &self.eq_token); - formatter.field("expr", &self.expr); - formatter.field("semi_token", &self.semi_token); - formatter.finish() + impl ImplItemConst { + fn debug(&self, formatter: &mut fmt::Formatter, name: &str) -> fmt::Result { + let mut formatter = formatter.debug_struct(name); + formatter.field("attrs", &self.attrs); + formatter.field("vis", &self.vis); + formatter.field("defaultness", &self.defaultness); + formatter.field("const_token", &self.const_token); + formatter.field("ident", &self.ident); + formatter.field("generics", &self.generics); + formatter.field("colon_token", &self.colon_token); + formatter.field("ty", &self.ty); + formatter.field("eq_token", &self.eq_token); + formatter.field("expr", &self.expr); + formatter.field("semi_token", &self.semi_token); + formatter.finish() + } + } + self.debug(formatter, "ImplItemConst") } } #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] -impl Debug for ImplItemMacro { +impl Debug for ImplItemFn { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let mut formatter = formatter.debug_struct("ImplItemMacro"); - formatter.field("attrs", &self.attrs); - formatter.field("mac", &self.mac); - formatter.field("semi_token", &self.semi_token); - formatter.finish() + impl ImplItemFn { + fn debug(&self, formatter: &mut fmt::Formatter, name: &str) -> fmt::Result { + let mut formatter = formatter.debug_struct(name); + formatter.field("attrs", &self.attrs); + formatter.field("vis", &self.vis); + formatter.field("defaultness", &self.defaultness); + formatter.field("sig", &self.sig); + formatter.field("block", &self.block); + formatter.finish() + } + } + self.debug(formatter, "ImplItemFn") } } #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] -impl Debug for ImplItemMethod { +impl Debug for ImplItemMacro { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let mut formatter = formatter.debug_struct("ImplItemMethod"); - formatter.field("attrs", &self.attrs); - formatter.field("vis", &self.vis); - formatter.field("defaultness", &self.defaultness); - formatter.field("sig", &self.sig); - formatter.field("block", &self.block); - formatter.finish() + impl ImplItemMacro { + fn debug(&self, formatter: &mut fmt::Formatter, name: &str) -> fmt::Result { + let mut formatter = formatter.debug_struct(name); + formatter.field("attrs", &self.attrs); + formatter.field("mac", &self.mac); + formatter.field("semi_token", &self.semi_token); + formatter.finish() + } + } + self.debug(formatter, "ImplItemMacro") } } #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Debug for ImplItemType { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let mut formatter = formatter.debug_struct("ImplItemType"); - formatter.field("attrs", &self.attrs); - formatter.field("vis", &self.vis); - formatter.field("defaultness", &self.defaultness); - formatter.field("type_token", &self.type_token); - formatter.field("ident", &self.ident); - formatter.field("generics", &self.generics); - formatter.field("eq_token", &self.eq_token); - formatter.field("ty", &self.ty); - formatter.field("semi_token", &self.semi_token); - formatter.finish() + impl ImplItemType { + fn debug(&self, formatter: &mut fmt::Formatter, name: &str) -> fmt::Result { + let mut formatter = formatter.debug_struct(name); + formatter.field("attrs", &self.attrs); + formatter.field("vis", &self.vis); + formatter.field("defaultness", &self.defaultness); + formatter.field("type_token", &self.type_token); + formatter.field("ident", &self.ident); + formatter.field("generics", &self.generics); + formatter.field("eq_token", &self.eq_token); + formatter.field("ty", &self.ty); + formatter.field("semi_token", &self.semi_token); + formatter.finish() + } + } + self.debug(formatter, "ImplItemType") + } +} +#[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] +impl Debug for ImplRestriction { + fn fmt(&self, _formatter: &mut fmt::Formatter) -> fmt::Result { + match *self {} } } #[cfg(any(feature = "derive", feature = "full"))] @@ -1447,94 +1521,28 @@ impl Debug for Index { #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Debug for Item { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("Item::")?; match self { - Item::Const(v0) => { - let mut formatter = formatter.debug_tuple("Const"); - formatter.field(v0); - formatter.finish() - } - Item::Enum(v0) => { - let mut formatter = formatter.debug_tuple("Enum"); - formatter.field(v0); - formatter.finish() - } - Item::ExternCrate(v0) => { - let mut formatter = formatter.debug_tuple("ExternCrate"); - formatter.field(v0); - formatter.finish() - } - Item::Fn(v0) => { - let mut formatter = formatter.debug_tuple("Fn"); - formatter.field(v0); - formatter.finish() - } - Item::ForeignMod(v0) => { - let mut formatter = formatter.debug_tuple("ForeignMod"); - formatter.field(v0); - formatter.finish() - } - Item::Impl(v0) => { - let mut formatter = formatter.debug_tuple("Impl"); - formatter.field(v0); - formatter.finish() - } - Item::Macro(v0) => { - let mut formatter = formatter.debug_tuple("Macro"); - formatter.field(v0); - formatter.finish() - } - Item::Macro2(v0) => { - let mut formatter = formatter.debug_tuple("Macro2"); - formatter.field(v0); - formatter.finish() - } - Item::Mod(v0) => { - let mut formatter = formatter.debug_tuple("Mod"); - formatter.field(v0); - formatter.finish() - } - Item::Static(v0) => { - let mut formatter = formatter.debug_tuple("Static"); - formatter.field(v0); - formatter.finish() - } - Item::Struct(v0) => { - let mut formatter = formatter.debug_tuple("Struct"); - formatter.field(v0); - formatter.finish() - } - Item::Trait(v0) => { - let mut formatter = formatter.debug_tuple("Trait"); - formatter.field(v0); - formatter.finish() - } - Item::TraitAlias(v0) => { - let mut formatter = formatter.debug_tuple("TraitAlias"); - formatter.field(v0); - formatter.finish() - } - Item::Type(v0) => { - let mut formatter = formatter.debug_tuple("Type"); - formatter.field(v0); - formatter.finish() - } - Item::Union(v0) => { - let mut formatter = formatter.debug_tuple("Union"); - formatter.field(v0); - formatter.finish() - } - Item::Use(v0) => { - let mut formatter = formatter.debug_tuple("Use"); - formatter.field(v0); - formatter.finish() - } + Item::Const(v0) => v0.debug(formatter, "Const"), + Item::Enum(v0) => v0.debug(formatter, "Enum"), + Item::ExternCrate(v0) => v0.debug(formatter, "ExternCrate"), + Item::Fn(v0) => v0.debug(formatter, "Fn"), + Item::ForeignMod(v0) => v0.debug(formatter, "ForeignMod"), + Item::Impl(v0) => v0.debug(formatter, "Impl"), + Item::Macro(v0) => v0.debug(formatter, "Macro"), + Item::Mod(v0) => v0.debug(formatter, "Mod"), + Item::Static(v0) => v0.debug(formatter, "Static"), + Item::Struct(v0) => v0.debug(formatter, "Struct"), + Item::Trait(v0) => v0.debug(formatter, "Trait"), + Item::TraitAlias(v0) => v0.debug(formatter, "TraitAlias"), + Item::Type(v0) => v0.debug(formatter, "Type"), + Item::Union(v0) => v0.debug(formatter, "Union"), + Item::Use(v0) => v0.debug(formatter, "Use"), Item::Verbatim(v0) => { let mut formatter = formatter.debug_tuple("Verbatim"); formatter.field(v0); formatter.finish() } - #[cfg(syn_no_non_exhaustive)] - _ => unreachable!(), } } } @@ -1542,239 +1550,305 @@ impl Debug for Item { #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Debug for ItemConst { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let mut formatter = formatter.debug_struct("ItemConst"); - formatter.field("attrs", &self.attrs); - formatter.field("vis", &self.vis); - formatter.field("const_token", &self.const_token); - formatter.field("ident", &self.ident); - formatter.field("colon_token", &self.colon_token); - formatter.field("ty", &self.ty); - formatter.field("eq_token", &self.eq_token); - formatter.field("expr", &self.expr); - formatter.field("semi_token", &self.semi_token); - formatter.finish() + impl ItemConst { + fn debug(&self, formatter: &mut fmt::Formatter, name: &str) -> fmt::Result { + let mut formatter = formatter.debug_struct(name); + formatter.field("attrs", &self.attrs); + formatter.field("vis", &self.vis); + formatter.field("const_token", &self.const_token); + formatter.field("ident", &self.ident); + formatter.field("generics", &self.generics); + formatter.field("colon_token", &self.colon_token); + formatter.field("ty", &self.ty); + formatter.field("eq_token", &self.eq_token); + formatter.field("expr", &self.expr); + formatter.field("semi_token", &self.semi_token); + formatter.finish() + } + } + self.debug(formatter, "ItemConst") } } #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Debug for ItemEnum { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let mut formatter = formatter.debug_struct("ItemEnum"); - formatter.field("attrs", &self.attrs); - formatter.field("vis", &self.vis); - formatter.field("enum_token", &self.enum_token); - formatter.field("ident", &self.ident); - formatter.field("generics", &self.generics); - formatter.field("brace_token", &self.brace_token); - formatter.field("variants", &self.variants); - formatter.finish() + impl ItemEnum { + fn debug(&self, formatter: &mut fmt::Formatter, name: &str) -> fmt::Result { + let mut formatter = formatter.debug_struct(name); + formatter.field("attrs", &self.attrs); + formatter.field("vis", &self.vis); + formatter.field("enum_token", &self.enum_token); + formatter.field("ident", &self.ident); + formatter.field("generics", &self.generics); + formatter.field("brace_token", &self.brace_token); + formatter.field("variants", &self.variants); + formatter.finish() + } + } + self.debug(formatter, "ItemEnum") } } #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Debug for ItemExternCrate { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let mut formatter = formatter.debug_struct("ItemExternCrate"); - formatter.field("attrs", &self.attrs); - formatter.field("vis", &self.vis); - formatter.field("extern_token", &self.extern_token); - formatter.field("crate_token", &self.crate_token); - formatter.field("ident", &self.ident); - formatter.field("rename", &self.rename); - formatter.field("semi_token", &self.semi_token); - formatter.finish() + impl ItemExternCrate { + fn debug(&self, formatter: &mut fmt::Formatter, name: &str) -> fmt::Result { + let mut formatter = formatter.debug_struct(name); + formatter.field("attrs", &self.attrs); + formatter.field("vis", &self.vis); + formatter.field("extern_token", &self.extern_token); + formatter.field("crate_token", &self.crate_token); + formatter.field("ident", &self.ident); + formatter.field("rename", &self.rename); + formatter.field("semi_token", &self.semi_token); + formatter.finish() + } + } + self.debug(formatter, "ItemExternCrate") } } #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Debug for ItemFn { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let mut formatter = formatter.debug_struct("ItemFn"); - formatter.field("attrs", &self.attrs); - formatter.field("vis", &self.vis); - formatter.field("sig", &self.sig); - formatter.field("block", &self.block); - formatter.finish() + impl ItemFn { + fn debug(&self, formatter: &mut fmt::Formatter, name: &str) -> fmt::Result { + let mut formatter = formatter.debug_struct(name); + formatter.field("attrs", &self.attrs); + formatter.field("vis", &self.vis); + formatter.field("sig", &self.sig); + formatter.field("block", &self.block); + formatter.finish() + } + } + self.debug(formatter, "ItemFn") } } #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Debug for ItemForeignMod { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let mut formatter = formatter.debug_struct("ItemForeignMod"); - formatter.field("attrs", &self.attrs); - formatter.field("abi", &self.abi); - formatter.field("brace_token", &self.brace_token); - formatter.field("items", &self.items); - formatter.finish() + impl ItemForeignMod { + fn debug(&self, formatter: &mut fmt::Formatter, name: &str) -> fmt::Result { + let mut formatter = formatter.debug_struct(name); + formatter.field("attrs", &self.attrs); + formatter.field("unsafety", &self.unsafety); + formatter.field("abi", &self.abi); + formatter.field("brace_token", &self.brace_token); + formatter.field("items", &self.items); + formatter.finish() + } + } + self.debug(formatter, "ItemForeignMod") } } #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Debug for ItemImpl { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let mut formatter = formatter.debug_struct("ItemImpl"); - formatter.field("attrs", &self.attrs); - formatter.field("defaultness", &self.defaultness); - formatter.field("unsafety", &self.unsafety); - formatter.field("impl_token", &self.impl_token); - formatter.field("generics", &self.generics); - formatter.field("trait_", &self.trait_); - formatter.field("self_ty", &self.self_ty); - formatter.field("brace_token", &self.brace_token); - formatter.field("items", &self.items); - formatter.finish() + impl ItemImpl { + fn debug(&self, formatter: &mut fmt::Formatter, name: &str) -> fmt::Result { + let mut formatter = formatter.debug_struct(name); + formatter.field("attrs", &self.attrs); + formatter.field("defaultness", &self.defaultness); + formatter.field("unsafety", &self.unsafety); + formatter.field("impl_token", &self.impl_token); + formatter.field("generics", &self.generics); + formatter.field("trait_", &self.trait_); + formatter.field("self_ty", &self.self_ty); + formatter.field("brace_token", &self.brace_token); + formatter.field("items", &self.items); + formatter.finish() + } + } + self.debug(formatter, "ItemImpl") } } #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Debug for ItemMacro { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let mut formatter = formatter.debug_struct("ItemMacro"); - formatter.field("attrs", &self.attrs); - formatter.field("ident", &self.ident); - formatter.field("mac", &self.mac); - formatter.field("semi_token", &self.semi_token); - formatter.finish() - } -} -#[cfg(feature = "full")] -#[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] -impl Debug for ItemMacro2 { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let mut formatter = formatter.debug_struct("ItemMacro2"); - formatter.field("attrs", &self.attrs); - formatter.field("vis", &self.vis); - formatter.field("macro_token", &self.macro_token); - formatter.field("ident", &self.ident); - formatter.field("rules", &self.rules); - formatter.finish() + impl ItemMacro { + fn debug(&self, formatter: &mut fmt::Formatter, name: &str) -> fmt::Result { + let mut formatter = formatter.debug_struct(name); + formatter.field("attrs", &self.attrs); + formatter.field("ident", &self.ident); + formatter.field("mac", &self.mac); + formatter.field("semi_token", &self.semi_token); + formatter.finish() + } + } + self.debug(formatter, "ItemMacro") } } #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Debug for ItemMod { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let mut formatter = formatter.debug_struct("ItemMod"); - formatter.field("attrs", &self.attrs); - formatter.field("vis", &self.vis); - formatter.field("mod_token", &self.mod_token); - formatter.field("ident", &self.ident); - formatter.field("content", &self.content); - formatter.field("semi", &self.semi); - formatter.finish() + impl ItemMod { + fn debug(&self, formatter: &mut fmt::Formatter, name: &str) -> fmt::Result { + let mut formatter = formatter.debug_struct(name); + formatter.field("attrs", &self.attrs); + formatter.field("vis", &self.vis); + formatter.field("unsafety", &self.unsafety); + formatter.field("mod_token", &self.mod_token); + formatter.field("ident", &self.ident); + formatter.field("content", &self.content); + formatter.field("semi", &self.semi); + formatter.finish() + } + } + self.debug(formatter, "ItemMod") } } #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Debug for ItemStatic { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let mut formatter = formatter.debug_struct("ItemStatic"); - formatter.field("attrs", &self.attrs); - formatter.field("vis", &self.vis); - formatter.field("static_token", &self.static_token); - formatter.field("mutability", &self.mutability); - formatter.field("ident", &self.ident); - formatter.field("colon_token", &self.colon_token); - formatter.field("ty", &self.ty); - formatter.field("eq_token", &self.eq_token); - formatter.field("expr", &self.expr); - formatter.field("semi_token", &self.semi_token); - formatter.finish() + impl ItemStatic { + fn debug(&self, formatter: &mut fmt::Formatter, name: &str) -> fmt::Result { + let mut formatter = formatter.debug_struct(name); + formatter.field("attrs", &self.attrs); + formatter.field("vis", &self.vis); + formatter.field("static_token", &self.static_token); + formatter.field("mutability", &self.mutability); + formatter.field("ident", &self.ident); + formatter.field("colon_token", &self.colon_token); + formatter.field("ty", &self.ty); + formatter.field("eq_token", &self.eq_token); + formatter.field("expr", &self.expr); + formatter.field("semi_token", &self.semi_token); + formatter.finish() + } + } + self.debug(formatter, "ItemStatic") } } #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Debug for ItemStruct { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let mut formatter = formatter.debug_struct("ItemStruct"); - formatter.field("attrs", &self.attrs); - formatter.field("vis", &self.vis); - formatter.field("struct_token", &self.struct_token); - formatter.field("ident", &self.ident); - formatter.field("generics", &self.generics); - formatter.field("fields", &self.fields); - formatter.field("semi_token", &self.semi_token); - formatter.finish() + impl ItemStruct { + fn debug(&self, formatter: &mut fmt::Formatter, name: &str) -> fmt::Result { + let mut formatter = formatter.debug_struct(name); + formatter.field("attrs", &self.attrs); + formatter.field("vis", &self.vis); + formatter.field("struct_token", &self.struct_token); + formatter.field("ident", &self.ident); + formatter.field("generics", &self.generics); + formatter.field("fields", &self.fields); + formatter.field("semi_token", &self.semi_token); + formatter.finish() + } + } + self.debug(formatter, "ItemStruct") } } #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Debug for ItemTrait { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let mut formatter = formatter.debug_struct("ItemTrait"); - formatter.field("attrs", &self.attrs); - formatter.field("vis", &self.vis); - formatter.field("unsafety", &self.unsafety); - formatter.field("auto_token", &self.auto_token); - formatter.field("trait_token", &self.trait_token); - formatter.field("ident", &self.ident); - formatter.field("generics", &self.generics); - formatter.field("colon_token", &self.colon_token); - formatter.field("supertraits", &self.supertraits); - formatter.field("brace_token", &self.brace_token); - formatter.field("items", &self.items); - formatter.finish() + impl ItemTrait { + fn debug(&self, formatter: &mut fmt::Formatter, name: &str) -> fmt::Result { + let mut formatter = formatter.debug_struct(name); + formatter.field("attrs", &self.attrs); + formatter.field("vis", &self.vis); + formatter.field("unsafety", &self.unsafety); + formatter.field("auto_token", &self.auto_token); + formatter.field("restriction", &self.restriction); + formatter.field("trait_token", &self.trait_token); + formatter.field("ident", &self.ident); + formatter.field("generics", &self.generics); + formatter.field("colon_token", &self.colon_token); + formatter.field("supertraits", &self.supertraits); + formatter.field("brace_token", &self.brace_token); + formatter.field("items", &self.items); + formatter.finish() + } + } + self.debug(formatter, "ItemTrait") } } #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Debug for ItemTraitAlias { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let mut formatter = formatter.debug_struct("ItemTraitAlias"); - formatter.field("attrs", &self.attrs); - formatter.field("vis", &self.vis); - formatter.field("trait_token", &self.trait_token); - formatter.field("ident", &self.ident); - formatter.field("generics", &self.generics); - formatter.field("eq_token", &self.eq_token); - formatter.field("bounds", &self.bounds); - formatter.field("semi_token", &self.semi_token); - formatter.finish() + impl ItemTraitAlias { + fn debug(&self, formatter: &mut fmt::Formatter, name: &str) -> fmt::Result { + let mut formatter = formatter.debug_struct(name); + formatter.field("attrs", &self.attrs); + formatter.field("vis", &self.vis); + formatter.field("trait_token", &self.trait_token); + formatter.field("ident", &self.ident); + formatter.field("generics", &self.generics); + formatter.field("eq_token", &self.eq_token); + formatter.field("bounds", &self.bounds); + formatter.field("semi_token", &self.semi_token); + formatter.finish() + } + } + self.debug(formatter, "ItemTraitAlias") } } #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Debug for ItemType { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let mut formatter = formatter.debug_struct("ItemType"); - formatter.field("attrs", &self.attrs); - formatter.field("vis", &self.vis); - formatter.field("type_token", &self.type_token); - formatter.field("ident", &self.ident); - formatter.field("generics", &self.generics); - formatter.field("eq_token", &self.eq_token); - formatter.field("ty", &self.ty); - formatter.field("semi_token", &self.semi_token); - formatter.finish() + impl ItemType { + fn debug(&self, formatter: &mut fmt::Formatter, name: &str) -> fmt::Result { + let mut formatter = formatter.debug_struct(name); + formatter.field("attrs", &self.attrs); + formatter.field("vis", &self.vis); + formatter.field("type_token", &self.type_token); + formatter.field("ident", &self.ident); + formatter.field("generics", &self.generics); + formatter.field("eq_token", &self.eq_token); + formatter.field("ty", &self.ty); + formatter.field("semi_token", &self.semi_token); + formatter.finish() + } + } + self.debug(formatter, "ItemType") } } #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Debug for ItemUnion { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let mut formatter = formatter.debug_struct("ItemUnion"); - formatter.field("attrs", &self.attrs); - formatter.field("vis", &self.vis); - formatter.field("union_token", &self.union_token); - formatter.field("ident", &self.ident); - formatter.field("generics", &self.generics); - formatter.field("fields", &self.fields); - formatter.finish() + impl ItemUnion { + fn debug(&self, formatter: &mut fmt::Formatter, name: &str) -> fmt::Result { + let mut formatter = formatter.debug_struct(name); + formatter.field("attrs", &self.attrs); + formatter.field("vis", &self.vis); + formatter.field("union_token", &self.union_token); + formatter.field("ident", &self.ident); + formatter.field("generics", &self.generics); + formatter.field("fields", &self.fields); + formatter.finish() + } + } + self.debug(formatter, "ItemUnion") } } #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Debug for ItemUse { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let mut formatter = formatter.debug_struct("ItemUse"); - formatter.field("attrs", &self.attrs); - formatter.field("vis", &self.vis); - formatter.field("use_token", &self.use_token); - formatter.field("leading_colon", &self.leading_colon); - formatter.field("tree", &self.tree); - formatter.field("semi_token", &self.semi_token); - formatter.finish() + impl ItemUse { + fn debug(&self, formatter: &mut fmt::Formatter, name: &str) -> fmt::Result { + let mut formatter = formatter.debug_struct(name); + formatter.field("attrs", &self.attrs); + formatter.field("vis", &self.vis); + formatter.field("use_token", &self.use_token); + formatter.field("leading_colon", &self.leading_colon); + formatter.field("tree", &self.tree); + formatter.field("semi_token", &self.semi_token); + formatter.finish() + } + } + self.debug(formatter, "ItemUse") } } #[cfg(feature = "full")] @@ -1790,17 +1864,22 @@ impl Debug for Label { #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Debug for Lifetime { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let mut formatter = formatter.debug_struct("Lifetime"); - formatter.field("apostrophe", &self.apostrophe); - formatter.field("ident", &self.ident); - formatter.finish() + impl Lifetime { + fn debug(&self, formatter: &mut fmt::Formatter, name: &str) -> fmt::Result { + let mut formatter = formatter.debug_struct(name); + formatter.field("apostrophe", &self.apostrophe); + formatter.field("ident", &self.ident); + formatter.finish() + } + } + self.debug(formatter, "Lifetime") } } #[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] -impl Debug for LifetimeDef { +impl Debug for LifetimeParam { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let mut formatter = formatter.debug_struct("LifetimeDef"); + let mut formatter = formatter.debug_struct("LifetimeParam"); formatter.field("attrs", &self.attrs); formatter.field("lifetime", &self.lifetime); formatter.field("colon_token", &self.colon_token); @@ -1811,42 +1890,15 @@ impl Debug for LifetimeDef { #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Debug for Lit { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("Lit::")?; match self { - Lit::Str(v0) => { - let mut formatter = formatter.debug_tuple("Str"); - formatter.field(v0); - formatter.finish() - } - Lit::ByteStr(v0) => { - let mut formatter = formatter.debug_tuple("ByteStr"); - formatter.field(v0); - formatter.finish() - } - Lit::Byte(v0) => { - let mut formatter = formatter.debug_tuple("Byte"); - formatter.field(v0); - formatter.finish() - } - Lit::Char(v0) => { - let mut formatter = formatter.debug_tuple("Char"); - formatter.field(v0); - formatter.finish() - } - Lit::Int(v0) => { - let mut formatter = formatter.debug_tuple("Int"); - formatter.field(v0); - formatter.finish() - } - Lit::Float(v0) => { - let mut formatter = formatter.debug_tuple("Float"); - formatter.field(v0); - formatter.finish() - } - Lit::Bool(v0) => { - let mut formatter = formatter.debug_tuple("Bool"); - formatter.field(v0); - formatter.finish() - } + Lit::Str(v0) => v0.debug(formatter, "Str"), + Lit::ByteStr(v0) => v0.debug(formatter, "ByteStr"), + Lit::Byte(v0) => v0.debug(formatter, "Byte"), + Lit::Char(v0) => v0.debug(formatter, "Char"), + Lit::Int(v0) => v0.debug(formatter, "Int"), + Lit::Float(v0) => v0.debug(formatter, "Float"), + Lit::Bool(v0) => v0.debug(formatter, "Bool"), Lit::Verbatim(v0) => { let mut formatter = formatter.debug_tuple("Verbatim"); formatter.field(v0); @@ -1859,12 +1911,28 @@ impl Debug for Lit { #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Debug for Local { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let mut formatter = formatter.debug_struct("Local"); - formatter.field("attrs", &self.attrs); - formatter.field("let_token", &self.let_token); - formatter.field("pat", &self.pat); - formatter.field("init", &self.init); - formatter.field("semi_token", &self.semi_token); + impl Local { + fn debug(&self, formatter: &mut fmt::Formatter, name: &str) -> fmt::Result { + let mut formatter = formatter.debug_struct(name); + formatter.field("attrs", &self.attrs); + formatter.field("let_token", &self.let_token); + formatter.field("pat", &self.pat); + formatter.field("init", &self.init); + formatter.field("semi_token", &self.semi_token); + formatter.finish() + } + } + self.debug(formatter, "Local") + } +} +#[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] +impl Debug for LocalInit { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + let mut formatter = formatter.debug_struct("LocalInit"); + formatter.field("eq_token", &self.eq_token); + formatter.field("expr", &self.expr); + formatter.field("diverge", &self.diverge); formatter.finish() } } @@ -1884,6 +1952,7 @@ impl Debug for Macro { #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Debug for MacroDelimiter { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("MacroDelimiter::")?; match self { MacroDelimiter::Paren(v0) => { let mut formatter = formatter.debug_tuple("Paren"); @@ -1907,6 +1976,7 @@ impl Debug for MacroDelimiter { #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Debug for Member { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("Member::")?; match self { Member::Named(v0) => { let mut formatter = formatter.debug_tuple("Named"); @@ -1925,22 +1995,11 @@ impl Debug for Member { #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Debug for Meta { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("Meta::")?; match self { - Meta::Path(v0) => { - let mut formatter = formatter.debug_tuple("Path"); - formatter.field(v0); - formatter.finish() - } - Meta::List(v0) => { - let mut formatter = formatter.debug_tuple("List"); - formatter.field(v0); - formatter.finish() - } - Meta::NameValue(v0) => { - let mut formatter = formatter.debug_tuple("NameValue"); - formatter.field(v0); - formatter.finish() - } + Meta::Path(v0) => v0.debug(formatter, "Path"), + Meta::List(v0) => v0.debug(formatter, "List"), + Meta::NameValue(v0) => v0.debug(formatter, "NameValue"), } } } @@ -1948,349 +2007,287 @@ impl Debug for Meta { #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Debug for MetaList { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let mut formatter = formatter.debug_struct("MetaList"); - formatter.field("path", &self.path); - formatter.field("paren_token", &self.paren_token); - formatter.field("nested", &self.nested); - formatter.finish() + impl MetaList { + fn debug(&self, formatter: &mut fmt::Formatter, name: &str) -> fmt::Result { + let mut formatter = formatter.debug_struct(name); + formatter.field("path", &self.path); + formatter.field("delimiter", &self.delimiter); + formatter.field("tokens", &self.tokens); + formatter.finish() + } + } + self.debug(formatter, "MetaList") } } #[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Debug for MetaNameValue { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let mut formatter = formatter.debug_struct("MetaNameValue"); - formatter.field("path", &self.path); - formatter.field("eq_token", &self.eq_token); - formatter.field("lit", &self.lit); - formatter.finish() - } -} -#[cfg(feature = "full")] -#[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] -impl Debug for MethodTurbofish { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let mut formatter = formatter.debug_struct("MethodTurbofish"); - formatter.field("colon2_token", &self.colon2_token); - formatter.field("lt_token", &self.lt_token); - formatter.field("args", &self.args); - formatter.field("gt_token", &self.gt_token); - formatter.finish() - } -} -#[cfg(any(feature = "derive", feature = "full"))] -#[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] -impl Debug for NestedMeta { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - match self { - NestedMeta::Meta(v0) => { - let mut formatter = formatter.debug_tuple("Meta"); - formatter.field(v0); - formatter.finish() - } - NestedMeta::Lit(v0) => { - let mut formatter = formatter.debug_tuple("Lit"); - formatter.field(v0); + impl MetaNameValue { + fn debug(&self, formatter: &mut fmt::Formatter, name: &str) -> fmt::Result { + let mut formatter = formatter.debug_struct(name); + formatter.field("path", &self.path); + formatter.field("eq_token", &self.eq_token); + formatter.field("value", &self.value); formatter.finish() } } + self.debug(formatter, "MetaNameValue") } } #[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Debug for ParenthesizedGenericArguments { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let mut formatter = formatter.debug_struct("ParenthesizedGenericArguments"); - formatter.field("paren_token", &self.paren_token); - formatter.field("inputs", &self.inputs); - formatter.field("output", &self.output); - formatter.finish() + impl ParenthesizedGenericArguments { + fn debug(&self, formatter: &mut fmt::Formatter, name: &str) -> fmt::Result { + let mut formatter = formatter.debug_struct(name); + formatter.field("paren_token", &self.paren_token); + formatter.field("inputs", &self.inputs); + formatter.field("output", &self.output); + formatter.finish() + } + } + self.debug(formatter, "ParenthesizedGenericArguments") } } #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Debug for Pat { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("Pat::")?; match self { - Pat::Box(v0) => { - let mut formatter = formatter.debug_tuple("Box"); - formatter.field(v0); - formatter.finish() - } - Pat::Ident(v0) => { - let mut formatter = formatter.debug_tuple("Ident"); - formatter.field(v0); - formatter.finish() - } - Pat::Lit(v0) => { - let mut formatter = formatter.debug_tuple("Lit"); - formatter.field(v0); - formatter.finish() - } - Pat::Macro(v0) => { - let mut formatter = formatter.debug_tuple("Macro"); - formatter.field(v0); - formatter.finish() - } - Pat::Or(v0) => { - let mut formatter = formatter.debug_tuple("Or"); - formatter.field(v0); - formatter.finish() - } - Pat::Path(v0) => { - let mut formatter = formatter.debug_tuple("Path"); - formatter.field(v0); - formatter.finish() - } - Pat::Range(v0) => { - let mut formatter = formatter.debug_tuple("Range"); - formatter.field(v0); - formatter.finish() - } - Pat::Reference(v0) => { - let mut formatter = formatter.debug_tuple("Reference"); - formatter.field(v0); - formatter.finish() - } - Pat::Rest(v0) => { - let mut formatter = formatter.debug_tuple("Rest"); - formatter.field(v0); - formatter.finish() - } - Pat::Slice(v0) => { - let mut formatter = formatter.debug_tuple("Slice"); - formatter.field(v0); - formatter.finish() - } - Pat::Struct(v0) => { - let mut formatter = formatter.debug_tuple("Struct"); - formatter.field(v0); - formatter.finish() - } - Pat::Tuple(v0) => { - let mut formatter = formatter.debug_tuple("Tuple"); - formatter.field(v0); - formatter.finish() - } - Pat::TupleStruct(v0) => { - let mut formatter = formatter.debug_tuple("TupleStruct"); - formatter.field(v0); - formatter.finish() - } - Pat::Type(v0) => { - let mut formatter = formatter.debug_tuple("Type"); - formatter.field(v0); - formatter.finish() - } + Pat::Const(v0) => v0.debug(formatter, "Const"), + Pat::Ident(v0) => v0.debug(formatter, "Ident"), + Pat::Lit(v0) => v0.debug(formatter, "Lit"), + Pat::Macro(v0) => v0.debug(formatter, "Macro"), + Pat::Or(v0) => v0.debug(formatter, "Or"), + Pat::Paren(v0) => v0.debug(formatter, "Paren"), + Pat::Path(v0) => v0.debug(formatter, "Path"), + Pat::Range(v0) => v0.debug(formatter, "Range"), + Pat::Reference(v0) => v0.debug(formatter, "Reference"), + Pat::Rest(v0) => v0.debug(formatter, "Rest"), + Pat::Slice(v0) => v0.debug(formatter, "Slice"), + Pat::Struct(v0) => v0.debug(formatter, "Struct"), + Pat::Tuple(v0) => v0.debug(formatter, "Tuple"), + Pat::TupleStruct(v0) => v0.debug(formatter, "TupleStruct"), + Pat::Type(v0) => v0.debug(formatter, "Type"), Pat::Verbatim(v0) => { let mut formatter = formatter.debug_tuple("Verbatim"); formatter.field(v0); formatter.finish() } - Pat::Wild(v0) => { - let mut formatter = formatter.debug_tuple("Wild"); - formatter.field(v0); - formatter.finish() - } - #[cfg(syn_no_non_exhaustive)] - _ => unreachable!(), + Pat::Wild(v0) => v0.debug(formatter, "Wild"), } } } #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] -impl Debug for PatBox { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let mut formatter = formatter.debug_struct("PatBox"); - formatter.field("attrs", &self.attrs); - formatter.field("box_token", &self.box_token); - formatter.field("pat", &self.pat); - formatter.finish() - } -} -#[cfg(feature = "full")] -#[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Debug for PatIdent { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let mut formatter = formatter.debug_struct("PatIdent"); - formatter.field("attrs", &self.attrs); - formatter.field("by_ref", &self.by_ref); - formatter.field("mutability", &self.mutability); - formatter.field("ident", &self.ident); - formatter.field("subpat", &self.subpat); - formatter.finish() - } -} -#[cfg(feature = "full")] -#[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] -impl Debug for PatLit { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let mut formatter = formatter.debug_struct("PatLit"); - formatter.field("attrs", &self.attrs); - formatter.field("expr", &self.expr); - formatter.finish() - } -} -#[cfg(feature = "full")] -#[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] -impl Debug for PatMacro { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let mut formatter = formatter.debug_struct("PatMacro"); - formatter.field("attrs", &self.attrs); - formatter.field("mac", &self.mac); - formatter.finish() + impl PatIdent { + fn debug(&self, formatter: &mut fmt::Formatter, name: &str) -> fmt::Result { + let mut formatter = formatter.debug_struct(name); + formatter.field("attrs", &self.attrs); + formatter.field("by_ref", &self.by_ref); + formatter.field("mutability", &self.mutability); + formatter.field("ident", &self.ident); + formatter.field("subpat", &self.subpat); + formatter.finish() + } + } + self.debug(formatter, "PatIdent") } } #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Debug for PatOr { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let mut formatter = formatter.debug_struct("PatOr"); - formatter.field("attrs", &self.attrs); - formatter.field("leading_vert", &self.leading_vert); - formatter.field("cases", &self.cases); - formatter.finish() - } -} -#[cfg(feature = "full")] -#[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] -impl Debug for PatPath { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let mut formatter = formatter.debug_struct("PatPath"); - formatter.field("attrs", &self.attrs); - formatter.field("qself", &self.qself); - formatter.field("path", &self.path); - formatter.finish() + impl PatOr { + fn debug(&self, formatter: &mut fmt::Formatter, name: &str) -> fmt::Result { + let mut formatter = formatter.debug_struct(name); + formatter.field("attrs", &self.attrs); + formatter.field("leading_vert", &self.leading_vert); + formatter.field("cases", &self.cases); + formatter.finish() + } + } + self.debug(formatter, "PatOr") } } #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] -impl Debug for PatRange { +impl Debug for PatParen { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let mut formatter = formatter.debug_struct("PatRange"); - formatter.field("attrs", &self.attrs); - formatter.field("lo", &self.lo); - formatter.field("limits", &self.limits); - formatter.field("hi", &self.hi); - formatter.finish() + impl PatParen { + fn debug(&self, formatter: &mut fmt::Formatter, name: &str) -> fmt::Result { + let mut formatter = formatter.debug_struct(name); + formatter.field("attrs", &self.attrs); + formatter.field("paren_token", &self.paren_token); + formatter.field("pat", &self.pat); + formatter.finish() + } + } + self.debug(formatter, "PatParen") } } #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Debug for PatReference { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let mut formatter = formatter.debug_struct("PatReference"); - formatter.field("attrs", &self.attrs); - formatter.field("and_token", &self.and_token); - formatter.field("mutability", &self.mutability); - formatter.field("pat", &self.pat); - formatter.finish() + impl PatReference { + fn debug(&self, formatter: &mut fmt::Formatter, name: &str) -> fmt::Result { + let mut formatter = formatter.debug_struct(name); + formatter.field("attrs", &self.attrs); + formatter.field("and_token", &self.and_token); + formatter.field("mutability", &self.mutability); + formatter.field("pat", &self.pat); + formatter.finish() + } + } + self.debug(formatter, "PatReference") } } #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Debug for PatRest { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let mut formatter = formatter.debug_struct("PatRest"); - formatter.field("attrs", &self.attrs); - formatter.field("dot2_token", &self.dot2_token); - formatter.finish() + impl PatRest { + fn debug(&self, formatter: &mut fmt::Formatter, name: &str) -> fmt::Result { + let mut formatter = formatter.debug_struct(name); + formatter.field("attrs", &self.attrs); + formatter.field("dot2_token", &self.dot2_token); + formatter.finish() + } + } + self.debug(formatter, "PatRest") } } #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Debug for PatSlice { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let mut formatter = formatter.debug_struct("PatSlice"); - formatter.field("attrs", &self.attrs); - formatter.field("bracket_token", &self.bracket_token); - formatter.field("elems", &self.elems); - formatter.finish() + impl PatSlice { + fn debug(&self, formatter: &mut fmt::Formatter, name: &str) -> fmt::Result { + let mut formatter = formatter.debug_struct(name); + formatter.field("attrs", &self.attrs); + formatter.field("bracket_token", &self.bracket_token); + formatter.field("elems", &self.elems); + formatter.finish() + } + } + self.debug(formatter, "PatSlice") } } #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Debug for PatStruct { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let mut formatter = formatter.debug_struct("PatStruct"); - formatter.field("attrs", &self.attrs); - formatter.field("path", &self.path); - formatter.field("brace_token", &self.brace_token); - formatter.field("fields", &self.fields); - formatter.field("dot2_token", &self.dot2_token); - formatter.finish() + impl PatStruct { + fn debug(&self, formatter: &mut fmt::Formatter, name: &str) -> fmt::Result { + let mut formatter = formatter.debug_struct(name); + formatter.field("attrs", &self.attrs); + formatter.field("qself", &self.qself); + formatter.field("path", &self.path); + formatter.field("brace_token", &self.brace_token); + formatter.field("fields", &self.fields); + formatter.field("rest", &self.rest); + formatter.finish() + } + } + self.debug(formatter, "PatStruct") } } #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Debug for PatTuple { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let mut formatter = formatter.debug_struct("PatTuple"); - formatter.field("attrs", &self.attrs); - formatter.field("paren_token", &self.paren_token); - formatter.field("elems", &self.elems); - formatter.finish() + impl PatTuple { + fn debug(&self, formatter: &mut fmt::Formatter, name: &str) -> fmt::Result { + let mut formatter = formatter.debug_struct(name); + formatter.field("attrs", &self.attrs); + formatter.field("paren_token", &self.paren_token); + formatter.field("elems", &self.elems); + formatter.finish() + } + } + self.debug(formatter, "PatTuple") } } #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Debug for PatTupleStruct { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let mut formatter = formatter.debug_struct("PatTupleStruct"); - formatter.field("attrs", &self.attrs); - formatter.field("path", &self.path); - formatter.field("pat", &self.pat); - formatter.finish() + impl PatTupleStruct { + fn debug(&self, formatter: &mut fmt::Formatter, name: &str) -> fmt::Result { + let mut formatter = formatter.debug_struct(name); + formatter.field("attrs", &self.attrs); + formatter.field("qself", &self.qself); + formatter.field("path", &self.path); + formatter.field("paren_token", &self.paren_token); + formatter.field("elems", &self.elems); + formatter.finish() + } + } + self.debug(formatter, "PatTupleStruct") } } #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Debug for PatType { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let mut formatter = formatter.debug_struct("PatType"); - formatter.field("attrs", &self.attrs); - formatter.field("pat", &self.pat); - formatter.field("colon_token", &self.colon_token); - formatter.field("ty", &self.ty); - formatter.finish() + impl PatType { + fn debug(&self, formatter: &mut fmt::Formatter, name: &str) -> fmt::Result { + let mut formatter = formatter.debug_struct(name); + formatter.field("attrs", &self.attrs); + formatter.field("pat", &self.pat); + formatter.field("colon_token", &self.colon_token); + formatter.field("ty", &self.ty); + formatter.finish() + } + } + self.debug(formatter, "PatType") } } #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Debug for PatWild { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let mut formatter = formatter.debug_struct("PatWild"); - formatter.field("attrs", &self.attrs); - formatter.field("underscore_token", &self.underscore_token); - formatter.finish() + impl PatWild { + fn debug(&self, formatter: &mut fmt::Formatter, name: &str) -> fmt::Result { + let mut formatter = formatter.debug_struct(name); + formatter.field("attrs", &self.attrs); + formatter.field("underscore_token", &self.underscore_token); + formatter.finish() + } + } + self.debug(formatter, "PatWild") } } #[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Debug for Path { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let mut formatter = formatter.debug_struct("Path"); - formatter.field("leading_colon", &self.leading_colon); - formatter.field("segments", &self.segments); - formatter.finish() + impl Path { + fn debug(&self, formatter: &mut fmt::Formatter, name: &str) -> fmt::Result { + let mut formatter = formatter.debug_struct(name); + formatter.field("leading_colon", &self.leading_colon); + formatter.field("segments", &self.segments); + formatter.finish() + } + } + self.debug(formatter, "Path") } } #[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Debug for PathArguments { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("PathArguments::")?; match self { PathArguments::None => formatter.write_str("None"), - PathArguments::AngleBracketed(v0) => { - let mut formatter = formatter.debug_tuple("AngleBracketed"); - formatter.field(v0); - formatter.finish() - } - PathArguments::Parenthesized(v0) => { - let mut formatter = formatter.debug_tuple("Parenthesized"); - formatter.field(v0); - formatter.finish() - } + PathArguments::AngleBracketed(v0) => v0.debug(formatter, "AngleBracketed"), + PathArguments::Parenthesized(v0) => v0.debug(formatter, "Parenthesized"), } } } @@ -2306,17 +2303,6 @@ impl Debug for PathSegment { } #[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] -impl Debug for PredicateEq { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let mut formatter = formatter.debug_struct("PredicateEq"); - formatter.field("lhs_ty", &self.lhs_ty); - formatter.field("eq_token", &self.eq_token); - formatter.field("rhs_ty", &self.rhs_ty); - formatter.finish() - } -} -#[cfg(any(feature = "derive", feature = "full"))] -#[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Debug for PredicateLifetime { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { let mut formatter = formatter.debug_struct("PredicateLifetime"); @@ -2355,6 +2341,7 @@ impl Debug for QSelf { #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Debug for RangeLimits { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("RangeLimits::")?; match self { RangeLimits::HalfOpen(v0) => { let mut formatter = formatter.debug_tuple("HalfOpen"); @@ -2378,6 +2365,8 @@ impl Debug for Receiver { formatter.field("reference", &self.reference); formatter.field("mutability", &self.mutability); formatter.field("self_token", &self.self_token); + formatter.field("colon_token", &self.colon_token); + formatter.field("ty", &self.ty); formatter.finish() } } @@ -2385,6 +2374,7 @@ impl Debug for Receiver { #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Debug for ReturnType { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("ReturnType::")?; match self { ReturnType::Default => formatter.write_str("Default"), ReturnType::Type(v0, v1) => { @@ -2417,31 +2407,55 @@ impl Debug for Signature { } #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] -impl Debug for Stmt { +impl Debug for StaticMutability { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("StaticMutability::")?; match self { - Stmt::Local(v0) => { - let mut formatter = formatter.debug_tuple("Local"); + StaticMutability::Mut(v0) => { + let mut formatter = formatter.debug_tuple("Mut"); formatter.field(v0); formatter.finish() } + StaticMutability::None => formatter.write_str("None"), + } + } +} +#[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] +impl Debug for Stmt { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("Stmt::")?; + match self { + Stmt::Local(v0) => v0.debug(formatter, "Local"), Stmt::Item(v0) => { let mut formatter = formatter.debug_tuple("Item"); formatter.field(v0); formatter.finish() } - Stmt::Expr(v0) => { + Stmt::Expr(v0, v1) => { let mut formatter = formatter.debug_tuple("Expr"); formatter.field(v0); + formatter.field(v1); formatter.finish() } - Stmt::Semi(v0, v1) => { - let mut formatter = formatter.debug_tuple("Semi"); - formatter.field(v0); - formatter.field(v1); + Stmt::Macro(v0) => v0.debug(formatter, "Macro"), + } + } +} +#[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] +impl Debug for StmtMacro { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + impl StmtMacro { + fn debug(&self, formatter: &mut fmt::Formatter, name: &str) -> fmt::Result { + let mut formatter = formatter.debug_struct(name); + formatter.field("attrs", &self.attrs); + formatter.field("mac", &self.mac); + formatter.field("semi_token", &self.semi_token); formatter.finish() } } + self.debug(formatter, "StmtMacro") } } #[cfg(any(feature = "derive", feature = "full"))] @@ -2460,6 +2474,7 @@ impl Debug for TraitBound { #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Debug for TraitBoundModifier { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("TraitBoundModifier::")?; match self { TraitBoundModifier::None => formatter.write_str("None"), TraitBoundModifier::Maybe(v0) => { @@ -2474,34 +2489,17 @@ impl Debug for TraitBoundModifier { #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Debug for TraitItem { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("TraitItem::")?; match self { - TraitItem::Const(v0) => { - let mut formatter = formatter.debug_tuple("Const"); - formatter.field(v0); - formatter.finish() - } - TraitItem::Method(v0) => { - let mut formatter = formatter.debug_tuple("Method"); - formatter.field(v0); - formatter.finish() - } - TraitItem::Type(v0) => { - let mut formatter = formatter.debug_tuple("Type"); - formatter.field(v0); - formatter.finish() - } - TraitItem::Macro(v0) => { - let mut formatter = formatter.debug_tuple("Macro"); - formatter.field(v0); - formatter.finish() - } + TraitItem::Const(v0) => v0.debug(formatter, "Const"), + TraitItem::Fn(v0) => v0.debug(formatter, "Fn"), + TraitItem::Type(v0) => v0.debug(formatter, "Type"), + TraitItem::Macro(v0) => v0.debug(formatter, "Macro"), TraitItem::Verbatim(v0) => { let mut formatter = formatter.debug_tuple("Verbatim"); formatter.field(v0); formatter.finish() } - #[cfg(syn_no_non_exhaustive)] - _ => unreachable!(), } } } @@ -2509,138 +2507,102 @@ impl Debug for TraitItem { #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Debug for TraitItemConst { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let mut formatter = formatter.debug_struct("TraitItemConst"); - formatter.field("attrs", &self.attrs); - formatter.field("const_token", &self.const_token); - formatter.field("ident", &self.ident); - formatter.field("colon_token", &self.colon_token); - formatter.field("ty", &self.ty); - formatter.field("default", &self.default); - formatter.field("semi_token", &self.semi_token); - formatter.finish() + impl TraitItemConst { + fn debug(&self, formatter: &mut fmt::Formatter, name: &str) -> fmt::Result { + let mut formatter = formatter.debug_struct(name); + formatter.field("attrs", &self.attrs); + formatter.field("const_token", &self.const_token); + formatter.field("ident", &self.ident); + formatter.field("generics", &self.generics); + formatter.field("colon_token", &self.colon_token); + formatter.field("ty", &self.ty); + formatter.field("default", &self.default); + formatter.field("semi_token", &self.semi_token); + formatter.finish() + } + } + self.debug(formatter, "TraitItemConst") } } #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] -impl Debug for TraitItemMacro { +impl Debug for TraitItemFn { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let mut formatter = formatter.debug_struct("TraitItemMacro"); - formatter.field("attrs", &self.attrs); - formatter.field("mac", &self.mac); - formatter.field("semi_token", &self.semi_token); - formatter.finish() + impl TraitItemFn { + fn debug(&self, formatter: &mut fmt::Formatter, name: &str) -> fmt::Result { + let mut formatter = formatter.debug_struct(name); + formatter.field("attrs", &self.attrs); + formatter.field("sig", &self.sig); + formatter.field("default", &self.default); + formatter.field("semi_token", &self.semi_token); + formatter.finish() + } + } + self.debug(formatter, "TraitItemFn") } } #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] -impl Debug for TraitItemMethod { +impl Debug for TraitItemMacro { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let mut formatter = formatter.debug_struct("TraitItemMethod"); - formatter.field("attrs", &self.attrs); - formatter.field("sig", &self.sig); - formatter.field("default", &self.default); - formatter.field("semi_token", &self.semi_token); - formatter.finish() + impl TraitItemMacro { + fn debug(&self, formatter: &mut fmt::Formatter, name: &str) -> fmt::Result { + let mut formatter = formatter.debug_struct(name); + formatter.field("attrs", &self.attrs); + formatter.field("mac", &self.mac); + formatter.field("semi_token", &self.semi_token); + formatter.finish() + } + } + self.debug(formatter, "TraitItemMacro") } } #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Debug for TraitItemType { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let mut formatter = formatter.debug_struct("TraitItemType"); - formatter.field("attrs", &self.attrs); - formatter.field("type_token", &self.type_token); - formatter.field("ident", &self.ident); - formatter.field("generics", &self.generics); - formatter.field("colon_token", &self.colon_token); - formatter.field("bounds", &self.bounds); - formatter.field("default", &self.default); - formatter.field("semi_token", &self.semi_token); - formatter.finish() + impl TraitItemType { + fn debug(&self, formatter: &mut fmt::Formatter, name: &str) -> fmt::Result { + let mut formatter = formatter.debug_struct(name); + formatter.field("attrs", &self.attrs); + formatter.field("type_token", &self.type_token); + formatter.field("ident", &self.ident); + formatter.field("generics", &self.generics); + formatter.field("colon_token", &self.colon_token); + formatter.field("bounds", &self.bounds); + formatter.field("default", &self.default); + formatter.field("semi_token", &self.semi_token); + formatter.finish() + } + } + self.debug(formatter, "TraitItemType") } } #[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Debug for Type { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("Type::")?; match self { - Type::Array(v0) => { - let mut formatter = formatter.debug_tuple("Array"); - formatter.field(v0); - formatter.finish() - } - Type::BareFn(v0) => { - let mut formatter = formatter.debug_tuple("BareFn"); - formatter.field(v0); - formatter.finish() - } - Type::Group(v0) => { - let mut formatter = formatter.debug_tuple("Group"); - formatter.field(v0); - formatter.finish() - } - Type::ImplTrait(v0) => { - let mut formatter = formatter.debug_tuple("ImplTrait"); - formatter.field(v0); - formatter.finish() - } - Type::Infer(v0) => { - let mut formatter = formatter.debug_tuple("Infer"); - formatter.field(v0); - formatter.finish() - } - Type::Macro(v0) => { - let mut formatter = formatter.debug_tuple("Macro"); - formatter.field(v0); - formatter.finish() - } - Type::Never(v0) => { - let mut formatter = formatter.debug_tuple("Never"); - formatter.field(v0); - formatter.finish() - } - Type::Paren(v0) => { - let mut formatter = formatter.debug_tuple("Paren"); - formatter.field(v0); - formatter.finish() - } - Type::Path(v0) => { - let mut formatter = formatter.debug_tuple("Path"); - formatter.field(v0); - formatter.finish() - } - Type::Ptr(v0) => { - let mut formatter = formatter.debug_tuple("Ptr"); - formatter.field(v0); - formatter.finish() - } - Type::Reference(v0) => { - let mut formatter = formatter.debug_tuple("Reference"); - formatter.field(v0); - formatter.finish() - } - Type::Slice(v0) => { - let mut formatter = formatter.debug_tuple("Slice"); - formatter.field(v0); - formatter.finish() - } - Type::TraitObject(v0) => { - let mut formatter = formatter.debug_tuple("TraitObject"); - formatter.field(v0); - formatter.finish() - } - Type::Tuple(v0) => { - let mut formatter = formatter.debug_tuple("Tuple"); - formatter.field(v0); - formatter.finish() - } + Type::Array(v0) => v0.debug(formatter, "Array"), + Type::BareFn(v0) => v0.debug(formatter, "BareFn"), + Type::Group(v0) => v0.debug(formatter, "Group"), + Type::ImplTrait(v0) => v0.debug(formatter, "ImplTrait"), + Type::Infer(v0) => v0.debug(formatter, "Infer"), + Type::Macro(v0) => v0.debug(formatter, "Macro"), + Type::Never(v0) => v0.debug(formatter, "Never"), + Type::Paren(v0) => v0.debug(formatter, "Paren"), + Type::Path(v0) => v0.debug(formatter, "Path"), + Type::Ptr(v0) => v0.debug(formatter, "Ptr"), + Type::Reference(v0) => v0.debug(formatter, "Reference"), + Type::Slice(v0) => v0.debug(formatter, "Slice"), + Type::TraitObject(v0) => v0.debug(formatter, "TraitObject"), + Type::Tuple(v0) => v0.debug(formatter, "Tuple"), Type::Verbatim(v0) => { let mut formatter = formatter.debug_tuple("Verbatim"); formatter.field(v0); formatter.finish() } - #[cfg(syn_no_non_exhaustive)] - _ => unreachable!(), } } } @@ -2648,75 +2610,110 @@ impl Debug for Type { #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Debug for TypeArray { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let mut formatter = formatter.debug_struct("TypeArray"); - formatter.field("bracket_token", &self.bracket_token); - formatter.field("elem", &self.elem); - formatter.field("semi_token", &self.semi_token); - formatter.field("len", &self.len); - formatter.finish() + impl TypeArray { + fn debug(&self, formatter: &mut fmt::Formatter, name: &str) -> fmt::Result { + let mut formatter = formatter.debug_struct(name); + formatter.field("bracket_token", &self.bracket_token); + formatter.field("elem", &self.elem); + formatter.field("semi_token", &self.semi_token); + formatter.field("len", &self.len); + formatter.finish() + } + } + self.debug(formatter, "TypeArray") } } #[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Debug for TypeBareFn { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let mut formatter = formatter.debug_struct("TypeBareFn"); - formatter.field("lifetimes", &self.lifetimes); - formatter.field("unsafety", &self.unsafety); - formatter.field("abi", &self.abi); - formatter.field("fn_token", &self.fn_token); - formatter.field("paren_token", &self.paren_token); - formatter.field("inputs", &self.inputs); - formatter.field("variadic", &self.variadic); - formatter.field("output", &self.output); - formatter.finish() + impl TypeBareFn { + fn debug(&self, formatter: &mut fmt::Formatter, name: &str) -> fmt::Result { + let mut formatter = formatter.debug_struct(name); + formatter.field("lifetimes", &self.lifetimes); + formatter.field("unsafety", &self.unsafety); + formatter.field("abi", &self.abi); + formatter.field("fn_token", &self.fn_token); + formatter.field("paren_token", &self.paren_token); + formatter.field("inputs", &self.inputs); + formatter.field("variadic", &self.variadic); + formatter.field("output", &self.output); + formatter.finish() + } + } + self.debug(formatter, "TypeBareFn") } } #[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Debug for TypeGroup { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let mut formatter = formatter.debug_struct("TypeGroup"); - formatter.field("group_token", &self.group_token); - formatter.field("elem", &self.elem); - formatter.finish() + impl TypeGroup { + fn debug(&self, formatter: &mut fmt::Formatter, name: &str) -> fmt::Result { + let mut formatter = formatter.debug_struct(name); + formatter.field("group_token", &self.group_token); + formatter.field("elem", &self.elem); + formatter.finish() + } + } + self.debug(formatter, "TypeGroup") } } #[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Debug for TypeImplTrait { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let mut formatter = formatter.debug_struct("TypeImplTrait"); - formatter.field("impl_token", &self.impl_token); - formatter.field("bounds", &self.bounds); - formatter.finish() + impl TypeImplTrait { + fn debug(&self, formatter: &mut fmt::Formatter, name: &str) -> fmt::Result { + let mut formatter = formatter.debug_struct(name); + formatter.field("impl_token", &self.impl_token); + formatter.field("bounds", &self.bounds); + formatter.finish() + } + } + self.debug(formatter, "TypeImplTrait") } } #[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Debug for TypeInfer { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let mut formatter = formatter.debug_struct("TypeInfer"); - formatter.field("underscore_token", &self.underscore_token); - formatter.finish() + impl TypeInfer { + fn debug(&self, formatter: &mut fmt::Formatter, name: &str) -> fmt::Result { + let mut formatter = formatter.debug_struct(name); + formatter.field("underscore_token", &self.underscore_token); + formatter.finish() + } + } + self.debug(formatter, "TypeInfer") } } #[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Debug for TypeMacro { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let mut formatter = formatter.debug_struct("TypeMacro"); - formatter.field("mac", &self.mac); - formatter.finish() + impl TypeMacro { + fn debug(&self, formatter: &mut fmt::Formatter, name: &str) -> fmt::Result { + let mut formatter = formatter.debug_struct(name); + formatter.field("mac", &self.mac); + formatter.finish() + } + } + self.debug(formatter, "TypeMacro") } } #[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Debug for TypeNever { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let mut formatter = formatter.debug_struct("TypeNever"); - formatter.field("bang_token", &self.bang_token); - formatter.finish() + impl TypeNever { + fn debug(&self, formatter: &mut fmt::Formatter, name: &str) -> fmt::Result { + let mut formatter = formatter.debug_struct(name); + formatter.field("bang_token", &self.bang_token); + formatter.finish() + } + } + self.debug(formatter, "TypeNever") } } #[cfg(any(feature = "derive", feature = "full"))] @@ -2737,14 +2734,16 @@ impl Debug for TypeParam { #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Debug for TypeParamBound { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("TypeParamBound::")?; match self { TypeParamBound::Trait(v0) => { let mut formatter = formatter.debug_tuple("Trait"); formatter.field(v0); formatter.finish() } - TypeParamBound::Lifetime(v0) => { - let mut formatter = formatter.debug_tuple("Lifetime"); + TypeParamBound::Lifetime(v0) => v0.debug(formatter, "Lifetime"), + TypeParamBound::Verbatim(v0) => { + let mut formatter = formatter.debug_tuple("Verbatim"); formatter.field(v0); formatter.finish() } @@ -2755,80 +2754,116 @@ impl Debug for TypeParamBound { #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Debug for TypeParen { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let mut formatter = formatter.debug_struct("TypeParen"); - formatter.field("paren_token", &self.paren_token); - formatter.field("elem", &self.elem); - formatter.finish() + impl TypeParen { + fn debug(&self, formatter: &mut fmt::Formatter, name: &str) -> fmt::Result { + let mut formatter = formatter.debug_struct(name); + formatter.field("paren_token", &self.paren_token); + formatter.field("elem", &self.elem); + formatter.finish() + } + } + self.debug(formatter, "TypeParen") } } #[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Debug for TypePath { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let mut formatter = formatter.debug_struct("TypePath"); - formatter.field("qself", &self.qself); - formatter.field("path", &self.path); - formatter.finish() + impl TypePath { + fn debug(&self, formatter: &mut fmt::Formatter, name: &str) -> fmt::Result { + let mut formatter = formatter.debug_struct(name); + formatter.field("qself", &self.qself); + formatter.field("path", &self.path); + formatter.finish() + } + } + self.debug(formatter, "TypePath") } } #[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Debug for TypePtr { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let mut formatter = formatter.debug_struct("TypePtr"); - formatter.field("star_token", &self.star_token); - formatter.field("const_token", &self.const_token); - formatter.field("mutability", &self.mutability); - formatter.field("elem", &self.elem); - formatter.finish() + impl TypePtr { + fn debug(&self, formatter: &mut fmt::Formatter, name: &str) -> fmt::Result { + let mut formatter = formatter.debug_struct(name); + formatter.field("star_token", &self.star_token); + formatter.field("const_token", &self.const_token); + formatter.field("mutability", &self.mutability); + formatter.field("elem", &self.elem); + formatter.finish() + } + } + self.debug(formatter, "TypePtr") } } #[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Debug for TypeReference { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let mut formatter = formatter.debug_struct("TypeReference"); - formatter.field("and_token", &self.and_token); - formatter.field("lifetime", &self.lifetime); - formatter.field("mutability", &self.mutability); - formatter.field("elem", &self.elem); - formatter.finish() + impl TypeReference { + fn debug(&self, formatter: &mut fmt::Formatter, name: &str) -> fmt::Result { + let mut formatter = formatter.debug_struct(name); + formatter.field("and_token", &self.and_token); + formatter.field("lifetime", &self.lifetime); + formatter.field("mutability", &self.mutability); + formatter.field("elem", &self.elem); + formatter.finish() + } + } + self.debug(formatter, "TypeReference") } } #[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Debug for TypeSlice { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let mut formatter = formatter.debug_struct("TypeSlice"); - formatter.field("bracket_token", &self.bracket_token); - formatter.field("elem", &self.elem); - formatter.finish() + impl TypeSlice { + fn debug(&self, formatter: &mut fmt::Formatter, name: &str) -> fmt::Result { + let mut formatter = formatter.debug_struct(name); + formatter.field("bracket_token", &self.bracket_token); + formatter.field("elem", &self.elem); + formatter.finish() + } + } + self.debug(formatter, "TypeSlice") } } #[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Debug for TypeTraitObject { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let mut formatter = formatter.debug_struct("TypeTraitObject"); - formatter.field("dyn_token", &self.dyn_token); - formatter.field("bounds", &self.bounds); - formatter.finish() + impl TypeTraitObject { + fn debug(&self, formatter: &mut fmt::Formatter, name: &str) -> fmt::Result { + let mut formatter = formatter.debug_struct(name); + formatter.field("dyn_token", &self.dyn_token); + formatter.field("bounds", &self.bounds); + formatter.finish() + } + } + self.debug(formatter, "TypeTraitObject") } } #[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Debug for TypeTuple { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let mut formatter = formatter.debug_struct("TypeTuple"); - formatter.field("paren_token", &self.paren_token); - formatter.field("elems", &self.elems); - formatter.finish() + impl TypeTuple { + fn debug(&self, formatter: &mut fmt::Formatter, name: &str) -> fmt::Result { + let mut formatter = formatter.debug_struct(name); + formatter.field("paren_token", &self.paren_token); + formatter.field("elems", &self.elems); + formatter.finish() + } + } + self.debug(formatter, "TypeTuple") } } #[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Debug for UnOp { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("UnOp::")?; match self { UnOp::Deref(v0) => { let mut formatter = formatter.debug_tuple("Deref"); @@ -2902,6 +2937,7 @@ impl Debug for UseRename { #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Debug for UseTree { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("UseTree::")?; match self { UseTree::Path(v0) => { let mut formatter = formatter.debug_tuple("Path"); @@ -2931,13 +2967,15 @@ impl Debug for UseTree { } } } -#[cfg(any(feature = "derive", feature = "full"))] +#[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Debug for Variadic { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { let mut formatter = formatter.debug_struct("Variadic"); formatter.field("attrs", &self.attrs); + formatter.field("pat", &self.pat); formatter.field("dots", &self.dots); + formatter.field("comma", &self.comma); formatter.finish() } } @@ -2955,54 +2993,33 @@ impl Debug for Variant { } #[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] -impl Debug for VisCrate { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let mut formatter = formatter.debug_struct("VisCrate"); - formatter.field("crate_token", &self.crate_token); - formatter.finish() - } -} -#[cfg(any(feature = "derive", feature = "full"))] -#[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] -impl Debug for VisPublic { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let mut formatter = formatter.debug_struct("VisPublic"); - formatter.field("pub_token", &self.pub_token); - formatter.finish() - } -} -#[cfg(any(feature = "derive", feature = "full"))] -#[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Debug for VisRestricted { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let mut formatter = formatter.debug_struct("VisRestricted"); - formatter.field("pub_token", &self.pub_token); - formatter.field("paren_token", &self.paren_token); - formatter.field("in_token", &self.in_token); - formatter.field("path", &self.path); - formatter.finish() + impl VisRestricted { + fn debug(&self, formatter: &mut fmt::Formatter, name: &str) -> fmt::Result { + let mut formatter = formatter.debug_struct(name); + formatter.field("pub_token", &self.pub_token); + formatter.field("paren_token", &self.paren_token); + formatter.field("in_token", &self.in_token); + formatter.field("path", &self.path); + formatter.finish() + } + } + self.debug(formatter, "VisRestricted") } } #[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Debug for Visibility { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("Visibility::")?; match self { Visibility::Public(v0) => { let mut formatter = formatter.debug_tuple("Public"); formatter.field(v0); formatter.finish() } - Visibility::Crate(v0) => { - let mut formatter = formatter.debug_tuple("Crate"); - formatter.field(v0); - formatter.finish() - } - Visibility::Restricted(v0) => { - let mut formatter = formatter.debug_tuple("Restricted"); - formatter.field(v0); - formatter.finish() - } + Visibility::Restricted(v0) => v0.debug(formatter, "Restricted"), Visibility::Inherited => formatter.write_str("Inherited"), } } @@ -3021,19 +3038,15 @@ impl Debug for WhereClause { #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Debug for WherePredicate { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("WherePredicate::")?; match self { - WherePredicate::Type(v0) => { - let mut formatter = formatter.debug_tuple("Type"); - formatter.field(v0); - formatter.finish() - } WherePredicate::Lifetime(v0) => { let mut formatter = formatter.debug_tuple("Lifetime"); formatter.field(v0); formatter.finish() } - WherePredicate::Eq(v0) => { - let mut formatter = formatter.debug_tuple("Eq"); + WherePredicate::Type(v0) => { + let mut formatter = formatter.debug_tuple("Type"); formatter.field(v0); formatter.finish() } diff --git a/vendor/syn/src/gen/eq.rs b/vendor/syn/src/gen/eq.rs index 20acb809d..a7479c300 100644 --- a/vendor/syn/src/gen/eq.rs +++ b/vendor/syn/src/gen/eq.rs @@ -37,6 +37,28 @@ impl PartialEq for Arm { } #[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] +impl Eq for AssocConst {} +#[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] +impl PartialEq for AssocConst { + fn eq(&self, other: &Self) -> bool { + self.ident == other.ident && self.generics == other.generics + && self.value == other.value + } +} +#[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] +impl Eq for AssocType {} +#[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] +impl PartialEq for AssocType { + fn eq(&self, other: &Self) -> bool { + self.ident == other.ident && self.generics == other.generics + && self.ty == other.ty + } +} +#[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Eq for AttrStyle {} #[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] @@ -56,8 +78,7 @@ impl Eq for Attribute {} #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl PartialEq for Attribute { fn eq(&self, other: &Self) -> bool { - self.style == other.style && self.path == other.path - && TokenStreamHelper(&self.tokens) == TokenStreamHelper(&other.tokens) + self.style == other.style && self.meta == other.meta } } #[cfg(any(feature = "derive", feature = "full"))] @@ -72,6 +93,16 @@ impl PartialEq for BareFnArg { } #[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] +impl Eq for BareVariadic {} +#[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] +impl PartialEq for BareVariadic { + fn eq(&self, other: &Self) -> bool { + self.attrs == other.attrs && self.name == other.name && self.comma == other.comma + } +} +#[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Eq for BinOp {} #[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] @@ -96,30 +127,20 @@ impl PartialEq for BinOp { (BinOp::Ne(_), BinOp::Ne(_)) => true, (BinOp::Ge(_), BinOp::Ge(_)) => true, (BinOp::Gt(_), BinOp::Gt(_)) => true, - (BinOp::AddEq(_), BinOp::AddEq(_)) => true, - (BinOp::SubEq(_), BinOp::SubEq(_)) => true, - (BinOp::MulEq(_), BinOp::MulEq(_)) => true, - (BinOp::DivEq(_), BinOp::DivEq(_)) => true, - (BinOp::RemEq(_), BinOp::RemEq(_)) => true, - (BinOp::BitXorEq(_), BinOp::BitXorEq(_)) => true, - (BinOp::BitAndEq(_), BinOp::BitAndEq(_)) => true, - (BinOp::BitOrEq(_), BinOp::BitOrEq(_)) => true, - (BinOp::ShlEq(_), BinOp::ShlEq(_)) => true, - (BinOp::ShrEq(_), BinOp::ShrEq(_)) => true, + (BinOp::AddAssign(_), BinOp::AddAssign(_)) => true, + (BinOp::SubAssign(_), BinOp::SubAssign(_)) => true, + (BinOp::MulAssign(_), BinOp::MulAssign(_)) => true, + (BinOp::DivAssign(_), BinOp::DivAssign(_)) => true, + (BinOp::RemAssign(_), BinOp::RemAssign(_)) => true, + (BinOp::BitXorAssign(_), BinOp::BitXorAssign(_)) => true, + (BinOp::BitAndAssign(_), BinOp::BitAndAssign(_)) => true, + (BinOp::BitOrAssign(_), BinOp::BitOrAssign(_)) => true, + (BinOp::ShlAssign(_), BinOp::ShlAssign(_)) => true, + (BinOp::ShrAssign(_), BinOp::ShrAssign(_)) => true, _ => false, } } } -#[cfg(any(feature = "derive", feature = "full"))] -#[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] -impl Eq for Binding {} -#[cfg(any(feature = "derive", feature = "full"))] -#[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] -impl PartialEq for Binding { - fn eq(&self, other: &Self) -> bool { - self.ident == other.ident && self.ty == other.ty - } -} #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Eq for Block {} @@ -158,7 +179,8 @@ impl Eq for Constraint {} #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl PartialEq for Constraint { fn eq(&self, other: &Self) -> bool { - self.ident == other.ident && self.bounds == other.bounds + self.ident == other.ident && self.generics == other.generics + && self.bounds == other.bounds } } #[cfg(feature = "derive")] @@ -230,8 +252,6 @@ impl PartialEq for Expr { #[cfg(feature = "full")] (Expr::Assign(self0), Expr::Assign(other0)) => self0 == other0, #[cfg(feature = "full")] - (Expr::AssignOp(self0), Expr::AssignOp(other0)) => self0 == other0, - #[cfg(feature = "full")] (Expr::Async(self0), Expr::Async(other0)) => self0 == other0, #[cfg(feature = "full")] (Expr::Await(self0), Expr::Await(other0)) => self0 == other0, @@ -239,29 +259,29 @@ impl PartialEq for Expr { #[cfg(feature = "full")] (Expr::Block(self0), Expr::Block(other0)) => self0 == other0, #[cfg(feature = "full")] - (Expr::Box(self0), Expr::Box(other0)) => self0 == other0, - #[cfg(feature = "full")] (Expr::Break(self0), Expr::Break(other0)) => self0 == other0, (Expr::Call(self0), Expr::Call(other0)) => self0 == other0, (Expr::Cast(self0), Expr::Cast(other0)) => self0 == other0, #[cfg(feature = "full")] (Expr::Closure(self0), Expr::Closure(other0)) => self0 == other0, #[cfg(feature = "full")] + (Expr::Const(self0), Expr::Const(other0)) => self0 == other0, + #[cfg(feature = "full")] (Expr::Continue(self0), Expr::Continue(other0)) => self0 == other0, (Expr::Field(self0), Expr::Field(other0)) => self0 == other0, #[cfg(feature = "full")] (Expr::ForLoop(self0), Expr::ForLoop(other0)) => self0 == other0, - #[cfg(feature = "full")] (Expr::Group(self0), Expr::Group(other0)) => self0 == other0, #[cfg(feature = "full")] (Expr::If(self0), Expr::If(other0)) => self0 == other0, (Expr::Index(self0), Expr::Index(other0)) => self0 == other0, #[cfg(feature = "full")] + (Expr::Infer(self0), Expr::Infer(other0)) => self0 == other0, + #[cfg(feature = "full")] (Expr::Let(self0), Expr::Let(other0)) => self0 == other0, (Expr::Lit(self0), Expr::Lit(other0)) => self0 == other0, #[cfg(feature = "full")] (Expr::Loop(self0), Expr::Loop(other0)) => self0 == other0, - #[cfg(feature = "full")] (Expr::Macro(self0), Expr::Macro(other0)) => self0 == other0, #[cfg(feature = "full")] (Expr::Match(self0), Expr::Match(other0)) => self0 == other0, @@ -285,8 +305,6 @@ impl PartialEq for Expr { (Expr::TryBlock(self0), Expr::TryBlock(other0)) => self0 == other0, #[cfg(feature = "full")] (Expr::Tuple(self0), Expr::Tuple(other0)) => self0 == other0, - #[cfg(feature = "full")] - (Expr::Type(self0), Expr::Type(other0)) => self0 == other0, (Expr::Unary(self0), Expr::Unary(other0)) => self0 == other0, #[cfg(feature = "full")] (Expr::Unsafe(self0), Expr::Unsafe(other0)) => self0 == other0, @@ -323,17 +341,6 @@ impl PartialEq for ExprAssign { } #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] -impl Eq for ExprAssignOp {} -#[cfg(feature = "full")] -#[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] -impl PartialEq for ExprAssignOp { - fn eq(&self, other: &Self) -> bool { - self.attrs == other.attrs && self.left == other.left && self.op == other.op - && self.right == other.right - } -} -#[cfg(feature = "full")] -#[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Eq for ExprAsync {} #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] @@ -377,16 +384,6 @@ impl PartialEq for ExprBlock { } #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] -impl Eq for ExprBox {} -#[cfg(feature = "full")] -#[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] -impl PartialEq for ExprBox { - fn eq(&self, other: &Self) -> bool { - self.attrs == other.attrs && self.expr == other.expr - } -} -#[cfg(feature = "full")] -#[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Eq for ExprBreak {} #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] @@ -422,7 +419,8 @@ impl Eq for ExprClosure {} #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl PartialEq for ExprClosure { fn eq(&self, other: &Self) -> bool { - self.attrs == other.attrs && self.movability == other.movability + self.attrs == other.attrs && self.lifetimes == other.lifetimes + && self.constness == other.constness && self.movability == other.movability && self.asyncness == other.asyncness && self.capture == other.capture && self.inputs == other.inputs && self.output == other.output && self.body == other.body @@ -430,6 +428,16 @@ impl PartialEq for ExprClosure { } #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] +impl Eq for ExprConst {} +#[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] +impl PartialEq for ExprConst { + fn eq(&self, other: &Self) -> bool { + self.attrs == other.attrs && self.block == other.block + } +} +#[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Eq for ExprContinue {} #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] @@ -460,10 +468,10 @@ impl PartialEq for ExprForLoop { && self.expr == other.expr && self.body == other.body } } -#[cfg(feature = "full")] +#[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Eq for ExprGroup {} -#[cfg(feature = "full")] +#[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl PartialEq for ExprGroup { fn eq(&self, other: &Self) -> bool { @@ -494,6 +502,16 @@ impl PartialEq for ExprIndex { } #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] +impl Eq for ExprInfer {} +#[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] +impl PartialEq for ExprInfer { + fn eq(&self, other: &Self) -> bool { + self.attrs == other.attrs + } +} +#[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Eq for ExprLet {} #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] @@ -522,10 +540,10 @@ impl PartialEq for ExprLoop { self.attrs == other.attrs && self.label == other.label && self.body == other.body } } -#[cfg(feature = "full")] +#[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Eq for ExprMacro {} -#[cfg(feature = "full")] +#[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl PartialEq for ExprMacro { fn eq(&self, other: &Self) -> bool { @@ -581,8 +599,8 @@ impl Eq for ExprRange {} #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl PartialEq for ExprRange { fn eq(&self, other: &Self) -> bool { - self.attrs == other.attrs && self.from == other.from - && self.limits == other.limits && self.to == other.to + self.attrs == other.attrs && self.start == other.start + && self.limits == other.limits && self.end == other.end } } #[cfg(feature = "full")] @@ -623,7 +641,7 @@ impl Eq for ExprStruct {} #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl PartialEq for ExprStruct { fn eq(&self, other: &Self) -> bool { - self.attrs == other.attrs && self.path == other.path + self.attrs == other.attrs && self.qself == other.qself && self.path == other.path && self.fields == other.fields && self.dot2_token == other.dot2_token && self.rest == other.rest } @@ -658,16 +676,6 @@ impl PartialEq for ExprTuple { self.attrs == other.attrs && self.elems == other.elems } } -#[cfg(feature = "full")] -#[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] -impl Eq for ExprType {} -#[cfg(feature = "full")] -#[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] -impl PartialEq for ExprType { - fn eq(&self, other: &Self) -> bool { - self.attrs == other.attrs && self.expr == other.expr && self.ty == other.ty - } -} #[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Eq for ExprUnary {} @@ -716,10 +724,23 @@ impl Eq for Field {} #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl PartialEq for Field { fn eq(&self, other: &Self) -> bool { - self.attrs == other.attrs && self.vis == other.vis && self.ident == other.ident + self.attrs == other.attrs && self.vis == other.vis + && self.mutability == other.mutability && self.ident == other.ident && self.colon_token == other.colon_token && self.ty == other.ty } } +#[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] +impl Eq for FieldMutability {} +#[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] +impl PartialEq for FieldMutability { + fn eq(&self, other: &Self) -> bool { + match (self, other) { + (FieldMutability::None, FieldMutability::None) => true, + } + } +} #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Eq for FieldPat {} @@ -862,6 +883,7 @@ impl Eq for ForeignItemType {} impl PartialEq for ForeignItemType { fn eq(&self, other: &Self) -> bool { self.attrs == other.attrs && self.vis == other.vis && self.ident == other.ident + && self.generics == other.generics } } #[cfg(any(feature = "derive", feature = "full"))] @@ -881,31 +903,15 @@ impl PartialEq for GenericArgument { (GenericArgument::Const(self0), GenericArgument::Const(other0)) => { self0 == other0 } - (GenericArgument::Binding(self0), GenericArgument::Binding(other0)) => { + (GenericArgument::AssocType(self0), GenericArgument::AssocType(other0)) => { self0 == other0 } - (GenericArgument::Constraint(self0), GenericArgument::Constraint(other0)) => { + (GenericArgument::AssocConst(self0), GenericArgument::AssocConst(other0)) => { self0 == other0 } - _ => false, - } - } -} -#[cfg(feature = "full")] -#[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] -impl Eq for GenericMethodArgument {} -#[cfg(feature = "full")] -#[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] -impl PartialEq for GenericMethodArgument { - fn eq(&self, other: &Self) -> bool { - match (self, other) { - (GenericMethodArgument::Type(self0), GenericMethodArgument::Type(other0)) => { + (GenericArgument::Constraint(self0), GenericArgument::Constraint(other0)) => { self0 == other0 } - ( - GenericMethodArgument::Const(self0), - GenericMethodArgument::Const(other0), - ) => self0 == other0, _ => false, } } @@ -918,10 +924,10 @@ impl Eq for GenericParam {} impl PartialEq for GenericParam { fn eq(&self, other: &Self) -> bool { match (self, other) { - (GenericParam::Type(self0), GenericParam::Type(other0)) => self0 == other0, (GenericParam::Lifetime(self0), GenericParam::Lifetime(other0)) => { self0 == other0 } + (GenericParam::Type(self0), GenericParam::Type(other0)) => self0 == other0, (GenericParam::Const(self0), GenericParam::Const(other0)) => self0 == other0, _ => false, } @@ -947,7 +953,7 @@ impl PartialEq for ImplItem { fn eq(&self, other: &Self) -> bool { match (self, other) { (ImplItem::Const(self0), ImplItem::Const(other0)) => self0 == other0, - (ImplItem::Method(self0), ImplItem::Method(other0)) => self0 == other0, + (ImplItem::Fn(self0), ImplItem::Fn(other0)) => self0 == other0, (ImplItem::Type(self0), ImplItem::Type(other0)) => self0 == other0, (ImplItem::Macro(self0), ImplItem::Macro(other0)) => self0 == other0, (ImplItem::Verbatim(self0), ImplItem::Verbatim(other0)) => { @@ -966,30 +972,31 @@ impl PartialEq for ImplItemConst { fn eq(&self, other: &Self) -> bool { self.attrs == other.attrs && self.vis == other.vis && self.defaultness == other.defaultness && self.ident == other.ident - && self.ty == other.ty && self.expr == other.expr + && self.generics == other.generics && self.ty == other.ty + && self.expr == other.expr } } #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] -impl Eq for ImplItemMacro {} +impl Eq for ImplItemFn {} #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] -impl PartialEq for ImplItemMacro { +impl PartialEq for ImplItemFn { fn eq(&self, other: &Self) -> bool { - self.attrs == other.attrs && self.mac == other.mac - && self.semi_token == other.semi_token + self.attrs == other.attrs && self.vis == other.vis + && self.defaultness == other.defaultness && self.sig == other.sig + && self.block == other.block } } #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] -impl Eq for ImplItemMethod {} +impl Eq for ImplItemMacro {} #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] -impl PartialEq for ImplItemMethod { +impl PartialEq for ImplItemMacro { fn eq(&self, other: &Self) -> bool { - self.attrs == other.attrs && self.vis == other.vis - && self.defaultness == other.defaultness && self.sig == other.sig - && self.block == other.block + self.attrs == other.attrs && self.mac == other.mac + && self.semi_token == other.semi_token } } #[cfg(feature = "full")] @@ -1006,6 +1013,16 @@ impl PartialEq for ImplItemType { } #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] +impl Eq for ImplRestriction {} +#[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] +impl PartialEq for ImplRestriction { + fn eq(&self, _other: &Self) -> bool { + match *self {} + } +} +#[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Eq for Item {} #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] @@ -1019,7 +1036,6 @@ impl PartialEq for Item { (Item::ForeignMod(self0), Item::ForeignMod(other0)) => self0 == other0, (Item::Impl(self0), Item::Impl(other0)) => self0 == other0, (Item::Macro(self0), Item::Macro(other0)) => self0 == other0, - (Item::Macro2(self0), Item::Macro2(other0)) => self0 == other0, (Item::Mod(self0), Item::Mod(other0)) => self0 == other0, (Item::Static(self0), Item::Static(other0)) => self0 == other0, (Item::Struct(self0), Item::Struct(other0)) => self0 == other0, @@ -1043,7 +1059,8 @@ impl Eq for ItemConst {} impl PartialEq for ItemConst { fn eq(&self, other: &Self) -> bool { self.attrs == other.attrs && self.vis == other.vis && self.ident == other.ident - && self.ty == other.ty && self.expr == other.expr + && self.generics == other.generics && self.ty == other.ty + && self.expr == other.expr } } #[cfg(feature = "full")] @@ -1086,7 +1103,8 @@ impl Eq for ItemForeignMod {} #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl PartialEq for ItemForeignMod { fn eq(&self, other: &Self) -> bool { - self.attrs == other.attrs && self.abi == other.abi && self.items == other.items + self.attrs == other.attrs && self.unsafety == other.unsafety + && self.abi == other.abi && self.items == other.items } } #[cfg(feature = "full")] @@ -1115,23 +1133,13 @@ impl PartialEq for ItemMacro { } #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] -impl Eq for ItemMacro2 {} -#[cfg(feature = "full")] -#[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] -impl PartialEq for ItemMacro2 { - fn eq(&self, other: &Self) -> bool { - self.attrs == other.attrs && self.vis == other.vis && self.ident == other.ident - && TokenStreamHelper(&self.rules) == TokenStreamHelper(&other.rules) - } -} -#[cfg(feature = "full")] -#[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Eq for ItemMod {} #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl PartialEq for ItemMod { fn eq(&self, other: &Self) -> bool { - self.attrs == other.attrs && self.vis == other.vis && self.ident == other.ident + self.attrs == other.attrs && self.vis == other.vis + && self.unsafety == other.unsafety && self.ident == other.ident && self.content == other.content && self.semi == other.semi } } @@ -1168,8 +1176,8 @@ impl PartialEq for ItemTrait { fn eq(&self, other: &Self) -> bool { self.attrs == other.attrs && self.vis == other.vis && self.unsafety == other.unsafety && self.auto_token == other.auto_token - && self.ident == other.ident && self.generics == other.generics - && self.colon_token == other.colon_token + && self.restriction == other.restriction && self.ident == other.ident + && self.generics == other.generics && self.colon_token == other.colon_token && self.supertraits == other.supertraits && self.items == other.items } } @@ -1229,10 +1237,10 @@ impl PartialEq for Label { } #[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] -impl Eq for LifetimeDef {} +impl Eq for LifetimeParam {} #[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] -impl PartialEq for LifetimeDef { +impl PartialEq for LifetimeParam { fn eq(&self, other: &Self) -> bool { self.attrs == other.attrs && self.lifetime == other.lifetime && self.colon_token == other.colon_token && self.bounds == other.bounds @@ -1288,6 +1296,16 @@ impl PartialEq for Local { self.attrs == other.attrs && self.pat == other.pat && self.init == other.init } } +#[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] +impl Eq for LocalInit {} +#[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] +impl PartialEq for LocalInit { + fn eq(&self, other: &Self) -> bool { + self.expr == other.expr && self.diverge == other.diverge + } +} #[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Eq for Macro {} @@ -1336,7 +1354,8 @@ impl Eq for MetaList {} #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl PartialEq for MetaList { fn eq(&self, other: &Self) -> bool { - self.path == other.path && self.nested == other.nested + self.path == other.path && self.delimiter == other.delimiter + && TokenStreamHelper(&self.tokens) == TokenStreamHelper(&other.tokens) } } #[cfg(any(feature = "derive", feature = "full"))] @@ -1346,31 +1365,7 @@ impl Eq for MetaNameValue {} #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl PartialEq for MetaNameValue { fn eq(&self, other: &Self) -> bool { - self.path == other.path && self.lit == other.lit - } -} -#[cfg(feature = "full")] -#[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] -impl Eq for MethodTurbofish {} -#[cfg(feature = "full")] -#[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] -impl PartialEq for MethodTurbofish { - fn eq(&self, other: &Self) -> bool { - self.args == other.args - } -} -#[cfg(any(feature = "derive", feature = "full"))] -#[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] -impl Eq for NestedMeta {} -#[cfg(any(feature = "derive", feature = "full"))] -#[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] -impl PartialEq for NestedMeta { - fn eq(&self, other: &Self) -> bool { - match (self, other) { - (NestedMeta::Meta(self0), NestedMeta::Meta(other0)) => self0 == other0, - (NestedMeta::Lit(self0), NestedMeta::Lit(other0)) => self0 == other0, - _ => false, - } + self.path == other.path && self.value == other.value } } #[cfg(any(feature = "derive", feature = "full"))] @@ -1391,11 +1386,12 @@ impl Eq for Pat {} impl PartialEq for Pat { fn eq(&self, other: &Self) -> bool { match (self, other) { - (Pat::Box(self0), Pat::Box(other0)) => self0 == other0, + (Pat::Const(self0), Pat::Const(other0)) => self0 == other0, (Pat::Ident(self0), Pat::Ident(other0)) => self0 == other0, (Pat::Lit(self0), Pat::Lit(other0)) => self0 == other0, (Pat::Macro(self0), Pat::Macro(other0)) => self0 == other0, (Pat::Or(self0), Pat::Or(other0)) => self0 == other0, + (Pat::Paren(self0), Pat::Paren(other0)) => self0 == other0, (Pat::Path(self0), Pat::Path(other0)) => self0 == other0, (Pat::Range(self0), Pat::Range(other0)) => self0 == other0, (Pat::Reference(self0), Pat::Reference(other0)) => self0 == other0, @@ -1415,16 +1411,6 @@ impl PartialEq for Pat { } #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] -impl Eq for PatBox {} -#[cfg(feature = "full")] -#[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] -impl PartialEq for PatBox { - fn eq(&self, other: &Self) -> bool { - self.attrs == other.attrs && self.pat == other.pat - } -} -#[cfg(feature = "full")] -#[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Eq for PatIdent {} #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] @@ -1437,26 +1423,6 @@ impl PartialEq for PatIdent { } #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] -impl Eq for PatLit {} -#[cfg(feature = "full")] -#[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] -impl PartialEq for PatLit { - fn eq(&self, other: &Self) -> bool { - self.attrs == other.attrs && self.expr == other.expr - } -} -#[cfg(feature = "full")] -#[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] -impl Eq for PatMacro {} -#[cfg(feature = "full")] -#[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] -impl PartialEq for PatMacro { - fn eq(&self, other: &Self) -> bool { - self.attrs == other.attrs && self.mac == other.mac - } -} -#[cfg(feature = "full")] -#[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Eq for PatOr {} #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] @@ -1468,23 +1434,12 @@ impl PartialEq for PatOr { } #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] -impl Eq for PatPath {} -#[cfg(feature = "full")] -#[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] -impl PartialEq for PatPath { - fn eq(&self, other: &Self) -> bool { - self.attrs == other.attrs && self.qself == other.qself && self.path == other.path - } -} -#[cfg(feature = "full")] -#[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] -impl Eq for PatRange {} +impl Eq for PatParen {} #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] -impl PartialEq for PatRange { +impl PartialEq for PatParen { fn eq(&self, other: &Self) -> bool { - self.attrs == other.attrs && self.lo == other.lo && self.limits == other.limits - && self.hi == other.hi + self.attrs == other.attrs && self.pat == other.pat } } #[cfg(feature = "full")] @@ -1525,8 +1480,8 @@ impl Eq for PatStruct {} #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl PartialEq for PatStruct { fn eq(&self, other: &Self) -> bool { - self.attrs == other.attrs && self.path == other.path - && self.fields == other.fields && self.dot2_token == other.dot2_token + self.attrs == other.attrs && self.qself == other.qself && self.path == other.path + && self.fields == other.fields && self.rest == other.rest } } #[cfg(feature = "full")] @@ -1546,7 +1501,8 @@ impl Eq for PatTupleStruct {} #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl PartialEq for PatTupleStruct { fn eq(&self, other: &Self) -> bool { - self.attrs == other.attrs && self.path == other.path && self.pat == other.pat + self.attrs == other.attrs && self.qself == other.qself && self.path == other.path + && self.elems == other.elems } } #[cfg(feature = "full")] @@ -1612,16 +1568,6 @@ impl PartialEq for PathSegment { } #[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] -impl Eq for PredicateEq {} -#[cfg(any(feature = "derive", feature = "full"))] -#[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] -impl PartialEq for PredicateEq { - fn eq(&self, other: &Self) -> bool { - self.lhs_ty == other.lhs_ty && self.rhs_ty == other.rhs_ty - } -} -#[cfg(any(feature = "derive", feature = "full"))] -#[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Eq for PredicateLifetime {} #[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] @@ -1675,6 +1621,7 @@ impl PartialEq for Receiver { fn eq(&self, other: &Self) -> bool { self.attrs == other.attrs && self.reference == other.reference && self.mutability == other.mutability + && self.colon_token == other.colon_token && self.ty == other.ty } } #[cfg(any(feature = "derive", feature = "full"))] @@ -1707,6 +1654,20 @@ impl PartialEq for Signature { } #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] +impl Eq for StaticMutability {} +#[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] +impl PartialEq for StaticMutability { + fn eq(&self, other: &Self) -> bool { + match (self, other) { + (StaticMutability::Mut(_), StaticMutability::Mut(_)) => true, + (StaticMutability::None, StaticMutability::None) => true, + _ => false, + } + } +} +#[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Eq for Stmt {} #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] @@ -1715,12 +1676,25 @@ impl PartialEq for Stmt { match (self, other) { (Stmt::Local(self0), Stmt::Local(other0)) => self0 == other0, (Stmt::Item(self0), Stmt::Item(other0)) => self0 == other0, - (Stmt::Expr(self0), Stmt::Expr(other0)) => self0 == other0, - (Stmt::Semi(self0, _), Stmt::Semi(other0, _)) => self0 == other0, + (Stmt::Expr(self0, self1), Stmt::Expr(other0, other1)) => { + self0 == other0 && self1 == other1 + } + (Stmt::Macro(self0), Stmt::Macro(other0)) => self0 == other0, _ => false, } } } +#[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] +impl Eq for StmtMacro {} +#[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] +impl PartialEq for StmtMacro { + fn eq(&self, other: &Self) -> bool { + self.attrs == other.attrs && self.mac == other.mac + && self.semi_token == other.semi_token + } +} #[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Eq for TraitBound {} @@ -1755,7 +1729,7 @@ impl PartialEq for TraitItem { fn eq(&self, other: &Self) -> bool { match (self, other) { (TraitItem::Const(self0), TraitItem::Const(other0)) => self0 == other0, - (TraitItem::Method(self0), TraitItem::Method(other0)) => self0 == other0, + (TraitItem::Fn(self0), TraitItem::Fn(other0)) => self0 == other0, (TraitItem::Type(self0), TraitItem::Type(other0)) => self0 == other0, (TraitItem::Macro(self0), TraitItem::Macro(other0)) => self0 == other0, (TraitItem::Verbatim(self0), TraitItem::Verbatim(other0)) => { @@ -1772,30 +1746,31 @@ impl Eq for TraitItemConst {} #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl PartialEq for TraitItemConst { fn eq(&self, other: &Self) -> bool { - self.attrs == other.attrs && self.ident == other.ident && self.ty == other.ty + self.attrs == other.attrs && self.ident == other.ident + && self.generics == other.generics && self.ty == other.ty && self.default == other.default } } #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] -impl Eq for TraitItemMacro {} +impl Eq for TraitItemFn {} #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] -impl PartialEq for TraitItemMacro { +impl PartialEq for TraitItemFn { fn eq(&self, other: &Self) -> bool { - self.attrs == other.attrs && self.mac == other.mac - && self.semi_token == other.semi_token + self.attrs == other.attrs && self.sig == other.sig + && self.default == other.default && self.semi_token == other.semi_token } } #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] -impl Eq for TraitItemMethod {} +impl Eq for TraitItemMacro {} #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] -impl PartialEq for TraitItemMethod { +impl PartialEq for TraitItemMacro { fn eq(&self, other: &Self) -> bool { - self.attrs == other.attrs && self.sig == other.sig - && self.default == other.default && self.semi_token == other.semi_token + self.attrs == other.attrs && self.mac == other.mac + && self.semi_token == other.semi_token } } #[cfg(feature = "full")] @@ -1937,6 +1912,9 @@ impl PartialEq for TypeParamBound { (TypeParamBound::Lifetime(self0), TypeParamBound::Lifetime(other0)) => { self0 == other0 } + (TypeParamBound::Verbatim(self0), TypeParamBound::Verbatim(other0)) => { + TokenStreamHelper(self0) == TokenStreamHelper(other0) + } _ => false, } } @@ -2095,14 +2073,14 @@ impl PartialEq for UseTree { } } } -#[cfg(any(feature = "derive", feature = "full"))] +#[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Eq for Variadic {} -#[cfg(any(feature = "derive", feature = "full"))] +#[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl PartialEq for Variadic { fn eq(&self, other: &Self) -> bool { - self.attrs == other.attrs + self.attrs == other.attrs && self.pat == other.pat && self.comma == other.comma } } #[cfg(any(feature = "derive", feature = "full"))] @@ -2118,26 +2096,6 @@ impl PartialEq for Variant { } #[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] -impl Eq for VisCrate {} -#[cfg(any(feature = "derive", feature = "full"))] -#[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] -impl PartialEq for VisCrate { - fn eq(&self, _other: &Self) -> bool { - true - } -} -#[cfg(any(feature = "derive", feature = "full"))] -#[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] -impl Eq for VisPublic {} -#[cfg(any(feature = "derive", feature = "full"))] -#[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] -impl PartialEq for VisPublic { - fn eq(&self, _other: &Self) -> bool { - true - } -} -#[cfg(any(feature = "derive", feature = "full"))] -#[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Eq for VisRestricted {} #[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] @@ -2154,8 +2112,7 @@ impl Eq for Visibility {} impl PartialEq for Visibility { fn eq(&self, other: &Self) -> bool { match (self, other) { - (Visibility::Public(self0), Visibility::Public(other0)) => self0 == other0, - (Visibility::Crate(self0), Visibility::Crate(other0)) => self0 == other0, + (Visibility::Public(_), Visibility::Public(_)) => true, (Visibility::Restricted(self0), Visibility::Restricted(other0)) => { self0 == other0 } @@ -2182,13 +2139,12 @@ impl Eq for WherePredicate {} impl PartialEq for WherePredicate { fn eq(&self, other: &Self) -> bool { match (self, other) { - (WherePredicate::Type(self0), WherePredicate::Type(other0)) => { + (WherePredicate::Lifetime(self0), WherePredicate::Lifetime(other0)) => { self0 == other0 } - (WherePredicate::Lifetime(self0), WherePredicate::Lifetime(other0)) => { + (WherePredicate::Type(self0), WherePredicate::Type(other0)) => { self0 == other0 } - (WherePredicate::Eq(self0), WherePredicate::Eq(other0)) => self0 == other0, _ => false, } } diff --git a/vendor/syn/src/gen/fold.rs b/vendor/syn/src/gen/fold.rs index 98bb5794a..624c15b17 100644 --- a/vendor/syn/src/gen/fold.rs +++ b/vendor/syn/src/gen/fold.rs @@ -2,11 +2,9 @@ // It is not intended for manual editing. #![allow(unreachable_code, unused_variables)] -#![allow(clippy::match_wildcard_for_single_variants)] +#![allow(clippy::match_wildcard_for_single_variants, clippy::needless_match)] #[cfg(any(feature = "full", feature = "derive"))] use crate::gen::helper::fold::*; -#[cfg(any(feature = "full", feature = "derive"))] -use crate::token::{Brace, Bracket, Group, Paren}; use crate::*; use proc_macro2::Span; #[cfg(feature = "full")] @@ -26,8 +24,6 @@ macro_rules! full { /// See the [module documentation] for details. /// /// [module documentation]: self -/// -/// *This trait is available only if Syn is built with the `"fold"` feature.* pub trait Fold { #[cfg(any(feature = "derive", feature = "full"))] fn fold_abi(&mut self, i: Abi) -> Abi { @@ -45,6 +41,14 @@ pub trait Fold { fold_arm(self, i) } #[cfg(any(feature = "derive", feature = "full"))] + fn fold_assoc_const(&mut self, i: AssocConst) -> AssocConst { + fold_assoc_const(self, i) + } + #[cfg(any(feature = "derive", feature = "full"))] + fn fold_assoc_type(&mut self, i: AssocType) -> AssocType { + fold_assoc_type(self, i) + } + #[cfg(any(feature = "derive", feature = "full"))] fn fold_attr_style(&mut self, i: AttrStyle) -> AttrStyle { fold_attr_style(self, i) } @@ -57,12 +61,12 @@ pub trait Fold { fold_bare_fn_arg(self, i) } #[cfg(any(feature = "derive", feature = "full"))] - fn fold_bin_op(&mut self, i: BinOp) -> BinOp { - fold_bin_op(self, i) + fn fold_bare_variadic(&mut self, i: BareVariadic) -> BareVariadic { + fold_bare_variadic(self, i) } #[cfg(any(feature = "derive", feature = "full"))] - fn fold_binding(&mut self, i: Binding) -> Binding { - fold_binding(self, i) + fn fold_bin_op(&mut self, i: BinOp) -> BinOp { + fold_bin_op(self, i) } #[cfg(feature = "full")] fn fold_block(&mut self, i: Block) -> Block { @@ -113,10 +117,6 @@ pub trait Fold { fold_expr_assign(self, i) } #[cfg(feature = "full")] - fn fold_expr_assign_op(&mut self, i: ExprAssignOp) -> ExprAssignOp { - fold_expr_assign_op(self, i) - } - #[cfg(feature = "full")] fn fold_expr_async(&mut self, i: ExprAsync) -> ExprAsync { fold_expr_async(self, i) } @@ -133,10 +133,6 @@ pub trait Fold { fold_expr_block(self, i) } #[cfg(feature = "full")] - fn fold_expr_box(&mut self, i: ExprBox) -> ExprBox { - fold_expr_box(self, i) - } - #[cfg(feature = "full")] fn fold_expr_break(&mut self, i: ExprBreak) -> ExprBreak { fold_expr_break(self, i) } @@ -153,6 +149,10 @@ pub trait Fold { fold_expr_closure(self, i) } #[cfg(feature = "full")] + fn fold_expr_const(&mut self, i: ExprConst) -> ExprConst { + fold_expr_const(self, i) + } + #[cfg(feature = "full")] fn fold_expr_continue(&mut self, i: ExprContinue) -> ExprContinue { fold_expr_continue(self, i) } @@ -164,7 +164,7 @@ pub trait Fold { fn fold_expr_for_loop(&mut self, i: ExprForLoop) -> ExprForLoop { fold_expr_for_loop(self, i) } - #[cfg(feature = "full")] + #[cfg(any(feature = "derive", feature = "full"))] fn fold_expr_group(&mut self, i: ExprGroup) -> ExprGroup { fold_expr_group(self, i) } @@ -177,6 +177,10 @@ pub trait Fold { fold_expr_index(self, i) } #[cfg(feature = "full")] + fn fold_expr_infer(&mut self, i: ExprInfer) -> ExprInfer { + fold_expr_infer(self, i) + } + #[cfg(feature = "full")] fn fold_expr_let(&mut self, i: ExprLet) -> ExprLet { fold_expr_let(self, i) } @@ -188,7 +192,7 @@ pub trait Fold { fn fold_expr_loop(&mut self, i: ExprLoop) -> ExprLoop { fold_expr_loop(self, i) } - #[cfg(feature = "full")] + #[cfg(any(feature = "derive", feature = "full"))] fn fold_expr_macro(&mut self, i: ExprMacro) -> ExprMacro { fold_expr_macro(self, i) } @@ -240,10 +244,6 @@ pub trait Fold { fn fold_expr_tuple(&mut self, i: ExprTuple) -> ExprTuple { fold_expr_tuple(self, i) } - #[cfg(feature = "full")] - fn fold_expr_type(&mut self, i: ExprType) -> ExprType { - fold_expr_type(self, i) - } #[cfg(any(feature = "derive", feature = "full"))] fn fold_expr_unary(&mut self, i: ExprUnary) -> ExprUnary { fold_expr_unary(self, i) @@ -264,6 +264,10 @@ pub trait Fold { fn fold_field(&mut self, i: Field) -> Field { fold_field(self, i) } + #[cfg(any(feature = "derive", feature = "full"))] + fn fold_field_mutability(&mut self, i: FieldMutability) -> FieldMutability { + fold_field_mutability(self, i) + } #[cfg(feature = "full")] fn fold_field_pat(&mut self, i: FieldPat) -> FieldPat { fold_field_pat(self, i) @@ -316,13 +320,6 @@ pub trait Fold { fn fold_generic_argument(&mut self, i: GenericArgument) -> GenericArgument { fold_generic_argument(self, i) } - #[cfg(feature = "full")] - fn fold_generic_method_argument( - &mut self, - i: GenericMethodArgument, - ) -> GenericMethodArgument { - fold_generic_method_argument(self, i) - } #[cfg(any(feature = "derive", feature = "full"))] fn fold_generic_param(&mut self, i: GenericParam) -> GenericParam { fold_generic_param(self, i) @@ -343,17 +340,21 @@ pub trait Fold { fold_impl_item_const(self, i) } #[cfg(feature = "full")] - fn fold_impl_item_macro(&mut self, i: ImplItemMacro) -> ImplItemMacro { - fold_impl_item_macro(self, i) + fn fold_impl_item_fn(&mut self, i: ImplItemFn) -> ImplItemFn { + fold_impl_item_fn(self, i) } #[cfg(feature = "full")] - fn fold_impl_item_method(&mut self, i: ImplItemMethod) -> ImplItemMethod { - fold_impl_item_method(self, i) + fn fold_impl_item_macro(&mut self, i: ImplItemMacro) -> ImplItemMacro { + fold_impl_item_macro(self, i) } #[cfg(feature = "full")] fn fold_impl_item_type(&mut self, i: ImplItemType) -> ImplItemType { fold_impl_item_type(self, i) } + #[cfg(feature = "full")] + fn fold_impl_restriction(&mut self, i: ImplRestriction) -> ImplRestriction { + fold_impl_restriction(self, i) + } #[cfg(any(feature = "derive", feature = "full"))] fn fold_index(&mut self, i: Index) -> Index { fold_index(self, i) @@ -391,10 +392,6 @@ pub trait Fold { fold_item_macro(self, i) } #[cfg(feature = "full")] - fn fold_item_macro2(&mut self, i: ItemMacro2) -> ItemMacro2 { - fold_item_macro2(self, i) - } - #[cfg(feature = "full")] fn fold_item_mod(&mut self, i: ItemMod) -> ItemMod { fold_item_mod(self, i) } @@ -434,8 +431,8 @@ pub trait Fold { fold_lifetime(self, i) } #[cfg(any(feature = "derive", feature = "full"))] - fn fold_lifetime_def(&mut self, i: LifetimeDef) -> LifetimeDef { - fold_lifetime_def(self, i) + fn fold_lifetime_param(&mut self, i: LifetimeParam) -> LifetimeParam { + fold_lifetime_param(self, i) } fn fold_lit(&mut self, i: Lit) -> Lit { fold_lit(self, i) @@ -465,6 +462,10 @@ pub trait Fold { fn fold_local(&mut self, i: Local) -> Local { fold_local(self, i) } + #[cfg(feature = "full")] + fn fold_local_init(&mut self, i: LocalInit) -> LocalInit { + fold_local_init(self, i) + } #[cfg(any(feature = "derive", feature = "full"))] fn fold_macro(&mut self, i: Macro) -> Macro { fold_macro(self, i) @@ -489,14 +490,6 @@ pub trait Fold { fn fold_meta_name_value(&mut self, i: MetaNameValue) -> MetaNameValue { fold_meta_name_value(self, i) } - #[cfg(feature = "full")] - fn fold_method_turbofish(&mut self, i: MethodTurbofish) -> MethodTurbofish { - fold_method_turbofish(self, i) - } - #[cfg(any(feature = "derive", feature = "full"))] - fn fold_nested_meta(&mut self, i: NestedMeta) -> NestedMeta { - fold_nested_meta(self, i) - } #[cfg(any(feature = "derive", feature = "full"))] fn fold_parenthesized_generic_arguments( &mut self, @@ -509,32 +502,16 @@ pub trait Fold { fold_pat(self, i) } #[cfg(feature = "full")] - fn fold_pat_box(&mut self, i: PatBox) -> PatBox { - fold_pat_box(self, i) - } - #[cfg(feature = "full")] fn fold_pat_ident(&mut self, i: PatIdent) -> PatIdent { fold_pat_ident(self, i) } #[cfg(feature = "full")] - fn fold_pat_lit(&mut self, i: PatLit) -> PatLit { - fold_pat_lit(self, i) - } - #[cfg(feature = "full")] - fn fold_pat_macro(&mut self, i: PatMacro) -> PatMacro { - fold_pat_macro(self, i) - } - #[cfg(feature = "full")] fn fold_pat_or(&mut self, i: PatOr) -> PatOr { fold_pat_or(self, i) } #[cfg(feature = "full")] - fn fold_pat_path(&mut self, i: PatPath) -> PatPath { - fold_pat_path(self, i) - } - #[cfg(feature = "full")] - fn fold_pat_range(&mut self, i: PatRange) -> PatRange { - fold_pat_range(self, i) + fn fold_pat_paren(&mut self, i: PatParen) -> PatParen { + fold_pat_paren(self, i) } #[cfg(feature = "full")] fn fold_pat_reference(&mut self, i: PatReference) -> PatReference { @@ -581,10 +558,6 @@ pub trait Fold { fold_path_segment(self, i) } #[cfg(any(feature = "derive", feature = "full"))] - fn fold_predicate_eq(&mut self, i: PredicateEq) -> PredicateEq { - fold_predicate_eq(self, i) - } - #[cfg(any(feature = "derive", feature = "full"))] fn fold_predicate_lifetime(&mut self, i: PredicateLifetime) -> PredicateLifetime { fold_predicate_lifetime(self, i) } @@ -616,9 +589,17 @@ pub trait Fold { fold_span(self, i) } #[cfg(feature = "full")] + fn fold_static_mutability(&mut self, i: StaticMutability) -> StaticMutability { + fold_static_mutability(self, i) + } + #[cfg(feature = "full")] fn fold_stmt(&mut self, i: Stmt) -> Stmt { fold_stmt(self, i) } + #[cfg(feature = "full")] + fn fold_stmt_macro(&mut self, i: StmtMacro) -> StmtMacro { + fold_stmt_macro(self, i) + } #[cfg(any(feature = "derive", feature = "full"))] fn fold_trait_bound(&mut self, i: TraitBound) -> TraitBound { fold_trait_bound(self, i) @@ -639,12 +620,12 @@ pub trait Fold { fold_trait_item_const(self, i) } #[cfg(feature = "full")] - fn fold_trait_item_macro(&mut self, i: TraitItemMacro) -> TraitItemMacro { - fold_trait_item_macro(self, i) + fn fold_trait_item_fn(&mut self, i: TraitItemFn) -> TraitItemFn { + fold_trait_item_fn(self, i) } #[cfg(feature = "full")] - fn fold_trait_item_method(&mut self, i: TraitItemMethod) -> TraitItemMethod { - fold_trait_item_method(self, i) + fn fold_trait_item_macro(&mut self, i: TraitItemMacro) -> TraitItemMacro { + fold_trait_item_macro(self, i) } #[cfg(feature = "full")] fn fold_trait_item_type(&mut self, i: TraitItemType) -> TraitItemType { @@ -746,7 +727,7 @@ pub trait Fold { fn fold_use_tree(&mut self, i: UseTree) -> UseTree { fold_use_tree(self, i) } - #[cfg(any(feature = "derive", feature = "full"))] + #[cfg(feature = "full")] fn fold_variadic(&mut self, i: Variadic) -> Variadic { fold_variadic(self, i) } @@ -755,14 +736,6 @@ pub trait Fold { fold_variant(self, i) } #[cfg(any(feature = "derive", feature = "full"))] - fn fold_vis_crate(&mut self, i: VisCrate) -> VisCrate { - fold_vis_crate(self, i) - } - #[cfg(any(feature = "derive", feature = "full"))] - fn fold_vis_public(&mut self, i: VisPublic) -> VisPublic { - fold_vis_public(self, i) - } - #[cfg(any(feature = "derive", feature = "full"))] fn fold_vis_restricted(&mut self, i: VisRestricted) -> VisRestricted { fold_vis_restricted(self, i) } @@ -785,7 +758,7 @@ where F: Fold + ?Sized, { Abi { - extern_token: Token![extern](tokens_helper(f, &node.extern_token.span)), + extern_token: node.extern_token, name: (node.name).map(|it| f.fold_lit_str(it)), } } @@ -798,11 +771,10 @@ where F: Fold + ?Sized, { AngleBracketedGenericArguments { - colon2_token: (node.colon2_token) - .map(|it| Token![::](tokens_helper(f, &it.spans))), - lt_token: Token![<](tokens_helper(f, &node.lt_token.spans)), + colon2_token: node.colon2_token, + lt_token: node.lt_token, args: FoldHelper::lift(node.args, |it| f.fold_generic_argument(it)), - gt_token: Token![>](tokens_helper(f, &node.gt_token.spans)), + gt_token: node.gt_token, } } #[cfg(feature = "full")] @@ -813,14 +785,34 @@ where Arm { attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), pat: f.fold_pat(node.pat), - guard: (node.guard) - .map(|it| ( - Token![if](tokens_helper(f, &(it).0.span)), - Box::new(f.fold_expr(*(it).1)), - )), - fat_arrow_token: Token![=>](tokens_helper(f, &node.fat_arrow_token.spans)), + guard: (node.guard).map(|it| ((it).0, Box::new(f.fold_expr(*(it).1)))), + fat_arrow_token: node.fat_arrow_token, body: Box::new(f.fold_expr(*node.body)), - comma: (node.comma).map(|it| Token![,](tokens_helper(f, &it.spans))), + comma: node.comma, + } +} +#[cfg(any(feature = "derive", feature = "full"))] +pub fn fold_assoc_const<F>(f: &mut F, node: AssocConst) -> AssocConst +where + F: Fold + ?Sized, +{ + AssocConst { + ident: f.fold_ident(node.ident), + generics: (node.generics).map(|it| f.fold_angle_bracketed_generic_arguments(it)), + eq_token: node.eq_token, + value: f.fold_expr(node.value), + } +} +#[cfg(any(feature = "derive", feature = "full"))] +pub fn fold_assoc_type<F>(f: &mut F, node: AssocType) -> AssocType +where + F: Fold + ?Sized, +{ + AssocType { + ident: f.fold_ident(node.ident), + generics: (node.generics).map(|it| f.fold_angle_bracketed_generic_arguments(it)), + eq_token: node.eq_token, + ty: f.fold_type(node.ty), } } #[cfg(any(feature = "derive", feature = "full"))] @@ -830,9 +822,7 @@ where { match node { AttrStyle::Outer => AttrStyle::Outer, - AttrStyle::Inner(_binding_0) => { - AttrStyle::Inner(Token![!](tokens_helper(f, &_binding_0.spans))) - } + AttrStyle::Inner(_binding_0) => AttrStyle::Inner(_binding_0), } } #[cfg(any(feature = "derive", feature = "full"))] @@ -841,11 +831,10 @@ where F: Fold + ?Sized, { Attribute { - pound_token: Token![#](tokens_helper(f, &node.pound_token.spans)), + pound_token: node.pound_token, style: f.fold_attr_style(node.style), - bracket_token: Bracket(tokens_helper(f, &node.bracket_token.span)), - path: f.fold_path(node.path), - tokens: node.tokens, + bracket_token: node.bracket_token, + meta: f.fold_meta(node.meta), } } #[cfg(any(feature = "derive", feature = "full"))] @@ -855,115 +844,56 @@ where { BareFnArg { attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), - name: (node.name) - .map(|it| ( - f.fold_ident((it).0), - Token![:](tokens_helper(f, &(it).1.spans)), - )), + name: (node.name).map(|it| (f.fold_ident((it).0), (it).1)), ty: f.fold_type(node.ty), } } #[cfg(any(feature = "derive", feature = "full"))] -pub fn fold_bin_op<F>(f: &mut F, node: BinOp) -> BinOp +pub fn fold_bare_variadic<F>(f: &mut F, node: BareVariadic) -> BareVariadic where F: Fold + ?Sized, { - match node { - BinOp::Add(_binding_0) => { - BinOp::Add(Token![+](tokens_helper(f, &_binding_0.spans))) - } - BinOp::Sub(_binding_0) => { - BinOp::Sub(Token![-](tokens_helper(f, &_binding_0.spans))) - } - BinOp::Mul(_binding_0) => { - BinOp::Mul(Token![*](tokens_helper(f, &_binding_0.spans))) - } - BinOp::Div(_binding_0) => { - BinOp::Div(Token![/](tokens_helper(f, &_binding_0.spans))) - } - BinOp::Rem(_binding_0) => { - BinOp::Rem(Token![%](tokens_helper(f, &_binding_0.spans))) - } - BinOp::And(_binding_0) => { - BinOp::And(Token![&&](tokens_helper(f, &_binding_0.spans))) - } - BinOp::Or(_binding_0) => { - BinOp::Or(Token![||](tokens_helper(f, &_binding_0.spans))) - } - BinOp::BitXor(_binding_0) => { - BinOp::BitXor(Token![^](tokens_helper(f, &_binding_0.spans))) - } - BinOp::BitAnd(_binding_0) => { - BinOp::BitAnd(Token![&](tokens_helper(f, &_binding_0.spans))) - } - BinOp::BitOr(_binding_0) => { - BinOp::BitOr(Token![|](tokens_helper(f, &_binding_0.spans))) - } - BinOp::Shl(_binding_0) => { - BinOp::Shl(Token![<<](tokens_helper(f, &_binding_0.spans))) - } - BinOp::Shr(_binding_0) => { - BinOp::Shr(Token![>>](tokens_helper(f, &_binding_0.spans))) - } - BinOp::Eq(_binding_0) => { - BinOp::Eq(Token![==](tokens_helper(f, &_binding_0.spans))) - } - BinOp::Lt(_binding_0) => { - BinOp::Lt(Token![<](tokens_helper(f, &_binding_0.spans))) - } - BinOp::Le(_binding_0) => { - BinOp::Le(Token![<=](tokens_helper(f, &_binding_0.spans))) - } - BinOp::Ne(_binding_0) => { - BinOp::Ne(Token![!=](tokens_helper(f, &_binding_0.spans))) - } - BinOp::Ge(_binding_0) => { - BinOp::Ge(Token![>=](tokens_helper(f, &_binding_0.spans))) - } - BinOp::Gt(_binding_0) => { - BinOp::Gt(Token![>](tokens_helper(f, &_binding_0.spans))) - } - BinOp::AddEq(_binding_0) => { - BinOp::AddEq(Token![+=](tokens_helper(f, &_binding_0.spans))) - } - BinOp::SubEq(_binding_0) => { - BinOp::SubEq(Token![-=](tokens_helper(f, &_binding_0.spans))) - } - BinOp::MulEq(_binding_0) => { - BinOp::MulEq(Token![*=](tokens_helper(f, &_binding_0.spans))) - } - BinOp::DivEq(_binding_0) => { - BinOp::DivEq(Token![/=](tokens_helper(f, &_binding_0.spans))) - } - BinOp::RemEq(_binding_0) => { - BinOp::RemEq(Token![%=](tokens_helper(f, &_binding_0.spans))) - } - BinOp::BitXorEq(_binding_0) => { - BinOp::BitXorEq(Token![^=](tokens_helper(f, &_binding_0.spans))) - } - BinOp::BitAndEq(_binding_0) => { - BinOp::BitAndEq(Token![&=](tokens_helper(f, &_binding_0.spans))) - } - BinOp::BitOrEq(_binding_0) => { - BinOp::BitOrEq(Token![|=](tokens_helper(f, &_binding_0.spans))) - } - BinOp::ShlEq(_binding_0) => { - BinOp::ShlEq(Token![<<=](tokens_helper(f, &_binding_0.spans))) - } - BinOp::ShrEq(_binding_0) => { - BinOp::ShrEq(Token![>>=](tokens_helper(f, &_binding_0.spans))) - } + BareVariadic { + attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), + name: (node.name).map(|it| (f.fold_ident((it).0), (it).1)), + dots: node.dots, + comma: node.comma, } } #[cfg(any(feature = "derive", feature = "full"))] -pub fn fold_binding<F>(f: &mut F, node: Binding) -> Binding +pub fn fold_bin_op<F>(f: &mut F, node: BinOp) -> BinOp where F: Fold + ?Sized, { - Binding { - ident: f.fold_ident(node.ident), - eq_token: Token![=](tokens_helper(f, &node.eq_token.spans)), - ty: f.fold_type(node.ty), + match node { + BinOp::Add(_binding_0) => BinOp::Add(_binding_0), + BinOp::Sub(_binding_0) => BinOp::Sub(_binding_0), + BinOp::Mul(_binding_0) => BinOp::Mul(_binding_0), + BinOp::Div(_binding_0) => BinOp::Div(_binding_0), + BinOp::Rem(_binding_0) => BinOp::Rem(_binding_0), + BinOp::And(_binding_0) => BinOp::And(_binding_0), + BinOp::Or(_binding_0) => BinOp::Or(_binding_0), + BinOp::BitXor(_binding_0) => BinOp::BitXor(_binding_0), + BinOp::BitAnd(_binding_0) => BinOp::BitAnd(_binding_0), + BinOp::BitOr(_binding_0) => BinOp::BitOr(_binding_0), + BinOp::Shl(_binding_0) => BinOp::Shl(_binding_0), + BinOp::Shr(_binding_0) => BinOp::Shr(_binding_0), + BinOp::Eq(_binding_0) => BinOp::Eq(_binding_0), + BinOp::Lt(_binding_0) => BinOp::Lt(_binding_0), + BinOp::Le(_binding_0) => BinOp::Le(_binding_0), + BinOp::Ne(_binding_0) => BinOp::Ne(_binding_0), + BinOp::Ge(_binding_0) => BinOp::Ge(_binding_0), + BinOp::Gt(_binding_0) => BinOp::Gt(_binding_0), + BinOp::AddAssign(_binding_0) => BinOp::AddAssign(_binding_0), + BinOp::SubAssign(_binding_0) => BinOp::SubAssign(_binding_0), + BinOp::MulAssign(_binding_0) => BinOp::MulAssign(_binding_0), + BinOp::DivAssign(_binding_0) => BinOp::DivAssign(_binding_0), + BinOp::RemAssign(_binding_0) => BinOp::RemAssign(_binding_0), + BinOp::BitXorAssign(_binding_0) => BinOp::BitXorAssign(_binding_0), + BinOp::BitAndAssign(_binding_0) => BinOp::BitAndAssign(_binding_0), + BinOp::BitOrAssign(_binding_0) => BinOp::BitOrAssign(_binding_0), + BinOp::ShlAssign(_binding_0) => BinOp::ShlAssign(_binding_0), + BinOp::ShrAssign(_binding_0) => BinOp::ShrAssign(_binding_0), } } #[cfg(feature = "full")] @@ -972,7 +902,7 @@ where F: Fold + ?Sized, { Block { - brace_token: Brace(tokens_helper(f, &node.brace_token.span)), + brace_token: node.brace_token, stmts: FoldHelper::lift(node.stmts, |it| f.fold_stmt(it)), } } @@ -982,10 +912,10 @@ where F: Fold + ?Sized, { BoundLifetimes { - for_token: Token![for](tokens_helper(f, &node.for_token.span)), - lt_token: Token![<](tokens_helper(f, &node.lt_token.spans)), - lifetimes: FoldHelper::lift(node.lifetimes, |it| f.fold_lifetime_def(it)), - gt_token: Token![>](tokens_helper(f, &node.gt_token.spans)), + for_token: node.for_token, + lt_token: node.lt_token, + lifetimes: FoldHelper::lift(node.lifetimes, |it| f.fold_generic_param(it)), + gt_token: node.gt_token, } } #[cfg(any(feature = "derive", feature = "full"))] @@ -995,11 +925,11 @@ where { ConstParam { attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), - const_token: Token![const](tokens_helper(f, &node.const_token.span)), + const_token: node.const_token, ident: f.fold_ident(node.ident), - colon_token: Token![:](tokens_helper(f, &node.colon_token.spans)), + colon_token: node.colon_token, ty: f.fold_type(node.ty), - eq_token: (node.eq_token).map(|it| Token![=](tokens_helper(f, &it.spans))), + eq_token: node.eq_token, default: (node.default).map(|it| f.fold_expr(it)), } } @@ -1010,7 +940,8 @@ where { Constraint { ident: f.fold_ident(node.ident), - colon_token: Token![:](tokens_helper(f, &node.colon_token.spans)), + generics: (node.generics).map(|it| f.fold_angle_bracketed_generic_arguments(it)), + colon_token: node.colon_token, bounds: FoldHelper::lift(node.bounds, |it| f.fold_type_param_bound(it)), } } @@ -1031,8 +962,8 @@ where F: Fold + ?Sized, { DataEnum { - enum_token: Token![enum](tokens_helper(f, &node.enum_token.span)), - brace_token: Brace(tokens_helper(f, &node.brace_token.span)), + enum_token: node.enum_token, + brace_token: node.brace_token, variants: FoldHelper::lift(node.variants, |it| f.fold_variant(it)), } } @@ -1042,9 +973,9 @@ where F: Fold + ?Sized, { DataStruct { - struct_token: Token![struct](tokens_helper(f, &node.struct_token.span)), + struct_token: node.struct_token, fields: f.fold_fields(node.fields), - semi_token: (node.semi_token).map(|it| Token![;](tokens_helper(f, &it.spans))), + semi_token: node.semi_token, } } #[cfg(feature = "derive")] @@ -1053,7 +984,7 @@ where F: Fold + ?Sized, { DataUnion { - union_token: Token![union](tokens_helper(f, &node.union_token.span)), + union_token: node.union_token, fields: f.fold_fields_named(node.fields), } } @@ -1078,20 +1009,17 @@ where match node { Expr::Array(_binding_0) => Expr::Array(full!(f.fold_expr_array(_binding_0))), Expr::Assign(_binding_0) => Expr::Assign(full!(f.fold_expr_assign(_binding_0))), - Expr::AssignOp(_binding_0) => { - Expr::AssignOp(full!(f.fold_expr_assign_op(_binding_0))) - } Expr::Async(_binding_0) => Expr::Async(full!(f.fold_expr_async(_binding_0))), Expr::Await(_binding_0) => Expr::Await(full!(f.fold_expr_await(_binding_0))), Expr::Binary(_binding_0) => Expr::Binary(f.fold_expr_binary(_binding_0)), Expr::Block(_binding_0) => Expr::Block(full!(f.fold_expr_block(_binding_0))), - Expr::Box(_binding_0) => Expr::Box(full!(f.fold_expr_box(_binding_0))), Expr::Break(_binding_0) => Expr::Break(full!(f.fold_expr_break(_binding_0))), Expr::Call(_binding_0) => Expr::Call(f.fold_expr_call(_binding_0)), Expr::Cast(_binding_0) => Expr::Cast(f.fold_expr_cast(_binding_0)), Expr::Closure(_binding_0) => { Expr::Closure(full!(f.fold_expr_closure(_binding_0))) } + Expr::Const(_binding_0) => Expr::Const(full!(f.fold_expr_const(_binding_0))), Expr::Continue(_binding_0) => { Expr::Continue(full!(f.fold_expr_continue(_binding_0))) } @@ -1099,13 +1027,14 @@ where Expr::ForLoop(_binding_0) => { Expr::ForLoop(full!(f.fold_expr_for_loop(_binding_0))) } - Expr::Group(_binding_0) => Expr::Group(full!(f.fold_expr_group(_binding_0))), + Expr::Group(_binding_0) => Expr::Group(f.fold_expr_group(_binding_0)), Expr::If(_binding_0) => Expr::If(full!(f.fold_expr_if(_binding_0))), Expr::Index(_binding_0) => Expr::Index(f.fold_expr_index(_binding_0)), + Expr::Infer(_binding_0) => Expr::Infer(full!(f.fold_expr_infer(_binding_0))), Expr::Let(_binding_0) => Expr::Let(full!(f.fold_expr_let(_binding_0))), Expr::Lit(_binding_0) => Expr::Lit(f.fold_expr_lit(_binding_0)), Expr::Loop(_binding_0) => Expr::Loop(full!(f.fold_expr_loop(_binding_0))), - Expr::Macro(_binding_0) => Expr::Macro(full!(f.fold_expr_macro(_binding_0))), + Expr::Macro(_binding_0) => Expr::Macro(f.fold_expr_macro(_binding_0)), Expr::Match(_binding_0) => Expr::Match(full!(f.fold_expr_match(_binding_0))), Expr::MethodCall(_binding_0) => { Expr::MethodCall(full!(f.fold_expr_method_call(_binding_0))) @@ -1124,14 +1053,11 @@ where Expr::TryBlock(full!(f.fold_expr_try_block(_binding_0))) } Expr::Tuple(_binding_0) => Expr::Tuple(full!(f.fold_expr_tuple(_binding_0))), - Expr::Type(_binding_0) => Expr::Type(full!(f.fold_expr_type(_binding_0))), Expr::Unary(_binding_0) => Expr::Unary(f.fold_expr_unary(_binding_0)), Expr::Unsafe(_binding_0) => Expr::Unsafe(full!(f.fold_expr_unsafe(_binding_0))), Expr::Verbatim(_binding_0) => Expr::Verbatim(_binding_0), Expr::While(_binding_0) => Expr::While(full!(f.fold_expr_while(_binding_0))), Expr::Yield(_binding_0) => Expr::Yield(full!(f.fold_expr_yield(_binding_0))), - #[cfg(syn_no_non_exhaustive)] - _ => unreachable!(), } } #[cfg(feature = "full")] @@ -1141,7 +1067,7 @@ where { ExprArray { attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), - bracket_token: Bracket(tokens_helper(f, &node.bracket_token.span)), + bracket_token: node.bracket_token, elems: FoldHelper::lift(node.elems, |it| f.fold_expr(it)), } } @@ -1153,19 +1079,7 @@ where ExprAssign { attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), left: Box::new(f.fold_expr(*node.left)), - eq_token: Token![=](tokens_helper(f, &node.eq_token.spans)), - right: Box::new(f.fold_expr(*node.right)), - } -} -#[cfg(feature = "full")] -pub fn fold_expr_assign_op<F>(f: &mut F, node: ExprAssignOp) -> ExprAssignOp -where - F: Fold + ?Sized, -{ - ExprAssignOp { - attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), - left: Box::new(f.fold_expr(*node.left)), - op: f.fold_bin_op(node.op), + eq_token: node.eq_token, right: Box::new(f.fold_expr(*node.right)), } } @@ -1176,8 +1090,8 @@ where { ExprAsync { attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), - async_token: Token![async](tokens_helper(f, &node.async_token.span)), - capture: (node.capture).map(|it| Token![move](tokens_helper(f, &it.span))), + async_token: node.async_token, + capture: node.capture, block: f.fold_block(node.block), } } @@ -1189,8 +1103,8 @@ where ExprAwait { attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), base: Box::new(f.fold_expr(*node.base)), - dot_token: Token![.](tokens_helper(f, &node.dot_token.spans)), - await_token: crate::token::Await(tokens_helper(f, &node.await_token.span)), + dot_token: node.dot_token, + await_token: node.await_token, } } #[cfg(any(feature = "derive", feature = "full"))] @@ -1217,24 +1131,13 @@ where } } #[cfg(feature = "full")] -pub fn fold_expr_box<F>(f: &mut F, node: ExprBox) -> ExprBox -where - F: Fold + ?Sized, -{ - ExprBox { - attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), - box_token: Token![box](tokens_helper(f, &node.box_token.span)), - expr: Box::new(f.fold_expr(*node.expr)), - } -} -#[cfg(feature = "full")] pub fn fold_expr_break<F>(f: &mut F, node: ExprBreak) -> ExprBreak where F: Fold + ?Sized, { ExprBreak { attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), - break_token: Token![break](tokens_helper(f, &node.break_token.span)), + break_token: node.break_token, label: (node.label).map(|it| f.fold_lifetime(it)), expr: (node.expr).map(|it| Box::new(f.fold_expr(*it))), } @@ -1247,7 +1150,7 @@ where ExprCall { attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), func: Box::new(f.fold_expr(*node.func)), - paren_token: Paren(tokens_helper(f, &node.paren_token.span)), + paren_token: node.paren_token, args: FoldHelper::lift(node.args, |it| f.fold_expr(it)), } } @@ -1259,7 +1162,7 @@ where ExprCast { attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), expr: Box::new(f.fold_expr(*node.expr)), - as_token: Token![as](tokens_helper(f, &node.as_token.span)), + as_token: node.as_token, ty: Box::new(f.fold_type(*node.ty)), } } @@ -1270,25 +1173,37 @@ where { ExprClosure { attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), - movability: (node.movability) - .map(|it| Token![static](tokens_helper(f, &it.span))), - asyncness: (node.asyncness).map(|it| Token![async](tokens_helper(f, &it.span))), - capture: (node.capture).map(|it| Token![move](tokens_helper(f, &it.span))), - or1_token: Token![|](tokens_helper(f, &node.or1_token.spans)), + lifetimes: (node.lifetimes).map(|it| f.fold_bound_lifetimes(it)), + constness: node.constness, + movability: node.movability, + asyncness: node.asyncness, + capture: node.capture, + or1_token: node.or1_token, inputs: FoldHelper::lift(node.inputs, |it| f.fold_pat(it)), - or2_token: Token![|](tokens_helper(f, &node.or2_token.spans)), + or2_token: node.or2_token, output: f.fold_return_type(node.output), body: Box::new(f.fold_expr(*node.body)), } } #[cfg(feature = "full")] +pub fn fold_expr_const<F>(f: &mut F, node: ExprConst) -> ExprConst +where + F: Fold + ?Sized, +{ + ExprConst { + attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), + const_token: node.const_token, + block: f.fold_block(node.block), + } +} +#[cfg(feature = "full")] pub fn fold_expr_continue<F>(f: &mut F, node: ExprContinue) -> ExprContinue where F: Fold + ?Sized, { ExprContinue { attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), - continue_token: Token![continue](tokens_helper(f, &node.continue_token.span)), + continue_token: node.continue_token, label: (node.label).map(|it| f.fold_lifetime(it)), } } @@ -1300,7 +1215,7 @@ where ExprField { attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), base: Box::new(f.fold_expr(*node.base)), - dot_token: Token![.](tokens_helper(f, &node.dot_token.spans)), + dot_token: node.dot_token, member: f.fold_member(node.member), } } @@ -1312,21 +1227,21 @@ where ExprForLoop { attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), label: (node.label).map(|it| f.fold_label(it)), - for_token: Token![for](tokens_helper(f, &node.for_token.span)), - pat: f.fold_pat(node.pat), - in_token: Token![in](tokens_helper(f, &node.in_token.span)), + for_token: node.for_token, + pat: Box::new(f.fold_pat(*node.pat)), + in_token: node.in_token, expr: Box::new(f.fold_expr(*node.expr)), body: f.fold_block(node.body), } } -#[cfg(feature = "full")] +#[cfg(any(feature = "derive", feature = "full"))] pub fn fold_expr_group<F>(f: &mut F, node: ExprGroup) -> ExprGroup where F: Fold + ?Sized, { ExprGroup { attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), - group_token: Group(tokens_helper(f, &node.group_token.span)), + group_token: node.group_token, expr: Box::new(f.fold_expr(*node.expr)), } } @@ -1337,14 +1252,11 @@ where { ExprIf { attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), - if_token: Token![if](tokens_helper(f, &node.if_token.span)), + if_token: node.if_token, cond: Box::new(f.fold_expr(*node.cond)), then_branch: f.fold_block(node.then_branch), else_branch: (node.else_branch) - .map(|it| ( - Token![else](tokens_helper(f, &(it).0.span)), - Box::new(f.fold_expr(*(it).1)), - )), + .map(|it| ((it).0, Box::new(f.fold_expr(*(it).1)))), } } #[cfg(any(feature = "derive", feature = "full"))] @@ -1355,20 +1267,30 @@ where ExprIndex { attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), expr: Box::new(f.fold_expr(*node.expr)), - bracket_token: Bracket(tokens_helper(f, &node.bracket_token.span)), + bracket_token: node.bracket_token, index: Box::new(f.fold_expr(*node.index)), } } #[cfg(feature = "full")] +pub fn fold_expr_infer<F>(f: &mut F, node: ExprInfer) -> ExprInfer +where + F: Fold + ?Sized, +{ + ExprInfer { + attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), + underscore_token: node.underscore_token, + } +} +#[cfg(feature = "full")] pub fn fold_expr_let<F>(f: &mut F, node: ExprLet) -> ExprLet where F: Fold + ?Sized, { ExprLet { attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), - let_token: Token![let](tokens_helper(f, &node.let_token.span)), - pat: f.fold_pat(node.pat), - eq_token: Token![=](tokens_helper(f, &node.eq_token.spans)), + let_token: node.let_token, + pat: Box::new(f.fold_pat(*node.pat)), + eq_token: node.eq_token, expr: Box::new(f.fold_expr(*node.expr)), } } @@ -1390,11 +1312,11 @@ where ExprLoop { attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), label: (node.label).map(|it| f.fold_label(it)), - loop_token: Token![loop](tokens_helper(f, &node.loop_token.span)), + loop_token: node.loop_token, body: f.fold_block(node.body), } } -#[cfg(feature = "full")] +#[cfg(any(feature = "derive", feature = "full"))] pub fn fold_expr_macro<F>(f: &mut F, node: ExprMacro) -> ExprMacro where F: Fold + ?Sized, @@ -1411,9 +1333,9 @@ where { ExprMatch { attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), - match_token: Token![match](tokens_helper(f, &node.match_token.span)), + match_token: node.match_token, expr: Box::new(f.fold_expr(*node.expr)), - brace_token: Brace(tokens_helper(f, &node.brace_token.span)), + brace_token: node.brace_token, arms: FoldHelper::lift(node.arms, |it| f.fold_arm(it)), } } @@ -1425,10 +1347,11 @@ where ExprMethodCall { attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), receiver: Box::new(f.fold_expr(*node.receiver)), - dot_token: Token![.](tokens_helper(f, &node.dot_token.spans)), + dot_token: node.dot_token, method: f.fold_ident(node.method), - turbofish: (node.turbofish).map(|it| f.fold_method_turbofish(it)), - paren_token: Paren(tokens_helper(f, &node.paren_token.span)), + turbofish: (node.turbofish) + .map(|it| f.fold_angle_bracketed_generic_arguments(it)), + paren_token: node.paren_token, args: FoldHelper::lift(node.args, |it| f.fold_expr(it)), } } @@ -1439,7 +1362,7 @@ where { ExprParen { attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), - paren_token: Paren(tokens_helper(f, &node.paren_token.span)), + paren_token: node.paren_token, expr: Box::new(f.fold_expr(*node.expr)), } } @@ -1461,9 +1384,9 @@ where { ExprRange { attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), - from: (node.from).map(|it| Box::new(f.fold_expr(*it))), + start: (node.start).map(|it| Box::new(f.fold_expr(*it))), limits: f.fold_range_limits(node.limits), - to: (node.to).map(|it| Box::new(f.fold_expr(*it))), + end: (node.end).map(|it| Box::new(f.fold_expr(*it))), } } #[cfg(feature = "full")] @@ -1473,9 +1396,8 @@ where { ExprReference { attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), - and_token: Token![&](tokens_helper(f, &node.and_token.spans)), - raw: node.raw, - mutability: (node.mutability).map(|it| Token![mut](tokens_helper(f, &it.span))), + and_token: node.and_token, + mutability: node.mutability, expr: Box::new(f.fold_expr(*node.expr)), } } @@ -1486,9 +1408,9 @@ where { ExprRepeat { attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), - bracket_token: Bracket(tokens_helper(f, &node.bracket_token.span)), + bracket_token: node.bracket_token, expr: Box::new(f.fold_expr(*node.expr)), - semi_token: Token![;](tokens_helper(f, &node.semi_token.spans)), + semi_token: node.semi_token, len: Box::new(f.fold_expr(*node.len)), } } @@ -1499,7 +1421,7 @@ where { ExprReturn { attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), - return_token: Token![return](tokens_helper(f, &node.return_token.span)), + return_token: node.return_token, expr: (node.expr).map(|it| Box::new(f.fold_expr(*it))), } } @@ -1510,10 +1432,11 @@ where { ExprStruct { attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), + qself: (node.qself).map(|it| f.fold_qself(it)), path: f.fold_path(node.path), - brace_token: Brace(tokens_helper(f, &node.brace_token.span)), + brace_token: node.brace_token, fields: FoldHelper::lift(node.fields, |it| f.fold_field_value(it)), - dot2_token: (node.dot2_token).map(|it| Token![..](tokens_helper(f, &it.spans))), + dot2_token: node.dot2_token, rest: (node.rest).map(|it| Box::new(f.fold_expr(*it))), } } @@ -1525,7 +1448,7 @@ where ExprTry { attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), expr: Box::new(f.fold_expr(*node.expr)), - question_token: Token![?](tokens_helper(f, &node.question_token.spans)), + question_token: node.question_token, } } #[cfg(feature = "full")] @@ -1535,7 +1458,7 @@ where { ExprTryBlock { attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), - try_token: Token![try](tokens_helper(f, &node.try_token.span)), + try_token: node.try_token, block: f.fold_block(node.block), } } @@ -1546,22 +1469,10 @@ where { ExprTuple { attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), - paren_token: Paren(tokens_helper(f, &node.paren_token.span)), + paren_token: node.paren_token, elems: FoldHelper::lift(node.elems, |it| f.fold_expr(it)), } } -#[cfg(feature = "full")] -pub fn fold_expr_type<F>(f: &mut F, node: ExprType) -> ExprType -where - F: Fold + ?Sized, -{ - ExprType { - attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), - expr: Box::new(f.fold_expr(*node.expr)), - colon_token: Token![:](tokens_helper(f, &node.colon_token.spans)), - ty: Box::new(f.fold_type(*node.ty)), - } -} #[cfg(any(feature = "derive", feature = "full"))] pub fn fold_expr_unary<F>(f: &mut F, node: ExprUnary) -> ExprUnary where @@ -1580,7 +1491,7 @@ where { ExprUnsafe { attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), - unsafe_token: Token![unsafe](tokens_helper(f, &node.unsafe_token.span)), + unsafe_token: node.unsafe_token, block: f.fold_block(node.block), } } @@ -1592,7 +1503,7 @@ where ExprWhile { attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), label: (node.label).map(|it| f.fold_label(it)), - while_token: Token![while](tokens_helper(f, &node.while_token.span)), + while_token: node.while_token, cond: Box::new(f.fold_expr(*node.cond)), body: f.fold_block(node.body), } @@ -1604,7 +1515,7 @@ where { ExprYield { attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), - yield_token: Token![yield](tokens_helper(f, &node.yield_token.span)), + yield_token: node.yield_token, expr: (node.expr).map(|it| Box::new(f.fold_expr(*it))), } } @@ -1616,11 +1527,21 @@ where Field { attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), vis: f.fold_visibility(node.vis), + mutability: f.fold_field_mutability(node.mutability), ident: (node.ident).map(|it| f.fold_ident(it)), - colon_token: (node.colon_token).map(|it| Token![:](tokens_helper(f, &it.spans))), + colon_token: node.colon_token, ty: f.fold_type(node.ty), } } +#[cfg(any(feature = "derive", feature = "full"))] +pub fn fold_field_mutability<F>(f: &mut F, node: FieldMutability) -> FieldMutability +where + F: Fold + ?Sized, +{ + match node { + FieldMutability::None => FieldMutability::None, + } +} #[cfg(feature = "full")] pub fn fold_field_pat<F>(f: &mut F, node: FieldPat) -> FieldPat where @@ -1629,7 +1550,7 @@ where FieldPat { attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), member: f.fold_member(node.member), - colon_token: (node.colon_token).map(|it| Token![:](tokens_helper(f, &it.spans))), + colon_token: node.colon_token, pat: Box::new(f.fold_pat(*node.pat)), } } @@ -1641,7 +1562,7 @@ where FieldValue { attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), member: f.fold_member(node.member), - colon_token: (node.colon_token).map(|it| Token![:](tokens_helper(f, &it.spans))), + colon_token: node.colon_token, expr: f.fold_expr(node.expr), } } @@ -1662,7 +1583,7 @@ where F: Fold + ?Sized, { FieldsNamed { - brace_token: Brace(tokens_helper(f, &node.brace_token.span)), + brace_token: node.brace_token, named: FoldHelper::lift(node.named, |it| f.fold_field(it)), } } @@ -1672,7 +1593,7 @@ where F: Fold + ?Sized, { FieldsUnnamed { - paren_token: Paren(tokens_helper(f, &node.paren_token.span)), + paren_token: node.paren_token, unnamed: FoldHelper::lift(node.unnamed, |it| f.fold_field(it)), } } @@ -1716,8 +1637,6 @@ where ForeignItem::Macro(f.fold_foreign_item_macro(_binding_0)) } ForeignItem::Verbatim(_binding_0) => ForeignItem::Verbatim(_binding_0), - #[cfg(syn_no_non_exhaustive)] - _ => unreachable!(), } } #[cfg(feature = "full")] @@ -1729,7 +1648,7 @@ where attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), vis: f.fold_visibility(node.vis), sig: f.fold_signature(node.sig), - semi_token: Token![;](tokens_helper(f, &node.semi_token.spans)), + semi_token: node.semi_token, } } #[cfg(feature = "full")] @@ -1740,7 +1659,7 @@ where ForeignItemMacro { attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), mac: f.fold_macro(node.mac), - semi_token: (node.semi_token).map(|it| Token![;](tokens_helper(f, &it.spans))), + semi_token: node.semi_token, } } #[cfg(feature = "full")] @@ -1754,12 +1673,12 @@ where ForeignItemStatic { attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), vis: f.fold_visibility(node.vis), - static_token: Token![static](tokens_helper(f, &node.static_token.span)), - mutability: (node.mutability).map(|it| Token![mut](tokens_helper(f, &it.span))), + static_token: node.static_token, + mutability: f.fold_static_mutability(node.mutability), ident: f.fold_ident(node.ident), - colon_token: Token![:](tokens_helper(f, &node.colon_token.spans)), + colon_token: node.colon_token, ty: Box::new(f.fold_type(*node.ty)), - semi_token: Token![;](tokens_helper(f, &node.semi_token.spans)), + semi_token: node.semi_token, } } #[cfg(feature = "full")] @@ -1770,9 +1689,10 @@ where ForeignItemType { attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), vis: f.fold_visibility(node.vis), - type_token: Token![type](tokens_helper(f, &node.type_token.span)), + type_token: node.type_token, ident: f.fold_ident(node.ident), - semi_token: Token![;](tokens_helper(f, &node.semi_token.spans)), + generics: f.fold_generics(node.generics), + semi_token: node.semi_token, } } #[cfg(any(feature = "derive", feature = "full"))] @@ -1790,43 +1710,29 @@ where GenericArgument::Const(_binding_0) => { GenericArgument::Const(f.fold_expr(_binding_0)) } - GenericArgument::Binding(_binding_0) => { - GenericArgument::Binding(f.fold_binding(_binding_0)) + GenericArgument::AssocType(_binding_0) => { + GenericArgument::AssocType(f.fold_assoc_type(_binding_0)) + } + GenericArgument::AssocConst(_binding_0) => { + GenericArgument::AssocConst(f.fold_assoc_const(_binding_0)) } GenericArgument::Constraint(_binding_0) => { GenericArgument::Constraint(f.fold_constraint(_binding_0)) } } } -#[cfg(feature = "full")] -pub fn fold_generic_method_argument<F>( - f: &mut F, - node: GenericMethodArgument, -) -> GenericMethodArgument -where - F: Fold + ?Sized, -{ - match node { - GenericMethodArgument::Type(_binding_0) => { - GenericMethodArgument::Type(f.fold_type(_binding_0)) - } - GenericMethodArgument::Const(_binding_0) => { - GenericMethodArgument::Const(f.fold_expr(_binding_0)) - } - } -} #[cfg(any(feature = "derive", feature = "full"))] pub fn fold_generic_param<F>(f: &mut F, node: GenericParam) -> GenericParam where F: Fold + ?Sized, { match node { + GenericParam::Lifetime(_binding_0) => { + GenericParam::Lifetime(f.fold_lifetime_param(_binding_0)) + } GenericParam::Type(_binding_0) => { GenericParam::Type(f.fold_type_param(_binding_0)) } - GenericParam::Lifetime(_binding_0) => { - GenericParam::Lifetime(f.fold_lifetime_def(_binding_0)) - } GenericParam::Const(_binding_0) => { GenericParam::Const(f.fold_const_param(_binding_0)) } @@ -1838,9 +1744,9 @@ where F: Fold + ?Sized, { Generics { - lt_token: (node.lt_token).map(|it| Token![<](tokens_helper(f, &it.spans))), + lt_token: node.lt_token, params: FoldHelper::lift(node.params, |it| f.fold_generic_param(it)), - gt_token: (node.gt_token).map(|it| Token![>](tokens_helper(f, &it.spans))), + gt_token: node.gt_token, where_clause: (node.where_clause).map(|it| f.fold_where_clause(it)), } } @@ -1862,16 +1768,12 @@ where ImplItem::Const(_binding_0) => { ImplItem::Const(f.fold_impl_item_const(_binding_0)) } - ImplItem::Method(_binding_0) => { - ImplItem::Method(f.fold_impl_item_method(_binding_0)) - } + ImplItem::Fn(_binding_0) => ImplItem::Fn(f.fold_impl_item_fn(_binding_0)), ImplItem::Type(_binding_0) => ImplItem::Type(f.fold_impl_item_type(_binding_0)), ImplItem::Macro(_binding_0) => { ImplItem::Macro(f.fold_impl_item_macro(_binding_0)) } ImplItem::Verbatim(_binding_0) => ImplItem::Verbatim(_binding_0), - #[cfg(syn_no_non_exhaustive)] - _ => unreachable!(), } } #[cfg(feature = "full")] @@ -1882,40 +1784,39 @@ where ImplItemConst { attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), vis: f.fold_visibility(node.vis), - defaultness: (node.defaultness) - .map(|it| Token![default](tokens_helper(f, &it.span))), - const_token: Token![const](tokens_helper(f, &node.const_token.span)), + defaultness: node.defaultness, + const_token: node.const_token, ident: f.fold_ident(node.ident), - colon_token: Token![:](tokens_helper(f, &node.colon_token.spans)), + generics: f.fold_generics(node.generics), + colon_token: node.colon_token, ty: f.fold_type(node.ty), - eq_token: Token![=](tokens_helper(f, &node.eq_token.spans)), + eq_token: node.eq_token, expr: f.fold_expr(node.expr), - semi_token: Token![;](tokens_helper(f, &node.semi_token.spans)), + semi_token: node.semi_token, } } #[cfg(feature = "full")] -pub fn fold_impl_item_macro<F>(f: &mut F, node: ImplItemMacro) -> ImplItemMacro +pub fn fold_impl_item_fn<F>(f: &mut F, node: ImplItemFn) -> ImplItemFn where F: Fold + ?Sized, { - ImplItemMacro { + ImplItemFn { attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), - mac: f.fold_macro(node.mac), - semi_token: (node.semi_token).map(|it| Token![;](tokens_helper(f, &it.spans))), + vis: f.fold_visibility(node.vis), + defaultness: node.defaultness, + sig: f.fold_signature(node.sig), + block: f.fold_block(node.block), } } #[cfg(feature = "full")] -pub fn fold_impl_item_method<F>(f: &mut F, node: ImplItemMethod) -> ImplItemMethod +pub fn fold_impl_item_macro<F>(f: &mut F, node: ImplItemMacro) -> ImplItemMacro where F: Fold + ?Sized, { - ImplItemMethod { + ImplItemMacro { attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), - vis: f.fold_visibility(node.vis), - defaultness: (node.defaultness) - .map(|it| Token![default](tokens_helper(f, &it.span))), - sig: f.fold_signature(node.sig), - block: f.fold_block(node.block), + mac: f.fold_macro(node.mac), + semi_token: node.semi_token, } } #[cfg(feature = "full")] @@ -1926,16 +1827,22 @@ where ImplItemType { attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), vis: f.fold_visibility(node.vis), - defaultness: (node.defaultness) - .map(|it| Token![default](tokens_helper(f, &it.span))), - type_token: Token![type](tokens_helper(f, &node.type_token.span)), + defaultness: node.defaultness, + type_token: node.type_token, ident: f.fold_ident(node.ident), generics: f.fold_generics(node.generics), - eq_token: Token![=](tokens_helper(f, &node.eq_token.spans)), + eq_token: node.eq_token, ty: f.fold_type(node.ty), - semi_token: Token![;](tokens_helper(f, &node.semi_token.spans)), + semi_token: node.semi_token, } } +#[cfg(feature = "full")] +pub fn fold_impl_restriction<F>(f: &mut F, node: ImplRestriction) -> ImplRestriction +where + F: Fold + ?Sized, +{ + match node {} +} #[cfg(any(feature = "derive", feature = "full"))] pub fn fold_index<F>(f: &mut F, node: Index) -> Index where @@ -1963,7 +1870,6 @@ where } Item::Impl(_binding_0) => Item::Impl(f.fold_item_impl(_binding_0)), Item::Macro(_binding_0) => Item::Macro(f.fold_item_macro(_binding_0)), - Item::Macro2(_binding_0) => Item::Macro2(f.fold_item_macro2(_binding_0)), Item::Mod(_binding_0) => Item::Mod(f.fold_item_mod(_binding_0)), Item::Static(_binding_0) => Item::Static(f.fold_item_static(_binding_0)), Item::Struct(_binding_0) => Item::Struct(f.fold_item_struct(_binding_0)), @@ -1975,8 +1881,6 @@ where Item::Union(_binding_0) => Item::Union(f.fold_item_union(_binding_0)), Item::Use(_binding_0) => Item::Use(f.fold_item_use(_binding_0)), Item::Verbatim(_binding_0) => Item::Verbatim(_binding_0), - #[cfg(syn_no_non_exhaustive)] - _ => unreachable!(), } } #[cfg(feature = "full")] @@ -1987,13 +1891,14 @@ where ItemConst { attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), vis: f.fold_visibility(node.vis), - const_token: Token![const](tokens_helper(f, &node.const_token.span)), + const_token: node.const_token, ident: f.fold_ident(node.ident), - colon_token: Token![:](tokens_helper(f, &node.colon_token.spans)), + generics: f.fold_generics(node.generics), + colon_token: node.colon_token, ty: Box::new(f.fold_type(*node.ty)), - eq_token: Token![=](tokens_helper(f, &node.eq_token.spans)), + eq_token: node.eq_token, expr: Box::new(f.fold_expr(*node.expr)), - semi_token: Token![;](tokens_helper(f, &node.semi_token.spans)), + semi_token: node.semi_token, } } #[cfg(feature = "full")] @@ -2004,10 +1909,10 @@ where ItemEnum { attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), vis: f.fold_visibility(node.vis), - enum_token: Token![enum](tokens_helper(f, &node.enum_token.span)), + enum_token: node.enum_token, ident: f.fold_ident(node.ident), generics: f.fold_generics(node.generics), - brace_token: Brace(tokens_helper(f, &node.brace_token.span)), + brace_token: node.brace_token, variants: FoldHelper::lift(node.variants, |it| f.fold_variant(it)), } } @@ -2019,15 +1924,11 @@ where ItemExternCrate { attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), vis: f.fold_visibility(node.vis), - extern_token: Token![extern](tokens_helper(f, &node.extern_token.span)), - crate_token: Token![crate](tokens_helper(f, &node.crate_token.span)), + extern_token: node.extern_token, + crate_token: node.crate_token, ident: f.fold_ident(node.ident), - rename: (node.rename) - .map(|it| ( - Token![as](tokens_helper(f, &(it).0.span)), - f.fold_ident((it).1), - )), - semi_token: Token![;](tokens_helper(f, &node.semi_token.spans)), + rename: (node.rename).map(|it| ((it).0, f.fold_ident((it).1))), + semi_token: node.semi_token, } } #[cfg(feature = "full")] @@ -2049,8 +1950,9 @@ where { ItemForeignMod { attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), + unsafety: node.unsafety, abi: f.fold_abi(node.abi), - brace_token: Brace(tokens_helper(f, &node.brace_token.span)), + brace_token: node.brace_token, items: FoldHelper::lift(node.items, |it| f.fold_foreign_item(it)), } } @@ -2061,19 +1963,13 @@ where { ItemImpl { attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), - defaultness: (node.defaultness) - .map(|it| Token![default](tokens_helper(f, &it.span))), - unsafety: (node.unsafety).map(|it| Token![unsafe](tokens_helper(f, &it.span))), - impl_token: Token![impl](tokens_helper(f, &node.impl_token.span)), + defaultness: node.defaultness, + unsafety: node.unsafety, + impl_token: node.impl_token, generics: f.fold_generics(node.generics), - trait_: (node.trait_) - .map(|it| ( - ((it).0).map(|it| Token![!](tokens_helper(f, &it.spans))), - f.fold_path((it).1), - Token![for](tokens_helper(f, &(it).2.span)), - )), + trait_: (node.trait_).map(|it| ((it).0, f.fold_path((it).1), (it).2)), self_ty: Box::new(f.fold_type(*node.self_ty)), - brace_token: Brace(tokens_helper(f, &node.brace_token.span)), + brace_token: node.brace_token, items: FoldHelper::lift(node.items, |it| f.fold_impl_item(it)), } } @@ -2086,20 +1982,7 @@ where attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), ident: (node.ident).map(|it| f.fold_ident(it)), mac: f.fold_macro(node.mac), - semi_token: (node.semi_token).map(|it| Token![;](tokens_helper(f, &it.spans))), - } -} -#[cfg(feature = "full")] -pub fn fold_item_macro2<F>(f: &mut F, node: ItemMacro2) -> ItemMacro2 -where - F: Fold + ?Sized, -{ - ItemMacro2 { - attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), - vis: f.fold_visibility(node.vis), - macro_token: Token![macro](tokens_helper(f, &node.macro_token.span)), - ident: f.fold_ident(node.ident), - rules: node.rules, + semi_token: node.semi_token, } } #[cfg(feature = "full")] @@ -2110,14 +1993,12 @@ where ItemMod { attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), vis: f.fold_visibility(node.vis), - mod_token: Token![mod](tokens_helper(f, &node.mod_token.span)), + unsafety: node.unsafety, + mod_token: node.mod_token, ident: f.fold_ident(node.ident), content: (node.content) - .map(|it| ( - Brace(tokens_helper(f, &(it).0.span)), - FoldHelper::lift((it).1, |it| f.fold_item(it)), - )), - semi: (node.semi).map(|it| Token![;](tokens_helper(f, &it.spans))), + .map(|it| ((it).0, FoldHelper::lift((it).1, |it| f.fold_item(it)))), + semi: node.semi, } } #[cfg(feature = "full")] @@ -2128,14 +2009,14 @@ where ItemStatic { attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), vis: f.fold_visibility(node.vis), - static_token: Token![static](tokens_helper(f, &node.static_token.span)), - mutability: (node.mutability).map(|it| Token![mut](tokens_helper(f, &it.span))), + static_token: node.static_token, + mutability: f.fold_static_mutability(node.mutability), ident: f.fold_ident(node.ident), - colon_token: Token![:](tokens_helper(f, &node.colon_token.spans)), + colon_token: node.colon_token, ty: Box::new(f.fold_type(*node.ty)), - eq_token: Token![=](tokens_helper(f, &node.eq_token.spans)), + eq_token: node.eq_token, expr: Box::new(f.fold_expr(*node.expr)), - semi_token: Token![;](tokens_helper(f, &node.semi_token.spans)), + semi_token: node.semi_token, } } #[cfg(feature = "full")] @@ -2146,11 +2027,11 @@ where ItemStruct { attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), vis: f.fold_visibility(node.vis), - struct_token: Token![struct](tokens_helper(f, &node.struct_token.span)), + struct_token: node.struct_token, ident: f.fold_ident(node.ident), generics: f.fold_generics(node.generics), fields: f.fold_fields(node.fields), - semi_token: (node.semi_token).map(|it| Token![;](tokens_helper(f, &it.spans))), + semi_token: node.semi_token, } } #[cfg(feature = "full")] @@ -2161,17 +2042,18 @@ where ItemTrait { attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), vis: f.fold_visibility(node.vis), - unsafety: (node.unsafety).map(|it| Token![unsafe](tokens_helper(f, &it.span))), - auto_token: (node.auto_token).map(|it| Token![auto](tokens_helper(f, &it.span))), - trait_token: Token![trait](tokens_helper(f, &node.trait_token.span)), + unsafety: node.unsafety, + auto_token: node.auto_token, + restriction: (node.restriction).map(|it| f.fold_impl_restriction(it)), + trait_token: node.trait_token, ident: f.fold_ident(node.ident), generics: f.fold_generics(node.generics), - colon_token: (node.colon_token).map(|it| Token![:](tokens_helper(f, &it.spans))), + colon_token: node.colon_token, supertraits: FoldHelper::lift( node.supertraits, |it| f.fold_type_param_bound(it), ), - brace_token: Brace(tokens_helper(f, &node.brace_token.span)), + brace_token: node.brace_token, items: FoldHelper::lift(node.items, |it| f.fold_trait_item(it)), } } @@ -2183,12 +2065,12 @@ where ItemTraitAlias { attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), vis: f.fold_visibility(node.vis), - trait_token: Token![trait](tokens_helper(f, &node.trait_token.span)), + trait_token: node.trait_token, ident: f.fold_ident(node.ident), generics: f.fold_generics(node.generics), - eq_token: Token![=](tokens_helper(f, &node.eq_token.spans)), + eq_token: node.eq_token, bounds: FoldHelper::lift(node.bounds, |it| f.fold_type_param_bound(it)), - semi_token: Token![;](tokens_helper(f, &node.semi_token.spans)), + semi_token: node.semi_token, } } #[cfg(feature = "full")] @@ -2199,12 +2081,12 @@ where ItemType { attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), vis: f.fold_visibility(node.vis), - type_token: Token![type](tokens_helper(f, &node.type_token.span)), + type_token: node.type_token, ident: f.fold_ident(node.ident), generics: f.fold_generics(node.generics), - eq_token: Token![=](tokens_helper(f, &node.eq_token.spans)), + eq_token: node.eq_token, ty: Box::new(f.fold_type(*node.ty)), - semi_token: Token![;](tokens_helper(f, &node.semi_token.spans)), + semi_token: node.semi_token, } } #[cfg(feature = "full")] @@ -2215,7 +2097,7 @@ where ItemUnion { attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), vis: f.fold_visibility(node.vis), - union_token: Token![union](tokens_helper(f, &node.union_token.span)), + union_token: node.union_token, ident: f.fold_ident(node.ident), generics: f.fold_generics(node.generics), fields: f.fold_fields_named(node.fields), @@ -2229,11 +2111,10 @@ where ItemUse { attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), vis: f.fold_visibility(node.vis), - use_token: Token![use](tokens_helper(f, &node.use_token.span)), - leading_colon: (node.leading_colon) - .map(|it| Token![::](tokens_helper(f, &it.spans))), + use_token: node.use_token, + leading_colon: node.leading_colon, tree: f.fold_use_tree(node.tree), - semi_token: Token![;](tokens_helper(f, &node.semi_token.spans)), + semi_token: node.semi_token, } } #[cfg(feature = "full")] @@ -2243,7 +2124,7 @@ where { Label { name: f.fold_lifetime(node.name), - colon_token: Token![:](tokens_helper(f, &node.colon_token.spans)), + colon_token: node.colon_token, } } pub fn fold_lifetime<F>(f: &mut F, node: Lifetime) -> Lifetime @@ -2256,14 +2137,14 @@ where } } #[cfg(any(feature = "derive", feature = "full"))] -pub fn fold_lifetime_def<F>(f: &mut F, node: LifetimeDef) -> LifetimeDef +pub fn fold_lifetime_param<F>(f: &mut F, node: LifetimeParam) -> LifetimeParam where F: Fold + ?Sized, { - LifetimeDef { + LifetimeParam { attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), lifetime: f.fold_lifetime(node.lifetime), - colon_token: (node.colon_token).map(|it| Token![:](tokens_helper(f, &it.spans))), + colon_token: node.colon_token, bounds: FoldHelper::lift(node.bounds, |it| f.fold_lifetime(it)), } } @@ -2352,14 +2233,21 @@ where { Local { attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), - let_token: Token![let](tokens_helper(f, &node.let_token.span)), + let_token: node.let_token, pat: f.fold_pat(node.pat), - init: (node.init) - .map(|it| ( - Token![=](tokens_helper(f, &(it).0.spans)), - Box::new(f.fold_expr(*(it).1)), - )), - semi_token: Token![;](tokens_helper(f, &node.semi_token.spans)), + init: (node.init).map(|it| f.fold_local_init(it)), + semi_token: node.semi_token, + } +} +#[cfg(feature = "full")] +pub fn fold_local_init<F>(f: &mut F, node: LocalInit) -> LocalInit +where + F: Fold + ?Sized, +{ + LocalInit { + eq_token: node.eq_token, + expr: Box::new(f.fold_expr(*node.expr)), + diverge: (node.diverge).map(|it| ((it).0, Box::new(f.fold_expr(*(it).1)))), } } #[cfg(any(feature = "derive", feature = "full"))] @@ -2369,7 +2257,7 @@ where { Macro { path: f.fold_path(node.path), - bang_token: Token![!](tokens_helper(f, &node.bang_token.spans)), + bang_token: node.bang_token, delimiter: f.fold_macro_delimiter(node.delimiter), tokens: node.tokens, } @@ -2380,15 +2268,9 @@ where F: Fold + ?Sized, { match node { - MacroDelimiter::Paren(_binding_0) => { - MacroDelimiter::Paren(Paren(tokens_helper(f, &_binding_0.span))) - } - MacroDelimiter::Brace(_binding_0) => { - MacroDelimiter::Brace(Brace(tokens_helper(f, &_binding_0.span))) - } - MacroDelimiter::Bracket(_binding_0) => { - MacroDelimiter::Bracket(Bracket(tokens_helper(f, &_binding_0.span))) - } + MacroDelimiter::Paren(_binding_0) => MacroDelimiter::Paren(_binding_0), + MacroDelimiter::Brace(_binding_0) => MacroDelimiter::Brace(_binding_0), + MacroDelimiter::Bracket(_binding_0) => MacroDelimiter::Bracket(_binding_0), } } #[cfg(any(feature = "derive", feature = "full"))] @@ -2421,8 +2303,8 @@ where { MetaList { path: f.fold_path(node.path), - paren_token: Paren(tokens_helper(f, &node.paren_token.span)), - nested: FoldHelper::lift(node.nested, |it| f.fold_nested_meta(it)), + delimiter: f.fold_macro_delimiter(node.delimiter), + tokens: node.tokens, } } #[cfg(any(feature = "derive", feature = "full"))] @@ -2432,30 +2314,8 @@ where { MetaNameValue { path: f.fold_path(node.path), - eq_token: Token![=](tokens_helper(f, &node.eq_token.spans)), - lit: f.fold_lit(node.lit), - } -} -#[cfg(feature = "full")] -pub fn fold_method_turbofish<F>(f: &mut F, node: MethodTurbofish) -> MethodTurbofish -where - F: Fold + ?Sized, -{ - MethodTurbofish { - colon2_token: Token![::](tokens_helper(f, &node.colon2_token.spans)), - lt_token: Token![<](tokens_helper(f, &node.lt_token.spans)), - args: FoldHelper::lift(node.args, |it| f.fold_generic_method_argument(it)), - gt_token: Token![>](tokens_helper(f, &node.gt_token.spans)), - } -} -#[cfg(any(feature = "derive", feature = "full"))] -pub fn fold_nested_meta<F>(f: &mut F, node: NestedMeta) -> NestedMeta -where - F: Fold + ?Sized, -{ - match node { - NestedMeta::Meta(_binding_0) => NestedMeta::Meta(f.fold_meta(_binding_0)), - NestedMeta::Lit(_binding_0) => NestedMeta::Lit(f.fold_lit(_binding_0)), + eq_token: node.eq_token, + value: f.fold_expr(node.value), } } #[cfg(any(feature = "derive", feature = "full"))] @@ -2467,7 +2327,7 @@ where F: Fold + ?Sized, { ParenthesizedGenericArguments { - paren_token: Paren(tokens_helper(f, &node.paren_token.span)), + paren_token: node.paren_token, inputs: FoldHelper::lift(node.inputs, |it| f.fold_type(it)), output: f.fold_return_type(node.output), } @@ -2478,13 +2338,14 @@ where F: Fold + ?Sized, { match node { - Pat::Box(_binding_0) => Pat::Box(f.fold_pat_box(_binding_0)), + Pat::Const(_binding_0) => Pat::Const(f.fold_expr_const(_binding_0)), Pat::Ident(_binding_0) => Pat::Ident(f.fold_pat_ident(_binding_0)), - Pat::Lit(_binding_0) => Pat::Lit(f.fold_pat_lit(_binding_0)), - Pat::Macro(_binding_0) => Pat::Macro(f.fold_pat_macro(_binding_0)), + Pat::Lit(_binding_0) => Pat::Lit(f.fold_expr_lit(_binding_0)), + Pat::Macro(_binding_0) => Pat::Macro(f.fold_expr_macro(_binding_0)), Pat::Or(_binding_0) => Pat::Or(f.fold_pat_or(_binding_0)), - Pat::Path(_binding_0) => Pat::Path(f.fold_pat_path(_binding_0)), - Pat::Range(_binding_0) => Pat::Range(f.fold_pat_range(_binding_0)), + Pat::Paren(_binding_0) => Pat::Paren(f.fold_pat_paren(_binding_0)), + Pat::Path(_binding_0) => Pat::Path(f.fold_expr_path(_binding_0)), + Pat::Range(_binding_0) => Pat::Range(f.fold_expr_range(_binding_0)), Pat::Reference(_binding_0) => Pat::Reference(f.fold_pat_reference(_binding_0)), Pat::Rest(_binding_0) => Pat::Rest(f.fold_pat_rest(_binding_0)), Pat::Slice(_binding_0) => Pat::Slice(f.fold_pat_slice(_binding_0)), @@ -2496,19 +2357,6 @@ where Pat::Type(_binding_0) => Pat::Type(f.fold_pat_type(_binding_0)), Pat::Verbatim(_binding_0) => Pat::Verbatim(_binding_0), Pat::Wild(_binding_0) => Pat::Wild(f.fold_pat_wild(_binding_0)), - #[cfg(syn_no_non_exhaustive)] - _ => unreachable!(), - } -} -#[cfg(feature = "full")] -pub fn fold_pat_box<F>(f: &mut F, node: PatBox) -> PatBox -where - F: Fold + ?Sized, -{ - PatBox { - attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), - box_token: Token![box](tokens_helper(f, &node.box_token.span)), - pat: Box::new(f.fold_pat(*node.pat)), } } #[cfg(feature = "full")] @@ -2518,34 +2366,10 @@ where { PatIdent { attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), - by_ref: (node.by_ref).map(|it| Token![ref](tokens_helper(f, &it.span))), - mutability: (node.mutability).map(|it| Token![mut](tokens_helper(f, &it.span))), + by_ref: node.by_ref, + mutability: node.mutability, ident: f.fold_ident(node.ident), - subpat: (node.subpat) - .map(|it| ( - Token![@](tokens_helper(f, &(it).0.spans)), - Box::new(f.fold_pat(*(it).1)), - )), - } -} -#[cfg(feature = "full")] -pub fn fold_pat_lit<F>(f: &mut F, node: PatLit) -> PatLit -where - F: Fold + ?Sized, -{ - PatLit { - attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), - expr: Box::new(f.fold_expr(*node.expr)), - } -} -#[cfg(feature = "full")] -pub fn fold_pat_macro<F>(f: &mut F, node: PatMacro) -> PatMacro -where - F: Fold + ?Sized, -{ - PatMacro { - attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), - mac: f.fold_macro(node.mac), + subpat: (node.subpat).map(|it| ((it).0, Box::new(f.fold_pat(*(it).1)))), } } #[cfg(feature = "full")] @@ -2555,32 +2379,19 @@ where { PatOr { attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), - leading_vert: (node.leading_vert) - .map(|it| Token![|](tokens_helper(f, &it.spans))), + leading_vert: node.leading_vert, cases: FoldHelper::lift(node.cases, |it| f.fold_pat(it)), } } #[cfg(feature = "full")] -pub fn fold_pat_path<F>(f: &mut F, node: PatPath) -> PatPath +pub fn fold_pat_paren<F>(f: &mut F, node: PatParen) -> PatParen where F: Fold + ?Sized, { - PatPath { + PatParen { attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), - qself: (node.qself).map(|it| f.fold_qself(it)), - path: f.fold_path(node.path), - } -} -#[cfg(feature = "full")] -pub fn fold_pat_range<F>(f: &mut F, node: PatRange) -> PatRange -where - F: Fold + ?Sized, -{ - PatRange { - attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), - lo: Box::new(f.fold_expr(*node.lo)), - limits: f.fold_range_limits(node.limits), - hi: Box::new(f.fold_expr(*node.hi)), + paren_token: node.paren_token, + pat: Box::new(f.fold_pat(*node.pat)), } } #[cfg(feature = "full")] @@ -2590,8 +2401,8 @@ where { PatReference { attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), - and_token: Token![&](tokens_helper(f, &node.and_token.spans)), - mutability: (node.mutability).map(|it| Token![mut](tokens_helper(f, &it.span))), + and_token: node.and_token, + mutability: node.mutability, pat: Box::new(f.fold_pat(*node.pat)), } } @@ -2602,7 +2413,7 @@ where { PatRest { attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), - dot2_token: Token![..](tokens_helper(f, &node.dot2_token.spans)), + dot2_token: node.dot2_token, } } #[cfg(feature = "full")] @@ -2612,7 +2423,7 @@ where { PatSlice { attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), - bracket_token: Bracket(tokens_helper(f, &node.bracket_token.span)), + bracket_token: node.bracket_token, elems: FoldHelper::lift(node.elems, |it| f.fold_pat(it)), } } @@ -2623,10 +2434,11 @@ where { PatStruct { attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), + qself: (node.qself).map(|it| f.fold_qself(it)), path: f.fold_path(node.path), - brace_token: Brace(tokens_helper(f, &node.brace_token.span)), + brace_token: node.brace_token, fields: FoldHelper::lift(node.fields, |it| f.fold_field_pat(it)), - dot2_token: (node.dot2_token).map(|it| Token![..](tokens_helper(f, &it.spans))), + rest: (node.rest).map(|it| f.fold_pat_rest(it)), } } #[cfg(feature = "full")] @@ -2636,7 +2448,7 @@ where { PatTuple { attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), - paren_token: Paren(tokens_helper(f, &node.paren_token.span)), + paren_token: node.paren_token, elems: FoldHelper::lift(node.elems, |it| f.fold_pat(it)), } } @@ -2647,8 +2459,10 @@ where { PatTupleStruct { attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), + qself: (node.qself).map(|it| f.fold_qself(it)), path: f.fold_path(node.path), - pat: f.fold_pat_tuple(node.pat), + paren_token: node.paren_token, + elems: FoldHelper::lift(node.elems, |it| f.fold_pat(it)), } } #[cfg(feature = "full")] @@ -2659,7 +2473,7 @@ where PatType { attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), pat: Box::new(f.fold_pat(*node.pat)), - colon_token: Token![:](tokens_helper(f, &node.colon_token.spans)), + colon_token: node.colon_token, ty: Box::new(f.fold_type(*node.ty)), } } @@ -2670,7 +2484,7 @@ where { PatWild { attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), - underscore_token: Token![_](tokens_helper(f, &node.underscore_token.spans)), + underscore_token: node.underscore_token, } } #[cfg(any(feature = "derive", feature = "full"))] @@ -2679,8 +2493,7 @@ where F: Fold + ?Sized, { Path { - leading_colon: (node.leading_colon) - .map(|it| Token![::](tokens_helper(f, &it.spans))), + leading_colon: node.leading_colon, segments: FoldHelper::lift(node.segments, |it| f.fold_path_segment(it)), } } @@ -2714,17 +2527,6 @@ where } } #[cfg(any(feature = "derive", feature = "full"))] -pub fn fold_predicate_eq<F>(f: &mut F, node: PredicateEq) -> PredicateEq -where - F: Fold + ?Sized, -{ - PredicateEq { - lhs_ty: f.fold_type(node.lhs_ty), - eq_token: Token![=](tokens_helper(f, &node.eq_token.spans)), - rhs_ty: f.fold_type(node.rhs_ty), - } -} -#[cfg(any(feature = "derive", feature = "full"))] pub fn fold_predicate_lifetime<F>( f: &mut F, node: PredicateLifetime, @@ -2734,7 +2536,7 @@ where { PredicateLifetime { lifetime: f.fold_lifetime(node.lifetime), - colon_token: Token![:](tokens_helper(f, &node.colon_token.spans)), + colon_token: node.colon_token, bounds: FoldHelper::lift(node.bounds, |it| f.fold_lifetime(it)), } } @@ -2746,7 +2548,7 @@ where PredicateType { lifetimes: (node.lifetimes).map(|it| f.fold_bound_lifetimes(it)), bounded_ty: f.fold_type(node.bounded_ty), - colon_token: Token![:](tokens_helper(f, &node.colon_token.spans)), + colon_token: node.colon_token, bounds: FoldHelper::lift(node.bounds, |it| f.fold_type_param_bound(it)), } } @@ -2756,11 +2558,11 @@ where F: Fold + ?Sized, { QSelf { - lt_token: Token![<](tokens_helper(f, &node.lt_token.spans)), + lt_token: node.lt_token, ty: Box::new(f.fold_type(*node.ty)), position: node.position, - as_token: (node.as_token).map(|it| Token![as](tokens_helper(f, &it.span))), - gt_token: Token![>](tokens_helper(f, &node.gt_token.spans)), + as_token: node.as_token, + gt_token: node.gt_token, } } #[cfg(feature = "full")] @@ -2769,12 +2571,8 @@ where F: Fold + ?Sized, { match node { - RangeLimits::HalfOpen(_binding_0) => { - RangeLimits::HalfOpen(Token![..](tokens_helper(f, &_binding_0.spans))) - } - RangeLimits::Closed(_binding_0) => { - RangeLimits::Closed(Token![..=](tokens_helper(f, &_binding_0.spans))) - } + RangeLimits::HalfOpen(_binding_0) => RangeLimits::HalfOpen(_binding_0), + RangeLimits::Closed(_binding_0) => RangeLimits::Closed(_binding_0), } } #[cfg(feature = "full")] @@ -2785,12 +2583,11 @@ where Receiver { attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), reference: (node.reference) - .map(|it| ( - Token![&](tokens_helper(f, &(it).0.spans)), - ((it).1).map(|it| f.fold_lifetime(it)), - )), - mutability: (node.mutability).map(|it| Token![mut](tokens_helper(f, &it.span))), - self_token: Token![self](tokens_helper(f, &node.self_token.span)), + .map(|it| ((it).0, ((it).1).map(|it| f.fold_lifetime(it)))), + mutability: node.mutability, + self_token: node.self_token, + colon_token: node.colon_token, + ty: Box::new(f.fold_type(*node.ty)), } } #[cfg(any(feature = "derive", feature = "full"))] @@ -2801,10 +2598,7 @@ where match node { ReturnType::Default => ReturnType::Default, ReturnType::Type(_binding_0, _binding_1) => { - ReturnType::Type( - Token![->](tokens_helper(f, &_binding_0.spans)), - Box::new(f.fold_type(*_binding_1)), - ) + ReturnType::Type(_binding_0, Box::new(f.fold_type(*_binding_1))) } } } @@ -2814,14 +2608,14 @@ where F: Fold + ?Sized, { Signature { - constness: (node.constness).map(|it| Token![const](tokens_helper(f, &it.span))), - asyncness: (node.asyncness).map(|it| Token![async](tokens_helper(f, &it.span))), - unsafety: (node.unsafety).map(|it| Token![unsafe](tokens_helper(f, &it.span))), + constness: node.constness, + asyncness: node.asyncness, + unsafety: node.unsafety, abi: (node.abi).map(|it| f.fold_abi(it)), - fn_token: Token![fn](tokens_helper(f, &node.fn_token.span)), + fn_token: node.fn_token, ident: f.fold_ident(node.ident), generics: f.fold_generics(node.generics), - paren_token: Paren(tokens_helper(f, &node.paren_token.span)), + paren_token: node.paren_token, inputs: FoldHelper::lift(node.inputs, |it| f.fold_fn_arg(it)), variadic: (node.variadic).map(|it| f.fold_variadic(it)), output: f.fold_return_type(node.output), @@ -2834,6 +2628,16 @@ where node } #[cfg(feature = "full")] +pub fn fold_static_mutability<F>(f: &mut F, node: StaticMutability) -> StaticMutability +where + F: Fold + ?Sized, +{ + match node { + StaticMutability::Mut(_binding_0) => StaticMutability::Mut(_binding_0), + StaticMutability::None => StaticMutability::None, + } +} +#[cfg(feature = "full")] pub fn fold_stmt<F>(f: &mut F, node: Stmt) -> Stmt where F: Fold + ?Sized, @@ -2841,13 +2645,21 @@ where match node { Stmt::Local(_binding_0) => Stmt::Local(f.fold_local(_binding_0)), Stmt::Item(_binding_0) => Stmt::Item(f.fold_item(_binding_0)), - Stmt::Expr(_binding_0) => Stmt::Expr(f.fold_expr(_binding_0)), - Stmt::Semi(_binding_0, _binding_1) => { - Stmt::Semi( - f.fold_expr(_binding_0), - Token![;](tokens_helper(f, &_binding_1.spans)), - ) + Stmt::Expr(_binding_0, _binding_1) => { + Stmt::Expr(f.fold_expr(_binding_0), _binding_1) } + Stmt::Macro(_binding_0) => Stmt::Macro(f.fold_stmt_macro(_binding_0)), + } +} +#[cfg(feature = "full")] +pub fn fold_stmt_macro<F>(f: &mut F, node: StmtMacro) -> StmtMacro +where + F: Fold + ?Sized, +{ + StmtMacro { + attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), + mac: f.fold_macro(node.mac), + semi_token: node.semi_token, } } #[cfg(any(feature = "derive", feature = "full"))] @@ -2856,7 +2668,7 @@ where F: Fold + ?Sized, { TraitBound { - paren_token: (node.paren_token).map(|it| Paren(tokens_helper(f, &it.span))), + paren_token: node.paren_token, modifier: f.fold_trait_bound_modifier(node.modifier), lifetimes: (node.lifetimes).map(|it| f.fold_bound_lifetimes(it)), path: f.fold_path(node.path), @@ -2872,9 +2684,7 @@ where { match node { TraitBoundModifier::None => TraitBoundModifier::None, - TraitBoundModifier::Maybe(_binding_0) => { - TraitBoundModifier::Maybe(Token![?](tokens_helper(f, &_binding_0.spans))) - } + TraitBoundModifier::Maybe(_binding_0) => TraitBoundModifier::Maybe(_binding_0), } } #[cfg(feature = "full")] @@ -2886,9 +2696,7 @@ where TraitItem::Const(_binding_0) => { TraitItem::Const(f.fold_trait_item_const(_binding_0)) } - TraitItem::Method(_binding_0) => { - TraitItem::Method(f.fold_trait_item_method(_binding_0)) - } + TraitItem::Fn(_binding_0) => TraitItem::Fn(f.fold_trait_item_fn(_binding_0)), TraitItem::Type(_binding_0) => { TraitItem::Type(f.fold_trait_item_type(_binding_0)) } @@ -2896,8 +2704,6 @@ where TraitItem::Macro(f.fold_trait_item_macro(_binding_0)) } TraitItem::Verbatim(_binding_0) => TraitItem::Verbatim(_binding_0), - #[cfg(syn_no_non_exhaustive)] - _ => unreachable!(), } } #[cfg(feature = "full")] @@ -2907,36 +2713,36 @@ where { TraitItemConst { attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), - const_token: Token![const](tokens_helper(f, &node.const_token.span)), + const_token: node.const_token, ident: f.fold_ident(node.ident), - colon_token: Token![:](tokens_helper(f, &node.colon_token.spans)), + generics: f.fold_generics(node.generics), + colon_token: node.colon_token, ty: f.fold_type(node.ty), - default: (node.default) - .map(|it| (Token![=](tokens_helper(f, &(it).0.spans)), f.fold_expr((it).1))), - semi_token: Token![;](tokens_helper(f, &node.semi_token.spans)), + default: (node.default).map(|it| ((it).0, f.fold_expr((it).1))), + semi_token: node.semi_token, } } #[cfg(feature = "full")] -pub fn fold_trait_item_macro<F>(f: &mut F, node: TraitItemMacro) -> TraitItemMacro +pub fn fold_trait_item_fn<F>(f: &mut F, node: TraitItemFn) -> TraitItemFn where F: Fold + ?Sized, { - TraitItemMacro { + TraitItemFn { attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), - mac: f.fold_macro(node.mac), - semi_token: (node.semi_token).map(|it| Token![;](tokens_helper(f, &it.spans))), + sig: f.fold_signature(node.sig), + default: (node.default).map(|it| f.fold_block(it)), + semi_token: node.semi_token, } } #[cfg(feature = "full")] -pub fn fold_trait_item_method<F>(f: &mut F, node: TraitItemMethod) -> TraitItemMethod +pub fn fold_trait_item_macro<F>(f: &mut F, node: TraitItemMacro) -> TraitItemMacro where F: Fold + ?Sized, { - TraitItemMethod { + TraitItemMacro { attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), - sig: f.fold_signature(node.sig), - default: (node.default).map(|it| f.fold_block(it)), - semi_token: (node.semi_token).map(|it| Token![;](tokens_helper(f, &it.spans))), + mac: f.fold_macro(node.mac), + semi_token: node.semi_token, } } #[cfg(feature = "full")] @@ -2946,14 +2752,13 @@ where { TraitItemType { attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), - type_token: Token![type](tokens_helper(f, &node.type_token.span)), + type_token: node.type_token, ident: f.fold_ident(node.ident), generics: f.fold_generics(node.generics), - colon_token: (node.colon_token).map(|it| Token![:](tokens_helper(f, &it.spans))), + colon_token: node.colon_token, bounds: FoldHelper::lift(node.bounds, |it| f.fold_type_param_bound(it)), - default: (node.default) - .map(|it| (Token![=](tokens_helper(f, &(it).0.spans)), f.fold_type((it).1))), - semi_token: Token![;](tokens_helper(f, &node.semi_token.spans)), + default: (node.default).map(|it| ((it).0, f.fold_type((it).1))), + semi_token: node.semi_token, } } #[cfg(any(feature = "derive", feature = "full"))] @@ -2981,8 +2786,6 @@ where } Type::Tuple(_binding_0) => Type::Tuple(f.fold_type_tuple(_binding_0)), Type::Verbatim(_binding_0) => Type::Verbatim(_binding_0), - #[cfg(syn_no_non_exhaustive)] - _ => unreachable!(), } } #[cfg(any(feature = "derive", feature = "full"))] @@ -2991,9 +2794,9 @@ where F: Fold + ?Sized, { TypeArray { - bracket_token: Bracket(tokens_helper(f, &node.bracket_token.span)), + bracket_token: node.bracket_token, elem: Box::new(f.fold_type(*node.elem)), - semi_token: Token![;](tokens_helper(f, &node.semi_token.spans)), + semi_token: node.semi_token, len: f.fold_expr(node.len), } } @@ -3004,12 +2807,12 @@ where { TypeBareFn { lifetimes: (node.lifetimes).map(|it| f.fold_bound_lifetimes(it)), - unsafety: (node.unsafety).map(|it| Token![unsafe](tokens_helper(f, &it.span))), + unsafety: node.unsafety, abi: (node.abi).map(|it| f.fold_abi(it)), - fn_token: Token![fn](tokens_helper(f, &node.fn_token.span)), - paren_token: Paren(tokens_helper(f, &node.paren_token.span)), + fn_token: node.fn_token, + paren_token: node.paren_token, inputs: FoldHelper::lift(node.inputs, |it| f.fold_bare_fn_arg(it)), - variadic: (node.variadic).map(|it| f.fold_variadic(it)), + variadic: (node.variadic).map(|it| f.fold_bare_variadic(it)), output: f.fold_return_type(node.output), } } @@ -3019,7 +2822,7 @@ where F: Fold + ?Sized, { TypeGroup { - group_token: Group(tokens_helper(f, &node.group_token.span)), + group_token: node.group_token, elem: Box::new(f.fold_type(*node.elem)), } } @@ -3029,7 +2832,7 @@ where F: Fold + ?Sized, { TypeImplTrait { - impl_token: Token![impl](tokens_helper(f, &node.impl_token.span)), + impl_token: node.impl_token, bounds: FoldHelper::lift(node.bounds, |it| f.fold_type_param_bound(it)), } } @@ -3039,7 +2842,7 @@ where F: Fold + ?Sized, { TypeInfer { - underscore_token: Token![_](tokens_helper(f, &node.underscore_token.spans)), + underscore_token: node.underscore_token, } } #[cfg(any(feature = "derive", feature = "full"))] @@ -3057,7 +2860,7 @@ where F: Fold + ?Sized, { TypeNever { - bang_token: Token![!](tokens_helper(f, &node.bang_token.spans)), + bang_token: node.bang_token, } } #[cfg(any(feature = "derive", feature = "full"))] @@ -3068,9 +2871,9 @@ where TypeParam { attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), ident: f.fold_ident(node.ident), - colon_token: (node.colon_token).map(|it| Token![:](tokens_helper(f, &it.spans))), + colon_token: node.colon_token, bounds: FoldHelper::lift(node.bounds, |it| f.fold_type_param_bound(it)), - eq_token: (node.eq_token).map(|it| Token![=](tokens_helper(f, &it.spans))), + eq_token: node.eq_token, default: (node.default).map(|it| f.fold_type(it)), } } @@ -3086,6 +2889,7 @@ where TypeParamBound::Lifetime(_binding_0) => { TypeParamBound::Lifetime(f.fold_lifetime(_binding_0)) } + TypeParamBound::Verbatim(_binding_0) => TypeParamBound::Verbatim(_binding_0), } } #[cfg(any(feature = "derive", feature = "full"))] @@ -3094,7 +2898,7 @@ where F: Fold + ?Sized, { TypeParen { - paren_token: Paren(tokens_helper(f, &node.paren_token.span)), + paren_token: node.paren_token, elem: Box::new(f.fold_type(*node.elem)), } } @@ -3114,10 +2918,9 @@ where F: Fold + ?Sized, { TypePtr { - star_token: Token![*](tokens_helper(f, &node.star_token.spans)), - const_token: (node.const_token) - .map(|it| Token![const](tokens_helper(f, &it.span))), - mutability: (node.mutability).map(|it| Token![mut](tokens_helper(f, &it.span))), + star_token: node.star_token, + const_token: node.const_token, + mutability: node.mutability, elem: Box::new(f.fold_type(*node.elem)), } } @@ -3127,9 +2930,9 @@ where F: Fold + ?Sized, { TypeReference { - and_token: Token![&](tokens_helper(f, &node.and_token.spans)), + and_token: node.and_token, lifetime: (node.lifetime).map(|it| f.fold_lifetime(it)), - mutability: (node.mutability).map(|it| Token![mut](tokens_helper(f, &it.span))), + mutability: node.mutability, elem: Box::new(f.fold_type(*node.elem)), } } @@ -3139,7 +2942,7 @@ where F: Fold + ?Sized, { TypeSlice { - bracket_token: Bracket(tokens_helper(f, &node.bracket_token.span)), + bracket_token: node.bracket_token, elem: Box::new(f.fold_type(*node.elem)), } } @@ -3149,7 +2952,7 @@ where F: Fold + ?Sized, { TypeTraitObject { - dyn_token: (node.dyn_token).map(|it| Token![dyn](tokens_helper(f, &it.span))), + dyn_token: node.dyn_token, bounds: FoldHelper::lift(node.bounds, |it| f.fold_type_param_bound(it)), } } @@ -3159,7 +2962,7 @@ where F: Fold + ?Sized, { TypeTuple { - paren_token: Paren(tokens_helper(f, &node.paren_token.span)), + paren_token: node.paren_token, elems: FoldHelper::lift(node.elems, |it| f.fold_type(it)), } } @@ -3169,15 +2972,9 @@ where F: Fold + ?Sized, { match node { - UnOp::Deref(_binding_0) => { - UnOp::Deref(Token![*](tokens_helper(f, &_binding_0.spans))) - } - UnOp::Not(_binding_0) => { - UnOp::Not(Token![!](tokens_helper(f, &_binding_0.spans))) - } - UnOp::Neg(_binding_0) => { - UnOp::Neg(Token![-](tokens_helper(f, &_binding_0.spans))) - } + UnOp::Deref(_binding_0) => UnOp::Deref(_binding_0), + UnOp::Not(_binding_0) => UnOp::Not(_binding_0), + UnOp::Neg(_binding_0) => UnOp::Neg(_binding_0), } } #[cfg(feature = "full")] @@ -3186,7 +2983,7 @@ where F: Fold + ?Sized, { UseGlob { - star_token: Token![*](tokens_helper(f, &node.star_token.spans)), + star_token: node.star_token, } } #[cfg(feature = "full")] @@ -3195,7 +2992,7 @@ where F: Fold + ?Sized, { UseGroup { - brace_token: Brace(tokens_helper(f, &node.brace_token.span)), + brace_token: node.brace_token, items: FoldHelper::lift(node.items, |it| f.fold_use_tree(it)), } } @@ -3215,7 +3012,7 @@ where { UsePath { ident: f.fold_ident(node.ident), - colon2_token: Token![::](tokens_helper(f, &node.colon2_token.spans)), + colon2_token: node.colon2_token, tree: Box::new(f.fold_use_tree(*node.tree)), } } @@ -3226,7 +3023,7 @@ where { UseRename { ident: f.fold_ident(node.ident), - as_token: Token![as](tokens_helper(f, &node.as_token.span)), + as_token: node.as_token, rename: f.fold_ident(node.rename), } } @@ -3243,14 +3040,16 @@ where UseTree::Group(_binding_0) => UseTree::Group(f.fold_use_group(_binding_0)), } } -#[cfg(any(feature = "derive", feature = "full"))] +#[cfg(feature = "full")] pub fn fold_variadic<F>(f: &mut F, node: Variadic) -> Variadic where F: Fold + ?Sized, { Variadic { attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), - dots: Token![...](tokens_helper(f, &node.dots.spans)), + pat: (node.pat).map(|it| (Box::new(f.fold_pat(*(it).0)), (it).1)), + dots: node.dots, + comma: node.comma, } } #[cfg(any(feature = "derive", feature = "full"))] @@ -3262,26 +3061,7 @@ where attrs: FoldHelper::lift(node.attrs, |it| f.fold_attribute(it)), ident: f.fold_ident(node.ident), fields: f.fold_fields(node.fields), - discriminant: (node.discriminant) - .map(|it| (Token![=](tokens_helper(f, &(it).0.spans)), f.fold_expr((it).1))), - } -} -#[cfg(any(feature = "derive", feature = "full"))] -pub fn fold_vis_crate<F>(f: &mut F, node: VisCrate) -> VisCrate -where - F: Fold + ?Sized, -{ - VisCrate { - crate_token: Token![crate](tokens_helper(f, &node.crate_token.span)), - } -} -#[cfg(any(feature = "derive", feature = "full"))] -pub fn fold_vis_public<F>(f: &mut F, node: VisPublic) -> VisPublic -where - F: Fold + ?Sized, -{ - VisPublic { - pub_token: Token![pub](tokens_helper(f, &node.pub_token.span)), + discriminant: (node.discriminant).map(|it| ((it).0, f.fold_expr((it).1))), } } #[cfg(any(feature = "derive", feature = "full"))] @@ -3290,9 +3070,9 @@ where F: Fold + ?Sized, { VisRestricted { - pub_token: Token![pub](tokens_helper(f, &node.pub_token.span)), - paren_token: Paren(tokens_helper(f, &node.paren_token.span)), - in_token: (node.in_token).map(|it| Token![in](tokens_helper(f, &it.span))), + pub_token: node.pub_token, + paren_token: node.paren_token, + in_token: node.in_token, path: Box::new(f.fold_path(*node.path)), } } @@ -3302,10 +3082,7 @@ where F: Fold + ?Sized, { match node { - Visibility::Public(_binding_0) => { - Visibility::Public(f.fold_vis_public(_binding_0)) - } - Visibility::Crate(_binding_0) => Visibility::Crate(f.fold_vis_crate(_binding_0)), + Visibility::Public(_binding_0) => Visibility::Public(_binding_0), Visibility::Restricted(_binding_0) => { Visibility::Restricted(f.fold_vis_restricted(_binding_0)) } @@ -3318,7 +3095,7 @@ where F: Fold + ?Sized, { WhereClause { - where_token: Token![where](tokens_helper(f, &node.where_token.span)), + where_token: node.where_token, predicates: FoldHelper::lift(node.predicates, |it| f.fold_where_predicate(it)), } } @@ -3328,14 +3105,11 @@ where F: Fold + ?Sized, { match node { - WherePredicate::Type(_binding_0) => { - WherePredicate::Type(f.fold_predicate_type(_binding_0)) - } WherePredicate::Lifetime(_binding_0) => { WherePredicate::Lifetime(f.fold_predicate_lifetime(_binding_0)) } - WherePredicate::Eq(_binding_0) => { - WherePredicate::Eq(f.fold_predicate_eq(_binding_0)) + WherePredicate::Type(_binding_0) => { + WherePredicate::Type(f.fold_predicate_type(_binding_0)) } } } diff --git a/vendor/syn/src/gen/hash.rs b/vendor/syn/src/gen/hash.rs index d0400e19d..40dfc57f3 100644 --- a/vendor/syn/src/gen/hash.rs +++ b/vendor/syn/src/gen/hash.rs @@ -42,6 +42,30 @@ impl Hash for Arm { } #[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] +impl Hash for AssocConst { + fn hash<H>(&self, state: &mut H) + where + H: Hasher, + { + self.ident.hash(state); + self.generics.hash(state); + self.value.hash(state); + } +} +#[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] +impl Hash for AssocType { + fn hash<H>(&self, state: &mut H) + where + H: Hasher, + { + self.ident.hash(state); + self.generics.hash(state); + self.ty.hash(state); + } +} +#[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Hash for AttrStyle { fn hash<H>(&self, state: &mut H) where @@ -65,8 +89,7 @@ impl Hash for Attribute { H: Hasher, { self.style.hash(state); - self.path.hash(state); - TokenStreamHelper(&self.tokens).hash(state); + self.meta.hash(state); } } #[cfg(any(feature = "derive", feature = "full"))] @@ -83,6 +106,18 @@ impl Hash for BareFnArg { } #[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] +impl Hash for BareVariadic { + fn hash<H>(&self, state: &mut H) + where + H: Hasher, + { + self.attrs.hash(state); + self.name.hash(state); + self.comma.hash(state); + } +} +#[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Hash for BinOp { fn hash<H>(&self, state: &mut H) where @@ -143,50 +178,39 @@ impl Hash for BinOp { BinOp::Gt(_) => { state.write_u8(17u8); } - BinOp::AddEq(_) => { + BinOp::AddAssign(_) => { state.write_u8(18u8); } - BinOp::SubEq(_) => { + BinOp::SubAssign(_) => { state.write_u8(19u8); } - BinOp::MulEq(_) => { + BinOp::MulAssign(_) => { state.write_u8(20u8); } - BinOp::DivEq(_) => { + BinOp::DivAssign(_) => { state.write_u8(21u8); } - BinOp::RemEq(_) => { + BinOp::RemAssign(_) => { state.write_u8(22u8); } - BinOp::BitXorEq(_) => { + BinOp::BitXorAssign(_) => { state.write_u8(23u8); } - BinOp::BitAndEq(_) => { + BinOp::BitAndAssign(_) => { state.write_u8(24u8); } - BinOp::BitOrEq(_) => { + BinOp::BitOrAssign(_) => { state.write_u8(25u8); } - BinOp::ShlEq(_) => { + BinOp::ShlAssign(_) => { state.write_u8(26u8); } - BinOp::ShrEq(_) => { + BinOp::ShrAssign(_) => { state.write_u8(27u8); } } } } -#[cfg(any(feature = "derive", feature = "full"))] -#[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] -impl Hash for Binding { - fn hash<H>(&self, state: &mut H) - where - H: Hasher, - { - self.ident.hash(state); - self.ty.hash(state); - } -} #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Hash for Block { @@ -229,6 +253,7 @@ impl Hash for Constraint { H: Hasher, { self.ident.hash(state); + self.generics.hash(state); self.bounds.hash(state); } } @@ -319,77 +344,76 @@ impl Hash for Expr { v0.hash(state); } #[cfg(feature = "full")] - Expr::AssignOp(v0) => { + Expr::Async(v0) => { state.write_u8(2u8); v0.hash(state); } #[cfg(feature = "full")] - Expr::Async(v0) => { + Expr::Await(v0) => { state.write_u8(3u8); v0.hash(state); } - #[cfg(feature = "full")] - Expr::Await(v0) => { + Expr::Binary(v0) => { state.write_u8(4u8); v0.hash(state); } - Expr::Binary(v0) => { + #[cfg(feature = "full")] + Expr::Block(v0) => { state.write_u8(5u8); v0.hash(state); } #[cfg(feature = "full")] - Expr::Block(v0) => { + Expr::Break(v0) => { state.write_u8(6u8); v0.hash(state); } - #[cfg(feature = "full")] - Expr::Box(v0) => { + Expr::Call(v0) => { state.write_u8(7u8); v0.hash(state); } - #[cfg(feature = "full")] - Expr::Break(v0) => { + Expr::Cast(v0) => { state.write_u8(8u8); v0.hash(state); } - Expr::Call(v0) => { + #[cfg(feature = "full")] + Expr::Closure(v0) => { state.write_u8(9u8); v0.hash(state); } - Expr::Cast(v0) => { + #[cfg(feature = "full")] + Expr::Const(v0) => { state.write_u8(10u8); v0.hash(state); } #[cfg(feature = "full")] - Expr::Closure(v0) => { + Expr::Continue(v0) => { state.write_u8(11u8); v0.hash(state); } - #[cfg(feature = "full")] - Expr::Continue(v0) => { + Expr::Field(v0) => { state.write_u8(12u8); v0.hash(state); } - Expr::Field(v0) => { + #[cfg(feature = "full")] + Expr::ForLoop(v0) => { state.write_u8(13u8); v0.hash(state); } - #[cfg(feature = "full")] - Expr::ForLoop(v0) => { + Expr::Group(v0) => { state.write_u8(14u8); v0.hash(state); } #[cfg(feature = "full")] - Expr::Group(v0) => { + Expr::If(v0) => { state.write_u8(15u8); v0.hash(state); } - #[cfg(feature = "full")] - Expr::If(v0) => { + Expr::Index(v0) => { state.write_u8(16u8); v0.hash(state); } - Expr::Index(v0) => { + #[cfg(feature = "full")] + Expr::Infer(v0) => { state.write_u8(17u8); v0.hash(state); } @@ -407,7 +431,6 @@ impl Hash for Expr { state.write_u8(20u8); v0.hash(state); } - #[cfg(feature = "full")] Expr::Macro(v0) => { state.write_u8(21u8); v0.hash(state); @@ -470,35 +493,30 @@ impl Hash for Expr { state.write_u8(33u8); v0.hash(state); } - #[cfg(feature = "full")] - Expr::Type(v0) => { - state.write_u8(34u8); - v0.hash(state); - } Expr::Unary(v0) => { - state.write_u8(35u8); + state.write_u8(34u8); v0.hash(state); } #[cfg(feature = "full")] Expr::Unsafe(v0) => { - state.write_u8(36u8); + state.write_u8(35u8); v0.hash(state); } Expr::Verbatim(v0) => { - state.write_u8(37u8); + state.write_u8(36u8); TokenStreamHelper(v0).hash(state); } #[cfg(feature = "full")] Expr::While(v0) => { - state.write_u8(38u8); + state.write_u8(37u8); v0.hash(state); } #[cfg(feature = "full")] Expr::Yield(v0) => { - state.write_u8(39u8); + state.write_u8(38u8); v0.hash(state); } - #[cfg(any(syn_no_non_exhaustive, not(feature = "full")))] + #[cfg(not(feature = "full"))] _ => unreachable!(), } } @@ -528,19 +546,6 @@ impl Hash for ExprAssign { } #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] -impl Hash for ExprAssignOp { - fn hash<H>(&self, state: &mut H) - where - H: Hasher, - { - self.attrs.hash(state); - self.left.hash(state); - self.op.hash(state); - self.right.hash(state); - } -} -#[cfg(feature = "full")] -#[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Hash for ExprAsync { fn hash<H>(&self, state: &mut H) where @@ -589,17 +594,6 @@ impl Hash for ExprBlock { } #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] -impl Hash for ExprBox { - fn hash<H>(&self, state: &mut H) - where - H: Hasher, - { - self.attrs.hash(state); - self.expr.hash(state); - } -} -#[cfg(feature = "full")] -#[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Hash for ExprBreak { fn hash<H>(&self, state: &mut H) where @@ -642,6 +636,8 @@ impl Hash for ExprClosure { H: Hasher, { self.attrs.hash(state); + self.lifetimes.hash(state); + self.constness.hash(state); self.movability.hash(state); self.asyncness.hash(state); self.capture.hash(state); @@ -652,6 +648,17 @@ impl Hash for ExprClosure { } #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] +impl Hash for ExprConst { + fn hash<H>(&self, state: &mut H) + where + H: Hasher, + { + self.attrs.hash(state); + self.block.hash(state); + } +} +#[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Hash for ExprContinue { fn hash<H>(&self, state: &mut H) where @@ -687,7 +694,7 @@ impl Hash for ExprForLoop { self.body.hash(state); } } -#[cfg(feature = "full")] +#[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Hash for ExprGroup { fn hash<H>(&self, state: &mut H) @@ -725,6 +732,16 @@ impl Hash for ExprIndex { } #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] +impl Hash for ExprInfer { + fn hash<H>(&self, state: &mut H) + where + H: Hasher, + { + self.attrs.hash(state); + } +} +#[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Hash for ExprLet { fn hash<H>(&self, state: &mut H) where @@ -758,7 +775,7 @@ impl Hash for ExprLoop { self.body.hash(state); } } -#[cfg(feature = "full")] +#[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Hash for ExprMacro { fn hash<H>(&self, state: &mut H) @@ -826,9 +843,9 @@ impl Hash for ExprRange { H: Hasher, { self.attrs.hash(state); - self.from.hash(state); + self.start.hash(state); self.limits.hash(state); - self.to.hash(state); + self.end.hash(state); } } #[cfg(feature = "full")] @@ -874,6 +891,7 @@ impl Hash for ExprStruct { H: Hasher, { self.attrs.hash(state); + self.qself.hash(state); self.path.hash(state); self.fields.hash(state); self.dot2_token.hash(state); @@ -913,18 +931,6 @@ impl Hash for ExprTuple { self.elems.hash(state); } } -#[cfg(feature = "full")] -#[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] -impl Hash for ExprType { - fn hash<H>(&self, state: &mut H) - where - H: Hasher, - { - self.attrs.hash(state); - self.expr.hash(state); - self.ty.hash(state); - } -} #[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Hash for ExprUnary { @@ -981,11 +987,26 @@ impl Hash for Field { { self.attrs.hash(state); self.vis.hash(state); + self.mutability.hash(state); self.ident.hash(state); self.colon_token.hash(state); self.ty.hash(state); } } +#[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] +impl Hash for FieldMutability { + fn hash<H>(&self, state: &mut H) + where + H: Hasher, + { + match self { + FieldMutability::None => { + state.write_u8(0u8); + } + } + } +} #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Hash for FieldPat { @@ -1113,8 +1134,6 @@ impl Hash for ForeignItem { state.write_u8(4u8); TokenStreamHelper(v0).hash(state); } - #[cfg(syn_no_non_exhaustive)] - _ => unreachable!(), } } } @@ -1166,6 +1185,7 @@ impl Hash for ForeignItemType { self.attrs.hash(state); self.vis.hash(state); self.ident.hash(state); + self.generics.hash(state); } } #[cfg(any(feature = "derive", feature = "full"))] @@ -1188,31 +1208,16 @@ impl Hash for GenericArgument { state.write_u8(2u8); v0.hash(state); } - GenericArgument::Binding(v0) => { + GenericArgument::AssocType(v0) => { state.write_u8(3u8); v0.hash(state); } - GenericArgument::Constraint(v0) => { + GenericArgument::AssocConst(v0) => { state.write_u8(4u8); v0.hash(state); } - } - } -} -#[cfg(feature = "full")] -#[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] -impl Hash for GenericMethodArgument { - fn hash<H>(&self, state: &mut H) - where - H: Hasher, - { - match self { - GenericMethodArgument::Type(v0) => { - state.write_u8(0u8); - v0.hash(state); - } - GenericMethodArgument::Const(v0) => { - state.write_u8(1u8); + GenericArgument::Constraint(v0) => { + state.write_u8(5u8); v0.hash(state); } } @@ -1226,11 +1231,11 @@ impl Hash for GenericParam { H: Hasher, { match self { - GenericParam::Type(v0) => { + GenericParam::Lifetime(v0) => { state.write_u8(0u8); v0.hash(state); } - GenericParam::Lifetime(v0) => { + GenericParam::Type(v0) => { state.write_u8(1u8); v0.hash(state); } @@ -1266,7 +1271,7 @@ impl Hash for ImplItem { state.write_u8(0u8); v0.hash(state); } - ImplItem::Method(v0) => { + ImplItem::Fn(v0) => { state.write_u8(1u8); v0.hash(state); } @@ -1282,8 +1287,6 @@ impl Hash for ImplItem { state.write_u8(4u8); TokenStreamHelper(v0).hash(state); } - #[cfg(syn_no_non_exhaustive)] - _ => unreachable!(), } } } @@ -1298,34 +1301,35 @@ impl Hash for ImplItemConst { self.vis.hash(state); self.defaultness.hash(state); self.ident.hash(state); + self.generics.hash(state); self.ty.hash(state); self.expr.hash(state); } } #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] -impl Hash for ImplItemMacro { +impl Hash for ImplItemFn { fn hash<H>(&self, state: &mut H) where H: Hasher, { self.attrs.hash(state); - self.mac.hash(state); - self.semi_token.hash(state); + self.vis.hash(state); + self.defaultness.hash(state); + self.sig.hash(state); + self.block.hash(state); } } #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] -impl Hash for ImplItemMethod { +impl Hash for ImplItemMacro { fn hash<H>(&self, state: &mut H) where H: Hasher, { self.attrs.hash(state); - self.vis.hash(state); - self.defaultness.hash(state); - self.sig.hash(state); - self.block.hash(state); + self.mac.hash(state); + self.semi_token.hash(state); } } #[cfg(feature = "full")] @@ -1345,6 +1349,16 @@ impl Hash for ImplItemType { } #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] +impl Hash for ImplRestriction { + fn hash<H>(&self, _state: &mut H) + where + H: Hasher, + { + match *self {} + } +} +#[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Hash for Item { fn hash<H>(&self, state: &mut H) where @@ -1379,48 +1393,42 @@ impl Hash for Item { state.write_u8(6u8); v0.hash(state); } - Item::Macro2(v0) => { - state.write_u8(7u8); - v0.hash(state); - } Item::Mod(v0) => { - state.write_u8(8u8); + state.write_u8(7u8); v0.hash(state); } Item::Static(v0) => { - state.write_u8(9u8); + state.write_u8(8u8); v0.hash(state); } Item::Struct(v0) => { - state.write_u8(10u8); + state.write_u8(9u8); v0.hash(state); } Item::Trait(v0) => { - state.write_u8(11u8); + state.write_u8(10u8); v0.hash(state); } Item::TraitAlias(v0) => { - state.write_u8(12u8); + state.write_u8(11u8); v0.hash(state); } Item::Type(v0) => { - state.write_u8(13u8); + state.write_u8(12u8); v0.hash(state); } Item::Union(v0) => { - state.write_u8(14u8); + state.write_u8(13u8); v0.hash(state); } Item::Use(v0) => { - state.write_u8(15u8); + state.write_u8(14u8); v0.hash(state); } Item::Verbatim(v0) => { - state.write_u8(16u8); + state.write_u8(15u8); TokenStreamHelper(v0).hash(state); } - #[cfg(syn_no_non_exhaustive)] - _ => unreachable!(), } } } @@ -1434,6 +1442,7 @@ impl Hash for ItemConst { self.attrs.hash(state); self.vis.hash(state); self.ident.hash(state); + self.generics.hash(state); self.ty.hash(state); self.expr.hash(state); } @@ -1486,6 +1495,7 @@ impl Hash for ItemForeignMod { H: Hasher, { self.attrs.hash(state); + self.unsafety.hash(state); self.abi.hash(state); self.items.hash(state); } @@ -1521,19 +1531,6 @@ impl Hash for ItemMacro { } #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] -impl Hash for ItemMacro2 { - fn hash<H>(&self, state: &mut H) - where - H: Hasher, - { - self.attrs.hash(state); - self.vis.hash(state); - self.ident.hash(state); - TokenStreamHelper(&self.rules).hash(state); - } -} -#[cfg(feature = "full")] -#[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Hash for ItemMod { fn hash<H>(&self, state: &mut H) where @@ -1541,6 +1538,7 @@ impl Hash for ItemMod { { self.attrs.hash(state); self.vis.hash(state); + self.unsafety.hash(state); self.ident.hash(state); self.content.hash(state); self.semi.hash(state); @@ -1587,6 +1585,7 @@ impl Hash for ItemTrait { self.vis.hash(state); self.unsafety.hash(state); self.auto_token.hash(state); + self.restriction.hash(state); self.ident.hash(state); self.generics.hash(state); self.colon_token.hash(state); @@ -1661,7 +1660,7 @@ impl Hash for Label { } #[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] -impl Hash for LifetimeDef { +impl Hash for LifetimeParam { fn hash<H>(&self, state: &mut H) where H: Hasher, @@ -1735,6 +1734,17 @@ impl Hash for Local { self.init.hash(state); } } +#[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] +impl Hash for LocalInit { + fn hash<H>(&self, state: &mut H) + where + H: Hasher, + { + self.expr.hash(state); + self.diverge.hash(state); + } +} #[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Hash for Macro { @@ -1798,7 +1808,8 @@ impl Hash for MetaList { H: Hasher, { self.path.hash(state); - self.nested.hash(state); + self.delimiter.hash(state); + TokenStreamHelper(&self.tokens).hash(state); } } #[cfg(any(feature = "derive", feature = "full"))] @@ -1809,36 +1820,7 @@ impl Hash for MetaNameValue { H: Hasher, { self.path.hash(state); - self.lit.hash(state); - } -} -#[cfg(feature = "full")] -#[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] -impl Hash for MethodTurbofish { - fn hash<H>(&self, state: &mut H) - where - H: Hasher, - { - self.args.hash(state); - } -} -#[cfg(any(feature = "derive", feature = "full"))] -#[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] -impl Hash for NestedMeta { - fn hash<H>(&self, state: &mut H) - where - H: Hasher, - { - match self { - NestedMeta::Meta(v0) => { - state.write_u8(0u8); - v0.hash(state); - } - NestedMeta::Lit(v0) => { - state.write_u8(1u8); - v0.hash(state); - } - } + self.value.hash(state); } } #[cfg(any(feature = "derive", feature = "full"))] @@ -1860,7 +1842,7 @@ impl Hash for Pat { H: Hasher, { match self { - Pat::Box(v0) => { + Pat::Const(v0) => { state.write_u8(0u8); v0.hash(state); } @@ -1880,68 +1862,59 @@ impl Hash for Pat { state.write_u8(4u8); v0.hash(state); } - Pat::Path(v0) => { + Pat::Paren(v0) => { state.write_u8(5u8); v0.hash(state); } - Pat::Range(v0) => { + Pat::Path(v0) => { state.write_u8(6u8); v0.hash(state); } - Pat::Reference(v0) => { + Pat::Range(v0) => { state.write_u8(7u8); v0.hash(state); } - Pat::Rest(v0) => { + Pat::Reference(v0) => { state.write_u8(8u8); v0.hash(state); } - Pat::Slice(v0) => { + Pat::Rest(v0) => { state.write_u8(9u8); v0.hash(state); } - Pat::Struct(v0) => { + Pat::Slice(v0) => { state.write_u8(10u8); v0.hash(state); } - Pat::Tuple(v0) => { + Pat::Struct(v0) => { state.write_u8(11u8); v0.hash(state); } - Pat::TupleStruct(v0) => { + Pat::Tuple(v0) => { state.write_u8(12u8); v0.hash(state); } - Pat::Type(v0) => { + Pat::TupleStruct(v0) => { state.write_u8(13u8); v0.hash(state); } - Pat::Verbatim(v0) => { + Pat::Type(v0) => { state.write_u8(14u8); + v0.hash(state); + } + Pat::Verbatim(v0) => { + state.write_u8(15u8); TokenStreamHelper(v0).hash(state); } Pat::Wild(v0) => { - state.write_u8(15u8); + state.write_u8(16u8); v0.hash(state); } - #[cfg(syn_no_non_exhaustive)] - _ => unreachable!(), } } } #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] -impl Hash for PatBox { - fn hash<H>(&self, state: &mut H) - where - H: Hasher, - { - self.attrs.hash(state); - self.pat.hash(state); - } -} -#[cfg(feature = "full")] -#[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Hash for PatIdent { fn hash<H>(&self, state: &mut H) where @@ -1956,28 +1929,6 @@ impl Hash for PatIdent { } #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] -impl Hash for PatLit { - fn hash<H>(&self, state: &mut H) - where - H: Hasher, - { - self.attrs.hash(state); - self.expr.hash(state); - } -} -#[cfg(feature = "full")] -#[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] -impl Hash for PatMacro { - fn hash<H>(&self, state: &mut H) - where - H: Hasher, - { - self.attrs.hash(state); - self.mac.hash(state); - } -} -#[cfg(feature = "full")] -#[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Hash for PatOr { fn hash<H>(&self, state: &mut H) where @@ -1990,27 +1941,13 @@ impl Hash for PatOr { } #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] -impl Hash for PatPath { - fn hash<H>(&self, state: &mut H) - where - H: Hasher, - { - self.attrs.hash(state); - self.qself.hash(state); - self.path.hash(state); - } -} -#[cfg(feature = "full")] -#[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] -impl Hash for PatRange { +impl Hash for PatParen { fn hash<H>(&self, state: &mut H) where H: Hasher, { self.attrs.hash(state); - self.lo.hash(state); - self.limits.hash(state); - self.hi.hash(state); + self.pat.hash(state); } } #[cfg(feature = "full")] @@ -2054,9 +1991,10 @@ impl Hash for PatStruct { H: Hasher, { self.attrs.hash(state); + self.qself.hash(state); self.path.hash(state); self.fields.hash(state); - self.dot2_token.hash(state); + self.rest.hash(state); } } #[cfg(feature = "full")] @@ -2078,8 +2016,9 @@ impl Hash for PatTupleStruct { H: Hasher, { self.attrs.hash(state); + self.qself.hash(state); self.path.hash(state); - self.pat.hash(state); + self.elems.hash(state); } } #[cfg(feature = "full")] @@ -2150,17 +2089,6 @@ impl Hash for PathSegment { } #[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] -impl Hash for PredicateEq { - fn hash<H>(&self, state: &mut H) - where - H: Hasher, - { - self.lhs_ty.hash(state); - self.rhs_ty.hash(state); - } -} -#[cfg(any(feature = "derive", feature = "full"))] -#[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Hash for PredicateLifetime { fn hash<H>(&self, state: &mut H) where @@ -2221,6 +2149,8 @@ impl Hash for Receiver { self.attrs.hash(state); self.reference.hash(state); self.mutability.hash(state); + self.colon_token.hash(state); + self.ty.hash(state); } } #[cfg(any(feature = "derive", feature = "full"))] @@ -2261,6 +2191,23 @@ impl Hash for Signature { } #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] +impl Hash for StaticMutability { + fn hash<H>(&self, state: &mut H) + where + H: Hasher, + { + match self { + StaticMutability::Mut(_) => { + state.write_u8(0u8); + } + StaticMutability::None => { + state.write_u8(1u8); + } + } + } +} +#[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Hash for Stmt { fn hash<H>(&self, state: &mut H) where @@ -2275,17 +2222,30 @@ impl Hash for Stmt { state.write_u8(1u8); v0.hash(state); } - Stmt::Expr(v0) => { + Stmt::Expr(v0, v1) => { state.write_u8(2u8); v0.hash(state); + v1.hash(state); } - Stmt::Semi(v0, _) => { + Stmt::Macro(v0) => { state.write_u8(3u8); v0.hash(state); } } } } +#[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] +impl Hash for StmtMacro { + fn hash<H>(&self, state: &mut H) + where + H: Hasher, + { + self.attrs.hash(state); + self.mac.hash(state); + self.semi_token.hash(state); + } +} #[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Hash for TraitBound { @@ -2328,7 +2288,7 @@ impl Hash for TraitItem { state.write_u8(0u8); v0.hash(state); } - TraitItem::Method(v0) => { + TraitItem::Fn(v0) => { state.write_u8(1u8); v0.hash(state); } @@ -2344,8 +2304,6 @@ impl Hash for TraitItem { state.write_u8(4u8); TokenStreamHelper(v0).hash(state); } - #[cfg(syn_no_non_exhaustive)] - _ => unreachable!(), } } } @@ -2358,32 +2316,33 @@ impl Hash for TraitItemConst { { self.attrs.hash(state); self.ident.hash(state); + self.generics.hash(state); self.ty.hash(state); self.default.hash(state); } } #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] -impl Hash for TraitItemMacro { +impl Hash for TraitItemFn { fn hash<H>(&self, state: &mut H) where H: Hasher, { self.attrs.hash(state); - self.mac.hash(state); + self.sig.hash(state); + self.default.hash(state); self.semi_token.hash(state); } } #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] -impl Hash for TraitItemMethod { +impl Hash for TraitItemMacro { fn hash<H>(&self, state: &mut H) where H: Hasher, { self.attrs.hash(state); - self.sig.hash(state); - self.default.hash(state); + self.mac.hash(state); self.semi_token.hash(state); } } @@ -2470,8 +2429,6 @@ impl Hash for Type { state.write_u8(14u8); TokenStreamHelper(v0).hash(state); } - #[cfg(syn_no_non_exhaustive)] - _ => unreachable!(), } } } @@ -2578,6 +2535,10 @@ impl Hash for TypeParamBound { state.write_u8(1u8); v0.hash(state); } + TypeParamBound::Verbatim(v0) => { + state.write_u8(2u8); + TokenStreamHelper(v0).hash(state); + } } } } @@ -2758,7 +2719,7 @@ impl Hash for UseTree { } } } -#[cfg(any(feature = "derive", feature = "full"))] +#[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Hash for Variadic { fn hash<H>(&self, state: &mut H) @@ -2766,6 +2727,8 @@ impl Hash for Variadic { H: Hasher, { self.attrs.hash(state); + self.pat.hash(state); + self.comma.hash(state); } } #[cfg(any(feature = "derive", feature = "full"))] @@ -2783,22 +2746,6 @@ impl Hash for Variant { } #[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] -impl Hash for VisCrate { - fn hash<H>(&self, _state: &mut H) - where - H: Hasher, - {} -} -#[cfg(any(feature = "derive", feature = "full"))] -#[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] -impl Hash for VisPublic { - fn hash<H>(&self, _state: &mut H) - where - H: Hasher, - {} -} -#[cfg(any(feature = "derive", feature = "full"))] -#[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Hash for VisRestricted { fn hash<H>(&self, state: &mut H) where @@ -2816,20 +2763,15 @@ impl Hash for Visibility { H: Hasher, { match self { - Visibility::Public(v0) => { + Visibility::Public(_) => { state.write_u8(0u8); - v0.hash(state); - } - Visibility::Crate(v0) => { - state.write_u8(1u8); - v0.hash(state); } Visibility::Restricted(v0) => { - state.write_u8(2u8); + state.write_u8(1u8); v0.hash(state); } Visibility::Inherited => { - state.write_u8(3u8); + state.write_u8(2u8); } } } @@ -2852,18 +2794,14 @@ impl Hash for WherePredicate { H: Hasher, { match self { - WherePredicate::Type(v0) => { + WherePredicate::Lifetime(v0) => { state.write_u8(0u8); v0.hash(state); } - WherePredicate::Lifetime(v0) => { + WherePredicate::Type(v0) => { state.write_u8(1u8); v0.hash(state); } - WherePredicate::Eq(v0) => { - state.write_u8(2u8); - v0.hash(state); - } } } } diff --git a/vendor/syn/src/gen/visit.rs b/vendor/syn/src/gen/visit.rs index 19ddd2e72..9eaa24f05 100644 --- a/vendor/syn/src/gen/visit.rs +++ b/vendor/syn/src/gen/visit.rs @@ -3,8 +3,6 @@ #![allow(unused_variables)] #[cfg(any(feature = "full", feature = "derive"))] -use crate::gen::helper::visit::*; -#[cfg(any(feature = "full", feature = "derive"))] use crate::punctuated::Punctuated; use crate::*; use proc_macro2::Span; @@ -28,8 +26,6 @@ macro_rules! skip { /// See the [module documentation] for details. /// /// [module documentation]: self -/// -/// *This trait is available only if Syn is built with the `"visit"` feature.* pub trait Visit<'ast> { #[cfg(any(feature = "derive", feature = "full"))] fn visit_abi(&mut self, i: &'ast Abi) { @@ -47,6 +43,14 @@ pub trait Visit<'ast> { visit_arm(self, i); } #[cfg(any(feature = "derive", feature = "full"))] + fn visit_assoc_const(&mut self, i: &'ast AssocConst) { + visit_assoc_const(self, i); + } + #[cfg(any(feature = "derive", feature = "full"))] + fn visit_assoc_type(&mut self, i: &'ast AssocType) { + visit_assoc_type(self, i); + } + #[cfg(any(feature = "derive", feature = "full"))] fn visit_attr_style(&mut self, i: &'ast AttrStyle) { visit_attr_style(self, i); } @@ -59,12 +63,12 @@ pub trait Visit<'ast> { visit_bare_fn_arg(self, i); } #[cfg(any(feature = "derive", feature = "full"))] - fn visit_bin_op(&mut self, i: &'ast BinOp) { - visit_bin_op(self, i); + fn visit_bare_variadic(&mut self, i: &'ast BareVariadic) { + visit_bare_variadic(self, i); } #[cfg(any(feature = "derive", feature = "full"))] - fn visit_binding(&mut self, i: &'ast Binding) { - visit_binding(self, i); + fn visit_bin_op(&mut self, i: &'ast BinOp) { + visit_bin_op(self, i); } #[cfg(feature = "full")] fn visit_block(&mut self, i: &'ast Block) { @@ -115,10 +119,6 @@ pub trait Visit<'ast> { visit_expr_assign(self, i); } #[cfg(feature = "full")] - fn visit_expr_assign_op(&mut self, i: &'ast ExprAssignOp) { - visit_expr_assign_op(self, i); - } - #[cfg(feature = "full")] fn visit_expr_async(&mut self, i: &'ast ExprAsync) { visit_expr_async(self, i); } @@ -135,10 +135,6 @@ pub trait Visit<'ast> { visit_expr_block(self, i); } #[cfg(feature = "full")] - fn visit_expr_box(&mut self, i: &'ast ExprBox) { - visit_expr_box(self, i); - } - #[cfg(feature = "full")] fn visit_expr_break(&mut self, i: &'ast ExprBreak) { visit_expr_break(self, i); } @@ -155,6 +151,10 @@ pub trait Visit<'ast> { visit_expr_closure(self, i); } #[cfg(feature = "full")] + fn visit_expr_const(&mut self, i: &'ast ExprConst) { + visit_expr_const(self, i); + } + #[cfg(feature = "full")] fn visit_expr_continue(&mut self, i: &'ast ExprContinue) { visit_expr_continue(self, i); } @@ -166,7 +166,7 @@ pub trait Visit<'ast> { fn visit_expr_for_loop(&mut self, i: &'ast ExprForLoop) { visit_expr_for_loop(self, i); } - #[cfg(feature = "full")] + #[cfg(any(feature = "derive", feature = "full"))] fn visit_expr_group(&mut self, i: &'ast ExprGroup) { visit_expr_group(self, i); } @@ -179,6 +179,10 @@ pub trait Visit<'ast> { visit_expr_index(self, i); } #[cfg(feature = "full")] + fn visit_expr_infer(&mut self, i: &'ast ExprInfer) { + visit_expr_infer(self, i); + } + #[cfg(feature = "full")] fn visit_expr_let(&mut self, i: &'ast ExprLet) { visit_expr_let(self, i); } @@ -190,7 +194,7 @@ pub trait Visit<'ast> { fn visit_expr_loop(&mut self, i: &'ast ExprLoop) { visit_expr_loop(self, i); } - #[cfg(feature = "full")] + #[cfg(any(feature = "derive", feature = "full"))] fn visit_expr_macro(&mut self, i: &'ast ExprMacro) { visit_expr_macro(self, i); } @@ -242,10 +246,6 @@ pub trait Visit<'ast> { fn visit_expr_tuple(&mut self, i: &'ast ExprTuple) { visit_expr_tuple(self, i); } - #[cfg(feature = "full")] - fn visit_expr_type(&mut self, i: &'ast ExprType) { - visit_expr_type(self, i); - } #[cfg(any(feature = "derive", feature = "full"))] fn visit_expr_unary(&mut self, i: &'ast ExprUnary) { visit_expr_unary(self, i); @@ -266,6 +266,10 @@ pub trait Visit<'ast> { fn visit_field(&mut self, i: &'ast Field) { visit_field(self, i); } + #[cfg(any(feature = "derive", feature = "full"))] + fn visit_field_mutability(&mut self, i: &'ast FieldMutability) { + visit_field_mutability(self, i); + } #[cfg(feature = "full")] fn visit_field_pat(&mut self, i: &'ast FieldPat) { visit_field_pat(self, i); @@ -318,10 +322,6 @@ pub trait Visit<'ast> { fn visit_generic_argument(&mut self, i: &'ast GenericArgument) { visit_generic_argument(self, i); } - #[cfg(feature = "full")] - fn visit_generic_method_argument(&mut self, i: &'ast GenericMethodArgument) { - visit_generic_method_argument(self, i); - } #[cfg(any(feature = "derive", feature = "full"))] fn visit_generic_param(&mut self, i: &'ast GenericParam) { visit_generic_param(self, i); @@ -342,17 +342,21 @@ pub trait Visit<'ast> { visit_impl_item_const(self, i); } #[cfg(feature = "full")] - fn visit_impl_item_macro(&mut self, i: &'ast ImplItemMacro) { - visit_impl_item_macro(self, i); + fn visit_impl_item_fn(&mut self, i: &'ast ImplItemFn) { + visit_impl_item_fn(self, i); } #[cfg(feature = "full")] - fn visit_impl_item_method(&mut self, i: &'ast ImplItemMethod) { - visit_impl_item_method(self, i); + fn visit_impl_item_macro(&mut self, i: &'ast ImplItemMacro) { + visit_impl_item_macro(self, i); } #[cfg(feature = "full")] fn visit_impl_item_type(&mut self, i: &'ast ImplItemType) { visit_impl_item_type(self, i); } + #[cfg(feature = "full")] + fn visit_impl_restriction(&mut self, i: &'ast ImplRestriction) { + visit_impl_restriction(self, i); + } #[cfg(any(feature = "derive", feature = "full"))] fn visit_index(&mut self, i: &'ast Index) { visit_index(self, i); @@ -390,10 +394,6 @@ pub trait Visit<'ast> { visit_item_macro(self, i); } #[cfg(feature = "full")] - fn visit_item_macro2(&mut self, i: &'ast ItemMacro2) { - visit_item_macro2(self, i); - } - #[cfg(feature = "full")] fn visit_item_mod(&mut self, i: &'ast ItemMod) { visit_item_mod(self, i); } @@ -433,8 +433,8 @@ pub trait Visit<'ast> { visit_lifetime(self, i); } #[cfg(any(feature = "derive", feature = "full"))] - fn visit_lifetime_def(&mut self, i: &'ast LifetimeDef) { - visit_lifetime_def(self, i); + fn visit_lifetime_param(&mut self, i: &'ast LifetimeParam) { + visit_lifetime_param(self, i); } fn visit_lit(&mut self, i: &'ast Lit) { visit_lit(self, i); @@ -464,6 +464,10 @@ pub trait Visit<'ast> { fn visit_local(&mut self, i: &'ast Local) { visit_local(self, i); } + #[cfg(feature = "full")] + fn visit_local_init(&mut self, i: &'ast LocalInit) { + visit_local_init(self, i); + } #[cfg(any(feature = "derive", feature = "full"))] fn visit_macro(&mut self, i: &'ast Macro) { visit_macro(self, i); @@ -488,14 +492,6 @@ pub trait Visit<'ast> { fn visit_meta_name_value(&mut self, i: &'ast MetaNameValue) { visit_meta_name_value(self, i); } - #[cfg(feature = "full")] - fn visit_method_turbofish(&mut self, i: &'ast MethodTurbofish) { - visit_method_turbofish(self, i); - } - #[cfg(any(feature = "derive", feature = "full"))] - fn visit_nested_meta(&mut self, i: &'ast NestedMeta) { - visit_nested_meta(self, i); - } #[cfg(any(feature = "derive", feature = "full"))] fn visit_parenthesized_generic_arguments( &mut self, @@ -508,32 +504,16 @@ pub trait Visit<'ast> { visit_pat(self, i); } #[cfg(feature = "full")] - fn visit_pat_box(&mut self, i: &'ast PatBox) { - visit_pat_box(self, i); - } - #[cfg(feature = "full")] fn visit_pat_ident(&mut self, i: &'ast PatIdent) { visit_pat_ident(self, i); } #[cfg(feature = "full")] - fn visit_pat_lit(&mut self, i: &'ast PatLit) { - visit_pat_lit(self, i); - } - #[cfg(feature = "full")] - fn visit_pat_macro(&mut self, i: &'ast PatMacro) { - visit_pat_macro(self, i); - } - #[cfg(feature = "full")] fn visit_pat_or(&mut self, i: &'ast PatOr) { visit_pat_or(self, i); } #[cfg(feature = "full")] - fn visit_pat_path(&mut self, i: &'ast PatPath) { - visit_pat_path(self, i); - } - #[cfg(feature = "full")] - fn visit_pat_range(&mut self, i: &'ast PatRange) { - visit_pat_range(self, i); + fn visit_pat_paren(&mut self, i: &'ast PatParen) { + visit_pat_paren(self, i); } #[cfg(feature = "full")] fn visit_pat_reference(&mut self, i: &'ast PatReference) { @@ -580,10 +560,6 @@ pub trait Visit<'ast> { visit_path_segment(self, i); } #[cfg(any(feature = "derive", feature = "full"))] - fn visit_predicate_eq(&mut self, i: &'ast PredicateEq) { - visit_predicate_eq(self, i); - } - #[cfg(any(feature = "derive", feature = "full"))] fn visit_predicate_lifetime(&mut self, i: &'ast PredicateLifetime) { visit_predicate_lifetime(self, i); } @@ -615,9 +591,17 @@ pub trait Visit<'ast> { visit_span(self, i); } #[cfg(feature = "full")] + fn visit_static_mutability(&mut self, i: &'ast StaticMutability) { + visit_static_mutability(self, i); + } + #[cfg(feature = "full")] fn visit_stmt(&mut self, i: &'ast Stmt) { visit_stmt(self, i); } + #[cfg(feature = "full")] + fn visit_stmt_macro(&mut self, i: &'ast StmtMacro) { + visit_stmt_macro(self, i); + } #[cfg(any(feature = "derive", feature = "full"))] fn visit_trait_bound(&mut self, i: &'ast TraitBound) { visit_trait_bound(self, i); @@ -635,12 +619,12 @@ pub trait Visit<'ast> { visit_trait_item_const(self, i); } #[cfg(feature = "full")] - fn visit_trait_item_macro(&mut self, i: &'ast TraitItemMacro) { - visit_trait_item_macro(self, i); + fn visit_trait_item_fn(&mut self, i: &'ast TraitItemFn) { + visit_trait_item_fn(self, i); } #[cfg(feature = "full")] - fn visit_trait_item_method(&mut self, i: &'ast TraitItemMethod) { - visit_trait_item_method(self, i); + fn visit_trait_item_macro(&mut self, i: &'ast TraitItemMacro) { + visit_trait_item_macro(self, i); } #[cfg(feature = "full")] fn visit_trait_item_type(&mut self, i: &'ast TraitItemType) { @@ -742,7 +726,7 @@ pub trait Visit<'ast> { fn visit_use_tree(&mut self, i: &'ast UseTree) { visit_use_tree(self, i); } - #[cfg(any(feature = "derive", feature = "full"))] + #[cfg(feature = "full")] fn visit_variadic(&mut self, i: &'ast Variadic) { visit_variadic(self, i); } @@ -751,14 +735,6 @@ pub trait Visit<'ast> { visit_variant(self, i); } #[cfg(any(feature = "derive", feature = "full"))] - fn visit_vis_crate(&mut self, i: &'ast VisCrate) { - visit_vis_crate(self, i); - } - #[cfg(any(feature = "derive", feature = "full"))] - fn visit_vis_public(&mut self, i: &'ast VisPublic) { - visit_vis_public(self, i); - } - #[cfg(any(feature = "derive", feature = "full"))] fn visit_vis_restricted(&mut self, i: &'ast VisRestricted) { visit_vis_restricted(self, i); } @@ -780,7 +756,7 @@ pub fn visit_abi<'ast, V>(v: &mut V, node: &'ast Abi) where V: Visit<'ast> + ?Sized, { - tokens_helper(v, &node.extern_token.span); + skip!(node.extern_token); if let Some(it) = &node.name { v.visit_lit_str(it); } @@ -793,18 +769,13 @@ pub fn visit_angle_bracketed_generic_arguments<'ast, V>( where V: Visit<'ast> + ?Sized, { - if let Some(it) = &node.colon2_token { - tokens_helper(v, &it.spans); - } - tokens_helper(v, &node.lt_token.spans); + skip!(node.colon2_token); + skip!(node.lt_token); for el in Punctuated::pairs(&node.args) { - let (it, p) = el.into_tuple(); + let it = el.value(); v.visit_generic_argument(it); - if let Some(p) = p { - tokens_helper(v, &p.spans); - } } - tokens_helper(v, &node.gt_token.spans); + skip!(node.gt_token); } #[cfg(feature = "full")] pub fn visit_arm<'ast, V>(v: &mut V, node: &'ast Arm) @@ -816,14 +787,36 @@ where } v.visit_pat(&node.pat); if let Some(it) = &node.guard { - tokens_helper(v, &(it).0.span); + skip!((it).0); v.visit_expr(&*(it).1); } - tokens_helper(v, &node.fat_arrow_token.spans); + skip!(node.fat_arrow_token); v.visit_expr(&*node.body); - if let Some(it) = &node.comma { - tokens_helper(v, &it.spans); + skip!(node.comma); +} +#[cfg(any(feature = "derive", feature = "full"))] +pub fn visit_assoc_const<'ast, V>(v: &mut V, node: &'ast AssocConst) +where + V: Visit<'ast> + ?Sized, +{ + v.visit_ident(&node.ident); + if let Some(it) = &node.generics { + v.visit_angle_bracketed_generic_arguments(it); } + skip!(node.eq_token); + v.visit_expr(&node.value); +} +#[cfg(any(feature = "derive", feature = "full"))] +pub fn visit_assoc_type<'ast, V>(v: &mut V, node: &'ast AssocType) +where + V: Visit<'ast> + ?Sized, +{ + v.visit_ident(&node.ident); + if let Some(it) = &node.generics { + v.visit_angle_bracketed_generic_arguments(it); + } + skip!(node.eq_token); + v.visit_type(&node.ty); } #[cfg(any(feature = "derive", feature = "full"))] pub fn visit_attr_style<'ast, V>(v: &mut V, node: &'ast AttrStyle) @@ -833,7 +826,7 @@ where match node { AttrStyle::Outer => {} AttrStyle::Inner(_binding_0) => { - tokens_helper(v, &_binding_0.spans); + skip!(_binding_0); } } } @@ -842,11 +835,10 @@ pub fn visit_attribute<'ast, V>(v: &mut V, node: &'ast Attribute) where V: Visit<'ast> + ?Sized, { - tokens_helper(v, &node.pound_token.spans); + skip!(node.pound_token); v.visit_attr_style(&node.style); - tokens_helper(v, &node.bracket_token.span); - v.visit_path(&node.path); - skip!(node.tokens); + skip!(node.bracket_token); + v.visit_meta(&node.meta); } #[cfg(any(feature = "derive", feature = "full"))] pub fn visit_bare_fn_arg<'ast, V>(v: &mut V, node: &'ast BareFnArg) @@ -858,117 +850,123 @@ where } if let Some(it) = &node.name { v.visit_ident(&(it).0); - tokens_helper(v, &(it).1.spans); + skip!((it).1); } v.visit_type(&node.ty); } #[cfg(any(feature = "derive", feature = "full"))] +pub fn visit_bare_variadic<'ast, V>(v: &mut V, node: &'ast BareVariadic) +where + V: Visit<'ast> + ?Sized, +{ + for it in &node.attrs { + v.visit_attribute(it); + } + if let Some(it) = &node.name { + v.visit_ident(&(it).0); + skip!((it).1); + } + skip!(node.dots); + skip!(node.comma); +} +#[cfg(any(feature = "derive", feature = "full"))] pub fn visit_bin_op<'ast, V>(v: &mut V, node: &'ast BinOp) where V: Visit<'ast> + ?Sized, { match node { BinOp::Add(_binding_0) => { - tokens_helper(v, &_binding_0.spans); + skip!(_binding_0); } BinOp::Sub(_binding_0) => { - tokens_helper(v, &_binding_0.spans); + skip!(_binding_0); } BinOp::Mul(_binding_0) => { - tokens_helper(v, &_binding_0.spans); + skip!(_binding_0); } BinOp::Div(_binding_0) => { - tokens_helper(v, &_binding_0.spans); + skip!(_binding_0); } BinOp::Rem(_binding_0) => { - tokens_helper(v, &_binding_0.spans); + skip!(_binding_0); } BinOp::And(_binding_0) => { - tokens_helper(v, &_binding_0.spans); + skip!(_binding_0); } BinOp::Or(_binding_0) => { - tokens_helper(v, &_binding_0.spans); + skip!(_binding_0); } BinOp::BitXor(_binding_0) => { - tokens_helper(v, &_binding_0.spans); + skip!(_binding_0); } BinOp::BitAnd(_binding_0) => { - tokens_helper(v, &_binding_0.spans); + skip!(_binding_0); } BinOp::BitOr(_binding_0) => { - tokens_helper(v, &_binding_0.spans); + skip!(_binding_0); } BinOp::Shl(_binding_0) => { - tokens_helper(v, &_binding_0.spans); + skip!(_binding_0); } BinOp::Shr(_binding_0) => { - tokens_helper(v, &_binding_0.spans); + skip!(_binding_0); } BinOp::Eq(_binding_0) => { - tokens_helper(v, &_binding_0.spans); + skip!(_binding_0); } BinOp::Lt(_binding_0) => { - tokens_helper(v, &_binding_0.spans); + skip!(_binding_0); } BinOp::Le(_binding_0) => { - tokens_helper(v, &_binding_0.spans); + skip!(_binding_0); } BinOp::Ne(_binding_0) => { - tokens_helper(v, &_binding_0.spans); + skip!(_binding_0); } BinOp::Ge(_binding_0) => { - tokens_helper(v, &_binding_0.spans); + skip!(_binding_0); } BinOp::Gt(_binding_0) => { - tokens_helper(v, &_binding_0.spans); + skip!(_binding_0); } - BinOp::AddEq(_binding_0) => { - tokens_helper(v, &_binding_0.spans); + BinOp::AddAssign(_binding_0) => { + skip!(_binding_0); } - BinOp::SubEq(_binding_0) => { - tokens_helper(v, &_binding_0.spans); + BinOp::SubAssign(_binding_0) => { + skip!(_binding_0); } - BinOp::MulEq(_binding_0) => { - tokens_helper(v, &_binding_0.spans); + BinOp::MulAssign(_binding_0) => { + skip!(_binding_0); } - BinOp::DivEq(_binding_0) => { - tokens_helper(v, &_binding_0.spans); + BinOp::DivAssign(_binding_0) => { + skip!(_binding_0); } - BinOp::RemEq(_binding_0) => { - tokens_helper(v, &_binding_0.spans); + BinOp::RemAssign(_binding_0) => { + skip!(_binding_0); } - BinOp::BitXorEq(_binding_0) => { - tokens_helper(v, &_binding_0.spans); + BinOp::BitXorAssign(_binding_0) => { + skip!(_binding_0); } - BinOp::BitAndEq(_binding_0) => { - tokens_helper(v, &_binding_0.spans); + BinOp::BitAndAssign(_binding_0) => { + skip!(_binding_0); } - BinOp::BitOrEq(_binding_0) => { - tokens_helper(v, &_binding_0.spans); + BinOp::BitOrAssign(_binding_0) => { + skip!(_binding_0); } - BinOp::ShlEq(_binding_0) => { - tokens_helper(v, &_binding_0.spans); + BinOp::ShlAssign(_binding_0) => { + skip!(_binding_0); } - BinOp::ShrEq(_binding_0) => { - tokens_helper(v, &_binding_0.spans); + BinOp::ShrAssign(_binding_0) => { + skip!(_binding_0); } } } -#[cfg(any(feature = "derive", feature = "full"))] -pub fn visit_binding<'ast, V>(v: &mut V, node: &'ast Binding) -where - V: Visit<'ast> + ?Sized, -{ - v.visit_ident(&node.ident); - tokens_helper(v, &node.eq_token.spans); - v.visit_type(&node.ty); -} #[cfg(feature = "full")] pub fn visit_block<'ast, V>(v: &mut V, node: &'ast Block) where V: Visit<'ast> + ?Sized, { - tokens_helper(v, &node.brace_token.span); + skip!(node.brace_token); for it in &node.stmts { v.visit_stmt(it); } @@ -978,16 +976,13 @@ pub fn visit_bound_lifetimes<'ast, V>(v: &mut V, node: &'ast BoundLifetimes) where V: Visit<'ast> + ?Sized, { - tokens_helper(v, &node.for_token.span); - tokens_helper(v, &node.lt_token.spans); + skip!(node.for_token); + skip!(node.lt_token); for el in Punctuated::pairs(&node.lifetimes) { - let (it, p) = el.into_tuple(); - v.visit_lifetime_def(it); - if let Some(p) = p { - tokens_helper(v, &p.spans); - } + let it = el.value(); + v.visit_generic_param(it); } - tokens_helper(v, &node.gt_token.spans); + skip!(node.gt_token); } #[cfg(any(feature = "derive", feature = "full"))] pub fn visit_const_param<'ast, V>(v: &mut V, node: &'ast ConstParam) @@ -997,13 +992,11 @@ where for it in &node.attrs { v.visit_attribute(it); } - tokens_helper(v, &node.const_token.span); + skip!(node.const_token); v.visit_ident(&node.ident); - tokens_helper(v, &node.colon_token.spans); + skip!(node.colon_token); v.visit_type(&node.ty); - if let Some(it) = &node.eq_token { - tokens_helper(v, &it.spans); - } + skip!(node.eq_token); if let Some(it) = &node.default { v.visit_expr(it); } @@ -1014,13 +1007,13 @@ where V: Visit<'ast> + ?Sized, { v.visit_ident(&node.ident); - tokens_helper(v, &node.colon_token.spans); + if let Some(it) = &node.generics { + v.visit_angle_bracketed_generic_arguments(it); + } + skip!(node.colon_token); for el in Punctuated::pairs(&node.bounds) { - let (it, p) = el.into_tuple(); + let it = el.value(); v.visit_type_param_bound(it); - if let Some(p) = p { - tokens_helper(v, &p.spans); - } } } #[cfg(feature = "derive")] @@ -1045,14 +1038,11 @@ pub fn visit_data_enum<'ast, V>(v: &mut V, node: &'ast DataEnum) where V: Visit<'ast> + ?Sized, { - tokens_helper(v, &node.enum_token.span); - tokens_helper(v, &node.brace_token.span); + skip!(node.enum_token); + skip!(node.brace_token); for el in Punctuated::pairs(&node.variants) { - let (it, p) = el.into_tuple(); + let it = el.value(); v.visit_variant(it); - if let Some(p) = p { - tokens_helper(v, &p.spans); - } } } #[cfg(feature = "derive")] @@ -1060,18 +1050,16 @@ pub fn visit_data_struct<'ast, V>(v: &mut V, node: &'ast DataStruct) where V: Visit<'ast> + ?Sized, { - tokens_helper(v, &node.struct_token.span); + skip!(node.struct_token); v.visit_fields(&node.fields); - if let Some(it) = &node.semi_token { - tokens_helper(v, &it.spans); - } + skip!(node.semi_token); } #[cfg(feature = "derive")] pub fn visit_data_union<'ast, V>(v: &mut V, node: &'ast DataUnion) where V: Visit<'ast> + ?Sized, { - tokens_helper(v, &node.union_token.span); + skip!(node.union_token); v.visit_fields_named(&node.fields); } #[cfg(feature = "derive")] @@ -1099,9 +1087,6 @@ where Expr::Assign(_binding_0) => { full!(v.visit_expr_assign(_binding_0)); } - Expr::AssignOp(_binding_0) => { - full!(v.visit_expr_assign_op(_binding_0)); - } Expr::Async(_binding_0) => { full!(v.visit_expr_async(_binding_0)); } @@ -1114,9 +1099,6 @@ where Expr::Block(_binding_0) => { full!(v.visit_expr_block(_binding_0)); } - Expr::Box(_binding_0) => { - full!(v.visit_expr_box(_binding_0)); - } Expr::Break(_binding_0) => { full!(v.visit_expr_break(_binding_0)); } @@ -1129,6 +1111,9 @@ where Expr::Closure(_binding_0) => { full!(v.visit_expr_closure(_binding_0)); } + Expr::Const(_binding_0) => { + full!(v.visit_expr_const(_binding_0)); + } Expr::Continue(_binding_0) => { full!(v.visit_expr_continue(_binding_0)); } @@ -1139,7 +1124,7 @@ where full!(v.visit_expr_for_loop(_binding_0)); } Expr::Group(_binding_0) => { - full!(v.visit_expr_group(_binding_0)); + v.visit_expr_group(_binding_0); } Expr::If(_binding_0) => { full!(v.visit_expr_if(_binding_0)); @@ -1147,6 +1132,9 @@ where Expr::Index(_binding_0) => { v.visit_expr_index(_binding_0); } + Expr::Infer(_binding_0) => { + full!(v.visit_expr_infer(_binding_0)); + } Expr::Let(_binding_0) => { full!(v.visit_expr_let(_binding_0)); } @@ -1157,7 +1145,7 @@ where full!(v.visit_expr_loop(_binding_0)); } Expr::Macro(_binding_0) => { - full!(v.visit_expr_macro(_binding_0)); + v.visit_expr_macro(_binding_0); } Expr::Match(_binding_0) => { full!(v.visit_expr_match(_binding_0)); @@ -1195,9 +1183,6 @@ where Expr::Tuple(_binding_0) => { full!(v.visit_expr_tuple(_binding_0)); } - Expr::Type(_binding_0) => { - full!(v.visit_expr_type(_binding_0)); - } Expr::Unary(_binding_0) => { v.visit_expr_unary(_binding_0); } @@ -1213,8 +1198,6 @@ where Expr::Yield(_binding_0) => { full!(v.visit_expr_yield(_binding_0)); } - #[cfg(syn_no_non_exhaustive)] - _ => unreachable!(), } } #[cfg(feature = "full")] @@ -1225,13 +1208,10 @@ where for it in &node.attrs { v.visit_attribute(it); } - tokens_helper(v, &node.bracket_token.span); + skip!(node.bracket_token); for el in Punctuated::pairs(&node.elems) { - let (it, p) = el.into_tuple(); + let it = el.value(); v.visit_expr(it); - if let Some(p) = p { - tokens_helper(v, &p.spans); - } } } #[cfg(feature = "full")] @@ -1243,19 +1223,7 @@ where v.visit_attribute(it); } v.visit_expr(&*node.left); - tokens_helper(v, &node.eq_token.spans); - v.visit_expr(&*node.right); -} -#[cfg(feature = "full")] -pub fn visit_expr_assign_op<'ast, V>(v: &mut V, node: &'ast ExprAssignOp) -where - V: Visit<'ast> + ?Sized, -{ - for it in &node.attrs { - v.visit_attribute(it); - } - v.visit_expr(&*node.left); - v.visit_bin_op(&node.op); + skip!(node.eq_token); v.visit_expr(&*node.right); } #[cfg(feature = "full")] @@ -1266,10 +1234,8 @@ where for it in &node.attrs { v.visit_attribute(it); } - tokens_helper(v, &node.async_token.span); - if let Some(it) = &node.capture { - tokens_helper(v, &it.span); - } + skip!(node.async_token); + skip!(node.capture); v.visit_block(&node.block); } #[cfg(feature = "full")] @@ -1281,8 +1247,8 @@ where v.visit_attribute(it); } v.visit_expr(&*node.base); - tokens_helper(v, &node.dot_token.spans); - tokens_helper(v, &node.await_token.span); + skip!(node.dot_token); + skip!(node.await_token); } #[cfg(any(feature = "derive", feature = "full"))] pub fn visit_expr_binary<'ast, V>(v: &mut V, node: &'ast ExprBinary) @@ -1310,17 +1276,6 @@ where v.visit_block(&node.block); } #[cfg(feature = "full")] -pub fn visit_expr_box<'ast, V>(v: &mut V, node: &'ast ExprBox) -where - V: Visit<'ast> + ?Sized, -{ - for it in &node.attrs { - v.visit_attribute(it); - } - tokens_helper(v, &node.box_token.span); - v.visit_expr(&*node.expr); -} -#[cfg(feature = "full")] pub fn visit_expr_break<'ast, V>(v: &mut V, node: &'ast ExprBreak) where V: Visit<'ast> + ?Sized, @@ -1328,7 +1283,7 @@ where for it in &node.attrs { v.visit_attribute(it); } - tokens_helper(v, &node.break_token.span); + skip!(node.break_token); if let Some(it) = &node.label { v.visit_lifetime(it); } @@ -1345,13 +1300,10 @@ where v.visit_attribute(it); } v.visit_expr(&*node.func); - tokens_helper(v, &node.paren_token.span); + skip!(node.paren_token); for el in Punctuated::pairs(&node.args) { - let (it, p) = el.into_tuple(); + let it = el.value(); v.visit_expr(it); - if let Some(p) = p { - tokens_helper(v, &p.spans); - } } } #[cfg(any(feature = "derive", feature = "full"))] @@ -1363,7 +1315,7 @@ where v.visit_attribute(it); } v.visit_expr(&*node.expr); - tokens_helper(v, &node.as_token.span); + skip!(node.as_token); v.visit_type(&*node.ty); } #[cfg(feature = "full")] @@ -1374,28 +1326,34 @@ where for it in &node.attrs { v.visit_attribute(it); } - if let Some(it) = &node.movability { - tokens_helper(v, &it.span); - } - if let Some(it) = &node.asyncness { - tokens_helper(v, &it.span); - } - if let Some(it) = &node.capture { - tokens_helper(v, &it.span); + if let Some(it) = &node.lifetimes { + v.visit_bound_lifetimes(it); } - tokens_helper(v, &node.or1_token.spans); + skip!(node.constness); + skip!(node.movability); + skip!(node.asyncness); + skip!(node.capture); + skip!(node.or1_token); for el in Punctuated::pairs(&node.inputs) { - let (it, p) = el.into_tuple(); + let it = el.value(); v.visit_pat(it); - if let Some(p) = p { - tokens_helper(v, &p.spans); - } } - tokens_helper(v, &node.or2_token.spans); + skip!(node.or2_token); v.visit_return_type(&node.output); v.visit_expr(&*node.body); } #[cfg(feature = "full")] +pub fn visit_expr_const<'ast, V>(v: &mut V, node: &'ast ExprConst) +where + V: Visit<'ast> + ?Sized, +{ + for it in &node.attrs { + v.visit_attribute(it); + } + skip!(node.const_token); + v.visit_block(&node.block); +} +#[cfg(feature = "full")] pub fn visit_expr_continue<'ast, V>(v: &mut V, node: &'ast ExprContinue) where V: Visit<'ast> + ?Sized, @@ -1403,7 +1361,7 @@ where for it in &node.attrs { v.visit_attribute(it); } - tokens_helper(v, &node.continue_token.span); + skip!(node.continue_token); if let Some(it) = &node.label { v.visit_lifetime(it); } @@ -1417,7 +1375,7 @@ where v.visit_attribute(it); } v.visit_expr(&*node.base); - tokens_helper(v, &node.dot_token.spans); + skip!(node.dot_token); v.visit_member(&node.member); } #[cfg(feature = "full")] @@ -1431,13 +1389,13 @@ where if let Some(it) = &node.label { v.visit_label(it); } - tokens_helper(v, &node.for_token.span); - v.visit_pat(&node.pat); - tokens_helper(v, &node.in_token.span); + skip!(node.for_token); + v.visit_pat(&*node.pat); + skip!(node.in_token); v.visit_expr(&*node.expr); v.visit_block(&node.body); } -#[cfg(feature = "full")] +#[cfg(any(feature = "derive", feature = "full"))] pub fn visit_expr_group<'ast, V>(v: &mut V, node: &'ast ExprGroup) where V: Visit<'ast> + ?Sized, @@ -1445,7 +1403,7 @@ where for it in &node.attrs { v.visit_attribute(it); } - tokens_helper(v, &node.group_token.span); + skip!(node.group_token); v.visit_expr(&*node.expr); } #[cfg(feature = "full")] @@ -1456,11 +1414,11 @@ where for it in &node.attrs { v.visit_attribute(it); } - tokens_helper(v, &node.if_token.span); + skip!(node.if_token); v.visit_expr(&*node.cond); v.visit_block(&node.then_branch); if let Some(it) = &node.else_branch { - tokens_helper(v, &(it).0.span); + skip!((it).0); v.visit_expr(&*(it).1); } } @@ -1473,10 +1431,20 @@ where v.visit_attribute(it); } v.visit_expr(&*node.expr); - tokens_helper(v, &node.bracket_token.span); + skip!(node.bracket_token); v.visit_expr(&*node.index); } #[cfg(feature = "full")] +pub fn visit_expr_infer<'ast, V>(v: &mut V, node: &'ast ExprInfer) +where + V: Visit<'ast> + ?Sized, +{ + for it in &node.attrs { + v.visit_attribute(it); + } + skip!(node.underscore_token); +} +#[cfg(feature = "full")] pub fn visit_expr_let<'ast, V>(v: &mut V, node: &'ast ExprLet) where V: Visit<'ast> + ?Sized, @@ -1484,9 +1452,9 @@ where for it in &node.attrs { v.visit_attribute(it); } - tokens_helper(v, &node.let_token.span); - v.visit_pat(&node.pat); - tokens_helper(v, &node.eq_token.spans); + skip!(node.let_token); + v.visit_pat(&*node.pat); + skip!(node.eq_token); v.visit_expr(&*node.expr); } #[cfg(any(feature = "derive", feature = "full"))] @@ -1510,10 +1478,10 @@ where if let Some(it) = &node.label { v.visit_label(it); } - tokens_helper(v, &node.loop_token.span); + skip!(node.loop_token); v.visit_block(&node.body); } -#[cfg(feature = "full")] +#[cfg(any(feature = "derive", feature = "full"))] pub fn visit_expr_macro<'ast, V>(v: &mut V, node: &'ast ExprMacro) where V: Visit<'ast> + ?Sized, @@ -1531,9 +1499,9 @@ where for it in &node.attrs { v.visit_attribute(it); } - tokens_helper(v, &node.match_token.span); + skip!(node.match_token); v.visit_expr(&*node.expr); - tokens_helper(v, &node.brace_token.span); + skip!(node.brace_token); for it in &node.arms { v.visit_arm(it); } @@ -1547,18 +1515,15 @@ where v.visit_attribute(it); } v.visit_expr(&*node.receiver); - tokens_helper(v, &node.dot_token.spans); + skip!(node.dot_token); v.visit_ident(&node.method); if let Some(it) = &node.turbofish { - v.visit_method_turbofish(it); + v.visit_angle_bracketed_generic_arguments(it); } - tokens_helper(v, &node.paren_token.span); + skip!(node.paren_token); for el in Punctuated::pairs(&node.args) { - let (it, p) = el.into_tuple(); + let it = el.value(); v.visit_expr(it); - if let Some(p) = p { - tokens_helper(v, &p.spans); - } } } #[cfg(any(feature = "derive", feature = "full"))] @@ -1569,7 +1534,7 @@ where for it in &node.attrs { v.visit_attribute(it); } - tokens_helper(v, &node.paren_token.span); + skip!(node.paren_token); v.visit_expr(&*node.expr); } #[cfg(any(feature = "derive", feature = "full"))] @@ -1593,11 +1558,11 @@ where for it in &node.attrs { v.visit_attribute(it); } - if let Some(it) = &node.from { + if let Some(it) = &node.start { v.visit_expr(&**it); } v.visit_range_limits(&node.limits); - if let Some(it) = &node.to { + if let Some(it) = &node.end { v.visit_expr(&**it); } } @@ -1609,10 +1574,8 @@ where for it in &node.attrs { v.visit_attribute(it); } - tokens_helper(v, &node.and_token.spans); - if let Some(it) = &node.mutability { - tokens_helper(v, &it.span); - } + skip!(node.and_token); + skip!(node.mutability); v.visit_expr(&*node.expr); } #[cfg(feature = "full")] @@ -1623,9 +1586,9 @@ where for it in &node.attrs { v.visit_attribute(it); } - tokens_helper(v, &node.bracket_token.span); + skip!(node.bracket_token); v.visit_expr(&*node.expr); - tokens_helper(v, &node.semi_token.spans); + skip!(node.semi_token); v.visit_expr(&*node.len); } #[cfg(feature = "full")] @@ -1636,7 +1599,7 @@ where for it in &node.attrs { v.visit_attribute(it); } - tokens_helper(v, &node.return_token.span); + skip!(node.return_token); if let Some(it) = &node.expr { v.visit_expr(&**it); } @@ -1649,18 +1612,16 @@ where for it in &node.attrs { v.visit_attribute(it); } + if let Some(it) = &node.qself { + v.visit_qself(it); + } v.visit_path(&node.path); - tokens_helper(v, &node.brace_token.span); + skip!(node.brace_token); for el in Punctuated::pairs(&node.fields) { - let (it, p) = el.into_tuple(); + let it = el.value(); v.visit_field_value(it); - if let Some(p) = p { - tokens_helper(v, &p.spans); - } - } - if let Some(it) = &node.dot2_token { - tokens_helper(v, &it.spans); } + skip!(node.dot2_token); if let Some(it) = &node.rest { v.visit_expr(&**it); } @@ -1674,7 +1635,7 @@ where v.visit_attribute(it); } v.visit_expr(&*node.expr); - tokens_helper(v, &node.question_token.spans); + skip!(node.question_token); } #[cfg(feature = "full")] pub fn visit_expr_try_block<'ast, V>(v: &mut V, node: &'ast ExprTryBlock) @@ -1684,7 +1645,7 @@ where for it in &node.attrs { v.visit_attribute(it); } - tokens_helper(v, &node.try_token.span); + skip!(node.try_token); v.visit_block(&node.block); } #[cfg(feature = "full")] @@ -1695,27 +1656,12 @@ where for it in &node.attrs { v.visit_attribute(it); } - tokens_helper(v, &node.paren_token.span); + skip!(node.paren_token); for el in Punctuated::pairs(&node.elems) { - let (it, p) = el.into_tuple(); + let it = el.value(); v.visit_expr(it); - if let Some(p) = p { - tokens_helper(v, &p.spans); - } } } -#[cfg(feature = "full")] -pub fn visit_expr_type<'ast, V>(v: &mut V, node: &'ast ExprType) -where - V: Visit<'ast> + ?Sized, -{ - for it in &node.attrs { - v.visit_attribute(it); - } - v.visit_expr(&*node.expr); - tokens_helper(v, &node.colon_token.spans); - v.visit_type(&*node.ty); -} #[cfg(any(feature = "derive", feature = "full"))] pub fn visit_expr_unary<'ast, V>(v: &mut V, node: &'ast ExprUnary) where @@ -1735,7 +1681,7 @@ where for it in &node.attrs { v.visit_attribute(it); } - tokens_helper(v, &node.unsafe_token.span); + skip!(node.unsafe_token); v.visit_block(&node.block); } #[cfg(feature = "full")] @@ -1749,7 +1695,7 @@ where if let Some(it) = &node.label { v.visit_label(it); } - tokens_helper(v, &node.while_token.span); + skip!(node.while_token); v.visit_expr(&*node.cond); v.visit_block(&node.body); } @@ -1761,7 +1707,7 @@ where for it in &node.attrs { v.visit_attribute(it); } - tokens_helper(v, &node.yield_token.span); + skip!(node.yield_token); if let Some(it) = &node.expr { v.visit_expr(&**it); } @@ -1775,14 +1721,22 @@ where v.visit_attribute(it); } v.visit_visibility(&node.vis); + v.visit_field_mutability(&node.mutability); if let Some(it) = &node.ident { v.visit_ident(it); } - if let Some(it) = &node.colon_token { - tokens_helper(v, &it.spans); - } + skip!(node.colon_token); v.visit_type(&node.ty); } +#[cfg(any(feature = "derive", feature = "full"))] +pub fn visit_field_mutability<'ast, V>(v: &mut V, node: &'ast FieldMutability) +where + V: Visit<'ast> + ?Sized, +{ + match node { + FieldMutability::None => {} + } +} #[cfg(feature = "full")] pub fn visit_field_pat<'ast, V>(v: &mut V, node: &'ast FieldPat) where @@ -1792,9 +1746,7 @@ where v.visit_attribute(it); } v.visit_member(&node.member); - if let Some(it) = &node.colon_token { - tokens_helper(v, &it.spans); - } + skip!(node.colon_token); v.visit_pat(&*node.pat); } #[cfg(feature = "full")] @@ -1806,9 +1758,7 @@ where v.visit_attribute(it); } v.visit_member(&node.member); - if let Some(it) = &node.colon_token { - tokens_helper(v, &it.spans); - } + skip!(node.colon_token); v.visit_expr(&node.expr); } #[cfg(any(feature = "derive", feature = "full"))] @@ -1831,13 +1781,10 @@ pub fn visit_fields_named<'ast, V>(v: &mut V, node: &'ast FieldsNamed) where V: Visit<'ast> + ?Sized, { - tokens_helper(v, &node.brace_token.span); + skip!(node.brace_token); for el in Punctuated::pairs(&node.named) { - let (it, p) = el.into_tuple(); + let it = el.value(); v.visit_field(it); - if let Some(p) = p { - tokens_helper(v, &p.spans); - } } } #[cfg(any(feature = "derive", feature = "full"))] @@ -1845,13 +1792,10 @@ pub fn visit_fields_unnamed<'ast, V>(v: &mut V, node: &'ast FieldsUnnamed) where V: Visit<'ast> + ?Sized, { - tokens_helper(v, &node.paren_token.span); + skip!(node.paren_token); for el in Punctuated::pairs(&node.unnamed) { - let (it, p) = el.into_tuple(); + let it = el.value(); v.visit_field(it); - if let Some(p) = p { - tokens_helper(v, &p.spans); - } } } #[cfg(feature = "full")] @@ -1902,8 +1846,6 @@ where ForeignItem::Verbatim(_binding_0) => { skip!(_binding_0); } - #[cfg(syn_no_non_exhaustive)] - _ => unreachable!(), } } #[cfg(feature = "full")] @@ -1916,7 +1858,7 @@ where } v.visit_visibility(&node.vis); v.visit_signature(&node.sig); - tokens_helper(v, &node.semi_token.spans); + skip!(node.semi_token); } #[cfg(feature = "full")] pub fn visit_foreign_item_macro<'ast, V>(v: &mut V, node: &'ast ForeignItemMacro) @@ -1927,9 +1869,7 @@ where v.visit_attribute(it); } v.visit_macro(&node.mac); - if let Some(it) = &node.semi_token { - tokens_helper(v, &it.spans); - } + skip!(node.semi_token); } #[cfg(feature = "full")] pub fn visit_foreign_item_static<'ast, V>(v: &mut V, node: &'ast ForeignItemStatic) @@ -1940,14 +1880,12 @@ where v.visit_attribute(it); } v.visit_visibility(&node.vis); - tokens_helper(v, &node.static_token.span); - if let Some(it) = &node.mutability { - tokens_helper(v, &it.span); - } + skip!(node.static_token); + v.visit_static_mutability(&node.mutability); v.visit_ident(&node.ident); - tokens_helper(v, &node.colon_token.spans); + skip!(node.colon_token); v.visit_type(&*node.ty); - tokens_helper(v, &node.semi_token.spans); + skip!(node.semi_token); } #[cfg(feature = "full")] pub fn visit_foreign_item_type<'ast, V>(v: &mut V, node: &'ast ForeignItemType) @@ -1958,9 +1896,10 @@ where v.visit_attribute(it); } v.visit_visibility(&node.vis); - tokens_helper(v, &node.type_token.span); + skip!(node.type_token); v.visit_ident(&node.ident); - tokens_helper(v, &node.semi_token.spans); + v.visit_generics(&node.generics); + skip!(node.semi_token); } #[cfg(any(feature = "derive", feature = "full"))] pub fn visit_generic_argument<'ast, V>(v: &mut V, node: &'ast GenericArgument) @@ -1977,43 +1916,29 @@ where GenericArgument::Const(_binding_0) => { v.visit_expr(_binding_0); } - GenericArgument::Binding(_binding_0) => { - v.visit_binding(_binding_0); + GenericArgument::AssocType(_binding_0) => { + v.visit_assoc_type(_binding_0); + } + GenericArgument::AssocConst(_binding_0) => { + v.visit_assoc_const(_binding_0); } GenericArgument::Constraint(_binding_0) => { v.visit_constraint(_binding_0); } } } -#[cfg(feature = "full")] -pub fn visit_generic_method_argument<'ast, V>( - v: &mut V, - node: &'ast GenericMethodArgument, -) -where - V: Visit<'ast> + ?Sized, -{ - match node { - GenericMethodArgument::Type(_binding_0) => { - v.visit_type(_binding_0); - } - GenericMethodArgument::Const(_binding_0) => { - v.visit_expr(_binding_0); - } - } -} #[cfg(any(feature = "derive", feature = "full"))] pub fn visit_generic_param<'ast, V>(v: &mut V, node: &'ast GenericParam) where V: Visit<'ast> + ?Sized, { match node { + GenericParam::Lifetime(_binding_0) => { + v.visit_lifetime_param(_binding_0); + } GenericParam::Type(_binding_0) => { v.visit_type_param(_binding_0); } - GenericParam::Lifetime(_binding_0) => { - v.visit_lifetime_def(_binding_0); - } GenericParam::Const(_binding_0) => { v.visit_const_param(_binding_0); } @@ -2024,19 +1949,12 @@ pub fn visit_generics<'ast, V>(v: &mut V, node: &'ast Generics) where V: Visit<'ast> + ?Sized, { - if let Some(it) = &node.lt_token { - tokens_helper(v, &it.spans); - } + skip!(node.lt_token); for el in Punctuated::pairs(&node.params) { - let (it, p) = el.into_tuple(); + let it = el.value(); v.visit_generic_param(it); - if let Some(p) = p { - tokens_helper(v, &p.spans); - } - } - if let Some(it) = &node.gt_token { - tokens_helper(v, &it.spans); } + skip!(node.gt_token); if let Some(it) = &node.where_clause { v.visit_where_clause(it); } @@ -2056,8 +1974,8 @@ where ImplItem::Const(_binding_0) => { v.visit_impl_item_const(_binding_0); } - ImplItem::Method(_binding_0) => { - v.visit_impl_item_method(_binding_0); + ImplItem::Fn(_binding_0) => { + v.visit_impl_item_fn(_binding_0); } ImplItem::Type(_binding_0) => { v.visit_impl_item_type(_binding_0); @@ -2068,8 +1986,6 @@ where ImplItem::Verbatim(_binding_0) => { skip!(_binding_0); } - #[cfg(syn_no_non_exhaustive)] - _ => unreachable!(), } } #[cfg(feature = "full")] @@ -2081,44 +1997,39 @@ where v.visit_attribute(it); } v.visit_visibility(&node.vis); - if let Some(it) = &node.defaultness { - tokens_helper(v, &it.span); - } - tokens_helper(v, &node.const_token.span); + skip!(node.defaultness); + skip!(node.const_token); v.visit_ident(&node.ident); - tokens_helper(v, &node.colon_token.spans); + v.visit_generics(&node.generics); + skip!(node.colon_token); v.visit_type(&node.ty); - tokens_helper(v, &node.eq_token.spans); + skip!(node.eq_token); v.visit_expr(&node.expr); - tokens_helper(v, &node.semi_token.spans); + skip!(node.semi_token); } #[cfg(feature = "full")] -pub fn visit_impl_item_macro<'ast, V>(v: &mut V, node: &'ast ImplItemMacro) +pub fn visit_impl_item_fn<'ast, V>(v: &mut V, node: &'ast ImplItemFn) where V: Visit<'ast> + ?Sized, { for it in &node.attrs { v.visit_attribute(it); } - v.visit_macro(&node.mac); - if let Some(it) = &node.semi_token { - tokens_helper(v, &it.spans); - } + v.visit_visibility(&node.vis); + skip!(node.defaultness); + v.visit_signature(&node.sig); + v.visit_block(&node.block); } #[cfg(feature = "full")] -pub fn visit_impl_item_method<'ast, V>(v: &mut V, node: &'ast ImplItemMethod) +pub fn visit_impl_item_macro<'ast, V>(v: &mut V, node: &'ast ImplItemMacro) where V: Visit<'ast> + ?Sized, { for it in &node.attrs { v.visit_attribute(it); } - v.visit_visibility(&node.vis); - if let Some(it) = &node.defaultness { - tokens_helper(v, &it.span); - } - v.visit_signature(&node.sig); - v.visit_block(&node.block); + v.visit_macro(&node.mac); + skip!(node.semi_token); } #[cfg(feature = "full")] pub fn visit_impl_item_type<'ast, V>(v: &mut V, node: &'ast ImplItemType) @@ -2129,15 +2040,20 @@ where v.visit_attribute(it); } v.visit_visibility(&node.vis); - if let Some(it) = &node.defaultness { - tokens_helper(v, &it.span); - } - tokens_helper(v, &node.type_token.span); + skip!(node.defaultness); + skip!(node.type_token); v.visit_ident(&node.ident); v.visit_generics(&node.generics); - tokens_helper(v, &node.eq_token.spans); + skip!(node.eq_token); v.visit_type(&node.ty); - tokens_helper(v, &node.semi_token.spans); + skip!(node.semi_token); +} +#[cfg(feature = "full")] +pub fn visit_impl_restriction<'ast, V>(v: &mut V, node: &'ast ImplRestriction) +where + V: Visit<'ast> + ?Sized, +{ + match *node {} } #[cfg(any(feature = "derive", feature = "full"))] pub fn visit_index<'ast, V>(v: &mut V, node: &'ast Index) @@ -2174,9 +2090,6 @@ where Item::Macro(_binding_0) => { v.visit_item_macro(_binding_0); } - Item::Macro2(_binding_0) => { - v.visit_item_macro2(_binding_0); - } Item::Mod(_binding_0) => { v.visit_item_mod(_binding_0); } @@ -2204,8 +2117,6 @@ where Item::Verbatim(_binding_0) => { skip!(_binding_0); } - #[cfg(syn_no_non_exhaustive)] - _ => unreachable!(), } } #[cfg(feature = "full")] @@ -2217,13 +2128,14 @@ where v.visit_attribute(it); } v.visit_visibility(&node.vis); - tokens_helper(v, &node.const_token.span); + skip!(node.const_token); v.visit_ident(&node.ident); - tokens_helper(v, &node.colon_token.spans); + v.visit_generics(&node.generics); + skip!(node.colon_token); v.visit_type(&*node.ty); - tokens_helper(v, &node.eq_token.spans); + skip!(node.eq_token); v.visit_expr(&*node.expr); - tokens_helper(v, &node.semi_token.spans); + skip!(node.semi_token); } #[cfg(feature = "full")] pub fn visit_item_enum<'ast, V>(v: &mut V, node: &'ast ItemEnum) @@ -2234,16 +2146,13 @@ where v.visit_attribute(it); } v.visit_visibility(&node.vis); - tokens_helper(v, &node.enum_token.span); + skip!(node.enum_token); v.visit_ident(&node.ident); v.visit_generics(&node.generics); - tokens_helper(v, &node.brace_token.span); + skip!(node.brace_token); for el in Punctuated::pairs(&node.variants) { - let (it, p) = el.into_tuple(); + let it = el.value(); v.visit_variant(it); - if let Some(p) = p { - tokens_helper(v, &p.spans); - } } } #[cfg(feature = "full")] @@ -2255,14 +2164,14 @@ where v.visit_attribute(it); } v.visit_visibility(&node.vis); - tokens_helper(v, &node.extern_token.span); - tokens_helper(v, &node.crate_token.span); + skip!(node.extern_token); + skip!(node.crate_token); v.visit_ident(&node.ident); if let Some(it) = &node.rename { - tokens_helper(v, &(it).0.span); + skip!((it).0); v.visit_ident(&(it).1); } - tokens_helper(v, &node.semi_token.spans); + skip!(node.semi_token); } #[cfg(feature = "full")] pub fn visit_item_fn<'ast, V>(v: &mut V, node: &'ast ItemFn) @@ -2284,8 +2193,9 @@ where for it in &node.attrs { v.visit_attribute(it); } + skip!(node.unsafety); v.visit_abi(&node.abi); - tokens_helper(v, &node.brace_token.span); + skip!(node.brace_token); for it in &node.items { v.visit_foreign_item(it); } @@ -2298,23 +2208,17 @@ where for it in &node.attrs { v.visit_attribute(it); } - if let Some(it) = &node.defaultness { - tokens_helper(v, &it.span); - } - if let Some(it) = &node.unsafety { - tokens_helper(v, &it.span); - } - tokens_helper(v, &node.impl_token.span); + skip!(node.defaultness); + skip!(node.unsafety); + skip!(node.impl_token); v.visit_generics(&node.generics); if let Some(it) = &node.trait_ { - if let Some(it) = &(it).0 { - tokens_helper(v, &it.spans); - } + skip!((it).0); v.visit_path(&(it).1); - tokens_helper(v, &(it).2.span); + skip!((it).2); } v.visit_type(&*node.self_ty); - tokens_helper(v, &node.brace_token.span); + skip!(node.brace_token); for it in &node.items { v.visit_impl_item(it); } @@ -2331,22 +2235,7 @@ where v.visit_ident(it); } v.visit_macro(&node.mac); - if let Some(it) = &node.semi_token { - tokens_helper(v, &it.spans); - } -} -#[cfg(feature = "full")] -pub fn visit_item_macro2<'ast, V>(v: &mut V, node: &'ast ItemMacro2) -where - V: Visit<'ast> + ?Sized, -{ - for it in &node.attrs { - v.visit_attribute(it); - } - v.visit_visibility(&node.vis); - tokens_helper(v, &node.macro_token.span); - v.visit_ident(&node.ident); - skip!(node.rules); + skip!(node.semi_token); } #[cfg(feature = "full")] pub fn visit_item_mod<'ast, V>(v: &mut V, node: &'ast ItemMod) @@ -2357,17 +2246,16 @@ where v.visit_attribute(it); } v.visit_visibility(&node.vis); - tokens_helper(v, &node.mod_token.span); + skip!(node.unsafety); + skip!(node.mod_token); v.visit_ident(&node.ident); if let Some(it) = &node.content { - tokens_helper(v, &(it).0.span); + skip!((it).0); for it in &(it).1 { v.visit_item(it); } } - if let Some(it) = &node.semi { - tokens_helper(v, &it.spans); - } + skip!(node.semi); } #[cfg(feature = "full")] pub fn visit_item_static<'ast, V>(v: &mut V, node: &'ast ItemStatic) @@ -2378,16 +2266,14 @@ where v.visit_attribute(it); } v.visit_visibility(&node.vis); - tokens_helper(v, &node.static_token.span); - if let Some(it) = &node.mutability { - tokens_helper(v, &it.span); - } + skip!(node.static_token); + v.visit_static_mutability(&node.mutability); v.visit_ident(&node.ident); - tokens_helper(v, &node.colon_token.spans); + skip!(node.colon_token); v.visit_type(&*node.ty); - tokens_helper(v, &node.eq_token.spans); + skip!(node.eq_token); v.visit_expr(&*node.expr); - tokens_helper(v, &node.semi_token.spans); + skip!(node.semi_token); } #[cfg(feature = "full")] pub fn visit_item_struct<'ast, V>(v: &mut V, node: &'ast ItemStruct) @@ -2398,13 +2284,11 @@ where v.visit_attribute(it); } v.visit_visibility(&node.vis); - tokens_helper(v, &node.struct_token.span); + skip!(node.struct_token); v.visit_ident(&node.ident); v.visit_generics(&node.generics); v.visit_fields(&node.fields); - if let Some(it) = &node.semi_token { - tokens_helper(v, &it.spans); - } + skip!(node.semi_token); } #[cfg(feature = "full")] pub fn visit_item_trait<'ast, V>(v: &mut V, node: &'ast ItemTrait) @@ -2415,26 +2299,20 @@ where v.visit_attribute(it); } v.visit_visibility(&node.vis); - if let Some(it) = &node.unsafety { - tokens_helper(v, &it.span); + skip!(node.unsafety); + skip!(node.auto_token); + if let Some(it) = &node.restriction { + v.visit_impl_restriction(it); } - if let Some(it) = &node.auto_token { - tokens_helper(v, &it.span); - } - tokens_helper(v, &node.trait_token.span); + skip!(node.trait_token); v.visit_ident(&node.ident); v.visit_generics(&node.generics); - if let Some(it) = &node.colon_token { - tokens_helper(v, &it.spans); - } + skip!(node.colon_token); for el in Punctuated::pairs(&node.supertraits) { - let (it, p) = el.into_tuple(); + let it = el.value(); v.visit_type_param_bound(it); - if let Some(p) = p { - tokens_helper(v, &p.spans); - } } - tokens_helper(v, &node.brace_token.span); + skip!(node.brace_token); for it in &node.items { v.visit_trait_item(it); } @@ -2448,18 +2326,15 @@ where v.visit_attribute(it); } v.visit_visibility(&node.vis); - tokens_helper(v, &node.trait_token.span); + skip!(node.trait_token); v.visit_ident(&node.ident); v.visit_generics(&node.generics); - tokens_helper(v, &node.eq_token.spans); + skip!(node.eq_token); for el in Punctuated::pairs(&node.bounds) { - let (it, p) = el.into_tuple(); + let it = el.value(); v.visit_type_param_bound(it); - if let Some(p) = p { - tokens_helper(v, &p.spans); - } } - tokens_helper(v, &node.semi_token.spans); + skip!(node.semi_token); } #[cfg(feature = "full")] pub fn visit_item_type<'ast, V>(v: &mut V, node: &'ast ItemType) @@ -2470,12 +2345,12 @@ where v.visit_attribute(it); } v.visit_visibility(&node.vis); - tokens_helper(v, &node.type_token.span); + skip!(node.type_token); v.visit_ident(&node.ident); v.visit_generics(&node.generics); - tokens_helper(v, &node.eq_token.spans); + skip!(node.eq_token); v.visit_type(&*node.ty); - tokens_helper(v, &node.semi_token.spans); + skip!(node.semi_token); } #[cfg(feature = "full")] pub fn visit_item_union<'ast, V>(v: &mut V, node: &'ast ItemUnion) @@ -2486,7 +2361,7 @@ where v.visit_attribute(it); } v.visit_visibility(&node.vis); - tokens_helper(v, &node.union_token.span); + skip!(node.union_token); v.visit_ident(&node.ident); v.visit_generics(&node.generics); v.visit_fields_named(&node.fields); @@ -2500,12 +2375,10 @@ where v.visit_attribute(it); } v.visit_visibility(&node.vis); - tokens_helper(v, &node.use_token.span); - if let Some(it) = &node.leading_colon { - tokens_helper(v, &it.spans); - } + skip!(node.use_token); + skip!(node.leading_colon); v.visit_use_tree(&node.tree); - tokens_helper(v, &node.semi_token.spans); + skip!(node.semi_token); } #[cfg(feature = "full")] pub fn visit_label<'ast, V>(v: &mut V, node: &'ast Label) @@ -2513,7 +2386,7 @@ where V: Visit<'ast> + ?Sized, { v.visit_lifetime(&node.name); - tokens_helper(v, &node.colon_token.spans); + skip!(node.colon_token); } pub fn visit_lifetime<'ast, V>(v: &mut V, node: &'ast Lifetime) where @@ -2523,7 +2396,7 @@ where v.visit_ident(&node.ident); } #[cfg(any(feature = "derive", feature = "full"))] -pub fn visit_lifetime_def<'ast, V>(v: &mut V, node: &'ast LifetimeDef) +pub fn visit_lifetime_param<'ast, V>(v: &mut V, node: &'ast LifetimeParam) where V: Visit<'ast> + ?Sized, { @@ -2531,15 +2404,10 @@ where v.visit_attribute(it); } v.visit_lifetime(&node.lifetime); - if let Some(it) = &node.colon_token { - tokens_helper(v, &it.spans); - } + skip!(node.colon_token); for el in Punctuated::pairs(&node.bounds) { - let (it, p) = el.into_tuple(); + let it = el.value(); v.visit_lifetime(it); - if let Some(p) = p { - tokens_helper(v, &p.spans); - } } } pub fn visit_lit<'ast, V>(v: &mut V, node: &'ast Lit) @@ -2612,13 +2480,24 @@ where for it in &node.attrs { v.visit_attribute(it); } - tokens_helper(v, &node.let_token.span); + skip!(node.let_token); v.visit_pat(&node.pat); if let Some(it) = &node.init { - tokens_helper(v, &(it).0.spans); + v.visit_local_init(it); + } + skip!(node.semi_token); +} +#[cfg(feature = "full")] +pub fn visit_local_init<'ast, V>(v: &mut V, node: &'ast LocalInit) +where + V: Visit<'ast> + ?Sized, +{ + skip!(node.eq_token); + v.visit_expr(&*node.expr); + if let Some(it) = &node.diverge { + skip!((it).0); v.visit_expr(&*(it).1); } - tokens_helper(v, &node.semi_token.spans); } #[cfg(any(feature = "derive", feature = "full"))] pub fn visit_macro<'ast, V>(v: &mut V, node: &'ast Macro) @@ -2626,7 +2505,7 @@ where V: Visit<'ast> + ?Sized, { v.visit_path(&node.path); - tokens_helper(v, &node.bang_token.spans); + skip!(node.bang_token); v.visit_macro_delimiter(&node.delimiter); skip!(node.tokens); } @@ -2637,13 +2516,13 @@ where { match node { MacroDelimiter::Paren(_binding_0) => { - tokens_helper(v, &_binding_0.span); + skip!(_binding_0); } MacroDelimiter::Brace(_binding_0) => { - tokens_helper(v, &_binding_0.span); + skip!(_binding_0); } MacroDelimiter::Bracket(_binding_0) => { - tokens_helper(v, &_binding_0.span); + skip!(_binding_0); } } } @@ -2684,14 +2563,8 @@ where V: Visit<'ast> + ?Sized, { v.visit_path(&node.path); - tokens_helper(v, &node.paren_token.span); - for el in Punctuated::pairs(&node.nested) { - let (it, p) = el.into_tuple(); - v.visit_nested_meta(it); - if let Some(p) = p { - tokens_helper(v, &p.spans); - } - } + v.visit_macro_delimiter(&node.delimiter); + skip!(node.tokens); } #[cfg(any(feature = "derive", feature = "full"))] pub fn visit_meta_name_value<'ast, V>(v: &mut V, node: &'ast MetaNameValue) @@ -2699,38 +2572,8 @@ where V: Visit<'ast> + ?Sized, { v.visit_path(&node.path); - tokens_helper(v, &node.eq_token.spans); - v.visit_lit(&node.lit); -} -#[cfg(feature = "full")] -pub fn visit_method_turbofish<'ast, V>(v: &mut V, node: &'ast MethodTurbofish) -where - V: Visit<'ast> + ?Sized, -{ - tokens_helper(v, &node.colon2_token.spans); - tokens_helper(v, &node.lt_token.spans); - for el in Punctuated::pairs(&node.args) { - let (it, p) = el.into_tuple(); - v.visit_generic_method_argument(it); - if let Some(p) = p { - tokens_helper(v, &p.spans); - } - } - tokens_helper(v, &node.gt_token.spans); -} -#[cfg(any(feature = "derive", feature = "full"))] -pub fn visit_nested_meta<'ast, V>(v: &mut V, node: &'ast NestedMeta) -where - V: Visit<'ast> + ?Sized, -{ - match node { - NestedMeta::Meta(_binding_0) => { - v.visit_meta(_binding_0); - } - NestedMeta::Lit(_binding_0) => { - v.visit_lit(_binding_0); - } - } + skip!(node.eq_token); + v.visit_expr(&node.value); } #[cfg(any(feature = "derive", feature = "full"))] pub fn visit_parenthesized_generic_arguments<'ast, V>( @@ -2740,13 +2583,10 @@ pub fn visit_parenthesized_generic_arguments<'ast, V>( where V: Visit<'ast> + ?Sized, { - tokens_helper(v, &node.paren_token.span); + skip!(node.paren_token); for el in Punctuated::pairs(&node.inputs) { - let (it, p) = el.into_tuple(); + let it = el.value(); v.visit_type(it); - if let Some(p) = p { - tokens_helper(v, &p.spans); - } } v.visit_return_type(&node.output); } @@ -2756,26 +2596,29 @@ where V: Visit<'ast> + ?Sized, { match node { - Pat::Box(_binding_0) => { - v.visit_pat_box(_binding_0); + Pat::Const(_binding_0) => { + v.visit_expr_const(_binding_0); } Pat::Ident(_binding_0) => { v.visit_pat_ident(_binding_0); } Pat::Lit(_binding_0) => { - v.visit_pat_lit(_binding_0); + v.visit_expr_lit(_binding_0); } Pat::Macro(_binding_0) => { - v.visit_pat_macro(_binding_0); + v.visit_expr_macro(_binding_0); } Pat::Or(_binding_0) => { v.visit_pat_or(_binding_0); } + Pat::Paren(_binding_0) => { + v.visit_pat_paren(_binding_0); + } Pat::Path(_binding_0) => { - v.visit_pat_path(_binding_0); + v.visit_expr_path(_binding_0); } Pat::Range(_binding_0) => { - v.visit_pat_range(_binding_0); + v.visit_expr_range(_binding_0); } Pat::Reference(_binding_0) => { v.visit_pat_reference(_binding_0); @@ -2804,22 +2647,9 @@ where Pat::Wild(_binding_0) => { v.visit_pat_wild(_binding_0); } - #[cfg(syn_no_non_exhaustive)] - _ => unreachable!(), } } #[cfg(feature = "full")] -pub fn visit_pat_box<'ast, V>(v: &mut V, node: &'ast PatBox) -where - V: Visit<'ast> + ?Sized, -{ - for it in &node.attrs { - v.visit_attribute(it); - } - tokens_helper(v, &node.box_token.span); - v.visit_pat(&*node.pat); -} -#[cfg(feature = "full")] pub fn visit_pat_ident<'ast, V>(v: &mut V, node: &'ast PatIdent) where V: Visit<'ast> + ?Sized, @@ -2827,39 +2657,15 @@ where for it in &node.attrs { v.visit_attribute(it); } - if let Some(it) = &node.by_ref { - tokens_helper(v, &it.span); - } - if let Some(it) = &node.mutability { - tokens_helper(v, &it.span); - } + skip!(node.by_ref); + skip!(node.mutability); v.visit_ident(&node.ident); if let Some(it) = &node.subpat { - tokens_helper(v, &(it).0.spans); + skip!((it).0); v.visit_pat(&*(it).1); } } #[cfg(feature = "full")] -pub fn visit_pat_lit<'ast, V>(v: &mut V, node: &'ast PatLit) -where - V: Visit<'ast> + ?Sized, -{ - for it in &node.attrs { - v.visit_attribute(it); - } - v.visit_expr(&*node.expr); -} -#[cfg(feature = "full")] -pub fn visit_pat_macro<'ast, V>(v: &mut V, node: &'ast PatMacro) -where - V: Visit<'ast> + ?Sized, -{ - for it in &node.attrs { - v.visit_attribute(it); - } - v.visit_macro(&node.mac); -} -#[cfg(feature = "full")] pub fn visit_pat_or<'ast, V>(v: &mut V, node: &'ast PatOr) where V: Visit<'ast> + ?Sized, @@ -2867,41 +2673,22 @@ where for it in &node.attrs { v.visit_attribute(it); } - if let Some(it) = &node.leading_vert { - tokens_helper(v, &it.spans); - } + skip!(node.leading_vert); for el in Punctuated::pairs(&node.cases) { - let (it, p) = el.into_tuple(); + let it = el.value(); v.visit_pat(it); - if let Some(p) = p { - tokens_helper(v, &p.spans); - } - } -} -#[cfg(feature = "full")] -pub fn visit_pat_path<'ast, V>(v: &mut V, node: &'ast PatPath) -where - V: Visit<'ast> + ?Sized, -{ - for it in &node.attrs { - v.visit_attribute(it); - } - if let Some(it) = &node.qself { - v.visit_qself(it); } - v.visit_path(&node.path); } #[cfg(feature = "full")] -pub fn visit_pat_range<'ast, V>(v: &mut V, node: &'ast PatRange) +pub fn visit_pat_paren<'ast, V>(v: &mut V, node: &'ast PatParen) where V: Visit<'ast> + ?Sized, { for it in &node.attrs { v.visit_attribute(it); } - v.visit_expr(&*node.lo); - v.visit_range_limits(&node.limits); - v.visit_expr(&*node.hi); + skip!(node.paren_token); + v.visit_pat(&*node.pat); } #[cfg(feature = "full")] pub fn visit_pat_reference<'ast, V>(v: &mut V, node: &'ast PatReference) @@ -2911,10 +2698,8 @@ where for it in &node.attrs { v.visit_attribute(it); } - tokens_helper(v, &node.and_token.spans); - if let Some(it) = &node.mutability { - tokens_helper(v, &it.span); - } + skip!(node.and_token); + skip!(node.mutability); v.visit_pat(&*node.pat); } #[cfg(feature = "full")] @@ -2925,7 +2710,7 @@ where for it in &node.attrs { v.visit_attribute(it); } - tokens_helper(v, &node.dot2_token.spans); + skip!(node.dot2_token); } #[cfg(feature = "full")] pub fn visit_pat_slice<'ast, V>(v: &mut V, node: &'ast PatSlice) @@ -2935,13 +2720,10 @@ where for it in &node.attrs { v.visit_attribute(it); } - tokens_helper(v, &node.bracket_token.span); + skip!(node.bracket_token); for el in Punctuated::pairs(&node.elems) { - let (it, p) = el.into_tuple(); + let it = el.value(); v.visit_pat(it); - if let Some(p) = p { - tokens_helper(v, &p.spans); - } } } #[cfg(feature = "full")] @@ -2952,17 +2734,17 @@ where for it in &node.attrs { v.visit_attribute(it); } + if let Some(it) = &node.qself { + v.visit_qself(it); + } v.visit_path(&node.path); - tokens_helper(v, &node.brace_token.span); + skip!(node.brace_token); for el in Punctuated::pairs(&node.fields) { - let (it, p) = el.into_tuple(); + let it = el.value(); v.visit_field_pat(it); - if let Some(p) = p { - tokens_helper(v, &p.spans); - } } - if let Some(it) = &node.dot2_token { - tokens_helper(v, &it.spans); + if let Some(it) = &node.rest { + v.visit_pat_rest(it); } } #[cfg(feature = "full")] @@ -2973,13 +2755,10 @@ where for it in &node.attrs { v.visit_attribute(it); } - tokens_helper(v, &node.paren_token.span); + skip!(node.paren_token); for el in Punctuated::pairs(&node.elems) { - let (it, p) = el.into_tuple(); + let it = el.value(); v.visit_pat(it); - if let Some(p) = p { - tokens_helper(v, &p.spans); - } } } #[cfg(feature = "full")] @@ -2990,8 +2769,15 @@ where for it in &node.attrs { v.visit_attribute(it); } + if let Some(it) = &node.qself { + v.visit_qself(it); + } v.visit_path(&node.path); - v.visit_pat_tuple(&node.pat); + skip!(node.paren_token); + for el in Punctuated::pairs(&node.elems) { + let it = el.value(); + v.visit_pat(it); + } } #[cfg(feature = "full")] pub fn visit_pat_type<'ast, V>(v: &mut V, node: &'ast PatType) @@ -3002,7 +2788,7 @@ where v.visit_attribute(it); } v.visit_pat(&*node.pat); - tokens_helper(v, &node.colon_token.spans); + skip!(node.colon_token); v.visit_type(&*node.ty); } #[cfg(feature = "full")] @@ -3013,22 +2799,17 @@ where for it in &node.attrs { v.visit_attribute(it); } - tokens_helper(v, &node.underscore_token.spans); + skip!(node.underscore_token); } #[cfg(any(feature = "derive", feature = "full"))] pub fn visit_path<'ast, V>(v: &mut V, node: &'ast Path) where V: Visit<'ast> + ?Sized, { - if let Some(it) = &node.leading_colon { - tokens_helper(v, &it.spans); - } + skip!(node.leading_colon); for el in Punctuated::pairs(&node.segments) { - let (it, p) = el.into_tuple(); + let it = el.value(); v.visit_path_segment(it); - if let Some(p) = p { - tokens_helper(v, &p.spans); - } } } #[cfg(any(feature = "derive", feature = "full"))] @@ -3055,27 +2836,15 @@ where v.visit_path_arguments(&node.arguments); } #[cfg(any(feature = "derive", feature = "full"))] -pub fn visit_predicate_eq<'ast, V>(v: &mut V, node: &'ast PredicateEq) -where - V: Visit<'ast> + ?Sized, -{ - v.visit_type(&node.lhs_ty); - tokens_helper(v, &node.eq_token.spans); - v.visit_type(&node.rhs_ty); -} -#[cfg(any(feature = "derive", feature = "full"))] pub fn visit_predicate_lifetime<'ast, V>(v: &mut V, node: &'ast PredicateLifetime) where V: Visit<'ast> + ?Sized, { v.visit_lifetime(&node.lifetime); - tokens_helper(v, &node.colon_token.spans); + skip!(node.colon_token); for el in Punctuated::pairs(&node.bounds) { - let (it, p) = el.into_tuple(); + let it = el.value(); v.visit_lifetime(it); - if let Some(p) = p { - tokens_helper(v, &p.spans); - } } } #[cfg(any(feature = "derive", feature = "full"))] @@ -3087,13 +2856,10 @@ where v.visit_bound_lifetimes(it); } v.visit_type(&node.bounded_ty); - tokens_helper(v, &node.colon_token.spans); + skip!(node.colon_token); for el in Punctuated::pairs(&node.bounds) { - let (it, p) = el.into_tuple(); + let it = el.value(); v.visit_type_param_bound(it); - if let Some(p) = p { - tokens_helper(v, &p.spans); - } } } #[cfg(any(feature = "derive", feature = "full"))] @@ -3101,13 +2867,11 @@ pub fn visit_qself<'ast, V>(v: &mut V, node: &'ast QSelf) where V: Visit<'ast> + ?Sized, { - tokens_helper(v, &node.lt_token.spans); + skip!(node.lt_token); v.visit_type(&*node.ty); skip!(node.position); - if let Some(it) = &node.as_token { - tokens_helper(v, &it.span); - } - tokens_helper(v, &node.gt_token.spans); + skip!(node.as_token); + skip!(node.gt_token); } #[cfg(feature = "full")] pub fn visit_range_limits<'ast, V>(v: &mut V, node: &'ast RangeLimits) @@ -3116,10 +2880,10 @@ where { match node { RangeLimits::HalfOpen(_binding_0) => { - tokens_helper(v, &_binding_0.spans); + skip!(_binding_0); } RangeLimits::Closed(_binding_0) => { - tokens_helper(v, &_binding_0.spans); + skip!(_binding_0); } } } @@ -3132,15 +2896,15 @@ where v.visit_attribute(it); } if let Some(it) = &node.reference { - tokens_helper(v, &(it).0.spans); + skip!((it).0); if let Some(it) = &(it).1 { v.visit_lifetime(it); } } - if let Some(it) = &node.mutability { - tokens_helper(v, &it.span); - } - tokens_helper(v, &node.self_token.span); + skip!(node.mutability); + skip!(node.self_token); + skip!(node.colon_token); + v.visit_type(&*node.ty); } #[cfg(any(feature = "derive", feature = "full"))] pub fn visit_return_type<'ast, V>(v: &mut V, node: &'ast ReturnType) @@ -3150,7 +2914,7 @@ where match node { ReturnType::Default => {} ReturnType::Type(_binding_0, _binding_1) => { - tokens_helper(v, &_binding_0.spans); + skip!(_binding_0); v.visit_type(&**_binding_1); } } @@ -3160,28 +2924,19 @@ pub fn visit_signature<'ast, V>(v: &mut V, node: &'ast Signature) where V: Visit<'ast> + ?Sized, { - if let Some(it) = &node.constness { - tokens_helper(v, &it.span); - } - if let Some(it) = &node.asyncness { - tokens_helper(v, &it.span); - } - if let Some(it) = &node.unsafety { - tokens_helper(v, &it.span); - } + skip!(node.constness); + skip!(node.asyncness); + skip!(node.unsafety); if let Some(it) = &node.abi { v.visit_abi(it); } - tokens_helper(v, &node.fn_token.span); + skip!(node.fn_token); v.visit_ident(&node.ident); v.visit_generics(&node.generics); - tokens_helper(v, &node.paren_token.span); + skip!(node.paren_token); for el in Punctuated::pairs(&node.inputs) { - let (it, p) = el.into_tuple(); + let it = el.value(); v.visit_fn_arg(it); - if let Some(p) = p { - tokens_helper(v, &p.spans); - } } if let Some(it) = &node.variadic { v.visit_variadic(it); @@ -3193,6 +2948,18 @@ where V: Visit<'ast> + ?Sized, {} #[cfg(feature = "full")] +pub fn visit_static_mutability<'ast, V>(v: &mut V, node: &'ast StaticMutability) +where + V: Visit<'ast> + ?Sized, +{ + match node { + StaticMutability::Mut(_binding_0) => { + skip!(_binding_0); + } + StaticMutability::None => {} + } +} +#[cfg(feature = "full")] pub fn visit_stmt<'ast, V>(v: &mut V, node: &'ast Stmt) where V: Visit<'ast> + ?Sized, @@ -3204,23 +2971,32 @@ where Stmt::Item(_binding_0) => { v.visit_item(_binding_0); } - Stmt::Expr(_binding_0) => { + Stmt::Expr(_binding_0, _binding_1) => { v.visit_expr(_binding_0); + skip!(_binding_1); } - Stmt::Semi(_binding_0, _binding_1) => { - v.visit_expr(_binding_0); - tokens_helper(v, &_binding_1.spans); + Stmt::Macro(_binding_0) => { + v.visit_stmt_macro(_binding_0); } } } +#[cfg(feature = "full")] +pub fn visit_stmt_macro<'ast, V>(v: &mut V, node: &'ast StmtMacro) +where + V: Visit<'ast> + ?Sized, +{ + for it in &node.attrs { + v.visit_attribute(it); + } + v.visit_macro(&node.mac); + skip!(node.semi_token); +} #[cfg(any(feature = "derive", feature = "full"))] pub fn visit_trait_bound<'ast, V>(v: &mut V, node: &'ast TraitBound) where V: Visit<'ast> + ?Sized, { - if let Some(it) = &node.paren_token { - tokens_helper(v, &it.span); - } + skip!(node.paren_token); v.visit_trait_bound_modifier(&node.modifier); if let Some(it) = &node.lifetimes { v.visit_bound_lifetimes(it); @@ -3235,7 +3011,7 @@ where match node { TraitBoundModifier::None => {} TraitBoundModifier::Maybe(_binding_0) => { - tokens_helper(v, &_binding_0.spans); + skip!(_binding_0); } } } @@ -3248,8 +3024,8 @@ where TraitItem::Const(_binding_0) => { v.visit_trait_item_const(_binding_0); } - TraitItem::Method(_binding_0) => { - v.visit_trait_item_method(_binding_0); + TraitItem::Fn(_binding_0) => { + v.visit_trait_item_fn(_binding_0); } TraitItem::Type(_binding_0) => { v.visit_trait_item_type(_binding_0); @@ -3260,8 +3036,6 @@ where TraitItem::Verbatim(_binding_0) => { skip!(_binding_0); } - #[cfg(syn_no_non_exhaustive)] - _ => unreachable!(), } } #[cfg(feature = "full")] @@ -3272,44 +3046,41 @@ where for it in &node.attrs { v.visit_attribute(it); } - tokens_helper(v, &node.const_token.span); + skip!(node.const_token); v.visit_ident(&node.ident); - tokens_helper(v, &node.colon_token.spans); + v.visit_generics(&node.generics); + skip!(node.colon_token); v.visit_type(&node.ty); if let Some(it) = &node.default { - tokens_helper(v, &(it).0.spans); + skip!((it).0); v.visit_expr(&(it).1); } - tokens_helper(v, &node.semi_token.spans); + skip!(node.semi_token); } #[cfg(feature = "full")] -pub fn visit_trait_item_macro<'ast, V>(v: &mut V, node: &'ast TraitItemMacro) +pub fn visit_trait_item_fn<'ast, V>(v: &mut V, node: &'ast TraitItemFn) where V: Visit<'ast> + ?Sized, { for it in &node.attrs { v.visit_attribute(it); } - v.visit_macro(&node.mac); - if let Some(it) = &node.semi_token { - tokens_helper(v, &it.spans); + v.visit_signature(&node.sig); + if let Some(it) = &node.default { + v.visit_block(it); } + skip!(node.semi_token); } #[cfg(feature = "full")] -pub fn visit_trait_item_method<'ast, V>(v: &mut V, node: &'ast TraitItemMethod) +pub fn visit_trait_item_macro<'ast, V>(v: &mut V, node: &'ast TraitItemMacro) where V: Visit<'ast> + ?Sized, { for it in &node.attrs { v.visit_attribute(it); } - v.visit_signature(&node.sig); - if let Some(it) = &node.default { - v.visit_block(it); - } - if let Some(it) = &node.semi_token { - tokens_helper(v, &it.spans); - } + v.visit_macro(&node.mac); + skip!(node.semi_token); } #[cfg(feature = "full")] pub fn visit_trait_item_type<'ast, V>(v: &mut V, node: &'ast TraitItemType) @@ -3319,24 +3090,19 @@ where for it in &node.attrs { v.visit_attribute(it); } - tokens_helper(v, &node.type_token.span); + skip!(node.type_token); v.visit_ident(&node.ident); v.visit_generics(&node.generics); - if let Some(it) = &node.colon_token { - tokens_helper(v, &it.spans); - } + skip!(node.colon_token); for el in Punctuated::pairs(&node.bounds) { - let (it, p) = el.into_tuple(); + let it = el.value(); v.visit_type_param_bound(it); - if let Some(p) = p { - tokens_helper(v, &p.spans); - } } if let Some(it) = &node.default { - tokens_helper(v, &(it).0.spans); + skip!((it).0); v.visit_type(&(it).1); } - tokens_helper(v, &node.semi_token.spans); + skip!(node.semi_token); } #[cfg(any(feature = "derive", feature = "full"))] pub fn visit_type<'ast, V>(v: &mut V, node: &'ast Type) @@ -3389,8 +3155,6 @@ where Type::Verbatim(_binding_0) => { skip!(_binding_0); } - #[cfg(syn_no_non_exhaustive)] - _ => unreachable!(), } } #[cfg(any(feature = "derive", feature = "full"))] @@ -3398,9 +3162,9 @@ pub fn visit_type_array<'ast, V>(v: &mut V, node: &'ast TypeArray) where V: Visit<'ast> + ?Sized, { - tokens_helper(v, &node.bracket_token.span); + skip!(node.bracket_token); v.visit_type(&*node.elem); - tokens_helper(v, &node.semi_token.spans); + skip!(node.semi_token); v.visit_expr(&node.len); } #[cfg(any(feature = "derive", feature = "full"))] @@ -3411,23 +3175,18 @@ where if let Some(it) = &node.lifetimes { v.visit_bound_lifetimes(it); } - if let Some(it) = &node.unsafety { - tokens_helper(v, &it.span); - } + skip!(node.unsafety); if let Some(it) = &node.abi { v.visit_abi(it); } - tokens_helper(v, &node.fn_token.span); - tokens_helper(v, &node.paren_token.span); + skip!(node.fn_token); + skip!(node.paren_token); for el in Punctuated::pairs(&node.inputs) { - let (it, p) = el.into_tuple(); + let it = el.value(); v.visit_bare_fn_arg(it); - if let Some(p) = p { - tokens_helper(v, &p.spans); - } } if let Some(it) = &node.variadic { - v.visit_variadic(it); + v.visit_bare_variadic(it); } v.visit_return_type(&node.output); } @@ -3436,7 +3195,7 @@ pub fn visit_type_group<'ast, V>(v: &mut V, node: &'ast TypeGroup) where V: Visit<'ast> + ?Sized, { - tokens_helper(v, &node.group_token.span); + skip!(node.group_token); v.visit_type(&*node.elem); } #[cfg(any(feature = "derive", feature = "full"))] @@ -3444,13 +3203,10 @@ pub fn visit_type_impl_trait<'ast, V>(v: &mut V, node: &'ast TypeImplTrait) where V: Visit<'ast> + ?Sized, { - tokens_helper(v, &node.impl_token.span); + skip!(node.impl_token); for el in Punctuated::pairs(&node.bounds) { - let (it, p) = el.into_tuple(); + let it = el.value(); v.visit_type_param_bound(it); - if let Some(p) = p { - tokens_helper(v, &p.spans); - } } } #[cfg(any(feature = "derive", feature = "full"))] @@ -3458,7 +3214,7 @@ pub fn visit_type_infer<'ast, V>(v: &mut V, node: &'ast TypeInfer) where V: Visit<'ast> + ?Sized, { - tokens_helper(v, &node.underscore_token.spans); + skip!(node.underscore_token); } #[cfg(any(feature = "derive", feature = "full"))] pub fn visit_type_macro<'ast, V>(v: &mut V, node: &'ast TypeMacro) @@ -3472,7 +3228,7 @@ pub fn visit_type_never<'ast, V>(v: &mut V, node: &'ast TypeNever) where V: Visit<'ast> + ?Sized, { - tokens_helper(v, &node.bang_token.spans); + skip!(node.bang_token); } #[cfg(any(feature = "derive", feature = "full"))] pub fn visit_type_param<'ast, V>(v: &mut V, node: &'ast TypeParam) @@ -3483,19 +3239,12 @@ where v.visit_attribute(it); } v.visit_ident(&node.ident); - if let Some(it) = &node.colon_token { - tokens_helper(v, &it.spans); - } + skip!(node.colon_token); for el in Punctuated::pairs(&node.bounds) { - let (it, p) = el.into_tuple(); + let it = el.value(); v.visit_type_param_bound(it); - if let Some(p) = p { - tokens_helper(v, &p.spans); - } - } - if let Some(it) = &node.eq_token { - tokens_helper(v, &it.spans); } + skip!(node.eq_token); if let Some(it) = &node.default { v.visit_type(it); } @@ -3512,6 +3261,9 @@ where TypeParamBound::Lifetime(_binding_0) => { v.visit_lifetime(_binding_0); } + TypeParamBound::Verbatim(_binding_0) => { + skip!(_binding_0); + } } } #[cfg(any(feature = "derive", feature = "full"))] @@ -3519,7 +3271,7 @@ pub fn visit_type_paren<'ast, V>(v: &mut V, node: &'ast TypeParen) where V: Visit<'ast> + ?Sized, { - tokens_helper(v, &node.paren_token.span); + skip!(node.paren_token); v.visit_type(&*node.elem); } #[cfg(any(feature = "derive", feature = "full"))] @@ -3537,13 +3289,9 @@ pub fn visit_type_ptr<'ast, V>(v: &mut V, node: &'ast TypePtr) where V: Visit<'ast> + ?Sized, { - tokens_helper(v, &node.star_token.spans); - if let Some(it) = &node.const_token { - tokens_helper(v, &it.span); - } - if let Some(it) = &node.mutability { - tokens_helper(v, &it.span); - } + skip!(node.star_token); + skip!(node.const_token); + skip!(node.mutability); v.visit_type(&*node.elem); } #[cfg(any(feature = "derive", feature = "full"))] @@ -3551,13 +3299,11 @@ pub fn visit_type_reference<'ast, V>(v: &mut V, node: &'ast TypeReference) where V: Visit<'ast> + ?Sized, { - tokens_helper(v, &node.and_token.spans); + skip!(node.and_token); if let Some(it) = &node.lifetime { v.visit_lifetime(it); } - if let Some(it) = &node.mutability { - tokens_helper(v, &it.span); - } + skip!(node.mutability); v.visit_type(&*node.elem); } #[cfg(any(feature = "derive", feature = "full"))] @@ -3565,7 +3311,7 @@ pub fn visit_type_slice<'ast, V>(v: &mut V, node: &'ast TypeSlice) where V: Visit<'ast> + ?Sized, { - tokens_helper(v, &node.bracket_token.span); + skip!(node.bracket_token); v.visit_type(&*node.elem); } #[cfg(any(feature = "derive", feature = "full"))] @@ -3573,15 +3319,10 @@ pub fn visit_type_trait_object<'ast, V>(v: &mut V, node: &'ast TypeTraitObject) where V: Visit<'ast> + ?Sized, { - if let Some(it) = &node.dyn_token { - tokens_helper(v, &it.span); - } + skip!(node.dyn_token); for el in Punctuated::pairs(&node.bounds) { - let (it, p) = el.into_tuple(); + let it = el.value(); v.visit_type_param_bound(it); - if let Some(p) = p { - tokens_helper(v, &p.spans); - } } } #[cfg(any(feature = "derive", feature = "full"))] @@ -3589,13 +3330,10 @@ pub fn visit_type_tuple<'ast, V>(v: &mut V, node: &'ast TypeTuple) where V: Visit<'ast> + ?Sized, { - tokens_helper(v, &node.paren_token.span); + skip!(node.paren_token); for el in Punctuated::pairs(&node.elems) { - let (it, p) = el.into_tuple(); + let it = el.value(); v.visit_type(it); - if let Some(p) = p { - tokens_helper(v, &p.spans); - } } } #[cfg(any(feature = "derive", feature = "full"))] @@ -3605,13 +3343,13 @@ where { match node { UnOp::Deref(_binding_0) => { - tokens_helper(v, &_binding_0.spans); + skip!(_binding_0); } UnOp::Not(_binding_0) => { - tokens_helper(v, &_binding_0.spans); + skip!(_binding_0); } UnOp::Neg(_binding_0) => { - tokens_helper(v, &_binding_0.spans); + skip!(_binding_0); } } } @@ -3620,20 +3358,17 @@ pub fn visit_use_glob<'ast, V>(v: &mut V, node: &'ast UseGlob) where V: Visit<'ast> + ?Sized, { - tokens_helper(v, &node.star_token.spans); + skip!(node.star_token); } #[cfg(feature = "full")] pub fn visit_use_group<'ast, V>(v: &mut V, node: &'ast UseGroup) where V: Visit<'ast> + ?Sized, { - tokens_helper(v, &node.brace_token.span); + skip!(node.brace_token); for el in Punctuated::pairs(&node.items) { - let (it, p) = el.into_tuple(); + let it = el.value(); v.visit_use_tree(it); - if let Some(p) = p { - tokens_helper(v, &p.spans); - } } } #[cfg(feature = "full")] @@ -3649,7 +3384,7 @@ where V: Visit<'ast> + ?Sized, { v.visit_ident(&node.ident); - tokens_helper(v, &node.colon2_token.spans); + skip!(node.colon2_token); v.visit_use_tree(&*node.tree); } #[cfg(feature = "full")] @@ -3658,7 +3393,7 @@ where V: Visit<'ast> + ?Sized, { v.visit_ident(&node.ident); - tokens_helper(v, &node.as_token.span); + skip!(node.as_token); v.visit_ident(&node.rename); } #[cfg(feature = "full")] @@ -3684,7 +3419,7 @@ where } } } -#[cfg(any(feature = "derive", feature = "full"))] +#[cfg(feature = "full")] pub fn visit_variadic<'ast, V>(v: &mut V, node: &'ast Variadic) where V: Visit<'ast> + ?Sized, @@ -3692,7 +3427,12 @@ where for it in &node.attrs { v.visit_attribute(it); } - tokens_helper(v, &node.dots.spans); + if let Some(it) = &node.pat { + v.visit_pat(&*(it).0); + skip!((it).1); + } + skip!(node.dots); + skip!(node.comma); } #[cfg(any(feature = "derive", feature = "full"))] pub fn visit_variant<'ast, V>(v: &mut V, node: &'ast Variant) @@ -3705,34 +3445,18 @@ where v.visit_ident(&node.ident); v.visit_fields(&node.fields); if let Some(it) = &node.discriminant { - tokens_helper(v, &(it).0.spans); + skip!((it).0); v.visit_expr(&(it).1); } } #[cfg(any(feature = "derive", feature = "full"))] -pub fn visit_vis_crate<'ast, V>(v: &mut V, node: &'ast VisCrate) -where - V: Visit<'ast> + ?Sized, -{ - tokens_helper(v, &node.crate_token.span); -} -#[cfg(any(feature = "derive", feature = "full"))] -pub fn visit_vis_public<'ast, V>(v: &mut V, node: &'ast VisPublic) -where - V: Visit<'ast> + ?Sized, -{ - tokens_helper(v, &node.pub_token.span); -} -#[cfg(any(feature = "derive", feature = "full"))] pub fn visit_vis_restricted<'ast, V>(v: &mut V, node: &'ast VisRestricted) where V: Visit<'ast> + ?Sized, { - tokens_helper(v, &node.pub_token.span); - tokens_helper(v, &node.paren_token.span); - if let Some(it) = &node.in_token { - tokens_helper(v, &it.span); - } + skip!(node.pub_token); + skip!(node.paren_token); + skip!(node.in_token); v.visit_path(&*node.path); } #[cfg(any(feature = "derive", feature = "full"))] @@ -3742,10 +3466,7 @@ where { match node { Visibility::Public(_binding_0) => { - v.visit_vis_public(_binding_0); - } - Visibility::Crate(_binding_0) => { - v.visit_vis_crate(_binding_0); + skip!(_binding_0); } Visibility::Restricted(_binding_0) => { v.visit_vis_restricted(_binding_0); @@ -3758,13 +3479,10 @@ pub fn visit_where_clause<'ast, V>(v: &mut V, node: &'ast WhereClause) where V: Visit<'ast> + ?Sized, { - tokens_helper(v, &node.where_token.span); + skip!(node.where_token); for el in Punctuated::pairs(&node.predicates) { - let (it, p) = el.into_tuple(); + let it = el.value(); v.visit_where_predicate(it); - if let Some(p) = p { - tokens_helper(v, &p.spans); - } } } #[cfg(any(feature = "derive", feature = "full"))] @@ -3773,14 +3491,11 @@ where V: Visit<'ast> + ?Sized, { match node { - WherePredicate::Type(_binding_0) => { - v.visit_predicate_type(_binding_0); - } WherePredicate::Lifetime(_binding_0) => { v.visit_predicate_lifetime(_binding_0); } - WherePredicate::Eq(_binding_0) => { - v.visit_predicate_eq(_binding_0); + WherePredicate::Type(_binding_0) => { + v.visit_predicate_type(_binding_0); } } } diff --git a/vendor/syn/src/gen/visit_mut.rs b/vendor/syn/src/gen/visit_mut.rs index 239709d19..83bd1ccf8 100644 --- a/vendor/syn/src/gen/visit_mut.rs +++ b/vendor/syn/src/gen/visit_mut.rs @@ -3,8 +3,6 @@ #![allow(unused_variables)] #[cfg(any(feature = "full", feature = "derive"))] -use crate::gen::helper::visit_mut::*; -#[cfg(any(feature = "full", feature = "derive"))] use crate::punctuated::Punctuated; use crate::*; use proc_macro2::Span; @@ -29,8 +27,6 @@ macro_rules! skip { /// See the [module documentation] for details. /// /// [module documentation]: self -/// -/// *This trait is available only if Syn is built with the `"visit-mut"` feature.* pub trait VisitMut { #[cfg(any(feature = "derive", feature = "full"))] fn visit_abi_mut(&mut self, i: &mut Abi) { @@ -48,6 +44,14 @@ pub trait VisitMut { visit_arm_mut(self, i); } #[cfg(any(feature = "derive", feature = "full"))] + fn visit_assoc_const_mut(&mut self, i: &mut AssocConst) { + visit_assoc_const_mut(self, i); + } + #[cfg(any(feature = "derive", feature = "full"))] + fn visit_assoc_type_mut(&mut self, i: &mut AssocType) { + visit_assoc_type_mut(self, i); + } + #[cfg(any(feature = "derive", feature = "full"))] fn visit_attr_style_mut(&mut self, i: &mut AttrStyle) { visit_attr_style_mut(self, i); } @@ -60,12 +64,12 @@ pub trait VisitMut { visit_bare_fn_arg_mut(self, i); } #[cfg(any(feature = "derive", feature = "full"))] - fn visit_bin_op_mut(&mut self, i: &mut BinOp) { - visit_bin_op_mut(self, i); + fn visit_bare_variadic_mut(&mut self, i: &mut BareVariadic) { + visit_bare_variadic_mut(self, i); } #[cfg(any(feature = "derive", feature = "full"))] - fn visit_binding_mut(&mut self, i: &mut Binding) { - visit_binding_mut(self, i); + fn visit_bin_op_mut(&mut self, i: &mut BinOp) { + visit_bin_op_mut(self, i); } #[cfg(feature = "full")] fn visit_block_mut(&mut self, i: &mut Block) { @@ -116,10 +120,6 @@ pub trait VisitMut { visit_expr_assign_mut(self, i); } #[cfg(feature = "full")] - fn visit_expr_assign_op_mut(&mut self, i: &mut ExprAssignOp) { - visit_expr_assign_op_mut(self, i); - } - #[cfg(feature = "full")] fn visit_expr_async_mut(&mut self, i: &mut ExprAsync) { visit_expr_async_mut(self, i); } @@ -136,10 +136,6 @@ pub trait VisitMut { visit_expr_block_mut(self, i); } #[cfg(feature = "full")] - fn visit_expr_box_mut(&mut self, i: &mut ExprBox) { - visit_expr_box_mut(self, i); - } - #[cfg(feature = "full")] fn visit_expr_break_mut(&mut self, i: &mut ExprBreak) { visit_expr_break_mut(self, i); } @@ -156,6 +152,10 @@ pub trait VisitMut { visit_expr_closure_mut(self, i); } #[cfg(feature = "full")] + fn visit_expr_const_mut(&mut self, i: &mut ExprConst) { + visit_expr_const_mut(self, i); + } + #[cfg(feature = "full")] fn visit_expr_continue_mut(&mut self, i: &mut ExprContinue) { visit_expr_continue_mut(self, i); } @@ -167,7 +167,7 @@ pub trait VisitMut { fn visit_expr_for_loop_mut(&mut self, i: &mut ExprForLoop) { visit_expr_for_loop_mut(self, i); } - #[cfg(feature = "full")] + #[cfg(any(feature = "derive", feature = "full"))] fn visit_expr_group_mut(&mut self, i: &mut ExprGroup) { visit_expr_group_mut(self, i); } @@ -180,6 +180,10 @@ pub trait VisitMut { visit_expr_index_mut(self, i); } #[cfg(feature = "full")] + fn visit_expr_infer_mut(&mut self, i: &mut ExprInfer) { + visit_expr_infer_mut(self, i); + } + #[cfg(feature = "full")] fn visit_expr_let_mut(&mut self, i: &mut ExprLet) { visit_expr_let_mut(self, i); } @@ -191,7 +195,7 @@ pub trait VisitMut { fn visit_expr_loop_mut(&mut self, i: &mut ExprLoop) { visit_expr_loop_mut(self, i); } - #[cfg(feature = "full")] + #[cfg(any(feature = "derive", feature = "full"))] fn visit_expr_macro_mut(&mut self, i: &mut ExprMacro) { visit_expr_macro_mut(self, i); } @@ -243,10 +247,6 @@ pub trait VisitMut { fn visit_expr_tuple_mut(&mut self, i: &mut ExprTuple) { visit_expr_tuple_mut(self, i); } - #[cfg(feature = "full")] - fn visit_expr_type_mut(&mut self, i: &mut ExprType) { - visit_expr_type_mut(self, i); - } #[cfg(any(feature = "derive", feature = "full"))] fn visit_expr_unary_mut(&mut self, i: &mut ExprUnary) { visit_expr_unary_mut(self, i); @@ -267,6 +267,10 @@ pub trait VisitMut { fn visit_field_mut(&mut self, i: &mut Field) { visit_field_mut(self, i); } + #[cfg(any(feature = "derive", feature = "full"))] + fn visit_field_mutability_mut(&mut self, i: &mut FieldMutability) { + visit_field_mutability_mut(self, i); + } #[cfg(feature = "full")] fn visit_field_pat_mut(&mut self, i: &mut FieldPat) { visit_field_pat_mut(self, i); @@ -319,10 +323,6 @@ pub trait VisitMut { fn visit_generic_argument_mut(&mut self, i: &mut GenericArgument) { visit_generic_argument_mut(self, i); } - #[cfg(feature = "full")] - fn visit_generic_method_argument_mut(&mut self, i: &mut GenericMethodArgument) { - visit_generic_method_argument_mut(self, i); - } #[cfg(any(feature = "derive", feature = "full"))] fn visit_generic_param_mut(&mut self, i: &mut GenericParam) { visit_generic_param_mut(self, i); @@ -343,17 +343,21 @@ pub trait VisitMut { visit_impl_item_const_mut(self, i); } #[cfg(feature = "full")] - fn visit_impl_item_macro_mut(&mut self, i: &mut ImplItemMacro) { - visit_impl_item_macro_mut(self, i); + fn visit_impl_item_fn_mut(&mut self, i: &mut ImplItemFn) { + visit_impl_item_fn_mut(self, i); } #[cfg(feature = "full")] - fn visit_impl_item_method_mut(&mut self, i: &mut ImplItemMethod) { - visit_impl_item_method_mut(self, i); + fn visit_impl_item_macro_mut(&mut self, i: &mut ImplItemMacro) { + visit_impl_item_macro_mut(self, i); } #[cfg(feature = "full")] fn visit_impl_item_type_mut(&mut self, i: &mut ImplItemType) { visit_impl_item_type_mut(self, i); } + #[cfg(feature = "full")] + fn visit_impl_restriction_mut(&mut self, i: &mut ImplRestriction) { + visit_impl_restriction_mut(self, i); + } #[cfg(any(feature = "derive", feature = "full"))] fn visit_index_mut(&mut self, i: &mut Index) { visit_index_mut(self, i); @@ -391,10 +395,6 @@ pub trait VisitMut { visit_item_macro_mut(self, i); } #[cfg(feature = "full")] - fn visit_item_macro2_mut(&mut self, i: &mut ItemMacro2) { - visit_item_macro2_mut(self, i); - } - #[cfg(feature = "full")] fn visit_item_mod_mut(&mut self, i: &mut ItemMod) { visit_item_mod_mut(self, i); } @@ -434,8 +434,8 @@ pub trait VisitMut { visit_lifetime_mut(self, i); } #[cfg(any(feature = "derive", feature = "full"))] - fn visit_lifetime_def_mut(&mut self, i: &mut LifetimeDef) { - visit_lifetime_def_mut(self, i); + fn visit_lifetime_param_mut(&mut self, i: &mut LifetimeParam) { + visit_lifetime_param_mut(self, i); } fn visit_lit_mut(&mut self, i: &mut Lit) { visit_lit_mut(self, i); @@ -465,6 +465,10 @@ pub trait VisitMut { fn visit_local_mut(&mut self, i: &mut Local) { visit_local_mut(self, i); } + #[cfg(feature = "full")] + fn visit_local_init_mut(&mut self, i: &mut LocalInit) { + visit_local_init_mut(self, i); + } #[cfg(any(feature = "derive", feature = "full"))] fn visit_macro_mut(&mut self, i: &mut Macro) { visit_macro_mut(self, i); @@ -489,14 +493,6 @@ pub trait VisitMut { fn visit_meta_name_value_mut(&mut self, i: &mut MetaNameValue) { visit_meta_name_value_mut(self, i); } - #[cfg(feature = "full")] - fn visit_method_turbofish_mut(&mut self, i: &mut MethodTurbofish) { - visit_method_turbofish_mut(self, i); - } - #[cfg(any(feature = "derive", feature = "full"))] - fn visit_nested_meta_mut(&mut self, i: &mut NestedMeta) { - visit_nested_meta_mut(self, i); - } #[cfg(any(feature = "derive", feature = "full"))] fn visit_parenthesized_generic_arguments_mut( &mut self, @@ -509,32 +505,16 @@ pub trait VisitMut { visit_pat_mut(self, i); } #[cfg(feature = "full")] - fn visit_pat_box_mut(&mut self, i: &mut PatBox) { - visit_pat_box_mut(self, i); - } - #[cfg(feature = "full")] fn visit_pat_ident_mut(&mut self, i: &mut PatIdent) { visit_pat_ident_mut(self, i); } #[cfg(feature = "full")] - fn visit_pat_lit_mut(&mut self, i: &mut PatLit) { - visit_pat_lit_mut(self, i); - } - #[cfg(feature = "full")] - fn visit_pat_macro_mut(&mut self, i: &mut PatMacro) { - visit_pat_macro_mut(self, i); - } - #[cfg(feature = "full")] fn visit_pat_or_mut(&mut self, i: &mut PatOr) { visit_pat_or_mut(self, i); } #[cfg(feature = "full")] - fn visit_pat_path_mut(&mut self, i: &mut PatPath) { - visit_pat_path_mut(self, i); - } - #[cfg(feature = "full")] - fn visit_pat_range_mut(&mut self, i: &mut PatRange) { - visit_pat_range_mut(self, i); + fn visit_pat_paren_mut(&mut self, i: &mut PatParen) { + visit_pat_paren_mut(self, i); } #[cfg(feature = "full")] fn visit_pat_reference_mut(&mut self, i: &mut PatReference) { @@ -581,10 +561,6 @@ pub trait VisitMut { visit_path_segment_mut(self, i); } #[cfg(any(feature = "derive", feature = "full"))] - fn visit_predicate_eq_mut(&mut self, i: &mut PredicateEq) { - visit_predicate_eq_mut(self, i); - } - #[cfg(any(feature = "derive", feature = "full"))] fn visit_predicate_lifetime_mut(&mut self, i: &mut PredicateLifetime) { visit_predicate_lifetime_mut(self, i); } @@ -616,9 +592,17 @@ pub trait VisitMut { visit_span_mut(self, i); } #[cfg(feature = "full")] + fn visit_static_mutability_mut(&mut self, i: &mut StaticMutability) { + visit_static_mutability_mut(self, i); + } + #[cfg(feature = "full")] fn visit_stmt_mut(&mut self, i: &mut Stmt) { visit_stmt_mut(self, i); } + #[cfg(feature = "full")] + fn visit_stmt_macro_mut(&mut self, i: &mut StmtMacro) { + visit_stmt_macro_mut(self, i); + } #[cfg(any(feature = "derive", feature = "full"))] fn visit_trait_bound_mut(&mut self, i: &mut TraitBound) { visit_trait_bound_mut(self, i); @@ -636,12 +620,12 @@ pub trait VisitMut { visit_trait_item_const_mut(self, i); } #[cfg(feature = "full")] - fn visit_trait_item_macro_mut(&mut self, i: &mut TraitItemMacro) { - visit_trait_item_macro_mut(self, i); + fn visit_trait_item_fn_mut(&mut self, i: &mut TraitItemFn) { + visit_trait_item_fn_mut(self, i); } #[cfg(feature = "full")] - fn visit_trait_item_method_mut(&mut self, i: &mut TraitItemMethod) { - visit_trait_item_method_mut(self, i); + fn visit_trait_item_macro_mut(&mut self, i: &mut TraitItemMacro) { + visit_trait_item_macro_mut(self, i); } #[cfg(feature = "full")] fn visit_trait_item_type_mut(&mut self, i: &mut TraitItemType) { @@ -743,7 +727,7 @@ pub trait VisitMut { fn visit_use_tree_mut(&mut self, i: &mut UseTree) { visit_use_tree_mut(self, i); } - #[cfg(any(feature = "derive", feature = "full"))] + #[cfg(feature = "full")] fn visit_variadic_mut(&mut self, i: &mut Variadic) { visit_variadic_mut(self, i); } @@ -752,14 +736,6 @@ pub trait VisitMut { visit_variant_mut(self, i); } #[cfg(any(feature = "derive", feature = "full"))] - fn visit_vis_crate_mut(&mut self, i: &mut VisCrate) { - visit_vis_crate_mut(self, i); - } - #[cfg(any(feature = "derive", feature = "full"))] - fn visit_vis_public_mut(&mut self, i: &mut VisPublic) { - visit_vis_public_mut(self, i); - } - #[cfg(any(feature = "derive", feature = "full"))] fn visit_vis_restricted_mut(&mut self, i: &mut VisRestricted) { visit_vis_restricted_mut(self, i); } @@ -781,7 +757,7 @@ pub fn visit_abi_mut<V>(v: &mut V, node: &mut Abi) where V: VisitMut + ?Sized, { - tokens_helper(v, &mut node.extern_token.span); + skip!(node.extern_token); if let Some(it) = &mut node.name { v.visit_lit_str_mut(it); } @@ -794,18 +770,13 @@ pub fn visit_angle_bracketed_generic_arguments_mut<V>( where V: VisitMut + ?Sized, { - if let Some(it) = &mut node.colon2_token { - tokens_helper(v, &mut it.spans); - } - tokens_helper(v, &mut node.lt_token.spans); - for el in Punctuated::pairs_mut(&mut node.args) { - let (it, p) = el.into_tuple(); + skip!(node.colon2_token); + skip!(node.lt_token); + for mut el in Punctuated::pairs_mut(&mut node.args) { + let it = el.value_mut(); v.visit_generic_argument_mut(it); - if let Some(p) = p { - tokens_helper(v, &mut p.spans); - } } - tokens_helper(v, &mut node.gt_token.spans); + skip!(node.gt_token); } #[cfg(feature = "full")] pub fn visit_arm_mut<V>(v: &mut V, node: &mut Arm) @@ -817,14 +788,36 @@ where } v.visit_pat_mut(&mut node.pat); if let Some(it) = &mut node.guard { - tokens_helper(v, &mut (it).0.span); + skip!((it).0); v.visit_expr_mut(&mut *(it).1); } - tokens_helper(v, &mut node.fat_arrow_token.spans); + skip!(node.fat_arrow_token); v.visit_expr_mut(&mut *node.body); - if let Some(it) = &mut node.comma { - tokens_helper(v, &mut it.spans); + skip!(node.comma); +} +#[cfg(any(feature = "derive", feature = "full"))] +pub fn visit_assoc_const_mut<V>(v: &mut V, node: &mut AssocConst) +where + V: VisitMut + ?Sized, +{ + v.visit_ident_mut(&mut node.ident); + if let Some(it) = &mut node.generics { + v.visit_angle_bracketed_generic_arguments_mut(it); + } + skip!(node.eq_token); + v.visit_expr_mut(&mut node.value); +} +#[cfg(any(feature = "derive", feature = "full"))] +pub fn visit_assoc_type_mut<V>(v: &mut V, node: &mut AssocType) +where + V: VisitMut + ?Sized, +{ + v.visit_ident_mut(&mut node.ident); + if let Some(it) = &mut node.generics { + v.visit_angle_bracketed_generic_arguments_mut(it); } + skip!(node.eq_token); + v.visit_type_mut(&mut node.ty); } #[cfg(any(feature = "derive", feature = "full"))] pub fn visit_attr_style_mut<V>(v: &mut V, node: &mut AttrStyle) @@ -834,7 +827,7 @@ where match node { AttrStyle::Outer => {} AttrStyle::Inner(_binding_0) => { - tokens_helper(v, &mut _binding_0.spans); + skip!(_binding_0); } } } @@ -843,11 +836,10 @@ pub fn visit_attribute_mut<V>(v: &mut V, node: &mut Attribute) where V: VisitMut + ?Sized, { - tokens_helper(v, &mut node.pound_token.spans); + skip!(node.pound_token); v.visit_attr_style_mut(&mut node.style); - tokens_helper(v, &mut node.bracket_token.span); - v.visit_path_mut(&mut node.path); - skip!(node.tokens); + skip!(node.bracket_token); + v.visit_meta_mut(&mut node.meta); } #[cfg(any(feature = "derive", feature = "full"))] pub fn visit_bare_fn_arg_mut<V>(v: &mut V, node: &mut BareFnArg) @@ -859,117 +851,123 @@ where } if let Some(it) = &mut node.name { v.visit_ident_mut(&mut (it).0); - tokens_helper(v, &mut (it).1.spans); + skip!((it).1); } v.visit_type_mut(&mut node.ty); } #[cfg(any(feature = "derive", feature = "full"))] +pub fn visit_bare_variadic_mut<V>(v: &mut V, node: &mut BareVariadic) +where + V: VisitMut + ?Sized, +{ + for it in &mut node.attrs { + v.visit_attribute_mut(it); + } + if let Some(it) = &mut node.name { + v.visit_ident_mut(&mut (it).0); + skip!((it).1); + } + skip!(node.dots); + skip!(node.comma); +} +#[cfg(any(feature = "derive", feature = "full"))] pub fn visit_bin_op_mut<V>(v: &mut V, node: &mut BinOp) where V: VisitMut + ?Sized, { match node { BinOp::Add(_binding_0) => { - tokens_helper(v, &mut _binding_0.spans); + skip!(_binding_0); } BinOp::Sub(_binding_0) => { - tokens_helper(v, &mut _binding_0.spans); + skip!(_binding_0); } BinOp::Mul(_binding_0) => { - tokens_helper(v, &mut _binding_0.spans); + skip!(_binding_0); } BinOp::Div(_binding_0) => { - tokens_helper(v, &mut _binding_0.spans); + skip!(_binding_0); } BinOp::Rem(_binding_0) => { - tokens_helper(v, &mut _binding_0.spans); + skip!(_binding_0); } BinOp::And(_binding_0) => { - tokens_helper(v, &mut _binding_0.spans); + skip!(_binding_0); } BinOp::Or(_binding_0) => { - tokens_helper(v, &mut _binding_0.spans); + skip!(_binding_0); } BinOp::BitXor(_binding_0) => { - tokens_helper(v, &mut _binding_0.spans); + skip!(_binding_0); } BinOp::BitAnd(_binding_0) => { - tokens_helper(v, &mut _binding_0.spans); + skip!(_binding_0); } BinOp::BitOr(_binding_0) => { - tokens_helper(v, &mut _binding_0.spans); + skip!(_binding_0); } BinOp::Shl(_binding_0) => { - tokens_helper(v, &mut _binding_0.spans); + skip!(_binding_0); } BinOp::Shr(_binding_0) => { - tokens_helper(v, &mut _binding_0.spans); + skip!(_binding_0); } BinOp::Eq(_binding_0) => { - tokens_helper(v, &mut _binding_0.spans); + skip!(_binding_0); } BinOp::Lt(_binding_0) => { - tokens_helper(v, &mut _binding_0.spans); + skip!(_binding_0); } BinOp::Le(_binding_0) => { - tokens_helper(v, &mut _binding_0.spans); + skip!(_binding_0); } BinOp::Ne(_binding_0) => { - tokens_helper(v, &mut _binding_0.spans); + skip!(_binding_0); } BinOp::Ge(_binding_0) => { - tokens_helper(v, &mut _binding_0.spans); + skip!(_binding_0); } BinOp::Gt(_binding_0) => { - tokens_helper(v, &mut _binding_0.spans); + skip!(_binding_0); } - BinOp::AddEq(_binding_0) => { - tokens_helper(v, &mut _binding_0.spans); + BinOp::AddAssign(_binding_0) => { + skip!(_binding_0); } - BinOp::SubEq(_binding_0) => { - tokens_helper(v, &mut _binding_0.spans); + BinOp::SubAssign(_binding_0) => { + skip!(_binding_0); } - BinOp::MulEq(_binding_0) => { - tokens_helper(v, &mut _binding_0.spans); + BinOp::MulAssign(_binding_0) => { + skip!(_binding_0); } - BinOp::DivEq(_binding_0) => { - tokens_helper(v, &mut _binding_0.spans); + BinOp::DivAssign(_binding_0) => { + skip!(_binding_0); } - BinOp::RemEq(_binding_0) => { - tokens_helper(v, &mut _binding_0.spans); + BinOp::RemAssign(_binding_0) => { + skip!(_binding_0); } - BinOp::BitXorEq(_binding_0) => { - tokens_helper(v, &mut _binding_0.spans); + BinOp::BitXorAssign(_binding_0) => { + skip!(_binding_0); } - BinOp::BitAndEq(_binding_0) => { - tokens_helper(v, &mut _binding_0.spans); + BinOp::BitAndAssign(_binding_0) => { + skip!(_binding_0); } - BinOp::BitOrEq(_binding_0) => { - tokens_helper(v, &mut _binding_0.spans); + BinOp::BitOrAssign(_binding_0) => { + skip!(_binding_0); } - BinOp::ShlEq(_binding_0) => { - tokens_helper(v, &mut _binding_0.spans); + BinOp::ShlAssign(_binding_0) => { + skip!(_binding_0); } - BinOp::ShrEq(_binding_0) => { - tokens_helper(v, &mut _binding_0.spans); + BinOp::ShrAssign(_binding_0) => { + skip!(_binding_0); } } } -#[cfg(any(feature = "derive", feature = "full"))] -pub fn visit_binding_mut<V>(v: &mut V, node: &mut Binding) -where - V: VisitMut + ?Sized, -{ - v.visit_ident_mut(&mut node.ident); - tokens_helper(v, &mut node.eq_token.spans); - v.visit_type_mut(&mut node.ty); -} #[cfg(feature = "full")] pub fn visit_block_mut<V>(v: &mut V, node: &mut Block) where V: VisitMut + ?Sized, { - tokens_helper(v, &mut node.brace_token.span); + skip!(node.brace_token); for it in &mut node.stmts { v.visit_stmt_mut(it); } @@ -979,16 +977,13 @@ pub fn visit_bound_lifetimes_mut<V>(v: &mut V, node: &mut BoundLifetimes) where V: VisitMut + ?Sized, { - tokens_helper(v, &mut node.for_token.span); - tokens_helper(v, &mut node.lt_token.spans); - for el in Punctuated::pairs_mut(&mut node.lifetimes) { - let (it, p) = el.into_tuple(); - v.visit_lifetime_def_mut(it); - if let Some(p) = p { - tokens_helper(v, &mut p.spans); - } + skip!(node.for_token); + skip!(node.lt_token); + for mut el in Punctuated::pairs_mut(&mut node.lifetimes) { + let it = el.value_mut(); + v.visit_generic_param_mut(it); } - tokens_helper(v, &mut node.gt_token.spans); + skip!(node.gt_token); } #[cfg(any(feature = "derive", feature = "full"))] pub fn visit_const_param_mut<V>(v: &mut V, node: &mut ConstParam) @@ -998,13 +993,11 @@ where for it in &mut node.attrs { v.visit_attribute_mut(it); } - tokens_helper(v, &mut node.const_token.span); + skip!(node.const_token); v.visit_ident_mut(&mut node.ident); - tokens_helper(v, &mut node.colon_token.spans); + skip!(node.colon_token); v.visit_type_mut(&mut node.ty); - if let Some(it) = &mut node.eq_token { - tokens_helper(v, &mut it.spans); - } + skip!(node.eq_token); if let Some(it) = &mut node.default { v.visit_expr_mut(it); } @@ -1015,13 +1008,13 @@ where V: VisitMut + ?Sized, { v.visit_ident_mut(&mut node.ident); - tokens_helper(v, &mut node.colon_token.spans); - for el in Punctuated::pairs_mut(&mut node.bounds) { - let (it, p) = el.into_tuple(); + if let Some(it) = &mut node.generics { + v.visit_angle_bracketed_generic_arguments_mut(it); + } + skip!(node.colon_token); + for mut el in Punctuated::pairs_mut(&mut node.bounds) { + let it = el.value_mut(); v.visit_type_param_bound_mut(it); - if let Some(p) = p { - tokens_helper(v, &mut p.spans); - } } } #[cfg(feature = "derive")] @@ -1046,14 +1039,11 @@ pub fn visit_data_enum_mut<V>(v: &mut V, node: &mut DataEnum) where V: VisitMut + ?Sized, { - tokens_helper(v, &mut node.enum_token.span); - tokens_helper(v, &mut node.brace_token.span); - for el in Punctuated::pairs_mut(&mut node.variants) { - let (it, p) = el.into_tuple(); + skip!(node.enum_token); + skip!(node.brace_token); + for mut el in Punctuated::pairs_mut(&mut node.variants) { + let it = el.value_mut(); v.visit_variant_mut(it); - if let Some(p) = p { - tokens_helper(v, &mut p.spans); - } } } #[cfg(feature = "derive")] @@ -1061,18 +1051,16 @@ pub fn visit_data_struct_mut<V>(v: &mut V, node: &mut DataStruct) where V: VisitMut + ?Sized, { - tokens_helper(v, &mut node.struct_token.span); + skip!(node.struct_token); v.visit_fields_mut(&mut node.fields); - if let Some(it) = &mut node.semi_token { - tokens_helper(v, &mut it.spans); - } + skip!(node.semi_token); } #[cfg(feature = "derive")] pub fn visit_data_union_mut<V>(v: &mut V, node: &mut DataUnion) where V: VisitMut + ?Sized, { - tokens_helper(v, &mut node.union_token.span); + skip!(node.union_token); v.visit_fields_named_mut(&mut node.fields); } #[cfg(feature = "derive")] @@ -1100,9 +1088,6 @@ where Expr::Assign(_binding_0) => { full!(v.visit_expr_assign_mut(_binding_0)); } - Expr::AssignOp(_binding_0) => { - full!(v.visit_expr_assign_op_mut(_binding_0)); - } Expr::Async(_binding_0) => { full!(v.visit_expr_async_mut(_binding_0)); } @@ -1115,9 +1100,6 @@ where Expr::Block(_binding_0) => { full!(v.visit_expr_block_mut(_binding_0)); } - Expr::Box(_binding_0) => { - full!(v.visit_expr_box_mut(_binding_0)); - } Expr::Break(_binding_0) => { full!(v.visit_expr_break_mut(_binding_0)); } @@ -1130,6 +1112,9 @@ where Expr::Closure(_binding_0) => { full!(v.visit_expr_closure_mut(_binding_0)); } + Expr::Const(_binding_0) => { + full!(v.visit_expr_const_mut(_binding_0)); + } Expr::Continue(_binding_0) => { full!(v.visit_expr_continue_mut(_binding_0)); } @@ -1140,7 +1125,7 @@ where full!(v.visit_expr_for_loop_mut(_binding_0)); } Expr::Group(_binding_0) => { - full!(v.visit_expr_group_mut(_binding_0)); + v.visit_expr_group_mut(_binding_0); } Expr::If(_binding_0) => { full!(v.visit_expr_if_mut(_binding_0)); @@ -1148,6 +1133,9 @@ where Expr::Index(_binding_0) => { v.visit_expr_index_mut(_binding_0); } + Expr::Infer(_binding_0) => { + full!(v.visit_expr_infer_mut(_binding_0)); + } Expr::Let(_binding_0) => { full!(v.visit_expr_let_mut(_binding_0)); } @@ -1158,7 +1146,7 @@ where full!(v.visit_expr_loop_mut(_binding_0)); } Expr::Macro(_binding_0) => { - full!(v.visit_expr_macro_mut(_binding_0)); + v.visit_expr_macro_mut(_binding_0); } Expr::Match(_binding_0) => { full!(v.visit_expr_match_mut(_binding_0)); @@ -1196,9 +1184,6 @@ where Expr::Tuple(_binding_0) => { full!(v.visit_expr_tuple_mut(_binding_0)); } - Expr::Type(_binding_0) => { - full!(v.visit_expr_type_mut(_binding_0)); - } Expr::Unary(_binding_0) => { v.visit_expr_unary_mut(_binding_0); } @@ -1214,8 +1199,6 @@ where Expr::Yield(_binding_0) => { full!(v.visit_expr_yield_mut(_binding_0)); } - #[cfg(syn_no_non_exhaustive)] - _ => unreachable!(), } } #[cfg(feature = "full")] @@ -1226,13 +1209,10 @@ where for it in &mut node.attrs { v.visit_attribute_mut(it); } - tokens_helper(v, &mut node.bracket_token.span); - for el in Punctuated::pairs_mut(&mut node.elems) { - let (it, p) = el.into_tuple(); + skip!(node.bracket_token); + for mut el in Punctuated::pairs_mut(&mut node.elems) { + let it = el.value_mut(); v.visit_expr_mut(it); - if let Some(p) = p { - tokens_helper(v, &mut p.spans); - } } } #[cfg(feature = "full")] @@ -1244,19 +1224,7 @@ where v.visit_attribute_mut(it); } v.visit_expr_mut(&mut *node.left); - tokens_helper(v, &mut node.eq_token.spans); - v.visit_expr_mut(&mut *node.right); -} -#[cfg(feature = "full")] -pub fn visit_expr_assign_op_mut<V>(v: &mut V, node: &mut ExprAssignOp) -where - V: VisitMut + ?Sized, -{ - for it in &mut node.attrs { - v.visit_attribute_mut(it); - } - v.visit_expr_mut(&mut *node.left); - v.visit_bin_op_mut(&mut node.op); + skip!(node.eq_token); v.visit_expr_mut(&mut *node.right); } #[cfg(feature = "full")] @@ -1267,10 +1235,8 @@ where for it in &mut node.attrs { v.visit_attribute_mut(it); } - tokens_helper(v, &mut node.async_token.span); - if let Some(it) = &mut node.capture { - tokens_helper(v, &mut it.span); - } + skip!(node.async_token); + skip!(node.capture); v.visit_block_mut(&mut node.block); } #[cfg(feature = "full")] @@ -1282,8 +1248,8 @@ where v.visit_attribute_mut(it); } v.visit_expr_mut(&mut *node.base); - tokens_helper(v, &mut node.dot_token.spans); - tokens_helper(v, &mut node.await_token.span); + skip!(node.dot_token); + skip!(node.await_token); } #[cfg(any(feature = "derive", feature = "full"))] pub fn visit_expr_binary_mut<V>(v: &mut V, node: &mut ExprBinary) @@ -1311,17 +1277,6 @@ where v.visit_block_mut(&mut node.block); } #[cfg(feature = "full")] -pub fn visit_expr_box_mut<V>(v: &mut V, node: &mut ExprBox) -where - V: VisitMut + ?Sized, -{ - for it in &mut node.attrs { - v.visit_attribute_mut(it); - } - tokens_helper(v, &mut node.box_token.span); - v.visit_expr_mut(&mut *node.expr); -} -#[cfg(feature = "full")] pub fn visit_expr_break_mut<V>(v: &mut V, node: &mut ExprBreak) where V: VisitMut + ?Sized, @@ -1329,7 +1284,7 @@ where for it in &mut node.attrs { v.visit_attribute_mut(it); } - tokens_helper(v, &mut node.break_token.span); + skip!(node.break_token); if let Some(it) = &mut node.label { v.visit_lifetime_mut(it); } @@ -1346,13 +1301,10 @@ where v.visit_attribute_mut(it); } v.visit_expr_mut(&mut *node.func); - tokens_helper(v, &mut node.paren_token.span); - for el in Punctuated::pairs_mut(&mut node.args) { - let (it, p) = el.into_tuple(); + skip!(node.paren_token); + for mut el in Punctuated::pairs_mut(&mut node.args) { + let it = el.value_mut(); v.visit_expr_mut(it); - if let Some(p) = p { - tokens_helper(v, &mut p.spans); - } } } #[cfg(any(feature = "derive", feature = "full"))] @@ -1364,7 +1316,7 @@ where v.visit_attribute_mut(it); } v.visit_expr_mut(&mut *node.expr); - tokens_helper(v, &mut node.as_token.span); + skip!(node.as_token); v.visit_type_mut(&mut *node.ty); } #[cfg(feature = "full")] @@ -1375,28 +1327,34 @@ where for it in &mut node.attrs { v.visit_attribute_mut(it); } - if let Some(it) = &mut node.movability { - tokens_helper(v, &mut it.span); - } - if let Some(it) = &mut node.asyncness { - tokens_helper(v, &mut it.span); - } - if let Some(it) = &mut node.capture { - tokens_helper(v, &mut it.span); + if let Some(it) = &mut node.lifetimes { + v.visit_bound_lifetimes_mut(it); } - tokens_helper(v, &mut node.or1_token.spans); - for el in Punctuated::pairs_mut(&mut node.inputs) { - let (it, p) = el.into_tuple(); + skip!(node.constness); + skip!(node.movability); + skip!(node.asyncness); + skip!(node.capture); + skip!(node.or1_token); + for mut el in Punctuated::pairs_mut(&mut node.inputs) { + let it = el.value_mut(); v.visit_pat_mut(it); - if let Some(p) = p { - tokens_helper(v, &mut p.spans); - } } - tokens_helper(v, &mut node.or2_token.spans); + skip!(node.or2_token); v.visit_return_type_mut(&mut node.output); v.visit_expr_mut(&mut *node.body); } #[cfg(feature = "full")] +pub fn visit_expr_const_mut<V>(v: &mut V, node: &mut ExprConst) +where + V: VisitMut + ?Sized, +{ + for it in &mut node.attrs { + v.visit_attribute_mut(it); + } + skip!(node.const_token); + v.visit_block_mut(&mut node.block); +} +#[cfg(feature = "full")] pub fn visit_expr_continue_mut<V>(v: &mut V, node: &mut ExprContinue) where V: VisitMut + ?Sized, @@ -1404,7 +1362,7 @@ where for it in &mut node.attrs { v.visit_attribute_mut(it); } - tokens_helper(v, &mut node.continue_token.span); + skip!(node.continue_token); if let Some(it) = &mut node.label { v.visit_lifetime_mut(it); } @@ -1418,7 +1376,7 @@ where v.visit_attribute_mut(it); } v.visit_expr_mut(&mut *node.base); - tokens_helper(v, &mut node.dot_token.spans); + skip!(node.dot_token); v.visit_member_mut(&mut node.member); } #[cfg(feature = "full")] @@ -1432,13 +1390,13 @@ where if let Some(it) = &mut node.label { v.visit_label_mut(it); } - tokens_helper(v, &mut node.for_token.span); - v.visit_pat_mut(&mut node.pat); - tokens_helper(v, &mut node.in_token.span); + skip!(node.for_token); + v.visit_pat_mut(&mut *node.pat); + skip!(node.in_token); v.visit_expr_mut(&mut *node.expr); v.visit_block_mut(&mut node.body); } -#[cfg(feature = "full")] +#[cfg(any(feature = "derive", feature = "full"))] pub fn visit_expr_group_mut<V>(v: &mut V, node: &mut ExprGroup) where V: VisitMut + ?Sized, @@ -1446,7 +1404,7 @@ where for it in &mut node.attrs { v.visit_attribute_mut(it); } - tokens_helper(v, &mut node.group_token.span); + skip!(node.group_token); v.visit_expr_mut(&mut *node.expr); } #[cfg(feature = "full")] @@ -1457,11 +1415,11 @@ where for it in &mut node.attrs { v.visit_attribute_mut(it); } - tokens_helper(v, &mut node.if_token.span); + skip!(node.if_token); v.visit_expr_mut(&mut *node.cond); v.visit_block_mut(&mut node.then_branch); if let Some(it) = &mut node.else_branch { - tokens_helper(v, &mut (it).0.span); + skip!((it).0); v.visit_expr_mut(&mut *(it).1); } } @@ -1474,10 +1432,20 @@ where v.visit_attribute_mut(it); } v.visit_expr_mut(&mut *node.expr); - tokens_helper(v, &mut node.bracket_token.span); + skip!(node.bracket_token); v.visit_expr_mut(&mut *node.index); } #[cfg(feature = "full")] +pub fn visit_expr_infer_mut<V>(v: &mut V, node: &mut ExprInfer) +where + V: VisitMut + ?Sized, +{ + for it in &mut node.attrs { + v.visit_attribute_mut(it); + } + skip!(node.underscore_token); +} +#[cfg(feature = "full")] pub fn visit_expr_let_mut<V>(v: &mut V, node: &mut ExprLet) where V: VisitMut + ?Sized, @@ -1485,9 +1453,9 @@ where for it in &mut node.attrs { v.visit_attribute_mut(it); } - tokens_helper(v, &mut node.let_token.span); - v.visit_pat_mut(&mut node.pat); - tokens_helper(v, &mut node.eq_token.spans); + skip!(node.let_token); + v.visit_pat_mut(&mut *node.pat); + skip!(node.eq_token); v.visit_expr_mut(&mut *node.expr); } #[cfg(any(feature = "derive", feature = "full"))] @@ -1511,10 +1479,10 @@ where if let Some(it) = &mut node.label { v.visit_label_mut(it); } - tokens_helper(v, &mut node.loop_token.span); + skip!(node.loop_token); v.visit_block_mut(&mut node.body); } -#[cfg(feature = "full")] +#[cfg(any(feature = "derive", feature = "full"))] pub fn visit_expr_macro_mut<V>(v: &mut V, node: &mut ExprMacro) where V: VisitMut + ?Sized, @@ -1532,9 +1500,9 @@ where for it in &mut node.attrs { v.visit_attribute_mut(it); } - tokens_helper(v, &mut node.match_token.span); + skip!(node.match_token); v.visit_expr_mut(&mut *node.expr); - tokens_helper(v, &mut node.brace_token.span); + skip!(node.brace_token); for it in &mut node.arms { v.visit_arm_mut(it); } @@ -1548,18 +1516,15 @@ where v.visit_attribute_mut(it); } v.visit_expr_mut(&mut *node.receiver); - tokens_helper(v, &mut node.dot_token.spans); + skip!(node.dot_token); v.visit_ident_mut(&mut node.method); if let Some(it) = &mut node.turbofish { - v.visit_method_turbofish_mut(it); + v.visit_angle_bracketed_generic_arguments_mut(it); } - tokens_helper(v, &mut node.paren_token.span); - for el in Punctuated::pairs_mut(&mut node.args) { - let (it, p) = el.into_tuple(); + skip!(node.paren_token); + for mut el in Punctuated::pairs_mut(&mut node.args) { + let it = el.value_mut(); v.visit_expr_mut(it); - if let Some(p) = p { - tokens_helper(v, &mut p.spans); - } } } #[cfg(any(feature = "derive", feature = "full"))] @@ -1570,7 +1535,7 @@ where for it in &mut node.attrs { v.visit_attribute_mut(it); } - tokens_helper(v, &mut node.paren_token.span); + skip!(node.paren_token); v.visit_expr_mut(&mut *node.expr); } #[cfg(any(feature = "derive", feature = "full"))] @@ -1594,11 +1559,11 @@ where for it in &mut node.attrs { v.visit_attribute_mut(it); } - if let Some(it) = &mut node.from { + if let Some(it) = &mut node.start { v.visit_expr_mut(&mut **it); } v.visit_range_limits_mut(&mut node.limits); - if let Some(it) = &mut node.to { + if let Some(it) = &mut node.end { v.visit_expr_mut(&mut **it); } } @@ -1610,10 +1575,8 @@ where for it in &mut node.attrs { v.visit_attribute_mut(it); } - tokens_helper(v, &mut node.and_token.spans); - if let Some(it) = &mut node.mutability { - tokens_helper(v, &mut it.span); - } + skip!(node.and_token); + skip!(node.mutability); v.visit_expr_mut(&mut *node.expr); } #[cfg(feature = "full")] @@ -1624,9 +1587,9 @@ where for it in &mut node.attrs { v.visit_attribute_mut(it); } - tokens_helper(v, &mut node.bracket_token.span); + skip!(node.bracket_token); v.visit_expr_mut(&mut *node.expr); - tokens_helper(v, &mut node.semi_token.spans); + skip!(node.semi_token); v.visit_expr_mut(&mut *node.len); } #[cfg(feature = "full")] @@ -1637,7 +1600,7 @@ where for it in &mut node.attrs { v.visit_attribute_mut(it); } - tokens_helper(v, &mut node.return_token.span); + skip!(node.return_token); if let Some(it) = &mut node.expr { v.visit_expr_mut(&mut **it); } @@ -1650,18 +1613,16 @@ where for it in &mut node.attrs { v.visit_attribute_mut(it); } + if let Some(it) = &mut node.qself { + v.visit_qself_mut(it); + } v.visit_path_mut(&mut node.path); - tokens_helper(v, &mut node.brace_token.span); - for el in Punctuated::pairs_mut(&mut node.fields) { - let (it, p) = el.into_tuple(); + skip!(node.brace_token); + for mut el in Punctuated::pairs_mut(&mut node.fields) { + let it = el.value_mut(); v.visit_field_value_mut(it); - if let Some(p) = p { - tokens_helper(v, &mut p.spans); - } - } - if let Some(it) = &mut node.dot2_token { - tokens_helper(v, &mut it.spans); } + skip!(node.dot2_token); if let Some(it) = &mut node.rest { v.visit_expr_mut(&mut **it); } @@ -1675,7 +1636,7 @@ where v.visit_attribute_mut(it); } v.visit_expr_mut(&mut *node.expr); - tokens_helper(v, &mut node.question_token.spans); + skip!(node.question_token); } #[cfg(feature = "full")] pub fn visit_expr_try_block_mut<V>(v: &mut V, node: &mut ExprTryBlock) @@ -1685,7 +1646,7 @@ where for it in &mut node.attrs { v.visit_attribute_mut(it); } - tokens_helper(v, &mut node.try_token.span); + skip!(node.try_token); v.visit_block_mut(&mut node.block); } #[cfg(feature = "full")] @@ -1696,26 +1657,11 @@ where for it in &mut node.attrs { v.visit_attribute_mut(it); } - tokens_helper(v, &mut node.paren_token.span); - for el in Punctuated::pairs_mut(&mut node.elems) { - let (it, p) = el.into_tuple(); + skip!(node.paren_token); + for mut el in Punctuated::pairs_mut(&mut node.elems) { + let it = el.value_mut(); v.visit_expr_mut(it); - if let Some(p) = p { - tokens_helper(v, &mut p.spans); - } - } -} -#[cfg(feature = "full")] -pub fn visit_expr_type_mut<V>(v: &mut V, node: &mut ExprType) -where - V: VisitMut + ?Sized, -{ - for it in &mut node.attrs { - v.visit_attribute_mut(it); } - v.visit_expr_mut(&mut *node.expr); - tokens_helper(v, &mut node.colon_token.spans); - v.visit_type_mut(&mut *node.ty); } #[cfg(any(feature = "derive", feature = "full"))] pub fn visit_expr_unary_mut<V>(v: &mut V, node: &mut ExprUnary) @@ -1736,7 +1682,7 @@ where for it in &mut node.attrs { v.visit_attribute_mut(it); } - tokens_helper(v, &mut node.unsafe_token.span); + skip!(node.unsafe_token); v.visit_block_mut(&mut node.block); } #[cfg(feature = "full")] @@ -1750,7 +1696,7 @@ where if let Some(it) = &mut node.label { v.visit_label_mut(it); } - tokens_helper(v, &mut node.while_token.span); + skip!(node.while_token); v.visit_expr_mut(&mut *node.cond); v.visit_block_mut(&mut node.body); } @@ -1762,7 +1708,7 @@ where for it in &mut node.attrs { v.visit_attribute_mut(it); } - tokens_helper(v, &mut node.yield_token.span); + skip!(node.yield_token); if let Some(it) = &mut node.expr { v.visit_expr_mut(&mut **it); } @@ -1776,14 +1722,22 @@ where v.visit_attribute_mut(it); } v.visit_visibility_mut(&mut node.vis); + v.visit_field_mutability_mut(&mut node.mutability); if let Some(it) = &mut node.ident { v.visit_ident_mut(it); } - if let Some(it) = &mut node.colon_token { - tokens_helper(v, &mut it.spans); - } + skip!(node.colon_token); v.visit_type_mut(&mut node.ty); } +#[cfg(any(feature = "derive", feature = "full"))] +pub fn visit_field_mutability_mut<V>(v: &mut V, node: &mut FieldMutability) +where + V: VisitMut + ?Sized, +{ + match node { + FieldMutability::None => {} + } +} #[cfg(feature = "full")] pub fn visit_field_pat_mut<V>(v: &mut V, node: &mut FieldPat) where @@ -1793,9 +1747,7 @@ where v.visit_attribute_mut(it); } v.visit_member_mut(&mut node.member); - if let Some(it) = &mut node.colon_token { - tokens_helper(v, &mut it.spans); - } + skip!(node.colon_token); v.visit_pat_mut(&mut *node.pat); } #[cfg(feature = "full")] @@ -1807,9 +1759,7 @@ where v.visit_attribute_mut(it); } v.visit_member_mut(&mut node.member); - if let Some(it) = &mut node.colon_token { - tokens_helper(v, &mut it.spans); - } + skip!(node.colon_token); v.visit_expr_mut(&mut node.expr); } #[cfg(any(feature = "derive", feature = "full"))] @@ -1832,13 +1782,10 @@ pub fn visit_fields_named_mut<V>(v: &mut V, node: &mut FieldsNamed) where V: VisitMut + ?Sized, { - tokens_helper(v, &mut node.brace_token.span); - for el in Punctuated::pairs_mut(&mut node.named) { - let (it, p) = el.into_tuple(); + skip!(node.brace_token); + for mut el in Punctuated::pairs_mut(&mut node.named) { + let it = el.value_mut(); v.visit_field_mut(it); - if let Some(p) = p { - tokens_helper(v, &mut p.spans); - } } } #[cfg(any(feature = "derive", feature = "full"))] @@ -1846,13 +1793,10 @@ pub fn visit_fields_unnamed_mut<V>(v: &mut V, node: &mut FieldsUnnamed) where V: VisitMut + ?Sized, { - tokens_helper(v, &mut node.paren_token.span); - for el in Punctuated::pairs_mut(&mut node.unnamed) { - let (it, p) = el.into_tuple(); + skip!(node.paren_token); + for mut el in Punctuated::pairs_mut(&mut node.unnamed) { + let it = el.value_mut(); v.visit_field_mut(it); - if let Some(p) = p { - tokens_helper(v, &mut p.spans); - } } } #[cfg(feature = "full")] @@ -1903,8 +1847,6 @@ where ForeignItem::Verbatim(_binding_0) => { skip!(_binding_0); } - #[cfg(syn_no_non_exhaustive)] - _ => unreachable!(), } } #[cfg(feature = "full")] @@ -1917,7 +1859,7 @@ where } v.visit_visibility_mut(&mut node.vis); v.visit_signature_mut(&mut node.sig); - tokens_helper(v, &mut node.semi_token.spans); + skip!(node.semi_token); } #[cfg(feature = "full")] pub fn visit_foreign_item_macro_mut<V>(v: &mut V, node: &mut ForeignItemMacro) @@ -1928,9 +1870,7 @@ where v.visit_attribute_mut(it); } v.visit_macro_mut(&mut node.mac); - if let Some(it) = &mut node.semi_token { - tokens_helper(v, &mut it.spans); - } + skip!(node.semi_token); } #[cfg(feature = "full")] pub fn visit_foreign_item_static_mut<V>(v: &mut V, node: &mut ForeignItemStatic) @@ -1941,14 +1881,12 @@ where v.visit_attribute_mut(it); } v.visit_visibility_mut(&mut node.vis); - tokens_helper(v, &mut node.static_token.span); - if let Some(it) = &mut node.mutability { - tokens_helper(v, &mut it.span); - } + skip!(node.static_token); + v.visit_static_mutability_mut(&mut node.mutability); v.visit_ident_mut(&mut node.ident); - tokens_helper(v, &mut node.colon_token.spans); + skip!(node.colon_token); v.visit_type_mut(&mut *node.ty); - tokens_helper(v, &mut node.semi_token.spans); + skip!(node.semi_token); } #[cfg(feature = "full")] pub fn visit_foreign_item_type_mut<V>(v: &mut V, node: &mut ForeignItemType) @@ -1959,9 +1897,10 @@ where v.visit_attribute_mut(it); } v.visit_visibility_mut(&mut node.vis); - tokens_helper(v, &mut node.type_token.span); + skip!(node.type_token); v.visit_ident_mut(&mut node.ident); - tokens_helper(v, &mut node.semi_token.spans); + v.visit_generics_mut(&mut node.generics); + skip!(node.semi_token); } #[cfg(any(feature = "derive", feature = "full"))] pub fn visit_generic_argument_mut<V>(v: &mut V, node: &mut GenericArgument) @@ -1978,40 +1917,29 @@ where GenericArgument::Const(_binding_0) => { v.visit_expr_mut(_binding_0); } - GenericArgument::Binding(_binding_0) => { - v.visit_binding_mut(_binding_0); + GenericArgument::AssocType(_binding_0) => { + v.visit_assoc_type_mut(_binding_0); + } + GenericArgument::AssocConst(_binding_0) => { + v.visit_assoc_const_mut(_binding_0); } GenericArgument::Constraint(_binding_0) => { v.visit_constraint_mut(_binding_0); } } } -#[cfg(feature = "full")] -pub fn visit_generic_method_argument_mut<V>(v: &mut V, node: &mut GenericMethodArgument) -where - V: VisitMut + ?Sized, -{ - match node { - GenericMethodArgument::Type(_binding_0) => { - v.visit_type_mut(_binding_0); - } - GenericMethodArgument::Const(_binding_0) => { - v.visit_expr_mut(_binding_0); - } - } -} #[cfg(any(feature = "derive", feature = "full"))] pub fn visit_generic_param_mut<V>(v: &mut V, node: &mut GenericParam) where V: VisitMut + ?Sized, { match node { + GenericParam::Lifetime(_binding_0) => { + v.visit_lifetime_param_mut(_binding_0); + } GenericParam::Type(_binding_0) => { v.visit_type_param_mut(_binding_0); } - GenericParam::Lifetime(_binding_0) => { - v.visit_lifetime_def_mut(_binding_0); - } GenericParam::Const(_binding_0) => { v.visit_const_param_mut(_binding_0); } @@ -2022,19 +1950,12 @@ pub fn visit_generics_mut<V>(v: &mut V, node: &mut Generics) where V: VisitMut + ?Sized, { - if let Some(it) = &mut node.lt_token { - tokens_helper(v, &mut it.spans); - } - for el in Punctuated::pairs_mut(&mut node.params) { - let (it, p) = el.into_tuple(); + skip!(node.lt_token); + for mut el in Punctuated::pairs_mut(&mut node.params) { + let it = el.value_mut(); v.visit_generic_param_mut(it); - if let Some(p) = p { - tokens_helper(v, &mut p.spans); - } - } - if let Some(it) = &mut node.gt_token { - tokens_helper(v, &mut it.spans); } + skip!(node.gt_token); if let Some(it) = &mut node.where_clause { v.visit_where_clause_mut(it); } @@ -2056,8 +1977,8 @@ where ImplItem::Const(_binding_0) => { v.visit_impl_item_const_mut(_binding_0); } - ImplItem::Method(_binding_0) => { - v.visit_impl_item_method_mut(_binding_0); + ImplItem::Fn(_binding_0) => { + v.visit_impl_item_fn_mut(_binding_0); } ImplItem::Type(_binding_0) => { v.visit_impl_item_type_mut(_binding_0); @@ -2068,8 +1989,6 @@ where ImplItem::Verbatim(_binding_0) => { skip!(_binding_0); } - #[cfg(syn_no_non_exhaustive)] - _ => unreachable!(), } } #[cfg(feature = "full")] @@ -2081,44 +2000,39 @@ where v.visit_attribute_mut(it); } v.visit_visibility_mut(&mut node.vis); - if let Some(it) = &mut node.defaultness { - tokens_helper(v, &mut it.span); - } - tokens_helper(v, &mut node.const_token.span); + skip!(node.defaultness); + skip!(node.const_token); v.visit_ident_mut(&mut node.ident); - tokens_helper(v, &mut node.colon_token.spans); + v.visit_generics_mut(&mut node.generics); + skip!(node.colon_token); v.visit_type_mut(&mut node.ty); - tokens_helper(v, &mut node.eq_token.spans); + skip!(node.eq_token); v.visit_expr_mut(&mut node.expr); - tokens_helper(v, &mut node.semi_token.spans); + skip!(node.semi_token); } #[cfg(feature = "full")] -pub fn visit_impl_item_macro_mut<V>(v: &mut V, node: &mut ImplItemMacro) +pub fn visit_impl_item_fn_mut<V>(v: &mut V, node: &mut ImplItemFn) where V: VisitMut + ?Sized, { for it in &mut node.attrs { v.visit_attribute_mut(it); } - v.visit_macro_mut(&mut node.mac); - if let Some(it) = &mut node.semi_token { - tokens_helper(v, &mut it.spans); - } + v.visit_visibility_mut(&mut node.vis); + skip!(node.defaultness); + v.visit_signature_mut(&mut node.sig); + v.visit_block_mut(&mut node.block); } #[cfg(feature = "full")] -pub fn visit_impl_item_method_mut<V>(v: &mut V, node: &mut ImplItemMethod) +pub fn visit_impl_item_macro_mut<V>(v: &mut V, node: &mut ImplItemMacro) where V: VisitMut + ?Sized, { for it in &mut node.attrs { v.visit_attribute_mut(it); } - v.visit_visibility_mut(&mut node.vis); - if let Some(it) = &mut node.defaultness { - tokens_helper(v, &mut it.span); - } - v.visit_signature_mut(&mut node.sig); - v.visit_block_mut(&mut node.block); + v.visit_macro_mut(&mut node.mac); + skip!(node.semi_token); } #[cfg(feature = "full")] pub fn visit_impl_item_type_mut<V>(v: &mut V, node: &mut ImplItemType) @@ -2129,15 +2043,20 @@ where v.visit_attribute_mut(it); } v.visit_visibility_mut(&mut node.vis); - if let Some(it) = &mut node.defaultness { - tokens_helper(v, &mut it.span); - } - tokens_helper(v, &mut node.type_token.span); + skip!(node.defaultness); + skip!(node.type_token); v.visit_ident_mut(&mut node.ident); v.visit_generics_mut(&mut node.generics); - tokens_helper(v, &mut node.eq_token.spans); + skip!(node.eq_token); v.visit_type_mut(&mut node.ty); - tokens_helper(v, &mut node.semi_token.spans); + skip!(node.semi_token); +} +#[cfg(feature = "full")] +pub fn visit_impl_restriction_mut<V>(v: &mut V, node: &mut ImplRestriction) +where + V: VisitMut + ?Sized, +{ + match *node {} } #[cfg(any(feature = "derive", feature = "full"))] pub fn visit_index_mut<V>(v: &mut V, node: &mut Index) @@ -2174,9 +2093,6 @@ where Item::Macro(_binding_0) => { v.visit_item_macro_mut(_binding_0); } - Item::Macro2(_binding_0) => { - v.visit_item_macro2_mut(_binding_0); - } Item::Mod(_binding_0) => { v.visit_item_mod_mut(_binding_0); } @@ -2204,8 +2120,6 @@ where Item::Verbatim(_binding_0) => { skip!(_binding_0); } - #[cfg(syn_no_non_exhaustive)] - _ => unreachable!(), } } #[cfg(feature = "full")] @@ -2217,13 +2131,14 @@ where v.visit_attribute_mut(it); } v.visit_visibility_mut(&mut node.vis); - tokens_helper(v, &mut node.const_token.span); + skip!(node.const_token); v.visit_ident_mut(&mut node.ident); - tokens_helper(v, &mut node.colon_token.spans); + v.visit_generics_mut(&mut node.generics); + skip!(node.colon_token); v.visit_type_mut(&mut *node.ty); - tokens_helper(v, &mut node.eq_token.spans); + skip!(node.eq_token); v.visit_expr_mut(&mut *node.expr); - tokens_helper(v, &mut node.semi_token.spans); + skip!(node.semi_token); } #[cfg(feature = "full")] pub fn visit_item_enum_mut<V>(v: &mut V, node: &mut ItemEnum) @@ -2234,16 +2149,13 @@ where v.visit_attribute_mut(it); } v.visit_visibility_mut(&mut node.vis); - tokens_helper(v, &mut node.enum_token.span); + skip!(node.enum_token); v.visit_ident_mut(&mut node.ident); v.visit_generics_mut(&mut node.generics); - tokens_helper(v, &mut node.brace_token.span); - for el in Punctuated::pairs_mut(&mut node.variants) { - let (it, p) = el.into_tuple(); + skip!(node.brace_token); + for mut el in Punctuated::pairs_mut(&mut node.variants) { + let it = el.value_mut(); v.visit_variant_mut(it); - if let Some(p) = p { - tokens_helper(v, &mut p.spans); - } } } #[cfg(feature = "full")] @@ -2255,14 +2167,14 @@ where v.visit_attribute_mut(it); } v.visit_visibility_mut(&mut node.vis); - tokens_helper(v, &mut node.extern_token.span); - tokens_helper(v, &mut node.crate_token.span); + skip!(node.extern_token); + skip!(node.crate_token); v.visit_ident_mut(&mut node.ident); if let Some(it) = &mut node.rename { - tokens_helper(v, &mut (it).0.span); + skip!((it).0); v.visit_ident_mut(&mut (it).1); } - tokens_helper(v, &mut node.semi_token.spans); + skip!(node.semi_token); } #[cfg(feature = "full")] pub fn visit_item_fn_mut<V>(v: &mut V, node: &mut ItemFn) @@ -2284,8 +2196,9 @@ where for it in &mut node.attrs { v.visit_attribute_mut(it); } + skip!(node.unsafety); v.visit_abi_mut(&mut node.abi); - tokens_helper(v, &mut node.brace_token.span); + skip!(node.brace_token); for it in &mut node.items { v.visit_foreign_item_mut(it); } @@ -2298,23 +2211,17 @@ where for it in &mut node.attrs { v.visit_attribute_mut(it); } - if let Some(it) = &mut node.defaultness { - tokens_helper(v, &mut it.span); - } - if let Some(it) = &mut node.unsafety { - tokens_helper(v, &mut it.span); - } - tokens_helper(v, &mut node.impl_token.span); + skip!(node.defaultness); + skip!(node.unsafety); + skip!(node.impl_token); v.visit_generics_mut(&mut node.generics); if let Some(it) = &mut node.trait_ { - if let Some(it) = &mut (it).0 { - tokens_helper(v, &mut it.spans); - } + skip!((it).0); v.visit_path_mut(&mut (it).1); - tokens_helper(v, &mut (it).2.span); + skip!((it).2); } v.visit_type_mut(&mut *node.self_ty); - tokens_helper(v, &mut node.brace_token.span); + skip!(node.brace_token); for it in &mut node.items { v.visit_impl_item_mut(it); } @@ -2331,22 +2238,7 @@ where v.visit_ident_mut(it); } v.visit_macro_mut(&mut node.mac); - if let Some(it) = &mut node.semi_token { - tokens_helper(v, &mut it.spans); - } -} -#[cfg(feature = "full")] -pub fn visit_item_macro2_mut<V>(v: &mut V, node: &mut ItemMacro2) -where - V: VisitMut + ?Sized, -{ - for it in &mut node.attrs { - v.visit_attribute_mut(it); - } - v.visit_visibility_mut(&mut node.vis); - tokens_helper(v, &mut node.macro_token.span); - v.visit_ident_mut(&mut node.ident); - skip!(node.rules); + skip!(node.semi_token); } #[cfg(feature = "full")] pub fn visit_item_mod_mut<V>(v: &mut V, node: &mut ItemMod) @@ -2357,17 +2249,16 @@ where v.visit_attribute_mut(it); } v.visit_visibility_mut(&mut node.vis); - tokens_helper(v, &mut node.mod_token.span); + skip!(node.unsafety); + skip!(node.mod_token); v.visit_ident_mut(&mut node.ident); if let Some(it) = &mut node.content { - tokens_helper(v, &mut (it).0.span); + skip!((it).0); for it in &mut (it).1 { v.visit_item_mut(it); } } - if let Some(it) = &mut node.semi { - tokens_helper(v, &mut it.spans); - } + skip!(node.semi); } #[cfg(feature = "full")] pub fn visit_item_static_mut<V>(v: &mut V, node: &mut ItemStatic) @@ -2378,16 +2269,14 @@ where v.visit_attribute_mut(it); } v.visit_visibility_mut(&mut node.vis); - tokens_helper(v, &mut node.static_token.span); - if let Some(it) = &mut node.mutability { - tokens_helper(v, &mut it.span); - } + skip!(node.static_token); + v.visit_static_mutability_mut(&mut node.mutability); v.visit_ident_mut(&mut node.ident); - tokens_helper(v, &mut node.colon_token.spans); + skip!(node.colon_token); v.visit_type_mut(&mut *node.ty); - tokens_helper(v, &mut node.eq_token.spans); + skip!(node.eq_token); v.visit_expr_mut(&mut *node.expr); - tokens_helper(v, &mut node.semi_token.spans); + skip!(node.semi_token); } #[cfg(feature = "full")] pub fn visit_item_struct_mut<V>(v: &mut V, node: &mut ItemStruct) @@ -2398,13 +2287,11 @@ where v.visit_attribute_mut(it); } v.visit_visibility_mut(&mut node.vis); - tokens_helper(v, &mut node.struct_token.span); + skip!(node.struct_token); v.visit_ident_mut(&mut node.ident); v.visit_generics_mut(&mut node.generics); v.visit_fields_mut(&mut node.fields); - if let Some(it) = &mut node.semi_token { - tokens_helper(v, &mut it.spans); - } + skip!(node.semi_token); } #[cfg(feature = "full")] pub fn visit_item_trait_mut<V>(v: &mut V, node: &mut ItemTrait) @@ -2415,26 +2302,20 @@ where v.visit_attribute_mut(it); } v.visit_visibility_mut(&mut node.vis); - if let Some(it) = &mut node.unsafety { - tokens_helper(v, &mut it.span); + skip!(node.unsafety); + skip!(node.auto_token); + if let Some(it) = &mut node.restriction { + v.visit_impl_restriction_mut(it); } - if let Some(it) = &mut node.auto_token { - tokens_helper(v, &mut it.span); - } - tokens_helper(v, &mut node.trait_token.span); + skip!(node.trait_token); v.visit_ident_mut(&mut node.ident); v.visit_generics_mut(&mut node.generics); - if let Some(it) = &mut node.colon_token { - tokens_helper(v, &mut it.spans); - } - for el in Punctuated::pairs_mut(&mut node.supertraits) { - let (it, p) = el.into_tuple(); + skip!(node.colon_token); + for mut el in Punctuated::pairs_mut(&mut node.supertraits) { + let it = el.value_mut(); v.visit_type_param_bound_mut(it); - if let Some(p) = p { - tokens_helper(v, &mut p.spans); - } } - tokens_helper(v, &mut node.brace_token.span); + skip!(node.brace_token); for it in &mut node.items { v.visit_trait_item_mut(it); } @@ -2448,18 +2329,15 @@ where v.visit_attribute_mut(it); } v.visit_visibility_mut(&mut node.vis); - tokens_helper(v, &mut node.trait_token.span); + skip!(node.trait_token); v.visit_ident_mut(&mut node.ident); v.visit_generics_mut(&mut node.generics); - tokens_helper(v, &mut node.eq_token.spans); - for el in Punctuated::pairs_mut(&mut node.bounds) { - let (it, p) = el.into_tuple(); + skip!(node.eq_token); + for mut el in Punctuated::pairs_mut(&mut node.bounds) { + let it = el.value_mut(); v.visit_type_param_bound_mut(it); - if let Some(p) = p { - tokens_helper(v, &mut p.spans); - } } - tokens_helper(v, &mut node.semi_token.spans); + skip!(node.semi_token); } #[cfg(feature = "full")] pub fn visit_item_type_mut<V>(v: &mut V, node: &mut ItemType) @@ -2470,12 +2348,12 @@ where v.visit_attribute_mut(it); } v.visit_visibility_mut(&mut node.vis); - tokens_helper(v, &mut node.type_token.span); + skip!(node.type_token); v.visit_ident_mut(&mut node.ident); v.visit_generics_mut(&mut node.generics); - tokens_helper(v, &mut node.eq_token.spans); + skip!(node.eq_token); v.visit_type_mut(&mut *node.ty); - tokens_helper(v, &mut node.semi_token.spans); + skip!(node.semi_token); } #[cfg(feature = "full")] pub fn visit_item_union_mut<V>(v: &mut V, node: &mut ItemUnion) @@ -2486,7 +2364,7 @@ where v.visit_attribute_mut(it); } v.visit_visibility_mut(&mut node.vis); - tokens_helper(v, &mut node.union_token.span); + skip!(node.union_token); v.visit_ident_mut(&mut node.ident); v.visit_generics_mut(&mut node.generics); v.visit_fields_named_mut(&mut node.fields); @@ -2500,12 +2378,10 @@ where v.visit_attribute_mut(it); } v.visit_visibility_mut(&mut node.vis); - tokens_helper(v, &mut node.use_token.span); - if let Some(it) = &mut node.leading_colon { - tokens_helper(v, &mut it.spans); - } + skip!(node.use_token); + skip!(node.leading_colon); v.visit_use_tree_mut(&mut node.tree); - tokens_helper(v, &mut node.semi_token.spans); + skip!(node.semi_token); } #[cfg(feature = "full")] pub fn visit_label_mut<V>(v: &mut V, node: &mut Label) @@ -2513,7 +2389,7 @@ where V: VisitMut + ?Sized, { v.visit_lifetime_mut(&mut node.name); - tokens_helper(v, &mut node.colon_token.spans); + skip!(node.colon_token); } pub fn visit_lifetime_mut<V>(v: &mut V, node: &mut Lifetime) where @@ -2523,7 +2399,7 @@ where v.visit_ident_mut(&mut node.ident); } #[cfg(any(feature = "derive", feature = "full"))] -pub fn visit_lifetime_def_mut<V>(v: &mut V, node: &mut LifetimeDef) +pub fn visit_lifetime_param_mut<V>(v: &mut V, node: &mut LifetimeParam) where V: VisitMut + ?Sized, { @@ -2531,15 +2407,10 @@ where v.visit_attribute_mut(it); } v.visit_lifetime_mut(&mut node.lifetime); - if let Some(it) = &mut node.colon_token { - tokens_helper(v, &mut it.spans); - } - for el in Punctuated::pairs_mut(&mut node.bounds) { - let (it, p) = el.into_tuple(); + skip!(node.colon_token); + for mut el in Punctuated::pairs_mut(&mut node.bounds) { + let it = el.value_mut(); v.visit_lifetime_mut(it); - if let Some(p) = p { - tokens_helper(v, &mut p.spans); - } } } pub fn visit_lit_mut<V>(v: &mut V, node: &mut Lit) @@ -2612,13 +2483,24 @@ where for it in &mut node.attrs { v.visit_attribute_mut(it); } - tokens_helper(v, &mut node.let_token.span); + skip!(node.let_token); v.visit_pat_mut(&mut node.pat); if let Some(it) = &mut node.init { - tokens_helper(v, &mut (it).0.spans); + v.visit_local_init_mut(it); + } + skip!(node.semi_token); +} +#[cfg(feature = "full")] +pub fn visit_local_init_mut<V>(v: &mut V, node: &mut LocalInit) +where + V: VisitMut + ?Sized, +{ + skip!(node.eq_token); + v.visit_expr_mut(&mut *node.expr); + if let Some(it) = &mut node.diverge { + skip!((it).0); v.visit_expr_mut(&mut *(it).1); } - tokens_helper(v, &mut node.semi_token.spans); } #[cfg(any(feature = "derive", feature = "full"))] pub fn visit_macro_mut<V>(v: &mut V, node: &mut Macro) @@ -2626,7 +2508,7 @@ where V: VisitMut + ?Sized, { v.visit_path_mut(&mut node.path); - tokens_helper(v, &mut node.bang_token.spans); + skip!(node.bang_token); v.visit_macro_delimiter_mut(&mut node.delimiter); skip!(node.tokens); } @@ -2637,13 +2519,13 @@ where { match node { MacroDelimiter::Paren(_binding_0) => { - tokens_helper(v, &mut _binding_0.span); + skip!(_binding_0); } MacroDelimiter::Brace(_binding_0) => { - tokens_helper(v, &mut _binding_0.span); + skip!(_binding_0); } MacroDelimiter::Bracket(_binding_0) => { - tokens_helper(v, &mut _binding_0.span); + skip!(_binding_0); } } } @@ -2684,14 +2566,8 @@ where V: VisitMut + ?Sized, { v.visit_path_mut(&mut node.path); - tokens_helper(v, &mut node.paren_token.span); - for el in Punctuated::pairs_mut(&mut node.nested) { - let (it, p) = el.into_tuple(); - v.visit_nested_meta_mut(it); - if let Some(p) = p { - tokens_helper(v, &mut p.spans); - } - } + v.visit_macro_delimiter_mut(&mut node.delimiter); + skip!(node.tokens); } #[cfg(any(feature = "derive", feature = "full"))] pub fn visit_meta_name_value_mut<V>(v: &mut V, node: &mut MetaNameValue) @@ -2699,38 +2575,8 @@ where V: VisitMut + ?Sized, { v.visit_path_mut(&mut node.path); - tokens_helper(v, &mut node.eq_token.spans); - v.visit_lit_mut(&mut node.lit); -} -#[cfg(feature = "full")] -pub fn visit_method_turbofish_mut<V>(v: &mut V, node: &mut MethodTurbofish) -where - V: VisitMut + ?Sized, -{ - tokens_helper(v, &mut node.colon2_token.spans); - tokens_helper(v, &mut node.lt_token.spans); - for el in Punctuated::pairs_mut(&mut node.args) { - let (it, p) = el.into_tuple(); - v.visit_generic_method_argument_mut(it); - if let Some(p) = p { - tokens_helper(v, &mut p.spans); - } - } - tokens_helper(v, &mut node.gt_token.spans); -} -#[cfg(any(feature = "derive", feature = "full"))] -pub fn visit_nested_meta_mut<V>(v: &mut V, node: &mut NestedMeta) -where - V: VisitMut + ?Sized, -{ - match node { - NestedMeta::Meta(_binding_0) => { - v.visit_meta_mut(_binding_0); - } - NestedMeta::Lit(_binding_0) => { - v.visit_lit_mut(_binding_0); - } - } + skip!(node.eq_token); + v.visit_expr_mut(&mut node.value); } #[cfg(any(feature = "derive", feature = "full"))] pub fn visit_parenthesized_generic_arguments_mut<V>( @@ -2740,13 +2586,10 @@ pub fn visit_parenthesized_generic_arguments_mut<V>( where V: VisitMut + ?Sized, { - tokens_helper(v, &mut node.paren_token.span); - for el in Punctuated::pairs_mut(&mut node.inputs) { - let (it, p) = el.into_tuple(); + skip!(node.paren_token); + for mut el in Punctuated::pairs_mut(&mut node.inputs) { + let it = el.value_mut(); v.visit_type_mut(it); - if let Some(p) = p { - tokens_helper(v, &mut p.spans); - } } v.visit_return_type_mut(&mut node.output); } @@ -2756,26 +2599,29 @@ where V: VisitMut + ?Sized, { match node { - Pat::Box(_binding_0) => { - v.visit_pat_box_mut(_binding_0); + Pat::Const(_binding_0) => { + v.visit_expr_const_mut(_binding_0); } Pat::Ident(_binding_0) => { v.visit_pat_ident_mut(_binding_0); } Pat::Lit(_binding_0) => { - v.visit_pat_lit_mut(_binding_0); + v.visit_expr_lit_mut(_binding_0); } Pat::Macro(_binding_0) => { - v.visit_pat_macro_mut(_binding_0); + v.visit_expr_macro_mut(_binding_0); } Pat::Or(_binding_0) => { v.visit_pat_or_mut(_binding_0); } + Pat::Paren(_binding_0) => { + v.visit_pat_paren_mut(_binding_0); + } Pat::Path(_binding_0) => { - v.visit_pat_path_mut(_binding_0); + v.visit_expr_path_mut(_binding_0); } Pat::Range(_binding_0) => { - v.visit_pat_range_mut(_binding_0); + v.visit_expr_range_mut(_binding_0); } Pat::Reference(_binding_0) => { v.visit_pat_reference_mut(_binding_0); @@ -2804,20 +2650,7 @@ where Pat::Wild(_binding_0) => { v.visit_pat_wild_mut(_binding_0); } - #[cfg(syn_no_non_exhaustive)] - _ => unreachable!(), - } -} -#[cfg(feature = "full")] -pub fn visit_pat_box_mut<V>(v: &mut V, node: &mut PatBox) -where - V: VisitMut + ?Sized, -{ - for it in &mut node.attrs { - v.visit_attribute_mut(it); } - tokens_helper(v, &mut node.box_token.span); - v.visit_pat_mut(&mut *node.pat); } #[cfg(feature = "full")] pub fn visit_pat_ident_mut<V>(v: &mut V, node: &mut PatIdent) @@ -2827,39 +2660,15 @@ where for it in &mut node.attrs { v.visit_attribute_mut(it); } - if let Some(it) = &mut node.by_ref { - tokens_helper(v, &mut it.span); - } - if let Some(it) = &mut node.mutability { - tokens_helper(v, &mut it.span); - } + skip!(node.by_ref); + skip!(node.mutability); v.visit_ident_mut(&mut node.ident); if let Some(it) = &mut node.subpat { - tokens_helper(v, &mut (it).0.spans); + skip!((it).0); v.visit_pat_mut(&mut *(it).1); } } #[cfg(feature = "full")] -pub fn visit_pat_lit_mut<V>(v: &mut V, node: &mut PatLit) -where - V: VisitMut + ?Sized, -{ - for it in &mut node.attrs { - v.visit_attribute_mut(it); - } - v.visit_expr_mut(&mut *node.expr); -} -#[cfg(feature = "full")] -pub fn visit_pat_macro_mut<V>(v: &mut V, node: &mut PatMacro) -where - V: VisitMut + ?Sized, -{ - for it in &mut node.attrs { - v.visit_attribute_mut(it); - } - v.visit_macro_mut(&mut node.mac); -} -#[cfg(feature = "full")] pub fn visit_pat_or_mut<V>(v: &mut V, node: &mut PatOr) where V: VisitMut + ?Sized, @@ -2867,41 +2676,22 @@ where for it in &mut node.attrs { v.visit_attribute_mut(it); } - if let Some(it) = &mut node.leading_vert { - tokens_helper(v, &mut it.spans); - } - for el in Punctuated::pairs_mut(&mut node.cases) { - let (it, p) = el.into_tuple(); + skip!(node.leading_vert); + for mut el in Punctuated::pairs_mut(&mut node.cases) { + let it = el.value_mut(); v.visit_pat_mut(it); - if let Some(p) = p { - tokens_helper(v, &mut p.spans); - } - } -} -#[cfg(feature = "full")] -pub fn visit_pat_path_mut<V>(v: &mut V, node: &mut PatPath) -where - V: VisitMut + ?Sized, -{ - for it in &mut node.attrs { - v.visit_attribute_mut(it); - } - if let Some(it) = &mut node.qself { - v.visit_qself_mut(it); } - v.visit_path_mut(&mut node.path); } #[cfg(feature = "full")] -pub fn visit_pat_range_mut<V>(v: &mut V, node: &mut PatRange) +pub fn visit_pat_paren_mut<V>(v: &mut V, node: &mut PatParen) where V: VisitMut + ?Sized, { for it in &mut node.attrs { v.visit_attribute_mut(it); } - v.visit_expr_mut(&mut *node.lo); - v.visit_range_limits_mut(&mut node.limits); - v.visit_expr_mut(&mut *node.hi); + skip!(node.paren_token); + v.visit_pat_mut(&mut *node.pat); } #[cfg(feature = "full")] pub fn visit_pat_reference_mut<V>(v: &mut V, node: &mut PatReference) @@ -2911,10 +2701,8 @@ where for it in &mut node.attrs { v.visit_attribute_mut(it); } - tokens_helper(v, &mut node.and_token.spans); - if let Some(it) = &mut node.mutability { - tokens_helper(v, &mut it.span); - } + skip!(node.and_token); + skip!(node.mutability); v.visit_pat_mut(&mut *node.pat); } #[cfg(feature = "full")] @@ -2925,7 +2713,7 @@ where for it in &mut node.attrs { v.visit_attribute_mut(it); } - tokens_helper(v, &mut node.dot2_token.spans); + skip!(node.dot2_token); } #[cfg(feature = "full")] pub fn visit_pat_slice_mut<V>(v: &mut V, node: &mut PatSlice) @@ -2935,13 +2723,10 @@ where for it in &mut node.attrs { v.visit_attribute_mut(it); } - tokens_helper(v, &mut node.bracket_token.span); - for el in Punctuated::pairs_mut(&mut node.elems) { - let (it, p) = el.into_tuple(); + skip!(node.bracket_token); + for mut el in Punctuated::pairs_mut(&mut node.elems) { + let it = el.value_mut(); v.visit_pat_mut(it); - if let Some(p) = p { - tokens_helper(v, &mut p.spans); - } } } #[cfg(feature = "full")] @@ -2952,17 +2737,17 @@ where for it in &mut node.attrs { v.visit_attribute_mut(it); } + if let Some(it) = &mut node.qself { + v.visit_qself_mut(it); + } v.visit_path_mut(&mut node.path); - tokens_helper(v, &mut node.brace_token.span); - for el in Punctuated::pairs_mut(&mut node.fields) { - let (it, p) = el.into_tuple(); + skip!(node.brace_token); + for mut el in Punctuated::pairs_mut(&mut node.fields) { + let it = el.value_mut(); v.visit_field_pat_mut(it); - if let Some(p) = p { - tokens_helper(v, &mut p.spans); - } } - if let Some(it) = &mut node.dot2_token { - tokens_helper(v, &mut it.spans); + if let Some(it) = &mut node.rest { + v.visit_pat_rest_mut(it); } } #[cfg(feature = "full")] @@ -2973,13 +2758,10 @@ where for it in &mut node.attrs { v.visit_attribute_mut(it); } - tokens_helper(v, &mut node.paren_token.span); - for el in Punctuated::pairs_mut(&mut node.elems) { - let (it, p) = el.into_tuple(); + skip!(node.paren_token); + for mut el in Punctuated::pairs_mut(&mut node.elems) { + let it = el.value_mut(); v.visit_pat_mut(it); - if let Some(p) = p { - tokens_helper(v, &mut p.spans); - } } } #[cfg(feature = "full")] @@ -2990,8 +2772,15 @@ where for it in &mut node.attrs { v.visit_attribute_mut(it); } + if let Some(it) = &mut node.qself { + v.visit_qself_mut(it); + } v.visit_path_mut(&mut node.path); - v.visit_pat_tuple_mut(&mut node.pat); + skip!(node.paren_token); + for mut el in Punctuated::pairs_mut(&mut node.elems) { + let it = el.value_mut(); + v.visit_pat_mut(it); + } } #[cfg(feature = "full")] pub fn visit_pat_type_mut<V>(v: &mut V, node: &mut PatType) @@ -3002,7 +2791,7 @@ where v.visit_attribute_mut(it); } v.visit_pat_mut(&mut *node.pat); - tokens_helper(v, &mut node.colon_token.spans); + skip!(node.colon_token); v.visit_type_mut(&mut *node.ty); } #[cfg(feature = "full")] @@ -3013,22 +2802,17 @@ where for it in &mut node.attrs { v.visit_attribute_mut(it); } - tokens_helper(v, &mut node.underscore_token.spans); + skip!(node.underscore_token); } #[cfg(any(feature = "derive", feature = "full"))] pub fn visit_path_mut<V>(v: &mut V, node: &mut Path) where V: VisitMut + ?Sized, { - if let Some(it) = &mut node.leading_colon { - tokens_helper(v, &mut it.spans); - } - for el in Punctuated::pairs_mut(&mut node.segments) { - let (it, p) = el.into_tuple(); + skip!(node.leading_colon); + for mut el in Punctuated::pairs_mut(&mut node.segments) { + let it = el.value_mut(); v.visit_path_segment_mut(it); - if let Some(p) = p { - tokens_helper(v, &mut p.spans); - } } } #[cfg(any(feature = "derive", feature = "full"))] @@ -3055,27 +2839,15 @@ where v.visit_path_arguments_mut(&mut node.arguments); } #[cfg(any(feature = "derive", feature = "full"))] -pub fn visit_predicate_eq_mut<V>(v: &mut V, node: &mut PredicateEq) -where - V: VisitMut + ?Sized, -{ - v.visit_type_mut(&mut node.lhs_ty); - tokens_helper(v, &mut node.eq_token.spans); - v.visit_type_mut(&mut node.rhs_ty); -} -#[cfg(any(feature = "derive", feature = "full"))] pub fn visit_predicate_lifetime_mut<V>(v: &mut V, node: &mut PredicateLifetime) where V: VisitMut + ?Sized, { v.visit_lifetime_mut(&mut node.lifetime); - tokens_helper(v, &mut node.colon_token.spans); - for el in Punctuated::pairs_mut(&mut node.bounds) { - let (it, p) = el.into_tuple(); + skip!(node.colon_token); + for mut el in Punctuated::pairs_mut(&mut node.bounds) { + let it = el.value_mut(); v.visit_lifetime_mut(it); - if let Some(p) = p { - tokens_helper(v, &mut p.spans); - } } } #[cfg(any(feature = "derive", feature = "full"))] @@ -3087,13 +2859,10 @@ where v.visit_bound_lifetimes_mut(it); } v.visit_type_mut(&mut node.bounded_ty); - tokens_helper(v, &mut node.colon_token.spans); - for el in Punctuated::pairs_mut(&mut node.bounds) { - let (it, p) = el.into_tuple(); + skip!(node.colon_token); + for mut el in Punctuated::pairs_mut(&mut node.bounds) { + let it = el.value_mut(); v.visit_type_param_bound_mut(it); - if let Some(p) = p { - tokens_helper(v, &mut p.spans); - } } } #[cfg(any(feature = "derive", feature = "full"))] @@ -3101,13 +2870,11 @@ pub fn visit_qself_mut<V>(v: &mut V, node: &mut QSelf) where V: VisitMut + ?Sized, { - tokens_helper(v, &mut node.lt_token.spans); + skip!(node.lt_token); v.visit_type_mut(&mut *node.ty); skip!(node.position); - if let Some(it) = &mut node.as_token { - tokens_helper(v, &mut it.span); - } - tokens_helper(v, &mut node.gt_token.spans); + skip!(node.as_token); + skip!(node.gt_token); } #[cfg(feature = "full")] pub fn visit_range_limits_mut<V>(v: &mut V, node: &mut RangeLimits) @@ -3116,10 +2883,10 @@ where { match node { RangeLimits::HalfOpen(_binding_0) => { - tokens_helper(v, &mut _binding_0.spans); + skip!(_binding_0); } RangeLimits::Closed(_binding_0) => { - tokens_helper(v, &mut _binding_0.spans); + skip!(_binding_0); } } } @@ -3132,15 +2899,15 @@ where v.visit_attribute_mut(it); } if let Some(it) = &mut node.reference { - tokens_helper(v, &mut (it).0.spans); + skip!((it).0); if let Some(it) = &mut (it).1 { v.visit_lifetime_mut(it); } } - if let Some(it) = &mut node.mutability { - tokens_helper(v, &mut it.span); - } - tokens_helper(v, &mut node.self_token.span); + skip!(node.mutability); + skip!(node.self_token); + skip!(node.colon_token); + v.visit_type_mut(&mut *node.ty); } #[cfg(any(feature = "derive", feature = "full"))] pub fn visit_return_type_mut<V>(v: &mut V, node: &mut ReturnType) @@ -3150,7 +2917,7 @@ where match node { ReturnType::Default => {} ReturnType::Type(_binding_0, _binding_1) => { - tokens_helper(v, &mut _binding_0.spans); + skip!(_binding_0); v.visit_type_mut(&mut **_binding_1); } } @@ -3160,28 +2927,19 @@ pub fn visit_signature_mut<V>(v: &mut V, node: &mut Signature) where V: VisitMut + ?Sized, { - if let Some(it) = &mut node.constness { - tokens_helper(v, &mut it.span); - } - if let Some(it) = &mut node.asyncness { - tokens_helper(v, &mut it.span); - } - if let Some(it) = &mut node.unsafety { - tokens_helper(v, &mut it.span); - } + skip!(node.constness); + skip!(node.asyncness); + skip!(node.unsafety); if let Some(it) = &mut node.abi { v.visit_abi_mut(it); } - tokens_helper(v, &mut node.fn_token.span); + skip!(node.fn_token); v.visit_ident_mut(&mut node.ident); v.visit_generics_mut(&mut node.generics); - tokens_helper(v, &mut node.paren_token.span); - for el in Punctuated::pairs_mut(&mut node.inputs) { - let (it, p) = el.into_tuple(); + skip!(node.paren_token); + for mut el in Punctuated::pairs_mut(&mut node.inputs) { + let it = el.value_mut(); v.visit_fn_arg_mut(it); - if let Some(p) = p { - tokens_helper(v, &mut p.spans); - } } if let Some(it) = &mut node.variadic { v.visit_variadic_mut(it); @@ -3193,6 +2951,18 @@ where V: VisitMut + ?Sized, {} #[cfg(feature = "full")] +pub fn visit_static_mutability_mut<V>(v: &mut V, node: &mut StaticMutability) +where + V: VisitMut + ?Sized, +{ + match node { + StaticMutability::Mut(_binding_0) => { + skip!(_binding_0); + } + StaticMutability::None => {} + } +} +#[cfg(feature = "full")] pub fn visit_stmt_mut<V>(v: &mut V, node: &mut Stmt) where V: VisitMut + ?Sized, @@ -3204,23 +2974,32 @@ where Stmt::Item(_binding_0) => { v.visit_item_mut(_binding_0); } - Stmt::Expr(_binding_0) => { + Stmt::Expr(_binding_0, _binding_1) => { v.visit_expr_mut(_binding_0); + skip!(_binding_1); } - Stmt::Semi(_binding_0, _binding_1) => { - v.visit_expr_mut(_binding_0); - tokens_helper(v, &mut _binding_1.spans); + Stmt::Macro(_binding_0) => { + v.visit_stmt_macro_mut(_binding_0); } } } +#[cfg(feature = "full")] +pub fn visit_stmt_macro_mut<V>(v: &mut V, node: &mut StmtMacro) +where + V: VisitMut + ?Sized, +{ + for it in &mut node.attrs { + v.visit_attribute_mut(it); + } + v.visit_macro_mut(&mut node.mac); + skip!(node.semi_token); +} #[cfg(any(feature = "derive", feature = "full"))] pub fn visit_trait_bound_mut<V>(v: &mut V, node: &mut TraitBound) where V: VisitMut + ?Sized, { - if let Some(it) = &mut node.paren_token { - tokens_helper(v, &mut it.span); - } + skip!(node.paren_token); v.visit_trait_bound_modifier_mut(&mut node.modifier); if let Some(it) = &mut node.lifetimes { v.visit_bound_lifetimes_mut(it); @@ -3235,7 +3014,7 @@ where match node { TraitBoundModifier::None => {} TraitBoundModifier::Maybe(_binding_0) => { - tokens_helper(v, &mut _binding_0.spans); + skip!(_binding_0); } } } @@ -3248,8 +3027,8 @@ where TraitItem::Const(_binding_0) => { v.visit_trait_item_const_mut(_binding_0); } - TraitItem::Method(_binding_0) => { - v.visit_trait_item_method_mut(_binding_0); + TraitItem::Fn(_binding_0) => { + v.visit_trait_item_fn_mut(_binding_0); } TraitItem::Type(_binding_0) => { v.visit_trait_item_type_mut(_binding_0); @@ -3260,8 +3039,6 @@ where TraitItem::Verbatim(_binding_0) => { skip!(_binding_0); } - #[cfg(syn_no_non_exhaustive)] - _ => unreachable!(), } } #[cfg(feature = "full")] @@ -3272,44 +3049,41 @@ where for it in &mut node.attrs { v.visit_attribute_mut(it); } - tokens_helper(v, &mut node.const_token.span); + skip!(node.const_token); v.visit_ident_mut(&mut node.ident); - tokens_helper(v, &mut node.colon_token.spans); + v.visit_generics_mut(&mut node.generics); + skip!(node.colon_token); v.visit_type_mut(&mut node.ty); if let Some(it) = &mut node.default { - tokens_helper(v, &mut (it).0.spans); + skip!((it).0); v.visit_expr_mut(&mut (it).1); } - tokens_helper(v, &mut node.semi_token.spans); + skip!(node.semi_token); } #[cfg(feature = "full")] -pub fn visit_trait_item_macro_mut<V>(v: &mut V, node: &mut TraitItemMacro) +pub fn visit_trait_item_fn_mut<V>(v: &mut V, node: &mut TraitItemFn) where V: VisitMut + ?Sized, { for it in &mut node.attrs { v.visit_attribute_mut(it); } - v.visit_macro_mut(&mut node.mac); - if let Some(it) = &mut node.semi_token { - tokens_helper(v, &mut it.spans); + v.visit_signature_mut(&mut node.sig); + if let Some(it) = &mut node.default { + v.visit_block_mut(it); } + skip!(node.semi_token); } #[cfg(feature = "full")] -pub fn visit_trait_item_method_mut<V>(v: &mut V, node: &mut TraitItemMethod) +pub fn visit_trait_item_macro_mut<V>(v: &mut V, node: &mut TraitItemMacro) where V: VisitMut + ?Sized, { for it in &mut node.attrs { v.visit_attribute_mut(it); } - v.visit_signature_mut(&mut node.sig); - if let Some(it) = &mut node.default { - v.visit_block_mut(it); - } - if let Some(it) = &mut node.semi_token { - tokens_helper(v, &mut it.spans); - } + v.visit_macro_mut(&mut node.mac); + skip!(node.semi_token); } #[cfg(feature = "full")] pub fn visit_trait_item_type_mut<V>(v: &mut V, node: &mut TraitItemType) @@ -3319,24 +3093,19 @@ where for it in &mut node.attrs { v.visit_attribute_mut(it); } - tokens_helper(v, &mut node.type_token.span); + skip!(node.type_token); v.visit_ident_mut(&mut node.ident); v.visit_generics_mut(&mut node.generics); - if let Some(it) = &mut node.colon_token { - tokens_helper(v, &mut it.spans); - } - for el in Punctuated::pairs_mut(&mut node.bounds) { - let (it, p) = el.into_tuple(); + skip!(node.colon_token); + for mut el in Punctuated::pairs_mut(&mut node.bounds) { + let it = el.value_mut(); v.visit_type_param_bound_mut(it); - if let Some(p) = p { - tokens_helper(v, &mut p.spans); - } } if let Some(it) = &mut node.default { - tokens_helper(v, &mut (it).0.spans); + skip!((it).0); v.visit_type_mut(&mut (it).1); } - tokens_helper(v, &mut node.semi_token.spans); + skip!(node.semi_token); } #[cfg(any(feature = "derive", feature = "full"))] pub fn visit_type_mut<V>(v: &mut V, node: &mut Type) @@ -3389,8 +3158,6 @@ where Type::Verbatim(_binding_0) => { skip!(_binding_0); } - #[cfg(syn_no_non_exhaustive)] - _ => unreachable!(), } } #[cfg(any(feature = "derive", feature = "full"))] @@ -3398,9 +3165,9 @@ pub fn visit_type_array_mut<V>(v: &mut V, node: &mut TypeArray) where V: VisitMut + ?Sized, { - tokens_helper(v, &mut node.bracket_token.span); + skip!(node.bracket_token); v.visit_type_mut(&mut *node.elem); - tokens_helper(v, &mut node.semi_token.spans); + skip!(node.semi_token); v.visit_expr_mut(&mut node.len); } #[cfg(any(feature = "derive", feature = "full"))] @@ -3411,23 +3178,18 @@ where if let Some(it) = &mut node.lifetimes { v.visit_bound_lifetimes_mut(it); } - if let Some(it) = &mut node.unsafety { - tokens_helper(v, &mut it.span); - } + skip!(node.unsafety); if let Some(it) = &mut node.abi { v.visit_abi_mut(it); } - tokens_helper(v, &mut node.fn_token.span); - tokens_helper(v, &mut node.paren_token.span); - for el in Punctuated::pairs_mut(&mut node.inputs) { - let (it, p) = el.into_tuple(); + skip!(node.fn_token); + skip!(node.paren_token); + for mut el in Punctuated::pairs_mut(&mut node.inputs) { + let it = el.value_mut(); v.visit_bare_fn_arg_mut(it); - if let Some(p) = p { - tokens_helper(v, &mut p.spans); - } } if let Some(it) = &mut node.variadic { - v.visit_variadic_mut(it); + v.visit_bare_variadic_mut(it); } v.visit_return_type_mut(&mut node.output); } @@ -3436,7 +3198,7 @@ pub fn visit_type_group_mut<V>(v: &mut V, node: &mut TypeGroup) where V: VisitMut + ?Sized, { - tokens_helper(v, &mut node.group_token.span); + skip!(node.group_token); v.visit_type_mut(&mut *node.elem); } #[cfg(any(feature = "derive", feature = "full"))] @@ -3444,13 +3206,10 @@ pub fn visit_type_impl_trait_mut<V>(v: &mut V, node: &mut TypeImplTrait) where V: VisitMut + ?Sized, { - tokens_helper(v, &mut node.impl_token.span); - for el in Punctuated::pairs_mut(&mut node.bounds) { - let (it, p) = el.into_tuple(); + skip!(node.impl_token); + for mut el in Punctuated::pairs_mut(&mut node.bounds) { + let it = el.value_mut(); v.visit_type_param_bound_mut(it); - if let Some(p) = p { - tokens_helper(v, &mut p.spans); - } } } #[cfg(any(feature = "derive", feature = "full"))] @@ -3458,7 +3217,7 @@ pub fn visit_type_infer_mut<V>(v: &mut V, node: &mut TypeInfer) where V: VisitMut + ?Sized, { - tokens_helper(v, &mut node.underscore_token.spans); + skip!(node.underscore_token); } #[cfg(any(feature = "derive", feature = "full"))] pub fn visit_type_macro_mut<V>(v: &mut V, node: &mut TypeMacro) @@ -3472,7 +3231,7 @@ pub fn visit_type_never_mut<V>(v: &mut V, node: &mut TypeNever) where V: VisitMut + ?Sized, { - tokens_helper(v, &mut node.bang_token.spans); + skip!(node.bang_token); } #[cfg(any(feature = "derive", feature = "full"))] pub fn visit_type_param_mut<V>(v: &mut V, node: &mut TypeParam) @@ -3483,19 +3242,12 @@ where v.visit_attribute_mut(it); } v.visit_ident_mut(&mut node.ident); - if let Some(it) = &mut node.colon_token { - tokens_helper(v, &mut it.spans); - } - for el in Punctuated::pairs_mut(&mut node.bounds) { - let (it, p) = el.into_tuple(); + skip!(node.colon_token); + for mut el in Punctuated::pairs_mut(&mut node.bounds) { + let it = el.value_mut(); v.visit_type_param_bound_mut(it); - if let Some(p) = p { - tokens_helper(v, &mut p.spans); - } - } - if let Some(it) = &mut node.eq_token { - tokens_helper(v, &mut it.spans); } + skip!(node.eq_token); if let Some(it) = &mut node.default { v.visit_type_mut(it); } @@ -3512,6 +3264,9 @@ where TypeParamBound::Lifetime(_binding_0) => { v.visit_lifetime_mut(_binding_0); } + TypeParamBound::Verbatim(_binding_0) => { + skip!(_binding_0); + } } } #[cfg(any(feature = "derive", feature = "full"))] @@ -3519,7 +3274,7 @@ pub fn visit_type_paren_mut<V>(v: &mut V, node: &mut TypeParen) where V: VisitMut + ?Sized, { - tokens_helper(v, &mut node.paren_token.span); + skip!(node.paren_token); v.visit_type_mut(&mut *node.elem); } #[cfg(any(feature = "derive", feature = "full"))] @@ -3537,13 +3292,9 @@ pub fn visit_type_ptr_mut<V>(v: &mut V, node: &mut TypePtr) where V: VisitMut + ?Sized, { - tokens_helper(v, &mut node.star_token.spans); - if let Some(it) = &mut node.const_token { - tokens_helper(v, &mut it.span); - } - if let Some(it) = &mut node.mutability { - tokens_helper(v, &mut it.span); - } + skip!(node.star_token); + skip!(node.const_token); + skip!(node.mutability); v.visit_type_mut(&mut *node.elem); } #[cfg(any(feature = "derive", feature = "full"))] @@ -3551,13 +3302,11 @@ pub fn visit_type_reference_mut<V>(v: &mut V, node: &mut TypeReference) where V: VisitMut + ?Sized, { - tokens_helper(v, &mut node.and_token.spans); + skip!(node.and_token); if let Some(it) = &mut node.lifetime { v.visit_lifetime_mut(it); } - if let Some(it) = &mut node.mutability { - tokens_helper(v, &mut it.span); - } + skip!(node.mutability); v.visit_type_mut(&mut *node.elem); } #[cfg(any(feature = "derive", feature = "full"))] @@ -3565,7 +3314,7 @@ pub fn visit_type_slice_mut<V>(v: &mut V, node: &mut TypeSlice) where V: VisitMut + ?Sized, { - tokens_helper(v, &mut node.bracket_token.span); + skip!(node.bracket_token); v.visit_type_mut(&mut *node.elem); } #[cfg(any(feature = "derive", feature = "full"))] @@ -3573,15 +3322,10 @@ pub fn visit_type_trait_object_mut<V>(v: &mut V, node: &mut TypeTraitObject) where V: VisitMut + ?Sized, { - if let Some(it) = &mut node.dyn_token { - tokens_helper(v, &mut it.span); - } - for el in Punctuated::pairs_mut(&mut node.bounds) { - let (it, p) = el.into_tuple(); + skip!(node.dyn_token); + for mut el in Punctuated::pairs_mut(&mut node.bounds) { + let it = el.value_mut(); v.visit_type_param_bound_mut(it); - if let Some(p) = p { - tokens_helper(v, &mut p.spans); - } } } #[cfg(any(feature = "derive", feature = "full"))] @@ -3589,13 +3333,10 @@ pub fn visit_type_tuple_mut<V>(v: &mut V, node: &mut TypeTuple) where V: VisitMut + ?Sized, { - tokens_helper(v, &mut node.paren_token.span); - for el in Punctuated::pairs_mut(&mut node.elems) { - let (it, p) = el.into_tuple(); + skip!(node.paren_token); + for mut el in Punctuated::pairs_mut(&mut node.elems) { + let it = el.value_mut(); v.visit_type_mut(it); - if let Some(p) = p { - tokens_helper(v, &mut p.spans); - } } } #[cfg(any(feature = "derive", feature = "full"))] @@ -3605,13 +3346,13 @@ where { match node { UnOp::Deref(_binding_0) => { - tokens_helper(v, &mut _binding_0.spans); + skip!(_binding_0); } UnOp::Not(_binding_0) => { - tokens_helper(v, &mut _binding_0.spans); + skip!(_binding_0); } UnOp::Neg(_binding_0) => { - tokens_helper(v, &mut _binding_0.spans); + skip!(_binding_0); } } } @@ -3620,20 +3361,17 @@ pub fn visit_use_glob_mut<V>(v: &mut V, node: &mut UseGlob) where V: VisitMut + ?Sized, { - tokens_helper(v, &mut node.star_token.spans); + skip!(node.star_token); } #[cfg(feature = "full")] pub fn visit_use_group_mut<V>(v: &mut V, node: &mut UseGroup) where V: VisitMut + ?Sized, { - tokens_helper(v, &mut node.brace_token.span); - for el in Punctuated::pairs_mut(&mut node.items) { - let (it, p) = el.into_tuple(); + skip!(node.brace_token); + for mut el in Punctuated::pairs_mut(&mut node.items) { + let it = el.value_mut(); v.visit_use_tree_mut(it); - if let Some(p) = p { - tokens_helper(v, &mut p.spans); - } } } #[cfg(feature = "full")] @@ -3649,7 +3387,7 @@ where V: VisitMut + ?Sized, { v.visit_ident_mut(&mut node.ident); - tokens_helper(v, &mut node.colon2_token.spans); + skip!(node.colon2_token); v.visit_use_tree_mut(&mut *node.tree); } #[cfg(feature = "full")] @@ -3658,7 +3396,7 @@ where V: VisitMut + ?Sized, { v.visit_ident_mut(&mut node.ident); - tokens_helper(v, &mut node.as_token.span); + skip!(node.as_token); v.visit_ident_mut(&mut node.rename); } #[cfg(feature = "full")] @@ -3684,7 +3422,7 @@ where } } } -#[cfg(any(feature = "derive", feature = "full"))] +#[cfg(feature = "full")] pub fn visit_variadic_mut<V>(v: &mut V, node: &mut Variadic) where V: VisitMut + ?Sized, @@ -3692,7 +3430,12 @@ where for it in &mut node.attrs { v.visit_attribute_mut(it); } - tokens_helper(v, &mut node.dots.spans); + if let Some(it) = &mut node.pat { + v.visit_pat_mut(&mut *(it).0); + skip!((it).1); + } + skip!(node.dots); + skip!(node.comma); } #[cfg(any(feature = "derive", feature = "full"))] pub fn visit_variant_mut<V>(v: &mut V, node: &mut Variant) @@ -3705,34 +3448,18 @@ where v.visit_ident_mut(&mut node.ident); v.visit_fields_mut(&mut node.fields); if let Some(it) = &mut node.discriminant { - tokens_helper(v, &mut (it).0.spans); + skip!((it).0); v.visit_expr_mut(&mut (it).1); } } #[cfg(any(feature = "derive", feature = "full"))] -pub fn visit_vis_crate_mut<V>(v: &mut V, node: &mut VisCrate) -where - V: VisitMut + ?Sized, -{ - tokens_helper(v, &mut node.crate_token.span); -} -#[cfg(any(feature = "derive", feature = "full"))] -pub fn visit_vis_public_mut<V>(v: &mut V, node: &mut VisPublic) -where - V: VisitMut + ?Sized, -{ - tokens_helper(v, &mut node.pub_token.span); -} -#[cfg(any(feature = "derive", feature = "full"))] pub fn visit_vis_restricted_mut<V>(v: &mut V, node: &mut VisRestricted) where V: VisitMut + ?Sized, { - tokens_helper(v, &mut node.pub_token.span); - tokens_helper(v, &mut node.paren_token.span); - if let Some(it) = &mut node.in_token { - tokens_helper(v, &mut it.span); - } + skip!(node.pub_token); + skip!(node.paren_token); + skip!(node.in_token); v.visit_path_mut(&mut *node.path); } #[cfg(any(feature = "derive", feature = "full"))] @@ -3742,10 +3469,7 @@ where { match node { Visibility::Public(_binding_0) => { - v.visit_vis_public_mut(_binding_0); - } - Visibility::Crate(_binding_0) => { - v.visit_vis_crate_mut(_binding_0); + skip!(_binding_0); } Visibility::Restricted(_binding_0) => { v.visit_vis_restricted_mut(_binding_0); @@ -3758,13 +3482,10 @@ pub fn visit_where_clause_mut<V>(v: &mut V, node: &mut WhereClause) where V: VisitMut + ?Sized, { - tokens_helper(v, &mut node.where_token.span); - for el in Punctuated::pairs_mut(&mut node.predicates) { - let (it, p) = el.into_tuple(); + skip!(node.where_token); + for mut el in Punctuated::pairs_mut(&mut node.predicates) { + let it = el.value_mut(); v.visit_where_predicate_mut(it); - if let Some(p) = p { - tokens_helper(v, &mut p.spans); - } } } #[cfg(any(feature = "derive", feature = "full"))] @@ -3773,14 +3494,11 @@ where V: VisitMut + ?Sized, { match node { - WherePredicate::Type(_binding_0) => { - v.visit_predicate_type_mut(_binding_0); - } WherePredicate::Lifetime(_binding_0) => { v.visit_predicate_lifetime_mut(_binding_0); } - WherePredicate::Eq(_binding_0) => { - v.visit_predicate_eq_mut(_binding_0); + WherePredicate::Type(_binding_0) => { + v.visit_predicate_type_mut(_binding_0); } } } diff --git a/vendor/syn/src/gen_helper.rs b/vendor/syn/src/gen_helper.rs index b2796126a..e433bac3a 100644 --- a/vendor/syn/src/gen_helper.rs +++ b/vendor/syn/src/gen_helper.rs @@ -1,10 +1,8 @@ #[cfg(feature = "fold")] -pub mod fold { - use crate::fold::Fold; +pub(crate) mod fold { use crate::punctuated::{Pair, Punctuated}; - use proc_macro2::Span; - pub trait FoldHelper { + pub(crate) trait FoldHelper { type Item; fn lift<F>(self, f: F) -> Self where @@ -33,122 +31,4 @@ pub mod fold { .collect() } } - - pub fn tokens_helper<F: Fold + ?Sized, S: Spans>(folder: &mut F, spans: &S) -> S { - spans.fold(folder) - } - - pub trait Spans { - fn fold<F: Fold + ?Sized>(&self, folder: &mut F) -> Self; - } - - impl Spans for Span { - fn fold<F: Fold + ?Sized>(&self, folder: &mut F) -> Self { - folder.fold_span(*self) - } - } - - impl Spans for [Span; 1] { - fn fold<F: Fold + ?Sized>(&self, folder: &mut F) -> Self { - [folder.fold_span(self[0])] - } - } - - impl Spans for [Span; 2] { - fn fold<F: Fold + ?Sized>(&self, folder: &mut F) -> Self { - [folder.fold_span(self[0]), folder.fold_span(self[1])] - } - } - - impl Spans for [Span; 3] { - fn fold<F: Fold + ?Sized>(&self, folder: &mut F) -> Self { - [ - folder.fold_span(self[0]), - folder.fold_span(self[1]), - folder.fold_span(self[2]), - ] - } - } -} - -#[cfg(feature = "visit")] -pub mod visit { - use crate::visit::Visit; - use proc_macro2::Span; - - pub fn tokens_helper<'ast, V: Visit<'ast> + ?Sized, S: Spans>(visitor: &mut V, spans: &S) { - spans.visit(visitor); - } - - pub trait Spans { - fn visit<'ast, V: Visit<'ast> + ?Sized>(&self, visitor: &mut V); - } - - impl Spans for Span { - fn visit<'ast, V: Visit<'ast> + ?Sized>(&self, visitor: &mut V) { - visitor.visit_span(self); - } - } - - impl Spans for [Span; 1] { - fn visit<'ast, V: Visit<'ast> + ?Sized>(&self, visitor: &mut V) { - visitor.visit_span(&self[0]); - } - } - - impl Spans for [Span; 2] { - fn visit<'ast, V: Visit<'ast> + ?Sized>(&self, visitor: &mut V) { - visitor.visit_span(&self[0]); - visitor.visit_span(&self[1]); - } - } - - impl Spans for [Span; 3] { - fn visit<'ast, V: Visit<'ast> + ?Sized>(&self, visitor: &mut V) { - visitor.visit_span(&self[0]); - visitor.visit_span(&self[1]); - visitor.visit_span(&self[2]); - } - } -} - -#[cfg(feature = "visit-mut")] -pub mod visit_mut { - use crate::visit_mut::VisitMut; - use proc_macro2::Span; - - pub fn tokens_helper<V: VisitMut + ?Sized, S: Spans>(visitor: &mut V, spans: &mut S) { - spans.visit_mut(visitor); - } - - pub trait Spans { - fn visit_mut<V: VisitMut + ?Sized>(&mut self, visitor: &mut V); - } - - impl Spans for Span { - fn visit_mut<V: VisitMut + ?Sized>(&mut self, visitor: &mut V) { - visitor.visit_span_mut(self); - } - } - - impl Spans for [Span; 1] { - fn visit_mut<V: VisitMut + ?Sized>(&mut self, visitor: &mut V) { - visitor.visit_span_mut(&mut self[0]); - } - } - - impl Spans for [Span; 2] { - fn visit_mut<V: VisitMut + ?Sized>(&mut self, visitor: &mut V) { - visitor.visit_span_mut(&mut self[0]); - visitor.visit_span_mut(&mut self[1]); - } - } - - impl Spans for [Span; 3] { - fn visit_mut<V: VisitMut + ?Sized>(&mut self, visitor: &mut V) { - visitor.visit_span_mut(&mut self[0]); - visitor.visit_span_mut(&mut self[1]); - visitor.visit_span_mut(&mut self[2]); - } - } } diff --git a/vendor/syn/src/generics.rs b/vendor/syn/src/generics.rs index 6d4fe847e..44a10da7d 100644 --- a/vendor/syn/src/generics.rs +++ b/vendor/syn/src/generics.rs @@ -1,5 +1,6 @@ use super::*; use crate::punctuated::{Iter, IterMut, Punctuated}; +use proc_macro2::TokenStream; #[cfg(all(feature = "printing", feature = "extra-traits"))] use std::fmt::{self, Debug}; #[cfg(all(feature = "printing", feature = "extra-traits"))] @@ -9,8 +10,12 @@ ast_struct! { /// Lifetimes and type parameters attached to a declaration of a function, /// enum, trait, etc. /// - /// *This type is available only if Syn is built with the `"derive"` or `"full"` - /// feature.* + /// This struct represents two distinct optional syntactic elements, + /// [generic parameters] and [where clause]. In some locations of the + /// grammar, there may be other tokens in between these two things. + /// + /// [generic parameters]: https://doc.rust-lang.org/stable/reference/items/generics.html#generic-parameters + /// [where clause]: https://doc.rust-lang.org/stable/reference/items/generics.html#where-clauses #[cfg_attr(doc_cfg, doc(cfg(any(feature = "full", feature = "derive"))))] pub struct Generics { pub lt_token: Option<Token![<]>, @@ -24,9 +29,6 @@ ast_enum_of_structs! { /// A generic type parameter, lifetime, or const generic: `T: Into<String>`, /// `'a: 'b`, `const LEN: usize`. /// - /// *This type is available only if Syn is built with the `"derive"` or `"full"` - /// feature.* - /// /// # Syntax tree enum /// /// This type is a [syntax tree enum]. @@ -34,52 +36,43 @@ ast_enum_of_structs! { /// [syntax tree enum]: Expr#syntax-tree-enums #[cfg_attr(doc_cfg, doc(cfg(any(feature = "full", feature = "derive"))))] pub enum GenericParam { + /// A lifetime parameter: `'a: 'b + 'c + 'd`. + Lifetime(LifetimeParam), + /// A generic type parameter: `T: Into<String>`. Type(TypeParam), - /// A lifetime definition: `'a: 'b + 'c + 'd`. - Lifetime(LifetimeDef), - /// A const generic parameter: `const LENGTH: usize`. Const(ConstParam), } } ast_struct! { - /// A generic type parameter: `T: Into<String>`. - /// - /// *This type is available only if Syn is built with the `"derive"` or - /// `"full"` feature.* + /// A lifetime definition: `'a: 'b + 'c + 'd`. #[cfg_attr(doc_cfg, doc(cfg(any(feature = "full", feature = "derive"))))] - pub struct TypeParam { + pub struct LifetimeParam { pub attrs: Vec<Attribute>, - pub ident: Ident, + pub lifetime: Lifetime, pub colon_token: Option<Token![:]>, - pub bounds: Punctuated<TypeParamBound, Token![+]>, - pub eq_token: Option<Token![=]>, - pub default: Option<Type>, + pub bounds: Punctuated<Lifetime, Token![+]>, } } ast_struct! { - /// A lifetime definition: `'a: 'b + 'c + 'd`. - /// - /// *This type is available only if Syn is built with the `"derive"` or - /// `"full"` feature.* + /// A generic type parameter: `T: Into<String>`. #[cfg_attr(doc_cfg, doc(cfg(any(feature = "full", feature = "derive"))))] - pub struct LifetimeDef { + pub struct TypeParam { pub attrs: Vec<Attribute>, - pub lifetime: Lifetime, + pub ident: Ident, pub colon_token: Option<Token![:]>, - pub bounds: Punctuated<Lifetime, Token![+]>, + pub bounds: Punctuated<TypeParamBound, Token![+]>, + pub eq_token: Option<Token![=]>, + pub default: Option<Type>, } } ast_struct! { /// A const generic parameter: `const LENGTH: usize`. - /// - /// *This type is available only if Syn is built with the `"derive"` or - /// `"full"` feature.* #[cfg_attr(doc_cfg, doc(cfg(any(feature = "full", feature = "derive"))))] pub struct ConstParam { pub attrs: Vec<Attribute>, @@ -107,45 +100,45 @@ impl Generics { /// Returns an /// <code /// style="padding-right:0;">Iterator<Item = &</code><a - /// href="struct.TypeParam.html"><code - /// style="padding-left:0;padding-right:0;">TypeParam</code></a><code + /// href="struct.LifetimeParam.html"><code + /// style="padding-left:0;padding-right:0;">LifetimeParam</code></a><code /// style="padding-left:0;">></code> - /// over the type parameters in `self.params`. - pub fn type_params(&self) -> TypeParams { - TypeParams(self.params.iter()) + /// over the lifetime parameters in `self.params`. + pub fn lifetimes(&self) -> Lifetimes { + Lifetimes(self.params.iter()) } /// Returns an /// <code /// style="padding-right:0;">Iterator<Item = &mut </code><a - /// href="struct.TypeParam.html"><code - /// style="padding-left:0;padding-right:0;">TypeParam</code></a><code + /// href="struct.LifetimeParam.html"><code + /// style="padding-left:0;padding-right:0;">LifetimeParam</code></a><code /// style="padding-left:0;">></code> - /// over the type parameters in `self.params`. - pub fn type_params_mut(&mut self) -> TypeParamsMut { - TypeParamsMut(self.params.iter_mut()) + /// over the lifetime parameters in `self.params`. + pub fn lifetimes_mut(&mut self) -> LifetimesMut { + LifetimesMut(self.params.iter_mut()) } /// Returns an /// <code /// style="padding-right:0;">Iterator<Item = &</code><a - /// href="struct.LifetimeDef.html"><code - /// style="padding-left:0;padding-right:0;">LifetimeDef</code></a><code + /// href="struct.TypeParam.html"><code + /// style="padding-left:0;padding-right:0;">TypeParam</code></a><code /// style="padding-left:0;">></code> - /// over the lifetime parameters in `self.params`. - pub fn lifetimes(&self) -> Lifetimes { - Lifetimes(self.params.iter()) + /// over the type parameters in `self.params`. + pub fn type_params(&self) -> TypeParams { + TypeParams(self.params.iter()) } /// Returns an /// <code /// style="padding-right:0;">Iterator<Item = &mut </code><a - /// href="struct.LifetimeDef.html"><code - /// style="padding-left:0;padding-right:0;">LifetimeDef</code></a><code + /// href="struct.TypeParam.html"><code + /// style="padding-left:0;padding-right:0;">TypeParam</code></a><code /// style="padding-left:0;">></code> - /// over the lifetime parameters in `self.params`. - pub fn lifetimes_mut(&mut self) -> LifetimesMut { - LifetimesMut(self.params.iter_mut()) + /// over the type parameters in `self.params`. + pub fn type_params_mut(&mut self) -> TypeParamsMut { + TypeParamsMut(self.params.iter_mut()) } /// Returns an @@ -179,72 +172,72 @@ impl Generics { } } -pub struct TypeParams<'a>(Iter<'a, GenericParam>); +pub struct Lifetimes<'a>(Iter<'a, GenericParam>); -impl<'a> Iterator for TypeParams<'a> { - type Item = &'a TypeParam; +impl<'a> Iterator for Lifetimes<'a> { + type Item = &'a LifetimeParam; fn next(&mut self) -> Option<Self::Item> { let next = match self.0.next() { Some(item) => item, None => return None, }; - if let GenericParam::Type(type_param) = next { - Some(type_param) + if let GenericParam::Lifetime(lifetime) = next { + Some(lifetime) } else { self.next() } } } -pub struct TypeParamsMut<'a>(IterMut<'a, GenericParam>); +pub struct LifetimesMut<'a>(IterMut<'a, GenericParam>); -impl<'a> Iterator for TypeParamsMut<'a> { - type Item = &'a mut TypeParam; +impl<'a> Iterator for LifetimesMut<'a> { + type Item = &'a mut LifetimeParam; fn next(&mut self) -> Option<Self::Item> { let next = match self.0.next() { Some(item) => item, None => return None, }; - if let GenericParam::Type(type_param) = next { - Some(type_param) + if let GenericParam::Lifetime(lifetime) = next { + Some(lifetime) } else { self.next() } } } -pub struct Lifetimes<'a>(Iter<'a, GenericParam>); +pub struct TypeParams<'a>(Iter<'a, GenericParam>); -impl<'a> Iterator for Lifetimes<'a> { - type Item = &'a LifetimeDef; +impl<'a> Iterator for TypeParams<'a> { + type Item = &'a TypeParam; fn next(&mut self) -> Option<Self::Item> { let next = match self.0.next() { Some(item) => item, None => return None, }; - if let GenericParam::Lifetime(lifetime) = next { - Some(lifetime) + if let GenericParam::Type(type_param) = next { + Some(type_param) } else { self.next() } } } -pub struct LifetimesMut<'a>(IterMut<'a, GenericParam>); +pub struct TypeParamsMut<'a>(IterMut<'a, GenericParam>); -impl<'a> Iterator for LifetimesMut<'a> { - type Item = &'a mut LifetimeDef; +impl<'a> Iterator for TypeParamsMut<'a> { + type Item = &'a mut TypeParam; fn next(&mut self) -> Option<Self::Item> { let next = match self.0.next() { Some(item) => item, None => return None, }; - if let GenericParam::Lifetime(lifetime) = next { - Some(lifetime) + if let GenericParam::Type(type_param) = next { + Some(type_param) } else { self.next() } @@ -288,9 +281,6 @@ impl<'a> Iterator for ConstParamsMut<'a> { } /// Returned by `Generics::split_for_impl`. -/// -/// *This type is available only if Syn is built with the `"derive"` or `"full"` -/// feature and the `"printing"` feature.* #[cfg(feature = "printing")] #[cfg_attr( doc_cfg, @@ -299,9 +289,6 @@ impl<'a> Iterator for ConstParamsMut<'a> { pub struct ImplGenerics<'a>(&'a Generics); /// Returned by `Generics::split_for_impl`. -/// -/// *This type is available only if Syn is built with the `"derive"` or `"full"` -/// feature and the `"printing"` feature.* #[cfg(feature = "printing")] #[cfg_attr( doc_cfg, @@ -310,9 +297,6 @@ pub struct ImplGenerics<'a>(&'a Generics); pub struct TypeGenerics<'a>(&'a Generics); /// Returned by `TypeGenerics::as_turbofish`. -/// -/// *This type is available only if Syn is built with the `"derive"` or `"full"` -/// feature and the `"printing"` feature.* #[cfg(feature = "printing")] #[cfg_attr( doc_cfg, @@ -340,9 +324,6 @@ impl Generics { /// } /// # ; /// ``` - /// - /// *This method is available only if Syn is built with the `"derive"` or - /// `"full"` feature and the `"printing"` feature.* #[cfg_attr( doc_cfg, doc(cfg(all(any(feature = "full", feature = "derive"), feature = "printing"))) @@ -410,9 +391,6 @@ generics_wrapper_impls!(Turbofish); #[cfg(feature = "printing")] impl<'a> TypeGenerics<'a> { /// Turn a type's generics like `<X, Y>` into a turbofish like `::<X, Y>`. - /// - /// *This method is available only if Syn is built with the `"derive"` or - /// `"full"` feature and the `"printing"` feature.* pub fn as_turbofish(&self) -> Turbofish { Turbofish(self.0) } @@ -420,14 +398,11 @@ impl<'a> TypeGenerics<'a> { ast_struct! { /// A set of bound lifetimes: `for<'a, 'b, 'c>`. - /// - /// *This type is available only if Syn is built with the `"derive"` or `"full"` - /// feature.* #[cfg_attr(doc_cfg, doc(cfg(any(feature = "full", feature = "derive"))))] pub struct BoundLifetimes { pub for_token: Token![for], pub lt_token: Token![<], - pub lifetimes: Punctuated<LifetimeDef, Token![,]>, + pub lifetimes: Punctuated<GenericParam, Token![,]>, pub gt_token: Token![>], } } @@ -443,9 +418,9 @@ impl Default for BoundLifetimes { } } -impl LifetimeDef { +impl LifetimeParam { pub fn new(lifetime: Lifetime) -> Self { - LifetimeDef { + LifetimeParam { attrs: Vec::new(), lifetime, colon_token: None, @@ -469,21 +444,17 @@ impl From<Ident> for TypeParam { ast_enum_of_structs! { /// A trait or lifetime used as a bound on a type parameter. - /// - /// *This type is available only if Syn is built with the `"derive"` or `"full"` - /// feature.* #[cfg_attr(doc_cfg, doc(cfg(any(feature = "full", feature = "derive"))))] + #[non_exhaustive] pub enum TypeParamBound { Trait(TraitBound), Lifetime(Lifetime), + Verbatim(TokenStream), } } ast_struct! { /// A trait used as a bound on a type parameter. - /// - /// *This type is available only if Syn is built with the `"derive"` or `"full"` - /// feature.* #[cfg_attr(doc_cfg, doc(cfg(any(feature = "full", feature = "derive"))))] pub struct TraitBound { pub paren_token: Option<token::Paren>, @@ -498,9 +469,6 @@ ast_struct! { ast_enum! { /// A modifier on a trait bound, currently only used for the `?` in /// `?Sized`. - /// - /// *This type is available only if Syn is built with the `"derive"` or `"full"` - /// feature.* #[cfg_attr(doc_cfg, doc(cfg(any(feature = "full", feature = "derive"))))] pub enum TraitBoundModifier { None, @@ -511,9 +479,6 @@ ast_enum! { ast_struct! { /// A `where` clause in a definition: `where T: Deserialize<'de>, D: /// 'static`. - /// - /// *This type is available only if Syn is built with the `"derive"` or `"full"` - /// feature.* #[cfg_attr(doc_cfg, doc(cfg(any(feature = "full", feature = "derive"))))] pub struct WhereClause { pub where_token: Token![where], @@ -524,49 +489,24 @@ ast_struct! { ast_enum_of_structs! { /// A single predicate in a `where` clause: `T: Deserialize<'de>`. /// - /// *This type is available only if Syn is built with the `"derive"` or `"full"` - /// feature.* - /// /// # Syntax tree enum /// /// This type is a [syntax tree enum]. /// /// [syntax tree enum]: Expr#syntax-tree-enums #[cfg_attr(doc_cfg, doc(cfg(any(feature = "full", feature = "derive"))))] + #[non_exhaustive] pub enum WherePredicate { - /// A type predicate in a `where` clause: `for<'c> Foo<'c>: Trait<'c>`. - Type(PredicateType), - /// A lifetime predicate in a `where` clause: `'a: 'b + 'c`. Lifetime(PredicateLifetime), - /// An equality predicate in a `where` clause (unsupported). - Eq(PredicateEq), - } -} - -ast_struct! { - /// A type predicate in a `where` clause: `for<'c> Foo<'c>: Trait<'c>`. - /// - /// *This type is available only if Syn is built with the `"derive"` or - /// `"full"` feature.* - #[cfg_attr(doc_cfg, doc(cfg(any(feature = "full", feature = "derive"))))] - pub struct PredicateType { - /// Any lifetimes from a `for` binding - pub lifetimes: Option<BoundLifetimes>, - /// The type being bounded - pub bounded_ty: Type, - pub colon_token: Token![:], - /// Trait and lifetime bounds (`Clone+Send+'static`) - pub bounds: Punctuated<TypeParamBound, Token![+]>, + /// A type predicate in a `where` clause: `for<'c> Foo<'c>: Trait<'c>`. + Type(PredicateType), } } ast_struct! { /// A lifetime predicate in a `where` clause: `'a: 'b + 'c`. - /// - /// *This type is available only if Syn is built with the `"derive"` or - /// `"full"` feature.* #[cfg_attr(doc_cfg, doc(cfg(any(feature = "full", feature = "derive"))))] pub struct PredicateLifetime { pub lifetime: Lifetime, @@ -576,20 +516,21 @@ ast_struct! { } ast_struct! { - /// An equality predicate in a `where` clause (unsupported). - /// - /// *This type is available only if Syn is built with the `"derive"` or - /// `"full"` feature.* + /// A type predicate in a `where` clause: `for<'c> Foo<'c>: Trait<'c>`. #[cfg_attr(doc_cfg, doc(cfg(any(feature = "full", feature = "derive"))))] - pub struct PredicateEq { - pub lhs_ty: Type, - pub eq_token: Token![=], - pub rhs_ty: Type, + pub struct PredicateType { + /// Any lifetimes from a `for` binding + pub lifetimes: Option<BoundLifetimes>, + /// The type being bounded + pub bounded_ty: Type, + pub colon_token: Token![:], + /// Trait and lifetime bounds (`Clone+Send+'static`) + pub bounds: Punctuated<TypeParamBound, Token![+]>, } } #[cfg(feature = "parsing")] -pub mod parsing { +pub(crate) mod parsing { use super::*; use crate::ext::IdentExt; use crate::parse::{Parse, ParseStream, Result}; @@ -612,7 +553,7 @@ pub mod parsing { let attrs = input.call(Attribute::parse_outer)?; let lookahead = input.lookahead1(); if lookahead.peek(Lifetime) { - params.push_value(GenericParam::Lifetime(LifetimeDef { + params.push_value(GenericParam::Lifetime(LifetimeParam { attrs, ..input.parse()? })); @@ -669,7 +610,7 @@ pub mod parsing { ..input.parse()? })) } else if lookahead.peek(Lifetime) { - Ok(GenericParam::Lifetime(LifetimeDef { + Ok(GenericParam::Lifetime(LifetimeParam { attrs, ..input.parse()? })) @@ -685,10 +626,10 @@ pub mod parsing { } #[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))] - impl Parse for LifetimeDef { + impl Parse for LifetimeParam { fn parse(input: ParseStream) -> Result<Self> { let has_colon; - Ok(LifetimeDef { + Ok(LifetimeParam { attrs: input.call(Attribute::parse_outer)?, lifetime: input.parse()?, colon_token: { @@ -731,7 +672,14 @@ pub mod parsing { lifetimes: { let mut lifetimes = Punctuated::new(); while !input.peek(Token![>]) { - lifetimes.push_value(input.parse()?); + let attrs = input.call(Attribute::parse_outer)?; + let lifetime: Lifetime = input.parse()?; + lifetimes.push_value(GenericParam::Lifetime(LifetimeParam { + attrs, + lifetime, + colon_token: None, + bounds: Punctuated::new(), + })); if input.peek(Token![>]) { break; } @@ -762,19 +710,12 @@ pub mod parsing { let ident: Ident = input.parse()?; let colon_token: Option<Token![:]> = input.parse()?; - let begin_bound = input.fork(); - let mut is_maybe_const = false; let mut bounds = Punctuated::new(); if colon_token.is_some() { loop { if input.peek(Token![,]) || input.peek(Token![>]) || input.peek(Token![=]) { break; } - if input.peek(Token![~]) && input.peek2(Token![const]) { - input.parse::<Token![~]>()?; - input.parse::<Token![const]>()?; - is_maybe_const = true; - } let value: TypeParamBound = input.parse()?; bounds.push_value(value); if !input.peek(Token![+]) { @@ -785,19 +726,13 @@ pub mod parsing { } } - let mut eq_token: Option<Token![=]> = input.parse()?; - let mut default = if eq_token.is_some() { + let eq_token: Option<Token![=]> = input.parse()?; + let default = if eq_token.is_some() { Some(input.parse::<Type>()?) } else { None }; - if is_maybe_const { - bounds.clear(); - eq_token = None; - default = Some(Type::Verbatim(verbatim::between(begin_bound, input))); - } - Ok(TypeParam { attrs, ident, @@ -816,15 +751,30 @@ pub mod parsing { return input.parse().map(TypeParamBound::Lifetime); } - if input.peek(token::Paren) { - let content; - let paren_token = parenthesized!(content in input); - let mut bound: TraitBound = content.parse()?; - bound.paren_token = Some(paren_token); - return Ok(TypeParamBound::Trait(bound)); + let begin = input.fork(); + + let content; + let (paren_token, content) = if input.peek(token::Paren) { + (Some(parenthesized!(content in input)), &content) + } else { + (None, input) + }; + + let is_tilde_const = + cfg!(feature = "full") && content.peek(Token![~]) && content.peek2(Token![const]); + if is_tilde_const { + content.parse::<Token![~]>()?; + content.parse::<Token![const]>()?; } - input.parse().map(TypeParamBound::Trait) + let mut bound: TraitBound = content.parse()?; + bound.paren_token = paren_token; + + if is_tilde_const { + Ok(TypeParamBound::Verbatim(verbatim::between(begin, input))) + } else { + Ok(TypeParamBound::Trait(bound)) + } } } @@ -844,7 +794,8 @@ pub mod parsing { || input.peek(Token![::]) || input.peek(Token![?]) || input.peek(Lifetime) - || input.peek(token::Paren)) + || input.peek(token::Paren) + || input.peek(Token![~])) { break; } @@ -856,15 +807,6 @@ pub mod parsing { #[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))] impl Parse for TraitBound { fn parse(input: ParseStream) -> Result<Self> { - #[cfg(feature = "full")] - let tilde_const = if input.peek(Token![~]) && input.peek2(Token![const]) { - let tilde_token = input.parse::<Token![~]>()?; - let const_token = input.parse::<Token![const]>()?; - Some((tilde_token, const_token)) - } else { - None - }; - let modifier: TraitBoundModifier = input.parse()?; let lifetimes: Option<BoundLifetimes> = input.parse()?; @@ -878,21 +820,6 @@ pub mod parsing { path.segments.last_mut().unwrap().arguments = parenthesized; } - #[cfg(feature = "full")] - { - if let Some((tilde_token, const_token)) = tilde_const { - path.segments.insert( - 0, - PathSegment { - ident: Ident::new("const", const_token.span), - arguments: PathArguments::None, - }, - ); - let (_const, punct) = path.segments.pairs_mut().next().unwrap().into_tuple(); - *punct.unwrap() = Token![::](tilde_token.span); - } - } - Ok(TraitBound { paren_token: None, modifier, @@ -1047,11 +974,7 @@ mod printing { use super::*; use crate::attr::FilterAttrs; use crate::print::TokensOrDefault; - #[cfg(feature = "full")] - use crate::punctuated::Pair; use proc_macro2::TokenStream; - #[cfg(feature = "full")] - use proc_macro2::TokenTree; use quote::{ToTokens, TokenStreamExt}; #[cfg_attr(doc_cfg, doc(cfg(feature = "printing")))] @@ -1065,9 +988,6 @@ mod printing { // Print lifetimes before types and consts, regardless of their // order in self.params. - // - // TODO: ordering rules for const parameters vs type parameters have - // not been settled yet. https://github.com/rust-lang/rust/issues/44580 let mut trailing_or_empty = true; for param in self.params.pairs() { if let GenericParam::Lifetime(_) = **param.value() { @@ -1076,7 +996,7 @@ mod printing { } } for param in self.params.pairs() { - match **param.value() { + match param.value() { GenericParam::Type(_) | GenericParam::Const(_) => { if !trailing_or_empty { <Token![,]>::default().to_tokens(tokens); @@ -1102,9 +1022,6 @@ mod printing { // Print lifetimes before types and consts, regardless of their // order in self.params. - // - // TODO: ordering rules for const parameters vs type parameters have - // not been settled yet. https://github.com/rust-lang/rust/issues/44580 let mut trailing_or_empty = true; for param in self.0.params.pairs() { if let GenericParam::Lifetime(_) = **param.value() { @@ -1120,7 +1037,7 @@ mod printing { <Token![,]>::default().to_tokens(tokens); trailing_or_empty = true; } - match *param.value() { + match param.value() { GenericParam::Lifetime(_) => unreachable!(), GenericParam::Type(param) => { // Leave off the type parameter defaults @@ -1157,9 +1074,6 @@ mod printing { // Print lifetimes before types and consts, regardless of their // order in self.params. - // - // TODO: ordering rules for const parameters vs type parameters have - // not been settled yet. https://github.com/rust-lang/rust/issues/44580 let mut trailing_or_empty = true; for param in self.0.params.pairs() { if let GenericParam::Lifetime(def) = *param.value() { @@ -1177,7 +1091,7 @@ mod printing { <Token![,]>::default().to_tokens(tokens); trailing_or_empty = true; } - match *param.value() { + match param.value() { GenericParam::Lifetime(_) => unreachable!(), GenericParam::Type(param) => { // Leave off the type parameter defaults @@ -1215,7 +1129,7 @@ mod printing { } #[cfg_attr(doc_cfg, doc(cfg(feature = "printing")))] - impl ToTokens for LifetimeDef { + impl ToTokens for LifetimeParam { fn to_tokens(&self, tokens: &mut TokenStream) { tokens.append_all(self.attrs.outer()); self.lifetime.to_tokens(tokens); @@ -1236,29 +1150,6 @@ mod printing { self.bounds.to_tokens(tokens); } if let Some(default) = &self.default { - #[cfg(feature = "full")] - { - if self.eq_token.is_none() { - if let Type::Verbatim(default) = default { - let mut iter = default.clone().into_iter().peekable(); - while let Some(token) = iter.next() { - if let TokenTree::Punct(q) = token { - if q.as_char() == '~' { - if let Some(TokenTree::Ident(c)) = iter.peek() { - if c == "const" { - if self.bounds.is_empty() { - TokensOrDefault(&self.colon_token) - .to_tokens(tokens); - } - return default.to_tokens(tokens); - } - } - } - } - } - } - } - } TokensOrDefault(&self.eq_token).to_tokens(tokens); default.to_tokens(tokens); } @@ -1269,26 +1160,9 @@ mod printing { impl ToTokens for TraitBound { fn to_tokens(&self, tokens: &mut TokenStream) { let to_tokens = |tokens: &mut TokenStream| { - #[cfg(feature = "full")] - let skip = match self.path.segments.pairs().next() { - Some(Pair::Punctuated(t, p)) if t.ident == "const" => { - Token![~](p.spans[0]).to_tokens(tokens); - t.to_tokens(tokens); - 1 - } - _ => 0, - }; self.modifier.to_tokens(tokens); self.lifetimes.to_tokens(tokens); - #[cfg(feature = "full")] - { - self.path.leading_colon.to_tokens(tokens); - tokens.append_all(self.path.segments.pairs().skip(skip)); - } - #[cfg(not(feature = "full"))] - { - self.path.to_tokens(tokens); - } + self.path.to_tokens(tokens); }; match &self.paren_token { Some(paren) => paren.surround(tokens, to_tokens), @@ -1333,16 +1207,6 @@ mod printing { } #[cfg_attr(doc_cfg, doc(cfg(feature = "printing")))] - impl ToTokens for PredicateType { - fn to_tokens(&self, tokens: &mut TokenStream) { - self.lifetimes.to_tokens(tokens); - self.bounded_ty.to_tokens(tokens); - self.colon_token.to_tokens(tokens); - self.bounds.to_tokens(tokens); - } - } - - #[cfg_attr(doc_cfg, doc(cfg(feature = "printing")))] impl ToTokens for PredicateLifetime { fn to_tokens(&self, tokens: &mut TokenStream) { self.lifetime.to_tokens(tokens); @@ -1352,11 +1216,12 @@ mod printing { } #[cfg_attr(doc_cfg, doc(cfg(feature = "printing")))] - impl ToTokens for PredicateEq { + impl ToTokens for PredicateType { fn to_tokens(&self, tokens: &mut TokenStream) { - self.lhs_ty.to_tokens(tokens); - self.eq_token.to_tokens(tokens); - self.rhs_ty.to_tokens(tokens); + self.lifetimes.to_tokens(tokens); + self.bounded_ty.to_tokens(tokens); + self.colon_token.to_tokens(tokens); + self.bounds.to_tokens(tokens); } } } diff --git a/vendor/syn/src/group.rs b/vendor/syn/src/group.rs index 7fd273c1d..cccbc467d 100644 --- a/vendor/syn/src/group.rs +++ b/vendor/syn/src/group.rs @@ -1,7 +1,8 @@ use crate::error::Result; use crate::parse::ParseBuffer; use crate::token; -use proc_macro2::{Delimiter, Span}; +use proc_macro2::extra::DelimSpan; +use proc_macro2::Delimiter; // Not public API. #[doc(hidden)] @@ -62,7 +63,7 @@ pub fn parse_brackets<'a>(input: &ParseBuffer<'a>) -> Result<Brackets<'a>> { #[cfg(any(feature = "full", feature = "derive"))] pub(crate) fn parse_group<'a>(input: &ParseBuffer<'a>) -> Result<Group<'a>> { parse_delimited(input, Delimiter::None).map(|(span, content)| Group { - token: token::Group(span), + token: token::Group(span.join()), content, }) } @@ -70,7 +71,7 @@ pub(crate) fn parse_group<'a>(input: &ParseBuffer<'a>) -> Result<Group<'a>> { fn parse_delimited<'a>( input: &ParseBuffer<'a>, delimiter: Delimiter, -) -> Result<(Span, ParseBuffer<'a>)> { +) -> Result<(DelimSpan, ParseBuffer<'a>)> { input.step(|cursor| { if let Some((content, span, rest)) = cursor.group(delimiter) { let scope = crate::buffer::close_span_of_group(*cursor); @@ -119,7 +120,7 @@ fn parse_delimited<'a>( /// struct_token: input.parse()?, /// ident: input.parse()?, /// paren_token: parenthesized!(content in input), -/// fields: content.parse_terminated(Type::parse)?, +/// fields: content.parse_terminated(Type::parse, Token![,])?, /// semi_token: input.parse()?, /// }) /// } @@ -185,7 +186,7 @@ macro_rules! parenthesized { /// struct_token: input.parse()?, /// ident: input.parse()?, /// brace_token: braced!(content in input), -/// fields: content.parse_terminated(Field::parse)?, +/// fields: content.parse_terminated(Field::parse, Token![,])?, /// }) /// } /// } diff --git a/vendor/syn/src/ident.rs b/vendor/syn/src/ident.rs index 8e3d8bda9..bd6f3f9f2 100644 --- a/vendor/syn/src/ident.rs +++ b/vendor/syn/src/ident.rs @@ -1,14 +1,9 @@ #[cfg(feature = "parsing")] -use crate::buffer::Cursor; -#[cfg(feature = "parsing")] use crate::lookahead; -#[cfg(feature = "parsing")] -use crate::parse::{Parse, ParseStream, Result}; -#[cfg(feature = "parsing")] -use crate::token::Token; pub use proc_macro2::Ident; +#[cfg(not(doc))] // rustdoc bug: https://github.com/rust-lang/rust/issues/105735 #[cfg(feature = "parsing")] #[doc(hidden)] #[allow(non_snake_case)] @@ -16,54 +11,6 @@ pub fn Ident(marker: lookahead::TokenMarker) -> Ident { match marker {} } -#[cfg(feature = "parsing")] -fn accept_as_ident(ident: &Ident) -> bool { - match ident.to_string().as_str() { - "_" | - // Based on https://doc.rust-lang.org/grammar.html#keywords - // and https://github.com/rust-lang/rfcs/blob/master/text/2421-unreservations-2018.md - // and https://github.com/rust-lang/rfcs/blob/master/text/2420-unreserve-proc.md - "abstract" | "as" | "become" | "box" | "break" | "const" | "continue" | - "crate" | "do" | "else" | "enum" | "extern" | "false" | "final" | "fn" | - "for" | "if" | "impl" | "in" | "let" | "loop" | "macro" | "match" | - "mod" | "move" | "mut" | "override" | "priv" | "pub" | "ref" | - "return" | "Self" | "self" | "static" | "struct" | "super" | "trait" | - "true" | "type" | "typeof" | "unsafe" | "unsized" | "use" | "virtual" | - "where" | "while" | "yield" => false, - _ => true, - } -} - -#[cfg(feature = "parsing")] -#[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))] -impl Parse for Ident { - fn parse(input: ParseStream) -> Result<Self> { - input.step(|cursor| { - if let Some((ident, rest)) = cursor.ident() { - if accept_as_ident(&ident) { - return Ok((ident, rest)); - } - } - Err(cursor.error("expected identifier")) - }) - } -} - -#[cfg(feature = "parsing")] -impl Token for Ident { - fn peek(cursor: Cursor) -> bool { - if let Some((ident, _rest)) = cursor.ident() { - accept_as_ident(&ident) - } else { - false - } - } - - fn display() -> &'static str { - "identifier" - } -} - macro_rules! ident_from_token { ($token:ident) => { impl From<Token![$token]> for Ident { @@ -86,7 +33,7 @@ impl From<Token![_]> for Ident { } } -pub fn xid_ok(symbol: &str) -> bool { +pub(crate) fn xid_ok(symbol: &str) -> bool { let mut chars = symbol.chars(); let first = chars.next().unwrap(); if !(first == '_' || unicode_ident::is_xid_start(first)) { @@ -99,3 +46,61 @@ pub fn xid_ok(symbol: &str) -> bool { } true } + +#[cfg(feature = "parsing")] +mod parsing { + use crate::buffer::Cursor; + use crate::parse::{Parse, ParseStream, Result}; + use crate::token::Token; + use proc_macro2::Ident; + + fn accept_as_ident(ident: &Ident) -> bool { + match ident.to_string().as_str() { + "_" | + // Based on https://doc.rust-lang.org/1.65.0/reference/keywords.html + "abstract" | "as" | "async" | "await" | "become" | "box" | "break" | + "const" | "continue" | "crate" | "do" | "dyn" | "else" | "enum" | + "extern" | "false" | "final" | "fn" | "for" | "if" | "impl" | "in" | + "let" | "loop" | "macro" | "match" | "mod" | "move" | "mut" | + "override" | "priv" | "pub" | "ref" | "return" | "Self" | "self" | + "static" | "struct" | "super" | "trait" | "true" | "try" | "type" | + "typeof" | "unsafe" | "unsized" | "use" | "virtual" | "where" | + "while" | "yield" => false, + _ => true, + } + } + + #[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))] + impl Parse for Ident { + fn parse(input: ParseStream) -> Result<Self> { + input.step(|cursor| { + if let Some((ident, rest)) = cursor.ident() { + if accept_as_ident(&ident) { + Ok((ident, rest)) + } else { + Err(cursor.error(format_args!( + "expected identifier, found keyword `{}`", + ident, + ))) + } + } else { + Err(cursor.error("expected identifier")) + } + }) + } + } + + impl Token for Ident { + fn peek(cursor: Cursor) -> bool { + if let Some((ident, _rest)) = cursor.ident() { + accept_as_ident(&ident) + } else { + false + } + } + + fn display() -> &'static str { + "identifier" + } + } +} diff --git a/vendor/syn/src/item.rs b/vendor/syn/src/item.rs index a1ef7ab43..9d724b063 100644 --- a/vendor/syn/src/item.rs +++ b/vendor/syn/src/item.rs @@ -9,15 +9,13 @@ use std::mem; ast_enum_of_structs! { /// Things that can appear directly inside of a module or scope. /// - /// *This type is available only if Syn is built with the `"full"` feature.* - /// /// # Syntax tree enum /// /// This type is a [syntax tree enum]. /// /// [syntax tree enum]: Expr#syntax-tree-enums #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] - #[cfg_attr(not(syn_no_non_exhaustive), non_exhaustive)] + #[non_exhaustive] pub enum Item { /// A constant item: `const MAX: u16 = 65535`. Const(ItemConst), @@ -42,9 +40,6 @@ ast_enum_of_structs! { /// A macro invocation, which includes `macro_rules!` definitions. Macro(ItemMacro), - /// A 2.0-style declarative macro introduced by the `macro` keyword. - Macro2(ItemMacro2), - /// A module or module declaration: `mod m` or `mod m { ... }`. Mod(ItemMod), @@ -72,8 +67,6 @@ ast_enum_of_structs! { /// Tokens forming an item not interpreted by Syn. Verbatim(TokenStream), - // Not public API. - // // For testing exhaustiveness in downstream code, use the following idiom: // // match item { @@ -90,22 +83,18 @@ ast_enum_of_structs! { // a variant. You will be notified by a test failure when a variant is // added, so that you can add code to handle it, but your library will // continue to compile and work for downstream users in the interim. - #[cfg(syn_no_non_exhaustive)] - #[doc(hidden)] - __NonExhaustive, } } ast_struct! { /// A constant item: `const MAX: u16 = 65535`. - /// - /// *This type is available only if Syn is built with the `"full"` feature.* #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub struct ItemConst { pub attrs: Vec<Attribute>, pub vis: Visibility, pub const_token: Token![const], pub ident: Ident, + pub generics: Generics, pub colon_token: Token![:], pub ty: Box<Type>, pub eq_token: Token![=], @@ -116,8 +105,6 @@ ast_struct! { ast_struct! { /// An enum definition: `enum Foo<A, B> { A(A), B(B) }`. - /// - /// *This type is available only if Syn is built with the `"full"` feature.* #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub struct ItemEnum { pub attrs: Vec<Attribute>, @@ -132,8 +119,6 @@ ast_struct! { ast_struct! { /// An `extern crate` item: `extern crate serde`. - /// - /// *This type is available only if Syn is built with the `"full"` feature.* #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub struct ItemExternCrate { pub attrs: Vec<Attribute>, @@ -147,10 +132,7 @@ ast_struct! { } ast_struct! { - /// A free-standing function: `fn process(n: usize) -> Result<()> { ... - /// }`. - /// - /// *This type is available only if Syn is built with the `"full"` feature.* + /// A free-standing function: `fn process(n: usize) -> Result<()> { ... }`. #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub struct ItemFn { pub attrs: Vec<Attribute>, @@ -162,11 +144,10 @@ ast_struct! { ast_struct! { /// A block of foreign items: `extern "C" { ... }`. - /// - /// *This type is available only if Syn is built with the `"full"` feature.* #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub struct ItemForeignMod { pub attrs: Vec<Attribute>, + pub unsafety: Option<Token![unsafe]>, pub abi: Abi, pub brace_token: token::Brace, pub items: Vec<ForeignItem>, @@ -176,8 +157,6 @@ ast_struct! { ast_struct! { /// An impl block providing trait or associated items: `impl<A> Trait /// for Data<A> { ... }`. - /// - /// *This type is available only if Syn is built with the `"full"` feature.* #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub struct ItemImpl { pub attrs: Vec<Attribute>, @@ -196,8 +175,6 @@ ast_struct! { ast_struct! { /// A macro invocation, which includes `macro_rules!` definitions. - /// - /// *This type is available only if Syn is built with the `"full"` feature.* #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub struct ItemMacro { pub attrs: Vec<Attribute>, @@ -209,27 +186,12 @@ ast_struct! { } ast_struct! { - /// A 2.0-style declarative macro introduced by the `macro` keyword. - /// - /// *This type is available only if Syn is built with the `"full"` feature.* - #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] - pub struct ItemMacro2 { - pub attrs: Vec<Attribute>, - pub vis: Visibility, - pub macro_token: Token![macro], - pub ident: Ident, - pub rules: TokenStream, - } -} - -ast_struct! { /// A module or module declaration: `mod m` or `mod m { ... }`. - /// - /// *This type is available only if Syn is built with the `"full"` feature.* #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub struct ItemMod { pub attrs: Vec<Attribute>, pub vis: Visibility, + pub unsafety: Option<Token![unsafe]>, pub mod_token: Token![mod], pub ident: Ident, pub content: Option<(token::Brace, Vec<Item>)>, @@ -239,14 +201,12 @@ ast_struct! { ast_struct! { /// A static item: `static BIKE: Shed = Shed(42)`. - /// - /// *This type is available only if Syn is built with the `"full"` feature.* #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub struct ItemStatic { pub attrs: Vec<Attribute>, pub vis: Visibility, pub static_token: Token![static], - pub mutability: Option<Token![mut]>, + pub mutability: StaticMutability, pub ident: Ident, pub colon_token: Token![:], pub ty: Box<Type>, @@ -258,8 +218,6 @@ ast_struct! { ast_struct! { /// A struct definition: `struct Foo<A> { x: A }`. - /// - /// *This type is available only if Syn is built with the `"full"` feature.* #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub struct ItemStruct { pub attrs: Vec<Attribute>, @@ -274,14 +232,13 @@ ast_struct! { ast_struct! { /// A trait definition: `pub trait Iterator { ... }`. - /// - /// *This type is available only if Syn is built with the `"full"` feature.* #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub struct ItemTrait { pub attrs: Vec<Attribute>, pub vis: Visibility, pub unsafety: Option<Token![unsafe]>, pub auto_token: Option<Token![auto]>, + pub restriction: Option<ImplRestriction>, pub trait_token: Token![trait], pub ident: Ident, pub generics: Generics, @@ -294,8 +251,6 @@ ast_struct! { ast_struct! { /// A trait alias: `pub trait SharableIterator = Iterator + Sync`. - /// - /// *This type is available only if Syn is built with the `"full"` feature.* #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub struct ItemTraitAlias { pub attrs: Vec<Attribute>, @@ -311,8 +266,6 @@ ast_struct! { ast_struct! { /// A type alias: `type Result<T> = std::result::Result<T, MyError>`. - /// - /// *This type is available only if Syn is built with the `"full"` feature.* #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub struct ItemType { pub attrs: Vec<Attribute>, @@ -328,8 +281,6 @@ ast_struct! { ast_struct! { /// A union definition: `union Foo<A, B> { x: A, y: B }`. - /// - /// *This type is available only if Syn is built with the `"full"` feature.* #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub struct ItemUnion { pub attrs: Vec<Attribute>, @@ -343,8 +294,6 @@ ast_struct! { ast_struct! { /// A use declaration: `use std::collections::HashMap`. - /// - /// *This type is available only if Syn is built with the `"full"` feature.* #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub struct ItemUse { pub attrs: Vec<Attribute>, @@ -360,26 +309,22 @@ impl Item { #[cfg(feature = "parsing")] pub(crate) fn replace_attrs(&mut self, new: Vec<Attribute>) -> Vec<Attribute> { match self { - Item::ExternCrate(ItemExternCrate { attrs, .. }) - | Item::Use(ItemUse { attrs, .. }) - | Item::Static(ItemStatic { attrs, .. }) - | Item::Const(ItemConst { attrs, .. }) + Item::Const(ItemConst { attrs, .. }) + | Item::Enum(ItemEnum { attrs, .. }) + | Item::ExternCrate(ItemExternCrate { attrs, .. }) | Item::Fn(ItemFn { attrs, .. }) - | Item::Mod(ItemMod { attrs, .. }) | Item::ForeignMod(ItemForeignMod { attrs, .. }) - | Item::Type(ItemType { attrs, .. }) + | Item::Impl(ItemImpl { attrs, .. }) + | Item::Macro(ItemMacro { attrs, .. }) + | Item::Mod(ItemMod { attrs, .. }) + | Item::Static(ItemStatic { attrs, .. }) | Item::Struct(ItemStruct { attrs, .. }) - | Item::Enum(ItemEnum { attrs, .. }) - | Item::Union(ItemUnion { attrs, .. }) | Item::Trait(ItemTrait { attrs, .. }) | Item::TraitAlias(ItemTraitAlias { attrs, .. }) - | Item::Impl(ItemImpl { attrs, .. }) - | Item::Macro(ItemMacro { attrs, .. }) - | Item::Macro2(ItemMacro2 { attrs, .. }) => mem::replace(attrs, new), + | Item::Type(ItemType { attrs, .. }) + | Item::Union(ItemUnion { attrs, .. }) + | Item::Use(ItemUse { attrs, .. }) => mem::replace(attrs, new), Item::Verbatim(_) => Vec::new(), - - #[cfg(syn_no_non_exhaustive)] - _ => unreachable!(), } } } @@ -467,8 +412,6 @@ impl From<ItemUnion> for DeriveInput { ast_enum_of_structs! { /// A suffix of an import tree in a `use` item: `Type as Renamed` or `*`. /// - /// *This type is available only if Syn is built with the `"full"` feature.* - /// /// # Syntax tree enum /// /// This type is a [syntax tree enum]. @@ -495,8 +438,6 @@ ast_enum_of_structs! { ast_struct! { /// A path prefix of imports in a `use` item: `std::...`. - /// - /// *This type is available only if Syn is built with the `"full"` feature.* #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub struct UsePath { pub ident: Ident, @@ -507,8 +448,6 @@ ast_struct! { ast_struct! { /// An identifier imported by a `use` item: `HashMap`. - /// - /// *This type is available only if Syn is built with the `"full"` feature.* #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub struct UseName { pub ident: Ident, @@ -517,8 +456,6 @@ ast_struct! { ast_struct! { /// An renamed identifier imported by a `use` item: `HashMap as Map`. - /// - /// *This type is available only if Syn is built with the `"full"` feature.* #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub struct UseRename { pub ident: Ident, @@ -529,8 +466,6 @@ ast_struct! { ast_struct! { /// A glob import in a `use` item: `*`. - /// - /// *This type is available only if Syn is built with the `"full"` feature.* #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub struct UseGlob { pub star_token: Token![*], @@ -539,8 +474,6 @@ ast_struct! { ast_struct! { /// A braced group of imports in a `use` item: `{A, B, C}`. - /// - /// *This type is available only if Syn is built with the `"full"` feature.* #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub struct UseGroup { pub brace_token: token::Brace, @@ -551,15 +484,13 @@ ast_struct! { ast_enum_of_structs! { /// An item within an `extern` block. /// - /// *This type is available only if Syn is built with the `"full"` feature.* - /// /// # Syntax tree enum /// /// This type is a [syntax tree enum]. /// /// [syntax tree enum]: Expr#syntax-tree-enums #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] - #[cfg_attr(not(syn_no_non_exhaustive), non_exhaustive)] + #[non_exhaustive] pub enum ForeignItem { /// A foreign function in an `extern` block. Fn(ForeignItemFn), @@ -576,8 +507,6 @@ ast_enum_of_structs! { /// Tokens in an `extern` block not interpreted by Syn. Verbatim(TokenStream), - // Not public API. - // // For testing exhaustiveness in downstream code, use the following idiom: // // match item { @@ -594,16 +523,11 @@ ast_enum_of_structs! { // a variant. You will be notified by a test failure when a variant is // added, so that you can add code to handle it, but your library will // continue to compile and work for downstream users in the interim. - #[cfg(syn_no_non_exhaustive)] - #[doc(hidden)] - __NonExhaustive, } } ast_struct! { /// A foreign function in an `extern` block. - /// - /// *This type is available only if Syn is built with the `"full"` feature.* #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub struct ForeignItemFn { pub attrs: Vec<Attribute>, @@ -615,14 +539,12 @@ ast_struct! { ast_struct! { /// A foreign static item in an `extern` block: `static ext: u8`. - /// - /// *This type is available only if Syn is built with the `"full"` feature.* #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub struct ForeignItemStatic { pub attrs: Vec<Attribute>, pub vis: Visibility, pub static_token: Token![static], - pub mutability: Option<Token![mut]>, + pub mutability: StaticMutability, pub ident: Ident, pub colon_token: Token![:], pub ty: Box<Type>, @@ -632,22 +554,19 @@ ast_struct! { ast_struct! { /// A foreign type in an `extern` block: `type void`. - /// - /// *This type is available only if Syn is built with the `"full"` feature.* #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub struct ForeignItemType { pub attrs: Vec<Attribute>, pub vis: Visibility, pub type_token: Token![type], pub ident: Ident, + pub generics: Generics, pub semi_token: Token![;], } } ast_struct! { /// A macro invocation within an extern block. - /// - /// *This type is available only if Syn is built with the `"full"` feature.* #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub struct ForeignItemMacro { pub attrs: Vec<Attribute>, @@ -659,21 +578,19 @@ ast_struct! { ast_enum_of_structs! { /// An item declaration within the definition of a trait. /// - /// *This type is available only if Syn is built with the `"full"` feature.* - /// /// # Syntax tree enum /// /// This type is a [syntax tree enum]. /// /// [syntax tree enum]: Expr#syntax-tree-enums #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] - #[cfg_attr(not(syn_no_non_exhaustive), non_exhaustive)] + #[non_exhaustive] pub enum TraitItem { /// An associated constant within the definition of a trait. Const(TraitItemConst), - /// A trait method within the definition of a trait. - Method(TraitItemMethod), + /// An associated function within the definition of a trait. + Fn(TraitItemFn), /// An associated type within the definition of a trait. Type(TraitItemType), @@ -684,13 +601,11 @@ ast_enum_of_structs! { /// Tokens within the definition of a trait not interpreted by Syn. Verbatim(TokenStream), - // Not public API. - // // For testing exhaustiveness in downstream code, use the following idiom: // // match item { // TraitItem::Const(item) => {...} - // TraitItem::Method(item) => {...} + // TraitItem::Fn(item) => {...} // ... // TraitItem::Verbatim(item) => {...} // @@ -702,21 +617,17 @@ ast_enum_of_structs! { // a variant. You will be notified by a test failure when a variant is // added, so that you can add code to handle it, but your library will // continue to compile and work for downstream users in the interim. - #[cfg(syn_no_non_exhaustive)] - #[doc(hidden)] - __NonExhaustive, } } ast_struct! { /// An associated constant within the definition of a trait. - /// - /// *This type is available only if Syn is built with the `"full"` feature.* #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub struct TraitItemConst { pub attrs: Vec<Attribute>, pub const_token: Token![const], pub ident: Ident, + pub generics: Generics, pub colon_token: Token![:], pub ty: Type, pub default: Option<(Token![=], Expr)>, @@ -725,11 +636,9 @@ ast_struct! { } ast_struct! { - /// A trait method within the definition of a trait. - /// - /// *This type is available only if Syn is built with the `"full"` feature.* + /// An associated function within the definition of a trait. #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] - pub struct TraitItemMethod { + pub struct TraitItemFn { pub attrs: Vec<Attribute>, pub sig: Signature, pub default: Option<Block>, @@ -739,8 +648,6 @@ ast_struct! { ast_struct! { /// An associated type within the definition of a trait. - /// - /// *This type is available only if Syn is built with the `"full"` feature.* #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub struct TraitItemType { pub attrs: Vec<Attribute>, @@ -756,8 +663,6 @@ ast_struct! { ast_struct! { /// A macro invocation within the definition of a trait. - /// - /// *This type is available only if Syn is built with the `"full"` feature.* #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub struct TraitItemMacro { pub attrs: Vec<Attribute>, @@ -769,21 +674,19 @@ ast_struct! { ast_enum_of_structs! { /// An item within an impl block. /// - /// *This type is available only if Syn is built with the `"full"` feature.* - /// /// # Syntax tree enum /// /// This type is a [syntax tree enum]. /// /// [syntax tree enum]: Expr#syntax-tree-enums #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] - #[cfg_attr(not(syn_no_non_exhaustive), non_exhaustive)] + #[non_exhaustive] pub enum ImplItem { /// An associated constant within an impl block. Const(ImplItemConst), - /// A method within an impl block. - Method(ImplItemMethod), + /// An associated function within an impl block. + Fn(ImplItemFn), /// An associated type within an impl block. Type(ImplItemType), @@ -794,13 +697,11 @@ ast_enum_of_structs! { /// Tokens within an impl block not interpreted by Syn. Verbatim(TokenStream), - // Not public API. - // // For testing exhaustiveness in downstream code, use the following idiom: // // match item { // ImplItem::Const(item) => {...} - // ImplItem::Method(item) => {...} + // ImplItem::Fn(item) => {...} // ... // ImplItem::Verbatim(item) => {...} // @@ -812,16 +713,11 @@ ast_enum_of_structs! { // a variant. You will be notified by a test failure when a variant is // added, so that you can add code to handle it, but your library will // continue to compile and work for downstream users in the interim. - #[cfg(syn_no_non_exhaustive)] - #[doc(hidden)] - __NonExhaustive, } } ast_struct! { /// An associated constant within an impl block. - /// - /// *This type is available only if Syn is built with the `"full"` feature.* #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub struct ImplItemConst { pub attrs: Vec<Attribute>, @@ -829,6 +725,7 @@ ast_struct! { pub defaultness: Option<Token![default]>, pub const_token: Token![const], pub ident: Ident, + pub generics: Generics, pub colon_token: Token![:], pub ty: Type, pub eq_token: Token![=], @@ -838,11 +735,9 @@ ast_struct! { } ast_struct! { - /// A method within an impl block. - /// - /// *This type is available only if Syn is built with the `"full"` feature.* + /// An associated function within an impl block. #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] - pub struct ImplItemMethod { + pub struct ImplItemFn { pub attrs: Vec<Attribute>, pub vis: Visibility, pub defaultness: Option<Token![default]>, @@ -853,8 +748,6 @@ ast_struct! { ast_struct! { /// An associated type within an impl block. - /// - /// *This type is available only if Syn is built with the `"full"` feature.* #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub struct ImplItemType { pub attrs: Vec<Attribute>, @@ -871,8 +764,6 @@ ast_struct! { ast_struct! { /// A macro invocation within an impl block. - /// - /// *This type is available only if Syn is built with the `"full"` feature.* #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub struct ImplItemMacro { pub attrs: Vec<Attribute>, @@ -884,8 +775,6 @@ ast_struct! { ast_struct! { /// A function signature in a trait or implementation: `unsafe fn /// initialize(&self)`. - /// - /// *This type is available only if Syn is built with the `"full"` feature.* #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub struct Signature { pub constness: Option<Token![const]>, @@ -904,33 +793,20 @@ ast_struct! { impl Signature { /// A method's `self` receiver, such as `&self` or `self: Box<Self>`. - pub fn receiver(&self) -> Option<&FnArg> { + pub fn receiver(&self) -> Option<&Receiver> { let arg = self.inputs.first()?; match arg { - FnArg::Receiver(_) => Some(arg), - FnArg::Typed(PatType { pat, .. }) => { - if let Pat::Ident(PatIdent { ident, .. }) = &**pat { - if ident == "self" { - return Some(arg); - } - } - None - } + FnArg::Receiver(receiver) => Some(receiver), + FnArg::Typed(_) => None, } } } ast_enum_of_structs! { /// An argument in a function signature: the `n: usize` in `fn f(n: usize)`. - /// - /// *This type is available only if Syn is built with the `"full"` feature.* #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub enum FnArg { - /// The `self` argument of an associated method, whether taken by value - /// or by reference. - /// - /// Note that `self` receivers with a specified type, such as `self: - /// Box<Self>`, are parsed as a `FnArg::Typed`. + /// The `self` argument of an associated method. Receiver(Receiver), /// A function argument accepted by pattern and type. @@ -939,19 +815,21 @@ ast_enum_of_structs! { } ast_struct! { - /// The `self` argument of an associated method, whether taken by value - /// or by reference. + /// The `self` argument of an associated method. /// - /// Note that `self` receivers with a specified type, such as `self: - /// Box<Self>`, are parsed as a `FnArg::Typed`. - /// - /// *This type is available only if Syn is built with the `"full"` feature.* + /// If `colon_token` is present, the receiver is written with an explicit + /// type such as `self: Box<Self>`. If `colon_token` is absent, the receiver + /// is written in shorthand such as `self` or `&self` or `&mut self`. In the + /// shorthand case, the type in `ty` is reconstructed as one of `Self`, + /// `&Self`, or `&mut Self`. #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub struct Receiver { pub attrs: Vec<Attribute>, pub reference: Option<(Token![&], Option<Lifetime>)>, pub mutability: Option<Token![mut]>, pub self_token: Token![self], + pub colon_token: Option<Token![:]>, + pub ty: Box<Type>, } } @@ -961,17 +839,63 @@ impl Receiver { } } +ast_struct! { + /// The variadic argument of a foreign function. + /// + /// ```rust + /// # struct c_char; + /// # struct c_int; + /// # + /// extern "C" { + /// fn printf(format: *const c_char, ...) -> c_int; + /// // ^^^ + /// } + /// ``` + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] + pub struct Variadic { + pub attrs: Vec<Attribute>, + pub pat: Option<(Box<Pat>, Token![:])>, + pub dots: Token![...], + pub comma: Option<Token![,]>, + } +} + +ast_enum! { + /// The mutability of an `Item::Static` or `ForeignItem::Static`. + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] + #[non_exhaustive] + pub enum StaticMutability { + Mut(Token![mut]), + None, + } +} + +ast_enum! { + /// Unused, but reserved for RFC 3323 restrictions. + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] + #[non_exhaustive] + pub enum ImplRestriction {} + + + // TODO: https://rust-lang.github.io/rfcs/3323-restrictions.html + // + // pub struct ImplRestriction { + // pub impl_token: Token![impl], + // pub paren_token: token::Paren, + // pub in_token: Option<Token![in]>, + // pub path: Box<Path>, + // } +} + #[cfg(feature = "parsing")] -pub mod parsing { +pub(crate) mod parsing { use super::*; use crate::ext::IdentExt; use crate::parse::discouraged::Speculative; use crate::parse::{Parse, ParseBuffer, ParseStream, Result}; use crate::token::Brace; - use proc_macro2::{Delimiter, Group, Punct, Spacing, TokenTree}; - use std::iter::{self, FromIterator}; - - crate::custom_keyword!(macro_rules); + use proc_macro2::{Punct, Spacing, TokenTree}; + use std::iter::FromIterator; #[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))] impl Parse for Item { @@ -1010,7 +934,11 @@ pub mod parsing { Err(lookahead.error()) } } else if lookahead.peek(Token![use]) { - input.parse().map(Item::Use) + let allow_crate_root_in_path = true; + match parse_item_use(input, allow_crate_root_in_path)? { + Some(item_use) => Ok(Item::Use(item_use)), + None => Ok(Item::Verbatim(verbatim::between(begin, input))), + } } else if lookahead.peek(Token![static]) { let vis = input.parse()?; let static_token = input.parse()?; @@ -1067,6 +995,7 @@ pub mod parsing { vis, const_token, ident, + generics: Generics::default(), colon_token, ty, eq_token: input.parse()?, @@ -1092,15 +1021,9 @@ pub mod parsing { Ok(Item::Verbatim(verbatim::between(begin, input))) } } else if lookahead.peek(Token![extern]) { - input.parse::<Visibility>()?; - input.parse::<Token![unsafe]>()?; - input.parse::<ItemForeignMod>()?; - Ok(Item::Verbatim(verbatim::between(begin, input))) + input.parse().map(Item::ForeignMod) } else if lookahead.peek(Token![mod]) { - input.parse::<Visibility>()?; - input.parse::<Token![unsafe]>()?; - input.parse::<ItemMod>()?; - Ok(Item::Verbatim(verbatim::between(begin, input))) + input.parse().map(Item::Mod) } else { Err(lookahead.error()) } @@ -1128,7 +1051,8 @@ pub mod parsing { Ok(Item::Verbatim(verbatim::between(begin, input))) } } else if lookahead.peek(Token![macro]) { - input.parse().map(Item::Macro2) + input.advance_to(&ahead); + parse_macro2(begin, vis, input) } else if vis.is_inherited() && (lookahead.peek(Ident) || lookahead.peek(Token![self]) @@ -1137,10 +1061,6 @@ pub mod parsing { || lookahead.peek(Token![::])) { input.parse().map(Item::Macro) - } else if ahead.peek(macro_rules) { - input.advance_to(&ahead); - input.parse::<ItemMacro>()?; - Ok(Item::Verbatim(verbatim::between(begin, input))) } else { Err(lookahead.error()) }?; @@ -1167,7 +1087,6 @@ pub mod parsing { // type Ty<T> where T: 'static = T; BeforeEq, // type Ty<T> = T where T: 'static; - #[allow(dead_code)] AfterEq, // TODO: goes away once the migration period on rust-lang/rust#89122 is over Both, @@ -1200,7 +1119,7 @@ pub mod parsing { WhereClauseLocation::BeforeEq | WhereClauseLocation::Both => { generics.where_clause = input.parse()?; } - _ => {} + WhereClauseLocation::AfterEq => {} } let ty = if let Some(eq_token) = input.parse()? { @@ -1240,7 +1159,11 @@ pub mod parsing { let attrs = input.call(Attribute::parse_outer)?; let path = input.call(Path::parse_mod_style)?; let bang_token: Token![!] = input.parse()?; - let ident: Option<Ident> = input.parse()?; + let ident: Option<Ident> = if input.peek(Token![try]) { + input.call(Ident::parse_any).map(Some) + } else { + input.parse() + }?; let (delimiter, tokens) = input.call(mac::parse_delimiter)?; let semi_token: Option<Token![;]> = if !delimiter.is_brace() { Some(input.parse()?) @@ -1261,45 +1184,27 @@ pub mod parsing { } } - #[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))] - impl Parse for ItemMacro2 { - fn parse(input: ParseStream) -> Result<Self> { - let attrs = input.call(Attribute::parse_outer)?; - let vis: Visibility = input.parse()?; - let macro_token: Token![macro] = input.parse()?; - let ident: Ident = input.parse()?; - let mut rules = TokenStream::new(); - - let mut lookahead = input.lookahead1(); - if lookahead.peek(token::Paren) { - let paren_content; - let paren_token = parenthesized!(paren_content in input); - let args: TokenStream = paren_content.parse()?; - let mut args = Group::new(Delimiter::Parenthesis, args); - args.set_span(paren_token.span); - rules.extend(iter::once(TokenTree::Group(args))); - lookahead = input.lookahead1(); - } + fn parse_macro2(begin: ParseBuffer, _vis: Visibility, input: ParseStream) -> Result<Item> { + input.parse::<Token![macro]>()?; + input.parse::<Ident>()?; - if lookahead.peek(token::Brace) { - let brace_content; - let brace_token = braced!(brace_content in input); - let body: TokenStream = brace_content.parse()?; - let mut body = Group::new(Delimiter::Brace, body); - body.set_span(brace_token.span); - rules.extend(iter::once(TokenTree::Group(body))); - } else { - return Err(lookahead.error()); - } + let mut lookahead = input.lookahead1(); + if lookahead.peek(token::Paren) { + let paren_content; + parenthesized!(paren_content in input); + paren_content.parse::<TokenStream>()?; + lookahead = input.lookahead1(); + } - Ok(ItemMacro2 { - attrs, - vis, - macro_token, - ident, - rules, - }) + if lookahead.peek(token::Brace) { + let brace_content; + braced!(brace_content in input); + brace_content.parse::<TokenStream>()?; + } else { + return Err(lookahead.error()); } + + Ok(Item::Verbatim(verbatim::between(begin, input))) } #[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))] @@ -1338,63 +1243,110 @@ pub mod parsing { #[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))] impl Parse for ItemUse { fn parse(input: ParseStream) -> Result<Self> { - Ok(ItemUse { - attrs: input.call(Attribute::parse_outer)?, - vis: input.parse()?, - use_token: input.parse()?, - leading_colon: input.parse()?, - tree: input.parse()?, - semi_token: input.parse()?, - }) + let allow_crate_root_in_path = false; + parse_item_use(input, allow_crate_root_in_path).map(Option::unwrap) } } + fn parse_item_use( + input: ParseStream, + allow_crate_root_in_path: bool, + ) -> Result<Option<ItemUse>> { + let attrs = input.call(Attribute::parse_outer)?; + let vis: Visibility = input.parse()?; + let use_token: Token![use] = input.parse()?; + let leading_colon: Option<Token![::]> = input.parse()?; + let tree = parse_use_tree(input, allow_crate_root_in_path && leading_colon.is_none())?; + let semi_token: Token![;] = input.parse()?; + + let tree = match tree { + Some(tree) => tree, + None => return Ok(None), + }; + + Ok(Some(ItemUse { + attrs, + vis, + use_token, + leading_colon, + tree, + semi_token, + })) + } + #[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))] impl Parse for UseTree { fn parse(input: ParseStream) -> Result<UseTree> { - let lookahead = input.lookahead1(); - if lookahead.peek(Ident) - || lookahead.peek(Token![self]) - || lookahead.peek(Token![super]) - || lookahead.peek(Token![crate]) - { - let ident = input.call(Ident::parse_any)?; - if input.peek(Token![::]) { - Ok(UseTree::Path(UsePath { - ident, - colon2_token: input.parse()?, - tree: Box::new(input.parse()?), - })) - } else if input.peek(Token![as]) { - Ok(UseTree::Rename(UseRename { - ident, - as_token: input.parse()?, - rename: { - if input.peek(Ident) { - input.parse()? - } else if input.peek(Token![_]) { - Ident::from(input.parse::<Token![_]>()?) - } else { - return Err(input.error("expected identifier or underscore")); - } - }, - })) - } else { - Ok(UseTree::Name(UseName { ident })) + let allow_crate_root_in_path = false; + parse_use_tree(input, allow_crate_root_in_path).map(Option::unwrap) + } + } + + fn parse_use_tree( + input: ParseStream, + allow_crate_root_in_path: bool, + ) -> Result<Option<UseTree>> { + let lookahead = input.lookahead1(); + if lookahead.peek(Ident) + || lookahead.peek(Token![self]) + || lookahead.peek(Token![super]) + || lookahead.peek(Token![crate]) + || lookahead.peek(Token![try]) + { + let ident = input.call(Ident::parse_any)?; + if input.peek(Token![::]) { + Ok(Some(UseTree::Path(UsePath { + ident, + colon2_token: input.parse()?, + tree: Box::new(input.parse()?), + }))) + } else if input.peek(Token![as]) { + Ok(Some(UseTree::Rename(UseRename { + ident, + as_token: input.parse()?, + rename: { + if input.peek(Ident) { + input.parse()? + } else if input.peek(Token![_]) { + Ident::from(input.parse::<Token![_]>()?) + } else { + return Err(input.error("expected identifier or underscore")); + } + }, + }))) + } else { + Ok(Some(UseTree::Name(UseName { ident }))) + } + } else if lookahead.peek(Token![*]) { + Ok(Some(UseTree::Glob(UseGlob { + star_token: input.parse()?, + }))) + } else if lookahead.peek(token::Brace) { + let content; + let brace_token = braced!(content in input); + let mut items = Punctuated::new(); + let mut has_crate_root_in_path = false; + loop { + if content.is_empty() { + break; } - } else if lookahead.peek(Token![*]) { - Ok(UseTree::Glob(UseGlob { - star_token: input.parse()?, - })) - } else if lookahead.peek(token::Brace) { - let content; - Ok(UseTree::Group(UseGroup { - brace_token: braced!(content in input), - items: content.parse_terminated(UseTree::parse)?, - })) + has_crate_root_in_path |= + allow_crate_root_in_path && content.parse::<Option<Token![::]>>()?.is_some(); + let tree: UseTree = content.parse()?; + items.push_value(tree); + if content.is_empty() { + break; + } + let comma: Token![,] = content.parse()?; + items.push_punct(comma); + } + if has_crate_root_in_path { + Ok(None) } else { - Err(lookahead.error()) + Ok(Some(UseTree::Group(UseGroup { brace_token, items }))) } + } else { + Err(lookahead.error()) } } @@ -1431,6 +1383,7 @@ pub mod parsing { return Err(lookahead.error()); } }, + generics: Generics::default(), colon_token: input.parse()?, ty: input.parse()?, eq_token: input.parse()?, @@ -1440,54 +1393,6 @@ pub mod parsing { } } - fn pop_variadic(args: &mut Punctuated<FnArg, Token![,]>) -> Option<Variadic> { - let trailing_punct = args.trailing_punct(); - - let last = match args.last_mut()? { - FnArg::Typed(last) => last, - _ => return None, - }; - - let ty = match last.ty.as_ref() { - Type::Verbatim(ty) => ty, - _ => return None, - }; - - let mut variadic = Variadic { - attrs: Vec::new(), - dots: parse2(ty.clone()).ok()?, - }; - - if let Pat::Verbatim(pat) = last.pat.as_ref() { - if pat.to_string() == "..." && !trailing_punct { - variadic.attrs = mem::replace(&mut last.attrs, Vec::new()); - args.pop(); - } - } - - Some(variadic) - } - - fn variadic_to_tokens(dots: &Token![...]) -> TokenStream { - TokenStream::from_iter(vec![ - TokenTree::Punct({ - let mut dot = Punct::new('.', Spacing::Joint); - dot.set_span(dots.spans[0]); - dot - }), - TokenTree::Punct({ - let mut dot = Punct::new('.', Spacing::Joint); - dot.set_span(dots.spans[1]); - dot - }), - TokenTree::Punct({ - let mut dot = Punct::new('.', Spacing::Alone); - dot.set_span(dots.spans[2]); - dot - }), - ]) - } - fn peek_signature(input: ParseStream) -> bool { let fork = input.fork(); fork.parse::<Option<Token![const]>>().is_ok() @@ -1510,8 +1415,7 @@ pub mod parsing { let content; let paren_token = parenthesized!(content in input); - let mut inputs = parse_fn_args(&content)?; - let variadic = pop_variadic(&mut inputs); + let (inputs, variadic) = parse_fn_args(&content)?; let output: ReturnType = input.parse()?; generics.where_clause = input.parse()?; @@ -1564,78 +1468,171 @@ pub mod parsing { #[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))] impl Parse for FnArg { fn parse(input: ParseStream) -> Result<Self> { + let allow_variadic = false; let attrs = input.call(Attribute::parse_outer)?; - - let ahead = input.fork(); - if let Ok(mut receiver) = ahead.parse::<Receiver>() { - if !ahead.peek(Token![:]) { - input.advance_to(&ahead); - receiver.attrs = attrs; - return Ok(FnArg::Receiver(receiver)); - } + match parse_fn_arg_or_variadic(input, attrs, allow_variadic)? { + FnArgOrVariadic::FnArg(arg) => Ok(arg), + FnArgOrVariadic::Variadic(_) => unreachable!(), } + } + } + + enum FnArgOrVariadic { + FnArg(FnArg), + Variadic(Variadic), + } + + fn parse_fn_arg_or_variadic( + input: ParseStream, + attrs: Vec<Attribute>, + allow_variadic: bool, + ) -> Result<FnArgOrVariadic> { + let ahead = input.fork(); + if let Ok(mut receiver) = ahead.parse::<Receiver>() { + input.advance_to(&ahead); + receiver.attrs = attrs; + return Ok(FnArgOrVariadic::FnArg(FnArg::Receiver(receiver))); + } + + // Hack to parse pre-2018 syntax in + // test/ui/rfc-2565-param-attrs/param-attrs-pretty.rs + // because the rest of the test case is valuable. + if input.peek(Ident) && input.peek2(Token![<]) { + let span = input.fork().parse::<Ident>()?.span(); + return Ok(FnArgOrVariadic::FnArg(FnArg::Typed(PatType { + attrs, + pat: Box::new(Pat::Wild(PatWild { + attrs: Vec::new(), + underscore_token: Token![_](span), + })), + colon_token: Token![:](span), + ty: input.parse()?, + }))); + } + + let pat = Box::new(Pat::parse_single(input)?); + let colon_token: Token![:] = input.parse()?; - let mut typed = input.call(fn_arg_typed)?; - typed.attrs = attrs; - Ok(FnArg::Typed(typed)) + if allow_variadic { + if let Some(dots) = input.parse::<Option<Token![...]>>()? { + return Ok(FnArgOrVariadic::Variadic(Variadic { + attrs, + pat: Some((pat, colon_token)), + dots, + comma: None, + })); + } } + + Ok(FnArgOrVariadic::FnArg(FnArg::Typed(PatType { + attrs, + pat, + colon_token, + ty: input.parse()?, + }))) } #[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))] impl Parse for Receiver { fn parse(input: ParseStream) -> Result<Self> { + let reference = if input.peek(Token![&]) { + let ampersand: Token![&] = input.parse()?; + let lifetime: Option<Lifetime> = input.parse()?; + Some((ampersand, lifetime)) + } else { + None + }; + let mutability: Option<Token![mut]> = input.parse()?; + let self_token: Token![self] = input.parse()?; + let colon_token: Option<Token![:]> = if reference.is_some() { + None + } else { + input.parse()? + }; + let ty: Type = if colon_token.is_some() { + input.parse()? + } else { + let mut ty = Type::Path(TypePath { + qself: None, + path: Path::from(Ident::new("Self", self_token.span)), + }); + if let Some((ampersand, lifetime)) = reference.as_ref() { + ty = Type::Reference(TypeReference { + and_token: Token![&](ampersand.span), + lifetime: lifetime.clone(), + mutability: mutability.as_ref().map(|m| Token![mut](m.span)), + elem: Box::new(ty), + }); + } + ty + }; Ok(Receiver { attrs: Vec::new(), - reference: { - if input.peek(Token![&]) { - Some((input.parse()?, input.parse()?)) - } else { - None - } - }, - mutability: input.parse()?, - self_token: input.parse()?, + reference, + mutability, + self_token, + colon_token, + ty: Box::new(ty), }) } } - fn parse_fn_args(input: ParseStream) -> Result<Punctuated<FnArg, Token![,]>> { + fn parse_fn_args( + input: ParseStream, + ) -> Result<(Punctuated<FnArg, Token![,]>, Option<Variadic>)> { let mut args = Punctuated::new(); + let mut variadic = None; let mut has_receiver = false; while !input.is_empty() { let attrs = input.call(Attribute::parse_outer)?; - let arg = if let Some(dots) = input.parse::<Option<Token![...]>>()? { - FnArg::Typed(PatType { + if let Some(dots) = input.parse::<Option<Token![...]>>()? { + variadic = Some(Variadic { attrs, - pat: Box::new(Pat::Verbatim(variadic_to_tokens(&dots))), - colon_token: Token![:](dots.spans[0]), - ty: Box::new(Type::Verbatim(variadic_to_tokens(&dots))), - }) - } else { - let mut arg: FnArg = input.parse()?; - match &mut arg { - FnArg::Receiver(receiver) if has_receiver => { - return Err(Error::new( - receiver.self_token.span, - "unexpected second method receiver", - )); - } - FnArg::Receiver(receiver) if !args.is_empty() => { - return Err(Error::new( - receiver.self_token.span, - "unexpected method receiver", - )); - } - FnArg::Receiver(receiver) => { - has_receiver = true; - receiver.attrs = attrs; - } - FnArg::Typed(arg) => arg.attrs = attrs, + pat: None, + dots, + comma: if input.is_empty() { + None + } else { + Some(input.parse()?) + }, + }); + break; + } + + let allow_variadic = true; + let arg = match parse_fn_arg_or_variadic(input, attrs, allow_variadic)? { + FnArgOrVariadic::FnArg(arg) => arg, + FnArgOrVariadic::Variadic(arg) => { + variadic = Some(Variadic { + comma: if input.is_empty() { + None + } else { + Some(input.parse()?) + }, + ..arg + }); + break; } - arg }; + + match &arg { + FnArg::Receiver(receiver) if has_receiver => { + return Err(Error::new( + receiver.self_token.span, + "unexpected second method receiver", + )); + } + FnArg::Receiver(receiver) if !args.is_empty() => { + return Err(Error::new( + receiver.self_token.span, + "unexpected method receiver", + )); + } + FnArg::Receiver(_) => has_receiver = true, + FnArg::Typed(_) => {} + } args.push_value(arg); if input.is_empty() { @@ -1646,35 +1643,7 @@ pub mod parsing { args.push_punct(comma); } - Ok(args) - } - - fn fn_arg_typed(input: ParseStream) -> Result<PatType> { - // Hack to parse pre-2018 syntax in - // test/ui/rfc-2565-param-attrs/param-attrs-pretty.rs - // because the rest of the test case is valuable. - if input.peek(Ident) && input.peek2(Token![<]) { - let span = input.fork().parse::<Ident>()?.span(); - return Ok(PatType { - attrs: Vec::new(), - pat: Box::new(Pat::Wild(PatWild { - attrs: Vec::new(), - underscore_token: Token![_](span), - })), - colon_token: Token![:](span), - ty: input.parse()?, - }); - } - - Ok(PatType { - attrs: Vec::new(), - pat: Box::new(pat::parsing::multi_pat(input)?), - colon_token: input.parse()?, - ty: Box::new(match input.parse::<Option<Token![...]>>()? { - Some(dot3) => Type::Verbatim(variadic_to_tokens(&dot3)), - None => input.parse()?, - }), - }) + Ok((args, variadic)) } #[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))] @@ -1682,14 +1651,20 @@ pub mod parsing { fn parse(input: ParseStream) -> Result<Self> { let mut attrs = input.call(Attribute::parse_outer)?; let vis: Visibility = input.parse()?; + let unsafety: Option<Token![unsafe]> = input.parse()?; let mod_token: Token![mod] = input.parse()?; - let ident: Ident = input.parse()?; + let ident: Ident = if input.peek(Token![try]) { + input.call(Ident::parse_any) + } else { + input.parse() + }?; let lookahead = input.lookahead1(); if lookahead.peek(Token![;]) { Ok(ItemMod { attrs, vis, + unsafety, mod_token, ident, content: None, @@ -1708,6 +1683,7 @@ pub mod parsing { Ok(ItemMod { attrs, vis, + unsafety, mod_token, ident, content: Some((brace_token, items)), @@ -1723,6 +1699,7 @@ pub mod parsing { impl Parse for ItemForeignMod { fn parse(input: ParseStream) -> Result<Self> { let mut attrs = input.call(Attribute::parse_outer)?; + let unsafety: Option<Token![unsafe]> = input.parse()?; let abi: Abi = input.parse()?; let content; @@ -1735,6 +1712,7 @@ pub mod parsing { Ok(ItemForeignMod { attrs, + unsafety, abi, brace_token, items, @@ -1813,9 +1791,6 @@ pub mod parsing { ForeignItem::Type(item) => &mut item.attrs, ForeignItem::Macro(item) => &mut item.attrs, ForeignItem::Verbatim(_) => return Ok(item), - - #[cfg(syn_no_non_exhaustive)] - _ => unreachable!(), }; attrs.append(item_attrs); *item_attrs = attrs; @@ -1864,6 +1839,11 @@ pub mod parsing { vis: input.parse()?, type_token: input.parse()?, ident: input.parse()?, + generics: { + let mut generics: Generics = input.parse()?; + generics.where_clause = input.parse()?; + generics + }, semi_token: input.parse()?, }) } @@ -1880,14 +1860,9 @@ pub mod parsing { bounds: _, ty, semi_token, - } = FlexibleItemType::parse(input, WhereClauseLocation::BeforeEq)?; + } = FlexibleItemType::parse(input, WhereClauseLocation::Both)?; - if defaultness.is_some() - || generics.lt_token.is_some() - || generics.where_clause.is_some() - || colon_token.is_some() - || ty.is_some() - { + if defaultness.is_some() || colon_token.is_some() || ty.is_some() { Ok(ForeignItem::Verbatim(verbatim::between(begin, input))) } else { Ok(ForeignItem::Type(ForeignItemType { @@ -1895,6 +1870,7 @@ pub mod parsing { vis, type_token, ident, + generics, semi_token, })) } @@ -2131,6 +2107,7 @@ pub mod parsing { vis, unsafety, auto_token, + restriction: None, trait_token, ident, generics, @@ -2208,7 +2185,7 @@ pub mod parsing { let lookahead = ahead.lookahead1(); let mut item = if lookahead.peek(Token![fn]) || peek_signature(&ahead) { - input.parse().map(TraitItem::Method) + input.parse().map(TraitItem::Fn) } else if lookahead.peek(Token![const]) { ahead.parse::<Token![const]>()?; let lookahead = ahead.lookahead1(); @@ -2219,7 +2196,7 @@ pub mod parsing { || lookahead.peek(Token![extern]) || lookahead.peek(Token![fn]) { - input.parse().map(TraitItem::Method) + input.parse().map(TraitItem::Fn) } else { Err(lookahead.error()) } @@ -2243,13 +2220,10 @@ pub mod parsing { let item_attrs = match &mut item { TraitItem::Const(item) => &mut item.attrs, - TraitItem::Method(item) => &mut item.attrs, + TraitItem::Fn(item) => &mut item.attrs, TraitItem::Type(item) => &mut item.attrs, TraitItem::Macro(item) => &mut item.attrs, TraitItem::Verbatim(_) => unreachable!(), - - #[cfg(syn_no_non_exhaustive)] - _ => unreachable!(), }; attrs.append(item_attrs); *item_attrs = attrs; @@ -2271,6 +2245,7 @@ pub mod parsing { return Err(lookahead.error()); } }, + generics: Generics::default(), colon_token: input.parse()?, ty: input.parse()?, default: { @@ -2288,7 +2263,7 @@ pub mod parsing { } #[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))] - impl Parse for TraitItemMethod { + impl Parse for TraitItemFn { fn parse(input: ParseStream) -> Result<Self> { let mut attrs = input.call(Attribute::parse_outer)?; let sig: Signature = input.parse()?; @@ -2307,7 +2282,7 @@ pub mod parsing { return Err(lookahead.error()); }; - Ok(TraitItemMethod { + Ok(TraitItemFn { attrs, sig, default: brace_token.map(|brace_token| Block { brace_token, stmts }), @@ -2371,7 +2346,7 @@ pub mod parsing { bounds, ty, semi_token, - } = FlexibleItemType::parse(input, WhereClauseLocation::Both)?; + } = FlexibleItemType::parse(input, WhereClauseLocation::AfterEq)?; if defaultness.is_some() || vis.is_some() { Ok(TraitItem::Verbatim(verbatim::between(begin, input))) @@ -2537,7 +2512,7 @@ pub mod parsing { }; let mut item = if lookahead.peek(Token![fn]) || peek_signature(&ahead) { - input.parse().map(ImplItem::Method) + input.parse().map(ImplItem::Fn) } else if lookahead.peek(Token![const]) { let const_token: Token![const] = ahead.parse()?; let lookahead = ahead.lookahead1(); @@ -2553,6 +2528,7 @@ pub mod parsing { defaultness, const_token, ident, + generics: Generics::default(), colon_token, ty, eq_token, @@ -2584,13 +2560,10 @@ pub mod parsing { { let item_attrs = match &mut item { ImplItem::Const(item) => &mut item.attrs, - ImplItem::Method(item) => &mut item.attrs, + ImplItem::Fn(item) => &mut item.attrs, ImplItem::Type(item) => &mut item.attrs, ImplItem::Macro(item) => &mut item.attrs, ImplItem::Verbatim(_) => return Ok(item), - - #[cfg(syn_no_non_exhaustive)] - _ => unreachable!(), }; attrs.append(item_attrs); *item_attrs = attrs; @@ -2616,6 +2589,7 @@ pub mod parsing { return Err(lookahead.error()); } }, + generics: Generics::default(), colon_token: input.parse()?, ty: input.parse()?, eq_token: input.parse()?, @@ -2626,7 +2600,7 @@ pub mod parsing { } #[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))] - impl Parse for ImplItemMethod { + impl Parse for ImplItemFn { fn parse(input: ParseStream) -> Result<Self> { let mut attrs = input.call(Attribute::parse_outer)?; let vis: Visibility = input.parse()?; @@ -2634,7 +2608,7 @@ pub mod parsing { let sig: Signature = input.parse()?; let block = if let Some(semi) = input.parse::<Option<Token![;]>>()? { - // Accept methods without a body in an impl block because + // Accept functions without a body in an impl block because // rustc's *parser* does not reject them (the compilation error // is emitted later than parsing) and it can be useful for macro // DSLs. @@ -2642,7 +2616,7 @@ pub mod parsing { punct.set_span(semi.span); let tokens = TokenStream::from_iter(vec![TokenTree::Punct(punct)]); Block { - brace_token: Brace { span: semi.span }, + brace_token: Brace(semi.span), stmts: vec![Stmt::Item(Item::Verbatim(tokens))], } } else { @@ -2655,7 +2629,7 @@ pub mod parsing { } }; - Ok(ImplItemMethod { + Ok(ImplItemFn { attrs, vis, defaultness, @@ -2703,7 +2677,7 @@ pub mod parsing { bounds: _, ty, semi_token, - } = FlexibleItemType::parse(input, WhereClauseLocation::Both)?; + } = FlexibleItemType::parse(input, WhereClauseLocation::AfterEq)?; if colon_token.is_some() || ty.is_none() { Ok(ImplItem::Verbatim(verbatim::between(begin, input))) @@ -2743,7 +2717,7 @@ pub mod parsing { impl Visibility { fn is_inherited(&self) -> bool { - match *self { + match self { Visibility::Inherited => true, _ => false, } @@ -2751,13 +2725,21 @@ pub mod parsing { } impl MacroDelimiter { - fn is_brace(&self) -> bool { - match *self { + pub(crate) fn is_brace(&self) -> bool { + match self { MacroDelimiter::Brace(_) => true, MacroDelimiter::Paren(_) | MacroDelimiter::Bracket(_) => false, } } } + + #[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))] + impl Parse for StaticMutability { + fn parse(input: ParseStream) -> Result<Self> { + let mut_token: Option<Token![mut]> = input.parse()?; + Ok(mut_token.map_or(StaticMutability::None, StaticMutability::Mut)) + } + } } #[cfg(feature = "printing")] @@ -2845,6 +2827,7 @@ mod printing { fn to_tokens(&self, tokens: &mut TokenStream) { tokens.append_all(self.attrs.outer()); self.vis.to_tokens(tokens); + self.unsafety.to_tokens(tokens); self.mod_token.to_tokens(tokens); self.ident.to_tokens(tokens); if let Some((brace, items)) = &self.content { @@ -2862,6 +2845,7 @@ mod printing { impl ToTokens for ItemForeignMod { fn to_tokens(&self, tokens: &mut TokenStream) { tokens.append_all(self.attrs.outer()); + self.unsafety.to_tokens(tokens); self.abi.to_tokens(tokens); self.brace_token.surround(tokens, |tokens| { tokens.append_all(self.attrs.inner()); @@ -3021,17 +3005,6 @@ mod printing { } #[cfg_attr(doc_cfg, doc(cfg(feature = "printing")))] - impl ToTokens for ItemMacro2 { - fn to_tokens(&self, tokens: &mut TokenStream) { - tokens.append_all(self.attrs.outer()); - self.vis.to_tokens(tokens); - self.macro_token.to_tokens(tokens); - self.ident.to_tokens(tokens); - self.rules.to_tokens(tokens); - } - } - - #[cfg_attr(doc_cfg, doc(cfg(feature = "printing")))] impl ToTokens for UsePath { fn to_tokens(&self, tokens: &mut TokenStream) { self.ident.to_tokens(tokens); @@ -3089,7 +3062,7 @@ mod printing { } #[cfg_attr(doc_cfg, doc(cfg(feature = "printing")))] - impl ToTokens for TraitItemMethod { + impl ToTokens for TraitItemFn { fn to_tokens(&self, tokens: &mut TokenStream) { tokens.append_all(self.attrs.outer()); self.sig.to_tokens(tokens); @@ -3153,7 +3126,7 @@ mod printing { } #[cfg_attr(doc_cfg, doc(cfg(feature = "printing")))] - impl ToTokens for ImplItemMethod { + impl ToTokens for ImplItemFn { fn to_tokens(&self, tokens: &mut TokenStream) { tokens.append_all(self.attrs.outer()); self.vis.to_tokens(tokens); @@ -3230,6 +3203,8 @@ mod printing { self.vis.to_tokens(tokens); self.type_token.to_tokens(tokens); self.ident.to_tokens(tokens); + self.generics.to_tokens(tokens); + self.generics.where_clause.to_tokens(tokens); self.semi_token.to_tokens(tokens); } } @@ -3243,33 +3218,6 @@ mod printing { } } - fn maybe_variadic_to_tokens(arg: &FnArg, tokens: &mut TokenStream) -> bool { - let arg = match arg { - FnArg::Typed(arg) => arg, - FnArg::Receiver(receiver) => { - receiver.to_tokens(tokens); - return false; - } - }; - - match arg.ty.as_ref() { - Type::Verbatim(ty) if ty.to_string() == "..." => { - match arg.pat.as_ref() { - Pat::Verbatim(pat) if pat.to_string() == "..." => { - tokens.append_all(arg.attrs.outer()); - pat.to_tokens(tokens); - } - _ => arg.to_tokens(tokens), - } - true - } - _ => { - arg.to_tokens(tokens); - false - } - } - } - #[cfg_attr(doc_cfg, doc(cfg(feature = "printing")))] impl ToTokens for Signature { fn to_tokens(&self, tokens: &mut TokenStream) { @@ -3281,16 +3229,12 @@ mod printing { self.ident.to_tokens(tokens); self.generics.to_tokens(tokens); self.paren_token.surround(tokens, |tokens| { - let mut last_is_variadic = false; - for pair in self.inputs.pairs() { - last_is_variadic = maybe_variadic_to_tokens(pair.value(), tokens); - pair.punct().to_tokens(tokens); - } - if self.variadic.is_some() && !last_is_variadic { + self.inputs.to_tokens(tokens); + if let Some(variadic) = &self.variadic { if !self.inputs.empty_or_trailing() { <Token![,]>::default().to_tokens(tokens); } - self.variadic.to_tokens(tokens); + variadic.to_tokens(tokens); } }); self.output.to_tokens(tokens); @@ -3308,6 +3252,49 @@ mod printing { } self.mutability.to_tokens(tokens); self.self_token.to_tokens(tokens); + if let Some(colon_token) = &self.colon_token { + colon_token.to_tokens(tokens); + self.ty.to_tokens(tokens); + } else { + let consistent = match (&self.reference, &self.mutability, &*self.ty) { + (Some(_), mutability, Type::Reference(ty)) => { + mutability.is_some() == ty.mutability.is_some() + && match &*ty.elem { + Type::Path(ty) => ty.qself.is_none() && ty.path.is_ident("Self"), + _ => false, + } + } + (None, _, Type::Path(ty)) => ty.qself.is_none() && ty.path.is_ident("Self"), + _ => false, + }; + if !consistent { + <Token![:]>::default().to_tokens(tokens); + self.ty.to_tokens(tokens); + } + } + } + } + + #[cfg_attr(doc_cfg, doc(cfg(feature = "printing")))] + impl ToTokens for Variadic { + fn to_tokens(&self, tokens: &mut TokenStream) { + tokens.append_all(self.attrs.outer()); + if let Some((pat, colon)) = &self.pat { + pat.to_tokens(tokens); + colon.to_tokens(tokens); + } + self.dots.to_tokens(tokens); + self.comma.to_tokens(tokens); + } + } + + #[cfg_attr(doc_cfg, doc(cfg(feature = "printing")))] + impl ToTokens for StaticMutability { + fn to_tokens(&self, tokens: &mut TokenStream) { + match self { + StaticMutability::None => {} + StaticMutability::Mut(mut_token) => mut_token.to_tokens(tokens), + } } } } diff --git a/vendor/syn/src/lib.rs b/vendor/syn/src/lib.rs index e47ba28c6..72b9e7d89 100644 --- a/vendor/syn/src/lib.rs +++ b/vendor/syn/src/lib.rs @@ -62,7 +62,7 @@ //! //! ```toml //! [dependencies] -//! syn = "1.0" +//! syn = "2.0" //! quote = "1.0" //! //! [lib] @@ -94,9 +94,8 @@ //! ``` //! //! The [`heapsize`] example directory shows a complete working implementation -//! of a derive macro. It works on any Rust compiler 1.31+. The example derives -//! a `HeapSize` trait which computes an estimate of the amount of heap memory -//! owned by a value. +//! of a derive macro. The example derives a `HeapSize` trait which computes an +//! estimate of the amount of heap memory owned by a value. //! //! [`heapsize`]: https://github.com/dtolnay/syn/tree/master/examples/heapsize //! @@ -250,7 +249,7 @@ //! dynamic library libproc_macro from rustc toolchain. // Syn types in rustdoc of other crates get linked to here. -#![doc(html_root_url = "https://docs.rs/syn/1.0.107")] +#![doc(html_root_url = "https://docs.rs/syn/2.0.8")] #![cfg_attr(doc_cfg, feature(doc_cfg))] #![allow(non_camel_case_types)] #![allow( @@ -260,6 +259,7 @@ clippy::cast_possible_wrap, clippy::cast_ptr_alignment, clippy::default_trait_access, + clippy::derivable_impls, clippy::doc_markdown, clippy::expl_impl_clone_on_copy, clippy::explicit_auto_deref, @@ -267,7 +267,10 @@ clippy::inherent_to_string, clippy::items_after_statements, clippy::large_enum_variant, + clippy::let_underscore_untyped, // https://github.com/rust-lang/rust-clippy/issues/10410 clippy::manual_assert, + clippy::manual_let_else, + clippy::match_like_matches_macro, clippy::match_on_vec_items, clippy::match_same_arms, clippy::match_wildcard_for_single_variants, // clippy bug: https://github.com/rust-lang/rust-clippy/issues/6984 @@ -285,9 +288,10 @@ clippy::too_many_arguments, clippy::too_many_lines, clippy::trivially_copy_pass_by_ref, + clippy::uninlined_format_args, clippy::unnecessary_unwrap, clippy::used_underscore_binding, - clippy::wildcard_imports + clippy::wildcard_imports, )] #[cfg(all( @@ -295,10 +299,6 @@ feature = "proc-macro" ))] extern crate proc_macro; -extern crate proc_macro2; - -#[cfg(feature = "printing")] -extern crate quote; #[macro_use] mod macros; @@ -310,69 +310,84 @@ mod group; #[macro_use] pub mod token; -mod ident; -pub use crate::ident::Ident; - #[cfg(any(feature = "full", feature = "derive"))] mod attr; #[cfg(any(feature = "full", feature = "derive"))] -pub use crate::attr::{ - AttrStyle, Attribute, AttributeArgs, Meta, MetaList, MetaNameValue, NestedMeta, -}; +pub use crate::attr::{AttrStyle, Attribute, Meta, MetaList, MetaNameValue}; mod bigint; +#[cfg(feature = "parsing")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))] +pub mod buffer; + +mod custom_keyword; + +mod custom_punctuation; + #[cfg(any(feature = "full", feature = "derive"))] mod data; #[cfg(any(feature = "full", feature = "derive"))] -pub use crate::data::{ - Field, Fields, FieldsNamed, FieldsUnnamed, Variant, VisCrate, VisPublic, VisRestricted, - Visibility, -}; +pub use crate::data::{Field, Fields, FieldsNamed, FieldsUnnamed, Variant}; + +#[cfg(any(feature = "full", feature = "derive"))] +mod derive; +#[cfg(feature = "derive")] +pub use crate::derive::{Data, DataEnum, DataStruct, DataUnion, DeriveInput}; + +mod drops; + +mod error; +pub use crate::error::{Error, Result}; #[cfg(any(feature = "full", feature = "derive"))] mod expr; #[cfg(feature = "full")] -pub use crate::expr::{ - Arm, FieldValue, GenericMethodArgument, Label, MethodTurbofish, RangeLimits, -}; +pub use crate::expr::{Arm, FieldValue, Label, RangeLimits}; #[cfg(any(feature = "full", feature = "derive"))] pub use crate::expr::{ - Expr, ExprArray, ExprAssign, ExprAssignOp, ExprAsync, ExprAwait, ExprBinary, ExprBlock, - ExprBox, ExprBreak, ExprCall, ExprCast, ExprClosure, ExprContinue, ExprField, ExprForLoop, - ExprGroup, ExprIf, ExprIndex, ExprLet, ExprLit, ExprLoop, ExprMacro, ExprMatch, ExprMethodCall, + Expr, ExprArray, ExprAssign, ExprAsync, ExprAwait, ExprBinary, ExprBlock, ExprBreak, ExprCall, + ExprCast, ExprClosure, ExprConst, ExprContinue, ExprField, ExprForLoop, ExprGroup, ExprIf, + ExprIndex, ExprInfer, ExprLet, ExprLit, ExprLoop, ExprMacro, ExprMatch, ExprMethodCall, ExprParen, ExprPath, ExprRange, ExprReference, ExprRepeat, ExprReturn, ExprStruct, ExprTry, - ExprTryBlock, ExprTuple, ExprType, ExprUnary, ExprUnsafe, ExprWhile, ExprYield, Index, Member, + ExprTryBlock, ExprTuple, ExprUnary, ExprUnsafe, ExprWhile, ExprYield, Index, Member, }; +#[cfg(feature = "parsing")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))] +pub mod ext; + +#[cfg(feature = "full")] +mod file; +#[cfg(feature = "full")] +pub use crate::file::File; + #[cfg(any(feature = "full", feature = "derive"))] mod generics; #[cfg(any(feature = "full", feature = "derive"))] pub use crate::generics::{ - BoundLifetimes, ConstParam, GenericParam, Generics, LifetimeDef, PredicateEq, - PredicateLifetime, PredicateType, TraitBound, TraitBoundModifier, TypeParam, TypeParamBound, - WhereClause, WherePredicate, + BoundLifetimes, ConstParam, GenericParam, Generics, LifetimeParam, PredicateLifetime, + PredicateType, TraitBound, TraitBoundModifier, TypeParam, TypeParamBound, WhereClause, + WherePredicate, }; #[cfg(all(any(feature = "full", feature = "derive"), feature = "printing"))] pub use crate::generics::{ImplGenerics, Turbofish, TypeGenerics}; +mod ident; +pub use crate::ident::Ident; + #[cfg(feature = "full")] mod item; #[cfg(feature = "full")] pub use crate::item::{ FnArg, ForeignItem, ForeignItemFn, ForeignItemMacro, ForeignItemStatic, ForeignItemType, - ImplItem, ImplItemConst, ImplItemMacro, ImplItemMethod, ImplItemType, Item, ItemConst, - ItemEnum, ItemExternCrate, ItemFn, ItemForeignMod, ItemImpl, ItemMacro, ItemMacro2, ItemMod, + ImplItem, ImplItemConst, ImplItemFn, ImplItemMacro, ImplItemType, ImplRestriction, Item, + ItemConst, ItemEnum, ItemExternCrate, ItemFn, ItemForeignMod, ItemImpl, ItemMacro, ItemMod, ItemStatic, ItemStruct, ItemTrait, ItemTraitAlias, ItemType, ItemUnion, ItemUse, Receiver, - Signature, TraitItem, TraitItemConst, TraitItemMacro, TraitItemMethod, TraitItemType, UseGlob, - UseGroup, UseName, UsePath, UseRename, UseTree, + Signature, StaticMutability, TraitItem, TraitItemConst, TraitItemFn, TraitItemMacro, + TraitItemType, UseGlob, UseGroup, UseName, UsePath, UseRename, UseTree, Variadic, }; -#[cfg(feature = "full")] -mod file; -#[cfg(feature = "full")] -pub use crate::file::File; - mod lifetime; pub use crate::lifetime::Lifetime; @@ -381,84 +396,190 @@ pub use crate::lit::{ Lit, LitBool, LitByte, LitByteStr, LitChar, LitFloat, LitInt, LitStr, StrStyle, }; +#[cfg(feature = "parsing")] +mod lookahead; + #[cfg(any(feature = "full", feature = "derive"))] mod mac; #[cfg(any(feature = "full", feature = "derive"))] pub use crate::mac::{Macro, MacroDelimiter}; -#[cfg(any(feature = "full", feature = "derive"))] -mod derive; -#[cfg(feature = "derive")] -pub use crate::derive::{Data, DataEnum, DataStruct, DataUnion, DeriveInput}; +#[cfg(all(feature = "parsing", any(feature = "full", feature = "derive")))] +#[cfg_attr( + doc_cfg, + doc(cfg(all(feature = "parsing", any(feature = "full", feature = "derive")))) +)] +pub mod meta; #[cfg(any(feature = "full", feature = "derive"))] mod op; #[cfg(any(feature = "full", feature = "derive"))] pub use crate::op::{BinOp, UnOp}; -#[cfg(feature = "full")] -mod stmt; -#[cfg(feature = "full")] -pub use crate::stmt::{Block, Local, Stmt}; +#[cfg(feature = "parsing")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))] +pub mod parse; -#[cfg(any(feature = "full", feature = "derive"))] -mod ty; -#[cfg(any(feature = "full", feature = "derive"))] -pub use crate::ty::{ - Abi, BareFnArg, ReturnType, Type, TypeArray, TypeBareFn, TypeGroup, TypeImplTrait, TypeInfer, - TypeMacro, TypeNever, TypeParen, TypePath, TypePtr, TypeReference, TypeSlice, TypeTraitObject, - TypeTuple, Variadic, -}; +#[cfg(all( + not(all(target_arch = "wasm32", any(target_os = "unknown", target_os = "wasi"))), + feature = "parsing", + feature = "proc-macro" +))] +mod parse_macro_input; + +#[cfg(all(feature = "parsing", feature = "printing"))] +mod parse_quote; #[cfg(feature = "full")] mod pat; #[cfg(feature = "full")] +pub use crate::expr::{ + ExprConst as PatConst, ExprLit as PatLit, ExprMacro as PatMacro, ExprPath as PatPath, + ExprRange as PatRange, +}; +#[cfg(feature = "full")] pub use crate::pat::{ - FieldPat, Pat, PatBox, PatIdent, PatLit, PatMacro, PatOr, PatPath, PatRange, PatReference, - PatRest, PatSlice, PatStruct, PatTuple, PatTupleStruct, PatType, PatWild, + FieldPat, Pat, PatIdent, PatOr, PatParen, PatReference, PatRest, PatSlice, PatStruct, PatTuple, + PatTupleStruct, PatType, PatWild, }; #[cfg(any(feature = "full", feature = "derive"))] mod path; #[cfg(any(feature = "full", feature = "derive"))] pub use crate::path::{ - AngleBracketedGenericArguments, Binding, Constraint, GenericArgument, + AngleBracketedGenericArguments, AssocConst, AssocType, Constraint, GenericArgument, ParenthesizedGenericArguments, Path, PathArguments, PathSegment, QSelf, }; -#[cfg(feature = "parsing")] -#[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))] -pub mod buffer; -mod drops; -#[cfg(feature = "parsing")] -#[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))] -pub mod ext; +#[cfg(all(any(feature = "full", feature = "derive"), feature = "printing"))] +mod print; + pub mod punctuated; -#[cfg(all(any(feature = "full", feature = "derive"), feature = "extra-traits"))] -mod tt; -// Not public API except the `parse_quote!` macro. -#[cfg(feature = "parsing")] -#[doc(hidden)] -pub mod parse_quote; +#[cfg(any(feature = "full", feature = "derive"))] +mod restriction; +#[cfg(any(feature = "full", feature = "derive"))] +pub use crate::restriction::{FieldMutability, VisRestricted, Visibility}; -// Not public API except the `parse_macro_input!` macro. -#[cfg(all( - not(all(target_arch = "wasm32", any(target_os = "unknown", target_os = "wasi"))), - feature = "parsing", - feature = "proc-macro" -))] -#[doc(hidden)] -pub mod parse_macro_input; +mod sealed; + +mod span; #[cfg(all(feature = "parsing", feature = "printing"))] #[cfg_attr(doc_cfg, doc(cfg(all(feature = "parsing", feature = "printing"))))] pub mod spanned; +#[cfg(feature = "full")] +mod stmt; +#[cfg(feature = "full")] +pub use crate::stmt::{Block, Local, LocalInit, Stmt, StmtMacro}; + +mod thread; + +#[cfg(all(any(feature = "full", feature = "derive"), feature = "extra-traits"))] +mod tt; + +#[cfg(any(feature = "full", feature = "derive"))] +mod ty; +#[cfg(any(feature = "full", feature = "derive"))] +pub use crate::ty::{ + Abi, BareFnArg, BareVariadic, ReturnType, Type, TypeArray, TypeBareFn, TypeGroup, + TypeImplTrait, TypeInfer, TypeMacro, TypeNever, TypeParen, TypePath, TypePtr, TypeReference, + TypeSlice, TypeTraitObject, TypeTuple, +}; + +#[cfg(all(any(feature = "full", feature = "derive"), feature = "parsing"))] +mod verbatim; + #[cfg(all(feature = "parsing", feature = "full"))] mod whitespace; mod gen { + /// Syntax tree traversal to transform the nodes of an owned syntax tree. + /// + /// Each method of the [`Fold`] trait is a hook that can be overridden to + /// customize the behavior when transforming the corresponding type of node. + /// By default, every method recursively visits the substructure of the + /// input by invoking the right visitor method of each of its fields. + /// + /// [`Fold`]: fold::Fold + /// + /// ``` + /// # use syn::{Attribute, BinOp, Expr, ExprBinary}; + /// # + /// pub trait Fold { + /// /* ... */ + /// + /// fn fold_expr_binary(&mut self, node: ExprBinary) -> ExprBinary { + /// fold_expr_binary(self, node) + /// } + /// + /// /* ... */ + /// # fn fold_attribute(&mut self, node: Attribute) -> Attribute; + /// # fn fold_expr(&mut self, node: Expr) -> Expr; + /// # fn fold_bin_op(&mut self, node: BinOp) -> BinOp; + /// } + /// + /// pub fn fold_expr_binary<V>(v: &mut V, node: ExprBinary) -> ExprBinary + /// where + /// V: Fold + ?Sized, + /// { + /// ExprBinary { + /// attrs: node + /// .attrs + /// .into_iter() + /// .map(|attr| v.fold_attribute(attr)) + /// .collect(), + /// left: Box::new(v.fold_expr(*node.left)), + /// op: v.fold_bin_op(node.op), + /// right: Box::new(v.fold_expr(*node.right)), + /// } + /// } + /// + /// /* ... */ + /// ``` + /// + /// <br> + /// + /// # Example + /// + /// This fold inserts parentheses to fully parenthesizes any expression. + /// + /// ``` + /// // [dependencies] + /// // quote = "1.0" + /// // syn = { version = "2.0", features = ["fold", "full"] } + /// + /// use quote::quote; + /// use syn::fold::{fold_expr, Fold}; + /// use syn::{token, Expr, ExprParen}; + /// + /// struct ParenthesizeEveryExpr; + /// + /// impl Fold for ParenthesizeEveryExpr { + /// fn fold_expr(&mut self, expr: Expr) -> Expr { + /// Expr::Paren(ExprParen { + /// attrs: Vec::new(), + /// expr: Box::new(fold_expr(self, expr)), + /// paren_token: token::Paren::default(), + /// }) + /// } + /// } + /// + /// fn main() { + /// let code = quote! { a() + b(1) * c.d }; + /// let expr: Expr = syn::parse2(code).unwrap(); + /// let parenthesized = ParenthesizeEveryExpr.fold_expr(expr); + /// println!("{}", quote!(#parenthesized)); + /// + /// // Output: (((a)()) + (((b)((1))) * ((c).d))) + /// } + /// ``` + #[cfg(feature = "fold")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "fold")))] + #[rustfmt::skip] + pub mod fold; + /// Syntax tree traversal to walk a shared borrow of a syntax tree. /// /// Each method of the [`Visit`] trait is a hook that can be overridden to @@ -499,8 +620,6 @@ mod gen { /// /* ... */ /// ``` /// - /// *This module is available only if Syn is built with the `"visit"` feature.* - /// /// <br> /// /// # Example @@ -511,7 +630,7 @@ mod gen { /// ``` /// // [dependencies] /// // quote = "1.0" - /// // syn = { version = "1.0", features = ["full", "visit"] } + /// // syn = { version = "2.0", features = ["full", "visit"] } /// /// use quote::quote; /// use syn::visit::{self, Visit}; @@ -621,9 +740,6 @@ mod gen { /// /* ... */ /// ``` /// - /// *This module is available only if Syn is built with the `"visit-mut"` - /// feature.* - /// /// <br> /// /// # Example @@ -634,7 +750,7 @@ mod gen { /// ``` /// // [dependencies] /// // quote = "1.0" - /// // syn = { version = "1.0", features = ["full", "visit-mut"] } + /// // syn = { version = "2.0", features = ["full", "visit-mut"] } /// /// use quote::quote; /// use syn::visit_mut::{self, VisitMut}; @@ -677,108 +793,21 @@ mod gen { #[rustfmt::skip] pub mod visit_mut; - /// Syntax tree traversal to transform the nodes of an owned syntax tree. - /// - /// Each method of the [`Fold`] trait is a hook that can be overridden to - /// customize the behavior when transforming the corresponding type of node. - /// By default, every method recursively visits the substructure of the - /// input by invoking the right visitor method of each of its fields. - /// - /// [`Fold`]: fold::Fold - /// - /// ``` - /// # use syn::{Attribute, BinOp, Expr, ExprBinary}; - /// # - /// pub trait Fold { - /// /* ... */ - /// - /// fn fold_expr_binary(&mut self, node: ExprBinary) -> ExprBinary { - /// fold_expr_binary(self, node) - /// } - /// - /// /* ... */ - /// # fn fold_attribute(&mut self, node: Attribute) -> Attribute; - /// # fn fold_expr(&mut self, node: Expr) -> Expr; - /// # fn fold_bin_op(&mut self, node: BinOp) -> BinOp; - /// } - /// - /// pub fn fold_expr_binary<V>(v: &mut V, node: ExprBinary) -> ExprBinary - /// where - /// V: Fold + ?Sized, - /// { - /// ExprBinary { - /// attrs: node - /// .attrs - /// .into_iter() - /// .map(|attr| v.fold_attribute(attr)) - /// .collect(), - /// left: Box::new(v.fold_expr(*node.left)), - /// op: v.fold_bin_op(node.op), - /// right: Box::new(v.fold_expr(*node.right)), - /// } - /// } - /// - /// /* ... */ - /// ``` - /// - /// *This module is available only if Syn is built with the `"fold"` feature.* - /// - /// <br> - /// - /// # Example - /// - /// This fold inserts parentheses to fully parenthesizes any expression. - /// - /// ``` - /// // [dependencies] - /// // quote = "1.0" - /// // syn = { version = "1.0", features = ["fold", "full"] } - /// - /// use quote::quote; - /// use syn::fold::{fold_expr, Fold}; - /// use syn::{token, Expr, ExprParen}; - /// - /// struct ParenthesizeEveryExpr; - /// - /// impl Fold for ParenthesizeEveryExpr { - /// fn fold_expr(&mut self, expr: Expr) -> Expr { - /// Expr::Paren(ExprParen { - /// attrs: Vec::new(), - /// expr: Box::new(fold_expr(self, expr)), - /// paren_token: token::Paren::default(), - /// }) - /// } - /// } - /// - /// fn main() { - /// let code = quote! { a() + b(1) * c.d }; - /// let expr: Expr = syn::parse2(code).unwrap(); - /// let parenthesized = ParenthesizeEveryExpr.fold_expr(expr); - /// println!("{}", quote!(#parenthesized)); - /// - /// // Output: (((a)()) + (((b)((1))) * ((c).d))) - /// } - /// ``` - #[cfg(feature = "fold")] - #[cfg_attr(doc_cfg, doc(cfg(feature = "fold")))] - #[rustfmt::skip] - pub mod fold; - #[cfg(feature = "clone-impls")] #[rustfmt::skip] mod clone; #[cfg(feature = "extra-traits")] #[rustfmt::skip] - mod eq; + mod debug; #[cfg(feature = "extra-traits")] #[rustfmt::skip] - mod hash; + mod eq; #[cfg(feature = "extra-traits")] #[rustfmt::skip] - mod debug; + mod hash; #[cfg(any(feature = "full", feature = "derive"))] #[path = "../gen_helper.rs"] @@ -791,33 +820,6 @@ pub use crate::gen::*; #[path = "export.rs"] pub mod __private; -mod custom_keyword; -mod custom_punctuation; -mod sealed; -mod span; -mod thread; - -#[cfg(feature = "parsing")] -mod lookahead; - -#[cfg(feature = "parsing")] -#[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))] -pub mod parse; - -#[cfg(feature = "full")] -mod reserved; - -#[cfg(all(any(feature = "full", feature = "derive"), feature = "parsing"))] -mod verbatim; - -#[cfg(all(any(feature = "full", feature = "derive"), feature = "printing"))] -mod print; - -//////////////////////////////////////////////////////////////////////////////// - -mod error; -pub use crate::error::{Error, Result}; - /// Parse tokens of source code into the chosen syntax tree node. /// /// This is preferred over parsing a string because tokens are able to preserve @@ -831,9 +833,6 @@ pub use crate::error::{Error, Result}; /// /// [`syn::parse2`]: parse2 /// -/// *This function is available only if Syn is built with both the `"parsing"` and -/// `"proc-macro"` features.* -/// /// # Examples /// /// ``` @@ -881,8 +880,6 @@ pub fn parse<T: parse::Parse>(tokens: proc_macro::TokenStream) -> Result<T> { /// instead. /// /// [`syn::parse`]: parse() -/// -/// *This function is available only if Syn is built with the `"parsing"` feature.* #[cfg(feature = "parsing")] #[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))] pub fn parse2<T: parse::Parse>(tokens: proc_macro2::TokenStream) -> Result<T> { @@ -891,8 +888,6 @@ pub fn parse2<T: parse::Parse>(tokens: proc_macro2::TokenStream) -> Result<T> { /// Parse a string of Rust code into the chosen syntax tree node. /// -/// *This function is available only if Syn is built with the `"parsing"` feature.* -/// /// # Hygiene /// /// Every span in the resulting syntax tree will be set to resolve at the macro @@ -929,9 +924,6 @@ pub fn parse_str<T: parse::Parse>(s: &str) -> Result<T> { /// /// If present, either of these would be an error using `from_str`. /// -/// *This function is available only if Syn is built with the `"parsing"` and -/// `"full"` features.* -/// /// # Examples /// /// ```no_run @@ -939,7 +931,7 @@ pub fn parse_str<T: parse::Parse>(s: &str) -> Result<T> { /// use std::fs::File; /// use std::io::Read; /// -/// fn run() -> Result<(), Box<Error>> { +/// fn run() -> Result<(), Box<dyn Error>> { /// let mut file = File::open("path/to/code.rs")?; /// let mut content = String::new(); /// file.read_to_string(&mut content)?; diff --git a/vendor/syn/src/lifetime.rs b/vendor/syn/src/lifetime.rs index 5dc1753a8..96920ad05 100644 --- a/vendor/syn/src/lifetime.rs +++ b/vendor/syn/src/lifetime.rs @@ -120,7 +120,7 @@ pub fn Lifetime(marker: lookahead::TokenMarker) -> Lifetime { } #[cfg(feature = "parsing")] -pub mod parsing { +pub(crate) mod parsing { use super::*; use crate::parse::{Parse, ParseStream, Result}; diff --git a/vendor/syn/src/lit.rs b/vendor/syn/src/lit.rs index 130b40ed1..662ef8b22 100644 --- a/vendor/syn/src/lit.rs +++ b/vendor/syn/src/lit.rs @@ -19,6 +19,7 @@ ast_enum_of_structs! { /// This type is a [syntax tree enum]. /// /// [syntax tree enum]: crate::Expr#syntax-tree-enums + #[non_exhaustive] pub enum Lit { /// A UTF-8 string literal: `"foo"`. Str(LitStr), @@ -142,8 +143,7 @@ impl LitStr { /// # Example /// /// ``` - /// use proc_macro2::Span; - /// use syn::{Attribute, Error, Ident, Lit, Meta, MetaNameValue, Path, Result}; + /// use syn::{Attribute, Error, Expr, Lit, Meta, Path, Result}; /// /// // Parses the path from an attribute that looks like: /// // @@ -151,19 +151,20 @@ impl LitStr { /// // /// // or returns `None` if the input is some other attribute. /// fn get_path(attr: &Attribute) -> Result<Option<Path>> { - /// if !attr.path.is_ident("path") { + /// if !attr.path().is_ident("path") { /// return Ok(None); /// } /// - /// match attr.parse_meta()? { - /// Meta::NameValue(MetaNameValue { lit: Lit::Str(lit_str), .. }) => { - /// lit_str.parse().map(Some) - /// } - /// _ => { - /// let message = "expected #[path = \"...\"]"; - /// Err(Error::new_spanned(attr, message)) + /// if let Meta::NameValue(meta) = &attr.meta { + /// if let Expr::Lit(expr) = &meta.value { + /// if let Lit::Str(lit_str) = &expr.lit { + /// return lit_str.parse().map(Some); + /// } /// } /// } + /// + /// let message = "expected #[path = \"...\"]"; + /// Err(Error::new_spanned(attr, message)) /// } /// ``` #[cfg(feature = "parsing")] @@ -359,11 +360,7 @@ impl LitInt { None => panic!("Not an integer literal: `{}`", repr), }; - let mut token = match value::to_literal(repr, &digits, &suffix) { - Some(token) => token, - None => panic!("Unsupported integer literal: `{}`", repr), - }; - + let mut token: Literal = repr.parse().unwrap(); token.set_span(span); LitInt { repr: Box::new(LitIntRepr { @@ -457,11 +454,7 @@ impl LitFloat { None => panic!("Not a float literal: `{}`", repr), }; - let mut token = match value::to_literal(repr, &digits, &suffix) { - Some(token) => token, - None => panic!("Unsupported float literal: `{}`", repr), - }; - + let mut token: Literal = repr.parse().unwrap(); token.set_span(span); LitFloat { repr: Box::new(LitFloatRepr { @@ -557,70 +550,133 @@ mod debug_impls { #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Debug for LitStr { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter - .debug_struct("LitStr") - .field("token", &format_args!("{}", self.repr.token)) - .finish() + impl LitStr { + pub(crate) fn debug( + &self, + formatter: &mut fmt::Formatter, + name: &str, + ) -> fmt::Result { + formatter + .debug_struct(name) + .field("token", &format_args!("{}", self.repr.token)) + .finish() + } + } + self.debug(formatter, "LitStr") } } #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Debug for LitByteStr { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter - .debug_struct("LitByteStr") - .field("token", &format_args!("{}", self.repr.token)) - .finish() + impl LitByteStr { + pub(crate) fn debug( + &self, + formatter: &mut fmt::Formatter, + name: &str, + ) -> fmt::Result { + formatter + .debug_struct(name) + .field("token", &format_args!("{}", self.repr.token)) + .finish() + } + } + self.debug(formatter, "LitByteStr") } } #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Debug for LitByte { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter - .debug_struct("LitByte") - .field("token", &format_args!("{}", self.repr.token)) - .finish() + impl LitByte { + pub(crate) fn debug( + &self, + formatter: &mut fmt::Formatter, + name: &str, + ) -> fmt::Result { + formatter + .debug_struct(name) + .field("token", &format_args!("{}", self.repr.token)) + .finish() + } + } + self.debug(formatter, "LitByte") } } #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Debug for LitChar { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter - .debug_struct("LitChar") - .field("token", &format_args!("{}", self.repr.token)) - .finish() + impl LitChar { + pub(crate) fn debug( + &self, + formatter: &mut fmt::Formatter, + name: &str, + ) -> fmt::Result { + formatter + .debug_struct(name) + .field("token", &format_args!("{}", self.repr.token)) + .finish() + } + } + self.debug(formatter, "LitChar") } } #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Debug for LitInt { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter - .debug_struct("LitInt") - .field("token", &format_args!("{}", self.repr.token)) - .finish() + impl LitInt { + pub(crate) fn debug( + &self, + formatter: &mut fmt::Formatter, + name: &str, + ) -> fmt::Result { + formatter + .debug_struct(name) + .field("token", &format_args!("{}", self.repr.token)) + .finish() + } + } + self.debug(formatter, "LitInt") } } #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Debug for LitFloat { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter - .debug_struct("LitFloat") - .field("token", &format_args!("{}", self.repr.token)) - .finish() + impl LitFloat { + pub(crate) fn debug( + &self, + formatter: &mut fmt::Formatter, + name: &str, + ) -> fmt::Result { + formatter + .debug_struct(name) + .field("token", &format_args!("{}", self.repr.token)) + .finish() + } + } + self.debug(formatter, "LitFloat") } } #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Debug for LitBool { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter - .debug_struct("LitBool") - .field("value", &self.value) - .finish() + impl LitBool { + pub(crate) fn debug( + &self, + formatter: &mut fmt::Formatter, + name: &str, + ) -> fmt::Result { + formatter + .debug_struct(name) + .field("value", &self.value) + .finish() + } + } + self.debug(formatter, "LitBool") } } } @@ -735,7 +791,7 @@ pub fn Lit(marker: lookahead::TokenMarker) -> Lit { } #[cfg(feature = "parsing")] -pub mod parsing { +pub(crate) mod parsing { use super::*; use crate::buffer::Cursor; use crate::parse::{Parse, ParseStream, Result}; @@ -783,23 +839,22 @@ pub mod parsing { repr.insert(0, '-'); if let Some((digits, suffix)) = value::parse_lit_int(&repr) { - if let Some(mut token) = value::to_literal(&repr, &digits, &suffix) { - token.set_span(span); - return Some(( - Lit::Int(LitInt { - repr: Box::new(LitIntRepr { - token, - digits, - suffix, - }), + let mut token: Literal = repr.parse().unwrap(); + token.set_span(span); + return Some(( + Lit::Int(LitInt { + repr: Box::new(LitIntRepr { + token, + digits, + suffix, }), - rest, - )); - } + }), + rest, + )); } let (digits, suffix) = value::parse_lit_float(&repr)?; - let mut token = value::to_literal(&repr, &digits, &suffix)?; + let mut token: Literal = repr.parse().unwrap(); token.set_span(span); Some(( Lit::Float(LitFloat { @@ -959,6 +1014,7 @@ mod value { let repr = token.to_string(); match byte(&repr, 0) { + // "...", r"...", r#"..."# b'"' | b'r' => { let (_, suffix) = parse_lit_str(&repr); return Lit::Str(LitStr { @@ -966,12 +1022,14 @@ mod value { }); } b'b' => match byte(&repr, 1) { + // b"...", br"...", br#"...#" b'"' | b'r' => { let (_, suffix) = parse_lit_byte_str(&repr); return Lit::ByteStr(LitByteStr { repr: Box::new(LitRepr { token, suffix }), }); } + // b'...' b'\'' => { let (_, suffix) = parse_lit_byte(&repr); return Lit::Byte(LitByte { @@ -980,6 +1038,7 @@ mod value { } _ => {} }, + // '...' b'\'' => { let (_, suffix) = parse_lit_char(&repr); return Lit::Char(LitChar { @@ -987,6 +1046,7 @@ mod value { }); } b'0'..=b'9' | b'-' => { + // 0, 123, 0xFF, 0o77, 0b11 if let Some((digits, suffix)) = parse_lit_int(&repr) { return Lit::Int(LitInt { repr: Box::new(LitIntRepr { @@ -996,6 +1056,7 @@ mod value { }), }); } + // 1.0, 1e-1, 1e+1 if let Some((digits, suffix)) = parse_lit_float(&repr) { return Lit::Float(LitFloat { repr: Box::new(LitFloatRepr { @@ -1006,6 +1067,7 @@ mod value { }); } } + // true, false b't' | b'f' => { if repr == "true" || repr == "false" { return Lit::Bool(LitBool { @@ -1014,6 +1076,9 @@ mod value { }); } } + // c"...", cr"...", cr#"..."# + // TODO: add a Lit::CStr variant? + b'c' => return Lit::Verbatim(token), _ => {} } @@ -1061,7 +1126,7 @@ mod value { /// Get the byte at offset idx, or a default of `b'\0'` if we're looking /// past the end of the input buffer. - pub fn byte<S: AsRef<[u8]> + ?Sized>(s: &S, idx: usize) -> u8 { + pub(crate) fn byte<S: AsRef<[u8]> + ?Sized>(s: &S, idx: usize) -> u8 { let s = s.as_ref(); if idx < s.len() { s[idx] @@ -1075,7 +1140,7 @@ mod value { } // Returns (content, suffix). - pub fn parse_lit_str(s: &str) -> (Box<str>, Box<str>) { + pub(crate) fn parse_lit_str(s: &str) -> (Box<str>, Box<str>) { match byte(s, 0) { b'"' => parse_lit_str_cooked(s), b'r' => parse_lit_str_raw(s), @@ -1117,11 +1182,10 @@ mod value { b'\'' => '\'', b'"' => '"', b'\r' | b'\n' => loop { - let ch = next_chr(s); - if ch.is_whitespace() { - s = &s[ch.len_utf8()..]; - } else { - continue 'outer; + let b = byte(s, 0); + match b { + b' ' | b'\t' | b'\n' | b'\r' => s = &s[1..], + _ => continue 'outer, } }, b => panic!("unexpected byte {:?} after \\ character in byte literal", b), @@ -1167,7 +1231,7 @@ mod value { } // Returns (content, suffix). - pub fn parse_lit_byte_str(s: &str) -> (Vec<u8>, Box<str>) { + pub(crate) fn parse_lit_byte_str(s: &str) -> (Vec<u8>, Box<str>) { assert_eq!(byte(s, 0), b'b'); match byte(s, 1) { b'"' => parse_lit_byte_str_cooked(s), @@ -1244,7 +1308,7 @@ mod value { } // Returns (value, suffix). - pub fn parse_lit_byte(s: &str) -> (u8, Box<str>) { + pub(crate) fn parse_lit_byte(s: &str) -> (u8, Box<str>) { assert_eq!(byte(s, 0), b'b'); assert_eq!(byte(s, 1), b'\''); @@ -1283,7 +1347,7 @@ mod value { } // Returns (value, suffix). - pub fn parse_lit_char(mut s: &str) -> (char, Box<str>) { + pub(crate) fn parse_lit_char(mut s: &str) -> (char, Box<str>) { assert_eq!(byte(s, 0), b'\''); s = &s[1..]; @@ -1388,7 +1452,7 @@ mod value { } // Returns base 10 digits and suffix. - pub fn parse_lit_int(mut s: &str) -> Option<(Box<str>, Box<str>)> { + pub(crate) fn parse_lit_int(mut s: &str) -> Option<(Box<str>, Box<str>)> { let negative = byte(s, 0) == b'-'; if negative { s = &s[1..]; @@ -1412,6 +1476,7 @@ mod value { }; let mut value = BigInt::new(); + let mut has_digit = false; 'outer: loop { let b = byte(s, 0); let digit = match b { @@ -1455,11 +1520,16 @@ mod value { return None; } + has_digit = true; value *= base; value += digit; s = &s[1..]; } + if !has_digit { + return None; + } + let suffix = s; if suffix.is_empty() || crate::ident::xid_ok(suffix) { let mut repr = value.to_string(); @@ -1473,7 +1543,7 @@ mod value { } // Returns base 10 digits and suffix. - pub fn parse_lit_float(input: &str) -> Option<(Box<str>, Box<str>)> { + pub(crate) fn parse_lit_float(input: &str) -> Option<(Box<str>, Box<str>)> { // Rust's floating point literals are very similar to the ones parsed by // the standard library, except that rust's literals can contain // ignorable underscores. Let's remove those underscores. @@ -1563,38 +1633,4 @@ mod value { None } } - - #[allow(clippy::unnecessary_wraps)] - pub fn to_literal(repr: &str, digits: &str, suffix: &str) -> Option<Literal> { - #[cfg(syn_no_negative_literal_parse)] - { - // Rustc older than https://github.com/rust-lang/rust/pull/87262. - if repr.starts_with('-') { - let f64_parse_finite = || digits.parse().ok().filter(|x: &f64| x.is_finite()); - let f32_parse_finite = || digits.parse().ok().filter(|x: &f32| x.is_finite()); - return if suffix == "f64" { - f64_parse_finite().map(Literal::f64_suffixed) - } else if suffix == "f32" { - f32_parse_finite().map(Literal::f32_suffixed) - } else if suffix == "i64" { - digits.parse().ok().map(Literal::i64_suffixed) - } else if suffix == "i32" { - digits.parse().ok().map(Literal::i32_suffixed) - } else if suffix == "i16" { - digits.parse().ok().map(Literal::i16_suffixed) - } else if suffix == "i8" { - digits.parse().ok().map(Literal::i8_suffixed) - } else if !suffix.is_empty() { - None - } else if digits.contains('.') { - f64_parse_finite().map(Literal::f64_unsuffixed) - } else { - digits.parse().ok().map(Literal::i64_unsuffixed) - }; - } - } - let _ = digits; - let _ = suffix; - Some(repr.parse::<Literal>().unwrap()) - } } diff --git a/vendor/syn/src/lookahead.rs b/vendor/syn/src/lookahead.rs index 0cf5cf5a8..e89a4c7fd 100644 --- a/vendor/syn/src/lookahead.rs +++ b/vendor/syn/src/lookahead.rs @@ -24,7 +24,7 @@ use std::cell::RefCell; /// # Example /// /// ``` -/// use syn::{ConstParam, Ident, Lifetime, LifetimeDef, Result, Token, TypeParam}; +/// use syn::{ConstParam, Ident, Lifetime, LifetimeParam, Result, Token, TypeParam}; /// use syn::parse::{Parse, ParseStream}; /// /// // A generic parameter, a single one of the comma-separated elements inside @@ -40,7 +40,7 @@ use std::cell::RefCell; /// // | ^ /// enum GenericParam { /// Type(TypeParam), -/// Lifetime(LifetimeDef), +/// Lifetime(LifetimeParam), /// Const(ConstParam), /// } /// @@ -65,7 +65,7 @@ pub struct Lookahead1<'a> { comparisons: RefCell<Vec<&'static str>>, } -pub fn new(scope: Span, cursor: Cursor) -> Lookahead1 { +pub(crate) fn new(scope: Span, cursor: Cursor) -> Lookahead1 { Lookahead1 { scope, cursor, @@ -162,7 +162,7 @@ impl<S> IntoSpans<S> for TokenMarker { } } -pub fn is_delimiter(cursor: Cursor, delimiter: Delimiter) -> bool { +pub(crate) fn is_delimiter(cursor: Cursor, delimiter: Delimiter) -> bool { cursor.group(delimiter).is_some() } diff --git a/vendor/syn/src/mac.rs b/vendor/syn/src/mac.rs index 3d84f8e48..8f687cc9a 100644 --- a/vendor/syn/src/mac.rs +++ b/vendor/syn/src/mac.rs @@ -1,17 +1,17 @@ use super::*; use crate::token::{Brace, Bracket, Paren}; +use proc_macro2::extra::DelimSpan; +#[cfg(any(feature = "parsing", feature = "printing"))] +use proc_macro2::Delimiter; use proc_macro2::TokenStream; #[cfg(feature = "parsing")] -use proc_macro2::{Delimiter, Group, Span, TokenTree}; +use proc_macro2::TokenTree; #[cfg(feature = "parsing")] use crate::parse::{Parse, ParseStream, Parser, Result}; ast_struct! { /// A macro invocation: `println!("{}", mac)`. - /// - /// *This type is available only if Syn is built with the `"derive"` or `"full"` - /// feature.* #[cfg_attr(doc_cfg, doc(cfg(any(feature = "full", feature = "derive"))))] pub struct Macro { pub path: Path, @@ -23,9 +23,6 @@ ast_struct! { ast_enum! { /// A grouping token that surrounds a macro body: `m!(...)` or `m!{...}` or `m![...]`. - /// - /// *This type is available only if Syn is built with the `"derive"` or `"full"` - /// feature.* #[cfg_attr(doc_cfg, doc(cfg(any(feature = "full", feature = "derive"))))] pub enum MacroDelimiter { Paren(Paren), @@ -34,20 +31,14 @@ ast_enum! { } } -#[cfg(feature = "parsing")] -fn delimiter_span_close(macro_delimiter: &MacroDelimiter) -> Span { - let delimiter = match macro_delimiter { - MacroDelimiter::Paren(_) => Delimiter::Parenthesis, - MacroDelimiter::Brace(_) => Delimiter::Brace, - MacroDelimiter::Bracket(_) => Delimiter::Bracket, - }; - let mut group = Group::new(delimiter, TokenStream::new()); - group.set_span(match macro_delimiter { - MacroDelimiter::Paren(token) => token.span, - MacroDelimiter::Brace(token) => token.span, - MacroDelimiter::Bracket(token) => token.span, - }); - group.span_close() +impl MacroDelimiter { + pub fn span(&self) -> &DelimSpan { + match self { + MacroDelimiter::Paren(token) => &token.span, + MacroDelimiter::Brace(token) => &token.span, + MacroDelimiter::Bracket(token) => &token.span, + } + } } impl Macro { @@ -144,16 +135,16 @@ impl Macro { #[cfg(feature = "parsing")] #[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))] pub fn parse_body_with<F: Parser>(&self, parser: F) -> Result<F::Output> { - let scope = delimiter_span_close(&self.delimiter); + let scope = self.delimiter.span().close(); crate::parse::parse_scoped(parser, scope, self.tokens.clone()) } } #[cfg(feature = "parsing")] -pub fn parse_delimiter(input: ParseStream) -> Result<(MacroDelimiter, TokenStream)> { +pub(crate) fn parse_delimiter(input: ParseStream) -> Result<(MacroDelimiter, TokenStream)> { input.step(|cursor| { if let Some((TokenTree::Group(g), rest)) = cursor.token_tree() { - let span = g.span(); + let span = g.delim_span(); let delimiter = match g.delimiter() { Delimiter::Parenthesis => MacroDelimiter::Paren(Paren(span)), Delimiter::Brace => MacroDelimiter::Brace(Brace(span)), @@ -170,7 +161,7 @@ pub fn parse_delimiter(input: ParseStream) -> Result<(MacroDelimiter, TokenStrea } #[cfg(feature = "parsing")] -pub mod parsing { +pub(crate) mod parsing { use super::*; use crate::parse::{Parse, ParseStream, Result}; @@ -198,22 +189,23 @@ mod printing { use proc_macro2::TokenStream; use quote::ToTokens; + impl MacroDelimiter { + pub(crate) fn surround(&self, tokens: &mut TokenStream, inner: TokenStream) { + let (delim, span) = match self { + MacroDelimiter::Paren(paren) => (Delimiter::Parenthesis, paren.span), + MacroDelimiter::Brace(brace) => (Delimiter::Brace, brace.span), + MacroDelimiter::Bracket(bracket) => (Delimiter::Bracket, bracket.span), + }; + token::printing::delim(delim, span.join(), tokens, inner); + } + } + #[cfg_attr(doc_cfg, doc(cfg(feature = "printing")))] impl ToTokens for Macro { fn to_tokens(&self, tokens: &mut TokenStream) { self.path.to_tokens(tokens); self.bang_token.to_tokens(tokens); - match &self.delimiter { - MacroDelimiter::Paren(paren) => { - paren.surround(tokens, |tokens| self.tokens.to_tokens(tokens)); - } - MacroDelimiter::Brace(brace) => { - brace.surround(tokens, |tokens| self.tokens.to_tokens(tokens)); - } - MacroDelimiter::Bracket(bracket) => { - bracket.surround(tokens, |tokens| self.tokens.to_tokens(tokens)); - } - } + self.delimiter.surround(tokens, self.tokens.clone()); } } } diff --git a/vendor/syn/src/macros.rs b/vendor/syn/src/macros.rs index da10a1a55..953841b6f 100644 --- a/vendor/syn/src/macros.rs +++ b/vendor/syn/src/macros.rs @@ -76,8 +76,6 @@ macro_rules! ast_enum_of_structs_impl { $variant:ident $( ($($member:ident)::+) )*, )* } - - $($remaining:tt)* ) => { check_keyword_matches!(pub $pub); check_keyword_matches!(enum $enum); @@ -88,7 +86,6 @@ macro_rules! ast_enum_of_structs_impl { #[cfg(feature = "printing")] generate_to_tokens! { - $($remaining)* () tokens $name { @@ -116,13 +113,7 @@ macro_rules! ast_enum_from_struct { } #[cfg(feature = "printing")] -#[cfg_attr( - not(any(feature = "full", feature = "derive")), - allow(unknown_lints, unused_macro_rules) -)] macro_rules! generate_to_tokens { - (do_not_generate_to_tokens $($foo:tt)*) => (); - ( ($($arms:tt)*) $tokens:ident $name:ident { $(#[cfg $cfg_attr:tt])* diff --git a/vendor/syn/src/meta.rs b/vendor/syn/src/meta.rs new file mode 100644 index 000000000..766d5b703 --- /dev/null +++ b/vendor/syn/src/meta.rs @@ -0,0 +1,418 @@ +//! Facility for interpreting structured content inside of an `Attribute`. + +use crate::ext::IdentExt; +use crate::lit::Lit; +use crate::parse::{Error, ParseStream, Parser, Result}; +use crate::path::{Path, PathSegment}; +use crate::punctuated::Punctuated; +use proc_macro2::Ident; +use std::fmt::Display; + +/// Make a parser that is usable with `parse_macro_input!` in a +/// `#[proc_macro_attribute]` macro. +/// +/// *Warning:* When parsing attribute args **other than** the +/// `proc_macro::TokenStream` input of a `proc_macro_attribute`, you do **not** +/// need this function. In several cases your callers will get worse error +/// messages if you use this function, because the surrounding delimiter's span +/// is concealed from attribute macros by rustc. Use +/// [`Attribute::parse_nested_meta`] instead. +/// +/// [`Attribute::parse_nested_meta`]: crate::Attribute::parse_nested_meta +/// +/// # Example +/// +/// This example implements an attribute macro whose invocations look like this: +/// +/// ``` +/// # const IGNORE: &str = stringify! { +/// #[tea(kind = "EarlGrey", hot)] +/// struct Picard {...} +/// # }; +/// ``` +/// +/// The "parameters" supported by the attribute are: +/// +/// - `kind = "..."` +/// - `hot` +/// - `with(sugar, milk, ...)`, a comma-separated list of ingredients +/// +/// ``` +/// # extern crate proc_macro; +/// # +/// use proc_macro::TokenStream; +/// use syn::{parse_macro_input, LitStr, Path}; +/// +/// # const IGNORE: &str = stringify! { +/// #[proc_macro_attribute] +/// # }; +/// pub fn tea(args: TokenStream, input: TokenStream) -> TokenStream { +/// let mut kind: Option<LitStr> = None; +/// let mut hot: bool = false; +/// let mut with: Vec<Path> = Vec::new(); +/// let tea_parser = syn::meta::parser(|meta| { +/// if meta.path.is_ident("kind") { +/// kind = Some(meta.value()?.parse()?); +/// Ok(()) +/// } else if meta.path.is_ident("hot") { +/// hot = true; +/// Ok(()) +/// } else if meta.path.is_ident("with") { +/// meta.parse_nested_meta(|meta| { +/// with.push(meta.path); +/// Ok(()) +/// }) +/// } else { +/// Err(meta.error("unsupported tea property")) +/// } +/// }); +/// +/// parse_macro_input!(args with tea_parser); +/// eprintln!("kind={kind:?} hot={hot} with={with:?}"); +/// +/// /* ... */ +/// # TokenStream::new() +/// } +/// ``` +/// +/// The `syn::meta` library will take care of dealing with the commas including +/// trailing commas, and producing sensible error messages on unexpected input. +/// +/// ```console +/// error: expected `,` +/// --> src/main.rs:3:37 +/// | +/// 3 | #[tea(kind = "EarlGrey", with(sugar = "lol", milk))] +/// | ^ +/// ``` +/// +/// # Example +/// +/// Same as above but we factor out most of the logic into a separate function. +/// +/// ``` +/// # extern crate proc_macro; +/// # +/// use proc_macro::TokenStream; +/// use syn::meta::ParseNestedMeta; +/// use syn::parse::{Parser, Result}; +/// use syn::{parse_macro_input, LitStr, Path}; +/// +/// # const IGNORE: &str = stringify! { +/// #[proc_macro_attribute] +/// # }; +/// pub fn tea(args: TokenStream, input: TokenStream) -> TokenStream { +/// let mut attrs = TeaAttributes::default(); +/// let tea_parser = syn::meta::parser(|meta| attrs.parse(meta)); +/// parse_macro_input!(args with tea_parser); +/// +/// /* ... */ +/// # TokenStream::new() +/// } +/// +/// #[derive(Default)] +/// struct TeaAttributes { +/// kind: Option<LitStr>, +/// hot: bool, +/// with: Vec<Path>, +/// } +/// +/// impl TeaAttributes { +/// fn parse(&mut self, meta: ParseNestedMeta) -> Result<()> { +/// if meta.path.is_ident("kind") { +/// self.kind = Some(meta.value()?.parse()?); +/// Ok(()) +/// } else /* just like in last example */ +/// # { unimplemented!() } +/// +/// } +/// } +/// ``` +pub fn parser(logic: impl FnMut(ParseNestedMeta) -> Result<()>) -> impl Parser<Output = ()> { + |input: ParseStream| parse_nested_meta(input, logic) +} + +/// Context for parsing a single property in the conventional syntax for +/// structured attributes. +/// +/// # Examples +/// +/// Refer to usage examples on the following two entry-points: +/// +/// - [`Attribute::parse_nested_meta`] if you have an entire `Attribute` to +/// parse. Always use this if possible. Generally this is able to produce +/// better error messages because `Attribute` holds span information for all +/// of the delimiters therein. +/// +/// - [`syn::meta::parser`] if you are implementing a `proc_macro_attribute` +/// macro and parsing the arguments to the attribute macro, i.e. the ones +/// written in the same attribute that dispatched the macro invocation. Rustc +/// does not pass span information for the surrounding delimiters into the +/// attribute macro invocation in this situation, so error messages might be +/// less precise. +/// +/// [`Attribute::parse_nested_meta`]: crate::Attribute::parse_nested_meta +/// [`syn::meta::parser`]: crate::meta::parser +#[non_exhaustive] +pub struct ParseNestedMeta<'a> { + pub path: Path, + pub input: ParseStream<'a>, +} + +impl<'a> ParseNestedMeta<'a> { + /// Used when parsing `key = "value"` syntax. + /// + /// All it does is advance `meta.input` past the `=` sign in the input. You + /// could accomplish the same effect by writing + /// `meta.parse::<Token![=]>()?`, so at most it is a minor convenience to + /// use `meta.value()?`. + /// + /// # Example + /// + /// ``` + /// use syn::{parse_quote, Attribute, LitStr}; + /// + /// let attr: Attribute = parse_quote! { + /// #[tea(kind = "EarlGrey")] + /// }; + /// // conceptually: + /// if attr.path().is_ident("tea") { // this parses the `tea` + /// attr.parse_nested_meta(|meta| { // this parses the `(` + /// if meta.path.is_ident("kind") { // this parses the `kind` + /// let value = meta.value()?; // this parses the `=` + /// let s: LitStr = value.parse()?; // this parses `"EarlGrey"` + /// if s.value() == "EarlGrey" { + /// // ... + /// } + /// Ok(()) + /// } else { + /// Err(meta.error("unsupported attribute")) + /// } + /// })?; + /// } + /// # anyhow::Ok(()) + /// ``` + pub fn value(&self) -> Result<ParseStream<'a>> { + self.input.parse::<Token![=]>()?; + Ok(self.input) + } + + /// Used when parsing `list(...)` syntax **if** the content inside the + /// nested parentheses is also expected to conform to Rust's structured + /// attribute convention. + /// + /// # Example + /// + /// ``` + /// use syn::{parse_quote, Attribute}; + /// + /// let attr: Attribute = parse_quote! { + /// #[tea(with(sugar, milk))] + /// }; + /// + /// if attr.path().is_ident("tea") { + /// attr.parse_nested_meta(|meta| { + /// if meta.path.is_ident("with") { + /// meta.parse_nested_meta(|meta| { // <--- + /// if meta.path.is_ident("sugar") { + /// // Here we can go even deeper if needed. + /// Ok(()) + /// } else if meta.path.is_ident("milk") { + /// Ok(()) + /// } else { + /// Err(meta.error("unsupported ingredient")) + /// } + /// }) + /// } else { + /// Err(meta.error("unsupported tea property")) + /// } + /// })?; + /// } + /// # anyhow::Ok(()) + /// ``` + /// + /// # Counterexample + /// + /// If you don't need `parse_nested_meta`'s help in parsing the content + /// written within the nested parentheses, keep in mind that you can always + /// just parse it yourself from the exposed ParseStream. Rust syntax permits + /// arbitrary tokens within those parentheses so for the crazier stuff, + /// `parse_nested_meta` is not what you want. + /// + /// ``` + /// use syn::{parenthesized, parse_quote, Attribute, LitInt}; + /// + /// let attr: Attribute = parse_quote! { + /// #[repr(align(32))] + /// }; + /// + /// let mut align: Option<LitInt> = None; + /// if attr.path().is_ident("repr") { + /// attr.parse_nested_meta(|meta| { + /// if meta.path.is_ident("align") { + /// let content; + /// parenthesized!(content in meta.input); + /// align = Some(content.parse()?); + /// Ok(()) + /// } else { + /// Err(meta.error("unsupported repr")) + /// } + /// })?; + /// } + /// # anyhow::Ok(()) + /// ``` + pub fn parse_nested_meta( + &self, + logic: impl FnMut(ParseNestedMeta) -> Result<()>, + ) -> Result<()> { + let content; + parenthesized!(content in self.input); + parse_nested_meta(&content, logic) + } + + /// Report that the attribute's content did not conform to expectations. + /// + /// The span of the resulting error will cover `meta.path` *and* everything + /// that has been parsed so far since it. + /// + /// There are 2 ways you might call this. First, if `meta.path` is not + /// something you recognize: + /// + /// ``` + /// # use syn::Attribute; + /// # + /// # fn example(attr: &Attribute) -> syn::Result<()> { + /// attr.parse_nested_meta(|meta| { + /// if meta.path.is_ident("kind") { + /// // ... + /// Ok(()) + /// } else { + /// Err(meta.error("unsupported tea property")) + /// } + /// })?; + /// # Ok(()) + /// # } + /// ``` + /// + /// In this case, it behaves exactly like + /// `syn::Error::new_spanned(&meta.path, "message...")`. + /// + /// ```console + /// error: unsupported tea property + /// --> src/main.rs:3:26 + /// | + /// 3 | #[tea(kind = "EarlGrey", wat = "foo")] + /// | ^^^ + /// ``` + /// + /// More usefully, the second place is if you've already parsed a value but + /// have decided not to accept the value: + /// + /// ``` + /// # use syn::Attribute; + /// # + /// # fn example(attr: &Attribute) -> syn::Result<()> { + /// use syn::Expr; + /// + /// attr.parse_nested_meta(|meta| { + /// if meta.path.is_ident("kind") { + /// let expr: Expr = meta.value()?.parse()?; + /// match expr { + /// Expr::Lit(expr) => /* ... */ + /// # unimplemented!(), + /// Expr::Path(expr) => /* ... */ + /// # unimplemented!(), + /// Expr::Macro(expr) => /* ... */ + /// # unimplemented!(), + /// _ => Err(meta.error("tea kind must be a string literal, path, or macro")), + /// } + /// } else /* as above */ + /// # { unimplemented!() } + /// + /// })?; + /// # Ok(()) + /// # } + /// ``` + /// + /// ```console + /// error: tea kind must be a string literal, path, or macro + /// --> src/main.rs:3:7 + /// | + /// 3 | #[tea(kind = async { replicator.await })] + /// | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + /// ``` + /// + /// Often you may want to use `syn::Error::new_spanned` even in this + /// situation. In the above code, that would be: + /// + /// ``` + /// # use syn::{Error, Expr}; + /// # + /// # fn example(expr: Expr) -> syn::Result<()> { + /// match expr { + /// Expr::Lit(expr) => /* ... */ + /// # unimplemented!(), + /// Expr::Path(expr) => /* ... */ + /// # unimplemented!(), + /// Expr::Macro(expr) => /* ... */ + /// # unimplemented!(), + /// _ => Err(Error::new_spanned(expr, "unsupported expression type for `kind`")), + /// } + /// # } + /// ``` + /// + /// ```console + /// error: unsupported expression type for `kind` + /// --> src/main.rs:3:14 + /// | + /// 3 | #[tea(kind = async { replicator.await })] + /// | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + /// ``` + pub fn error(&self, msg: impl Display) -> Error { + let start_span = self.path.segments[0].ident.span(); + let end_span = self.input.cursor().prev_span(); + crate::error::new2(start_span, end_span, msg) + } +} + +pub(crate) fn parse_nested_meta( + input: ParseStream, + mut logic: impl FnMut(ParseNestedMeta) -> Result<()>, +) -> Result<()> { + loop { + let path = input.call(parse_meta_path)?; + logic(ParseNestedMeta { path, input })?; + if input.is_empty() { + return Ok(()); + } + input.parse::<Token![,]>()?; + if input.is_empty() { + return Ok(()); + } + } +} + +// Like Path::parse_mod_style, but accepts keywords in the path. +fn parse_meta_path(input: ParseStream) -> Result<Path> { + Ok(Path { + leading_colon: input.parse()?, + segments: { + let mut segments = Punctuated::new(); + if input.peek(Ident::peek_any) { + let ident = Ident::parse_any(input)?; + segments.push_value(PathSegment::from(ident)); + } else if input.peek(Lit) { + return Err(input.error("unexpected literal in nested attribute, expected ident")); + } else { + return Err(input.error("unexpected token in nested attribute, expected ident")); + } + while input.peek(Token![::]) { + let punct = input.parse()?; + segments.push_punct(punct); + let ident = Ident::parse_any(input)?; + segments.push_value(PathSegment::from(ident)); + } + segments + }, + }) +} diff --git a/vendor/syn/src/op.rs b/vendor/syn/src/op.rs index b8ef9a7fb..bff72c8ba 100644 --- a/vendor/syn/src/op.rs +++ b/vendor/syn/src/op.rs @@ -1,9 +1,7 @@ ast_enum! { /// A binary operator: `+`, `+=`, `&`. - /// - /// *This type is available only if Syn is built with the `"derive"` or `"full"` - /// feature.* #[cfg_attr(doc_cfg, doc(cfg(any(feature = "full", feature = "derive"))))] + #[non_exhaustive] pub enum BinOp { /// The `+` operator (addition) Add(Token![+]), @@ -42,34 +40,32 @@ ast_enum! { /// The `>` operator (greater than) Gt(Token![>]), /// The `+=` operator - AddEq(Token![+=]), + AddAssign(Token![+=]), /// The `-=` operator - SubEq(Token![-=]), + SubAssign(Token![-=]), /// The `*=` operator - MulEq(Token![*=]), + MulAssign(Token![*=]), /// The `/=` operator - DivEq(Token![/=]), + DivAssign(Token![/=]), /// The `%=` operator - RemEq(Token![%=]), + RemAssign(Token![%=]), /// The `^=` operator - BitXorEq(Token![^=]), + BitXorAssign(Token![^=]), /// The `&=` operator - BitAndEq(Token![&=]), + BitAndAssign(Token![&=]), /// The `|=` operator - BitOrEq(Token![|=]), + BitOrAssign(Token![|=]), /// The `<<=` operator - ShlEq(Token![<<=]), + ShlAssign(Token![<<=]), /// The `>>=` operator - ShrEq(Token![>>=]), + ShrAssign(Token![>>=]), } } ast_enum! { /// A unary operator: `*`, `!`, `-`. - /// - /// *This type is available only if Syn is built with the `"derive"` or `"full"` - /// feature.* #[cfg_attr(doc_cfg, doc(cfg(any(feature = "full", feature = "derive"))))] + #[non_exhaustive] pub enum UnOp { /// The `*` operator for dereferencing Deref(Token![*]), @@ -81,7 +77,7 @@ ast_enum! { } #[cfg(feature = "parsing")] -pub mod parsing { +pub(crate) mod parsing { use super::*; use crate::parse::{Parse, ParseStream, Result}; @@ -137,25 +133,25 @@ pub mod parsing { #[cfg(feature = "full")] fn parse(input: ParseStream) -> Result<Self> { if input.peek(Token![+=]) { - input.parse().map(BinOp::AddEq) + input.parse().map(BinOp::AddAssign) } else if input.peek(Token![-=]) { - input.parse().map(BinOp::SubEq) + input.parse().map(BinOp::SubAssign) } else if input.peek(Token![*=]) { - input.parse().map(BinOp::MulEq) + input.parse().map(BinOp::MulAssign) } else if input.peek(Token![/=]) { - input.parse().map(BinOp::DivEq) + input.parse().map(BinOp::DivAssign) } else if input.peek(Token![%=]) { - input.parse().map(BinOp::RemEq) + input.parse().map(BinOp::RemAssign) } else if input.peek(Token![^=]) { - input.parse().map(BinOp::BitXorEq) + input.parse().map(BinOp::BitXorAssign) } else if input.peek(Token![&=]) { - input.parse().map(BinOp::BitAndEq) + input.parse().map(BinOp::BitAndAssign) } else if input.peek(Token![|=]) { - input.parse().map(BinOp::BitOrEq) + input.parse().map(BinOp::BitOrAssign) } else if input.peek(Token![<<=]) { - input.parse().map(BinOp::ShlEq) + input.parse().map(BinOp::ShlAssign) } else if input.peek(Token![>>=]) { - input.parse().map(BinOp::ShrEq) + input.parse().map(BinOp::ShrAssign) } else { parse_binop(input) } @@ -207,16 +203,16 @@ mod printing { BinOp::Ne(t) => t.to_tokens(tokens), BinOp::Ge(t) => t.to_tokens(tokens), BinOp::Gt(t) => t.to_tokens(tokens), - BinOp::AddEq(t) => t.to_tokens(tokens), - BinOp::SubEq(t) => t.to_tokens(tokens), - BinOp::MulEq(t) => t.to_tokens(tokens), - BinOp::DivEq(t) => t.to_tokens(tokens), - BinOp::RemEq(t) => t.to_tokens(tokens), - BinOp::BitXorEq(t) => t.to_tokens(tokens), - BinOp::BitAndEq(t) => t.to_tokens(tokens), - BinOp::BitOrEq(t) => t.to_tokens(tokens), - BinOp::ShlEq(t) => t.to_tokens(tokens), - BinOp::ShrEq(t) => t.to_tokens(tokens), + BinOp::AddAssign(t) => t.to_tokens(tokens), + BinOp::SubAssign(t) => t.to_tokens(tokens), + BinOp::MulAssign(t) => t.to_tokens(tokens), + BinOp::DivAssign(t) => t.to_tokens(tokens), + BinOp::RemAssign(t) => t.to_tokens(tokens), + BinOp::BitXorAssign(t) => t.to_tokens(tokens), + BinOp::BitAndAssign(t) => t.to_tokens(tokens), + BinOp::BitOrAssign(t) => t.to_tokens(tokens), + BinOp::ShlAssign(t) => t.to_tokens(tokens), + BinOp::ShrAssign(t) => t.to_tokens(tokens), } } } diff --git a/vendor/syn/src/parse.rs b/vendor/syn/src/parse.rs index bac4ca05a..61a10d2bc 100644 --- a/vendor/syn/src/parse.rs +++ b/vendor/syn/src/parse.rs @@ -66,7 +66,7 @@ //! struct_token: input.parse()?, //! ident: input.parse()?, //! brace_token: braced!(content in input), -//! fields: content.parse_terminated(Field::parse_named)?, +//! fields: content.parse_terminated(Field::parse_named, Token![,])?, //! }) //! } //! } @@ -84,7 +84,7 @@ //! let input = parse_macro_input!(tokens as Item); //! //! /* ... */ -//! # "".parse().unwrap() +//! # TokenStream::new() //! } //! ``` //! @@ -178,10 +178,6 @@ //! Ok(()) //! } //! ``` -//! -//! --- -//! -//! *This module is available only if Syn is built with the `"parsing"` feature.* #[path = "discouraged.rs"] pub mod discouraged; @@ -685,7 +681,7 @@ impl<'a> ParseBuffer<'a> { /// struct_token: input.parse()?, /// ident: input.parse()?, /// paren_token: parenthesized!(content in input), - /// fields: content.parse_terminated(Type::parse)?, + /// fields: content.parse_terminated(Type::parse, Token![,])?, /// semi_token: input.parse()?, /// }) /// } @@ -696,10 +692,63 @@ impl<'a> ParseBuffer<'a> { /// # }; /// # syn::parse2::<TupleStruct>(input).unwrap(); /// ``` - pub fn parse_terminated<T, P: Parse>( + /// + /// # See also + /// + /// If your separator is anything more complicated than an invocation of the + /// `Token!` macro, this method won't be applicable and you can instead + /// directly use `Punctuated`'s parser functions: [`parse_terminated`], + /// [`parse_separated_nonempty`] etc. + /// + /// [`parse_terminated`]: Punctuated::parse_terminated + /// [`parse_separated_nonempty`]: Punctuated::parse_separated_nonempty + /// + /// ``` + /// use syn::{custom_keyword, Expr, Result, Token}; + /// use syn::parse::{Parse, ParseStream}; + /// use syn::punctuated::Punctuated; + /// + /// mod kw { + /// syn::custom_keyword!(fin); + /// } + /// + /// struct Fin(kw::fin, Token![;]); + /// + /// impl Parse for Fin { + /// fn parse(input: ParseStream) -> Result<Self> { + /// Ok(Self(input.parse()?, input.parse()?)) + /// } + /// } + /// + /// struct Thing { + /// steps: Punctuated<Expr, Fin>, + /// } + /// + /// impl Parse for Thing { + /// fn parse(input: ParseStream) -> Result<Self> { + /// # if true { + /// Ok(Thing { + /// steps: Punctuated::parse_terminated(input)?, + /// }) + /// # } else { + /// // or equivalently, this means the same thing: + /// # Ok(Thing { + /// steps: input.call(Punctuated::parse_terminated)?, + /// # }) + /// # } + /// } + /// } + /// ``` + pub fn parse_terminated<T, P>( &self, parser: fn(ParseStream) -> Result<T>, - ) -> Result<Punctuated<T, P>> { + separator: P, + ) -> Result<Punctuated<T, P::Token>> + where + P: Peek, + P::Token: Parse, + { + let _ = separator; Punctuated::parse_terminated_with(self, parser) } @@ -750,7 +799,7 @@ impl<'a> ParseBuffer<'a> { /// # Example /// /// ``` - /// use syn::{ConstParam, Ident, Lifetime, LifetimeDef, Result, Token, TypeParam}; + /// use syn::{ConstParam, Ident, Lifetime, LifetimeParam, Result, Token, TypeParam}; /// use syn::parse::{Parse, ParseStream}; /// /// // A generic parameter, a single one of the comma-separated elements inside @@ -766,7 +815,7 @@ impl<'a> ParseBuffer<'a> { /// // | ^ /// enum GenericParam { /// Type(TypeParam), - /// Lifetime(LifetimeDef), + /// Lifetime(LifetimeParam), /// Const(ConstParam), /// } /// @@ -1101,10 +1150,8 @@ impl Parse for TokenTree { impl Parse for Group { fn parse(input: ParseStream) -> Result<Self> { input.step(|cursor| { - for delim in &[Delimiter::Parenthesis, Delimiter::Brace, Delimiter::Bracket] { - if let Some((inside, span, rest)) = cursor.group(*delim) { - let mut group = Group::new(*delim, inside.token_stream()); - group.set_span(span); + if let Some((group, rest)) = cursor.any_group_token() { + if group.delimiter() != Delimiter::None { return Ok((group, rest)); } } @@ -1138,8 +1185,6 @@ impl Parse for Literal { /// Refer to the [module documentation] for details about parsing in Syn. /// /// [module documentation]: self -/// -/// *This trait is available only if Syn is built with the `"parsing"` feature.* pub trait Parser: Sized { type Output; @@ -1153,13 +1198,11 @@ pub trait Parser: Sized { /// /// This function will check that the input is fully parsed. If there are /// any unparsed tokens at the end of the stream, an error is returned. - /// - /// *This method is available only if Syn is built with both the `"parsing"` and - /// `"proc-macro"` features.* #[cfg(all( not(all(target_arch = "wasm32", any(target_os = "unknown", target_os = "wasi"))), feature = "proc-macro" ))] + #[cfg_attr(doc_cfg, doc(cfg(feature = "proc-macro")))] fn parse(self, tokens: proc_macro::TokenStream) -> Result<Self::Output> { self.parse2(proc_macro2::TokenStream::from(tokens)) } @@ -1184,13 +1227,6 @@ pub trait Parser: Sized { let _ = scope; self.parse2(tokens) } - - // Not public API. - #[doc(hidden)] - #[cfg(any(feature = "full", feature = "derive"))] - fn __parse_stream(self, input: ParseStream) -> Result<Self::Output> { - input.parse().and_then(|tokens| self.parse2(tokens)) - } } fn tokens_to_parse_buffer(tokens: &TokenBuffer) -> ParseBuffer { @@ -1232,11 +1268,6 @@ where Ok(node) } } - - #[cfg(any(feature = "full", feature = "derive"))] - fn __parse_stream(self, input: ParseStream) -> Result<Self::Output> { - self(input) - } } #[cfg(any(feature = "full", feature = "derive"))] @@ -1244,11 +1275,6 @@ pub(crate) fn parse_scoped<F: Parser>(f: F, scope: Span, tokens: TokenStream) -> f.__parse_scoped(scope, tokens) } -#[cfg(any(feature = "full", feature = "derive"))] -pub(crate) fn parse_stream<F: Parser>(f: F, input: ParseStream) -> Result<F::Output> { - f.__parse_stream(input) -} - /// An empty syntax tree node that consumes no tokens when parsed. /// /// This is useful for attribute macros that want to ensure they are not @@ -1268,7 +1294,7 @@ pub(crate) fn parse_stream<F: Parser>(f: F, input: ParseStream) -> Result<F::Out /// parse_macro_input!(args as Nothing); /// /// /* ... */ -/// # "".parse().unwrap() +/// # TokenStream::new() /// } /// ``` /// diff --git a/vendor/syn/src/parse_macro_input.rs b/vendor/syn/src/parse_macro_input.rs index 6163cd70a..6f1562f4b 100644 --- a/vendor/syn/src/parse_macro_input.rs +++ b/vendor/syn/src/parse_macro_input.rs @@ -40,7 +40,7 @@ /// let input = parse_macro_input!(tokens as MyMacroInput); /// /// /* ... */ -/// # "".parse().unwrap() +/// # TokenStream::new() /// } /// ``` /// @@ -76,7 +76,7 @@ /// let input = parse_macro_input!(tokens with MyMacroInput::parse_alternate); /// /// /* ... */ -/// # "".parse().unwrap() +/// # TokenStream::new() /// } /// ``` /// @@ -107,7 +107,7 @@ #[cfg_attr(doc_cfg, doc(cfg(all(feature = "parsing", feature = "proc-macro"))))] macro_rules! parse_macro_input { ($tokenstream:ident as $ty:ty) => { - match $crate::parse_macro_input::parse::<$ty>($tokenstream) { + match $crate::parse::<$ty>($tokenstream) { $crate::__private::Ok(data) => data, $crate::__private::Err(err) => { return $crate::__private::TokenStream::from(err.to_compile_error()); @@ -126,54 +126,3 @@ macro_rules! parse_macro_input { $crate::parse_macro_input!($tokenstream as _) }; } - -//////////////////////////////////////////////////////////////////////////////// -// Can parse any type that implements Parse. - -use crate::parse::{Parse, ParseStream, Parser, Result}; -use proc_macro::TokenStream; - -// Not public API. -#[doc(hidden)] -pub fn parse<T: ParseMacroInput>(token_stream: TokenStream) -> Result<T> { - T::parse.parse(token_stream) -} - -// Not public API. -#[doc(hidden)] -pub trait ParseMacroInput: Sized { - fn parse(input: ParseStream) -> Result<Self>; -} - -impl<T: Parse> ParseMacroInput for T { - fn parse(input: ParseStream) -> Result<Self> { - <T as Parse>::parse(input) - } -} - -//////////////////////////////////////////////////////////////////////////////// -// Any other types that we want `parse_macro_input!` to be able to parse. - -#[cfg(any(feature = "full", feature = "derive"))] -use crate::AttributeArgs; - -#[cfg(any(feature = "full", feature = "derive"))] -impl ParseMacroInput for AttributeArgs { - fn parse(input: ParseStream) -> Result<Self> { - let mut metas = Vec::new(); - - loop { - if input.is_empty() { - break; - } - let value = input.parse()?; - metas.push(value); - if input.is_empty() { - break; - } - input.parse::<Token![,]>()?; - } - - Ok(metas) - } -} diff --git a/vendor/syn/src/parse_quote.rs b/vendor/syn/src/parse_quote.rs index 8deae4e52..f5129439c 100644 --- a/vendor/syn/src/parse_quote.rs +++ b/vendor/syn/src/parse_quote.rs @@ -24,9 +24,8 @@ /// } /// ``` /// -/// *This macro is available only if Syn is built with the `"parsing"` feature, -/// although interpolation of syntax tree nodes into the quoted tokens is only -/// supported if Syn is built with the `"printing"` feature as well.* +/// *This macro is available only if Syn is built with both the `"parsing"` and +/// `"printing"` features.* /// /// # Example /// @@ -69,7 +68,7 @@ #[macro_export] macro_rules! parse_quote { ($($tt:tt)*) => { - $crate::parse_quote::parse($crate::__private::quote::quote!($($tt)*)) + $crate::__private::parse_quote($crate::__private::quote::quote!($($tt)*)) }; } @@ -101,7 +100,7 @@ macro_rules! parse_quote { #[macro_export] macro_rules! parse_quote_spanned { ($span:expr=> $($tt:tt)*) => { - $crate::parse_quote::parse($crate::__private::quote::quote_spanned!($span=> $($tt)*)) + $crate::__private::parse_quote($crate::__private::quote::quote_spanned!($span=> $($tt)*)) }; } @@ -121,8 +120,6 @@ pub fn parse<T: ParseQuote>(token_stream: TokenStream) -> T { } } -// Not public API. -#[doc(hidden)] pub trait ParseQuote: Sized { fn parse(input: ParseStream) -> Result<Self>; } @@ -140,7 +137,7 @@ use crate::punctuated::Punctuated; #[cfg(any(feature = "full", feature = "derive"))] use crate::{attr, Attribute}; #[cfg(feature = "full")] -use crate::{Block, Stmt}; +use crate::{Block, Pat, Stmt}; #[cfg(any(feature = "full", feature = "derive"))] impl ParseQuote for Attribute { @@ -153,6 +150,20 @@ impl ParseQuote for Attribute { } } +#[cfg(feature = "full")] +impl ParseQuote for Pat { + fn parse(input: ParseStream) -> Result<Self> { + Pat::parse_multi_with_leading_vert(input) + } +} + +#[cfg(feature = "full")] +impl ParseQuote for Box<Pat> { + fn parse(input: ParseStream) -> Result<Self> { + <Pat as ParseQuote>::parse(input).map(Box::new) + } +} + impl<T: Parse, P: Parse> ParseQuote for Punctuated<T, P> { fn parse(input: ParseStream) -> Result<Self> { Self::parse_terminated(input) diff --git a/vendor/syn/src/pat.rs b/vendor/syn/src/pat.rs index b279186aa..5833eeb33 100644 --- a/vendor/syn/src/pat.rs +++ b/vendor/syn/src/pat.rs @@ -6,26 +6,21 @@ ast_enum_of_structs! { /// A pattern in a local binding, function signature, match expression, or /// various other places. /// - /// *This type is available only if Syn is built with the `"full"` feature.* - /// /// # Syntax tree enum /// /// This type is a [syntax tree enum]. /// /// [syntax tree enum]: Expr#syntax-tree-enums #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] - #[cfg_attr(not(syn_no_non_exhaustive), non_exhaustive)] + #[non_exhaustive] pub enum Pat { - /// A box pattern: `box v`. - Box(PatBox), + /// A const block: `const { ... }`. + Const(PatConst), /// A pattern that binds a new variable: `ref mut binding @ SUBPATTERN`. Ident(PatIdent), /// A literal pattern: `0`. - /// - /// This holds an `Expr` rather than a `Lit` because negative numbers - /// are represented as an `Expr::Unary`. Lit(PatLit), /// A macro in pattern position. @@ -34,6 +29,9 @@ ast_enum_of_structs! { /// A pattern that matches any one of a set of cases. Or(PatOr), + /// A parenthesized pattern: `(A | B)`. + Paren(PatParen), + /// A path pattern like `Color::Red`, optionally qualified with a /// self-type. /// @@ -49,7 +47,7 @@ ast_enum_of_structs! { /// A reference pattern: `&mut var`. Reference(PatReference), - /// The dots in a tuple or slice pattern: `[0, 1, ..]` + /// The dots in a tuple or slice pattern: `[0, 1, ..]`. Rest(PatRest), /// A dynamically sized slice pattern: `[a, b, ref i @ .., y, z]`. @@ -73,8 +71,6 @@ ast_enum_of_structs! { /// A pattern that matches any value: `_`. Wild(PatWild), - // Not public API. - // // For testing exhaustiveness in downstream code, use the following idiom: // // match pat { @@ -91,21 +87,6 @@ ast_enum_of_structs! { // a variant. You will be notified by a test failure when a variant is // added, so that you can add code to handle it, but your library will // continue to compile and work for downstream users in the interim. - #[cfg(syn_no_non_exhaustive)] - #[doc(hidden)] - __NonExhaustive, - } -} - -ast_struct! { - /// A box pattern: `box v`. - /// - /// *This type is available only if Syn is built with the `"full"` feature.* - #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] - pub struct PatBox { - pub attrs: Vec<Attribute>, - pub box_token: Token![box], - pub pat: Box<Pat>, } } @@ -114,8 +95,6 @@ ast_struct! { /// /// It may also be a unit struct or struct variant (e.g. `None`), or a /// constant; these cannot be distinguished syntactically. - /// - /// *This type is available only if Syn is built with the `"full"` feature.* #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub struct PatIdent { pub attrs: Vec<Attribute>, @@ -127,34 +106,7 @@ ast_struct! { } ast_struct! { - /// A literal pattern: `0`. - /// - /// This holds an `Expr` rather than a `Lit` because negative numbers - /// are represented as an `Expr::Unary`. - /// - /// *This type is available only if Syn is built with the `"full"` feature.* - #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] - pub struct PatLit { - pub attrs: Vec<Attribute>, - pub expr: Box<Expr>, - } -} - -ast_struct! { - /// A macro in pattern position. - /// - /// *This type is available only if Syn is built with the `"full"` feature.* - #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] - pub struct PatMacro { - pub attrs: Vec<Attribute>, - pub mac: Macro, - } -} - -ast_struct! { /// A pattern that matches any one of a set of cases. - /// - /// *This type is available only if Syn is built with the `"full"` feature.* #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub struct PatOr { pub attrs: Vec<Attribute>, @@ -164,40 +116,16 @@ ast_struct! { } ast_struct! { - /// A path pattern like `Color::Red`, optionally qualified with a - /// self-type. - /// - /// Unqualified path patterns can legally refer to variants, structs, - /// constants or associated constants. Qualified path patterns like - /// `<A>::B::C` and `<A as Trait>::B::C` can only legally refer to - /// associated constants. - /// - /// *This type is available only if Syn is built with the `"full"` feature.* - #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] - pub struct PatPath { - pub attrs: Vec<Attribute>, - pub qself: Option<QSelf>, - pub path: Path, - } -} - -ast_struct! { - /// A range pattern: `1..=2`. - /// - /// *This type is available only if Syn is built with the `"full"` feature.* - #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] - pub struct PatRange { + /// A parenthesized pattern: `(A | B)`. + pub struct PatParen { pub attrs: Vec<Attribute>, - pub lo: Box<Expr>, - pub limits: RangeLimits, - pub hi: Box<Expr>, + pub paren_token: token::Paren, + pub pat: Box<Pat>, } } ast_struct! { /// A reference pattern: `&mut var`. - /// - /// *This type is available only if Syn is built with the `"full"` feature.* #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub struct PatReference { pub attrs: Vec<Attribute>, @@ -208,9 +136,7 @@ ast_struct! { } ast_struct! { - /// The dots in a tuple or slice pattern: `[0, 1, ..]` - /// - /// *This type is available only if Syn is built with the `"full"` feature.* + /// The dots in a tuple or slice pattern: `[0, 1, ..]`. #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub struct PatRest { pub attrs: Vec<Attribute>, @@ -220,8 +146,6 @@ ast_struct! { ast_struct! { /// A dynamically sized slice pattern: `[a, b, ref i @ .., y, z]`. - /// - /// *This type is available only if Syn is built with the `"full"` feature.* #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub struct PatSlice { pub attrs: Vec<Attribute>, @@ -232,22 +156,19 @@ ast_struct! { ast_struct! { /// A struct or struct variant pattern: `Variant { x, y, .. }`. - /// - /// *This type is available only if Syn is built with the `"full"` feature.* #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub struct PatStruct { pub attrs: Vec<Attribute>, + pub qself: Option<QSelf>, pub path: Path, pub brace_token: token::Brace, pub fields: Punctuated<FieldPat, Token![,]>, - pub dot2_token: Option<Token![..]>, + pub rest: Option<PatRest>, } } ast_struct! { /// A tuple pattern: `(a, b)`. - /// - /// *This type is available only if Syn is built with the `"full"` feature.* #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub struct PatTuple { pub attrs: Vec<Attribute>, @@ -258,20 +179,18 @@ ast_struct! { ast_struct! { /// A tuple struct or tuple variant pattern: `Variant(x, y, .., z)`. - /// - /// *This type is available only if Syn is built with the `"full"` feature.* #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub struct PatTupleStruct { pub attrs: Vec<Attribute>, + pub qself: Option<QSelf>, pub path: Path, - pub pat: PatTuple, + pub paren_token: token::Paren, + pub elems: Punctuated<Pat, Token![,]>, } } ast_struct! { /// A type ascription pattern: `foo: f64`. - /// - /// *This type is available only if Syn is built with the `"full"` feature.* #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub struct PatType { pub attrs: Vec<Attribute>, @@ -283,8 +202,6 @@ ast_struct! { ast_struct! { /// A pattern that matches any value: `_`. - /// - /// *This type is available only if Syn is built with the `"full"` feature.* #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub struct PatWild { pub attrs: Vec<Attribute>, @@ -297,8 +214,6 @@ ast_struct! { /// /// Patterns like the fields of Foo `{ x, ref y, ref mut z }` are treated /// the same as `x: x, y: ref y, z: ref mut z` but there is no colon token. - /// - /// *This type is available only if Syn is built with the `"full"` feature.* #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub struct FieldPat { pub attrs: Vec<Attribute>, @@ -309,31 +224,49 @@ ast_struct! { } #[cfg(feature = "parsing")] -pub mod parsing { +pub(crate) mod parsing { use super::*; use crate::ext::IdentExt; - use crate::parse::{Parse, ParseBuffer, ParseStream, Result}; + use crate::parse::{ParseBuffer, ParseStream, Result}; use crate::path; #[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))] - impl Parse for Pat { - fn parse(input: ParseStream) -> Result<Self> { + impl Pat { + /// Parse a pattern that does _not_ involve `|` at the top level. + /// + /// This parser matches the behavior of the `$:pat_param` macro_rules + /// matcher, and on editions prior to Rust 2021, the behavior of + /// `$:pat`. + /// + /// In Rust syntax, some examples of where this syntax would occur are + /// in the argument pattern of functions and closures. Patterns using + /// `|` are not allowed to occur in these positions. + /// + /// ```compile_fail + /// fn f(Some(_) | None: Option<T>) { + /// let _ = |Some(_) | None: Option<T>| {}; + /// // ^^^^^^^^^^^^^^^^^^^^^^^^^??? :( + /// } + /// ``` + /// + /// ```console + /// error: top-level or-patterns are not allowed in function parameters + /// --> src/main.rs:1:6 + /// | + /// 1 | fn f(Some(_) | None: Option<T>) { + /// | ^^^^^^^^^^^^^^ help: wrap the pattern in parentheses: `(Some(_) | None)` + /// ``` + pub fn parse_single(input: ParseStream) -> Result<Self> { let begin = input.fork(); let lookahead = input.lookahead1(); - if { - let ahead = input.fork(); - ahead.parse::<Option<Ident>>()?.is_some() - && (ahead.peek(Token![::]) - || ahead.peek(Token![!]) - || ahead.peek(token::Brace) - || ahead.peek(token::Paren) - || ahead.peek(Token![..]) - && ahead.parse::<RangeLimits>().is_ok() - && !(ahead.is_empty() || ahead.peek(Token![,]))) - } || { - let ahead = input.fork(); - ahead.parse::<Option<Token![self]>>()?.is_some() && ahead.peek(Token![::]) - } || lookahead.peek(Token![::]) + if lookahead.peek(Ident) + && (input.peek2(Token![::]) + || input.peek2(Token![!]) + || input.peek2(token::Brace) + || input.peek2(token::Paren) + || input.peek2(Token![..])) + || input.peek(Token![self]) && input.peek2(Token![::]) + || lookahead.peek(Token![::]) || lookahead.peek(Token![<]) || input.peek(Token![Self]) || input.peek(Token![super]) @@ -343,7 +276,7 @@ pub mod parsing { } else if lookahead.peek(Token![_]) { input.call(pat_wild).map(Pat::Wild) } else if input.peek(Token![box]) { - input.call(pat_box).map(Pat::Box) + pat_box(begin, input) } else if input.peek(Token![-]) || lookahead.peek(Lit) || lookahead.peek(Token![const]) { pat_lit_or_range(input) @@ -356,67 +289,122 @@ pub mod parsing { } else if lookahead.peek(Token![&]) { input.call(pat_reference).map(Pat::Reference) } else if lookahead.peek(token::Paren) { - input.call(pat_tuple).map(Pat::Tuple) + input.call(pat_paren_or_tuple) } else if lookahead.peek(token::Bracket) { input.call(pat_slice).map(Pat::Slice) } else if lookahead.peek(Token![..]) && !input.peek(Token![...]) { - pat_range_half_open(input, begin) + pat_range_half_open(input) } else if lookahead.peek(Token![const]) { input.call(pat_const).map(Pat::Verbatim) } else { Err(lookahead.error()) } } + + /// Parse a pattern, possibly involving `|`, but not a leading `|`. + pub fn parse_multi(input: ParseStream) -> Result<Self> { + multi_pat_impl(input, None) + } + + /// Parse a pattern, possibly involving `|`, possibly including a + /// leading `|`. + /// + /// This parser matches the behavior of the Rust 2021 edition's `$:pat` + /// macro_rules matcher. + /// + /// In Rust syntax, an example of where this syntax would occur is in + /// the pattern of a `match` arm, where the language permits an optional + /// leading `|`, although it is not idiomatic to write one there in + /// handwritten code. + /// + /// ``` + /// # let wat = None; + /// match wat { + /// | None | Some(false) => {} + /// | Some(true) => {} + /// } + /// ``` + /// + /// The compiler accepts it only to facilitate some situations in + /// macro-generated code where a macro author might need to write: + /// + /// ``` + /// # macro_rules! doc { + /// # ($value:expr, ($($conditions1:pat),*), ($($conditions2:pat),*), $then:expr) => { + /// match $value { + /// $(| $conditions1)* $(| $conditions2)* => $then + /// } + /// # }; + /// # } + /// # + /// # doc!(true, (true), (false), {}); + /// # doc!(true, (), (true, false), {}); + /// # doc!(true, (true, false), (), {}); + /// ``` + /// + /// Expressing the same thing correctly in the case that either one (but + /// not both) of `$conditions1` and `$conditions2` might be empty, + /// without leading `|`, is complex. + /// + /// Use [`Pat::parse_multi`] instead if you are not intending to support + /// macro-generated macro input. + pub fn parse_multi_with_leading_vert(input: ParseStream) -> Result<Self> { + let leading_vert: Option<Token![|]> = input.parse()?; + multi_pat_impl(input, leading_vert) + } + } + + fn multi_pat_impl(input: ParseStream, leading_vert: Option<Token![|]>) -> Result<Pat> { + let mut pat = Pat::parse_single(input)?; + if leading_vert.is_some() + || input.peek(Token![|]) && !input.peek(Token![||]) && !input.peek(Token![|=]) + { + let mut cases = Punctuated::new(); + cases.push_value(pat); + while input.peek(Token![|]) && !input.peek(Token![||]) && !input.peek(Token![|=]) { + let punct = input.parse()?; + cases.push_punct(punct); + let pat = Pat::parse_single(input)?; + cases.push_value(pat); + } + pat = Pat::Or(PatOr { + attrs: Vec::new(), + leading_vert, + cases, + }); + } + Ok(pat) } fn pat_path_or_macro_or_struct_or_range(input: ParseStream) -> Result<Pat> { - let begin = input.fork(); let (qself, path) = path::parsing::qpath(input, true)?; - if qself.is_none() && input.peek(Token![!]) && !input.peek(Token![!=]) { - let mut contains_arguments = false; - for segment in &path.segments { - match segment.arguments { - PathArguments::None => {} - PathArguments::AngleBracketed(_) | PathArguments::Parenthesized(_) => { - contains_arguments = true; - } - } - } - - if !contains_arguments { - let bang_token: Token![!] = input.parse()?; - let (delimiter, tokens) = mac::parse_delimiter(input)?; - return Ok(Pat::Macro(PatMacro { - attrs: Vec::new(), - mac: Macro { - path, - bang_token, - delimiter, - tokens, - }, - })); - } + if qself.is_none() + && input.peek(Token![!]) + && !input.peek(Token![!=]) + && path.is_mod_style() + { + let bang_token: Token![!] = input.parse()?; + let (delimiter, tokens) = mac::parse_delimiter(input)?; + return Ok(Pat::Macro(ExprMacro { + attrs: Vec::new(), + mac: Macro { + path, + bang_token, + delimiter, + tokens, + }, + })); } if input.peek(token::Brace) { - let pat = pat_struct(begin.fork(), input, path)?; - if qself.is_some() { - Ok(Pat::Verbatim(verbatim::between(begin, input))) - } else { - Ok(pat) - } + pat_struct(input, qself, path).map(Pat::Struct) } else if input.peek(token::Paren) { - let pat = pat_tuple_struct(input, path)?; - if qself.is_some() { - Ok(Pat::Verbatim(verbatim::between(begin, input))) - } else { - Ok(Pat::TupleStruct(pat)) - } + pat_tuple_struct(input, qself, path).map(Pat::TupleStruct) } else if input.peek(Token![..]) { - pat_range(input, begin, qself, path) + pat_range(input, qself, path) } else { - Ok(Pat::Path(PatPath { + Ok(Pat::Path(ExprPath { attrs: Vec::new(), qself, path, @@ -431,12 +419,10 @@ pub mod parsing { }) } - fn pat_box(input: ParseStream) -> Result<PatBox> { - Ok(PatBox { - attrs: Vec::new(), - box_token: input.parse()?, - pat: input.parse()?, - }) + fn pat_box(begin: ParseBuffer, input: ParseStream) -> Result<Pat> { + input.parse::<Token![box]>()?; + Pat::parse_single(input)?; + Ok(Pat::Verbatim(verbatim::between(begin, input))) } fn pat_ident(input: ParseStream) -> Result<PatIdent> { @@ -448,7 +434,7 @@ pub mod parsing { subpat: { if input.peek(Token![@]) { let at_token: Token![@] = input.parse()?; - let subpat: Pat = input.parse()?; + let subpat = Pat::parse_single(input)?; Some((at_token, Box::new(subpat))) } else { None @@ -457,27 +443,47 @@ pub mod parsing { }) } - fn pat_tuple_struct(input: ParseStream, path: Path) -> Result<PatTupleStruct> { + fn pat_tuple_struct( + input: ParseStream, + qself: Option<QSelf>, + path: Path, + ) -> Result<PatTupleStruct> { + let content; + let paren_token = parenthesized!(content in input); + + let mut elems = Punctuated::new(); + while !content.is_empty() { + let value = Pat::parse_multi_with_leading_vert(&content)?; + elems.push_value(value); + if content.is_empty() { + break; + } + let punct = content.parse()?; + elems.push_punct(punct); + } + Ok(PatTupleStruct { attrs: Vec::new(), + qself, path, - pat: input.call(pat_tuple)?, + paren_token, + elems, }) } - fn pat_struct(begin: ParseBuffer, input: ParseStream, path: Path) -> Result<Pat> { + fn pat_struct(input: ParseStream, qself: Option<QSelf>, path: Path) -> Result<PatStruct> { let content; let brace_token = braced!(content in input); let mut fields = Punctuated::new(); - let mut dot2_token = None; + let mut rest = None; while !content.is_empty() { let attrs = content.call(Attribute::parse_outer)?; if content.peek(Token![..]) { - dot2_token = Some(content.parse()?); - if !attrs.is_empty() { - return Ok(Pat::Verbatim(verbatim::between(begin, input))); - } + rest = Some(PatRest { + attrs, + dot2_token: content.parse()?, + }); break; } let mut value = content.call(field_pat)?; @@ -490,18 +496,19 @@ pub mod parsing { fields.push_punct(punct); } - Ok(Pat::Struct(PatStruct { + Ok(PatStruct { attrs: Vec::new(), + qself, path, brace_token, fields, - dot2_token, - })) + rest, + }) } impl Member { fn is_unnamed(&self) -> bool { - match *self { + match self { Member::Named(_) => false, Member::Unnamed(_) => true, } @@ -509,10 +516,16 @@ pub mod parsing { } fn field_pat(input: ParseStream) -> Result<FieldPat> { + let begin = input.fork(); let boxed: Option<Token![box]> = input.parse()?; let by_ref: Option<Token![ref]> = input.parse()?; let mutability: Option<Token![mut]> = input.parse()?; - let member: Member = input.parse()?; + + let member = if boxed.is_some() || by_ref.is_some() || mutability.is_some() { + input.parse().map(Member::Named) + } else { + input.parse() + }?; if boxed.is_none() && by_ref.is_none() && mutability.is_none() && input.peek(Token![:]) || member.is_unnamed() @@ -520,8 +533,8 @@ pub mod parsing { return Ok(FieldPat { attrs: Vec::new(), member, - colon_token: input.parse()?, - pat: Box::new(multi_pat_with_leading_vert(input)?), + colon_token: Some(input.parse()?), + pat: Box::new(Pat::parse_multi_with_leading_vert(input)?), }); } @@ -538,12 +551,8 @@ pub mod parsing { subpat: None, }); - if let Some(boxed) = boxed { - pat = Pat::Box(PatBox { - attrs: Vec::new(), - box_token: boxed, - pat: Box::new(pat), - }); + if boxed.is_some() { + pat = Pat::Verbatim(verbatim::between(begin, input)); } Ok(FieldPat { @@ -554,35 +563,34 @@ pub mod parsing { }) } - fn pat_range( - input: ParseStream, - begin: ParseBuffer, - qself: Option<QSelf>, - path: Path, - ) -> Result<Pat> { - let limits: RangeLimits = input.parse()?; - let hi = input.call(pat_lit_expr)?; - if let Some(hi) = hi { - Ok(Pat::Range(PatRange { - attrs: Vec::new(), - lo: Box::new(Expr::Path(ExprPath { - attrs: Vec::new(), - qself, - path, - })), - limits, - hi, - })) - } else { - Ok(Pat::Verbatim(verbatim::between(begin, input))) + fn pat_range(input: ParseStream, qself: Option<QSelf>, path: Path) -> Result<Pat> { + let limits = RangeLimits::parse_obsolete(input)?; + let end = input.call(pat_range_bound)?; + if let (RangeLimits::Closed(_), None) = (&limits, &end) { + return Err(input.error("expected range upper bound")); } + Ok(Pat::Range(ExprRange { + attrs: Vec::new(), + start: Some(Box::new(Expr::Path(ExprPath { + attrs: Vec::new(), + qself, + path, + }))), + limits, + end: end.map(PatRangeBound::into_expr), + })) } - fn pat_range_half_open(input: ParseStream, begin: ParseBuffer) -> Result<Pat> { + fn pat_range_half_open(input: ParseStream) -> Result<Pat> { let limits: RangeLimits = input.parse()?; - let hi = input.call(pat_lit_expr)?; - if hi.is_some() { - Ok(Pat::Verbatim(verbatim::between(begin, input))) + let end = input.call(pat_range_bound)?; + if end.is_some() { + Ok(Pat::Range(ExprRange { + attrs: Vec::new(), + start: None, + limits, + end: end.map(PatRangeBound::into_expr), + })) } else { match limits { RangeLimits::HalfOpen(dot2_token) => Ok(Pat::Rest(PatRest { @@ -594,26 +602,34 @@ pub mod parsing { } } - fn pat_tuple(input: ParseStream) -> Result<PatTuple> { + fn pat_paren_or_tuple(input: ParseStream) -> Result<Pat> { let content; let paren_token = parenthesized!(content in input); let mut elems = Punctuated::new(); while !content.is_empty() { - let value = multi_pat_with_leading_vert(&content)?; - elems.push_value(value); + let value = Pat::parse_multi_with_leading_vert(&content)?; if content.is_empty() { + if elems.is_empty() && !matches!(value, Pat::Rest(_)) { + return Ok(Pat::Paren(PatParen { + attrs: Vec::new(), + paren_token, + pat: Box::new(value), + })); + } + elems.push_value(value); break; } + elems.push_value(value); let punct = content.parse()?; elems.push_punct(punct); } - Ok(PatTuple { + Ok(Pat::Tuple(PatTuple { attrs: Vec::new(), paren_token, elems, - }) + })) } fn pat_reference(input: ParseStream) -> Result<PatReference> { @@ -621,52 +637,69 @@ pub mod parsing { attrs: Vec::new(), and_token: input.parse()?, mutability: input.parse()?, - pat: input.parse()?, + pat: Box::new(Pat::parse_single(input)?), }) } fn pat_lit_or_range(input: ParseStream) -> Result<Pat> { - let begin = input.fork(); - let lo = input.call(pat_lit_expr)?.unwrap(); + let start = input.call(pat_range_bound)?.unwrap(); if input.peek(Token![..]) { - let limits: RangeLimits = input.parse()?; - let hi = input.call(pat_lit_expr)?; - if let Some(hi) = hi { - Ok(Pat::Range(PatRange { - attrs: Vec::new(), - lo, - limits, - hi, - })) - } else { - Ok(Pat::Verbatim(verbatim::between(begin, input))) + let limits = RangeLimits::parse_obsolete(input)?; + let end = input.call(pat_range_bound)?; + if let (RangeLimits::Closed(_), None) = (&limits, &end) { + return Err(input.error("expected range upper bound")); } - } else if let Expr::Verbatim(verbatim) = *lo { - Ok(Pat::Verbatim(verbatim)) - } else { - Ok(Pat::Lit(PatLit { + Ok(Pat::Range(ExprRange { attrs: Vec::new(), - expr: lo, + start: Some(start.into_expr()), + limits, + end: end.map(PatRangeBound::into_expr), })) + } else { + Ok(start.into_pat()) } } - fn pat_lit_expr(input: ParseStream) -> Result<Option<Box<Expr>>> { + // Patterns that can appear on either side of a range pattern. + enum PatRangeBound { + Const(ExprConst), + Lit(ExprLit), + Path(ExprPath), + } + + impl PatRangeBound { + fn into_expr(self) -> Box<Expr> { + Box::new(match self { + PatRangeBound::Const(pat) => Expr::Const(pat), + PatRangeBound::Lit(pat) => Expr::Lit(pat), + PatRangeBound::Path(pat) => Expr::Path(pat), + }) + } + + fn into_pat(self) -> Pat { + match self { + PatRangeBound::Const(pat) => Pat::Const(pat), + PatRangeBound::Lit(pat) => Pat::Lit(pat), + PatRangeBound::Path(pat) => Pat::Path(pat), + } + } + } + + fn pat_range_bound(input: ParseStream) -> Result<Option<PatRangeBound>> { if input.is_empty() || input.peek(Token![|]) || input.peek(Token![=]) || input.peek(Token![:]) && !input.peek(Token![::]) || input.peek(Token![,]) || input.peek(Token![;]) + || input.peek(Token![if]) { return Ok(None); } - let neg: Option<Token![-]> = input.parse()?; - let lookahead = input.lookahead1(); let expr = if lookahead.peek(Lit) { - Expr::Lit(input.parse()?) + PatRangeBound::Lit(input.parse()?) } else if lookahead.peek(Ident) || lookahead.peek(Token![::]) || lookahead.peek(Token![<]) @@ -675,22 +708,14 @@ pub mod parsing { || lookahead.peek(Token![super]) || lookahead.peek(Token![crate]) { - Expr::Path(input.parse()?) + PatRangeBound::Path(input.parse()?) } else if lookahead.peek(Token![const]) { - Expr::Verbatim(input.call(expr::parsing::expr_const)?) + PatRangeBound::Const(input.parse()?) } else { return Err(lookahead.error()); }; - Ok(Some(Box::new(if let Some(neg) = neg { - Expr::Unary(ExprUnary { - attrs: Vec::new(), - op: UnOp::Neg(neg), - expr: Box::new(expr), - }) - } else { - expr - }))) + Ok(Some(expr)) } fn pat_slice(input: ParseStream) -> Result<PatSlice> { @@ -699,7 +724,20 @@ pub mod parsing { let mut elems = Punctuated::new(); while !content.is_empty() { - let value = multi_pat_with_leading_vert(&content)?; + let value = Pat::parse_multi_with_leading_vert(&content)?; + match value { + Pat::Range(pat) if pat.start.is_none() || pat.end.is_none() => { + let (start, end) = match pat.limits { + RangeLimits::HalfOpen(dot_dot) => (dot_dot.spans[0], dot_dot.spans[1]), + RangeLimits::Closed(dot_dot_eq) => { + (dot_dot_eq.spans[0], dot_dot_eq.spans[2]) + } + }; + let msg = "range pattern is not allowed unparenthesized inside slice pattern"; + return Err(error::new2(start, end, msg)); + } + _ => {} + } elems.push_value(value); if content.is_empty() { break; @@ -726,37 +764,6 @@ pub mod parsing { Ok(verbatim::between(begin, input)) } - - pub fn multi_pat(input: ParseStream) -> Result<Pat> { - multi_pat_impl(input, None) - } - - pub fn multi_pat_with_leading_vert(input: ParseStream) -> Result<Pat> { - let leading_vert: Option<Token![|]> = input.parse()?; - multi_pat_impl(input, leading_vert) - } - - fn multi_pat_impl(input: ParseStream, leading_vert: Option<Token![|]>) -> Result<Pat> { - let mut pat: Pat = input.parse()?; - if leading_vert.is_some() - || input.peek(Token![|]) && !input.peek(Token![||]) && !input.peek(Token![|=]) - { - let mut cases = Punctuated::new(); - cases.push_value(pat); - while input.peek(Token![|]) && !input.peek(Token![||]) && !input.peek(Token![|=]) { - let punct = input.parse()?; - cases.push_punct(punct); - let pat: Pat = input.parse()?; - cases.push_value(pat); - } - pat = Pat::Or(PatOr { - attrs: Vec::new(), - leading_vert, - cases, - }); - } - Ok(pat) - } } #[cfg(feature = "printing")] @@ -767,14 +774,6 @@ mod printing { use quote::{ToTokens, TokenStreamExt}; #[cfg_attr(doc_cfg, doc(cfg(feature = "printing")))] - impl ToTokens for PatWild { - fn to_tokens(&self, tokens: &mut TokenStream) { - tokens.append_all(self.attrs.outer()); - self.underscore_token.to_tokens(tokens); - } - } - - #[cfg_attr(doc_cfg, doc(cfg(feature = "printing")))] impl ToTokens for PatIdent { fn to_tokens(&self, tokens: &mut TokenStream) { tokens.append_all(self.attrs.outer()); @@ -789,127 +788,104 @@ mod printing { } #[cfg_attr(doc_cfg, doc(cfg(feature = "printing")))] - impl ToTokens for PatStruct { - fn to_tokens(&self, tokens: &mut TokenStream) { - tokens.append_all(self.attrs.outer()); - self.path.to_tokens(tokens); - self.brace_token.surround(tokens, |tokens| { - self.fields.to_tokens(tokens); - // NOTE: We need a comma before the dot2 token if it is present. - if !self.fields.empty_or_trailing() && self.dot2_token.is_some() { - <Token![,]>::default().to_tokens(tokens); - } - self.dot2_token.to_tokens(tokens); - }); - } - } - - #[cfg_attr(doc_cfg, doc(cfg(feature = "printing")))] - impl ToTokens for PatTupleStruct { - fn to_tokens(&self, tokens: &mut TokenStream) { - tokens.append_all(self.attrs.outer()); - self.path.to_tokens(tokens); - self.pat.to_tokens(tokens); - } - } - - #[cfg_attr(doc_cfg, doc(cfg(feature = "printing")))] - impl ToTokens for PatType { - fn to_tokens(&self, tokens: &mut TokenStream) { - tokens.append_all(self.attrs.outer()); - self.pat.to_tokens(tokens); - self.colon_token.to_tokens(tokens); - self.ty.to_tokens(tokens); - } - } - - #[cfg_attr(doc_cfg, doc(cfg(feature = "printing")))] - impl ToTokens for PatPath { + impl ToTokens for PatOr { fn to_tokens(&self, tokens: &mut TokenStream) { tokens.append_all(self.attrs.outer()); - path::printing::print_path(tokens, &self.qself, &self.path); + self.leading_vert.to_tokens(tokens); + self.cases.to_tokens(tokens); } } #[cfg_attr(doc_cfg, doc(cfg(feature = "printing")))] - impl ToTokens for PatTuple { + impl ToTokens for PatParen { fn to_tokens(&self, tokens: &mut TokenStream) { tokens.append_all(self.attrs.outer()); self.paren_token.surround(tokens, |tokens| { - self.elems.to_tokens(tokens); + self.pat.to_tokens(tokens); }); } } #[cfg_attr(doc_cfg, doc(cfg(feature = "printing")))] - impl ToTokens for PatBox { + impl ToTokens for PatReference { fn to_tokens(&self, tokens: &mut TokenStream) { tokens.append_all(self.attrs.outer()); - self.box_token.to_tokens(tokens); + self.and_token.to_tokens(tokens); + self.mutability.to_tokens(tokens); self.pat.to_tokens(tokens); } } #[cfg_attr(doc_cfg, doc(cfg(feature = "printing")))] - impl ToTokens for PatReference { + impl ToTokens for PatRest { fn to_tokens(&self, tokens: &mut TokenStream) { tokens.append_all(self.attrs.outer()); - self.and_token.to_tokens(tokens); - self.mutability.to_tokens(tokens); - self.pat.to_tokens(tokens); + self.dot2_token.to_tokens(tokens); } } #[cfg_attr(doc_cfg, doc(cfg(feature = "printing")))] - impl ToTokens for PatRest { + impl ToTokens for PatSlice { fn to_tokens(&self, tokens: &mut TokenStream) { tokens.append_all(self.attrs.outer()); - self.dot2_token.to_tokens(tokens); + self.bracket_token.surround(tokens, |tokens| { + self.elems.to_tokens(tokens); + }); } } #[cfg_attr(doc_cfg, doc(cfg(feature = "printing")))] - impl ToTokens for PatLit { + impl ToTokens for PatStruct { fn to_tokens(&self, tokens: &mut TokenStream) { tokens.append_all(self.attrs.outer()); - self.expr.to_tokens(tokens); + path::printing::print_path(tokens, &self.qself, &self.path); + self.brace_token.surround(tokens, |tokens| { + self.fields.to_tokens(tokens); + // NOTE: We need a comma before the dot2 token if it is present. + if !self.fields.empty_or_trailing() && self.rest.is_some() { + <Token![,]>::default().to_tokens(tokens); + } + self.rest.to_tokens(tokens); + }); } } #[cfg_attr(doc_cfg, doc(cfg(feature = "printing")))] - impl ToTokens for PatRange { + impl ToTokens for PatTuple { fn to_tokens(&self, tokens: &mut TokenStream) { tokens.append_all(self.attrs.outer()); - self.lo.to_tokens(tokens); - self.limits.to_tokens(tokens); - self.hi.to_tokens(tokens); + self.paren_token.surround(tokens, |tokens| { + self.elems.to_tokens(tokens); + }); } } #[cfg_attr(doc_cfg, doc(cfg(feature = "printing")))] - impl ToTokens for PatSlice { + impl ToTokens for PatTupleStruct { fn to_tokens(&self, tokens: &mut TokenStream) { tokens.append_all(self.attrs.outer()); - self.bracket_token.surround(tokens, |tokens| { + path::printing::print_path(tokens, &self.qself, &self.path); + self.paren_token.surround(tokens, |tokens| { self.elems.to_tokens(tokens); }); } } #[cfg_attr(doc_cfg, doc(cfg(feature = "printing")))] - impl ToTokens for PatMacro { + impl ToTokens for PatType { fn to_tokens(&self, tokens: &mut TokenStream) { tokens.append_all(self.attrs.outer()); - self.mac.to_tokens(tokens); + self.pat.to_tokens(tokens); + self.colon_token.to_tokens(tokens); + self.ty.to_tokens(tokens); } } #[cfg_attr(doc_cfg, doc(cfg(feature = "printing")))] - impl ToTokens for PatOr { + impl ToTokens for PatWild { fn to_tokens(&self, tokens: &mut TokenStream) { tokens.append_all(self.attrs.outer()); - self.leading_vert.to_tokens(tokens); - self.cases.to_tokens(tokens); + self.underscore_token.to_tokens(tokens); } } diff --git a/vendor/syn/src/path.rs b/vendor/syn/src/path.rs index 6cdb43ac5..e99a3f87d 100644 --- a/vendor/syn/src/path.rs +++ b/vendor/syn/src/path.rs @@ -3,9 +3,6 @@ use crate::punctuated::Punctuated; ast_struct! { /// A path at which a named item is exported (e.g. `std::collections::HashMap`). - /// - /// *This type is available only if Syn is built with the `"derive"` or `"full"` - /// feature.* #[cfg_attr(doc_cfg, doc(cfg(any(feature = "full", feature = "derive"))))] pub struct Path { pub leading_colon: Option<Token![::]>, @@ -27,11 +24,67 @@ where } } +impl Path { + /// Determines whether this is a path of length 1 equal to the given + /// ident. + /// + /// For them to compare equal, it must be the case that: + /// + /// - the path has no leading colon, + /// - the number of path segments is 1, + /// - the first path segment has no angle bracketed or parenthesized + /// path arguments, and + /// - the ident of the first path segment is equal to the given one. + /// + /// # Example + /// + /// ``` + /// use proc_macro2::TokenStream; + /// use syn::{Attribute, Error, Meta, Result}; + /// + /// fn get_serde_meta_item(attr: &Attribute) -> Result<Option<&TokenStream>> { + /// if attr.path().is_ident("serde") { + /// match &attr.meta { + /// Meta::List(meta) => Ok(Some(&meta.tokens)), + /// bad => Err(Error::new_spanned(bad, "unrecognized attribute")), + /// } + /// } else { + /// Ok(None) + /// } + /// } + /// ``` + pub fn is_ident<I: ?Sized>(&self, ident: &I) -> bool + where + Ident: PartialEq<I>, + { + match self.get_ident() { + Some(id) => id == ident, + None => false, + } + } + + /// If this path consists of a single ident, returns the ident. + /// + /// A path is considered an ident if: + /// + /// - the path has no leading colon, + /// - the number of path segments is 1, and + /// - the first path segment has no angle bracketed or parenthesized + /// path arguments. + pub fn get_ident(&self) -> Option<&Ident> { + if self.leading_colon.is_none() + && self.segments.len() == 1 + && self.segments[0].arguments.is_none() + { + Some(&self.segments[0].ident) + } else { + None + } + } +} + ast_struct! { /// A segment of a path together with any path arguments on that segment. - /// - /// *This type is available only if Syn is built with the `"derive"` or `"full"` - /// feature.* #[cfg_attr(doc_cfg, doc(cfg(any(feature = "full", feature = "derive"))))] pub struct PathSegment { pub ident: Ident, @@ -54,9 +107,6 @@ where ast_enum! { /// Angle bracketed or parenthesized arguments of a path segment. /// - /// *This type is available only if Syn is built with the `"derive"` or `"full"` - /// feature.* - /// /// ## Angle bracketed /// /// The `<'a, T>` in `std::slice::iter<'a, T>`. @@ -99,10 +149,8 @@ impl PathArguments { ast_enum! { /// An individual generic argument, like `'a`, `T`, or `Item = T`. - /// - /// *This type is available only if Syn is built with the `"derive"` or `"full"` - /// feature.* #[cfg_attr(doc_cfg, doc(cfg(any(feature = "full", feature = "derive"))))] + #[non_exhaustive] pub enum GenericArgument { /// A lifetime argument. Lifetime(Lifetime), @@ -115,7 +163,10 @@ ast_enum! { Const(Expr), /// A binding (equality constraint) on an associated type: the `Item = /// u8` in `Iterator<Item = u8>`. - Binding(Binding), + AssocType(AssocType), + /// An equality constraint on an associated constant: the `PANIC = + /// false` in `Trait<PANIC = false>`. + AssocConst(AssocConst), /// An associated type bound: `Iterator<Item: Display>`. Constraint(Constraint), } @@ -124,9 +175,6 @@ ast_enum! { ast_struct! { /// Angle bracketed arguments of a path segment: the `<K, V>` in `HashMap<K, /// V>`. - /// - /// *This type is available only if Syn is built with the `"derive"` or `"full"` - /// feature.* #[cfg_attr(doc_cfg, doc(cfg(any(feature = "full", feature = "derive"))))] pub struct AngleBracketedGenericArguments { pub colon2_token: Option<Token![::]>, @@ -137,26 +185,35 @@ ast_struct! { } ast_struct! { - /// A binding (equality constraint) on an associated type: `Item = u8`. - /// - /// *This type is available only if Syn is built with the `"derive"` or `"full"` - /// feature.* + /// A binding (equality constraint) on an associated type: the `Item = u8` + /// in `Iterator<Item = u8>`. #[cfg_attr(doc_cfg, doc(cfg(any(feature = "full", feature = "derive"))))] - pub struct Binding { + pub struct AssocType { pub ident: Ident, + pub generics: Option<AngleBracketedGenericArguments>, pub eq_token: Token![=], pub ty: Type, } } ast_struct! { + /// An equality constraint on an associated constant: the `PANIC = false` in + /// `Trait<PANIC = false>`. + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "full", feature = "derive"))))] + pub struct AssocConst { + pub ident: Ident, + pub generics: Option<AngleBracketedGenericArguments>, + pub eq_token: Token![=], + pub value: Expr, + } +} + +ast_struct! { /// An associated type bound: `Iterator<Item: Display>`. - /// - /// *This type is available only if Syn is built with the `"derive"` or `"full"` - /// feature.* #[cfg_attr(doc_cfg, doc(cfg(any(feature = "full", feature = "derive"))))] pub struct Constraint { pub ident: Ident, + pub generics: Option<AngleBracketedGenericArguments>, pub colon_token: Token![:], pub bounds: Punctuated<TypeParamBound, Token![+]>, } @@ -165,9 +222,6 @@ ast_struct! { ast_struct! { /// Arguments of a function path segment: the `(A, B) -> C` in `Fn(A,B) -> /// C`. - /// - /// *This type is available only if Syn is built with the `"derive"` or `"full"` - /// feature.* #[cfg_attr(doc_cfg, doc(cfg(any(feature = "full", feature = "derive"))))] pub struct ParenthesizedGenericArguments { pub paren_token: token::Paren, @@ -195,9 +249,6 @@ ast_struct! { /// ^~~~~~ ^ /// ty position = 0 /// ``` - /// - /// *This type is available only if Syn is built with the `"derive"` or `"full"` - /// feature.* #[cfg_attr(doc_cfg, doc(cfg(any(feature = "full", feature = "derive"))))] pub struct QSelf { pub lt_token: Token![<], @@ -209,7 +260,7 @@ ast_struct! { } #[cfg(feature = "parsing")] -pub mod parsing { +pub(crate) mod parsing { use super::*; use crate::ext::IdentExt; @@ -229,92 +280,87 @@ pub mod parsing { return Ok(GenericArgument::Lifetime(input.parse()?)); } - if input.peek(Ident) && input.peek2(Token![=]) { - let ident: Ident = input.parse()?; - let eq_token: Token![=] = input.parse()?; - - let ty = if input.peek(Lit) { - let begin = input.fork(); - input.parse::<Lit>()?; - Type::Verbatim(verbatim::between(begin, input)) - } else if input.peek(token::Brace) { - let begin = input.fork(); - - #[cfg(feature = "full")] - { - input.parse::<ExprBlock>()?; - } - - #[cfg(not(feature = "full"))] - { - let content; - braced!(content in input); - content.parse::<Expr>()?; - } - - Type::Verbatim(verbatim::between(begin, input)) - } else { - input.parse()? - }; - - return Ok(GenericArgument::Binding(Binding { - ident, - eq_token, - ty, - })); - } - - #[cfg(feature = "full")] - { - if input.peek(Ident) && input.peek2(Token![:]) && !input.peek2(Token![::]) { - return Ok(GenericArgument::Constraint(input.parse()?)); - } - } - if input.peek(Lit) || input.peek(token::Brace) { return const_argument(input).map(GenericArgument::Const); } - #[cfg(feature = "full")] - let begin = input.fork(); - - let argument: Type = input.parse()?; + let mut argument: Type = input.parse()?; + + match argument { + Type::Path(mut ty) + if ty.qself.is_none() + && ty.path.leading_colon.is_none() + && ty.path.segments.len() == 1 + && match &ty.path.segments[0].arguments { + PathArguments::None | PathArguments::AngleBracketed(_) => true, + PathArguments::Parenthesized(_) => false, + } => + { + if let Some(eq_token) = input.parse::<Option<Token![=]>>()? { + let segment = ty.path.segments.pop().unwrap().into_value(); + let ident = segment.ident; + let generics = match segment.arguments { + PathArguments::None => None, + PathArguments::AngleBracketed(arguments) => Some(arguments), + PathArguments::Parenthesized(_) => unreachable!(), + }; + return if input.peek(Lit) || input.peek(token::Brace) { + Ok(GenericArgument::AssocConst(AssocConst { + ident, + generics, + eq_token, + value: const_argument(input)?, + })) + } else { + Ok(GenericArgument::AssocType(AssocType { + ident, + generics, + eq_token, + ty: input.parse()?, + })) + }; + } - #[cfg(feature = "full")] - { - if match &argument { - Type::Path(argument) - if argument.qself.is_none() - && argument.path.leading_colon.is_none() - && argument.path.segments.len() == 1 => - { - match argument.path.segments[0].arguments { - PathArguments::AngleBracketed(_) => true, - _ => false, - } + #[cfg(feature = "full")] + if let Some(colon_token) = input.parse::<Option<Token![:]>>()? { + let segment = ty.path.segments.pop().unwrap().into_value(); + return Ok(GenericArgument::Constraint(Constraint { + ident: segment.ident, + generics: match segment.arguments { + PathArguments::None => None, + PathArguments::AngleBracketed(arguments) => Some(arguments), + PathArguments::Parenthesized(_) => unreachable!(), + }, + colon_token, + bounds: { + let mut bounds = Punctuated::new(); + loop { + if input.peek(Token![,]) || input.peek(Token![>]) { + break; + } + let value: TypeParamBound = input.parse()?; + bounds.push_value(value); + if !input.peek(Token![+]) { + break; + } + let punct: Token![+] = input.parse()?; + bounds.push_punct(punct); + } + bounds + }, + })); } - _ => false, - } && if input.peek(Token![=]) { - input.parse::<Token![=]>()?; - input.parse::<Type>()?; - true - } else if input.peek(Token![:]) { - input.parse::<Token![:]>()?; - input.call(constraint_bounds)?; - true - } else { - false - } { - let verbatim = verbatim::between(begin, input); - return Ok(GenericArgument::Type(Type::Verbatim(verbatim))); + + argument = Type::Path(ty); } + _ => {} } Ok(GenericArgument::Type(argument)) } } - pub fn const_argument(input: ParseStream) -> Result<Expr> { + pub(crate) fn const_argument(input: ParseStream) -> Result<Expr> { let lookahead = input.lookahead1(); if input.peek(Lit) { @@ -323,15 +369,13 @@ pub mod parsing { } #[cfg(feature = "full")] - { - if input.peek(Ident) { - let ident: Ident = input.parse()?; - return Ok(Expr::Path(ExprPath { - attrs: Vec::new(), - qself: None, - path: Path::from(ident), - })); - } + if input.peek(Ident) { + let ident: Ident = input.parse()?; + return Ok(Expr::Path(ExprPath { + attrs: Vec::new(), + qself: None, + path: Path::from(ident), + })); } if input.peek(token::Brace) { @@ -355,11 +399,21 @@ pub mod parsing { Err(lookahead.error()) } - #[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))] - impl Parse for AngleBracketedGenericArguments { - fn parse(input: ParseStream) -> Result<Self> { + impl AngleBracketedGenericArguments { + /// Parse `::<…>` with mandatory leading `::`. + /// + /// The ordinary [`Parse`] impl for `AngleBracketedGenericArguments` + /// parses optional leading `::`. + #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(all(feature = "parsing", feature = "full"))))] + pub fn parse_turbofish(input: ParseStream) -> Result<Self> { + let colon2_token: Token![::] = input.parse()?; + Self::do_parse(Some(colon2_token), input) + } + + fn do_parse(colon2_token: Option<Token![::]>, input: ParseStream) -> Result<Self> { Ok(AngleBracketedGenericArguments { - colon2_token: input.parse()?, + colon2_token, lt_token: input.parse()?, args: { let mut args = Punctuated::new(); @@ -367,12 +421,12 @@ pub mod parsing { if input.peek(Token![>]) { break; } - let value = input.parse()?; + let value: GenericArgument = input.parse()?; args.push_value(value); if input.peek(Token![>]) { break; } - let punct = input.parse()?; + let punct: Token![,] = input.parse()?; args.push_punct(punct); } args @@ -383,12 +437,20 @@ pub mod parsing { } #[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))] + impl Parse for AngleBracketedGenericArguments { + fn parse(input: ParseStream) -> Result<Self> { + let colon2_token: Option<Token![::]> = input.parse()?; + Self::do_parse(colon2_token, input) + } + } + + #[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))] impl Parse for ParenthesizedGenericArguments { fn parse(input: ParseStream) -> Result<Self> { let content; Ok(ParenthesizedGenericArguments { paren_token: parenthesized!(content in input), - inputs: content.parse_terminated(Type::parse)?, + inputs: content.parse_terminated(Type::parse, Token![,])?, output: input.call(ReturnType::without_plus)?, }) } @@ -403,7 +465,11 @@ pub mod parsing { impl PathSegment { fn parse_helper(input: ParseStream, expr_style: bool) -> Result<Self> { - if input.peek(Token![super]) || input.peek(Token![self]) || input.peek(Token![crate]) { + if input.peek(Token![super]) + || input.peek(Token![self]) + || input.peek(Token![crate]) + || cfg!(feature = "full") && input.peek(Token![try]) + { let ident = input.call(Ident::parse_any)?; return Ok(PathSegment::from(ident)); } @@ -427,53 +493,9 @@ pub mod parsing { } } - #[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))] - impl Parse for Binding { - fn parse(input: ParseStream) -> Result<Self> { - Ok(Binding { - ident: input.parse()?, - eq_token: input.parse()?, - ty: input.parse()?, - }) - } - } - - #[cfg(feature = "full")] - #[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))] - impl Parse for Constraint { - fn parse(input: ParseStream) -> Result<Self> { - Ok(Constraint { - ident: input.parse()?, - colon_token: input.parse()?, - bounds: constraint_bounds(input)?, - }) - } - } - - #[cfg(feature = "full")] - fn constraint_bounds(input: ParseStream) -> Result<Punctuated<TypeParamBound, Token![+]>> { - let mut bounds = Punctuated::new(); - loop { - if input.peek(Token![,]) || input.peek(Token![>]) { - break; - } - let value = input.parse()?; - bounds.push_value(value); - if !input.peek(Token![+]) { - break; - } - let punct = input.parse()?; - bounds.push_punct(punct); - } - Ok(bounds) - } - impl Path { /// Parse a `Path` containing no path arguments on any of its segments. /// - /// *This function is available only if Syn is built with the `"parsing"` - /// feature.* - /// /// # Example /// /// ``` @@ -526,80 +548,15 @@ pub mod parsing { segments.push_punct(punct); } if segments.is_empty() { - return Err(input.error("expected path")); + return Err(input.parse::<Ident>().unwrap_err()); } else if segments.trailing_punct() { - return Err(input.error("expected path segment")); + return Err(input.error("expected path segment after `::`")); } segments }, }) } - /// Determines whether this is a path of length 1 equal to the given - /// ident. - /// - /// For them to compare equal, it must be the case that: - /// - /// - the path has no leading colon, - /// - the number of path segments is 1, - /// - the first path segment has no angle bracketed or parenthesized - /// path arguments, and - /// - the ident of the first path segment is equal to the given one. - /// - /// *This function is available only if Syn is built with the `"parsing"` - /// feature.* - /// - /// # Example - /// - /// ``` - /// use syn::{Attribute, Error, Meta, NestedMeta, Result}; - /// # use std::iter::FromIterator; - /// - /// fn get_serde_meta_items(attr: &Attribute) -> Result<Vec<NestedMeta>> { - /// if attr.path.is_ident("serde") { - /// match attr.parse_meta()? { - /// Meta::List(meta) => Ok(Vec::from_iter(meta.nested)), - /// bad => Err(Error::new_spanned(bad, "unrecognized attribute")), - /// } - /// } else { - /// Ok(Vec::new()) - /// } - /// } - /// ``` - #[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))] - pub fn is_ident<I: ?Sized>(&self, ident: &I) -> bool - where - Ident: PartialEq<I>, - { - match self.get_ident() { - Some(id) => id == ident, - None => false, - } - } - - /// If this path consists of a single ident, returns the ident. - /// - /// A path is considered an ident if: - /// - /// - the path has no leading colon, - /// - the number of path segments is 1, and - /// - the first path segment has no angle bracketed or parenthesized - /// path arguments. - /// - /// *This function is available only if Syn is built with the `"parsing"` - /// feature.* - #[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))] - pub fn get_ident(&self) -> Option<&Ident> { - if self.leading_colon.is_none() - && self.segments.len() == 1 - && self.segments[0].arguments.is_none() - { - Some(&self.segments[0].ident) - } else { - None - } - } - pub(crate) fn parse_helper(input: ParseStream, expr_style: bool) -> Result<Self> { let mut path = Path { leading_colon: input.parse()?, @@ -627,9 +584,15 @@ pub mod parsing { } Ok(()) } + + pub(crate) fn is_mod_style(&self) -> bool { + self.segments + .iter() + .all(|segment| segment.arguments.is_none()) + } } - pub fn qpath(input: ParseStream, expr_style: bool) -> Result<(Option<QSelf>, Path)> { + pub(crate) fn qpath(input: ParseStream, expr_style: bool) -> Result<(Option<QSelf>, Path)> { if input.peek(Token![<]) { let lt_token: Token![<] = input.parse()?; let this: Type = input.parse()?; @@ -728,23 +691,21 @@ pub(crate) mod printing { match self { GenericArgument::Lifetime(lt) => lt.to_tokens(tokens), GenericArgument::Type(ty) => ty.to_tokens(tokens), - GenericArgument::Const(e) => match *e { - Expr::Lit(_) => e.to_tokens(tokens), + GenericArgument::Const(expr) => match expr { + Expr::Lit(_) => expr.to_tokens(tokens), - // NOTE: We should probably support parsing blocks with only - // expressions in them without the full feature for const - // generics. #[cfg(feature = "full")] - Expr::Block(_) => e.to_tokens(tokens), + Expr::Block(_) => expr.to_tokens(tokens), // ERROR CORRECTION: Add braces to make sure that the // generated code is valid. _ => token::Brace::default().surround(tokens, |tokens| { - e.to_tokens(tokens); + expr.to_tokens(tokens); }), }, - GenericArgument::Binding(tb) => tb.to_tokens(tokens), - GenericArgument::Constraint(tc) => tc.to_tokens(tokens), + GenericArgument::AssocType(assoc) => assoc.to_tokens(tokens), + GenericArgument::AssocConst(assoc) => assoc.to_tokens(tokens), + GenericArgument::Constraint(constraint) => constraint.to_tokens(tokens), } } } @@ -759,22 +720,24 @@ pub(crate) mod printing { // order in self.args. let mut trailing_or_empty = true; for param in self.args.pairs() { - match **param.value() { + match param.value() { GenericArgument::Lifetime(_) => { param.to_tokens(tokens); trailing_or_empty = param.punct().is_some(); } GenericArgument::Type(_) | GenericArgument::Const(_) - | GenericArgument::Binding(_) + | GenericArgument::AssocType(_) + | GenericArgument::AssocConst(_) | GenericArgument::Constraint(_) => {} } } for param in self.args.pairs() { - match **param.value() { + match param.value() { GenericArgument::Type(_) | GenericArgument::Const(_) - | GenericArgument::Binding(_) + | GenericArgument::AssocType(_) + | GenericArgument::AssocConst(_) | GenericArgument::Constraint(_) => { if !trailing_or_empty { <Token![,]>::default().to_tokens(tokens); @@ -791,18 +754,30 @@ pub(crate) mod printing { } #[cfg_attr(doc_cfg, doc(cfg(feature = "printing")))] - impl ToTokens for Binding { + impl ToTokens for AssocType { fn to_tokens(&self, tokens: &mut TokenStream) { self.ident.to_tokens(tokens); + self.generics.to_tokens(tokens); self.eq_token.to_tokens(tokens); self.ty.to_tokens(tokens); } } #[cfg_attr(doc_cfg, doc(cfg(feature = "printing")))] + impl ToTokens for AssocConst { + fn to_tokens(&self, tokens: &mut TokenStream) { + self.ident.to_tokens(tokens); + self.generics.to_tokens(tokens); + self.eq_token.to_tokens(tokens); + self.value.to_tokens(tokens); + } + } + + #[cfg_attr(doc_cfg, doc(cfg(feature = "printing")))] impl ToTokens for Constraint { fn to_tokens(&self, tokens: &mut TokenStream) { self.ident.to_tokens(tokens); + self.generics.to_tokens(tokens); self.colon_token.to_tokens(tokens); self.bounds.to_tokens(tokens); } diff --git a/vendor/syn/src/print.rs b/vendor/syn/src/print.rs index da4e07e3b..074099326 100644 --- a/vendor/syn/src/print.rs +++ b/vendor/syn/src/print.rs @@ -1,7 +1,7 @@ use proc_macro2::TokenStream; use quote::ToTokens; -pub struct TokensOrDefault<'a, T: 'a>(pub &'a Option<T>); +pub(crate) struct TokensOrDefault<'a, T: 'a>(pub &'a Option<T>); impl<'a, T> ToTokens for TokensOrDefault<'a, T> where diff --git a/vendor/syn/src/punctuated.rs b/vendor/syn/src/punctuated.rs index b7d0185e8..7880eb29c 100644 --- a/vendor/syn/src/punctuated.rs +++ b/vendor/syn/src/punctuated.rs @@ -26,7 +26,6 @@ use std::fmt::{self, Debug}; use std::hash::{Hash, Hasher}; #[cfg(any(feature = "full", feature = "derive"))] use std::iter; -use std::iter::FromIterator; use std::ops::{Index, IndexMut}; use std::option; use std::slice; @@ -38,8 +37,8 @@ use crate::parse::{Parse, ParseStream, Result}; #[cfg(feature = "parsing")] use crate::token::Token; -/// A punctuated sequence of syntax tree nodes of type `T` separated by -/// punctuation of type `P`. +/// **A punctuated sequence of syntax tree nodes of type `T` separated by +/// punctuation of type `P`.** /// /// Refer to the [module documentation] for details about punctuated sequences. /// @@ -51,7 +50,6 @@ pub struct Punctuated<T, P> { impl<T, P> Punctuated<T, P> { /// Creates an empty punctuated sequence. - #[cfg(not(syn_no_const_vec_new))] pub const fn new() -> Self { Punctuated { inner: Vec::new(), @@ -59,15 +57,6 @@ impl<T, P> Punctuated<T, P> { } } - /// Creates an empty punctuated sequence. - #[cfg(syn_no_const_vec_new)] - pub fn new() -> Self { - Punctuated { - inner: Vec::new(), - last: None, - } - } - /// Determines whether this punctuated sequence is empty, meaning it /// contains no syntax tree nodes or punctuation. pub fn is_empty(&self) -> bool { @@ -151,7 +140,7 @@ impl<T, P> Punctuated<T, P> { } /// Appends a syntax tree node onto the end of this punctuated sequence. The - /// sequence must previously have a trailing punctuation. + /// sequence must already have a trailing punctuation, or be empty. /// /// Use [`push`] instead if the punctuated sequence may or may not already /// have trailing punctuation. @@ -160,8 +149,8 @@ impl<T, P> Punctuated<T, P> { /// /// # Panics /// - /// Panics if the sequence does not already have a trailing punctuation when - /// this method is called. + /// Panics if the sequence is nonempty and does not already have a trailing + /// punctuation. pub fn push_value(&mut self, value: T) { assert!( self.empty_or_trailing(), @@ -260,9 +249,6 @@ impl<T, P> Punctuated<T, P> { /// /// Parsing continues until the end of this parse stream. The entire content /// of this parse stream must consist of `T` and `P`. - /// - /// *This function is available only if Syn is built with the `"parsing"` - /// feature.* #[cfg(feature = "parsing")] #[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))] pub fn parse_terminated(input: ParseStream) -> Result<Self> @@ -281,9 +267,6 @@ impl<T, P> Punctuated<T, P> { /// to be parsed. /// /// [`parse_terminated`]: Punctuated::parse_terminated - /// - /// *This function is available only if Syn is built with the `"parsing"` - /// feature.* #[cfg(feature = "parsing")] #[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))] pub fn parse_terminated_with( @@ -318,9 +301,6 @@ impl<T, P> Punctuated<T, P> { /// the stream. This method returns upon parsing a `T` and observing that it /// is not followed by a `P`, even if there are remaining tokens in the /// stream. - /// - /// *This function is available only if Syn is built with the `"parsing"` - /// feature.* #[cfg(feature = "parsing")] #[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))] pub fn parse_separated_nonempty(input: ParseStream) -> Result<Self> @@ -339,9 +319,6 @@ impl<T, P> Punctuated<T, P> { /// the entire content of this stream. /// /// [`parse_separated_nonempty`]: Punctuated::parse_separated_nonempty - /// - /// *This function is available only if Syn is built with the `"parsing"` - /// feature.* #[cfg(feature = "parsing")] #[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))] pub fn parse_separated_nonempty_with( @@ -459,29 +436,37 @@ where impl<T, P> FromIterator<Pair<T, P>> for Punctuated<T, P> { fn from_iter<I: IntoIterator<Item = Pair<T, P>>>(i: I) -> Self { let mut ret = Punctuated::new(); - ret.extend(i); + do_extend(&mut ret, i.into_iter()); ret } } -impl<T, P> Extend<Pair<T, P>> for Punctuated<T, P> { +impl<T, P> Extend<Pair<T, P>> for Punctuated<T, P> +where + P: Default, +{ fn extend<I: IntoIterator<Item = Pair<T, P>>>(&mut self, i: I) { - assert!( - self.empty_or_trailing(), - "Punctuated::extend: Punctuated is not empty or does not have a trailing punctuation", - ); + if !self.empty_or_trailing() { + self.push_punct(P::default()); + } + do_extend(self, i.into_iter()); + } +} - let mut nomore = false; - for pair in i { - if nomore { - panic!("Punctuated extended with items after a Pair::End"); - } - match pair { - Pair::Punctuated(a, b) => self.inner.push((a, b)), - Pair::End(a) => { - self.last = Some(Box::new(a)); - nomore = true; - } +fn do_extend<T, P, I>(punctuated: &mut Punctuated<T, P>, i: I) +where + I: Iterator<Item = Pair<T, P>>, +{ + let mut nomore = false; + for pair in i { + if nomore { + panic!("Punctuated extended with items after a Pair::End"); + } + match pair { + Pair::Punctuated(a, b) => punctuated.inner.push((a, b)), + Pair::End(a) => { + punctuated.last = Some(Box::new(a)); + nomore = true; } } } @@ -719,16 +704,11 @@ where /// /// [module documentation]: self pub struct Iter<'a, T: 'a> { - // The `Item = &'a T` needs to be specified to support rustc 1.31 and older. - // On modern compilers we would be able to write just IterTrait<'a, T> where - // Item can be inferred unambiguously from the supertrait. - inner: Box<NoDrop<dyn IterTrait<'a, T, Item = &'a T> + 'a>>, + inner: Box<NoDrop<dyn IterTrait<'a, T> + 'a>>, } -trait IterTrait<'a, T: 'a>: - DoubleEndedIterator<Item = &'a T> + ExactSizeIterator<Item = &'a T> -{ - fn clone_box(&self) -> Box<NoDrop<dyn IterTrait<'a, T, Item = &'a T> + 'a>>; +trait IterTrait<'a, T: 'a>: Iterator<Item = &'a T> + DoubleEndedIterator + ExactSizeIterator { + fn clone_box(&self) -> Box<NoDrop<dyn IterTrait<'a, T> + 'a>>; } struct PrivateIter<'a, T: 'a, P: 'a> { @@ -827,7 +807,7 @@ where + TrivialDrop + 'a, { - fn clone_box(&self) -> Box<NoDrop<dyn IterTrait<'a, T, Item = &'a T> + 'a>> { + fn clone_box(&self) -> Box<NoDrop<dyn IterTrait<'a, T> + 'a>> { Box::new(NoDrop::new(self.clone())) } } @@ -1010,6 +990,21 @@ impl<T, P> Pair<T, P> { #[cfg(feature = "clone-impls")] #[cfg_attr(doc_cfg, doc(cfg(feature = "clone-impls")))] +impl<T, P> Pair<&T, &P> { + pub fn cloned(self) -> Pair<T, P> + where + T: Clone, + P: Clone, + { + match self { + Pair::Punctuated(t, p) => Pair::Punctuated(t.clone(), p.clone()), + Pair::End(t) => Pair::End(t.clone()), + } + } +} + +#[cfg(feature = "clone-impls")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "clone-impls")))] impl<T, P> Clone for Pair<T, P> where T: Clone, @@ -1023,6 +1018,15 @@ where } } +#[cfg(feature = "clone-impls")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "clone-impls")))] +impl<T, P> Copy for Pair<T, P> +where + T: Copy, + P: Copy, +{ +} + impl<T, P> Index<usize> for Punctuated<T, P> { type Output = T; diff --git a/vendor/syn/src/reserved.rs b/vendor/syn/src/reserved.rs deleted file mode 100644 index abfdf43a9..000000000 --- a/vendor/syn/src/reserved.rs +++ /dev/null @@ -1,44 +0,0 @@ -// Type for a syntax tree node that is reserved for future use. -// -// For example ExprReference contains a field `raw` of type Reserved. If `&raw -// place` syntax becomes a thing as per https://github.com/rust-lang/rfcs/pull/2582, -// we can backward compatibly change `raw`'s type to Option<Token![raw]> without -// the possibility of breaking any code. - -use proc_macro2::Span; -use std::marker::PhantomData; - -#[cfg(feature = "extra-traits")] -use std::fmt::{self, Debug}; - -ast_struct! { - pub struct Reserved { - _private: PhantomData<Span>, - } -} - -impl Default for Reserved { - fn default() -> Self { - Reserved { - _private: PhantomData, - } - } -} - -#[cfg(feature = "clone-impls")] -#[cfg_attr(doc_cfg, doc(cfg(feature = "clone-impls")))] -impl Clone for Reserved { - fn clone(&self) -> Self { - Reserved { - _private: self._private, - } - } -} - -#[cfg(feature = "extra-traits")] -#[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] -impl Debug for Reserved { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.debug_struct("Reserved").finish() - } -} diff --git a/vendor/syn/src/restriction.rs b/vendor/syn/src/restriction.rs new file mode 100644 index 000000000..97c7f5ae3 --- /dev/null +++ b/vendor/syn/src/restriction.rs @@ -0,0 +1,171 @@ +use super::*; + +ast_enum! { + /// The visibility level of an item: inherited or `pub` or + /// `pub(restricted)`. + /// + /// # Syntax tree enum + /// + /// This type is a [syntax tree enum]. + /// + /// [syntax tree enum]: Expr#syntax-tree-enums + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "full", feature = "derive"))))] + pub enum Visibility { + /// A public visibility level: `pub`. + Public(Token![pub]), + + /// A visibility level restricted to some path: `pub(self)` or + /// `pub(super)` or `pub(crate)` or `pub(in some::module)`. + Restricted(VisRestricted), + + /// An inherited visibility, which usually means private. + Inherited, + } +} + +ast_struct! { + /// A visibility level restricted to some path: `pub(self)` or + /// `pub(super)` or `pub(crate)` or `pub(in some::module)`. + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "full", feature = "derive"))))] + pub struct VisRestricted { + pub pub_token: Token![pub], + pub paren_token: token::Paren, + pub in_token: Option<Token![in]>, + pub path: Box<Path>, + } +} + +ast_enum! { + /// Unused, but reserved for RFC 3323 restrictions. + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "full", feature = "derive"))))] + #[non_exhaustive] + pub enum FieldMutability { + None, + + // TODO: https://rust-lang.github.io/rfcs/3323-restrictions.html + // + // FieldMutability::Restricted(MutRestricted) + // + // pub struct MutRestricted { + // pub mut_token: Token![mut], + // pub paren_token: token::Paren, + // pub in_token: Option<Token![in]>, + // pub path: Box<Path>, + // } + } +} + +#[cfg(feature = "parsing")] +pub(crate) mod parsing { + use super::*; + use crate::ext::IdentExt; + use crate::parse::discouraged::Speculative; + use crate::parse::{Parse, ParseStream, Result}; + + #[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))] + impl Parse for Visibility { + fn parse(input: ParseStream) -> Result<Self> { + // Recognize an empty None-delimited group, as produced by a $:vis + // matcher that matched no tokens. + if input.peek(token::Group) { + let ahead = input.fork(); + let group = crate::group::parse_group(&ahead)?; + if group.content.is_empty() { + input.advance_to(&ahead); + return Ok(Visibility::Inherited); + } + } + + if input.peek(Token![pub]) { + Self::parse_pub(input) + } else { + Ok(Visibility::Inherited) + } + } + } + + impl Visibility { + fn parse_pub(input: ParseStream) -> Result<Self> { + let pub_token = input.parse::<Token![pub]>()?; + + if input.peek(token::Paren) { + let ahead = input.fork(); + + let content; + let paren_token = parenthesized!(content in ahead); + if content.peek(Token![crate]) + || content.peek(Token![self]) + || content.peek(Token![super]) + { + let path = content.call(Ident::parse_any)?; + + // Ensure there are no additional tokens within `content`. + // Without explicitly checking, we may misinterpret a tuple + // field as a restricted visibility, causing a parse error. + // e.g. `pub (crate::A, crate::B)` (Issue #720). + if content.is_empty() { + input.advance_to(&ahead); + return Ok(Visibility::Restricted(VisRestricted { + pub_token, + paren_token, + in_token: None, + path: Box::new(Path::from(path)), + })); + } + } else if content.peek(Token![in]) { + let in_token: Token![in] = content.parse()?; + let path = content.call(Path::parse_mod_style)?; + + input.advance_to(&ahead); + return Ok(Visibility::Restricted(VisRestricted { + pub_token, + paren_token, + in_token: Some(in_token), + path: Box::new(path), + })); + } + } + + Ok(Visibility::Public(pub_token)) + } + + #[cfg(feature = "full")] + pub(crate) fn is_some(&self) -> bool { + match self { + Visibility::Inherited => false, + _ => true, + } + } + } +} + +#[cfg(feature = "printing")] +mod printing { + use super::*; + use proc_macro2::TokenStream; + use quote::ToTokens; + + #[cfg_attr(doc_cfg, doc(cfg(feature = "printing")))] + impl ToTokens for Visibility { + fn to_tokens(&self, tokens: &mut TokenStream) { + match self { + Visibility::Public(pub_token) => pub_token.to_tokens(tokens), + Visibility::Restricted(vis_restricted) => vis_restricted.to_tokens(tokens), + Visibility::Inherited => {} + } + } + } + + #[cfg_attr(doc_cfg, doc(cfg(feature = "printing")))] + impl ToTokens for VisRestricted { + fn to_tokens(&self, tokens: &mut TokenStream) { + self.pub_token.to_tokens(tokens); + self.paren_token.surround(tokens, |tokens| { + // TODO: If we have a path which is not "self" or "super" or + // "crate", automatically add the "in" token. + self.in_token.to_tokens(tokens); + self.path.to_tokens(tokens); + }); + } + } +} diff --git a/vendor/syn/src/sealed.rs b/vendor/syn/src/sealed.rs index 0b11bc99a..dc804742d 100644 --- a/vendor/syn/src/sealed.rs +++ b/vendor/syn/src/sealed.rs @@ -1,4 +1,4 @@ #[cfg(feature = "parsing")] -pub mod lookahead { +pub(crate) mod lookahead { pub trait Sealed: Copy {} } diff --git a/vendor/syn/src/span.rs b/vendor/syn/src/span.rs index 27a7fe846..50a26b833 100644 --- a/vendor/syn/src/span.rs +++ b/vendor/syn/src/span.rs @@ -1,9 +1,16 @@ -use proc_macro2::Span; +use proc_macro2::extra::DelimSpan; +use proc_macro2::{Delimiter, Group, Span, TokenStream}; pub trait IntoSpans<S> { fn into_spans(self) -> S; } +impl IntoSpans<Span> for Span { + fn into_spans(self) -> Span { + self + } +} + impl IntoSpans<[Span; 1]> for Span { fn into_spans(self) -> [Span; 1] { [self] @@ -40,28 +47,16 @@ impl IntoSpans<[Span; 3]> for [Span; 3] { } } -#[cfg(feature = "parsing")] -pub trait FromSpans: Sized { - fn from_spans(spans: &[Span]) -> Self; -} - -#[cfg(feature = "parsing")] -impl FromSpans for [Span; 1] { - fn from_spans(spans: &[Span]) -> Self { - [spans[0]] - } -} - -#[cfg(feature = "parsing")] -impl FromSpans for [Span; 2] { - fn from_spans(spans: &[Span]) -> Self { - [spans[0], spans[1]] +impl IntoSpans<DelimSpan> for Span { + fn into_spans(self) -> DelimSpan { + let mut group = Group::new(Delimiter::None, TokenStream::new()); + group.set_span(self); + group.delim_span() } } -#[cfg(feature = "parsing")] -impl FromSpans for [Span; 3] { - fn from_spans(spans: &[Span]) -> Self { - [spans[0], spans[1], spans[2]] +impl IntoSpans<DelimSpan> for DelimSpan { + fn into_spans(self) -> DelimSpan { + self } } diff --git a/vendor/syn/src/spanned.rs b/vendor/syn/src/spanned.rs index d51ffb3fa..7e101d264 100644 --- a/vendor/syn/src/spanned.rs +++ b/vendor/syn/src/spanned.rs @@ -1,9 +1,6 @@ //! A trait that can provide the `Span` of the complete contents of a syntax //! tree node. //! -//! *This module is available only if Syn is built with both the `"parsing"` and -//! `"printing"` features.* -//! //! <br> //! //! # Example @@ -96,10 +93,7 @@ use quote::spanned::Spanned as ToTokens; /// See the [module documentation] for an example. /// /// [module documentation]: self -/// -/// *This trait is available only if Syn is built with both the `"parsing"` and -/// `"printing"` features.* -pub trait Spanned { +pub trait Spanned: private::Sealed { /// Returns a `Span` covering the complete contents of this syntax tree /// node, or [`Span::call_site()`] if this node is empty. /// @@ -112,3 +106,10 @@ impl<T: ?Sized + ToTokens> Spanned for T { self.__span() } } + +mod private { + use super::*; + + pub trait Sealed {} + impl<T: ?Sized + ToTokens> Sealed for T {} +} diff --git a/vendor/syn/src/stmt.rs b/vendor/syn/src/stmt.rs index 58bd013ec..b5434f7ce 100644 --- a/vendor/syn/src/stmt.rs +++ b/vendor/syn/src/stmt.rs @@ -2,8 +2,6 @@ use super::*; ast_struct! { /// A braced block containing Rust statements. - /// - /// *This type is available only if Syn is built with the `"full"` feature.* #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub struct Block { pub brace_token: token::Brace, @@ -14,8 +12,6 @@ ast_struct! { ast_enum! { /// A statement, usually ending in a semicolon. - /// - /// *This type is available only if Syn is built with the `"full"` feature.* #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub enum Stmt { /// A local (let) binding. @@ -24,42 +20,71 @@ ast_enum! { /// An item definition. Item(Item), - /// Expr without trailing semicolon. - Expr(Expr), + /// Expression, with or without trailing semicolon. + Expr(Expr, Option<Token![;]>), - /// Expression with trailing semicolon. - Semi(Expr, Token![;]), + /// A macro invocation in statement position. + /// + /// Syntactically it's ambiguous which other kind of statement this + /// macro would expand to. It can be any of local variable (`let`), + /// item, or expression. + Macro(StmtMacro), } } ast_struct! { /// A local `let` binding: `let x: u64 = s.parse()?`. - /// - /// *This type is available only if Syn is built with the `"full"` feature.* #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub struct Local { pub attrs: Vec<Attribute>, pub let_token: Token![let], pub pat: Pat, - pub init: Option<(Token![=], Box<Expr>)>, + pub init: Option<LocalInit>, pub semi_token: Token![;], } } +ast_struct! { + /// The expression assigned in a local `let` binding, including optional + /// diverging `else` block. + /// + /// `LocalInit` represents `= s.parse()?` in `let x: u64 = s.parse()?` and + /// `= r else { return }` in `let Ok(x) = r else { return }`. + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] + pub struct LocalInit { + pub eq_token: Token![=], + pub expr: Box<Expr>, + pub diverge: Option<(Token![else], Box<Expr>)>, + } +} + +ast_struct! { + /// A macro invocation in statement position. + /// + /// Syntactically it's ambiguous which other kind of statement this macro + /// would expand to. It can be any of local variable (`let`), item, or + /// expression. + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] + pub struct StmtMacro { + pub attrs: Vec<Attribute>, + pub mac: Macro, + pub semi_token: Option<Token![;]>, + } +} + #[cfg(feature = "parsing")] -pub mod parsing { +pub(crate) mod parsing { use super::*; use crate::parse::discouraged::Speculative; - use crate::parse::{Parse, ParseBuffer, ParseStream, Result}; + use crate::parse::{Parse, ParseStream, Result}; use proc_macro2::TokenStream; + struct AllowNoSemi(bool); + impl Block { /// Parse the body of a block as zero or more statements, possibly /// including one trailing expression. /// - /// *This function is available only if Syn is built with the `"parsing"` - /// feature.* - /// /// # Example /// /// ``` @@ -110,23 +135,25 @@ pub mod parsing { pub fn parse_within(input: ParseStream) -> Result<Vec<Stmt>> { let mut stmts = Vec::new(); loop { - while let Some(semi) = input.parse::<Option<Token![;]>>()? { - stmts.push(Stmt::Semi(Expr::Verbatim(TokenStream::new()), semi)); + while let semi @ Some(_) = input.parse()? { + stmts.push(Stmt::Expr(Expr::Verbatim(TokenStream::new()), semi)); } if input.is_empty() { break; } - let s = parse_stmt(input, true)?; - let requires_semicolon = if let Stmt::Expr(s) = &s { - expr::requires_terminator(s) - } else { - false + let stmt = parse_stmt(input, AllowNoSemi(true))?; + let requires_semicolon = match &stmt { + Stmt::Expr(stmt, None) => expr::requires_terminator(stmt), + Stmt::Macro(stmt) => { + stmt.semi_token.is_none() && !stmt.mac.delimiter.is_brace() + } + Stmt::Local(_) | Stmt::Item(_) | Stmt::Expr(_, Some(_)) => false, }; - stmts.push(s); + stmts.push(stmt); if input.is_empty() { break; } else if requires_semicolon { - return Err(input.error("unexpected token")); + return Err(input.error("unexpected token, expected `;`")); } } Ok(stmts) @@ -147,30 +174,33 @@ pub mod parsing { #[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))] impl Parse for Stmt { fn parse(input: ParseStream) -> Result<Self> { - parse_stmt(input, false) + let allow_nosemi = AllowNoSemi(false); + parse_stmt(input, allow_nosemi) } } - fn parse_stmt(input: ParseStream, allow_nosemi: bool) -> Result<Stmt> { - let begin = input.fork(); + fn parse_stmt(input: ParseStream, allow_nosemi: AllowNoSemi) -> Result<Stmt> { let mut attrs = input.call(Attribute::parse_outer)?; // brace-style macros; paren and bracket macros get parsed as // expression statements. let ahead = input.fork(); + let mut is_item_macro = false; if let Ok(path) = ahead.call(Path::parse_mod_style) { - if ahead.peek(Token![!]) - && (ahead.peek2(token::Brace) + if ahead.peek(Token![!]) { + if ahead.peek2(Ident) || ahead.peek2(Token![try]) { + is_item_macro = true; + } else if ahead.peek2(token::Brace) && !(ahead.peek3(Token![.]) || ahead.peek3(Token![?])) - || ahead.peek2(Ident)) - { - input.advance_to(&ahead); - return stmt_mac(input, attrs, path); + { + input.advance_to(&ahead); + return stmt_mac(input, attrs, path).map(Stmt::Macro); + } } } if input.peek(Token![let]) { - stmt_local(input, attrs, begin) + stmt_local(input, attrs).map(Stmt::Local) } else if input.peek(Token![pub]) || input.peek(Token![crate]) && !input.peek2(Token![::]) || input.peek(Token![extern]) @@ -180,7 +210,15 @@ pub mod parsing { || input.peek2(Ident) && !(input.peek2(Token![async]) && (input.peek3(Token![move]) || input.peek3(Token![|])))) - || input.peek(Token![const]) && !input.peek2(token::Brace) + || input.peek(Token![const]) + && !(input.peek2(token::Brace) + || input.peek2(Token![static]) + || input.peek2(Token![async]) + && !(input.peek3(Token![unsafe]) + || input.peek3(Token![extern]) + || input.peek3(Token![fn])) + || input.peek2(Token![move]) + || input.peek2(Token![|])) || input.peek(Token![unsafe]) && !input.peek2(token::Brace) || input.peek(Token![async]) && (input.peek2(Token![unsafe]) @@ -198,6 +236,7 @@ pub mod parsing { && (input.peek2(Token![unsafe]) || input.peek2(Token![impl])) || input.peek(Token![impl]) || input.peek(Token![macro]) + || is_item_macro { let mut item: Item = input.parse()?; attrs.extend(item.replace_attrs(Vec::new())); @@ -208,15 +247,13 @@ pub mod parsing { } } - fn stmt_mac(input: ParseStream, attrs: Vec<Attribute>, path: Path) -> Result<Stmt> { + fn stmt_mac(input: ParseStream, attrs: Vec<Attribute>, path: Path) -> Result<StmtMacro> { let bang_token: Token![!] = input.parse()?; - let ident: Option<Ident> = input.parse()?; let (delimiter, tokens) = mac::parse_delimiter(input)?; let semi_token: Option<Token![;]> = input.parse()?; - Ok(Stmt::Item(Item::Macro(ItemMacro { + Ok(StmtMacro { attrs, - ident, mac: Macro { path, bang_token, @@ -224,13 +261,13 @@ pub mod parsing { tokens, }, semi_token, - }))) + }) } - fn stmt_local(input: ParseStream, attrs: Vec<Attribute>, begin: ParseBuffer) -> Result<Stmt> { + fn stmt_local(input: ParseStream, attrs: Vec<Attribute>) -> Result<Local> { let let_token: Token![let] = input.parse()?; - let mut pat: Pat = pat::parsing::multi_pat_with_leading_vert(input)?; + let mut pat = Pat::parse_single(input)?; if input.peek(Token![:]) { let colon_token: Token![:] = input.parse()?; let ty: Type = input.parse()?; @@ -242,39 +279,45 @@ pub mod parsing { }); } - let init = if input.peek(Token![=]) { - let eq_token: Token![=] = input.parse()?; - let init: Expr = input.parse()?; - - if input.peek(Token![else]) { - input.parse::<Token![else]>()?; - let content; - braced!(content in input); - content.call(Block::parse_within)?; - let verbatim = Expr::Verbatim(verbatim::between(begin, input)); - let semi_token: Token![;] = input.parse()?; - return Ok(Stmt::Semi(verbatim, semi_token)); - } + let init = if let Some(eq_token) = input.parse()? { + let eq_token: Token![=] = eq_token; + let expr: Expr = input.parse()?; + + let diverge = if let Some(else_token) = input.parse()? { + let else_token: Token![else] = else_token; + let diverge = ExprBlock { + attrs: Vec::new(), + label: None, + block: input.parse()?, + }; + Some((else_token, Box::new(Expr::Block(diverge)))) + } else { + None + }; - Some((eq_token, Box::new(init))) + Some(LocalInit { + eq_token, + expr: Box::new(expr), + diverge, + }) } else { None }; let semi_token: Token![;] = input.parse()?; - Ok(Stmt::Local(Local { + Ok(Local { attrs, let_token, pat, init, semi_token, - })) + }) } fn stmt_expr( input: ParseStream, - allow_nosemi: bool, + allow_nosemi: AllowNoSemi, mut attrs: Vec<Attribute>, ) -> Result<Stmt> { let mut e = expr::parsing::expr_early(input)?; @@ -283,20 +326,68 @@ pub mod parsing { loop { attr_target = match attr_target { Expr::Assign(e) => &mut e.left, - Expr::AssignOp(e) => &mut e.left, Expr::Binary(e) => &mut e.left, - _ => break, + Expr::Cast(e) => &mut e.expr, + Expr::Array(_) + | Expr::Async(_) + | Expr::Await(_) + | Expr::Block(_) + | Expr::Break(_) + | Expr::Call(_) + | Expr::Closure(_) + | Expr::Const(_) + | Expr::Continue(_) + | Expr::Field(_) + | Expr::ForLoop(_) + | Expr::Group(_) + | Expr::If(_) + | Expr::Index(_) + | Expr::Infer(_) + | Expr::Let(_) + | Expr::Lit(_) + | Expr::Loop(_) + | Expr::Macro(_) + | Expr::Match(_) + | Expr::MethodCall(_) + | Expr::Paren(_) + | Expr::Path(_) + | Expr::Range(_) + | Expr::Reference(_) + | Expr::Repeat(_) + | Expr::Return(_) + | Expr::Struct(_) + | Expr::Try(_) + | Expr::TryBlock(_) + | Expr::Tuple(_) + | Expr::Unary(_) + | Expr::Unsafe(_) + | Expr::While(_) + | Expr::Yield(_) + | Expr::Verbatim(_) => break, }; } attrs.extend(attr_target.replace_attrs(Vec::new())); attr_target.replace_attrs(attrs); - if input.peek(Token![;]) { - return Ok(Stmt::Semi(e, input.parse()?)); + let semi_token: Option<Token![;]> = input.parse()?; + + match e { + Expr::Macro(ExprMacro { attrs, mac }) + if semi_token.is_some() || mac.delimiter.is_brace() => + { + return Ok(Stmt::Macro(StmtMacro { + attrs, + mac, + semi_token, + })); + } + _ => {} } - if allow_nosemi || !expr::requires_terminator(&e) { - Ok(Stmt::Expr(e)) + if semi_token.is_some() { + Ok(Stmt::Expr(e, semi_token)) + } else if allow_nosemi.0 || !expr::requires_terminator(&e) { + Ok(Stmt::Expr(e, None)) } else { Err(input.error("expected semicolon")) } @@ -324,11 +415,11 @@ mod printing { match self { Stmt::Local(local) => local.to_tokens(tokens), Stmt::Item(item) => item.to_tokens(tokens), - Stmt::Expr(expr) => expr.to_tokens(tokens), - Stmt::Semi(expr, semi) => { + Stmt::Expr(expr, semi) => { expr.to_tokens(tokens); semi.to_tokens(tokens); } + Stmt::Macro(mac) => mac.to_tokens(tokens), } } } @@ -339,11 +430,24 @@ mod printing { expr::printing::outer_attrs_to_tokens(&self.attrs, tokens); self.let_token.to_tokens(tokens); self.pat.to_tokens(tokens); - if let Some((eq_token, init)) = &self.init { - eq_token.to_tokens(tokens); - init.to_tokens(tokens); + if let Some(init) = &self.init { + init.eq_token.to_tokens(tokens); + init.expr.to_tokens(tokens); + if let Some((else_token, diverge)) = &init.diverge { + else_token.to_tokens(tokens); + diverge.to_tokens(tokens); + } } self.semi_token.to_tokens(tokens); } } + + #[cfg_attr(doc_cfg, doc(cfg(feature = "printing")))] + impl ToTokens for StmtMacro { + fn to_tokens(&self, tokens: &mut TokenStream) { + expr::printing::outer_attrs_to_tokens(&self.attrs, tokens); + self.mac.to_tokens(tokens); + self.semi_token.to_tokens(tokens); + } + } } diff --git a/vendor/syn/src/thread.rs b/vendor/syn/src/thread.rs index 9e5d8ad85..63fdea834 100644 --- a/vendor/syn/src/thread.rs +++ b/vendor/syn/src/thread.rs @@ -4,7 +4,7 @@ use std::thread::{self, ThreadId}; /// ThreadBound is a Sync-maker and Send-maker that allows accessing a value /// of type T only from the original thread on which the ThreadBound was /// constructed. -pub struct ThreadBound<T> { +pub(crate) struct ThreadBound<T> { value: T, thread_id: ThreadId, } @@ -15,14 +15,14 @@ unsafe impl<T> Sync for ThreadBound<T> {} unsafe impl<T: Copy> Send for ThreadBound<T> {} impl<T> ThreadBound<T> { - pub fn new(value: T) -> Self { + pub(crate) fn new(value: T) -> Self { ThreadBound { value, thread_id: thread::current().id(), } } - pub fn get(&self) -> Option<&T> { + pub(crate) fn get(&self) -> Option<&T> { if thread::current().id() == self.thread_id { Some(&self.value) } else { @@ -39,3 +39,12 @@ impl<T: Debug> Debug for ThreadBound<T> { } } } + +impl<T: Clone> Clone for ThreadBound<T> { + fn clone(&self) -> Self { + ThreadBound { + value: self.value.clone(), + thread_id: self.thread_id, + } + } +} diff --git a/vendor/syn/src/token.rs b/vendor/syn/src/token.rs index 2208b07d0..c140571a9 100644 --- a/vendor/syn/src/token.rs +++ b/vendor/syn/src/token.rs @@ -102,13 +102,14 @@ use crate::lookahead; #[cfg(feature = "parsing")] use crate::parse::{Parse, ParseStream}; use crate::span::IntoSpans; -#[cfg(any(feature = "parsing", feature = "printing"))] -use proc_macro2::Ident; +use proc_macro2::extra::DelimSpan; use proc_macro2::Span; #[cfg(feature = "printing")] use proc_macro2::TokenStream; +#[cfg(any(feature = "parsing", feature = "printing"))] +use proc_macro2::{Delimiter, Ident}; #[cfg(feature = "parsing")] -use proc_macro2::{Delimiter, Literal, Punct, TokenTree}; +use proc_macro2::{Literal, Punct, TokenTree}; #[cfg(feature = "printing")] use quote::{ToTokens, TokenStreamExt}; #[cfg(feature = "extra-traits")] @@ -141,7 +142,7 @@ mod private { /// Support writing `token.span` rather than `token.spans[0]` on tokens that /// hold a single span. - #[repr(C)] + #[repr(transparent)] pub struct WithSpan { pub span: Span, } @@ -163,7 +164,7 @@ fn peek_impl(cursor: Cursor, peek: fn(ParseStream) -> bool) -> bool { } macro_rules! impl_token { - ($display:tt $name:ty) => { + ($display:literal $name:ty) => { #[cfg(feature = "parsing")] impl Token for $name { fn peek(cursor: Cursor) -> bool { @@ -195,7 +196,7 @@ impl_token!("boolean literal" LitBool); impl_token!("group token" proc_macro2::Group); macro_rules! impl_low_level_token { - ($display:tt $ty:ident $get:ident) => { + ($display:literal $ty:ident $get:ident) => { #[cfg(feature = "parsing")] impl Token for $ty { fn peek(cursor: Cursor) -> bool { @@ -239,9 +240,9 @@ impl<T: CustomToken> Token for T { } macro_rules! define_keywords { - ($($token:tt pub struct $name:ident #[$doc:meta])*) => { + ($($token:literal pub struct $name:ident)*) => { $( - #[$doc] + #[doc = concat!('`', $token, '`')] /// /// Don't try to remember the name of this type — use the /// [`Token!`] macro instead. @@ -253,9 +254,9 @@ macro_rules! define_keywords { #[doc(hidden)] #[allow(non_snake_case)] - pub fn $name<S: IntoSpans<[Span; 1]>>(span: S) -> $name { + pub fn $name<S: IntoSpans<Span>>(span: S) -> $name { $name { - span: span.into_spans()[0], + span: span.into_spans(), } } @@ -346,25 +347,28 @@ macro_rules! impl_deref_if_len_is_1 { type Target = WithSpan; fn deref(&self) -> &Self::Target { - unsafe { &*(self as *const Self as *const WithSpan) } + unsafe { &*(self as *const Self).cast::<WithSpan>() } } } impl DerefMut for $name { fn deref_mut(&mut self) -> &mut Self::Target { - unsafe { &mut *(self as *mut Self as *mut WithSpan) } + unsafe { &mut *(self as *mut Self).cast::<WithSpan>() } } } }; - ($name:ident/$len:tt) => {}; + ($name:ident/$len:literal) => {}; } macro_rules! define_punctuation_structs { - ($($token:tt pub struct $name:ident/$len:tt #[$doc:meta])*) => { + ($($token:literal pub struct $name:ident/$len:tt #[doc = $usage:literal])*) => { $( - #[repr(C)] - #[$doc] + #[cfg_attr(not(doc), repr(transparent))] + #[doc = concat!('`', $token, '`')] + /// + /// Usage: + #[doc = concat!($usage, '.')] /// /// Don't try to remember the name of this type — use the /// [`Token!`] macro instead. @@ -434,10 +438,10 @@ macro_rules! define_punctuation_structs { } macro_rules! define_punctuation { - ($($token:tt pub struct $name:ident/$len:tt #[$doc:meta])*) => { + ($($token:literal pub struct $name:ident/$len:tt #[doc = $usage:literal])*) => { $( define_punctuation_structs! { - $token pub struct $name/$len #[$doc] + $token pub struct $name/$len #[doc = $usage] } #[cfg(feature = "printing")] @@ -476,26 +480,24 @@ macro_rules! define_punctuation { } macro_rules! define_delimiters { - ($($token:tt pub struct $name:ident #[$doc:meta])*) => { + ($($delim:ident pub struct $name:ident #[$doc:meta])*) => { $( #[$doc] pub struct $name { - pub span: Span, + pub span: DelimSpan, } #[doc(hidden)] #[allow(non_snake_case)] - pub fn $name<S: IntoSpans<[Span; 1]>>(span: S) -> $name { + pub fn $name<S: IntoSpans<DelimSpan>>(span: S) -> $name { $name { - span: span.into_spans()[0], + span: span.into_spans(), } } impl std::default::Default for $name { fn default() -> Self { - $name { - span: Span::call_site(), - } + $name(Span::call_site()) } } @@ -543,7 +545,9 @@ macro_rules! define_delimiters { where F: FnOnce(&mut TokenStream), { - printing::delim($token, self.span, tokens, f); + let mut inner = TokenStream::new(); + f(&mut inner); + printing::delim(Delimiter::$delim, self.span.join(), tokens, inner); } } @@ -554,7 +558,7 @@ macro_rules! define_delimiters { } define_punctuation_structs! { - "_" pub struct Underscore/1 /// `_` + "_" pub struct Underscore/1 /// wildcard patterns, inferred types, unnamed items in constants, extern crates, use declarations, and destructuring assignment } #[cfg(feature = "printing")] @@ -605,6 +609,80 @@ impl Token for Underscore { #[cfg(feature = "parsing")] impl private::Sealed for Underscore {} +/// None-delimited group +pub struct Group { + pub span: Span, +} + +#[doc(hidden)] +#[allow(non_snake_case)] +pub fn Group<S: IntoSpans<Span>>(span: S) -> Group { + Group { + span: span.into_spans(), + } +} + +impl std::default::Default for Group { + fn default() -> Self { + Group { + span: Span::call_site(), + } + } +} + +#[cfg(feature = "clone-impls")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "clone-impls")))] +impl Copy for Group {} + +#[cfg(feature = "clone-impls")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "clone-impls")))] +impl Clone for Group { + fn clone(&self) -> Self { + *self + } +} + +#[cfg(feature = "extra-traits")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] +impl Debug for Group { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.write_str("Group") + } +} + +#[cfg(feature = "extra-traits")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] +impl cmp::Eq for Group {} + +#[cfg(feature = "extra-traits")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] +impl PartialEq for Group { + fn eq(&self, _other: &Group) -> bool { + true + } +} + +#[cfg(feature = "extra-traits")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] +impl Hash for Group { + fn hash<H: Hasher>(&self, _state: &mut H) {} +} + +impl Group { + #[cfg(feature = "printing")] + pub fn surround<F>(&self, tokens: &mut TokenStream, f: F) + where + F: FnOnce(&mut TokenStream), + { + let mut inner = TokenStream::new(); + f(&mut inner); + printing::delim(Delimiter::None, self.span, tokens, inner); + } +} + +#[cfg(feature = "parsing")] +impl private::Sealed for Group {} + #[cfg(feature = "parsing")] impl Token for Paren { fn peek(cursor: Cursor) -> bool { @@ -650,250 +728,234 @@ impl Token for Group { } define_keywords! { - "abstract" pub struct Abstract /// `abstract` - "as" pub struct As /// `as` - "async" pub struct Async /// `async` - "auto" pub struct Auto /// `auto` - "await" pub struct Await /// `await` - "become" pub struct Become /// `become` - "box" pub struct Box /// `box` - "break" pub struct Break /// `break` - "const" pub struct Const /// `const` - "continue" pub struct Continue /// `continue` - "crate" pub struct Crate /// `crate` - "default" pub struct Default /// `default` - "do" pub struct Do /// `do` - "dyn" pub struct Dyn /// `dyn` - "else" pub struct Else /// `else` - "enum" pub struct Enum /// `enum` - "extern" pub struct Extern /// `extern` - "final" pub struct Final /// `final` - "fn" pub struct Fn /// `fn` - "for" pub struct For /// `for` - "if" pub struct If /// `if` - "impl" pub struct Impl /// `impl` - "in" pub struct In /// `in` - "let" pub struct Let /// `let` - "loop" pub struct Loop /// `loop` - "macro" pub struct Macro /// `macro` - "match" pub struct Match /// `match` - "mod" pub struct Mod /// `mod` - "move" pub struct Move /// `move` - "mut" pub struct Mut /// `mut` - "override" pub struct Override /// `override` - "priv" pub struct Priv /// `priv` - "pub" pub struct Pub /// `pub` - "ref" pub struct Ref /// `ref` - "return" pub struct Return /// `return` - "Self" pub struct SelfType /// `Self` - "self" pub struct SelfValue /// `self` - "static" pub struct Static /// `static` - "struct" pub struct Struct /// `struct` - "super" pub struct Super /// `super` - "trait" pub struct Trait /// `trait` - "try" pub struct Try /// `try` - "type" pub struct Type /// `type` - "typeof" pub struct Typeof /// `typeof` - "union" pub struct Union /// `union` - "unsafe" pub struct Unsafe /// `unsafe` - "unsized" pub struct Unsized /// `unsized` - "use" pub struct Use /// `use` - "virtual" pub struct Virtual /// `virtual` - "where" pub struct Where /// `where` - "while" pub struct While /// `while` - "yield" pub struct Yield /// `yield` + "abstract" pub struct Abstract + "as" pub struct As + "async" pub struct Async + "auto" pub struct Auto + "await" pub struct Await + "become" pub struct Become + "box" pub struct Box + "break" pub struct Break + "const" pub struct Const + "continue" pub struct Continue + "crate" pub struct Crate + "default" pub struct Default + "do" pub struct Do + "dyn" pub struct Dyn + "else" pub struct Else + "enum" pub struct Enum + "extern" pub struct Extern + "final" pub struct Final + "fn" pub struct Fn + "for" pub struct For + "if" pub struct If + "impl" pub struct Impl + "in" pub struct In + "let" pub struct Let + "loop" pub struct Loop + "macro" pub struct Macro + "match" pub struct Match + "mod" pub struct Mod + "move" pub struct Move + "mut" pub struct Mut + "override" pub struct Override + "priv" pub struct Priv + "pub" pub struct Pub + "ref" pub struct Ref + "return" pub struct Return + "Self" pub struct SelfType + "self" pub struct SelfValue + "static" pub struct Static + "struct" pub struct Struct + "super" pub struct Super + "trait" pub struct Trait + "try" pub struct Try + "type" pub struct Type + "typeof" pub struct Typeof + "union" pub struct Union + "unsafe" pub struct Unsafe + "unsized" pub struct Unsized + "use" pub struct Use + "virtual" pub struct Virtual + "where" pub struct Where + "while" pub struct While + "yield" pub struct Yield } define_punctuation! { - "+" pub struct Add/1 /// `+` - "+=" pub struct AddEq/2 /// `+=` - "&" pub struct And/1 /// `&` - "&&" pub struct AndAnd/2 /// `&&` - "&=" pub struct AndEq/2 /// `&=` - "@" pub struct At/1 /// `@` - "!" pub struct Bang/1 /// `!` - "^" pub struct Caret/1 /// `^` - "^=" pub struct CaretEq/2 /// `^=` - ":" pub struct Colon/1 /// `:` - "::" pub struct Colon2/2 /// `::` - "," pub struct Comma/1 /// `,` - "/" pub struct Div/1 /// `/` - "/=" pub struct DivEq/2 /// `/=` - "$" pub struct Dollar/1 /// `$` - "." pub struct Dot/1 /// `.` - ".." pub struct Dot2/2 /// `..` - "..." pub struct Dot3/3 /// `...` - "..=" pub struct DotDotEq/3 /// `..=` - "=" pub struct Eq/1 /// `=` - "==" pub struct EqEq/2 /// `==` - ">=" pub struct Ge/2 /// `>=` - ">" pub struct Gt/1 /// `>` - "<=" pub struct Le/2 /// `<=` - "<" pub struct Lt/1 /// `<` - "*=" pub struct MulEq/2 /// `*=` - "!=" pub struct Ne/2 /// `!=` - "|" pub struct Or/1 /// `|` - "|=" pub struct OrEq/2 /// `|=` - "||" pub struct OrOr/2 /// `||` - "#" pub struct Pound/1 /// `#` - "?" pub struct Question/1 /// `?` - "->" pub struct RArrow/2 /// `->` - "<-" pub struct LArrow/2 /// `<-` - "%" pub struct Rem/1 /// `%` - "%=" pub struct RemEq/2 /// `%=` - "=>" pub struct FatArrow/2 /// `=>` - ";" pub struct Semi/1 /// `;` - "<<" pub struct Shl/2 /// `<<` - "<<=" pub struct ShlEq/3 /// `<<=` - ">>" pub struct Shr/2 /// `>>` - ">>=" pub struct ShrEq/3 /// `>>=` - "*" pub struct Star/1 /// `*` - "-" pub struct Sub/1 /// `-` - "-=" pub struct SubEq/2 /// `-=` - "~" pub struct Tilde/1 /// `~` + "&" pub struct And/1 /// bitwise and logical AND, borrow, references, reference patterns + "&&" pub struct AndAnd/2 /// lazy AND, borrow, references, reference patterns + "&=" pub struct AndEq/2 /// bitwise AND assignment + "@" pub struct At/1 /// subpattern binding + "^" pub struct Caret/1 /// bitwise and logical XOR + "^=" pub struct CaretEq/2 /// bitwise XOR assignment + ":" pub struct Colon/1 /// various separators + "," pub struct Comma/1 /// various separators + "$" pub struct Dollar/1 /// macros + "." pub struct Dot/1 /// field access, tuple index + ".." pub struct DotDot/2 /// range, struct expressions, patterns, range patterns + "..." pub struct DotDotDot/3 /// variadic functions, range patterns + "..=" pub struct DotDotEq/3 /// inclusive range, range patterns + "=" pub struct Eq/1 /// assignment, attributes, various type definitions + "==" pub struct EqEq/2 /// equal + "=>" pub struct FatArrow/2 /// match arms, macros + ">=" pub struct Ge/2 /// greater than or equal to, generics + ">" pub struct Gt/1 /// greater than, generics, paths + "<-" pub struct LArrow/2 /// unused + "<=" pub struct Le/2 /// less than or equal to + "<" pub struct Lt/1 /// less than, generics, paths + "-" pub struct Minus/1 /// subtraction, negation + "-=" pub struct MinusEq/2 /// subtraction assignment + "!=" pub struct Ne/2 /// not equal + "!" pub struct Not/1 /// bitwise and logical NOT, macro calls, inner attributes, never type, negative impls + "|" pub struct Or/1 /// bitwise and logical OR, closures, patterns in match, if let, and while let + "|=" pub struct OrEq/2 /// bitwise OR assignment + "||" pub struct OrOr/2 /// lazy OR, closures + "::" pub struct PathSep/2 /// path separator + "%" pub struct Percent/1 /// remainder + "%=" pub struct PercentEq/2 /// remainder assignment + "+" pub struct Plus/1 /// addition, trait bounds, macro Kleene matcher + "+=" pub struct PlusEq/2 /// addition assignment + "#" pub struct Pound/1 /// attributes + "?" pub struct Question/1 /// question mark operator, questionably sized, macro Kleene matcher + "->" pub struct RArrow/2 /// function return type, closure return type, function pointer type + ";" pub struct Semi/1 /// terminator for various items and statements, array types + "<<" pub struct Shl/2 /// shift left, nested generics + "<<=" pub struct ShlEq/3 /// shift left assignment + ">>" pub struct Shr/2 /// shift right, nested generics + ">>=" pub struct ShrEq/3 /// shift right assignment, nested generics + "/" pub struct Slash/1 /// division + "/=" pub struct SlashEq/2 /// division assignment + "*" pub struct Star/1 /// multiplication, dereference, raw pointers, macro Kleene matcher, use wildcards + "*=" pub struct StarEq/2 /// multiplication assignment + "~" pub struct Tilde/1 /// unused since before Rust 1.0 } define_delimiters! { - "{" pub struct Brace /// `{...}` - "[" pub struct Bracket /// `[...]` - "(" pub struct Paren /// `(...)` - " " pub struct Group /// None-delimited group -} - -macro_rules! export_token_macro { - ($($await_rule:tt)*) => { - /// A type-macro that expands to the name of the Rust type representation of a - /// given token. - /// - /// See the [token module] documentation for details and examples. - /// - /// [token module]: crate::token - // Unfortunate duplication due to a rustdoc bug. - // https://github.com/rust-lang/rust/issues/45939 - #[macro_export] - macro_rules! Token { - [abstract] => { $crate::token::Abstract }; - [as] => { $crate::token::As }; - [async] => { $crate::token::Async }; - [auto] => { $crate::token::Auto }; - $($await_rule => { $crate::token::Await };)* - [become] => { $crate::token::Become }; - [box] => { $crate::token::Box }; - [break] => { $crate::token::Break }; - [const] => { $crate::token::Const }; - [continue] => { $crate::token::Continue }; - [crate] => { $crate::token::Crate }; - [default] => { $crate::token::Default }; - [do] => { $crate::token::Do }; - [dyn] => { $crate::token::Dyn }; - [else] => { $crate::token::Else }; - [enum] => { $crate::token::Enum }; - [extern] => { $crate::token::Extern }; - [final] => { $crate::token::Final }; - [fn] => { $crate::token::Fn }; - [for] => { $crate::token::For }; - [if] => { $crate::token::If }; - [impl] => { $crate::token::Impl }; - [in] => { $crate::token::In }; - [let] => { $crate::token::Let }; - [loop] => { $crate::token::Loop }; - [macro] => { $crate::token::Macro }; - [match] => { $crate::token::Match }; - [mod] => { $crate::token::Mod }; - [move] => { $crate::token::Move }; - [mut] => { $crate::token::Mut }; - [override] => { $crate::token::Override }; - [priv] => { $crate::token::Priv }; - [pub] => { $crate::token::Pub }; - [ref] => { $crate::token::Ref }; - [return] => { $crate::token::Return }; - [Self] => { $crate::token::SelfType }; - [self] => { $crate::token::SelfValue }; - [static] => { $crate::token::Static }; - [struct] => { $crate::token::Struct }; - [super] => { $crate::token::Super }; - [trait] => { $crate::token::Trait }; - [try] => { $crate::token::Try }; - [type] => { $crate::token::Type }; - [typeof] => { $crate::token::Typeof }; - [union] => { $crate::token::Union }; - [unsafe] => { $crate::token::Unsafe }; - [unsized] => { $crate::token::Unsized }; - [use] => { $crate::token::Use }; - [virtual] => { $crate::token::Virtual }; - [where] => { $crate::token::Where }; - [while] => { $crate::token::While }; - [yield] => { $crate::token::Yield }; - [+] => { $crate::token::Add }; - [+=] => { $crate::token::AddEq }; - [&] => { $crate::token::And }; - [&&] => { $crate::token::AndAnd }; - [&=] => { $crate::token::AndEq }; - [@] => { $crate::token::At }; - [!] => { $crate::token::Bang }; - [^] => { $crate::token::Caret }; - [^=] => { $crate::token::CaretEq }; - [:] => { $crate::token::Colon }; - [::] => { $crate::token::Colon2 }; - [,] => { $crate::token::Comma }; - [/] => { $crate::token::Div }; - [/=] => { $crate::token::DivEq }; - [$] => { $crate::token::Dollar }; - [.] => { $crate::token::Dot }; - [..] => { $crate::token::Dot2 }; - [...] => { $crate::token::Dot3 }; - [..=] => { $crate::token::DotDotEq }; - [=] => { $crate::token::Eq }; - [==] => { $crate::token::EqEq }; - [>=] => { $crate::token::Ge }; - [>] => { $crate::token::Gt }; - [<=] => { $crate::token::Le }; - [<] => { $crate::token::Lt }; - [*=] => { $crate::token::MulEq }; - [!=] => { $crate::token::Ne }; - [|] => { $crate::token::Or }; - [|=] => { $crate::token::OrEq }; - [||] => { $crate::token::OrOr }; - [#] => { $crate::token::Pound }; - [?] => { $crate::token::Question }; - [->] => { $crate::token::RArrow }; - [<-] => { $crate::token::LArrow }; - [%] => { $crate::token::Rem }; - [%=] => { $crate::token::RemEq }; - [=>] => { $crate::token::FatArrow }; - [;] => { $crate::token::Semi }; - [<<] => { $crate::token::Shl }; - [<<=] => { $crate::token::ShlEq }; - [>>] => { $crate::token::Shr }; - [>>=] => { $crate::token::ShrEq }; - [*] => { $crate::token::Star }; - [-] => { $crate::token::Sub }; - [-=] => { $crate::token::SubEq }; - [~] => { $crate::token::Tilde }; - [_] => { $crate::token::Underscore }; - } - }; + Brace pub struct Brace /// `{`…`}` + Bracket pub struct Bracket /// `[`…`]` + Parenthesis pub struct Paren /// `(`…`)` } -// Old rustc does not permit `await` appearing anywhere in the source file. -// https://github.com/rust-lang/rust/issues/57919 -// We put the Token![await] rule in a place that is not lexed by old rustc. -#[cfg(not(syn_omit_await_from_token_macro))] -include!("await.rs"); // export_token_macro! {[await]} -#[cfg(syn_omit_await_from_token_macro)] -export_token_macro! {} +/// A type-macro that expands to the name of the Rust type representation of a +/// given token. +/// +/// See the [token module] documentation for details and examples. +/// +/// [token module]: crate::token +#[macro_export] +macro_rules! Token { + [abstract] => { $crate::token::Abstract }; + [as] => { $crate::token::As }; + [async] => { $crate::token::Async }; + [auto] => { $crate::token::Auto }; + [await] => { $crate::token::Await }; + [become] => { $crate::token::Become }; + [box] => { $crate::token::Box }; + [break] => { $crate::token::Break }; + [const] => { $crate::token::Const }; + [continue] => { $crate::token::Continue }; + [crate] => { $crate::token::Crate }; + [default] => { $crate::token::Default }; + [do] => { $crate::token::Do }; + [dyn] => { $crate::token::Dyn }; + [else] => { $crate::token::Else }; + [enum] => { $crate::token::Enum }; + [extern] => { $crate::token::Extern }; + [final] => { $crate::token::Final }; + [fn] => { $crate::token::Fn }; + [for] => { $crate::token::For }; + [if] => { $crate::token::If }; + [impl] => { $crate::token::Impl }; + [in] => { $crate::token::In }; + [let] => { $crate::token::Let }; + [loop] => { $crate::token::Loop }; + [macro] => { $crate::token::Macro }; + [match] => { $crate::token::Match }; + [mod] => { $crate::token::Mod }; + [move] => { $crate::token::Move }; + [mut] => { $crate::token::Mut }; + [override] => { $crate::token::Override }; + [priv] => { $crate::token::Priv }; + [pub] => { $crate::token::Pub }; + [ref] => { $crate::token::Ref }; + [return] => { $crate::token::Return }; + [Self] => { $crate::token::SelfType }; + [self] => { $crate::token::SelfValue }; + [static] => { $crate::token::Static }; + [struct] => { $crate::token::Struct }; + [super] => { $crate::token::Super }; + [trait] => { $crate::token::Trait }; + [try] => { $crate::token::Try }; + [type] => { $crate::token::Type }; + [typeof] => { $crate::token::Typeof }; + [union] => { $crate::token::Union }; + [unsafe] => { $crate::token::Unsafe }; + [unsized] => { $crate::token::Unsized }; + [use] => { $crate::token::Use }; + [virtual] => { $crate::token::Virtual }; + [where] => { $crate::token::Where }; + [while] => { $crate::token::While }; + [yield] => { $crate::token::Yield }; + [&] => { $crate::token::And }; + [&&] => { $crate::token::AndAnd }; + [&=] => { $crate::token::AndEq }; + [@] => { $crate::token::At }; + [^] => { $crate::token::Caret }; + [^=] => { $crate::token::CaretEq }; + [:] => { $crate::token::Colon }; + [,] => { $crate::token::Comma }; + [$] => { $crate::token::Dollar }; + [.] => { $crate::token::Dot }; + [..] => { $crate::token::DotDot }; + [...] => { $crate::token::DotDotDot }; + [..=] => { $crate::token::DotDotEq }; + [=] => { $crate::token::Eq }; + [==] => { $crate::token::EqEq }; + [=>] => { $crate::token::FatArrow }; + [>=] => { $crate::token::Ge }; + [>] => { $crate::token::Gt }; + [<-] => { $crate::token::LArrow }; + [<=] => { $crate::token::Le }; + [<] => { $crate::token::Lt }; + [-] => { $crate::token::Minus }; + [-=] => { $crate::token::MinusEq }; + [!=] => { $crate::token::Ne }; + [!] => { $crate::token::Not }; + [|] => { $crate::token::Or }; + [|=] => { $crate::token::OrEq }; + [||] => { $crate::token::OrOr }; + [::] => { $crate::token::PathSep }; + [%] => { $crate::token::Percent }; + [%=] => { $crate::token::PercentEq }; + [+] => { $crate::token::Plus }; + [+=] => { $crate::token::PlusEq }; + [#] => { $crate::token::Pound }; + [?] => { $crate::token::Question }; + [->] => { $crate::token::RArrow }; + [;] => { $crate::token::Semi }; + [<<] => { $crate::token::Shl }; + [<<=] => { $crate::token::ShlEq }; + [>>] => { $crate::token::Shr }; + [>>=] => { $crate::token::ShrEq }; + [/] => { $crate::token::Slash }; + [/=] => { $crate::token::SlashEq }; + [*] => { $crate::token::Star }; + [*=] => { $crate::token::StarEq }; + [~] => { $crate::token::Tilde }; + [_] => { $crate::token::Underscore }; +} // Not public API. #[doc(hidden)] #[cfg(feature = "parsing")] -pub mod parsing { +pub(crate) mod parsing { use crate::buffer::Cursor; use crate::error::{Error, Result}; use crate::parse::ParseStream; - use crate::span::FromSpans; use proc_macro2::{Spacing, Span}; - pub fn keyword(input: ParseStream, token: &str) -> Result<Span> { + pub(crate) fn keyword(input: ParseStream, token: &str) -> Result<Span> { input.step(|cursor| { if let Some((ident, rest)) = cursor.ident() { if ident == token { @@ -904,7 +966,7 @@ pub mod parsing { }) } - pub fn peek_keyword(cursor: Cursor, token: &str) -> bool { + pub(crate) fn peek_keyword(cursor: Cursor, token: &str) -> bool { if let Some((ident, _rest)) = cursor.ident() { ident == token } else { @@ -912,16 +974,16 @@ pub mod parsing { } } - pub fn punct<S: FromSpans>(input: ParseStream, token: &str) -> Result<S> { - let mut spans = [input.span(); 3]; + pub fn punct<const N: usize>(input: ParseStream, token: &str) -> Result<[Span; N]> { + let mut spans = [input.span(); N]; punct_helper(input, token, &mut spans)?; - Ok(S::from_spans(&spans)) + Ok(spans) } - fn punct_helper(input: ParseStream, token: &str, spans: &mut [Span; 3]) -> Result<()> { + fn punct_helper(input: ParseStream, token: &str, spans: &mut [Span]) -> Result<()> { input.step(|cursor| { let mut cursor = *cursor; - assert!(token.len() <= spans.len()); + assert_eq!(token.len(), spans.len()); for (i, ch) in token.chars().enumerate() { match cursor.punct() { @@ -967,7 +1029,7 @@ pub mod parsing { // Not public API. #[doc(hidden)] #[cfg(feature = "printing")] -pub mod printing { +pub(crate) mod printing { use proc_macro2::{Delimiter, Group, Ident, Punct, Spacing, Span, TokenStream}; use quote::TokenStreamExt; @@ -989,23 +1051,16 @@ pub mod printing { tokens.append(op); } - pub fn keyword(s: &str, span: Span, tokens: &mut TokenStream) { + pub(crate) fn keyword(s: &str, span: Span, tokens: &mut TokenStream) { tokens.append(Ident::new(s, span)); } - pub fn delim<F>(s: &str, span: Span, tokens: &mut TokenStream, f: F) - where - F: FnOnce(&mut TokenStream), - { - let delim = match s { - "(" => Delimiter::Parenthesis, - "[" => Delimiter::Bracket, - "{" => Delimiter::Brace, - " " => Delimiter::None, - _ => panic!("unknown delimiter: {}", s), - }; - let mut inner = TokenStream::new(); - f(&mut inner); + pub(crate) fn delim( + delim: Delimiter, + span: Span, + tokens: &mut TokenStream, + inner: TokenStream, + ) { let mut g = Group::new(delim, inner); g.set_span(span); tokens.append(g); diff --git a/vendor/syn/src/tt.rs b/vendor/syn/src/tt.rs index d87c0ed4d..d8dc9aaa9 100644 --- a/vendor/syn/src/tt.rs +++ b/vendor/syn/src/tt.rs @@ -1,7 +1,7 @@ use proc_macro2::{Delimiter, TokenStream, TokenTree}; use std::hash::{Hash, Hasher}; -pub struct TokenTreeHelper<'a>(pub &'a TokenTree); +pub(crate) struct TokenTreeHelper<'a>(pub &'a TokenTree); impl<'a> PartialEq for TokenTreeHelper<'a> { fn eq(&self, other: &Self) -> bool { @@ -78,7 +78,7 @@ impl<'a> Hash for TokenTreeHelper<'a> { } } -pub struct TokenStreamHelper<'a>(pub &'a TokenStream); +pub(crate) struct TokenStreamHelper<'a>(pub &'a TokenStream); impl<'a> PartialEq for TokenStreamHelper<'a> { fn eq(&self, other: &Self) -> bool { diff --git a/vendor/syn/src/ty.rs b/vendor/syn/src/ty.rs index 8c841e2f7..9b341dafa 100644 --- a/vendor/syn/src/ty.rs +++ b/vendor/syn/src/ty.rs @@ -5,16 +5,13 @@ use proc_macro2::TokenStream; ast_enum_of_structs! { /// The possible types that a Rust value could have. /// - /// *This type is available only if Syn is built with the `"derive"` or `"full"` - /// feature.* - /// /// # Syntax tree enum /// /// This type is a [syntax tree enum]. /// /// [syntax tree enum]: Expr#syntax-tree-enums #[cfg_attr(doc_cfg, doc(cfg(any(feature = "full", feature = "derive"))))] - #[cfg_attr(not(syn_no_non_exhaustive), non_exhaustive)] + #[non_exhaustive] pub enum Type { /// A fixed size array type: `[T; n]`. Array(TypeArray), @@ -64,8 +61,6 @@ ast_enum_of_structs! { /// Tokens in type position not interpreted by Syn. Verbatim(TokenStream), - // Not public API. - // // For testing exhaustiveness in downstream code, use the following idiom: // // match ty { @@ -82,17 +77,11 @@ ast_enum_of_structs! { // a variant. You will be notified by a test failure when a variant is // added, so that you can add code to handle it, but your library will // continue to compile and work for downstream users in the interim. - #[cfg(syn_no_non_exhaustive)] - #[doc(hidden)] - __NonExhaustive, } } ast_struct! { /// A fixed size array type: `[T; n]`. - /// - /// *This type is available only if Syn is built with the `"derive"` or - /// `"full"` feature.* #[cfg_attr(doc_cfg, doc(cfg(any(feature = "full", feature = "derive"))))] pub struct TypeArray { pub bracket_token: token::Bracket, @@ -104,9 +93,6 @@ ast_struct! { ast_struct! { /// A bare function type: `fn(usize) -> bool`. - /// - /// *This type is available only if Syn is built with the `"derive"` or - /// `"full"` feature.* #[cfg_attr(doc_cfg, doc(cfg(any(feature = "full", feature = "derive"))))] pub struct TypeBareFn { pub lifetimes: Option<BoundLifetimes>, @@ -115,16 +101,13 @@ ast_struct! { pub fn_token: Token![fn], pub paren_token: token::Paren, pub inputs: Punctuated<BareFnArg, Token![,]>, - pub variadic: Option<Variadic>, + pub variadic: Option<BareVariadic>, pub output: ReturnType, } } ast_struct! { /// A type contained within invisible delimiters. - /// - /// *This type is available only if Syn is built with the `"derive"` or - /// `"full"` feature.* #[cfg_attr(doc_cfg, doc(cfg(any(feature = "full", feature = "derive"))))] pub struct TypeGroup { pub group_token: token::Group, @@ -135,9 +118,6 @@ ast_struct! { ast_struct! { /// An `impl Bound1 + Bound2 + Bound3` type where `Bound` is a trait or /// a lifetime. - /// - /// *This type is available only if Syn is built with the `"derive"` or - /// `"full"` feature.* #[cfg_attr(doc_cfg, doc(cfg(any(feature = "full", feature = "derive"))))] pub struct TypeImplTrait { pub impl_token: Token![impl], @@ -147,9 +127,6 @@ ast_struct! { ast_struct! { /// Indication that a type should be inferred by the compiler: `_`. - /// - /// *This type is available only if Syn is built with the `"derive"` or - /// `"full"` feature.* #[cfg_attr(doc_cfg, doc(cfg(any(feature = "full", feature = "derive"))))] pub struct TypeInfer { pub underscore_token: Token![_], @@ -158,9 +135,6 @@ ast_struct! { ast_struct! { /// A macro in the type position. - /// - /// *This type is available only if Syn is built with the `"derive"` or - /// `"full"` feature.* #[cfg_attr(doc_cfg, doc(cfg(any(feature = "full", feature = "derive"))))] pub struct TypeMacro { pub mac: Macro, @@ -169,9 +143,6 @@ ast_struct! { ast_struct! { /// The never type: `!`. - /// - /// *This type is available only if Syn is built with the `"derive"` or - /// `"full"` feature.* #[cfg_attr(doc_cfg, doc(cfg(any(feature = "full", feature = "derive"))))] pub struct TypeNever { pub bang_token: Token![!], @@ -180,9 +151,6 @@ ast_struct! { ast_struct! { /// A parenthesized type equivalent to the inner type. - /// - /// *This type is available only if Syn is built with the `"derive"` or - /// `"full"` feature.* #[cfg_attr(doc_cfg, doc(cfg(any(feature = "full", feature = "derive"))))] pub struct TypeParen { pub paren_token: token::Paren, @@ -193,9 +161,6 @@ ast_struct! { ast_struct! { /// A path like `std::slice::Iter`, optionally qualified with a /// self-type as in `<Vec<T> as SomeTrait>::Associated`. - /// - /// *This type is available only if Syn is built with the `"derive"` or - /// `"full"` feature.* #[cfg_attr(doc_cfg, doc(cfg(any(feature = "full", feature = "derive"))))] pub struct TypePath { pub qself: Option<QSelf>, @@ -205,9 +170,6 @@ ast_struct! { ast_struct! { /// A raw pointer type: `*const T` or `*mut T`. - /// - /// *This type is available only if Syn is built with the `"derive"` or - /// `"full"` feature.* #[cfg_attr(doc_cfg, doc(cfg(any(feature = "full", feature = "derive"))))] pub struct TypePtr { pub star_token: Token![*], @@ -219,9 +181,6 @@ ast_struct! { ast_struct! { /// A reference type: `&'a T` or `&'a mut T`. - /// - /// *This type is available only if Syn is built with the `"derive"` or - /// `"full"` feature.* #[cfg_attr(doc_cfg, doc(cfg(any(feature = "full", feature = "derive"))))] pub struct TypeReference { pub and_token: Token![&], @@ -233,9 +192,6 @@ ast_struct! { ast_struct! { /// A dynamically sized slice type: `[T]`. - /// - /// *This type is available only if Syn is built with the `"derive"` or - /// `"full"` feature.* #[cfg_attr(doc_cfg, doc(cfg(any(feature = "full", feature = "derive"))))] pub struct TypeSlice { pub bracket_token: token::Bracket, @@ -246,9 +202,6 @@ ast_struct! { ast_struct! { /// A trait object type `dyn Bound1 + Bound2 + Bound3` where `Bound` is a /// trait or a lifetime. - /// - /// *This type is available only if Syn is built with the `"derive"` or - /// `"full"` feature.* #[cfg_attr(doc_cfg, doc(cfg(any(feature = "full", feature = "derive"))))] pub struct TypeTraitObject { pub dyn_token: Option<Token![dyn]>, @@ -258,9 +211,6 @@ ast_struct! { ast_struct! { /// A tuple type: `(A, B, C, String)`. - /// - /// *This type is available only if Syn is built with the `"derive"` or - /// `"full"` feature.* #[cfg_attr(doc_cfg, doc(cfg(any(feature = "full", feature = "derive"))))] pub struct TypeTuple { pub paren_token: token::Paren, @@ -270,9 +220,6 @@ ast_struct! { ast_struct! { /// The binary interface of a function: `extern "C"`. - /// - /// *This type is available only if Syn is built with the `"derive"` or `"full"` - /// feature.* #[cfg_attr(doc_cfg, doc(cfg(any(feature = "full", feature = "derive"))))] pub struct Abi { pub extern_token: Token![extern], @@ -282,9 +229,6 @@ ast_struct! { ast_struct! { /// An argument in a function type: the `usize` in `fn(usize) -> bool`. - /// - /// *This type is available only if Syn is built with the `"derive"` or `"full"` - /// feature.* #[cfg_attr(doc_cfg, doc(cfg(any(feature = "full", feature = "derive"))))] pub struct BareFnArg { pub attrs: Vec<Attribute>, @@ -294,32 +238,18 @@ ast_struct! { } ast_struct! { - /// The variadic argument of a foreign function. - /// - /// ```rust - /// # struct c_char; - /// # struct c_int; - /// # - /// extern "C" { - /// fn printf(format: *const c_char, ...) -> c_int; - /// // ^^^ - /// } - /// ``` - /// - /// *This type is available only if Syn is built with the `"derive"` or `"full"` - /// feature.* + /// The variadic argument of a function pointer like `fn(usize, ...)`. #[cfg_attr(doc_cfg, doc(cfg(any(feature = "full", feature = "derive"))))] - pub struct Variadic { + pub struct BareVariadic { pub attrs: Vec<Attribute>, + pub name: Option<(Ident, Token![:])>, pub dots: Token![...], + pub comma: Option<Token![,]>, } } ast_enum! { /// Return type of a function signature. - /// - /// *This type is available only if Syn is built with the `"derive"` or `"full"` - /// feature.* #[cfg_attr(doc_cfg, doc(cfg(any(feature = "full", feature = "derive"))))] pub enum ReturnType { /// Return type is not specified. @@ -332,12 +262,12 @@ ast_enum! { } #[cfg(feature = "parsing")] -pub mod parsing { +pub(crate) mod parsing { use super::*; use crate::ext::IdentExt; use crate::parse::{Parse, ParseStream, Result}; use crate::path; - use proc_macro2::{Punct, Spacing, Span, TokenTree}; + use proc_macro2::Span; #[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))] impl Parse for Type { @@ -392,7 +322,7 @@ pub mod parsing { { if let Type::Path(mut ty) = *group.elem { let arguments = &mut ty.path.segments.last_mut().unwrap().arguments; - if let PathArguments::None = arguments { + if arguments.is_none() { *arguments = PathArguments::AngleBracketed(input.parse()?); Path::parse_rest(input, &mut ty.path, false)?; return Ok(Type::Path(ty)); @@ -503,7 +433,8 @@ pub mod parsing { ..trait_bound }) } - other @ TypeParamBound::Lifetime(_) => other, + other @ (TypeParamBound::Lifetime(_) + | TypeParamBound::Verbatim(_)) => other, } } _ => break, @@ -530,13 +461,9 @@ pub mod parsing { || lookahead.peek(Token![unsafe]) || lookahead.peek(Token![extern]) { - let allow_mut_self = true; - if let Some(mut bare_fn) = parse_bare_fn(input, allow_mut_self)? { - bare_fn.lifetimes = lifetimes; - Ok(Type::BareFn(bare_fn)) - } else { - Ok(Type::Verbatim(verbatim::between(begin, input))) - } + let mut bare_fn: TypeBareFn = input.parse()?; + bare_fn.lifetimes = lifetimes; + Ok(Type::BareFn(bare_fn)) } else if lookahead.peek(Ident) || input.peek(Token![super]) || input.peek(Token![self]) @@ -545,49 +472,22 @@ pub mod parsing { || lookahead.peek(Token![::]) || lookahead.peek(Token![<]) { - let dyn_token: Option<Token![dyn]> = input.parse()?; - if let Some(dyn_token) = dyn_token { - let dyn_span = dyn_token.span; - let star_token: Option<Token![*]> = input.parse()?; - let bounds = TypeTraitObject::parse_bounds(dyn_span, input, allow_plus)?; - return Ok(if star_token.is_some() { - Type::Verbatim(verbatim::between(begin, input)) - } else { - Type::TraitObject(TypeTraitObject { - dyn_token: Some(dyn_token), - bounds, - }) - }); - } - let ty: TypePath = input.parse()?; if ty.qself.is_some() { return Ok(Type::Path(ty)); } - if input.peek(Token![!]) && !input.peek(Token![!=]) { - let mut contains_arguments = false; - for segment in &ty.path.segments { - match segment.arguments { - PathArguments::None => {} - PathArguments::AngleBracketed(_) | PathArguments::Parenthesized(_) => { - contains_arguments = true; - } - } - } - - if !contains_arguments { - let bang_token: Token![!] = input.parse()?; - let (delimiter, tokens) = mac::parse_delimiter(input)?; - return Ok(Type::Macro(TypeMacro { - mac: Macro { - path: ty.path, - bang_token, - delimiter, - tokens, - }, - })); - } + if input.peek(Token![!]) && !input.peek(Token![!=]) && ty.path.is_mod_style() { + let bang_token: Token![!] = input.parse()?; + let (delimiter, tokens) = mac::parse_delimiter(input)?; + return Ok(Type::Macro(TypeMacro { + mac: Macro { + path: ty.path, + bang_token, + delimiter, + tokens, + }, + })); } if lifetimes.is_some() || allow_plus && input.peek(Token![+]) { @@ -619,6 +519,19 @@ pub mod parsing { } Ok(Type::Path(ty)) + } else if lookahead.peek(Token![dyn]) { + let dyn_token: Token![dyn] = input.parse()?; + let dyn_span = dyn_token.span; + let star_token: Option<Token![*]> = input.parse()?; + let bounds = TypeTraitObject::parse_bounds(dyn_span, input, allow_plus)?; + return Ok(if star_token.is_some() { + Type::Verbatim(verbatim::between(begin, input)) + } else { + Type::TraitObject(TypeTraitObject { + dyn_token: Some(dyn_token), + bounds, + }) + }); } else if lookahead.peek(token::Bracket) { let content; let bracket_token = bracketed!(content in input); @@ -716,61 +629,47 @@ pub mod parsing { #[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))] impl Parse for TypeBareFn { fn parse(input: ParseStream) -> Result<Self> { - let allow_mut_self = false; - parse_bare_fn(input, allow_mut_self).map(Option::unwrap) - } - } - - fn parse_bare_fn(input: ParseStream, allow_mut_self: bool) -> Result<Option<TypeBareFn>> { - let args; - let mut variadic = None; - let mut has_mut_self = false; - - let bare_fn = TypeBareFn { - lifetimes: input.parse()?, - unsafety: input.parse()?, - abi: input.parse()?, - fn_token: input.parse()?, - paren_token: parenthesized!(args in input), - inputs: { - let mut inputs = Punctuated::new(); - - while !args.is_empty() { - let attrs = args.call(Attribute::parse_outer)?; - - if inputs.empty_or_trailing() && args.peek(Token![...]) { - variadic = Some(Variadic { - attrs, - dots: args.parse()?, - }); - break; - } + let args; + let mut variadic = None; + + Ok(TypeBareFn { + lifetimes: input.parse()?, + unsafety: input.parse()?, + abi: input.parse()?, + fn_token: input.parse()?, + paren_token: parenthesized!(args in input), + inputs: { + let mut inputs = Punctuated::new(); + + while !args.is_empty() { + let attrs = args.call(Attribute::parse_outer)?; + + if inputs.empty_or_trailing() + && (args.peek(Token![...]) + || args.peek(Ident) + && args.peek2(Token![:]) + && args.peek3(Token![...])) + { + variadic = Some(parse_bare_variadic(&args, attrs)?); + break; + } - if let Some(arg) = parse_bare_fn_arg(&args, allow_mut_self)? { + let allow_self = inputs.is_empty(); + let arg = parse_bare_fn_arg(&args, allow_self)?; inputs.push_value(BareFnArg { attrs, ..arg }); - } else { - has_mut_self = true; - } - if args.is_empty() { - break; - } + if args.is_empty() { + break; + } - let comma = args.parse()?; - if !has_mut_self { + let comma = args.parse()?; inputs.push_punct(comma); } - } - inputs - }, - variadic, - output: input.call(ReturnType::without_plus)?, - }; - - if has_mut_self { - Ok(None) - } else { - Ok(Some(bare_fn)) + inputs + }, + variadic, + output: input.call(ReturnType::without_plus)?, + }) } } @@ -838,29 +737,7 @@ pub mod parsing { impl Parse for TypePath { fn parse(input: ParseStream) -> Result<Self> { let expr_style = false; - let (qself, mut path) = path::parsing::qpath(input, expr_style)?; - - while path.segments.last().unwrap().arguments.is_empty() - && (input.peek(token::Paren) || input.peek(Token![::]) && input.peek3(token::Paren)) - { - input.parse::<Option<Token![::]>>()?; - let args: ParenthesizedGenericArguments = input.parse()?; - let allow_associated_type = cfg!(feature = "full") - && match &args.output { - ReturnType::Default => true, - ReturnType::Type(_, ty) => match **ty { - // TODO: probably some of the other kinds allow this too. - Type::Paren(_) => true, - _ => false, - }, - }; - let parenthesized = PathArguments::Parenthesized(args); - path.segments.last_mut().unwrap().arguments = parenthesized; - if allow_associated_type { - Path::parse_rest(input, &mut path, expr_style)?; - } - } - + let (qself, path) = path::parsing::qpath(input, expr_style)?; Ok(TypePath { qself, path }) } } @@ -928,7 +805,7 @@ pub mod parsing { let mut at_least_one_trait = false; for bound in &bounds { match bound { - TypeParamBound::Trait(_) => { + TypeParamBound::Trait(_) | TypeParamBound::Verbatim(_) => { at_least_one_trait = true; break; } @@ -968,7 +845,7 @@ pub mod parsing { let mut at_least_one_trait = false; for bound in &bounds { match bound { - TypeParamBound::Trait(_) => { + TypeParamBound::Trait(_) | TypeParamBound::Verbatim(_) => { at_least_one_trait = true; break; } @@ -1024,75 +901,72 @@ pub mod parsing { #[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))] impl Parse for BareFnArg { fn parse(input: ParseStream) -> Result<Self> { - let allow_mut_self = false; - parse_bare_fn_arg(input, allow_mut_self).map(Option::unwrap) + let allow_self = false; + parse_bare_fn_arg(input, allow_self) } } - fn parse_bare_fn_arg( - input: ParseStream, - mut allow_mut_self: bool, - ) -> Result<Option<BareFnArg>> { - let mut has_mut_self = false; - let arg = BareFnArg { - attrs: input.call(Attribute::parse_outer)?, - name: { - if (input.peek(Ident) || input.peek(Token![_]) || input.peek(Token![self])) - && input.peek2(Token![:]) - && !input.peek2(Token![::]) - { - let name = input.call(Ident::parse_any)?; - let colon: Token![:] = input.parse()?; - Some((name, colon)) - } else if allow_mut_self - && input.peek(Token![mut]) - && input.peek2(Token![self]) - && input.peek3(Token![:]) - && !input.peek3(Token![::]) - { - has_mut_self = true; - allow_mut_self = false; - input.parse::<Token![mut]>()?; - input.parse::<Token![self]>()?; - input.parse::<Token![:]>()?; - None - } else { - None - } - }, - ty: if !has_mut_self && input.peek(Token![...]) { - let dot3 = input.parse::<Token![...]>()?; - let args = vec![ - TokenTree::Punct(Punct::new('.', Spacing::Joint)), - TokenTree::Punct(Punct::new('.', Spacing::Joint)), - TokenTree::Punct(Punct::new('.', Spacing::Alone)), - ]; - let tokens: TokenStream = args - .into_iter() - .zip(&dot3.spans) - .map(|(mut arg, span)| { - arg.set_span(*span); - arg - }) - .collect(); - Type::Verbatim(tokens) - } else if allow_mut_self && input.peek(Token![mut]) && input.peek2(Token![self]) { - has_mut_self = true; - input.parse::<Token![mut]>()?; - Type::Path(TypePath { - qself: None, - path: input.parse::<Token![self]>()?.into(), - }) - } else { - input.parse()? - }, - }; + fn parse_bare_fn_arg(input: ParseStream, allow_self: bool) -> Result<BareFnArg> { + let attrs = input.call(Attribute::parse_outer)?; + + let begin = input.fork(); + let has_mut_self = allow_self && input.peek(Token![mut]) && input.peek2(Token![self]); if has_mut_self { - Ok(None) - } else { - Ok(Some(arg)) + input.parse::<Token![mut]>()?; } + + let mut has_self = false; + let mut name = if (input.peek(Ident) || input.peek(Token![_]) || { + has_self = allow_self && input.peek(Token![self]); + has_self + }) && input.peek2(Token![:]) + && !input.peek2(Token![::]) + { + let name = input.call(Ident::parse_any)?; + let colon: Token![:] = input.parse()?; + Some((name, colon)) + } else { + has_self = false; + None + }; + + let ty = if allow_self && !has_self && input.peek(Token![mut]) && input.peek2(Token![self]) + { + input.parse::<Token![mut]>()?; + input.parse::<Token![self]>()?; + None + } else if has_mut_self && name.is_none() { + input.parse::<Token![self]>()?; + None + } else { + Some(input.parse()?) + }; + + let ty = match ty { + Some(ty) if !has_mut_self => ty, + _ => { + name = None; + Type::Verbatim(verbatim::between(begin, input)) + } + }; + + Ok(BareFnArg { attrs, name, ty }) + } + + fn parse_bare_variadic(input: ParseStream, attrs: Vec<Attribute>) -> Result<BareVariadic> { + Ok(BareVariadic { + attrs, + name: if input.peek(Ident) || input.peek(Token![_]) { + let name = input.call(Ident::parse_any)?; + let colon: Token![:] = input.parse()?; + Some((name, colon)) + } else { + None + }, + dots: input.parse()?, + comma: input.parse()?, + }) } #[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))] @@ -1287,10 +1161,15 @@ mod printing { } #[cfg_attr(doc_cfg, doc(cfg(feature = "printing")))] - impl ToTokens for Variadic { + impl ToTokens for BareVariadic { fn to_tokens(&self, tokens: &mut TokenStream) { tokens.append_all(self.attrs.outer()); + if let Some((name, colon)) = &self.name { + name.to_tokens(tokens); + colon.to_tokens(tokens); + } self.dots.to_tokens(tokens); + self.comma.to_tokens(tokens); } } diff --git a/vendor/syn/src/verbatim.rs b/vendor/syn/src/verbatim.rs index 58cf68d17..436d87343 100644 --- a/vendor/syn/src/verbatim.rs +++ b/vendor/syn/src/verbatim.rs @@ -3,7 +3,7 @@ use proc_macro2::{Delimiter, TokenStream}; use std::cmp::Ordering; use std::iter; -pub fn between<'a>(begin: ParseBuffer<'a>, end: ParseStream<'a>) -> TokenStream { +pub(crate) fn between<'a>(begin: ParseBuffer<'a>, end: ParseStream<'a>) -> TokenStream { let end = end.cursor(); let mut cursor = begin.cursor(); assert!(crate::buffer::same_buffer(end, cursor)); diff --git a/vendor/syn/src/whitespace.rs b/vendor/syn/src/whitespace.rs index 7be082e1a..f8de1b986 100644 --- a/vendor/syn/src/whitespace.rs +++ b/vendor/syn/src/whitespace.rs @@ -1,4 +1,4 @@ -pub fn skip(mut s: &str) -> &str { +pub(crate) fn skip(mut s: &str) -> &str { 'skip: while !s.is_empty() { let byte = s.as_bytes()[0]; if byte == b'/' { diff --git a/vendor/syn/tests/common/eq.rs b/vendor/syn/tests/common/eq.rs index 41d6d4118..70a533768 100644 --- a/vendor/syn/tests/common/eq.rs +++ b/vendor/syn/tests/common/eq.rs @@ -2,6 +2,7 @@ extern crate rustc_ast; extern crate rustc_data_structures; +extern crate rustc_driver; extern crate rustc_span; extern crate thin_vec; @@ -48,6 +49,20 @@ use rustc_ast::ast::FnRetTy; use rustc_ast::ast::FnSig; use rustc_ast::ast::ForeignItemKind; use rustc_ast::ast::ForeignMod; +use rustc_ast::ast::FormatAlignment; +use rustc_ast::ast::FormatArgPosition; +use rustc_ast::ast::FormatArgPositionKind; +use rustc_ast::ast::FormatArgs; +use rustc_ast::ast::FormatArgsPiece; +use rustc_ast::ast::FormatArgument; +use rustc_ast::ast::FormatArgumentKind; +use rustc_ast::ast::FormatArguments; +use rustc_ast::ast::FormatCount; +use rustc_ast::ast::FormatDebugHex; +use rustc_ast::ast::FormatOptions; +use rustc_ast::ast::FormatPlaceholder; +use rustc_ast::ast::FormatSign; +use rustc_ast::ast::FormatTrait; use rustc_ast::ast::GenericArg; use rustc_ast::ast::GenericArgs; use rustc_ast::ast::GenericBound; @@ -140,6 +155,8 @@ use rustc_data_structures::sync::Lrc; use rustc_span::source_map::Spanned; use rustc_span::symbol::{sym, Ident}; use rustc_span::{Span, Symbol, SyntaxContext, DUMMY_SP}; +use std::collections::HashMap; +use std::hash::{BuildHasher, Hash}; use thin_vec::ThinVec; pub trait SpanlessEq { @@ -174,6 +191,16 @@ impl<T: SpanlessEq> SpanlessEq for Option<T> { } } +impl<T: SpanlessEq, E: SpanlessEq> SpanlessEq for Result<T, E> { + fn eq(&self, other: &Self) -> bool { + match (self, other) { + (Ok(this), Ok(other)) => SpanlessEq::eq(this, other), + (Err(this), Err(other)) => SpanlessEq::eq(this, other), + _ => false, + } + } +} + impl<T: SpanlessEq> SpanlessEq for [T] { fn eq(&self, other: &Self) -> bool { self.len() == other.len() && self.iter().zip(other).all(|(a, b)| SpanlessEq::eq(a, b)) @@ -196,6 +223,17 @@ impl<T: SpanlessEq> SpanlessEq for ThinVec<T> { } } +impl<K: Eq + Hash, V: SpanlessEq, S: BuildHasher> SpanlessEq for HashMap<K, V, S> { + fn eq(&self, other: &Self) -> bool { + self.len() == other.len() + && self.iter().all(|(key, this_v)| { + other + .get(key) + .map_or(false, |other_v| SpanlessEq::eq(this_v, other_v)) + }) + } +} + impl<T: SpanlessEq> SpanlessEq for Spanned<T> { fn eq(&self, other: &Self) -> bool { SpanlessEq::eq(&self.node, &other.node) @@ -246,6 +284,7 @@ macro_rules! spanless_eq_partial_eq { spanless_eq_partial_eq!(bool); spanless_eq_partial_eq!(u8); spanless_eq_partial_eq!(u16); +spanless_eq_partial_eq!(u32); spanless_eq_partial_eq!(u128); spanless_eq_partial_eq!(usize); spanless_eq_partial_eq!(char); @@ -414,18 +453,23 @@ spanless_eq_struct!(AttributesData; attrs tokens); spanless_eq_struct!(BareFnTy; unsafety ext generic_params decl decl_span); spanless_eq_struct!(BindingAnnotation; 0 1); spanless_eq_struct!(Block; stmts id rules span tokens could_be_bare_literal); -spanless_eq_struct!(Closure; binder capture_clause asyncness movability fn_decl body !fn_decl_span); +spanless_eq_struct!(Closure; binder capture_clause constness asyncness movability fn_decl body !fn_decl_span !fn_arg_span); spanless_eq_struct!(Crate; attrs items spans id is_placeholder); spanless_eq_struct!(DelimArgs; dspan delim tokens); spanless_eq_struct!(EnumDef; variants); spanless_eq_struct!(Expr; id kind span attrs !tokens); spanless_eq_struct!(ExprField; attrs id span ident expr is_shorthand is_placeholder); spanless_eq_struct!(FieldDef; attrs id span vis ident ty is_placeholder); +spanless_eq_struct!(Fn; defaultness generics sig body); spanless_eq_struct!(FnDecl; inputs output); spanless_eq_struct!(FnHeader; constness asyncness unsafety ext); -spanless_eq_struct!(Fn; defaultness generics sig body); spanless_eq_struct!(FnSig; header decl span); spanless_eq_struct!(ForeignMod; unsafety abi items); +spanless_eq_struct!(FormatArgPosition; index kind span); +spanless_eq_struct!(FormatArgs; span template arguments); +spanless_eq_struct!(FormatArgument; kind expr); +spanless_eq_struct!(FormatOptions; width precision alignment fill sign alternate zero_pad debug_hex); +spanless_eq_struct!(FormatPlaceholder; argument span format_trait format_options); spanless_eq_struct!(GenericParam; id ident attrs bounds is_placeholder kind !colon_span); spanless_eq_struct!(Generics; params where_clause span); spanless_eq_struct!(Impl; defaultness unsafety generics constness polarity of_trait self_ty items); @@ -439,7 +483,7 @@ spanless_eq_struct!(Local; pat ty kind id span attrs !tokens); spanless_eq_struct!(MacCall; path args prior_type_ascription); spanless_eq_struct!(MacCallStmt; mac style attrs tokens); spanless_eq_struct!(MacroDef; body macro_rules); -spanless_eq_struct!(MetaItemLit; token_lit kind span); +spanless_eq_struct!(MetaItemLit; symbol suffix kind span); spanless_eq_struct!(MethodCall; seg receiver args !span); spanless_eq_struct!(ModSpans; !inner_span !inject_use_span); spanless_eq_struct!(MutTy; ty mutbl); @@ -452,7 +496,7 @@ spanless_eq_struct!(PathSegment; ident id args); spanless_eq_struct!(PolyTraitRef; bound_generic_params trait_ref span); spanless_eq_struct!(QSelf; ty path_span position); spanless_eq_struct!(Stmt; id kind span); -spanless_eq_struct!(StrLit; style symbol suffix span symbol_unescaped); +spanless_eq_struct!(StrLit; symbol suffix symbol_unescaped style span); spanless_eq_struct!(StructExpr; qself path fields rest); spanless_eq_struct!(Token; kind span); spanless_eq_struct!(Trait; unsafety is_auto generics bounds items); @@ -468,8 +512,8 @@ spanless_eq_struct!(WhereClause; has_where_token predicates span); spanless_eq_struct!(WhereEqPredicate; span lhs_ty rhs_ty); spanless_eq_struct!(WhereRegionPredicate; span lifetime bounds); spanless_eq_enum!(AngleBracketedArg; Arg(0) Constraint(0)); -spanless_eq_enum!(AssocItemKind; Const(0 1 2) Fn(0) Type(0) MacCall(0)); spanless_eq_enum!(AssocConstraintKind; Equality(term) Bound(bounds)); +spanless_eq_enum!(AssocItemKind; Const(0 1 2) Fn(0) Type(0) MacCall(0)); spanless_eq_enum!(Async; Yes(span closure_id return_impl_trait_id) No); spanless_eq_enum!(AttrArgs; Empty Delimited(0) Eq(0 1)); spanless_eq_enum!(AttrArgsEq; Ast(0) Hir(0)); @@ -487,6 +531,14 @@ spanless_eq_enum!(Extern; None Implicit(0) Explicit(0 1)); spanless_eq_enum!(FloatTy; F32 F64); spanless_eq_enum!(FnRetTy; Default(0) Ty(0)); spanless_eq_enum!(ForeignItemKind; Static(0 1 2) Fn(0) TyAlias(0) MacCall(0)); +spanless_eq_enum!(FormatAlignment; Left Right Center); +spanless_eq_enum!(FormatArgPositionKind; Implicit Number Named); +spanless_eq_enum!(FormatArgsPiece; Literal(0) Placeholder(0)); +spanless_eq_enum!(FormatArgumentKind; Normal Named(0) Captured(0)); +spanless_eq_enum!(FormatCount; Literal(0) Argument(0)); +spanless_eq_enum!(FormatDebugHex; Lower Upper); +spanless_eq_enum!(FormatSign; Plus Minus); +spanless_eq_enum!(FormatTrait; Display Debug LowerExp UpperExp Octal Pointer Binary LowerHex UpperHex); spanless_eq_enum!(GenericArg; Lifetime(0) Type(0) Const(0)); spanless_eq_enum!(GenericArgs; AngleBracketed(0) Parenthesized(0)); spanless_eq_enum!(GenericBound; Trait(0 1) Outlives(0)); @@ -522,26 +574,25 @@ spanless_eq_enum!(UseTreeKind; Simple(0) Nested(0) Glob); spanless_eq_enum!(VariantData; Struct(0 1) Tuple(0 1) Unit(0)); spanless_eq_enum!(VisibilityKind; Public Restricted(path id shorthand) Inherited); spanless_eq_enum!(WherePredicate; BoundPredicate(0) RegionPredicate(0) EqPredicate(0)); -spanless_eq_enum!(ExprKind; Box(0) Array(0) ConstBlock(0) Call(0 1) - MethodCall(0) Tup(0) Binary(0 1 2) Unary(0 1) Lit(0) Cast(0 1) Type(0 1) - Let(0 1 2) If(0 1 2) While(0 1 2) ForLoop(0 1 2 3) Loop(0 1 2) Match(0 1) - Closure(0) Block(0 1) Async(0 1 2) Await(0) TryBlock(0) Assign(0 1 2) - AssignOp(0 1 2) Field(0 1) Index(0 1) Underscore Range(0 1 2) Path(0 1) - AddrOf(0 1 2) Break(0 1) Continue(0) Ret(0) InlineAsm(0) MacCall(0) - Struct(0) Repeat(0 1) Paren(0) Try(0) Yield(0) Yeet(0) IncludedBytes(0) - Err); +spanless_eq_enum!(ExprKind; Array(0) ConstBlock(0) Call(0 1) MethodCall(0) + Tup(0) Binary(0 1 2) Unary(0 1) Lit(0) Cast(0 1) Type(0 1) Let(0 1 2) + If(0 1 2) While(0 1 2) ForLoop(0 1 2 3) Loop(0 1 2) Match(0 1) Closure(0) + Block(0 1) Async(0 1 2) Await(0) TryBlock(0) Assign(0 1 2) AssignOp(0 1 2) + Field(0 1) Index(0 1) Underscore Range(0 1 2) Path(0 1) AddrOf(0 1 2) + Break(0 1) Continue(0) Ret(0) InlineAsm(0) MacCall(0) Struct(0) Repeat(0 1) + Paren(0) Try(0) Yield(0) Yeet(0) IncludedBytes(0) FormatArgs(0) Err); spanless_eq_enum!(InlineAsmOperand; In(reg expr) Out(reg late expr) InOut(reg late expr) SplitInOut(reg late in_expr out_expr) Const(anon_const) Sym(sym)); spanless_eq_enum!(ItemKind; ExternCrate(0) Use(0) Static(0 1 2) Const(0 1 2) Fn(0) Mod(0 1) ForeignMod(0) GlobalAsm(0) TyAlias(0) Enum(0 1) Struct(0 1) Union(0 1) Trait(0) TraitAlias(0 1) Impl(0) MacCall(0) MacroDef(0)); -spanless_eq_enum!(LitKind; Str(0 1) ByteStr(0) Byte(0) Char(0) Int(0 1) +spanless_eq_enum!(LitKind; Str(0 1) ByteStr(0 1) Byte(0) Char(0) Int(0 1) Float(0 1) Bool(0) Err); spanless_eq_enum!(PatKind; Wild Ident(0 1 2) Struct(0 1 2 3) TupleStruct(0 1 2) Or(0) Path(0 1) Tuple(0) Box(0) Ref(0 1) Lit(0) Range(0 1 2) Slice(0) Rest Paren(0) MacCall(0)); -spanless_eq_enum!(TyKind; Slice(0) Array(0 1) Ptr(0) Rptr(0 1) BareFn(0) Never +spanless_eq_enum!(TyKind; Slice(0) Array(0 1) Ptr(0) Ref(0 1) BareFn(0) Never Tup(0) Path(0 1) TraitObject(0 1) ImplTrait(0 1) Paren(0) Typeof(0) Infer ImplicitSelf MacCall(0) Err CVarArgs); @@ -591,7 +642,7 @@ impl SpanlessEq for TokenKind { fn eq(&self, other: &Self) -> bool { match (self, other) { (TokenKind::Literal(this), TokenKind::Literal(other)) => SpanlessEq::eq(this, other), - (TokenKind::DotDotEq, _) | (TokenKind::DotDotDot, _) => match other { + (TokenKind::DotDotEq | TokenKind::DotDotDot, _) => match other { TokenKind::DotDotEq | TokenKind::DotDotDot => true, _ => false, }, @@ -734,12 +785,8 @@ fn is_escaped_literal_attr_args(value: &AttrArgsEq, unescaped: Symbol) -> bool { fn is_escaped_literal_meta_item_lit(lit: &MetaItemLit, unescaped: Symbol) -> bool { match lit { MetaItemLit { - token_lit: - Lit { - kind: token::LitKind::Str, - symbol: _, - suffix: None, - }, + symbol: _, + suffix: None, kind, span: _, } => is_escaped_lit_kind(kind, unescaped), @@ -804,3 +851,9 @@ impl SpanlessEq for AttrKind { } } } + +impl SpanlessEq for FormatArguments { + fn eq(&self, other: &Self) -> bool { + SpanlessEq::eq(self.all_args(), other.all_args()) + } +} diff --git a/vendor/syn/tests/common/parse.rs b/vendor/syn/tests/common/parse.rs index 636d0a37a..73be10186 100644 --- a/vendor/syn/tests/common/parse.rs +++ b/vendor/syn/tests/common/parse.rs @@ -1,4 +1,5 @@ extern crate rustc_ast; +extern crate rustc_driver; extern crate rustc_expand; extern crate rustc_parse as parse; extern crate rustc_session; @@ -13,7 +14,9 @@ use std::panic; pub fn librustc_expr(input: &str) -> Option<P<ast::Expr>> { match panic::catch_unwind(|| { - let sess = ParseSess::new(FilePathMapping::empty()); + let locale_resources = rustc_driver::DEFAULT_LOCALE_RESOURCES.to_vec(); + let file_path_mapping = FilePathMapping::empty(); + let sess = ParseSess::new(locale_resources, file_path_mapping); let e = parse::new_parser_from_source_str( &sess, FileName::Custom("test_precedence".to_string()), diff --git a/vendor/syn/tests/debug/gen.rs b/vendor/syn/tests/debug/gen.rs index cfd63d117..b64cc3e7e 100644 --- a/vendor/syn/tests/debug/gen.rs +++ b/vendor/syn/tests/debug/gen.rs @@ -1,22 +1,21 @@ // This file is @generated by syn-internal-codegen. // It is not intended for manual editing. -use super::{Lite, RefCast}; +#![allow(clippy::match_wildcard_for_single_variants)] +use super::{Lite, Present}; +use ref_cast::RefCast; use std::fmt::{self, Debug, Display}; impl Debug for Lite<syn::Abi> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("Abi"); - if let Some(val) = &_val.name { + if let Some(val) = &self.value.name { #[derive(RefCast)] #[repr(transparent)] struct Print(syn::LitStr); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - let _val = &self.0; - formatter.write_str("(")?; - Debug::fmt(Lite(_val), formatter)?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0), formatter)?; formatter.write_str(")")?; Ok(()) } @@ -28,73 +27,94 @@ impl Debug for Lite<syn::Abi> { } impl Debug for Lite<syn::AngleBracketedGenericArguments> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("AngleBracketedGenericArguments"); - if let Some(val) = &_val.colon2_token { + if self.value.colon2_token.is_some() { + formatter.field("colon2_token", &Present); + } + if !self.value.args.is_empty() { + formatter.field("args", Lite(&self.value.args)); + } + formatter.finish() + } +} +impl Debug for Lite<syn::Arm> { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + let mut formatter = formatter.debug_struct("Arm"); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); + } + formatter.field("pat", Lite(&self.value.pat)); + if let Some(val) = &self.value.guard { #[derive(RefCast)] #[repr(transparent)] - struct Print(syn::token::Colon2); + struct Print((syn::token::If, Box<syn::Expr>)); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0.1), formatter)?; + formatter.write_str(")")?; Ok(()) } } - formatter.field("colon2_token", Print::ref_cast(val)); + formatter.field("guard", Print::ref_cast(val)); } - if !_val.args.is_empty() { - formatter.field("args", Lite(&_val.args)); + formatter.field("body", Lite(&self.value.body)); + if self.value.comma.is_some() { + formatter.field("comma", &Present); } formatter.finish() } } -impl Debug for Lite<syn::Arm> { +impl Debug for Lite<syn::AssocConst> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; - let mut formatter = formatter.debug_struct("Arm"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); - } - formatter.field("pat", Lite(&_val.pat)); - if let Some(val) = &_val.guard { + let mut formatter = formatter.debug_struct("AssocConst"); + formatter.field("ident", Lite(&self.value.ident)); + if let Some(val) = &self.value.generics { #[derive(RefCast)] #[repr(transparent)] - struct Print((syn::token::If, Box<syn::Expr>)); + struct Print(syn::AngleBracketedGenericArguments); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - let _val = &self.0; - formatter.write_str("(")?; - Debug::fmt(Lite(&_val.1), formatter)?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0), formatter)?; formatter.write_str(")")?; Ok(()) } } - formatter.field("guard", Print::ref_cast(val)); + formatter.field("generics", Print::ref_cast(val)); } - formatter.field("body", Lite(&_val.body)); - if let Some(val) = &_val.comma { + formatter.field("value", Lite(&self.value.value)); + formatter.finish() + } +} +impl Debug for Lite<syn::AssocType> { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + let mut formatter = formatter.debug_struct("AssocType"); + formatter.field("ident", Lite(&self.value.ident)); + if let Some(val) = &self.value.generics { #[derive(RefCast)] #[repr(transparent)] - struct Print(syn::token::Comma); + struct Print(syn::AngleBracketedGenericArguments); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0), formatter)?; + formatter.write_str(")")?; Ok(()) } } - formatter.field("comma", Print::ref_cast(val)); + formatter.field("generics", Print::ref_cast(val)); } + formatter.field("ty", Lite(&self.value.ty)); formatter.finish() } } impl Debug for Lite<syn::AttrStyle> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; - match _val { - syn::AttrStyle::Outer => formatter.write_str("Outer"), + match &self.value { + syn::AttrStyle::Outer => formatter.write_str("AttrStyle::Outer"), syn::AttrStyle::Inner(_val) => { - formatter.write_str("Inner")?; + formatter.write_str("AttrStyle::Inner")?; Ok(()) } } @@ -102,220 +122,218 @@ impl Debug for Lite<syn::AttrStyle> { } impl Debug for Lite<syn::Attribute> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("Attribute"); - formatter.field("style", Lite(&_val.style)); - formatter.field("path", Lite(&_val.path)); - formatter.field("tokens", Lite(&_val.tokens)); + formatter.field("style", Lite(&self.value.style)); + formatter.field("meta", Lite(&self.value.meta)); formatter.finish() } } impl Debug for Lite<syn::BareFnArg> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("BareFnArg"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - if let Some(val) = &_val.name { + if let Some(val) = &self.value.name { #[derive(RefCast)] #[repr(transparent)] struct Print((proc_macro2::Ident, syn::token::Colon)); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - let _val = &self.0; - formatter.write_str("(")?; - Debug::fmt(Lite(&_val.0), formatter)?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0.0), formatter)?; formatter.write_str(")")?; Ok(()) } } formatter.field("name", Print::ref_cast(val)); } - formatter.field("ty", Lite(&_val.ty)); + formatter.field("ty", Lite(&self.value.ty)); + formatter.finish() + } +} +impl Debug for Lite<syn::BareVariadic> { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + let mut formatter = formatter.debug_struct("BareVariadic"); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); + } + if let Some(val) = &self.value.name { + #[derive(RefCast)] + #[repr(transparent)] + struct Print((proc_macro2::Ident, syn::token::Colon)); + impl Debug for Print { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0.0), formatter)?; + formatter.write_str(")")?; + Ok(()) + } + } + formatter.field("name", Print::ref_cast(val)); + } + if self.value.comma.is_some() { + formatter.field("comma", &Present); + } formatter.finish() } } impl Debug for Lite<syn::BinOp> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; - match _val { + match &self.value { syn::BinOp::Add(_val) => { - formatter.write_str("Add")?; + formatter.write_str("BinOp::Add")?; Ok(()) } syn::BinOp::Sub(_val) => { - formatter.write_str("Sub")?; + formatter.write_str("BinOp::Sub")?; Ok(()) } syn::BinOp::Mul(_val) => { - formatter.write_str("Mul")?; + formatter.write_str("BinOp::Mul")?; Ok(()) } syn::BinOp::Div(_val) => { - formatter.write_str("Div")?; + formatter.write_str("BinOp::Div")?; Ok(()) } syn::BinOp::Rem(_val) => { - formatter.write_str("Rem")?; + formatter.write_str("BinOp::Rem")?; Ok(()) } syn::BinOp::And(_val) => { - formatter.write_str("And")?; + formatter.write_str("BinOp::And")?; Ok(()) } syn::BinOp::Or(_val) => { - formatter.write_str("Or")?; + formatter.write_str("BinOp::Or")?; Ok(()) } syn::BinOp::BitXor(_val) => { - formatter.write_str("BitXor")?; + formatter.write_str("BinOp::BitXor")?; Ok(()) } syn::BinOp::BitAnd(_val) => { - formatter.write_str("BitAnd")?; + formatter.write_str("BinOp::BitAnd")?; Ok(()) } syn::BinOp::BitOr(_val) => { - formatter.write_str("BitOr")?; + formatter.write_str("BinOp::BitOr")?; Ok(()) } syn::BinOp::Shl(_val) => { - formatter.write_str("Shl")?; + formatter.write_str("BinOp::Shl")?; Ok(()) } syn::BinOp::Shr(_val) => { - formatter.write_str("Shr")?; + formatter.write_str("BinOp::Shr")?; Ok(()) } syn::BinOp::Eq(_val) => { - formatter.write_str("Eq")?; + formatter.write_str("BinOp::Eq")?; Ok(()) } syn::BinOp::Lt(_val) => { - formatter.write_str("Lt")?; + formatter.write_str("BinOp::Lt")?; Ok(()) } syn::BinOp::Le(_val) => { - formatter.write_str("Le")?; + formatter.write_str("BinOp::Le")?; Ok(()) } syn::BinOp::Ne(_val) => { - formatter.write_str("Ne")?; + formatter.write_str("BinOp::Ne")?; Ok(()) } syn::BinOp::Ge(_val) => { - formatter.write_str("Ge")?; + formatter.write_str("BinOp::Ge")?; Ok(()) } syn::BinOp::Gt(_val) => { - formatter.write_str("Gt")?; + formatter.write_str("BinOp::Gt")?; Ok(()) } - syn::BinOp::AddEq(_val) => { - formatter.write_str("AddEq")?; + syn::BinOp::AddAssign(_val) => { + formatter.write_str("BinOp::AddAssign")?; Ok(()) } - syn::BinOp::SubEq(_val) => { - formatter.write_str("SubEq")?; + syn::BinOp::SubAssign(_val) => { + formatter.write_str("BinOp::SubAssign")?; Ok(()) } - syn::BinOp::MulEq(_val) => { - formatter.write_str("MulEq")?; + syn::BinOp::MulAssign(_val) => { + formatter.write_str("BinOp::MulAssign")?; Ok(()) } - syn::BinOp::DivEq(_val) => { - formatter.write_str("DivEq")?; + syn::BinOp::DivAssign(_val) => { + formatter.write_str("BinOp::DivAssign")?; Ok(()) } - syn::BinOp::RemEq(_val) => { - formatter.write_str("RemEq")?; + syn::BinOp::RemAssign(_val) => { + formatter.write_str("BinOp::RemAssign")?; Ok(()) } - syn::BinOp::BitXorEq(_val) => { - formatter.write_str("BitXorEq")?; + syn::BinOp::BitXorAssign(_val) => { + formatter.write_str("BinOp::BitXorAssign")?; Ok(()) } - syn::BinOp::BitAndEq(_val) => { - formatter.write_str("BitAndEq")?; + syn::BinOp::BitAndAssign(_val) => { + formatter.write_str("BinOp::BitAndAssign")?; Ok(()) } - syn::BinOp::BitOrEq(_val) => { - formatter.write_str("BitOrEq")?; + syn::BinOp::BitOrAssign(_val) => { + formatter.write_str("BinOp::BitOrAssign")?; Ok(()) } - syn::BinOp::ShlEq(_val) => { - formatter.write_str("ShlEq")?; + syn::BinOp::ShlAssign(_val) => { + formatter.write_str("BinOp::ShlAssign")?; Ok(()) } - syn::BinOp::ShrEq(_val) => { - formatter.write_str("ShrEq")?; + syn::BinOp::ShrAssign(_val) => { + formatter.write_str("BinOp::ShrAssign")?; Ok(()) } + _ => unreachable!(), } } } -impl Debug for Lite<syn::Binding> { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; - let mut formatter = formatter.debug_struct("Binding"); - formatter.field("ident", Lite(&_val.ident)); - formatter.field("ty", Lite(&_val.ty)); - formatter.finish() - } -} impl Debug for Lite<syn::Block> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("Block"); - if !_val.stmts.is_empty() { - formatter.field("stmts", Lite(&_val.stmts)); + if !self.value.stmts.is_empty() { + formatter.field("stmts", Lite(&self.value.stmts)); } formatter.finish() } } impl Debug for Lite<syn::BoundLifetimes> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("BoundLifetimes"); - if !_val.lifetimes.is_empty() { - formatter.field("lifetimes", Lite(&_val.lifetimes)); + if !self.value.lifetimes.is_empty() { + formatter.field("lifetimes", Lite(&self.value.lifetimes)); } formatter.finish() } } impl Debug for Lite<syn::ConstParam> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("ConstParam"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - formatter.field("ident", Lite(&_val.ident)); - formatter.field("ty", Lite(&_val.ty)); - if let Some(val) = &_val.eq_token { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Eq); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } - } - formatter.field("eq_token", Print::ref_cast(val)); + formatter.field("ident", Lite(&self.value.ident)); + formatter.field("ty", Lite(&self.value.ty)); + if self.value.eq_token.is_some() { + formatter.field("eq_token", &Present); } - if let Some(val) = &_val.default { + if let Some(val) = &self.value.default { #[derive(RefCast)] #[repr(transparent)] struct Print(syn::Expr); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - let _val = &self.0; - formatter.write_str("(")?; - Debug::fmt(Lite(_val), formatter)?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0), formatter)?; formatter.write_str(")")?; Ok(()) } @@ -327,33 +345,36 @@ impl Debug for Lite<syn::ConstParam> { } impl Debug for Lite<syn::Constraint> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("Constraint"); - formatter.field("ident", Lite(&_val.ident)); - if !_val.bounds.is_empty() { - formatter.field("bounds", Lite(&_val.bounds)); + formatter.field("ident", Lite(&self.value.ident)); + if let Some(val) = &self.value.generics { + #[derive(RefCast)] + #[repr(transparent)] + struct Print(syn::AngleBracketedGenericArguments); + impl Debug for Print { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0), formatter)?; + formatter.write_str(")")?; + Ok(()) + } + } + formatter.field("generics", Print::ref_cast(val)); + } + if !self.value.bounds.is_empty() { + formatter.field("bounds", Lite(&self.value.bounds)); } formatter.finish() } } impl Debug for Lite<syn::Data> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; - match _val { + match &self.value { syn::Data::Struct(_val) => { let mut formatter = formatter.debug_struct("Data::Struct"); formatter.field("fields", Lite(&_val.fields)); - if let Some(val) = &_val.semi_token { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Semi); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } - } - formatter.field("semi_token", Print::ref_cast(val)); + if _val.semi_token.is_some() { + formatter.field("semi_token", &Present); } formatter.finish() } @@ -374,60 +395,46 @@ impl Debug for Lite<syn::Data> { } impl Debug for Lite<syn::DataEnum> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("DataEnum"); - if !_val.variants.is_empty() { - formatter.field("variants", Lite(&_val.variants)); + if !self.value.variants.is_empty() { + formatter.field("variants", Lite(&self.value.variants)); } formatter.finish() } } impl Debug for Lite<syn::DataStruct> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("DataStruct"); - formatter.field("fields", Lite(&_val.fields)); - if let Some(val) = &_val.semi_token { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Semi); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } - } - formatter.field("semi_token", Print::ref_cast(val)); + formatter.field("fields", Lite(&self.value.fields)); + if self.value.semi_token.is_some() { + formatter.field("semi_token", &Present); } formatter.finish() } } impl Debug for Lite<syn::DataUnion> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("DataUnion"); - formatter.field("fields", Lite(&_val.fields)); + formatter.field("fields", Lite(&self.value.fields)); formatter.finish() } } impl Debug for Lite<syn::DeriveInput> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("DeriveInput"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - formatter.field("vis", Lite(&_val.vis)); - formatter.field("ident", Lite(&_val.ident)); - formatter.field("generics", Lite(&_val.generics)); - formatter.field("data", Lite(&_val.data)); + formatter.field("vis", Lite(&self.value.vis)); + formatter.field("ident", Lite(&self.value.ident)); + formatter.field("generics", Lite(&self.value.generics)); + formatter.field("data", Lite(&self.value.data)); formatter.finish() } } impl Debug for Lite<syn::Expr> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; - match _val { + match &self.value { syn::Expr::Array(_val) => { let mut formatter = formatter.debug_struct("Expr::Array"); if !_val.attrs.is_empty() { @@ -447,32 +454,13 @@ impl Debug for Lite<syn::Expr> { formatter.field("right", Lite(&_val.right)); formatter.finish() } - syn::Expr::AssignOp(_val) => { - let mut formatter = formatter.debug_struct("Expr::AssignOp"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); - } - formatter.field("left", Lite(&_val.left)); - formatter.field("op", Lite(&_val.op)); - formatter.field("right", Lite(&_val.right)); - formatter.finish() - } syn::Expr::Async(_val) => { let mut formatter = formatter.debug_struct("Expr::Async"); if !_val.attrs.is_empty() { formatter.field("attrs", Lite(&_val.attrs)); } - if let Some(val) = &_val.capture { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Move); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } - } - formatter.field("capture", Print::ref_cast(val)); + if _val.capture.is_some() { + formatter.field("capture", &Present); } formatter.field("block", Lite(&_val.block)); formatter.finish() @@ -506,10 +494,8 @@ impl Debug for Lite<syn::Expr> { struct Print(syn::Label); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - let _val = &self.0; - formatter.write_str("(")?; - Debug::fmt(Lite(_val), formatter)?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0), formatter)?; formatter.write_str(")")?; Ok(()) } @@ -519,14 +505,6 @@ impl Debug for Lite<syn::Expr> { formatter.field("block", Lite(&_val.block)); formatter.finish() } - syn::Expr::Box(_val) => { - let mut formatter = formatter.debug_struct("Expr::Box"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); - } - formatter.field("expr", Lite(&_val.expr)); - formatter.finish() - } syn::Expr::Break(_val) => { let mut formatter = formatter.debug_struct("Expr::Break"); if !_val.attrs.is_empty() { @@ -538,10 +516,8 @@ impl Debug for Lite<syn::Expr> { struct Print(syn::Lifetime); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - let _val = &self.0; - formatter.write_str("(")?; - Debug::fmt(Lite(_val), formatter)?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0), formatter)?; formatter.write_str(")")?; Ok(()) } @@ -554,10 +530,8 @@ impl Debug for Lite<syn::Expr> { struct Print(Box<syn::Expr>); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - let _val = &self.0; - formatter.write_str("(")?; - Debug::fmt(Lite(_val), formatter)?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0), formatter)?; formatter.write_str(")")?; Ok(()) } @@ -591,41 +565,31 @@ impl Debug for Lite<syn::Expr> { if !_val.attrs.is_empty() { formatter.field("attrs", Lite(&_val.attrs)); } - if let Some(val) = &_val.movability { + if let Some(val) = &_val.lifetimes { #[derive(RefCast)] #[repr(transparent)] - struct Print(syn::token::Static); + struct Print(syn::BoundLifetimes); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0), formatter)?; + formatter.write_str(")")?; Ok(()) } } - formatter.field("movability", Print::ref_cast(val)); + formatter.field("lifetimes", Print::ref_cast(val)); } - if let Some(val) = &_val.asyncness { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Async); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } - } - formatter.field("asyncness", Print::ref_cast(val)); + if _val.constness.is_some() { + formatter.field("constness", &Present); } - if let Some(val) = &_val.capture { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Move); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } - } - formatter.field("capture", Print::ref_cast(val)); + if _val.movability.is_some() { + formatter.field("movability", &Present); + } + if _val.asyncness.is_some() { + formatter.field("asyncness", &Present); + } + if _val.capture.is_some() { + formatter.field("capture", &Present); } if !_val.inputs.is_empty() { formatter.field("inputs", Lite(&_val.inputs)); @@ -634,6 +598,14 @@ impl Debug for Lite<syn::Expr> { formatter.field("body", Lite(&_val.body)); formatter.finish() } + syn::Expr::Const(_val) => { + let mut formatter = formatter.debug_struct("Expr::Const"); + if !_val.attrs.is_empty() { + formatter.field("attrs", Lite(&_val.attrs)); + } + formatter.field("block", Lite(&_val.block)); + formatter.finish() + } syn::Expr::Continue(_val) => { let mut formatter = formatter.debug_struct("Expr::Continue"); if !_val.attrs.is_empty() { @@ -645,10 +617,8 @@ impl Debug for Lite<syn::Expr> { struct Print(syn::Lifetime); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - let _val = &self.0; - formatter.write_str("(")?; - Debug::fmt(Lite(_val), formatter)?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0), formatter)?; formatter.write_str(")")?; Ok(()) } @@ -677,10 +647,8 @@ impl Debug for Lite<syn::Expr> { struct Print(syn::Label); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - let _val = &self.0; - formatter.write_str("(")?; - Debug::fmt(Lite(_val), formatter)?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0), formatter)?; formatter.write_str(")")?; Ok(()) } @@ -713,10 +681,8 @@ impl Debug for Lite<syn::Expr> { struct Print((syn::token::Else, Box<syn::Expr>)); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - let _val = &self.0; - formatter.write_str("(")?; - Debug::fmt(Lite(&_val.1), formatter)?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0.1), formatter)?; formatter.write_str(")")?; Ok(()) } @@ -734,6 +700,13 @@ impl Debug for Lite<syn::Expr> { formatter.field("index", Lite(&_val.index)); formatter.finish() } + syn::Expr::Infer(_val) => { + let mut formatter = formatter.debug_struct("Expr::Infer"); + if !_val.attrs.is_empty() { + formatter.field("attrs", Lite(&_val.attrs)); + } + formatter.finish() + } syn::Expr::Let(_val) => { let mut formatter = formatter.debug_struct("Expr::Let"); if !_val.attrs.is_empty() { @@ -762,10 +735,8 @@ impl Debug for Lite<syn::Expr> { struct Print(syn::Label); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - let _val = &self.0; - formatter.write_str("(")?; - Debug::fmt(Lite(_val), formatter)?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0), formatter)?; formatter.write_str(")")?; Ok(()) } @@ -804,13 +775,11 @@ impl Debug for Lite<syn::Expr> { if let Some(val) = &_val.turbofish { #[derive(RefCast)] #[repr(transparent)] - struct Print(syn::MethodTurbofish); + struct Print(syn::AngleBracketedGenericArguments); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - let _val = &self.0; - formatter.write_str("(")?; - Debug::fmt(Lite(_val), formatter)?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0), formatter)?; formatter.write_str(")")?; Ok(()) } @@ -841,10 +810,8 @@ impl Debug for Lite<syn::Expr> { struct Print(syn::QSelf); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - let _val = &self.0; - formatter.write_str("(")?; - Debug::fmt(Lite(_val), formatter)?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0), formatter)?; formatter.write_str(")")?; Ok(()) } @@ -859,38 +826,34 @@ impl Debug for Lite<syn::Expr> { if !_val.attrs.is_empty() { formatter.field("attrs", Lite(&_val.attrs)); } - if let Some(val) = &_val.from { + if let Some(val) = &_val.start { #[derive(RefCast)] #[repr(transparent)] struct Print(Box<syn::Expr>); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - let _val = &self.0; - formatter.write_str("(")?; - Debug::fmt(Lite(_val), formatter)?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0), formatter)?; formatter.write_str(")")?; Ok(()) } } - formatter.field("from", Print::ref_cast(val)); + formatter.field("start", Print::ref_cast(val)); } formatter.field("limits", Lite(&_val.limits)); - if let Some(val) = &_val.to { + if let Some(val) = &_val.end { #[derive(RefCast)] #[repr(transparent)] struct Print(Box<syn::Expr>); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - let _val = &self.0; - formatter.write_str("(")?; - Debug::fmt(Lite(_val), formatter)?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0), formatter)?; formatter.write_str(")")?; Ok(()) } } - formatter.field("to", Print::ref_cast(val)); + formatter.field("end", Print::ref_cast(val)); } formatter.finish() } @@ -899,17 +862,8 @@ impl Debug for Lite<syn::Expr> { if !_val.attrs.is_empty() { formatter.field("attrs", Lite(&_val.attrs)); } - if let Some(val) = &_val.mutability { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Mut); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } - } - formatter.field("mutability", Print::ref_cast(val)); + if _val.mutability.is_some() { + formatter.field("mutability", &Present); } formatter.field("expr", Lite(&_val.expr)); formatter.finish() @@ -934,10 +888,8 @@ impl Debug for Lite<syn::Expr> { struct Print(Box<syn::Expr>); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - let _val = &self.0; - formatter.write_str("(")?; - Debug::fmt(Lite(_val), formatter)?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0), formatter)?; formatter.write_str(")")?; Ok(()) } @@ -951,21 +903,26 @@ impl Debug for Lite<syn::Expr> { if !_val.attrs.is_empty() { formatter.field("attrs", Lite(&_val.attrs)); } - formatter.field("path", Lite(&_val.path)); - if !_val.fields.is_empty() { - formatter.field("fields", Lite(&_val.fields)); - } - if let Some(val) = &_val.dot2_token { + if let Some(val) = &_val.qself { #[derive(RefCast)] #[repr(transparent)] - struct Print(syn::token::Dot2); + struct Print(syn::QSelf); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0), formatter)?; + formatter.write_str(")")?; Ok(()) } } - formatter.field("dot2_token", Print::ref_cast(val)); + formatter.field("qself", Print::ref_cast(val)); + } + formatter.field("path", Lite(&_val.path)); + if !_val.fields.is_empty() { + formatter.field("fields", Lite(&_val.fields)); + } + if _val.dot2_token.is_some() { + formatter.field("dot2_token", &Present); } if let Some(val) = &_val.rest { #[derive(RefCast)] @@ -973,10 +930,8 @@ impl Debug for Lite<syn::Expr> { struct Print(Box<syn::Expr>); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - let _val = &self.0; - formatter.write_str("(")?; - Debug::fmt(Lite(_val), formatter)?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0), formatter)?; formatter.write_str(")")?; Ok(()) } @@ -1011,15 +966,6 @@ impl Debug for Lite<syn::Expr> { } formatter.finish() } - syn::Expr::Type(_val) => { - let mut formatter = formatter.debug_struct("Expr::Type"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); - } - formatter.field("expr", Lite(&_val.expr)); - formatter.field("ty", Lite(&_val.ty)); - formatter.finish() - } syn::Expr::Unary(_val) => { let mut formatter = formatter.debug_struct("Expr::Unary"); if !_val.attrs.is_empty() { @@ -1038,7 +984,7 @@ impl Debug for Lite<syn::Expr> { formatter.finish() } syn::Expr::Verbatim(_val) => { - formatter.write_str("Verbatim")?; + formatter.write_str("Expr::Verbatim")?; formatter.write_str("(`")?; Display::fmt(_val, formatter)?; formatter.write_str("`)")?; @@ -1055,10 +1001,8 @@ impl Debug for Lite<syn::Expr> { struct Print(syn::Label); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - let _val = &self.0; - formatter.write_str("(")?; - Debug::fmt(Lite(_val), formatter)?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0), formatter)?; formatter.write_str(")")?; Ok(()) } @@ -1080,10 +1024,8 @@ impl Debug for Lite<syn::Expr> { struct Print(Box<syn::Expr>); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - let _val = &self.0; - formatter.write_str("(")?; - Debug::fmt(Lite(_val), formatter)?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0), formatter)?; formatter.write_str(")")?; Ok(()) } @@ -1098,160 +1040,114 @@ impl Debug for Lite<syn::Expr> { } impl Debug for Lite<syn::ExprArray> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("ExprArray"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - if !_val.elems.is_empty() { - formatter.field("elems", Lite(&_val.elems)); + if !self.value.elems.is_empty() { + formatter.field("elems", Lite(&self.value.elems)); } formatter.finish() } } impl Debug for Lite<syn::ExprAssign> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("ExprAssign"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - formatter.field("left", Lite(&_val.left)); - formatter.field("right", Lite(&_val.right)); - formatter.finish() - } -} -impl Debug for Lite<syn::ExprAssignOp> { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; - let mut formatter = formatter.debug_struct("ExprAssignOp"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); - } - formatter.field("left", Lite(&_val.left)); - formatter.field("op", Lite(&_val.op)); - formatter.field("right", Lite(&_val.right)); + formatter.field("left", Lite(&self.value.left)); + formatter.field("right", Lite(&self.value.right)); formatter.finish() } } impl Debug for Lite<syn::ExprAsync> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("ExprAsync"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - if let Some(val) = &_val.capture { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Move); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } - } - formatter.field("capture", Print::ref_cast(val)); + if self.value.capture.is_some() { + formatter.field("capture", &Present); } - formatter.field("block", Lite(&_val.block)); + formatter.field("block", Lite(&self.value.block)); formatter.finish() } } impl Debug for Lite<syn::ExprAwait> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("ExprAwait"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - formatter.field("base", Lite(&_val.base)); + formatter.field("base", Lite(&self.value.base)); formatter.finish() } } impl Debug for Lite<syn::ExprBinary> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("ExprBinary"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - formatter.field("left", Lite(&_val.left)); - formatter.field("op", Lite(&_val.op)); - formatter.field("right", Lite(&_val.right)); + formatter.field("left", Lite(&self.value.left)); + formatter.field("op", Lite(&self.value.op)); + formatter.field("right", Lite(&self.value.right)); formatter.finish() } } impl Debug for Lite<syn::ExprBlock> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("ExprBlock"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - if let Some(val) = &_val.label { + if let Some(val) = &self.value.label { #[derive(RefCast)] #[repr(transparent)] struct Print(syn::Label); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - let _val = &self.0; - formatter.write_str("(")?; - Debug::fmt(Lite(_val), formatter)?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0), formatter)?; formatter.write_str(")")?; Ok(()) } } formatter.field("label", Print::ref_cast(val)); } - formatter.field("block", Lite(&_val.block)); - formatter.finish() - } -} -impl Debug for Lite<syn::ExprBox> { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; - let mut formatter = formatter.debug_struct("ExprBox"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); - } - formatter.field("expr", Lite(&_val.expr)); + formatter.field("block", Lite(&self.value.block)); formatter.finish() } } impl Debug for Lite<syn::ExprBreak> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("ExprBreak"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - if let Some(val) = &_val.label { + if let Some(val) = &self.value.label { #[derive(RefCast)] #[repr(transparent)] struct Print(syn::Lifetime); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - let _val = &self.0; - formatter.write_str("(")?; - Debug::fmt(Lite(_val), formatter)?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0), formatter)?; formatter.write_str(")")?; Ok(()) } } formatter.field("label", Print::ref_cast(val)); } - if let Some(val) = &_val.expr { + if let Some(val) = &self.value.expr { #[derive(RefCast)] #[repr(transparent)] struct Print(Box<syn::Expr>); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - let _val = &self.0; - formatter.write_str("(")?; - Debug::fmt(Lite(_val), formatter)?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0), formatter)?; formatter.write_str(")")?; Ok(()) } @@ -1263,98 +1159,92 @@ impl Debug for Lite<syn::ExprBreak> { } impl Debug for Lite<syn::ExprCall> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("ExprCall"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - formatter.field("func", Lite(&_val.func)); - if !_val.args.is_empty() { - formatter.field("args", Lite(&_val.args)); + formatter.field("func", Lite(&self.value.func)); + if !self.value.args.is_empty() { + formatter.field("args", Lite(&self.value.args)); } formatter.finish() } } impl Debug for Lite<syn::ExprCast> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("ExprCast"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - formatter.field("expr", Lite(&_val.expr)); - formatter.field("ty", Lite(&_val.ty)); + formatter.field("expr", Lite(&self.value.expr)); + formatter.field("ty", Lite(&self.value.ty)); formatter.finish() } } impl Debug for Lite<syn::ExprClosure> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("ExprClosure"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - if let Some(val) = &_val.movability { + if let Some(val) = &self.value.lifetimes { #[derive(RefCast)] #[repr(transparent)] - struct Print(syn::token::Static); + struct Print(syn::BoundLifetimes); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0), formatter)?; + formatter.write_str(")")?; Ok(()) } } - formatter.field("movability", Print::ref_cast(val)); + formatter.field("lifetimes", Print::ref_cast(val)); } - if let Some(val) = &_val.asyncness { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Async); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } - } - formatter.field("asyncness", Print::ref_cast(val)); + if self.value.constness.is_some() { + formatter.field("constness", &Present); } - if let Some(val) = &_val.capture { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Move); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } - } - formatter.field("capture", Print::ref_cast(val)); + if self.value.movability.is_some() { + formatter.field("movability", &Present); + } + if self.value.asyncness.is_some() { + formatter.field("asyncness", &Present); + } + if self.value.capture.is_some() { + formatter.field("capture", &Present); } - if !_val.inputs.is_empty() { - formatter.field("inputs", Lite(&_val.inputs)); + if !self.value.inputs.is_empty() { + formatter.field("inputs", Lite(&self.value.inputs)); + } + formatter.field("output", Lite(&self.value.output)); + formatter.field("body", Lite(&self.value.body)); + formatter.finish() + } +} +impl Debug for Lite<syn::ExprConst> { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + let mut formatter = formatter.debug_struct("ExprConst"); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - formatter.field("output", Lite(&_val.output)); - formatter.field("body", Lite(&_val.body)); + formatter.field("block", Lite(&self.value.block)); formatter.finish() } } impl Debug for Lite<syn::ExprContinue> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("ExprContinue"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - if let Some(val) = &_val.label { + if let Some(val) = &self.value.label { #[derive(RefCast)] #[repr(transparent)] struct Print(syn::Lifetime); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - let _val = &self.0; - formatter.write_str("(")?; - Debug::fmt(Lite(_val), formatter)?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0), formatter)?; formatter.write_str(")")?; Ok(()) } @@ -1366,75 +1256,67 @@ impl Debug for Lite<syn::ExprContinue> { } impl Debug for Lite<syn::ExprField> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("ExprField"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - formatter.field("base", Lite(&_val.base)); - formatter.field("member", Lite(&_val.member)); + formatter.field("base", Lite(&self.value.base)); + formatter.field("member", Lite(&self.value.member)); formatter.finish() } } impl Debug for Lite<syn::ExprForLoop> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("ExprForLoop"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - if let Some(val) = &_val.label { + if let Some(val) = &self.value.label { #[derive(RefCast)] #[repr(transparent)] struct Print(syn::Label); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - let _val = &self.0; - formatter.write_str("(")?; - Debug::fmt(Lite(_val), formatter)?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0), formatter)?; formatter.write_str(")")?; Ok(()) } } formatter.field("label", Print::ref_cast(val)); } - formatter.field("pat", Lite(&_val.pat)); - formatter.field("expr", Lite(&_val.expr)); - formatter.field("body", Lite(&_val.body)); + formatter.field("pat", Lite(&self.value.pat)); + formatter.field("expr", Lite(&self.value.expr)); + formatter.field("body", Lite(&self.value.body)); formatter.finish() } } impl Debug for Lite<syn::ExprGroup> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("ExprGroup"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - formatter.field("expr", Lite(&_val.expr)); + formatter.field("expr", Lite(&self.value.expr)); formatter.finish() } } impl Debug for Lite<syn::ExprIf> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("ExprIf"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - formatter.field("cond", Lite(&_val.cond)); - formatter.field("then_branch", Lite(&_val.then_branch)); - if let Some(val) = &_val.else_branch { + formatter.field("cond", Lite(&self.value.cond)); + formatter.field("then_branch", Lite(&self.value.then_branch)); + if let Some(val) = &self.value.else_branch { #[derive(RefCast)] #[repr(transparent)] struct Print((syn::token::Else, Box<syn::Expr>)); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - let _val = &self.0; - formatter.write_str("(")?; - Debug::fmt(Lite(&_val.1), formatter)?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0.1), formatter)?; formatter.write_str(")")?; Ok(()) } @@ -1446,255 +1328,230 @@ impl Debug for Lite<syn::ExprIf> { } impl Debug for Lite<syn::ExprIndex> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("ExprIndex"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); + } + formatter.field("expr", Lite(&self.value.expr)); + formatter.field("index", Lite(&self.value.index)); + formatter.finish() + } +} +impl Debug for Lite<syn::ExprInfer> { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + let mut formatter = formatter.debug_struct("ExprInfer"); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - formatter.field("expr", Lite(&_val.expr)); - formatter.field("index", Lite(&_val.index)); formatter.finish() } } impl Debug for Lite<syn::ExprLet> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("ExprLet"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - formatter.field("pat", Lite(&_val.pat)); - formatter.field("expr", Lite(&_val.expr)); + formatter.field("pat", Lite(&self.value.pat)); + formatter.field("expr", Lite(&self.value.expr)); formatter.finish() } } impl Debug for Lite<syn::ExprLit> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("ExprLit"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - formatter.field("lit", Lite(&_val.lit)); + formatter.field("lit", Lite(&self.value.lit)); formatter.finish() } } impl Debug for Lite<syn::ExprLoop> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("ExprLoop"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - if let Some(val) = &_val.label { + if let Some(val) = &self.value.label { #[derive(RefCast)] #[repr(transparent)] struct Print(syn::Label); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - let _val = &self.0; - formatter.write_str("(")?; - Debug::fmt(Lite(_val), formatter)?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0), formatter)?; formatter.write_str(")")?; Ok(()) } } formatter.field("label", Print::ref_cast(val)); } - formatter.field("body", Lite(&_val.body)); + formatter.field("body", Lite(&self.value.body)); formatter.finish() } } impl Debug for Lite<syn::ExprMacro> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("ExprMacro"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - formatter.field("mac", Lite(&_val.mac)); + formatter.field("mac", Lite(&self.value.mac)); formatter.finish() } } impl Debug for Lite<syn::ExprMatch> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("ExprMatch"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - formatter.field("expr", Lite(&_val.expr)); - if !_val.arms.is_empty() { - formatter.field("arms", Lite(&_val.arms)); + formatter.field("expr", Lite(&self.value.expr)); + if !self.value.arms.is_empty() { + formatter.field("arms", Lite(&self.value.arms)); } formatter.finish() } } impl Debug for Lite<syn::ExprMethodCall> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("ExprMethodCall"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - formatter.field("receiver", Lite(&_val.receiver)); - formatter.field("method", Lite(&_val.method)); - if let Some(val) = &_val.turbofish { + formatter.field("receiver", Lite(&self.value.receiver)); + formatter.field("method", Lite(&self.value.method)); + if let Some(val) = &self.value.turbofish { #[derive(RefCast)] #[repr(transparent)] - struct Print(syn::MethodTurbofish); + struct Print(syn::AngleBracketedGenericArguments); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - let _val = &self.0; - formatter.write_str("(")?; - Debug::fmt(Lite(_val), formatter)?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0), formatter)?; formatter.write_str(")")?; Ok(()) } } formatter.field("turbofish", Print::ref_cast(val)); } - if !_val.args.is_empty() { - formatter.field("args", Lite(&_val.args)); + if !self.value.args.is_empty() { + formatter.field("args", Lite(&self.value.args)); } formatter.finish() } } impl Debug for Lite<syn::ExprParen> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("ExprParen"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - formatter.field("expr", Lite(&_val.expr)); + formatter.field("expr", Lite(&self.value.expr)); formatter.finish() } } impl Debug for Lite<syn::ExprPath> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("ExprPath"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - if let Some(val) = &_val.qself { + if let Some(val) = &self.value.qself { #[derive(RefCast)] #[repr(transparent)] struct Print(syn::QSelf); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - let _val = &self.0; - formatter.write_str("(")?; - Debug::fmt(Lite(_val), formatter)?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0), formatter)?; formatter.write_str(")")?; Ok(()) } } formatter.field("qself", Print::ref_cast(val)); } - formatter.field("path", Lite(&_val.path)); + formatter.field("path", Lite(&self.value.path)); formatter.finish() } } impl Debug for Lite<syn::ExprRange> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("ExprRange"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - if let Some(val) = &_val.from { + if let Some(val) = &self.value.start { #[derive(RefCast)] #[repr(transparent)] struct Print(Box<syn::Expr>); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - let _val = &self.0; - formatter.write_str("(")?; - Debug::fmt(Lite(_val), formatter)?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0), formatter)?; formatter.write_str(")")?; Ok(()) } } - formatter.field("from", Print::ref_cast(val)); + formatter.field("start", Print::ref_cast(val)); } - formatter.field("limits", Lite(&_val.limits)); - if let Some(val) = &_val.to { + formatter.field("limits", Lite(&self.value.limits)); + if let Some(val) = &self.value.end { #[derive(RefCast)] #[repr(transparent)] struct Print(Box<syn::Expr>); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - let _val = &self.0; - formatter.write_str("(")?; - Debug::fmt(Lite(_val), formatter)?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0), formatter)?; formatter.write_str(")")?; Ok(()) } } - formatter.field("to", Print::ref_cast(val)); + formatter.field("end", Print::ref_cast(val)); } formatter.finish() } } impl Debug for Lite<syn::ExprReference> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("ExprReference"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - if let Some(val) = &_val.mutability { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Mut); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } - } - formatter.field("mutability", Print::ref_cast(val)); + if self.value.mutability.is_some() { + formatter.field("mutability", &Present); } - formatter.field("expr", Lite(&_val.expr)); + formatter.field("expr", Lite(&self.value.expr)); formatter.finish() } } impl Debug for Lite<syn::ExprRepeat> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("ExprRepeat"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - formatter.field("expr", Lite(&_val.expr)); - formatter.field("len", Lite(&_val.len)); + formatter.field("expr", Lite(&self.value.expr)); + formatter.field("len", Lite(&self.value.len)); formatter.finish() } } impl Debug for Lite<syn::ExprReturn> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("ExprReturn"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - if let Some(val) = &_val.expr { + if let Some(val) = &self.value.expr { #[derive(RefCast)] #[repr(transparent)] struct Print(Box<syn::Expr>); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - let _val = &self.0; - formatter.write_str("(")?; - Debug::fmt(Lite(_val), formatter)?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0), formatter)?; formatter.write_str(")")?; Ok(()) } @@ -1706,37 +1563,39 @@ impl Debug for Lite<syn::ExprReturn> { } impl Debug for Lite<syn::ExprStruct> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("ExprStruct"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - formatter.field("path", Lite(&_val.path)); - if !_val.fields.is_empty() { - formatter.field("fields", Lite(&_val.fields)); - } - if let Some(val) = &_val.dot2_token { + if let Some(val) = &self.value.qself { #[derive(RefCast)] #[repr(transparent)] - struct Print(syn::token::Dot2); + struct Print(syn::QSelf); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0), formatter)?; + formatter.write_str(")")?; Ok(()) } } - formatter.field("dot2_token", Print::ref_cast(val)); + formatter.field("qself", Print::ref_cast(val)); } - if let Some(val) = &_val.rest { + formatter.field("path", Lite(&self.value.path)); + if !self.value.fields.is_empty() { + formatter.field("fields", Lite(&self.value.fields)); + } + if self.value.dot2_token.is_some() { + formatter.field("dot2_token", &Present); + } + if let Some(val) = &self.value.rest { #[derive(RefCast)] #[repr(transparent)] struct Print(Box<syn::Expr>); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - let _val = &self.0; - formatter.write_str("(")?; - Debug::fmt(Lite(_val), formatter)?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0), formatter)?; formatter.write_str(")")?; Ok(()) } @@ -1748,119 +1607,96 @@ impl Debug for Lite<syn::ExprStruct> { } impl Debug for Lite<syn::ExprTry> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("ExprTry"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - formatter.field("expr", Lite(&_val.expr)); + formatter.field("expr", Lite(&self.value.expr)); formatter.finish() } } impl Debug for Lite<syn::ExprTryBlock> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("ExprTryBlock"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - formatter.field("block", Lite(&_val.block)); + formatter.field("block", Lite(&self.value.block)); formatter.finish() } } impl Debug for Lite<syn::ExprTuple> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("ExprTuple"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - if !_val.elems.is_empty() { - formatter.field("elems", Lite(&_val.elems)); - } - formatter.finish() - } -} -impl Debug for Lite<syn::ExprType> { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; - let mut formatter = formatter.debug_struct("ExprType"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.elems.is_empty() { + formatter.field("elems", Lite(&self.value.elems)); } - formatter.field("expr", Lite(&_val.expr)); - formatter.field("ty", Lite(&_val.ty)); formatter.finish() } } impl Debug for Lite<syn::ExprUnary> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("ExprUnary"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - formatter.field("op", Lite(&_val.op)); - formatter.field("expr", Lite(&_val.expr)); + formatter.field("op", Lite(&self.value.op)); + formatter.field("expr", Lite(&self.value.expr)); formatter.finish() } } impl Debug for Lite<syn::ExprUnsafe> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("ExprUnsafe"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - formatter.field("block", Lite(&_val.block)); + formatter.field("block", Lite(&self.value.block)); formatter.finish() } } impl Debug for Lite<syn::ExprWhile> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("ExprWhile"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - if let Some(val) = &_val.label { + if let Some(val) = &self.value.label { #[derive(RefCast)] #[repr(transparent)] struct Print(syn::Label); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - let _val = &self.0; - formatter.write_str("(")?; - Debug::fmt(Lite(_val), formatter)?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0), formatter)?; formatter.write_str(")")?; Ok(()) } } formatter.field("label", Print::ref_cast(val)); } - formatter.field("cond", Lite(&_val.cond)); - formatter.field("body", Lite(&_val.body)); + formatter.field("cond", Lite(&self.value.cond)); + formatter.field("body", Lite(&self.value.body)); formatter.finish() } } impl Debug for Lite<syn::ExprYield> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("ExprYield"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - if let Some(val) = &_val.expr { + if let Some(val) = &self.value.expr { #[derive(RefCast)] #[repr(transparent)] struct Print(Box<syn::Expr>); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - let _val = &self.0; - formatter.write_str("(")?; - Debug::fmt(Lite(_val), formatter)?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0), formatter)?; formatter.write_str(")")?; Ok(()) } @@ -1872,96 +1708,77 @@ impl Debug for Lite<syn::ExprYield> { } impl Debug for Lite<syn::Field> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("Field"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - formatter.field("vis", Lite(&_val.vis)); - if let Some(val) = &_val.ident { + formatter.field("vis", Lite(&self.value.vis)); + match self.value.mutability { + syn::FieldMutability::None => {} + _ => { + formatter.field("mutability", Lite(&self.value.mutability)); + } + } + if let Some(val) = &self.value.ident { #[derive(RefCast)] #[repr(transparent)] struct Print(proc_macro2::Ident); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - let _val = &self.0; - formatter.write_str("(")?; - Debug::fmt(Lite(_val), formatter)?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0), formatter)?; formatter.write_str(")")?; Ok(()) } } formatter.field("ident", Print::ref_cast(val)); } - if let Some(val) = &_val.colon_token { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Colon); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } - } - formatter.field("colon_token", Print::ref_cast(val)); + if self.value.colon_token.is_some() { + formatter.field("colon_token", &Present); } - formatter.field("ty", Lite(&_val.ty)); + formatter.field("ty", Lite(&self.value.ty)); formatter.finish() } } +impl Debug for Lite<syn::FieldMutability> { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + match &self.value { + syn::FieldMutability::None => formatter.write_str("FieldMutability::None"), + _ => unreachable!(), + } + } +} impl Debug for Lite<syn::FieldPat> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("FieldPat"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - formatter.field("member", Lite(&_val.member)); - if let Some(val) = &_val.colon_token { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Colon); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } - } - formatter.field("colon_token", Print::ref_cast(val)); + formatter.field("member", Lite(&self.value.member)); + if self.value.colon_token.is_some() { + formatter.field("colon_token", &Present); } - formatter.field("pat", Lite(&_val.pat)); + formatter.field("pat", Lite(&self.value.pat)); formatter.finish() } } impl Debug for Lite<syn::FieldValue> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("FieldValue"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - formatter.field("member", Lite(&_val.member)); - if let Some(val) = &_val.colon_token { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Colon); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } - } - formatter.field("colon_token", Print::ref_cast(val)); + formatter.field("member", Lite(&self.value.member)); + if self.value.colon_token.is_some() { + formatter.field("colon_token", &Present); } - formatter.field("expr", Lite(&_val.expr)); + formatter.field("expr", Lite(&self.value.expr)); formatter.finish() } } impl Debug for Lite<syn::Fields> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; - match _val { + match &self.value { syn::Fields::Named(_val) => { let mut formatter = formatter.debug_struct("Fields::Named"); if !_val.named.is_empty() { @@ -1976,72 +1793,66 @@ impl Debug for Lite<syn::Fields> { } formatter.finish() } - syn::Fields::Unit => formatter.write_str("Unit"), + syn::Fields::Unit => formatter.write_str("Fields::Unit"), } } } impl Debug for Lite<syn::FieldsNamed> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("FieldsNamed"); - if !_val.named.is_empty() { - formatter.field("named", Lite(&_val.named)); + if !self.value.named.is_empty() { + formatter.field("named", Lite(&self.value.named)); } formatter.finish() } } impl Debug for Lite<syn::FieldsUnnamed> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("FieldsUnnamed"); - if !_val.unnamed.is_empty() { - formatter.field("unnamed", Lite(&_val.unnamed)); + if !self.value.unnamed.is_empty() { + formatter.field("unnamed", Lite(&self.value.unnamed)); } formatter.finish() } } impl Debug for Lite<syn::File> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("File"); - if let Some(val) = &_val.shebang { + if let Some(val) = &self.value.shebang { #[derive(RefCast)] #[repr(transparent)] struct Print(String); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - let _val = &self.0; - formatter.write_str("(")?; - Debug::fmt(Lite(_val), formatter)?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0), formatter)?; formatter.write_str(")")?; Ok(()) } } formatter.field("shebang", Print::ref_cast(val)); } - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - if !_val.items.is_empty() { - formatter.field("items", Lite(&_val.items)); + if !self.value.items.is_empty() { + formatter.field("items", Lite(&self.value.items)); } formatter.finish() } } impl Debug for Lite<syn::FnArg> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; - match _val { + match &self.value { syn::FnArg::Receiver(_val) => { - formatter.write_str("Receiver")?; + formatter.write_str("FnArg::Receiver")?; formatter.write_str("(")?; Debug::fmt(Lite(_val), formatter)?; formatter.write_str(")")?; Ok(()) } syn::FnArg::Typed(_val) => { - formatter.write_str("Typed")?; + formatter.write_str("FnArg::Typed")?; formatter.write_str("(")?; Debug::fmt(Lite(_val), formatter)?; formatter.write_str(")")?; @@ -2052,8 +1863,7 @@ impl Debug for Lite<syn::FnArg> { } impl Debug for Lite<syn::ForeignItem> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; - match _val { + match &self.value { syn::ForeignItem::Fn(_val) => { let mut formatter = formatter.debug_struct("ForeignItem::Fn"); if !_val.attrs.is_empty() { @@ -2069,17 +1879,11 @@ impl Debug for Lite<syn::ForeignItem> { formatter.field("attrs", Lite(&_val.attrs)); } formatter.field("vis", Lite(&_val.vis)); - if let Some(val) = &_val.mutability { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Mut); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } + match _val.mutability { + syn::StaticMutability::None => {} + _ => { + formatter.field("mutability", Lite(&_val.mutability)); } - formatter.field("mutability", Print::ref_cast(val)); } formatter.field("ident", Lite(&_val.ident)); formatter.field("ty", Lite(&_val.ty)); @@ -2092,6 +1896,7 @@ impl Debug for Lite<syn::ForeignItem> { } formatter.field("vis", Lite(&_val.vis)); formatter.field("ident", Lite(&_val.ident)); + formatter.field("generics", Lite(&_val.generics)); formatter.finish() } syn::ForeignItem::Macro(_val) => { @@ -2100,22 +1905,13 @@ impl Debug for Lite<syn::ForeignItem> { formatter.field("attrs", Lite(&_val.attrs)); } formatter.field("mac", Lite(&_val.mac)); - if let Some(val) = &_val.semi_token { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Semi); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } - } - formatter.field("semi_token", Print::ref_cast(val)); + if _val.semi_token.is_some() { + formatter.field("semi_token", &Present); } formatter.finish() } syn::ForeignItem::Verbatim(_val) => { - formatter.write_str("Verbatim")?; + formatter.write_str("ForeignItem::Verbatim")?; formatter.write_str("(`")?; Display::fmt(_val, formatter)?; formatter.write_str("`)")?; @@ -2127,159 +1923,126 @@ impl Debug for Lite<syn::ForeignItem> { } impl Debug for Lite<syn::ForeignItemFn> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("ForeignItemFn"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - formatter.field("vis", Lite(&_val.vis)); - formatter.field("sig", Lite(&_val.sig)); + formatter.field("vis", Lite(&self.value.vis)); + formatter.field("sig", Lite(&self.value.sig)); formatter.finish() } } impl Debug for Lite<syn::ForeignItemMacro> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("ForeignItemMacro"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - formatter.field("mac", Lite(&_val.mac)); - if let Some(val) = &_val.semi_token { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Semi); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } - } - formatter.field("semi_token", Print::ref_cast(val)); + formatter.field("mac", Lite(&self.value.mac)); + if self.value.semi_token.is_some() { + formatter.field("semi_token", &Present); } formatter.finish() } } impl Debug for Lite<syn::ForeignItemStatic> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("ForeignItemStatic"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - formatter.field("vis", Lite(&_val.vis)); - if let Some(val) = &_val.mutability { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Mut); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } + formatter.field("vis", Lite(&self.value.vis)); + match self.value.mutability { + syn::StaticMutability::None => {} + _ => { + formatter.field("mutability", Lite(&self.value.mutability)); } - formatter.field("mutability", Print::ref_cast(val)); } - formatter.field("ident", Lite(&_val.ident)); - formatter.field("ty", Lite(&_val.ty)); + formatter.field("ident", Lite(&self.value.ident)); + formatter.field("ty", Lite(&self.value.ty)); formatter.finish() } } impl Debug for Lite<syn::ForeignItemType> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("ForeignItemType"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - formatter.field("vis", Lite(&_val.vis)); - formatter.field("ident", Lite(&_val.ident)); + formatter.field("vis", Lite(&self.value.vis)); + formatter.field("ident", Lite(&self.value.ident)); + formatter.field("generics", Lite(&self.value.generics)); formatter.finish() } } impl Debug for Lite<syn::GenericArgument> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; - match _val { + match &self.value { syn::GenericArgument::Lifetime(_val) => { - formatter.write_str("Lifetime")?; + formatter.write_str("GenericArgument::Lifetime")?; formatter.write_str("(")?; Debug::fmt(Lite(_val), formatter)?; formatter.write_str(")")?; Ok(()) } syn::GenericArgument::Type(_val) => { - formatter.write_str("Type")?; + formatter.write_str("GenericArgument::Type")?; formatter.write_str("(")?; Debug::fmt(Lite(_val), formatter)?; formatter.write_str(")")?; Ok(()) } syn::GenericArgument::Const(_val) => { - formatter.write_str("Const")?; + formatter.write_str("GenericArgument::Const")?; formatter.write_str("(")?; Debug::fmt(Lite(_val), formatter)?; formatter.write_str(")")?; Ok(()) } - syn::GenericArgument::Binding(_val) => { - formatter.write_str("Binding")?; + syn::GenericArgument::AssocType(_val) => { + formatter.write_str("GenericArgument::AssocType")?; formatter.write_str("(")?; Debug::fmt(Lite(_val), formatter)?; formatter.write_str(")")?; Ok(()) } - syn::GenericArgument::Constraint(_val) => { - formatter.write_str("Constraint")?; + syn::GenericArgument::AssocConst(_val) => { + formatter.write_str("GenericArgument::AssocConst")?; formatter.write_str("(")?; Debug::fmt(Lite(_val), formatter)?; formatter.write_str(")")?; Ok(()) } - } - } -} -impl Debug for Lite<syn::GenericMethodArgument> { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; - match _val { - syn::GenericMethodArgument::Type(_val) => { - formatter.write_str("Type")?; - formatter.write_str("(")?; - Debug::fmt(Lite(_val), formatter)?; - formatter.write_str(")")?; - Ok(()) - } - syn::GenericMethodArgument::Const(_val) => { - formatter.write_str("Const")?; + syn::GenericArgument::Constraint(_val) => { + formatter.write_str("GenericArgument::Constraint")?; formatter.write_str("(")?; Debug::fmt(Lite(_val), formatter)?; formatter.write_str(")")?; Ok(()) } + _ => unreachable!(), } } } impl Debug for Lite<syn::GenericParam> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; - match _val { - syn::GenericParam::Type(_val) => { - formatter.write_str("Type")?; + match &self.value { + syn::GenericParam::Lifetime(_val) => { + formatter.write_str("GenericParam::Lifetime")?; formatter.write_str("(")?; Debug::fmt(Lite(_val), formatter)?; formatter.write_str(")")?; Ok(()) } - syn::GenericParam::Lifetime(_val) => { - formatter.write_str("Lifetime")?; + syn::GenericParam::Type(_val) => { + formatter.write_str("GenericParam::Type")?; formatter.write_str("(")?; Debug::fmt(Lite(_val), formatter)?; formatter.write_str(")")?; Ok(()) } syn::GenericParam::Const(_val) => { - formatter.write_str("Const")?; + formatter.write_str("GenericParam::Const")?; formatter.write_str("(")?; Debug::fmt(Lite(_val), formatter)?; formatter.write_str(")")?; @@ -2290,45 +2053,24 @@ impl Debug for Lite<syn::GenericParam> { } impl Debug for Lite<syn::Generics> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("Generics"); - if let Some(val) = &_val.lt_token { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Lt); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } - } - formatter.field("lt_token", Print::ref_cast(val)); + if self.value.lt_token.is_some() { + formatter.field("lt_token", &Present); } - if !_val.params.is_empty() { - formatter.field("params", Lite(&_val.params)); + if !self.value.params.is_empty() { + formatter.field("params", Lite(&self.value.params)); } - if let Some(val) = &_val.gt_token { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Gt); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } - } - formatter.field("gt_token", Print::ref_cast(val)); + if self.value.gt_token.is_some() { + formatter.field("gt_token", &Present); } - if let Some(val) = &_val.where_clause { + if let Some(val) = &self.value.where_clause { #[derive(RefCast)] #[repr(transparent)] struct Print(syn::WhereClause); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - let _val = &self.0; - formatter.write_str("(")?; - Debug::fmt(Lite(_val), formatter)?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0), formatter)?; formatter.write_str(")")?; Ok(()) } @@ -2340,48 +2082,30 @@ impl Debug for Lite<syn::Generics> { } impl Debug for Lite<syn::ImplItem> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; - match _val { + match &self.value { syn::ImplItem::Const(_val) => { let mut formatter = formatter.debug_struct("ImplItem::Const"); if !_val.attrs.is_empty() { formatter.field("attrs", Lite(&_val.attrs)); } formatter.field("vis", Lite(&_val.vis)); - if let Some(val) = &_val.defaultness { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Default); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } - } - formatter.field("defaultness", Print::ref_cast(val)); + if _val.defaultness.is_some() { + formatter.field("defaultness", &Present); } formatter.field("ident", Lite(&_val.ident)); + formatter.field("generics", Lite(&_val.generics)); formatter.field("ty", Lite(&_val.ty)); formatter.field("expr", Lite(&_val.expr)); formatter.finish() } - syn::ImplItem::Method(_val) => { - let mut formatter = formatter.debug_struct("ImplItem::Method"); + syn::ImplItem::Fn(_val) => { + let mut formatter = formatter.debug_struct("ImplItem::Fn"); if !_val.attrs.is_empty() { formatter.field("attrs", Lite(&_val.attrs)); } formatter.field("vis", Lite(&_val.vis)); - if let Some(val) = &_val.defaultness { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Default); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } - } - formatter.field("defaultness", Print::ref_cast(val)); + if _val.defaultness.is_some() { + formatter.field("defaultness", &Present); } formatter.field("sig", Lite(&_val.sig)); formatter.field("block", Lite(&_val.block)); @@ -2393,17 +2117,8 @@ impl Debug for Lite<syn::ImplItem> { formatter.field("attrs", Lite(&_val.attrs)); } formatter.field("vis", Lite(&_val.vis)); - if let Some(val) = &_val.defaultness { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Default); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } - } - formatter.field("defaultness", Print::ref_cast(val)); + if _val.defaultness.is_some() { + formatter.field("defaultness", &Present); } formatter.field("ident", Lite(&_val.ident)); formatter.field("generics", Lite(&_val.generics)); @@ -2416,22 +2131,13 @@ impl Debug for Lite<syn::ImplItem> { formatter.field("attrs", Lite(&_val.attrs)); } formatter.field("mac", Lite(&_val.mac)); - if let Some(val) = &_val.semi_token { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Semi); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } - } - formatter.field("semi_token", Print::ref_cast(val)); + if _val.semi_token.is_some() { + formatter.field("semi_token", &Present); } formatter.finish() } syn::ImplItem::Verbatim(_val) => { - formatter.write_str("Verbatim")?; + formatter.write_str("ImplItem::Verbatim")?; formatter.write_str("(`")?; Display::fmt(_val, formatter)?; formatter.write_str("`)")?; @@ -2443,116 +2149,80 @@ impl Debug for Lite<syn::ImplItem> { } impl Debug for Lite<syn::ImplItemConst> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("ImplItemConst"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - formatter.field("vis", Lite(&_val.vis)); - if let Some(val) = &_val.defaultness { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Default); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } - } - formatter.field("defaultness", Print::ref_cast(val)); + formatter.field("vis", Lite(&self.value.vis)); + if self.value.defaultness.is_some() { + formatter.field("defaultness", &Present); } - formatter.field("ident", Lite(&_val.ident)); - formatter.field("ty", Lite(&_val.ty)); - formatter.field("expr", Lite(&_val.expr)); + formatter.field("ident", Lite(&self.value.ident)); + formatter.field("generics", Lite(&self.value.generics)); + formatter.field("ty", Lite(&self.value.ty)); + formatter.field("expr", Lite(&self.value.expr)); formatter.finish() } } -impl Debug for Lite<syn::ImplItemMacro> { +impl Debug for Lite<syn::ImplItemFn> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; - let mut formatter = formatter.debug_struct("ImplItemMacro"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + let mut formatter = formatter.debug_struct("ImplItemFn"); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - formatter.field("mac", Lite(&_val.mac)); - if let Some(val) = &_val.semi_token { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Semi); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } - } - formatter.field("semi_token", Print::ref_cast(val)); + formatter.field("vis", Lite(&self.value.vis)); + if self.value.defaultness.is_some() { + formatter.field("defaultness", &Present); } + formatter.field("sig", Lite(&self.value.sig)); + formatter.field("block", Lite(&self.value.block)); formatter.finish() } } -impl Debug for Lite<syn::ImplItemMethod> { +impl Debug for Lite<syn::ImplItemMacro> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; - let mut formatter = formatter.debug_struct("ImplItemMethod"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + let mut formatter = formatter.debug_struct("ImplItemMacro"); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - formatter.field("vis", Lite(&_val.vis)); - if let Some(val) = &_val.defaultness { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Default); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } - } - formatter.field("defaultness", Print::ref_cast(val)); + formatter.field("mac", Lite(&self.value.mac)); + if self.value.semi_token.is_some() { + formatter.field("semi_token", &Present); } - formatter.field("sig", Lite(&_val.sig)); - formatter.field("block", Lite(&_val.block)); formatter.finish() } } impl Debug for Lite<syn::ImplItemType> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("ImplItemType"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - formatter.field("vis", Lite(&_val.vis)); - if let Some(val) = &_val.defaultness { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Default); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } - } - formatter.field("defaultness", Print::ref_cast(val)); + formatter.field("vis", Lite(&self.value.vis)); + if self.value.defaultness.is_some() { + formatter.field("defaultness", &Present); } - formatter.field("ident", Lite(&_val.ident)); - formatter.field("generics", Lite(&_val.generics)); - formatter.field("ty", Lite(&_val.ty)); + formatter.field("ident", Lite(&self.value.ident)); + formatter.field("generics", Lite(&self.value.generics)); + formatter.field("ty", Lite(&self.value.ty)); formatter.finish() } } +impl Debug for Lite<syn::ImplRestriction> { + fn fmt(&self, _formatter: &mut fmt::Formatter) -> fmt::Result { + unreachable!() + } +} impl Debug for Lite<syn::Index> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("Index"); - formatter.field("index", Lite(&_val.index)); + formatter.field("index", Lite(&self.value.index)); formatter.finish() } } impl Debug for Lite<syn::Item> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; - match _val { + match &self.value { syn::Item::Const(_val) => { let mut formatter = formatter.debug_struct("Item::Const"); if !_val.attrs.is_empty() { @@ -2560,6 +2230,7 @@ impl Debug for Lite<syn::Item> { } formatter.field("vis", Lite(&_val.vis)); formatter.field("ident", Lite(&_val.ident)); + formatter.field("generics", Lite(&_val.generics)); formatter.field("ty", Lite(&_val.ty)); formatter.field("expr", Lite(&_val.expr)); formatter.finish() @@ -2590,10 +2261,8 @@ impl Debug for Lite<syn::Item> { struct Print((syn::token::As, proc_macro2::Ident)); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - let _val = &self.0; - formatter.write_str("(")?; - Debug::fmt(Lite(&_val.1), formatter)?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0.1), formatter)?; formatter.write_str(")")?; Ok(()) } @@ -2617,6 +2286,9 @@ impl Debug for Lite<syn::Item> { if !_val.attrs.is_empty() { formatter.field("attrs", Lite(&_val.attrs)); } + if _val.unsafety.is_some() { + formatter.field("unsafety", &Present); + } formatter.field("abi", Lite(&_val.abi)); if !_val.items.is_empty() { formatter.field("items", Lite(&_val.items)); @@ -2628,63 +2300,26 @@ impl Debug for Lite<syn::Item> { if !_val.attrs.is_empty() { formatter.field("attrs", Lite(&_val.attrs)); } - if let Some(val) = &_val.defaultness { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Default); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } - } - formatter.field("defaultness", Print::ref_cast(val)); + if _val.defaultness.is_some() { + formatter.field("defaultness", &Present); } - if let Some(val) = &_val.unsafety { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Unsafe); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } - } - formatter.field("unsafety", Print::ref_cast(val)); + if _val.unsafety.is_some() { + formatter.field("unsafety", &Present); } formatter.field("generics", Lite(&_val.generics)); if let Some(val) = &_val.trait_ { #[derive(RefCast)] #[repr(transparent)] - struct Print((Option<syn::token::Bang>, syn::Path, syn::token::For)); + struct Print((Option<syn::token::Not>, syn::Path, syn::token::For)); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - let _val = &self.0; - formatter.write_str("(")?; + formatter.write_str("Some(")?; Debug::fmt( &( - { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(Option<syn::token::Bang>); - impl Debug for Print { - fn fmt( - &self, - formatter: &mut fmt::Formatter, - ) -> fmt::Result { - match &self.0 { - Some(_val) => { - formatter.write_str("Some")?; - Ok(()) - } - None => formatter.write_str("None"), - } - } - } - Print::ref_cast(&_val.0) + &super::Option { + present: self.0.0.is_some(), }, - Lite(&_val.1), + Lite(&self.0.1), ), formatter, )?; @@ -2711,10 +2346,8 @@ impl Debug for Lite<syn::Item> { struct Print(proc_macro2::Ident); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - let _val = &self.0; - formatter.write_str("(")?; - Debug::fmt(Lite(_val), formatter)?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0), formatter)?; formatter.write_str(")")?; Ok(()) } @@ -2722,28 +2355,9 @@ impl Debug for Lite<syn::Item> { formatter.field("ident", Print::ref_cast(val)); } formatter.field("mac", Lite(&_val.mac)); - if let Some(val) = &_val.semi_token { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Semi); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } - } - formatter.field("semi_token", Print::ref_cast(val)); - } - formatter.finish() - } - syn::Item::Macro2(_val) => { - let mut formatter = formatter.debug_struct("Item::Macro2"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if _val.semi_token.is_some() { + formatter.field("semi_token", &Present); } - formatter.field("vis", Lite(&_val.vis)); - formatter.field("ident", Lite(&_val.ident)); - formatter.field("rules", Lite(&_val.rules)); formatter.finish() } syn::Item::Mod(_val) => { @@ -2752,6 +2366,9 @@ impl Debug for Lite<syn::Item> { formatter.field("attrs", Lite(&_val.attrs)); } formatter.field("vis", Lite(&_val.vis)); + if _val.unsafety.is_some() { + formatter.field("unsafety", &Present); + } formatter.field("ident", Lite(&_val.ident)); if let Some(val) = &_val.content { #[derive(RefCast)] @@ -2759,27 +2376,16 @@ impl Debug for Lite<syn::Item> { struct Print((syn::token::Brace, Vec<syn::Item>)); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - let _val = &self.0; - formatter.write_str("(")?; - Debug::fmt(Lite(&_val.1), formatter)?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0.1), formatter)?; formatter.write_str(")")?; Ok(()) } } formatter.field("content", Print::ref_cast(val)); } - if let Some(val) = &_val.semi { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Semi); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } - } - formatter.field("semi", Print::ref_cast(val)); + if _val.semi.is_some() { + formatter.field("semi", &Present); } formatter.finish() } @@ -2789,17 +2395,11 @@ impl Debug for Lite<syn::Item> { formatter.field("attrs", Lite(&_val.attrs)); } formatter.field("vis", Lite(&_val.vis)); - if let Some(val) = &_val.mutability { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Mut); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } + match _val.mutability { + syn::StaticMutability::None => {} + _ => { + formatter.field("mutability", Lite(&_val.mutability)); } - formatter.field("mutability", Print::ref_cast(val)); } formatter.field("ident", Lite(&_val.ident)); formatter.field("ty", Lite(&_val.ty)); @@ -2815,17 +2415,8 @@ impl Debug for Lite<syn::Item> { formatter.field("ident", Lite(&_val.ident)); formatter.field("generics", Lite(&_val.generics)); formatter.field("fields", Lite(&_val.fields)); - if let Some(val) = &_val.semi_token { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Semi); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } - } - formatter.field("semi_token", Print::ref_cast(val)); + if _val.semi_token.is_some() { + formatter.field("semi_token", &Present); } formatter.finish() } @@ -2835,43 +2426,30 @@ impl Debug for Lite<syn::Item> { formatter.field("attrs", Lite(&_val.attrs)); } formatter.field("vis", Lite(&_val.vis)); - if let Some(val) = &_val.unsafety { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Unsafe); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } - } - formatter.field("unsafety", Print::ref_cast(val)); + if _val.unsafety.is_some() { + formatter.field("unsafety", &Present); + } + if _val.auto_token.is_some() { + formatter.field("auto_token", &Present); } - if let Some(val) = &_val.auto_token { + if let Some(val) = &_val.restriction { #[derive(RefCast)] #[repr(transparent)] - struct Print(syn::token::Auto); + struct Print(syn::ImplRestriction); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0), formatter)?; + formatter.write_str(")")?; Ok(()) } } - formatter.field("auto_token", Print::ref_cast(val)); + formatter.field("restriction", Print::ref_cast(val)); } formatter.field("ident", Lite(&_val.ident)); formatter.field("generics", Lite(&_val.generics)); - if let Some(val) = &_val.colon_token { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Colon); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } - } - formatter.field("colon_token", Print::ref_cast(val)); + if _val.colon_token.is_some() { + formatter.field("colon_token", &Present); } if !_val.supertraits.is_empty() { formatter.field("supertraits", Lite(&_val.supertraits)); @@ -2922,23 +2500,14 @@ impl Debug for Lite<syn::Item> { formatter.field("attrs", Lite(&_val.attrs)); } formatter.field("vis", Lite(&_val.vis)); - if let Some(val) = &_val.leading_colon { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Colon2); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } - } - formatter.field("leading_colon", Print::ref_cast(val)); + if _val.leading_colon.is_some() { + formatter.field("leading_colon", &Present); } formatter.field("tree", Lite(&_val.tree)); formatter.finish() } syn::Item::Verbatim(_val) => { - formatter.write_str("Verbatim")?; + formatter.write_str("Item::Verbatim")?; formatter.write_str("(`")?; Display::fmt(_val, formatter)?; formatter.write_str("`)")?; @@ -2950,53 +2519,49 @@ impl Debug for Lite<syn::Item> { } impl Debug for Lite<syn::ItemConst> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("ItemConst"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - formatter.field("vis", Lite(&_val.vis)); - formatter.field("ident", Lite(&_val.ident)); - formatter.field("ty", Lite(&_val.ty)); - formatter.field("expr", Lite(&_val.expr)); + formatter.field("vis", Lite(&self.value.vis)); + formatter.field("ident", Lite(&self.value.ident)); + formatter.field("generics", Lite(&self.value.generics)); + formatter.field("ty", Lite(&self.value.ty)); + formatter.field("expr", Lite(&self.value.expr)); formatter.finish() } } impl Debug for Lite<syn::ItemEnum> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("ItemEnum"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - formatter.field("vis", Lite(&_val.vis)); - formatter.field("ident", Lite(&_val.ident)); - formatter.field("generics", Lite(&_val.generics)); - if !_val.variants.is_empty() { - formatter.field("variants", Lite(&_val.variants)); + formatter.field("vis", Lite(&self.value.vis)); + formatter.field("ident", Lite(&self.value.ident)); + formatter.field("generics", Lite(&self.value.generics)); + if !self.value.variants.is_empty() { + formatter.field("variants", Lite(&self.value.variants)); } formatter.finish() } } impl Debug for Lite<syn::ItemExternCrate> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("ItemExternCrate"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - formatter.field("vis", Lite(&_val.vis)); - formatter.field("ident", Lite(&_val.ident)); - if let Some(val) = &_val.rename { + formatter.field("vis", Lite(&self.value.vis)); + formatter.field("ident", Lite(&self.value.ident)); + if let Some(val) = &self.value.rename { #[derive(RefCast)] #[repr(transparent)] struct Print((syn::token::As, proc_macro2::Ident)); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - let _val = &self.0; - formatter.write_str("(")?; - Debug::fmt(Lite(&_val.1), formatter)?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0.1), formatter)?; formatter.write_str(")")?; Ok(()) } @@ -3008,95 +2573,58 @@ impl Debug for Lite<syn::ItemExternCrate> { } impl Debug for Lite<syn::ItemFn> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("ItemFn"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - formatter.field("vis", Lite(&_val.vis)); - formatter.field("sig", Lite(&_val.sig)); - formatter.field("block", Lite(&_val.block)); + formatter.field("vis", Lite(&self.value.vis)); + formatter.field("sig", Lite(&self.value.sig)); + formatter.field("block", Lite(&self.value.block)); formatter.finish() } } impl Debug for Lite<syn::ItemForeignMod> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("ItemForeignMod"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - formatter.field("abi", Lite(&_val.abi)); - if !_val.items.is_empty() { - formatter.field("items", Lite(&_val.items)); + if self.value.unsafety.is_some() { + formatter.field("unsafety", &Present); + } + formatter.field("abi", Lite(&self.value.abi)); + if !self.value.items.is_empty() { + formatter.field("items", Lite(&self.value.items)); } formatter.finish() } } impl Debug for Lite<syn::ItemImpl> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("ItemImpl"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - if let Some(val) = &_val.defaultness { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Default); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } - } - formatter.field("defaultness", Print::ref_cast(val)); + if self.value.defaultness.is_some() { + formatter.field("defaultness", &Present); } - if let Some(val) = &_val.unsafety { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Unsafe); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } - } - formatter.field("unsafety", Print::ref_cast(val)); + if self.value.unsafety.is_some() { + formatter.field("unsafety", &Present); } - formatter.field("generics", Lite(&_val.generics)); - if let Some(val) = &_val.trait_ { + formatter.field("generics", Lite(&self.value.generics)); + if let Some(val) = &self.value.trait_ { #[derive(RefCast)] #[repr(transparent)] - struct Print((Option<syn::token::Bang>, syn::Path, syn::token::For)); + struct Print((Option<syn::token::Not>, syn::Path, syn::token::For)); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - let _val = &self.0; - formatter.write_str("(")?; + formatter.write_str("Some(")?; Debug::fmt( &( - { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(Option<syn::token::Bang>); - impl Debug for Print { - fn fmt( - &self, - formatter: &mut fmt::Formatter, - ) -> fmt::Result { - match &self.0 { - Some(_val) => { - formatter.write_str("Some")?; - Ok(()) - } - None => formatter.write_str("None"), - } - } - } - Print::ref_cast(&_val.0) + &super::Option { + present: self.0.0.is_some(), }, - Lite(&_val.1), + Lite(&self.0.1), ), formatter, )?; @@ -3106,326 +2634,235 @@ impl Debug for Lite<syn::ItemImpl> { } formatter.field("trait_", Print::ref_cast(val)); } - formatter.field("self_ty", Lite(&_val.self_ty)); - if !_val.items.is_empty() { - formatter.field("items", Lite(&_val.items)); + formatter.field("self_ty", Lite(&self.value.self_ty)); + if !self.value.items.is_empty() { + formatter.field("items", Lite(&self.value.items)); } formatter.finish() } } impl Debug for Lite<syn::ItemMacro> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("ItemMacro"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - if let Some(val) = &_val.ident { + if let Some(val) = &self.value.ident { #[derive(RefCast)] #[repr(transparent)] struct Print(proc_macro2::Ident); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - let _val = &self.0; - formatter.write_str("(")?; - Debug::fmt(Lite(_val), formatter)?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0), formatter)?; formatter.write_str(")")?; Ok(()) } } formatter.field("ident", Print::ref_cast(val)); } - formatter.field("mac", Lite(&_val.mac)); - if let Some(val) = &_val.semi_token { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Semi); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } - } - formatter.field("semi_token", Print::ref_cast(val)); + formatter.field("mac", Lite(&self.value.mac)); + if self.value.semi_token.is_some() { + formatter.field("semi_token", &Present); } formatter.finish() } } -impl Debug for Lite<syn::ItemMacro2> { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; - let mut formatter = formatter.debug_struct("ItemMacro2"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); - } - formatter.field("vis", Lite(&_val.vis)); - formatter.field("ident", Lite(&_val.ident)); - formatter.field("rules", Lite(&_val.rules)); - formatter.finish() - } -} impl Debug for Lite<syn::ItemMod> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("ItemMod"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); + } + formatter.field("vis", Lite(&self.value.vis)); + if self.value.unsafety.is_some() { + formatter.field("unsafety", &Present); } - formatter.field("vis", Lite(&_val.vis)); - formatter.field("ident", Lite(&_val.ident)); - if let Some(val) = &_val.content { + formatter.field("ident", Lite(&self.value.ident)); + if let Some(val) = &self.value.content { #[derive(RefCast)] #[repr(transparent)] struct Print((syn::token::Brace, Vec<syn::Item>)); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - let _val = &self.0; - formatter.write_str("(")?; - Debug::fmt(Lite(&_val.1), formatter)?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0.1), formatter)?; formatter.write_str(")")?; Ok(()) } } formatter.field("content", Print::ref_cast(val)); } - if let Some(val) = &_val.semi { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Semi); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } - } - formatter.field("semi", Print::ref_cast(val)); + if self.value.semi.is_some() { + formatter.field("semi", &Present); } formatter.finish() } } impl Debug for Lite<syn::ItemStatic> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("ItemStatic"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - formatter.field("vis", Lite(&_val.vis)); - if let Some(val) = &_val.mutability { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Mut); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } + formatter.field("vis", Lite(&self.value.vis)); + match self.value.mutability { + syn::StaticMutability::None => {} + _ => { + formatter.field("mutability", Lite(&self.value.mutability)); } - formatter.field("mutability", Print::ref_cast(val)); } - formatter.field("ident", Lite(&_val.ident)); - formatter.field("ty", Lite(&_val.ty)); - formatter.field("expr", Lite(&_val.expr)); + formatter.field("ident", Lite(&self.value.ident)); + formatter.field("ty", Lite(&self.value.ty)); + formatter.field("expr", Lite(&self.value.expr)); formatter.finish() } } impl Debug for Lite<syn::ItemStruct> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("ItemStruct"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); - } - formatter.field("vis", Lite(&_val.vis)); - formatter.field("ident", Lite(&_val.ident)); - formatter.field("generics", Lite(&_val.generics)); - formatter.field("fields", Lite(&_val.fields)); - if let Some(val) = &_val.semi_token { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Semi); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } - } - formatter.field("semi_token", Print::ref_cast(val)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); + } + formatter.field("vis", Lite(&self.value.vis)); + formatter.field("ident", Lite(&self.value.ident)); + formatter.field("generics", Lite(&self.value.generics)); + formatter.field("fields", Lite(&self.value.fields)); + if self.value.semi_token.is_some() { + formatter.field("semi_token", &Present); } formatter.finish() } } impl Debug for Lite<syn::ItemTrait> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("ItemTrait"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - formatter.field("vis", Lite(&_val.vis)); - if let Some(val) = &_val.unsafety { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Unsafe); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } - } - formatter.field("unsafety", Print::ref_cast(val)); + formatter.field("vis", Lite(&self.value.vis)); + if self.value.unsafety.is_some() { + formatter.field("unsafety", &Present); } - if let Some(val) = &_val.auto_token { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Auto); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } - } - formatter.field("auto_token", Print::ref_cast(val)); + if self.value.auto_token.is_some() { + formatter.field("auto_token", &Present); } - formatter.field("ident", Lite(&_val.ident)); - formatter.field("generics", Lite(&_val.generics)); - if let Some(val) = &_val.colon_token { + if let Some(val) = &self.value.restriction { #[derive(RefCast)] #[repr(transparent)] - struct Print(syn::token::Colon); + struct Print(syn::ImplRestriction); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0), formatter)?; + formatter.write_str(")")?; Ok(()) } } - formatter.field("colon_token", Print::ref_cast(val)); + formatter.field("restriction", Print::ref_cast(val)); + } + formatter.field("ident", Lite(&self.value.ident)); + formatter.field("generics", Lite(&self.value.generics)); + if self.value.colon_token.is_some() { + formatter.field("colon_token", &Present); } - if !_val.supertraits.is_empty() { - formatter.field("supertraits", Lite(&_val.supertraits)); + if !self.value.supertraits.is_empty() { + formatter.field("supertraits", Lite(&self.value.supertraits)); } - if !_val.items.is_empty() { - formatter.field("items", Lite(&_val.items)); + if !self.value.items.is_empty() { + formatter.field("items", Lite(&self.value.items)); } formatter.finish() } } impl Debug for Lite<syn::ItemTraitAlias> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("ItemTraitAlias"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - formatter.field("vis", Lite(&_val.vis)); - formatter.field("ident", Lite(&_val.ident)); - formatter.field("generics", Lite(&_val.generics)); - if !_val.bounds.is_empty() { - formatter.field("bounds", Lite(&_val.bounds)); + formatter.field("vis", Lite(&self.value.vis)); + formatter.field("ident", Lite(&self.value.ident)); + formatter.field("generics", Lite(&self.value.generics)); + if !self.value.bounds.is_empty() { + formatter.field("bounds", Lite(&self.value.bounds)); } formatter.finish() } } impl Debug for Lite<syn::ItemType> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("ItemType"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - formatter.field("vis", Lite(&_val.vis)); - formatter.field("ident", Lite(&_val.ident)); - formatter.field("generics", Lite(&_val.generics)); - formatter.field("ty", Lite(&_val.ty)); + formatter.field("vis", Lite(&self.value.vis)); + formatter.field("ident", Lite(&self.value.ident)); + formatter.field("generics", Lite(&self.value.generics)); + formatter.field("ty", Lite(&self.value.ty)); formatter.finish() } } impl Debug for Lite<syn::ItemUnion> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("ItemUnion"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - formatter.field("vis", Lite(&_val.vis)); - formatter.field("ident", Lite(&_val.ident)); - formatter.field("generics", Lite(&_val.generics)); - formatter.field("fields", Lite(&_val.fields)); + formatter.field("vis", Lite(&self.value.vis)); + formatter.field("ident", Lite(&self.value.ident)); + formatter.field("generics", Lite(&self.value.generics)); + formatter.field("fields", Lite(&self.value.fields)); formatter.finish() } } impl Debug for Lite<syn::ItemUse> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("ItemUse"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - formatter.field("vis", Lite(&_val.vis)); - if let Some(val) = &_val.leading_colon { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Colon2); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } - } - formatter.field("leading_colon", Print::ref_cast(val)); + formatter.field("vis", Lite(&self.value.vis)); + if self.value.leading_colon.is_some() { + formatter.field("leading_colon", &Present); } - formatter.field("tree", Lite(&_val.tree)); + formatter.field("tree", Lite(&self.value.tree)); formatter.finish() } } impl Debug for Lite<syn::Label> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("Label"); - formatter.field("name", Lite(&_val.name)); + formatter.field("name", Lite(&self.value.name)); formatter.finish() } } impl Debug for Lite<syn::Lifetime> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("Lifetime"); - formatter.field("ident", Lite(&_val.ident)); + formatter.field("ident", Lite(&self.value.ident)); formatter.finish() } } -impl Debug for Lite<syn::LifetimeDef> { +impl Debug for Lite<syn::LifetimeParam> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; - let mut formatter = formatter.debug_struct("LifetimeDef"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + let mut formatter = formatter.debug_struct("LifetimeParam"); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - formatter.field("lifetime", Lite(&_val.lifetime)); - if let Some(val) = &_val.colon_token { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Colon); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } - } - formatter.field("colon_token", Print::ref_cast(val)); + formatter.field("lifetime", Lite(&self.value.lifetime)); + if self.value.colon_token.is_some() { + formatter.field("colon_token", &Present); } - if !_val.bounds.is_empty() { - formatter.field("bounds", Lite(&_val.bounds)); + if !self.value.bounds.is_empty() { + formatter.field("bounds", Lite(&self.value.bounds)); } formatter.finish() } } impl Debug for Lite<syn::Lit> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; - match _val { + match &self.value { syn::Lit::Str(_val) => write!(formatter, "{:?}", _val.value()), syn::Lit::ByteStr(_val) => write!(formatter, "{:?}", _val.value()), syn::Lit::Byte(_val) => write!(formatter, "{:?}", _val.value()), @@ -3438,77 +2875,68 @@ impl Debug for Lite<syn::Lit> { formatter.finish() } syn::Lit::Verbatim(_val) => { - formatter.write_str("Verbatim")?; + formatter.write_str("Lit::Verbatim")?; formatter.write_str("(`")?; Display::fmt(_val, formatter)?; formatter.write_str("`)")?; Ok(()) } + _ => unreachable!(), } } } impl Debug for Lite<syn::LitBool> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("LitBool"); - formatter.field("value", Lite(&_val.value)); + formatter.field("value", Lite(&self.value.value)); formatter.finish() } } impl Debug for Lite<syn::LitByte> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; - write!(formatter, "{:?}", _val.value()) + write!(formatter, "{:?}", self.value.value()) } } impl Debug for Lite<syn::LitByteStr> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; - write!(formatter, "{:?}", _val.value()) + write!(formatter, "{:?}", self.value.value()) } } impl Debug for Lite<syn::LitChar> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; - write!(formatter, "{:?}", _val.value()) + write!(formatter, "{:?}", self.value.value()) } } impl Debug for Lite<syn::LitFloat> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; - write!(formatter, "{}", _val) + write!(formatter, "{}", & self.value) } } impl Debug for Lite<syn::LitInt> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; - write!(formatter, "{}", _val) + write!(formatter, "{}", & self.value) } } impl Debug for Lite<syn::LitStr> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; - write!(formatter, "{:?}", _val.value()) + write!(formatter, "{:?}", self.value.value()) } } impl Debug for Lite<syn::Local> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("Local"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - formatter.field("pat", Lite(&_val.pat)); - if let Some(val) = &_val.init { + formatter.field("pat", Lite(&self.value.pat)); + if let Some(val) = &self.value.init { #[derive(RefCast)] #[repr(transparent)] - struct Print((syn::token::Eq, Box<syn::Expr>)); + struct Print(syn::LocalInit); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - let _val = &self.0; - formatter.write_str("(")?; - Debug::fmt(Lite(&_val.1), formatter)?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0), formatter)?; formatter.write_str(")")?; Ok(()) } @@ -3518,30 +2946,49 @@ impl Debug for Lite<syn::Local> { formatter.finish() } } +impl Debug for Lite<syn::LocalInit> { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + let mut formatter = formatter.debug_struct("LocalInit"); + formatter.field("expr", Lite(&self.value.expr)); + if let Some(val) = &self.value.diverge { + #[derive(RefCast)] + #[repr(transparent)] + struct Print((syn::token::Else, Box<syn::Expr>)); + impl Debug for Print { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0.1), formatter)?; + formatter.write_str(")")?; + Ok(()) + } + } + formatter.field("diverge", Print::ref_cast(val)); + } + formatter.finish() + } +} impl Debug for Lite<syn::Macro> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("Macro"); - formatter.field("path", Lite(&_val.path)); - formatter.field("delimiter", Lite(&_val.delimiter)); - formatter.field("tokens", Lite(&_val.tokens)); + formatter.field("path", Lite(&self.value.path)); + formatter.field("delimiter", Lite(&self.value.delimiter)); + formatter.field("tokens", Lite(&self.value.tokens)); formatter.finish() } } impl Debug for Lite<syn::MacroDelimiter> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; - match _val { + match &self.value { syn::MacroDelimiter::Paren(_val) => { - formatter.write_str("Paren")?; + formatter.write_str("MacroDelimiter::Paren")?; Ok(()) } syn::MacroDelimiter::Brace(_val) => { - formatter.write_str("Brace")?; + formatter.write_str("MacroDelimiter::Brace")?; Ok(()) } syn::MacroDelimiter::Bracket(_val) => { - formatter.write_str("Bracket")?; + formatter.write_str("MacroDelimiter::Bracket")?; Ok(()) } } @@ -3549,17 +2996,16 @@ impl Debug for Lite<syn::MacroDelimiter> { } impl Debug for Lite<syn::Member> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; - match _val { + match &self.value { syn::Member::Named(_val) => { - formatter.write_str("Named")?; + formatter.write_str("Member::Named")?; formatter.write_str("(")?; Debug::fmt(Lite(_val), formatter)?; formatter.write_str(")")?; Ok(()) } syn::Member::Unnamed(_val) => { - formatter.write_str("Unnamed")?; + formatter.write_str("Member::Unnamed")?; formatter.write_str("(")?; Debug::fmt(Lite(_val), formatter)?; formatter.write_str(")")?; @@ -3570,27 +3016,28 @@ impl Debug for Lite<syn::Member> { } impl Debug for Lite<syn::Meta> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; - match _val { + match &self.value { syn::Meta::Path(_val) => { - formatter.write_str("Path")?; - formatter.write_str("(")?; - Debug::fmt(Lite(_val), formatter)?; - formatter.write_str(")")?; - Ok(()) + let mut formatter = formatter.debug_struct("Meta::Path"); + if _val.leading_colon.is_some() { + formatter.field("leading_colon", &Present); + } + if !_val.segments.is_empty() { + formatter.field("segments", Lite(&_val.segments)); + } + formatter.finish() } syn::Meta::List(_val) => { let mut formatter = formatter.debug_struct("Meta::List"); formatter.field("path", Lite(&_val.path)); - if !_val.nested.is_empty() { - formatter.field("nested", Lite(&_val.nested)); - } + formatter.field("delimiter", Lite(&_val.delimiter)); + formatter.field("tokens", Lite(&_val.tokens)); formatter.finish() } syn::Meta::NameValue(_val) => { let mut formatter = formatter.debug_struct("Meta::NameValue"); formatter.field("path", Lite(&_val.path)); - formatter.field("lit", Lite(&_val.lit)); + formatter.field("value", Lite(&_val.value)); formatter.finish() } } @@ -3598,106 +3045,51 @@ impl Debug for Lite<syn::Meta> { } impl Debug for Lite<syn::MetaList> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("MetaList"); - formatter.field("path", Lite(&_val.path)); - if !_val.nested.is_empty() { - formatter.field("nested", Lite(&_val.nested)); - } + formatter.field("path", Lite(&self.value.path)); + formatter.field("delimiter", Lite(&self.value.delimiter)); + formatter.field("tokens", Lite(&self.value.tokens)); formatter.finish() } } impl Debug for Lite<syn::MetaNameValue> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("MetaNameValue"); - formatter.field("path", Lite(&_val.path)); - formatter.field("lit", Lite(&_val.lit)); + formatter.field("path", Lite(&self.value.path)); + formatter.field("value", Lite(&self.value.value)); formatter.finish() } } -impl Debug for Lite<syn::MethodTurbofish> { +impl Debug for Lite<syn::ParenthesizedGenericArguments> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; - let mut formatter = formatter.debug_struct("MethodTurbofish"); - if !_val.args.is_empty() { - formatter.field("args", Lite(&_val.args)); + let mut formatter = formatter.debug_struct("ParenthesizedGenericArguments"); + if !self.value.inputs.is_empty() { + formatter.field("inputs", Lite(&self.value.inputs)); } + formatter.field("output", Lite(&self.value.output)); formatter.finish() } } -impl Debug for Lite<syn::NestedMeta> { +impl Debug for Lite<syn::Pat> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; - match _val { - syn::NestedMeta::Meta(_val) => { - formatter.write_str("Meta")?; + match &self.value { + syn::Pat::Const(_val) => { + formatter.write_str("Pat::Const")?; formatter.write_str("(")?; Debug::fmt(Lite(_val), formatter)?; formatter.write_str(")")?; Ok(()) } - syn::NestedMeta::Lit(_val) => { - formatter.write_str("Lit")?; - formatter.write_str("(")?; - Debug::fmt(Lite(_val), formatter)?; - formatter.write_str(")")?; - Ok(()) - } - } - } -} -impl Debug for Lite<syn::ParenthesizedGenericArguments> { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; - let mut formatter = formatter.debug_struct("ParenthesizedGenericArguments"); - if !_val.inputs.is_empty() { - formatter.field("inputs", Lite(&_val.inputs)); - } - formatter.field("output", Lite(&_val.output)); - formatter.finish() - } -} -impl Debug for Lite<syn::Pat> { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; - match _val { - syn::Pat::Box(_val) => { - let mut formatter = formatter.debug_struct("Pat::Box"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); - } - formatter.field("pat", Lite(&_val.pat)); - formatter.finish() - } syn::Pat::Ident(_val) => { let mut formatter = formatter.debug_struct("Pat::Ident"); if !_val.attrs.is_empty() { formatter.field("attrs", Lite(&_val.attrs)); } - if let Some(val) = &_val.by_ref { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Ref); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } - } - formatter.field("by_ref", Print::ref_cast(val)); + if _val.by_ref.is_some() { + formatter.field("by_ref", &Present); } - if let Some(val) = &_val.mutability { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Mut); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } - } - formatter.field("mutability", Print::ref_cast(val)); + if _val.mutability.is_some() { + formatter.field("mutability", &Present); } formatter.field("ident", Lite(&_val.ident)); if let Some(val) = &_val.subpat { @@ -3706,10 +3098,8 @@ impl Debug for Lite<syn::Pat> { struct Print((syn::token::At, Box<syn::Pat>)); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - let _val = &self.0; - formatter.write_str("(")?; - Debug::fmt(Lite(&_val.1), formatter)?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0.1), formatter)?; formatter.write_str(")")?; Ok(()) } @@ -3719,93 +3109,61 @@ impl Debug for Lite<syn::Pat> { formatter.finish() } syn::Pat::Lit(_val) => { - let mut formatter = formatter.debug_struct("Pat::Lit"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); - } - formatter.field("expr", Lite(&_val.expr)); - formatter.finish() + formatter.write_str("Pat::Lit")?; + formatter.write_str("(")?; + Debug::fmt(Lite(_val), formatter)?; + formatter.write_str(")")?; + Ok(()) } syn::Pat::Macro(_val) => { - let mut formatter = formatter.debug_struct("Pat::Macro"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); - } - formatter.field("mac", Lite(&_val.mac)); - formatter.finish() + formatter.write_str("Pat::Macro")?; + formatter.write_str("(")?; + Debug::fmt(Lite(_val), formatter)?; + formatter.write_str(")")?; + Ok(()) } syn::Pat::Or(_val) => { let mut formatter = formatter.debug_struct("Pat::Or"); if !_val.attrs.is_empty() { formatter.field("attrs", Lite(&_val.attrs)); } - if let Some(val) = &_val.leading_vert { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Or); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } - } - formatter.field("leading_vert", Print::ref_cast(val)); + if _val.leading_vert.is_some() { + formatter.field("leading_vert", &Present); } if !_val.cases.is_empty() { formatter.field("cases", Lite(&_val.cases)); } formatter.finish() } - syn::Pat::Path(_val) => { - let mut formatter = formatter.debug_struct("Pat::Path"); + syn::Pat::Paren(_val) => { + let mut formatter = formatter.debug_struct("Pat::Paren"); if !_val.attrs.is_empty() { formatter.field("attrs", Lite(&_val.attrs)); } - if let Some(val) = &_val.qself { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::QSelf); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - let _val = &self.0; - formatter.write_str("(")?; - Debug::fmt(Lite(_val), formatter)?; - formatter.write_str(")")?; - Ok(()) - } - } - formatter.field("qself", Print::ref_cast(val)); - } - formatter.field("path", Lite(&_val.path)); + formatter.field("pat", Lite(&_val.pat)); formatter.finish() } + syn::Pat::Path(_val) => { + formatter.write_str("Pat::Path")?; + formatter.write_str("(")?; + Debug::fmt(Lite(_val), formatter)?; + formatter.write_str(")")?; + Ok(()) + } syn::Pat::Range(_val) => { - let mut formatter = formatter.debug_struct("Pat::Range"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); - } - formatter.field("lo", Lite(&_val.lo)); - formatter.field("limits", Lite(&_val.limits)); - formatter.field("hi", Lite(&_val.hi)); - formatter.finish() + formatter.write_str("Pat::Range")?; + formatter.write_str("(")?; + Debug::fmt(Lite(_val), formatter)?; + formatter.write_str(")")?; + Ok(()) } syn::Pat::Reference(_val) => { let mut formatter = formatter.debug_struct("Pat::Reference"); if !_val.attrs.is_empty() { formatter.field("attrs", Lite(&_val.attrs)); } - if let Some(val) = &_val.mutability { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Mut); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } - } - formatter.field("mutability", Print::ref_cast(val)); + if _val.mutability.is_some() { + formatter.field("mutability", &Present); } formatter.field("pat", Lite(&_val.pat)); formatter.finish() @@ -3832,21 +3190,37 @@ impl Debug for Lite<syn::Pat> { if !_val.attrs.is_empty() { formatter.field("attrs", Lite(&_val.attrs)); } + if let Some(val) = &_val.qself { + #[derive(RefCast)] + #[repr(transparent)] + struct Print(syn::QSelf); + impl Debug for Print { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0), formatter)?; + formatter.write_str(")")?; + Ok(()) + } + } + formatter.field("qself", Print::ref_cast(val)); + } formatter.field("path", Lite(&_val.path)); if !_val.fields.is_empty() { formatter.field("fields", Lite(&_val.fields)); } - if let Some(val) = &_val.dot2_token { + if let Some(val) = &_val.rest { #[derive(RefCast)] #[repr(transparent)] - struct Print(syn::token::Dot2); + struct Print(syn::PatRest); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0), formatter)?; + formatter.write_str(")")?; Ok(()) } } - formatter.field("dot2_token", Print::ref_cast(val)); + formatter.field("rest", Print::ref_cast(val)); } formatter.finish() } @@ -3865,8 +3239,24 @@ impl Debug for Lite<syn::Pat> { if !_val.attrs.is_empty() { formatter.field("attrs", Lite(&_val.attrs)); } + if let Some(val) = &_val.qself { + #[derive(RefCast)] + #[repr(transparent)] + struct Print(syn::QSelf); + impl Debug for Print { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0), formatter)?; + formatter.write_str(")")?; + Ok(()) + } + } + formatter.field("qself", Print::ref_cast(val)); + } formatter.field("path", Lite(&_val.path)); - formatter.field("pat", Lite(&_val.pat)); + if !_val.elems.is_empty() { + formatter.field("elems", Lite(&_val.elems)); + } formatter.finish() } syn::Pat::Type(_val) => { @@ -3879,7 +3269,7 @@ impl Debug for Lite<syn::Pat> { formatter.finish() } syn::Pat::Verbatim(_val) => { - formatter.write_str("Verbatim")?; + formatter.write_str("Pat::Verbatim")?; formatter.write_str("(`")?; Display::fmt(_val, formatter)?; formatter.write_str("`)")?; @@ -3896,59 +3286,27 @@ impl Debug for Lite<syn::Pat> { } } } -impl Debug for Lite<syn::PatBox> { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; - let mut formatter = formatter.debug_struct("PatBox"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); - } - formatter.field("pat", Lite(&_val.pat)); - formatter.finish() - } -} impl Debug for Lite<syn::PatIdent> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("PatIdent"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - if let Some(val) = &_val.by_ref { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Ref); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } - } - formatter.field("by_ref", Print::ref_cast(val)); + if self.value.by_ref.is_some() { + formatter.field("by_ref", &Present); } - if let Some(val) = &_val.mutability { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Mut); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } - } - formatter.field("mutability", Print::ref_cast(val)); + if self.value.mutability.is_some() { + formatter.field("mutability", &Present); } - formatter.field("ident", Lite(&_val.ident)); - if let Some(val) = &_val.subpat { + formatter.field("ident", Lite(&self.value.ident)); + if let Some(val) = &self.value.subpat { #[derive(RefCast)] #[repr(transparent)] struct Print((syn::token::At, Box<syn::Pat>)); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - let _val = &self.0; - formatter.write_str("(")?; - Debug::fmt(Lite(&_val.1), formatter)?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0.1), formatter)?; formatter.write_str(")")?; Ok(()) } @@ -3958,253 +3316,186 @@ impl Debug for Lite<syn::PatIdent> { formatter.finish() } } -impl Debug for Lite<syn::PatLit> { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; - let mut formatter = formatter.debug_struct("PatLit"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); - } - formatter.field("expr", Lite(&_val.expr)); - formatter.finish() - } -} -impl Debug for Lite<syn::PatMacro> { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; - let mut formatter = formatter.debug_struct("PatMacro"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); - } - formatter.field("mac", Lite(&_val.mac)); - formatter.finish() - } -} impl Debug for Lite<syn::PatOr> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("PatOr"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - if let Some(val) = &_val.leading_vert { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Or); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } - } - formatter.field("leading_vert", Print::ref_cast(val)); + if self.value.leading_vert.is_some() { + formatter.field("leading_vert", &Present); } - if !_val.cases.is_empty() { - formatter.field("cases", Lite(&_val.cases)); + if !self.value.cases.is_empty() { + formatter.field("cases", Lite(&self.value.cases)); } formatter.finish() } } -impl Debug for Lite<syn::PatPath> { +impl Debug for Lite<syn::PatParen> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; - let mut formatter = formatter.debug_struct("PatPath"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + let mut formatter = formatter.debug_struct("PatParen"); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - if let Some(val) = &_val.qself { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::QSelf); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - let _val = &self.0; - formatter.write_str("(")?; - Debug::fmt(Lite(_val), formatter)?; - formatter.write_str(")")?; - Ok(()) - } - } - formatter.field("qself", Print::ref_cast(val)); - } - formatter.field("path", Lite(&_val.path)); - formatter.finish() - } -} -impl Debug for Lite<syn::PatRange> { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; - let mut formatter = formatter.debug_struct("PatRange"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); - } - formatter.field("lo", Lite(&_val.lo)); - formatter.field("limits", Lite(&_val.limits)); - formatter.field("hi", Lite(&_val.hi)); + formatter.field("pat", Lite(&self.value.pat)); formatter.finish() } } impl Debug for Lite<syn::PatReference> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("PatReference"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - if let Some(val) = &_val.mutability { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Mut); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } - } - formatter.field("mutability", Print::ref_cast(val)); + if self.value.mutability.is_some() { + formatter.field("mutability", &Present); } - formatter.field("pat", Lite(&_val.pat)); + formatter.field("pat", Lite(&self.value.pat)); formatter.finish() } } impl Debug for Lite<syn::PatRest> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("PatRest"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } formatter.finish() } } impl Debug for Lite<syn::PatSlice> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("PatSlice"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - if !_val.elems.is_empty() { - formatter.field("elems", Lite(&_val.elems)); + if !self.value.elems.is_empty() { + formatter.field("elems", Lite(&self.value.elems)); } formatter.finish() } } impl Debug for Lite<syn::PatStruct> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("PatStruct"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - formatter.field("path", Lite(&_val.path)); - if !_val.fields.is_empty() { - formatter.field("fields", Lite(&_val.fields)); + if let Some(val) = &self.value.qself { + #[derive(RefCast)] + #[repr(transparent)] + struct Print(syn::QSelf); + impl Debug for Print { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0), formatter)?; + formatter.write_str(")")?; + Ok(()) + } + } + formatter.field("qself", Print::ref_cast(val)); } - if let Some(val) = &_val.dot2_token { + formatter.field("path", Lite(&self.value.path)); + if !self.value.fields.is_empty() { + formatter.field("fields", Lite(&self.value.fields)); + } + if let Some(val) = &self.value.rest { #[derive(RefCast)] #[repr(transparent)] - struct Print(syn::token::Dot2); + struct Print(syn::PatRest); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0), formatter)?; + formatter.write_str(")")?; Ok(()) } } - formatter.field("dot2_token", Print::ref_cast(val)); + formatter.field("rest", Print::ref_cast(val)); } formatter.finish() } } impl Debug for Lite<syn::PatTuple> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("PatTuple"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - if !_val.elems.is_empty() { - formatter.field("elems", Lite(&_val.elems)); + if !self.value.elems.is_empty() { + formatter.field("elems", Lite(&self.value.elems)); } formatter.finish() } } impl Debug for Lite<syn::PatTupleStruct> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("PatTupleStruct"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); + } + if let Some(val) = &self.value.qself { + #[derive(RefCast)] + #[repr(transparent)] + struct Print(syn::QSelf); + impl Debug for Print { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0), formatter)?; + formatter.write_str(")")?; + Ok(()) + } + } + formatter.field("qself", Print::ref_cast(val)); + } + formatter.field("path", Lite(&self.value.path)); + if !self.value.elems.is_empty() { + formatter.field("elems", Lite(&self.value.elems)); } - formatter.field("path", Lite(&_val.path)); - formatter.field("pat", Lite(&_val.pat)); formatter.finish() } } impl Debug for Lite<syn::PatType> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("PatType"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - formatter.field("pat", Lite(&_val.pat)); - formatter.field("ty", Lite(&_val.ty)); + formatter.field("pat", Lite(&self.value.pat)); + formatter.field("ty", Lite(&self.value.ty)); formatter.finish() } } impl Debug for Lite<syn::PatWild> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("PatWild"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } formatter.finish() } } impl Debug for Lite<syn::Path> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("Path"); - if let Some(val) = &_val.leading_colon { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Colon2); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } - } - formatter.field("leading_colon", Print::ref_cast(val)); + if self.value.leading_colon.is_some() { + formatter.field("leading_colon", &Present); } - if !_val.segments.is_empty() { - formatter.field("segments", Lite(&_val.segments)); + if !self.value.segments.is_empty() { + formatter.field("segments", Lite(&self.value.segments)); } formatter.finish() } } impl Debug for Lite<syn::PathArguments> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; - match _val { - syn::PathArguments::None => formatter.write_str("None"), + match &self.value { + syn::PathArguments::None => formatter.write_str("PathArguments::None"), syn::PathArguments::AngleBracketed(_val) => { let mut formatter = formatter .debug_struct("PathArguments::AngleBracketed"); - if let Some(val) = &_val.colon2_token { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Colon2); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } - } - formatter.field("colon2_token", Print::ref_cast(val)); + if _val.colon2_token.is_some() { + formatter.field("colon2_token", &Present); } if !_val.args.is_empty() { formatter.field("args", Lite(&_val.args)); @@ -4225,91 +3516,71 @@ impl Debug for Lite<syn::PathArguments> { } impl Debug for Lite<syn::PathSegment> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("PathSegment"); - formatter.field("ident", Lite(&_val.ident)); - formatter.field("arguments", Lite(&_val.arguments)); - formatter.finish() - } -} -impl Debug for Lite<syn::PredicateEq> { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; - let mut formatter = formatter.debug_struct("PredicateEq"); - formatter.field("lhs_ty", Lite(&_val.lhs_ty)); - formatter.field("rhs_ty", Lite(&_val.rhs_ty)); + formatter.field("ident", Lite(&self.value.ident)); + match self.value.arguments { + syn::PathArguments::None => {} + _ => { + formatter.field("arguments", Lite(&self.value.arguments)); + } + } formatter.finish() } } impl Debug for Lite<syn::PredicateLifetime> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("PredicateLifetime"); - formatter.field("lifetime", Lite(&_val.lifetime)); - if !_val.bounds.is_empty() { - formatter.field("bounds", Lite(&_val.bounds)); + formatter.field("lifetime", Lite(&self.value.lifetime)); + if !self.value.bounds.is_empty() { + formatter.field("bounds", Lite(&self.value.bounds)); } formatter.finish() } } impl Debug for Lite<syn::PredicateType> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("PredicateType"); - if let Some(val) = &_val.lifetimes { + if let Some(val) = &self.value.lifetimes { #[derive(RefCast)] #[repr(transparent)] struct Print(syn::BoundLifetimes); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - let _val = &self.0; - formatter.write_str("(")?; - Debug::fmt(Lite(_val), formatter)?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0), formatter)?; formatter.write_str(")")?; Ok(()) } } formatter.field("lifetimes", Print::ref_cast(val)); } - formatter.field("bounded_ty", Lite(&_val.bounded_ty)); - if !_val.bounds.is_empty() { - formatter.field("bounds", Lite(&_val.bounds)); + formatter.field("bounded_ty", Lite(&self.value.bounded_ty)); + if !self.value.bounds.is_empty() { + formatter.field("bounds", Lite(&self.value.bounds)); } formatter.finish() } } impl Debug for Lite<syn::QSelf> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("QSelf"); - formatter.field("ty", Lite(&_val.ty)); - formatter.field("position", Lite(&_val.position)); - if let Some(val) = &_val.as_token { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::As); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } - } - formatter.field("as_token", Print::ref_cast(val)); + formatter.field("ty", Lite(&self.value.ty)); + formatter.field("position", Lite(&self.value.position)); + if self.value.as_token.is_some() { + formatter.field("as_token", &Present); } formatter.finish() } } impl Debug for Lite<syn::RangeLimits> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; - match _val { + match &self.value { syn::RangeLimits::HalfOpen(_val) => { - formatter.write_str("HalfOpen")?; + formatter.write_str("RangeLimits::HalfOpen")?; Ok(()) } syn::RangeLimits::Closed(_val) => { - formatter.write_str("Closed")?; + formatter.write_str("RangeLimits::Closed")?; Ok(()) } } @@ -4317,20 +3588,17 @@ impl Debug for Lite<syn::RangeLimits> { } impl Debug for Lite<syn::Receiver> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("Receiver"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - if let Some(val) = &_val.reference { + if let Some(val) = &self.value.reference { #[derive(RefCast)] #[repr(transparent)] struct Print((syn::token::And, Option<syn::Lifetime>)); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - let _val = &self.0; - formatter.write_str("(")?; + formatter.write_str("Some(")?; Debug::fmt( { #[derive(RefCast)] @@ -4343,8 +3611,7 @@ impl Debug for Lite<syn::Receiver> { ) -> fmt::Result { match &self.0 { Some(_val) => { - formatter.write_str("Some")?; - formatter.write_str("(")?; + formatter.write_str("Some(")?; Debug::fmt(Lite(_val), formatter)?; formatter.write_str(")")?; Ok(()) @@ -4353,7 +3620,7 @@ impl Debug for Lite<syn::Receiver> { } } } - Print::ref_cast(&_val.1) + Print::ref_cast(&self.0.1) }, formatter, )?; @@ -4363,28 +3630,22 @@ impl Debug for Lite<syn::Receiver> { } formatter.field("reference", Print::ref_cast(val)); } - if let Some(val) = &_val.mutability { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Mut); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } - } - formatter.field("mutability", Print::ref_cast(val)); + if self.value.mutability.is_some() { + formatter.field("mutability", &Present); } + if self.value.colon_token.is_some() { + formatter.field("colon_token", &Present); + } + formatter.field("ty", Lite(&self.value.ty)); formatter.finish() } } impl Debug for Lite<syn::ReturnType> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; - match _val { - syn::ReturnType::Default => formatter.write_str("Default"), + match &self.value { + syn::ReturnType::Default => formatter.write_str("ReturnType::Default"), syn::ReturnType::Type(_v0, _v1) => { - let mut formatter = formatter.debug_tuple("Type"); + let mut formatter = formatter.debug_tuple("ReturnType::Type"); formatter.field(Lite(_v1)); formatter.finish() } @@ -4393,162 +3654,173 @@ impl Debug for Lite<syn::ReturnType> { } impl Debug for Lite<syn::Signature> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("Signature"); - if let Some(val) = &_val.constness { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Const); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } - } - formatter.field("constness", Print::ref_cast(val)); + if self.value.constness.is_some() { + formatter.field("constness", &Present); } - if let Some(val) = &_val.asyncness { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Async); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } - } - formatter.field("asyncness", Print::ref_cast(val)); + if self.value.asyncness.is_some() { + formatter.field("asyncness", &Present); } - if let Some(val) = &_val.unsafety { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Unsafe); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } - } - formatter.field("unsafety", Print::ref_cast(val)); + if self.value.unsafety.is_some() { + formatter.field("unsafety", &Present); } - if let Some(val) = &_val.abi { + if let Some(val) = &self.value.abi { #[derive(RefCast)] #[repr(transparent)] struct Print(syn::Abi); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - let _val = &self.0; - formatter.write_str("(")?; - Debug::fmt(Lite(_val), formatter)?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0), formatter)?; formatter.write_str(")")?; Ok(()) } } formatter.field("abi", Print::ref_cast(val)); } - formatter.field("ident", Lite(&_val.ident)); - formatter.field("generics", Lite(&_val.generics)); - if !_val.inputs.is_empty() { - formatter.field("inputs", Lite(&_val.inputs)); + formatter.field("ident", Lite(&self.value.ident)); + formatter.field("generics", Lite(&self.value.generics)); + if !self.value.inputs.is_empty() { + formatter.field("inputs", Lite(&self.value.inputs)); } - if let Some(val) = &_val.variadic { + if let Some(val) = &self.value.variadic { #[derive(RefCast)] #[repr(transparent)] struct Print(syn::Variadic); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - let _val = &self.0; - formatter.write_str("(")?; - Debug::fmt(Lite(_val), formatter)?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0), formatter)?; formatter.write_str(")")?; Ok(()) } } formatter.field("variadic", Print::ref_cast(val)); } - formatter.field("output", Lite(&_val.output)); + formatter.field("output", Lite(&self.value.output)); formatter.finish() } } +impl Debug for Lite<syn::StaticMutability> { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + match &self.value { + syn::StaticMutability::Mut(_val) => { + formatter.write_str("StaticMutability::Mut")?; + Ok(()) + } + syn::StaticMutability::None => formatter.write_str("StaticMutability::None"), + _ => unreachable!(), + } + } +} impl Debug for Lite<syn::Stmt> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; - match _val { + match &self.value { syn::Stmt::Local(_val) => { - formatter.write_str("Local")?; - formatter.write_str("(")?; - Debug::fmt(Lite(_val), formatter)?; - formatter.write_str(")")?; - Ok(()) + let mut formatter = formatter.debug_struct("Stmt::Local"); + if !_val.attrs.is_empty() { + formatter.field("attrs", Lite(&_val.attrs)); + } + formatter.field("pat", Lite(&_val.pat)); + if let Some(val) = &_val.init { + #[derive(RefCast)] + #[repr(transparent)] + struct Print(syn::LocalInit); + impl Debug for Print { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0), formatter)?; + formatter.write_str(")")?; + Ok(()) + } + } + formatter.field("init", Print::ref_cast(val)); + } + formatter.finish() } syn::Stmt::Item(_val) => { - formatter.write_str("Item")?; - formatter.write_str("(")?; - Debug::fmt(Lite(_val), formatter)?; - formatter.write_str(")")?; - Ok(()) - } - syn::Stmt::Expr(_val) => { - formatter.write_str("Expr")?; + formatter.write_str("Stmt::Item")?; formatter.write_str("(")?; Debug::fmt(Lite(_val), formatter)?; formatter.write_str(")")?; Ok(()) } - syn::Stmt::Semi(_v0, _v1) => { - let mut formatter = formatter.debug_tuple("Semi"); + syn::Stmt::Expr(_v0, _v1) => { + let mut formatter = formatter.debug_tuple("Stmt::Expr"); formatter.field(Lite(_v0)); + formatter + .field( + &super::Option { + present: _v1.is_some(), + }, + ); formatter.finish() } + syn::Stmt::Macro(_val) => { + let mut formatter = formatter.debug_struct("Stmt::Macro"); + if !_val.attrs.is_empty() { + formatter.field("attrs", Lite(&_val.attrs)); + } + formatter.field("mac", Lite(&_val.mac)); + if _val.semi_token.is_some() { + formatter.field("semi_token", &Present); + } + formatter.finish() + } + } + } +} +impl Debug for Lite<syn::StmtMacro> { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + let mut formatter = formatter.debug_struct("StmtMacro"); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); + } + formatter.field("mac", Lite(&self.value.mac)); + if self.value.semi_token.is_some() { + formatter.field("semi_token", &Present); } + formatter.finish() } } impl Debug for Lite<syn::TraitBound> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("TraitBound"); - if let Some(val) = &_val.paren_token { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Paren); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } + if self.value.paren_token.is_some() { + formatter.field("paren_token", &Present); + } + match self.value.modifier { + syn::TraitBoundModifier::None => {} + _ => { + formatter.field("modifier", Lite(&self.value.modifier)); } - formatter.field("paren_token", Print::ref_cast(val)); } - formatter.field("modifier", Lite(&_val.modifier)); - if let Some(val) = &_val.lifetimes { + if let Some(val) = &self.value.lifetimes { #[derive(RefCast)] #[repr(transparent)] struct Print(syn::BoundLifetimes); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - let _val = &self.0; - formatter.write_str("(")?; - Debug::fmt(Lite(_val), formatter)?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0), formatter)?; formatter.write_str(")")?; Ok(()) } } formatter.field("lifetimes", Print::ref_cast(val)); } - formatter.field("path", Lite(&_val.path)); + formatter.field("path", Lite(&self.value.path)); formatter.finish() } } impl Debug for Lite<syn::TraitBoundModifier> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; - match _val { - syn::TraitBoundModifier::None => formatter.write_str("None"), + match &self.value { + syn::TraitBoundModifier::None => { + formatter.write_str("TraitBoundModifier::None") + } syn::TraitBoundModifier::Maybe(_val) => { - formatter.write_str("Maybe")?; + formatter.write_str("TraitBoundModifier::Maybe")?; Ok(()) } } @@ -4556,14 +3828,14 @@ impl Debug for Lite<syn::TraitBoundModifier> { } impl Debug for Lite<syn::TraitItem> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; - match _val { + match &self.value { syn::TraitItem::Const(_val) => { let mut formatter = formatter.debug_struct("TraitItem::Const"); if !_val.attrs.is_empty() { formatter.field("attrs", Lite(&_val.attrs)); } formatter.field("ident", Lite(&_val.ident)); + formatter.field("generics", Lite(&_val.generics)); formatter.field("ty", Lite(&_val.ty)); if let Some(val) = &_val.default { #[derive(RefCast)] @@ -4571,10 +3843,8 @@ impl Debug for Lite<syn::TraitItem> { struct Print((syn::token::Eq, syn::Expr)); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - let _val = &self.0; - formatter.write_str("(")?; - Debug::fmt(Lite(&_val.1), formatter)?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0.1), formatter)?; formatter.write_str(")")?; Ok(()) } @@ -4583,8 +3853,8 @@ impl Debug for Lite<syn::TraitItem> { } formatter.finish() } - syn::TraitItem::Method(_val) => { - let mut formatter = formatter.debug_struct("TraitItem::Method"); + syn::TraitItem::Fn(_val) => { + let mut formatter = formatter.debug_struct("TraitItem::Fn"); if !_val.attrs.is_empty() { formatter.field("attrs", Lite(&_val.attrs)); } @@ -4595,27 +3865,16 @@ impl Debug for Lite<syn::TraitItem> { struct Print(syn::Block); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - let _val = &self.0; - formatter.write_str("(")?; - Debug::fmt(Lite(_val), formatter)?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0), formatter)?; formatter.write_str(")")?; Ok(()) } } formatter.field("default", Print::ref_cast(val)); } - if let Some(val) = &_val.semi_token { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Semi); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } - } - formatter.field("semi_token", Print::ref_cast(val)); + if _val.semi_token.is_some() { + formatter.field("semi_token", &Present); } formatter.finish() } @@ -4626,17 +3885,8 @@ impl Debug for Lite<syn::TraitItem> { } formatter.field("ident", Lite(&_val.ident)); formatter.field("generics", Lite(&_val.generics)); - if let Some(val) = &_val.colon_token { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Colon); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } - } - formatter.field("colon_token", Print::ref_cast(val)); + if _val.colon_token.is_some() { + formatter.field("colon_token", &Present); } if !_val.bounds.is_empty() { formatter.field("bounds", Lite(&_val.bounds)); @@ -4647,10 +3897,8 @@ impl Debug for Lite<syn::TraitItem> { struct Print((syn::token::Eq, syn::Type)); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - let _val = &self.0; - formatter.write_str("(")?; - Debug::fmt(Lite(&_val.1), formatter)?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0.1), formatter)?; formatter.write_str(")")?; Ok(()) } @@ -4665,22 +3913,13 @@ impl Debug for Lite<syn::TraitItem> { formatter.field("attrs", Lite(&_val.attrs)); } formatter.field("mac", Lite(&_val.mac)); - if let Some(val) = &_val.semi_token { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Semi); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } - } - formatter.field("semi_token", Print::ref_cast(val)); + if _val.semi_token.is_some() { + formatter.field("semi_token", &Present); } formatter.finish() } syn::TraitItem::Verbatim(_val) => { - formatter.write_str("Verbatim")?; + formatter.write_str("TraitItem::Verbatim")?; formatter.write_str("(`")?; Display::fmt(_val, formatter)?; formatter.write_str("`)")?; @@ -4692,23 +3931,21 @@ impl Debug for Lite<syn::TraitItem> { } impl Debug for Lite<syn::TraitItemConst> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("TraitItemConst"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - formatter.field("ident", Lite(&_val.ident)); - formatter.field("ty", Lite(&_val.ty)); - if let Some(val) = &_val.default { + formatter.field("ident", Lite(&self.value.ident)); + formatter.field("generics", Lite(&self.value.generics)); + formatter.field("ty", Lite(&self.value.ty)); + if let Some(val) = &self.value.default { #[derive(RefCast)] #[repr(transparent)] struct Print((syn::token::Eq, syn::Expr)); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - let _val = &self.0; - formatter.write_str("(")?; - Debug::fmt(Lite(&_val.1), formatter)?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0.1), formatter)?; formatter.write_str(")")?; Ok(()) } @@ -4718,102 +3955,68 @@ impl Debug for Lite<syn::TraitItemConst> { formatter.finish() } } -impl Debug for Lite<syn::TraitItemMacro> { +impl Debug for Lite<syn::TraitItemFn> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; - let mut formatter = formatter.debug_struct("TraitItemMacro"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + let mut formatter = formatter.debug_struct("TraitItemFn"); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - formatter.field("mac", Lite(&_val.mac)); - if let Some(val) = &_val.semi_token { + formatter.field("sig", Lite(&self.value.sig)); + if let Some(val) = &self.value.default { #[derive(RefCast)] #[repr(transparent)] - struct Print(syn::token::Semi); + struct Print(syn::Block); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0), formatter)?; + formatter.write_str(")")?; Ok(()) } } - formatter.field("semi_token", Print::ref_cast(val)); + formatter.field("default", Print::ref_cast(val)); + } + if self.value.semi_token.is_some() { + formatter.field("semi_token", &Present); } formatter.finish() } } -impl Debug for Lite<syn::TraitItemMethod> { +impl Debug for Lite<syn::TraitItemMacro> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; - let mut formatter = formatter.debug_struct("TraitItemMethod"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + let mut formatter = formatter.debug_struct("TraitItemMacro"); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - formatter.field("sig", Lite(&_val.sig)); - if let Some(val) = &_val.default { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::Block); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - let _val = &self.0; - formatter.write_str("(")?; - Debug::fmt(Lite(_val), formatter)?; - formatter.write_str(")")?; - Ok(()) - } - } - formatter.field("default", Print::ref_cast(val)); - } - if let Some(val) = &_val.semi_token { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Semi); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } - } - formatter.field("semi_token", Print::ref_cast(val)); + formatter.field("mac", Lite(&self.value.mac)); + if self.value.semi_token.is_some() { + formatter.field("semi_token", &Present); } formatter.finish() } } impl Debug for Lite<syn::TraitItemType> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("TraitItemType"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - formatter.field("ident", Lite(&_val.ident)); - formatter.field("generics", Lite(&_val.generics)); - if let Some(val) = &_val.colon_token { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Colon); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } - } - formatter.field("colon_token", Print::ref_cast(val)); + formatter.field("ident", Lite(&self.value.ident)); + formatter.field("generics", Lite(&self.value.generics)); + if self.value.colon_token.is_some() { + formatter.field("colon_token", &Present); } - if !_val.bounds.is_empty() { - formatter.field("bounds", Lite(&_val.bounds)); + if !self.value.bounds.is_empty() { + formatter.field("bounds", Lite(&self.value.bounds)); } - if let Some(val) = &_val.default { + if let Some(val) = &self.value.default { #[derive(RefCast)] #[repr(transparent)] struct Print((syn::token::Eq, syn::Type)); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - let _val = &self.0; - formatter.write_str("(")?; - Debug::fmt(Lite(&_val.1), formatter)?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0.1), formatter)?; formatter.write_str(")")?; Ok(()) } @@ -4825,8 +4028,7 @@ impl Debug for Lite<syn::TraitItemType> { } impl Debug for Lite<syn::Type> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; - match _val { + match &self.value { syn::Type::Array(_val) => { let mut formatter = formatter.debug_struct("Type::Array"); formatter.field("elem", Lite(&_val.elem)); @@ -4841,27 +4043,16 @@ impl Debug for Lite<syn::Type> { struct Print(syn::BoundLifetimes); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - let _val = &self.0; - formatter.write_str("(")?; - Debug::fmt(Lite(_val), formatter)?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0), formatter)?; formatter.write_str(")")?; Ok(()) } } formatter.field("lifetimes", Print::ref_cast(val)); } - if let Some(val) = &_val.unsafety { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Unsafe); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } - } - formatter.field("unsafety", Print::ref_cast(val)); + if _val.unsafety.is_some() { + formatter.field("unsafety", &Present); } if let Some(val) = &_val.abi { #[derive(RefCast)] @@ -4869,10 +4060,8 @@ impl Debug for Lite<syn::Type> { struct Print(syn::Abi); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - let _val = &self.0; - formatter.write_str("(")?; - Debug::fmt(Lite(_val), formatter)?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0), formatter)?; formatter.write_str(")")?; Ok(()) } @@ -4885,13 +4074,11 @@ impl Debug for Lite<syn::Type> { if let Some(val) = &_val.variadic { #[derive(RefCast)] #[repr(transparent)] - struct Print(syn::Variadic); + struct Print(syn::BareVariadic); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - let _val = &self.0; - formatter.write_str("(")?; - Debug::fmt(Lite(_val), formatter)?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0), formatter)?; formatter.write_str(")")?; Ok(()) } @@ -4939,10 +4126,8 @@ impl Debug for Lite<syn::Type> { struct Print(syn::QSelf); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - let _val = &self.0; - formatter.write_str("(")?; - Debug::fmt(Lite(_val), formatter)?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0), formatter)?; formatter.write_str(")")?; Ok(()) } @@ -4954,29 +4139,11 @@ impl Debug for Lite<syn::Type> { } syn::Type::Ptr(_val) => { let mut formatter = formatter.debug_struct("Type::Ptr"); - if let Some(val) = &_val.const_token { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Const); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } - } - formatter.field("const_token", Print::ref_cast(val)); + if _val.const_token.is_some() { + formatter.field("const_token", &Present); } - if let Some(val) = &_val.mutability { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Mut); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } - } - formatter.field("mutability", Print::ref_cast(val)); + if _val.mutability.is_some() { + formatter.field("mutability", &Present); } formatter.field("elem", Lite(&_val.elem)); formatter.finish() @@ -4989,27 +4156,16 @@ impl Debug for Lite<syn::Type> { struct Print(syn::Lifetime); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - let _val = &self.0; - formatter.write_str("(")?; - Debug::fmt(Lite(_val), formatter)?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0), formatter)?; formatter.write_str(")")?; Ok(()) } } formatter.field("lifetime", Print::ref_cast(val)); } - if let Some(val) = &_val.mutability { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Mut); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } - } - formatter.field("mutability", Print::ref_cast(val)); + if _val.mutability.is_some() { + formatter.field("mutability", &Present); } formatter.field("elem", Lite(&_val.elem)); formatter.finish() @@ -5021,17 +4177,8 @@ impl Debug for Lite<syn::Type> { } syn::Type::TraitObject(_val) => { let mut formatter = formatter.debug_struct("Type::TraitObject"); - if let Some(val) = &_val.dyn_token { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Dyn); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } - } - formatter.field("dyn_token", Print::ref_cast(val)); + if _val.dyn_token.is_some() { + formatter.field("dyn_token", &Present); } if !_val.bounds.is_empty() { formatter.field("bounds", Lite(&_val.bounds)); @@ -5046,7 +4193,7 @@ impl Debug for Lite<syn::Type> { formatter.finish() } syn::Type::Verbatim(_val) => { - formatter.write_str("Verbatim")?; + formatter.write_str("Type::Verbatim")?; formatter.write_str("(`")?; Display::fmt(_val, formatter)?; formatter.write_str("`)")?; @@ -5058,169 +4205,126 @@ impl Debug for Lite<syn::Type> { } impl Debug for Lite<syn::TypeArray> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("TypeArray"); - formatter.field("elem", Lite(&_val.elem)); - formatter.field("len", Lite(&_val.len)); + formatter.field("elem", Lite(&self.value.elem)); + formatter.field("len", Lite(&self.value.len)); formatter.finish() } } impl Debug for Lite<syn::TypeBareFn> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("TypeBareFn"); - if let Some(val) = &_val.lifetimes { + if let Some(val) = &self.value.lifetimes { #[derive(RefCast)] #[repr(transparent)] struct Print(syn::BoundLifetimes); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - let _val = &self.0; - formatter.write_str("(")?; - Debug::fmt(Lite(_val), formatter)?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0), formatter)?; formatter.write_str(")")?; Ok(()) } } formatter.field("lifetimes", Print::ref_cast(val)); } - if let Some(val) = &_val.unsafety { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Unsafe); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } - } - formatter.field("unsafety", Print::ref_cast(val)); + if self.value.unsafety.is_some() { + formatter.field("unsafety", &Present); } - if let Some(val) = &_val.abi { + if let Some(val) = &self.value.abi { #[derive(RefCast)] #[repr(transparent)] struct Print(syn::Abi); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - let _val = &self.0; - formatter.write_str("(")?; - Debug::fmt(Lite(_val), formatter)?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0), formatter)?; formatter.write_str(")")?; Ok(()) } } formatter.field("abi", Print::ref_cast(val)); } - if !_val.inputs.is_empty() { - formatter.field("inputs", Lite(&_val.inputs)); + if !self.value.inputs.is_empty() { + formatter.field("inputs", Lite(&self.value.inputs)); } - if let Some(val) = &_val.variadic { + if let Some(val) = &self.value.variadic { #[derive(RefCast)] #[repr(transparent)] - struct Print(syn::Variadic); + struct Print(syn::BareVariadic); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - let _val = &self.0; - formatter.write_str("(")?; - Debug::fmt(Lite(_val), formatter)?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0), formatter)?; formatter.write_str(")")?; Ok(()) } } formatter.field("variadic", Print::ref_cast(val)); } - formatter.field("output", Lite(&_val.output)); + formatter.field("output", Lite(&self.value.output)); formatter.finish() } } impl Debug for Lite<syn::TypeGroup> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("TypeGroup"); - formatter.field("elem", Lite(&_val.elem)); + formatter.field("elem", Lite(&self.value.elem)); formatter.finish() } } impl Debug for Lite<syn::TypeImplTrait> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("TypeImplTrait"); - if !_val.bounds.is_empty() { - formatter.field("bounds", Lite(&_val.bounds)); + if !self.value.bounds.is_empty() { + formatter.field("bounds", Lite(&self.value.bounds)); } formatter.finish() } } impl Debug for Lite<syn::TypeInfer> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("TypeInfer"); formatter.finish() } } impl Debug for Lite<syn::TypeMacro> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("TypeMacro"); - formatter.field("mac", Lite(&_val.mac)); + formatter.field("mac", Lite(&self.value.mac)); formatter.finish() } } impl Debug for Lite<syn::TypeNever> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("TypeNever"); formatter.finish() } } impl Debug for Lite<syn::TypeParam> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("TypeParam"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - formatter.field("ident", Lite(&_val.ident)); - if let Some(val) = &_val.colon_token { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Colon); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } - } - formatter.field("colon_token", Print::ref_cast(val)); + formatter.field("ident", Lite(&self.value.ident)); + if self.value.colon_token.is_some() { + formatter.field("colon_token", &Present); } - if !_val.bounds.is_empty() { - formatter.field("bounds", Lite(&_val.bounds)); + if !self.value.bounds.is_empty() { + formatter.field("bounds", Lite(&self.value.bounds)); } - if let Some(val) = &_val.eq_token { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Eq); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } - } - formatter.field("eq_token", Print::ref_cast(val)); + if self.value.eq_token.is_some() { + formatter.field("eq_token", &Present); } - if let Some(val) = &_val.default { + if let Some(val) = &self.value.default { #[derive(RefCast)] #[repr(transparent)] struct Print(syn::Type); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - let _val = &self.0; - formatter.write_str("(")?; - Debug::fmt(Lite(_val), formatter)?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0), formatter)?; formatter.write_str(")")?; Ok(()) } @@ -5232,261 +4336,213 @@ impl Debug for Lite<syn::TypeParam> { } impl Debug for Lite<syn::TypeParamBound> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; - match _val { + match &self.value { syn::TypeParamBound::Trait(_val) => { - formatter.write_str("Trait")?; + formatter.write_str("TypeParamBound::Trait")?; formatter.write_str("(")?; Debug::fmt(Lite(_val), formatter)?; formatter.write_str(")")?; Ok(()) } syn::TypeParamBound::Lifetime(_val) => { - formatter.write_str("Lifetime")?; - formatter.write_str("(")?; - Debug::fmt(Lite(_val), formatter)?; - formatter.write_str(")")?; + let mut formatter = formatter.debug_struct("TypeParamBound::Lifetime"); + formatter.field("ident", Lite(&_val.ident)); + formatter.finish() + } + syn::TypeParamBound::Verbatim(_val) => { + formatter.write_str("TypeParamBound::Verbatim")?; + formatter.write_str("(`")?; + Display::fmt(_val, formatter)?; + formatter.write_str("`)")?; Ok(()) } + _ => unreachable!(), } } } impl Debug for Lite<syn::TypeParen> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("TypeParen"); - formatter.field("elem", Lite(&_val.elem)); + formatter.field("elem", Lite(&self.value.elem)); formatter.finish() } } impl Debug for Lite<syn::TypePath> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("TypePath"); - if let Some(val) = &_val.qself { + if let Some(val) = &self.value.qself { #[derive(RefCast)] #[repr(transparent)] struct Print(syn::QSelf); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - let _val = &self.0; - formatter.write_str("(")?; - Debug::fmt(Lite(_val), formatter)?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0), formatter)?; formatter.write_str(")")?; Ok(()) } } formatter.field("qself", Print::ref_cast(val)); } - formatter.field("path", Lite(&_val.path)); + formatter.field("path", Lite(&self.value.path)); formatter.finish() } } impl Debug for Lite<syn::TypePtr> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("TypePtr"); - if let Some(val) = &_val.const_token { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Const); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } - } - formatter.field("const_token", Print::ref_cast(val)); + if self.value.const_token.is_some() { + formatter.field("const_token", &Present); } - if let Some(val) = &_val.mutability { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Mut); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } - } - formatter.field("mutability", Print::ref_cast(val)); + if self.value.mutability.is_some() { + formatter.field("mutability", &Present); } - formatter.field("elem", Lite(&_val.elem)); + formatter.field("elem", Lite(&self.value.elem)); formatter.finish() } } impl Debug for Lite<syn::TypeReference> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("TypeReference"); - if let Some(val) = &_val.lifetime { + if let Some(val) = &self.value.lifetime { #[derive(RefCast)] #[repr(transparent)] struct Print(syn::Lifetime); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - let _val = &self.0; - formatter.write_str("(")?; - Debug::fmt(Lite(_val), formatter)?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0), formatter)?; formatter.write_str(")")?; Ok(()) } } formatter.field("lifetime", Print::ref_cast(val)); } - if let Some(val) = &_val.mutability { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Mut); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } - } - formatter.field("mutability", Print::ref_cast(val)); + if self.value.mutability.is_some() { + formatter.field("mutability", &Present); } - formatter.field("elem", Lite(&_val.elem)); + formatter.field("elem", Lite(&self.value.elem)); formatter.finish() } } impl Debug for Lite<syn::TypeSlice> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("TypeSlice"); - formatter.field("elem", Lite(&_val.elem)); + formatter.field("elem", Lite(&self.value.elem)); formatter.finish() } } impl Debug for Lite<syn::TypeTraitObject> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("TypeTraitObject"); - if let Some(val) = &_val.dyn_token { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::Dyn); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } - } - formatter.field("dyn_token", Print::ref_cast(val)); + if self.value.dyn_token.is_some() { + formatter.field("dyn_token", &Present); } - if !_val.bounds.is_empty() { - formatter.field("bounds", Lite(&_val.bounds)); + if !self.value.bounds.is_empty() { + formatter.field("bounds", Lite(&self.value.bounds)); } formatter.finish() } } impl Debug for Lite<syn::TypeTuple> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("TypeTuple"); - if !_val.elems.is_empty() { - formatter.field("elems", Lite(&_val.elems)); + if !self.value.elems.is_empty() { + formatter.field("elems", Lite(&self.value.elems)); } formatter.finish() } } impl Debug for Lite<syn::UnOp> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; - match _val { + match &self.value { syn::UnOp::Deref(_val) => { - formatter.write_str("Deref")?; + formatter.write_str("UnOp::Deref")?; Ok(()) } syn::UnOp::Not(_val) => { - formatter.write_str("Not")?; + formatter.write_str("UnOp::Not")?; Ok(()) } syn::UnOp::Neg(_val) => { - formatter.write_str("Neg")?; + formatter.write_str("UnOp::Neg")?; Ok(()) } + _ => unreachable!(), } } } impl Debug for Lite<syn::UseGlob> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("UseGlob"); formatter.finish() } } impl Debug for Lite<syn::UseGroup> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("UseGroup"); - if !_val.items.is_empty() { - formatter.field("items", Lite(&_val.items)); + if !self.value.items.is_empty() { + formatter.field("items", Lite(&self.value.items)); } formatter.finish() } } impl Debug for Lite<syn::UseName> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("UseName"); - formatter.field("ident", Lite(&_val.ident)); + formatter.field("ident", Lite(&self.value.ident)); formatter.finish() } } impl Debug for Lite<syn::UsePath> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("UsePath"); - formatter.field("ident", Lite(&_val.ident)); - formatter.field("tree", Lite(&_val.tree)); + formatter.field("ident", Lite(&self.value.ident)); + formatter.field("tree", Lite(&self.value.tree)); formatter.finish() } } impl Debug for Lite<syn::UseRename> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("UseRename"); - formatter.field("ident", Lite(&_val.ident)); - formatter.field("rename", Lite(&_val.rename)); + formatter.field("ident", Lite(&self.value.ident)); + formatter.field("rename", Lite(&self.value.rename)); formatter.finish() } } impl Debug for Lite<syn::UseTree> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; - match _val { + match &self.value { syn::UseTree::Path(_val) => { - formatter.write_str("Path")?; + formatter.write_str("UseTree::Path")?; formatter.write_str("(")?; Debug::fmt(Lite(_val), formatter)?; formatter.write_str(")")?; Ok(()) } syn::UseTree::Name(_val) => { - formatter.write_str("Name")?; + formatter.write_str("UseTree::Name")?; formatter.write_str("(")?; Debug::fmt(Lite(_val), formatter)?; formatter.write_str(")")?; Ok(()) } syn::UseTree::Rename(_val) => { - formatter.write_str("Rename")?; + formatter.write_str("UseTree::Rename")?; formatter.write_str("(")?; Debug::fmt(Lite(_val), formatter)?; formatter.write_str(")")?; Ok(()) } syn::UseTree::Glob(_val) => { - formatter.write_str("Glob")?; + formatter.write_str("UseTree::Glob")?; formatter.write_str("(")?; Debug::fmt(Lite(_val), formatter)?; formatter.write_str(")")?; Ok(()) } syn::UseTree::Group(_val) => { - formatter.write_str("Group")?; + formatter.write_str("UseTree::Group")?; formatter.write_str("(")?; Debug::fmt(Lite(_val), formatter)?; formatter.write_str(")")?; @@ -5497,33 +4553,46 @@ impl Debug for Lite<syn::UseTree> { } impl Debug for Lite<syn::Variadic> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("Variadic"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); + } + if let Some(val) = &self.value.pat { + #[derive(RefCast)] + #[repr(transparent)] + struct Print((Box<syn::Pat>, syn::token::Colon)); + impl Debug for Print { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0.0), formatter)?; + formatter.write_str(")")?; + Ok(()) + } + } + formatter.field("pat", Print::ref_cast(val)); + } + if self.value.comma.is_some() { + formatter.field("comma", &Present); } formatter.finish() } } impl Debug for Lite<syn::Variant> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("Variant"); - if !_val.attrs.is_empty() { - formatter.field("attrs", Lite(&_val.attrs)); + if !self.value.attrs.is_empty() { + formatter.field("attrs", Lite(&self.value.attrs)); } - formatter.field("ident", Lite(&_val.ident)); - formatter.field("fields", Lite(&_val.fields)); - if let Some(val) = &_val.discriminant { + formatter.field("ident", Lite(&self.value.ident)); + formatter.field("fields", Lite(&self.value.fields)); + if let Some(val) = &self.value.discriminant { #[derive(RefCast)] #[repr(transparent)] struct Print((syn::token::Eq, syn::Expr)); impl Debug for Print { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - let _val = &self.0; - formatter.write_str("(")?; - Debug::fmt(Lite(&_val.1), formatter)?; + formatter.write_str("Some(")?; + Debug::fmt(Lite(&self.0.1), formatter)?; formatter.write_str(")")?; Ok(()) } @@ -5533,108 +4602,62 @@ impl Debug for Lite<syn::Variant> { formatter.finish() } } -impl Debug for Lite<syn::VisCrate> { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; - let mut formatter = formatter.debug_struct("VisCrate"); - formatter.finish() - } -} -impl Debug for Lite<syn::VisPublic> { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; - let mut formatter = formatter.debug_struct("VisPublic"); - formatter.finish() - } -} impl Debug for Lite<syn::VisRestricted> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("VisRestricted"); - if let Some(val) = &_val.in_token { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::In); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } - } - formatter.field("in_token", Print::ref_cast(val)); + if self.value.in_token.is_some() { + formatter.field("in_token", &Present); } - formatter.field("path", Lite(&_val.path)); + formatter.field("path", Lite(&self.value.path)); formatter.finish() } } impl Debug for Lite<syn::Visibility> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; - match _val { + match &self.value { syn::Visibility::Public(_val) => { - let mut formatter = formatter.debug_struct("Visibility::Public"); - formatter.finish() - } - syn::Visibility::Crate(_val) => { - let mut formatter = formatter.debug_struct("Visibility::Crate"); - formatter.finish() + formatter.write_str("Visibility::Public")?; + Ok(()) } syn::Visibility::Restricted(_val) => { let mut formatter = formatter.debug_struct("Visibility::Restricted"); - if let Some(val) = &_val.in_token { - #[derive(RefCast)] - #[repr(transparent)] - struct Print(syn::token::In); - impl Debug for Print { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter.write_str("Some")?; - Ok(()) - } - } - formatter.field("in_token", Print::ref_cast(val)); + if _val.in_token.is_some() { + formatter.field("in_token", &Present); } formatter.field("path", Lite(&_val.path)); formatter.finish() } - syn::Visibility::Inherited => formatter.write_str("Inherited"), + syn::Visibility::Inherited => formatter.write_str("Visibility::Inherited"), } } } impl Debug for Lite<syn::WhereClause> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; let mut formatter = formatter.debug_struct("WhereClause"); - if !_val.predicates.is_empty() { - formatter.field("predicates", Lite(&_val.predicates)); + if !self.value.predicates.is_empty() { + formatter.field("predicates", Lite(&self.value.predicates)); } formatter.finish() } } impl Debug for Lite<syn::WherePredicate> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - let _val = &self.value; - match _val { - syn::WherePredicate::Type(_val) => { - formatter.write_str("Type")?; - formatter.write_str("(")?; - Debug::fmt(Lite(_val), formatter)?; - formatter.write_str(")")?; - Ok(()) - } + match &self.value { syn::WherePredicate::Lifetime(_val) => { - formatter.write_str("Lifetime")?; + formatter.write_str("WherePredicate::Lifetime")?; formatter.write_str("(")?; Debug::fmt(Lite(_val), formatter)?; formatter.write_str(")")?; Ok(()) } - syn::WherePredicate::Eq(_val) => { - formatter.write_str("Eq")?; + syn::WherePredicate::Type(_val) => { + formatter.write_str("WherePredicate::Type")?; formatter.write_str("(")?; Debug::fmt(Lite(_val), formatter)?; formatter.write_str(")")?; Ok(()) } + _ => unreachable!(), } } } diff --git a/vendor/syn/tests/debug/mod.rs b/vendor/syn/tests/debug/mod.rs index 0a0991a92..caf9eed80 100644 --- a/vendor/syn/tests/debug/mod.rs +++ b/vendor/syn/tests/debug/mod.rs @@ -123,3 +123,21 @@ where .finish() } } + +struct Present; + +impl Debug for Present { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("Some") + } +} + +struct Option { + present: bool, +} + +impl Debug for Option { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str(if self.present { "Some" } else { "None" }) + } +} diff --git a/vendor/syn/tests/regression.rs b/vendor/syn/tests/regression.rs index fb2b25c89..5c7fcddc8 100644 --- a/vendor/syn/tests/regression.rs +++ b/vendor/syn/tests/regression.rs @@ -1,3 +1,5 @@ +#![allow(clippy::let_underscore_untyped, clippy::uninlined_format_args)] + mod regression { automod::dir!("tests/regression"); } diff --git a/vendor/syn/tests/regression/issue1108.rs b/vendor/syn/tests/regression/issue1108.rs index 4fd30c0c7..11a82adaa 100644 --- a/vendor/syn/tests/regression/issue1108.rs +++ b/vendor/syn/tests/regression/issue1108.rs @@ -1,5 +1,5 @@ #[test] fn issue1108() { let data = "impl<x<>>::x for"; - _ = syn::parse_file(data); + let _ = syn::parse_file(data); } diff --git a/vendor/syn/tests/repo/mod.rs b/vendor/syn/tests/repo/mod.rs index 8418b8719..7be1cc323 100644 --- a/vendor/syn/tests/repo/mod.rs +++ b/vendor/syn/tests/repo/mod.rs @@ -10,33 +10,95 @@ use std::path::Path; use tar::Archive; use walkdir::DirEntry; -const REVISION: &str = "98ad6a5519651af36e246c0335c964dd52c554ba"; +const REVISION: &str = "22f247c6f3ed388cb702d01c2ff27da658a8b353"; #[rustfmt::skip] static EXCLUDE_FILES: &[&str] = &[ - // TODO: impl ~const T {} - // https://github.com/dtolnay/syn/issues/1051 - "src/test/ui/rfc-2632-const-trait-impl/syntax.rs", - // Compile-fail expr parameter in const generic position: f::<1 + 2>() - "src/test/ui/const-generics/early/closing-args-token.rs", - "src/test/ui/const-generics/early/const-expression-parameter.rs", + "tests/ui/const-generics/early/closing-args-token.rs", + "tests/ui/const-generics/early/const-expression-parameter.rs", + + // Compile-fail variadics in not the last position of a function parameter list + "tests/ui/parser/variadic-ffi-syntactic-pass.rs", // Need at least one trait in impl Trait, no such type as impl 'static - "src/test/ui/type-alias-impl-trait/generic_type_does_not_live_long_enough.rs", + "tests/ui/type-alias-impl-trait/generic_type_does_not_live_long_enough.rs", + + // Lifetime bound inside for<>: `T: ~const ?for<'a: 'b> Trait<'a>` + "tests/ui/rfc-2632-const-trait-impl/tilde-const-syntax.rs", + + // Const impl that is not a trait impl: `impl ~const T {}` + "tests/ui/rfc-2632-const-trait-impl/syntax.rs", // Deprecated anonymous parameter syntax in traits - "src/test/ui/issues/issue-13105.rs", - "src/test/ui/issues/issue-13775.rs", - "src/test/ui/issues/issue-34074.rs", - "src/test/ui/proc-macro/trait-fn-args-2015.rs", "src/tools/rustfmt/tests/source/trait.rs", "src/tools/rustfmt/tests/target/trait.rs", + "tests/ui/issues/issue-13105.rs", + "tests/ui/issues/issue-13775.rs", + "tests/ui/issues/issue-34074.rs", + "tests/ui/proc-macro/trait-fn-args-2015.rs", + + // Deprecated where-clause location + "src/tools/rustfmt/tests/source/issue_4257.rs", + "src/tools/rustfmt/tests/source/issue_4911.rs", + "src/tools/rustfmt/tests/target/issue_4257.rs", + "src/tools/rustfmt/tests/target/issue_4911.rs", + "tests/pretty/gat-bounds.rs", + "tests/rustdoc/generic-associated-types/gats.rs", + + // Deprecated trait object syntax with parenthesized generic arguments and no dyn keyword + "src/tools/rust-analyzer/crates/parser/test_data/parser/inline/ok/0004_value_parameters_no_patterns.rs", + "src/tools/rust-analyzer/crates/parser/test_data/parser/inline/ok/0104_path_fn_trait_args.rs", + "src/tools/rust-analyzer/crates/parser/test_data/parser/inline/ok/0202_typepathfn_with_coloncolon.rs", + "src/tools/rustfmt/tests/source/attrib.rs", + "src/tools/rustfmt/tests/source/closure.rs", + "src/tools/rustfmt/tests/source/existential_type.rs", + "src/tools/rustfmt/tests/source/fn-simple.rs", + "src/tools/rustfmt/tests/source/fn_args_layout-vertical.rs", + "src/tools/rustfmt/tests/source/issue-4689/one.rs", + "src/tools/rustfmt/tests/source/issue-4689/two.rs", + "src/tools/rustfmt/tests/source/paths.rs", + "src/tools/rustfmt/tests/source/structs.rs", + "src/tools/rustfmt/tests/target/attrib.rs", + "src/tools/rustfmt/tests/target/closure.rs", + "src/tools/rustfmt/tests/target/existential_type.rs", + "src/tools/rustfmt/tests/target/fn-simple.rs", + "src/tools/rustfmt/tests/target/fn.rs", + "src/tools/rustfmt/tests/target/fn_args_layout-vertical.rs", + "src/tools/rustfmt/tests/target/issue-4689/one.rs", + "src/tools/rustfmt/tests/target/issue-4689/two.rs", + "src/tools/rustfmt/tests/target/paths.rs", + "src/tools/rustfmt/tests/target/structs.rs", + "tests/codegen-units/item-collection/non-generic-closures.rs", + "tests/debuginfo/recursive-enum.rs", + "tests/pretty/closure-reform-pretty.rs", + "tests/run-make-fulldeps/reproducible-build-2/reproducible-build.rs", + "tests/run-make-fulldeps/reproducible-build/reproducible-build.rs", + "tests/ui/auxiliary/typeid-intrinsic-aux1.rs", + "tests/ui/auxiliary/typeid-intrinsic-aux2.rs", + "tests/ui/impl-trait/generic-with-implicit-hrtb-without-dyn.rs", + "tests/ui/lifetimes/auxiliary/lifetime_bound_will_change_warning_lib.rs", + "tests/ui/lifetimes/bare-trait-object-borrowck.rs", + "tests/ui/lifetimes/bare-trait-object.rs", + "tests/ui/parser/bounds-obj-parens.rs", + + // Old type ascription expression syntax + "src/tools/rustfmt/tests/source/type-ascription.rs", + "src/tools/rustfmt/tests/target/type-ascription.rs", + + // Obsolete box syntax + "src/tools/rust-analyzer/crates/parser/test_data/parser/inline/ok/0132_box_expr.rs", + + // Invalid unparenthesized range pattern inside slice pattern: `[1..]` + "tests/ui/consts/miri_unleashed/const_refers_to_static_cross_crate.rs", // Various extensions to Rust syntax made up by rust-analyzer "src/tools/rust-analyzer/crates/parser/test_data/parser/inline/ok/0012_type_item_where_clause.rs", "src/tools/rust-analyzer/crates/parser/test_data/parser/inline/ok/0040_crate_keyword_vis.rs", + "src/tools/rust-analyzer/crates/parser/test_data/parser/inline/ok/0058_range_pat.rs", + "src/tools/rust-analyzer/crates/parser/test_data/parser/inline/ok/0123_param_list_vararg.rs", "src/tools/rust-analyzer/crates/parser/test_data/parser/inline/ok/0131_existential_type.rs", + "src/tools/rust-analyzer/crates/parser/test_data/parser/inline/ok/0156_fn_def_param.rs", "src/tools/rust-analyzer/crates/parser/test_data/parser/inline/ok/0179_use_tree_abs_star.rs", "src/tools/rust-analyzer/crates/parser/test_data/parser/inline/ok/0188_const_param_default_path.rs", "src/tools/rust-analyzer/crates/parser/test_data/parser/ok/0015_use_tree.rs", @@ -45,20 +107,44 @@ static EXCLUDE_FILES: &[&str] = &[ "src/tools/rust-analyzer/crates/parser/test_data/parser/ok/0055_dot_dot_dot.rs", "src/tools/rust-analyzer/crates/parser/test_data/parser/ok/0068_item_modifiers.rs", "src/tools/rust-analyzer/crates/syntax/test_data/parser/validation/0031_block_inner_attrs.rs", + "src/tools/rust-analyzer/crates/syntax/test_data/parser/validation/0038_endless_inclusive_range.rs", "src/tools/rust-analyzer/crates/syntax/test_data/parser/validation/0045_ambiguous_trait_object.rs", "src/tools/rust-analyzer/crates/syntax/test_data/parser/validation/0046_mutable_const_item.rs", // Placeholder syntax for "throw expressions" - "src/test/pretty/yeet-expr.rs", - "src/test/ui/try-trait/yeet-for-option.rs", - "src/test/ui/try-trait/yeet-for-result.rs", + "compiler/rustc_errors/src/translation.rs", + "src/tools/clippy/tests/ui/needless_return.rs", + "src/tools/rust-analyzer/crates/parser/test_data/parser/inline/ok/0204_yeet_expr.rs", + "tests/pretty/yeet-expr.rs", + "tests/ui/try-trait/yeet-for-option.rs", + "tests/ui/try-trait/yeet-for-result.rs", + + // Edition 2015 code using identifiers that are now keywords + // TODO: some of these we should probably parse + "src/tools/rust-analyzer/crates/parser/test_data/parser/inline/ok/0159_try_macro_fallback.rs", + "src/tools/rust-analyzer/crates/parser/test_data/parser/inline/ok/0160_try_macro_rules.rs", + "src/tools/rustfmt/tests/source/configs/indent_style/block_call.rs", + "src/tools/rustfmt/tests/source/configs/use_try_shorthand/false.rs", + "src/tools/rustfmt/tests/source/configs/use_try_shorthand/true.rs", + "src/tools/rustfmt/tests/source/issue_1306.rs", + "src/tools/rustfmt/tests/source/try-conversion.rs", + "src/tools/rustfmt/tests/target/configs/indent_style/block_call.rs", + "src/tools/rustfmt/tests/target/configs/use_try_shorthand/false.rs", + "src/tools/rustfmt/tests/target/issue-1681.rs", + "src/tools/rustfmt/tests/target/issue_1306.rs", + "tests/ui/dyn-keyword/dyn-2015-no-warnings-without-lints.rs", + "tests/ui/editions/edition-keywords-2015-2015.rs", + "tests/ui/editions/edition-keywords-2015-2018.rs", + "tests/ui/lint/lint_pre_expansion_extern_module_aux.rs", + "tests/ui/macros/macro-comma-support-rpass.rs", + "tests/ui/macros/try-macro.rs", + "tests/ui/parser/extern-crate-async.rs", + "tests/ui/try-block/try-is-identifier-edition2015.rs", // Excessive nesting - "src/test/ui/issues/issue-74564-if-expr-stack-overflow.rs", + "tests/ui/issues/issue-74564-if-expr-stack-overflow.rs", // Testing tools on invalid syntax - "src/test/run-make/translation/test.rs", - "src/test/ui/generics/issue-94432-garbage-ice.rs", "src/tools/rustfmt/tests/coverage/target/comments.rs", "src/tools/rustfmt/tests/parser/issue-4126/invalid.rs", "src/tools/rustfmt/tests/parser/issue_4418.rs", @@ -70,32 +156,22 @@ static EXCLUDE_FILES: &[&str] = &[ "src/tools/rustfmt/tests/target/configs/spaces_around_ranges/false.rs", "src/tools/rustfmt/tests/target/configs/spaces_around_ranges/true.rs", "src/tools/rustfmt/tests/target/type.rs", + "tests/run-make/translation/test.rs", + "tests/ui/generics/issue-94432-garbage-ice.rs", // Generated file containing a top-level expression, used with `include!` "compiler/rustc_codegen_gcc/src/intrinsic/archs.rs", // Clippy lint lists represented as expressions "src/tools/clippy/clippy_lints/src/lib.deprecated.rs", - "src/tools/clippy/clippy_lints/src/lib.register_all.rs", - "src/tools/clippy/clippy_lints/src/lib.register_cargo.rs", - "src/tools/clippy/clippy_lints/src/lib.register_complexity.rs", - "src/tools/clippy/clippy_lints/src/lib.register_correctness.rs", - "src/tools/clippy/clippy_lints/src/lib.register_internal.rs", - "src/tools/clippy/clippy_lints/src/lib.register_lints.rs", - "src/tools/clippy/clippy_lints/src/lib.register_nursery.rs", - "src/tools/clippy/clippy_lints/src/lib.register_pedantic.rs", - "src/tools/clippy/clippy_lints/src/lib.register_perf.rs", - "src/tools/clippy/clippy_lints/src/lib.register_restriction.rs", - "src/tools/clippy/clippy_lints/src/lib.register_style.rs", - "src/tools/clippy/clippy_lints/src/lib.register_suspicious.rs", // Not actually test cases - "src/test/ui/lint/expansion-time-include.rs", - "src/test/ui/macros/auxiliary/macro-comma-support.rs", - "src/test/ui/macros/auxiliary/macro-include-items-expr.rs", - "src/test/ui/macros/include-single-expr-helper.rs", - "src/test/ui/macros/include-single-expr-helper-1.rs", - "src/test/ui/parser/issues/auxiliary/issue-21146-inc.rs", + "tests/ui/lint/expansion-time-include.rs", + "tests/ui/macros/auxiliary/macro-comma-support.rs", + "tests/ui/macros/auxiliary/macro-include-items-expr.rs", + "tests/ui/macros/include-single-expr-helper.rs", + "tests/ui/macros/include-single-expr-helper-1.rs", + "tests/ui/parser/issues/auxiliary/issue-21146-inc.rs", ]; #[rustfmt::skip] @@ -135,7 +211,7 @@ pub fn base_dir_filter(entry: &DirEntry) -> bool { return false; } - if path_string.starts_with("src/test/ui") || path_string.starts_with("src/test/rustdoc-ui") { + if path_string.starts_with("tests/ui") || path_string.starts_with("tests/rustdoc-ui") { let stderr_path = path.with_extension("stderr"); if stderr_path.exists() { // Expected to fail in some way diff --git a/vendor/syn/tests/test_asyncness.rs b/vendor/syn/tests/test_asyncness.rs index 0efef5976..6bc5a1637 100644 --- a/vendor/syn/tests/test_asyncness.rs +++ b/vendor/syn/tests/test_asyncness.rs @@ -1,3 +1,5 @@ +#![allow(clippy::uninlined_format_args)] + #[macro_use] mod macros; @@ -9,12 +11,12 @@ fn test_async_fn() { snapshot!(input as Item, @r###" Item::Fn { - vis: Inherited, + vis: Visibility::Inherited, sig: Signature { asyncness: Some, ident: "process", generics: Generics, - output: Default, + output: ReturnType::Default, }, block: Block, } @@ -28,7 +30,7 @@ fn test_async_closure() { snapshot!(input as Expr, @r###" Expr::Closure { asyncness: Some, - output: Default, + output: ReturnType::Default, body: Expr::Block { block: Block, }, diff --git a/vendor/syn/tests/test_attribute.rs b/vendor/syn/tests/test_attribute.rs index c26bd090e..597ae3adc 100644 --- a/vendor/syn/tests/test_attribute.rs +++ b/vendor/syn/tests/test_attribute.rs @@ -1,3 +1,5 @@ +#![allow(clippy::uninlined_format_args)] + #[macro_use] mod macros; @@ -9,14 +11,13 @@ fn test_meta_item_word() { let meta = test("#[foo]"); snapshot!(meta, @r###" - Path(Path { + Meta::Path { segments: [ PathSegment { ident: "foo", - arguments: None, }, ], - }) + } "###); } @@ -30,11 +31,12 @@ fn test_meta_item_name_value() { segments: [ PathSegment { ident: "foo", - arguments: None, }, ], }, - lit: 5, + value: Expr::Lit { + lit: 5, + }, } "###); } @@ -49,12 +51,13 @@ fn test_meta_item_bool_value() { segments: [ PathSegment { ident: "foo", - arguments: None, }, ], }, - lit: Lit::Bool { - value: true, + value: Expr::Lit { + lit: Lit::Bool { + value: true, + }, }, } "###); @@ -67,12 +70,13 @@ fn test_meta_item_bool_value() { segments: [ PathSegment { ident: "foo", - arguments: None, }, ], }, - lit: Lit::Bool { - value: false, + value: Expr::Lit { + lit: Lit::Bool { + value: false, + }, }, } "###); @@ -88,13 +92,11 @@ fn test_meta_item_list_lit() { segments: [ PathSegment { ident: "foo", - arguments: None, }, ], }, - nested: [ - Lit(5), - ], + delimiter: MacroDelimiter::Paren, + tokens: TokenStream(`5`), } "###); } @@ -109,20 +111,11 @@ fn test_meta_item_list_word() { segments: [ PathSegment { ident: "foo", - arguments: None, }, ], }, - nested: [ - Meta(Path(Path { - segments: [ - PathSegment { - ident: "bar", - arguments: None, - }, - ], - })), - ], + delimiter: MacroDelimiter::Paren, + tokens: TokenStream(`bar`), } "###); } @@ -137,23 +130,11 @@ fn test_meta_item_list_name_value() { segments: [ PathSegment { ident: "foo", - arguments: None, }, ], }, - nested: [ - Meta(Meta::NameValue { - path: Path { - segments: [ - PathSegment { - ident: "bar", - arguments: None, - }, - ], - }, - lit: 5, - }), - ], + delimiter: MacroDelimiter::Paren, + tokens: TokenStream(`bar = 5`), } "###); } @@ -168,25 +149,11 @@ fn test_meta_item_list_bool_value() { segments: [ PathSegment { ident: "foo", - arguments: None, }, ], }, - nested: [ - Meta(Meta::NameValue { - path: Path { - segments: [ - PathSegment { - ident: "bar", - arguments: None, - }, - ], - }, - lit: Lit::Bool { - value: true, - }, - }), - ], + delimiter: MacroDelimiter::Paren, + tokens: TokenStream(`bar = true`), } "###); } @@ -201,62 +168,11 @@ fn test_meta_item_multiple() { segments: [ PathSegment { ident: "foo", - arguments: None, }, ], }, - nested: [ - Meta(Path(Path { - segments: [ - PathSegment { - ident: "word", - arguments: None, - }, - ], - })), - Meta(Meta::NameValue { - path: Path { - segments: [ - PathSegment { - ident: "name", - arguments: None, - }, - ], - }, - lit: 5, - }), - Meta(Meta::List { - path: Path { - segments: [ - PathSegment { - ident: "list", - arguments: None, - }, - ], - }, - nested: [ - Meta(Meta::NameValue { - path: Path { - segments: [ - PathSegment { - ident: "name2", - arguments: None, - }, - ], - }, - lit: 6, - }), - ], - }), - Meta(Path(Path { - segments: [ - PathSegment { - ident: "word2", - arguments: None, - }, - ], - })), - ], + delimiter: MacroDelimiter::Paren, + tokens: TokenStream(`word , name = 5 , list (name2 = 6) , word2`), } "###); } @@ -271,15 +187,11 @@ fn test_bool_lit() { segments: [ PathSegment { ident: "foo", - arguments: None, }, ], }, - nested: [ - Lit(Lit::Bool { - value: true, - }), - ], + delimiter: MacroDelimiter::Paren, + tokens: TokenStream(`true`), } "###); } @@ -294,34 +206,11 @@ fn test_negative_lit() { segments: [ PathSegment { ident: "form", - arguments: None, }, ], }, - nested: [ - Meta(Meta::NameValue { - path: Path { - segments: [ - PathSegment { - ident: "min", - arguments: None, - }, - ], - }, - lit: -1, - }), - Meta(Meta::NameValue { - path: Path { - segments: [ - PathSegment { - ident: "max", - arguments: None, - }, - ], - }, - lit: 200, - }), - ], + delimiter: MacroDelimiter::Paren, + tokens: TokenStream(`min = - 1 , max = 200`), } "###); } @@ -332,5 +221,5 @@ fn test(input: &str) -> Meta { assert_eq!(attrs.len(), 1); let attr = attrs.into_iter().next().unwrap(); - attr.parse_meta().unwrap() + attr.meta } diff --git a/vendor/syn/tests/test_derive_input.rs b/vendor/syn/tests/test_derive_input.rs index 1eff01186..3ec6aecbc 100644 --- a/vendor/syn/tests/test_derive_input.rs +++ b/vendor/syn/tests/test_derive_input.rs @@ -1,4 +1,9 @@ -#![allow(clippy::assertions_on_result_states, clippy::too_many_lines)] +#![allow( + clippy::assertions_on_result_states, + clippy::manual_let_else, + clippy::too_many_lines, + clippy::uninlined_format_args +)] #[macro_use] mod macros; @@ -14,11 +19,11 @@ fn test_unit() { snapshot!(input as DeriveInput, @r###" DeriveInput { - vis: Inherited, + vis: Visibility::Inherited, ident: "Unit", generics: Generics, data: Data::Struct { - fields: Unit, + fields: Fields::Unit, semi_token: Some, }, } @@ -39,16 +44,18 @@ fn test_struct() { DeriveInput { attrs: [ Attribute { - style: Outer, - path: Path { - segments: [ - PathSegment { - ident: "derive", - arguments: None, - }, - ], + style: AttrStyle::Outer, + meta: Meta::List { + path: Path { + segments: [ + PathSegment { + ident: "derive", + }, + ], + }, + delimiter: MacroDelimiter::Paren, + tokens: TokenStream(`Debug , Clone`), }, - tokens: TokenStream(`(Debug , Clone)`), }, ], vis: Visibility::Public, @@ -66,7 +73,6 @@ fn test_struct() { segments: [ PathSegment { ident: "Ident", - arguments: None, }, ], }, @@ -83,12 +89,11 @@ fn test_struct() { ident: "Vec", arguments: PathArguments::AngleBracketed { args: [ - Type(Type::Path { + GenericArgument::Type(Type::Path { path: Path { segments: [ PathSegment { ident: "Attribute", - arguments: None, }, ], }, @@ -106,34 +111,17 @@ fn test_struct() { } "###); - snapshot!(input.attrs[0].parse_meta().unwrap(), @r###" + snapshot!(&input.attrs[0].meta, @r###" Meta::List { path: Path { segments: [ PathSegment { ident: "derive", - arguments: None, }, ], }, - nested: [ - Meta(Path(Path { - segments: [ - PathSegment { - ident: "Debug", - arguments: None, - }, - ], - })), - Meta(Path(Path { - segments: [ - PathSegment { - ident: "Clone", - arguments: None, - }, - ], - })), - ], + delimiter: MacroDelimiter::Paren, + tokens: TokenStream(`Debug , Clone`), } "###); } @@ -149,12 +137,12 @@ fn test_union() { snapshot!(input as DeriveInput, @r###" DeriveInput { - vis: Inherited, + vis: Visibility::Inherited, ident: "MaybeUninit", generics: Generics { lt_token: Some, params: [ - Type(TypeParam { + GenericParam::Type(TypeParam { ident: "T", }), ], @@ -164,13 +152,13 @@ fn test_union() { fields: FieldsNamed { named: [ Field { - vis: Inherited, + vis: Visibility::Inherited, ident: Some("uninit"), colon_token: Some, ty: Type::Tuple, }, Field { - vis: Inherited, + vis: Visibility::Inherited, ident: Some("value"), colon_token: Some, ty: Type::Path { @@ -178,7 +166,6 @@ fn test_union() { segments: [ PathSegment { ident: "T", - arguments: None, }, ], }, @@ -212,28 +199,29 @@ fn test_enum() { DeriveInput { attrs: [ Attribute { - style: Outer, - path: Path { - segments: [ - PathSegment { - ident: "doc", - arguments: None, - }, - ], + style: AttrStyle::Outer, + meta: Meta::NameValue { + path: Path { + segments: [ + PathSegment { + ident: "doc", + }, + ], + }, + value: Expr::Lit { + lit: " See the std::result module documentation for details.", + }, }, - tokens: TokenStream(`= r" See the std::result module documentation for details."`), }, Attribute { - style: Outer, - path: Path { + style: AttrStyle::Outer, + meta: Meta::Path { segments: [ PathSegment { ident: "must_use", - arguments: None, }, ], }, - tokens: TokenStream(``), }, ], vis: Visibility::Public, @@ -241,10 +229,10 @@ fn test_enum() { generics: Generics { lt_token: Some, params: [ - Type(TypeParam { + GenericParam::Type(TypeParam { ident: "T", }), - Type(TypeParam { + GenericParam::Type(TypeParam { ident: "E", }), ], @@ -257,13 +245,12 @@ fn test_enum() { fields: Fields::Unnamed { unnamed: [ Field { - vis: Inherited, + vis: Visibility::Inherited, ty: Type::Path { path: Path { segments: [ PathSegment { ident: "T", - arguments: None, }, ], }, @@ -277,13 +264,12 @@ fn test_enum() { fields: Fields::Unnamed { unnamed: [ Field { - vis: Inherited, + vis: Visibility::Inherited, ty: Type::Path { path: Path { segments: [ PathSegment { ident: "E", - arguments: None, }, ], }, @@ -294,14 +280,14 @@ fn test_enum() { }, Variant { ident: "Surprise", - fields: Unit, + fields: Fields::Unit, discriminant: Some(Expr::Lit { lit: 0isize, }), }, Variant { ident: "ProcMacroHack", - fields: Unit, + fields: Fields::Unit, discriminant: Some(Expr::Field { base: Expr::Tuple { elems: [ @@ -313,7 +299,7 @@ fn test_enum() { }, ], }, - member: Unnamed(Index { + member: Member::Unnamed(Index { index: 0, }), }), @@ -323,11 +309,7 @@ fn test_enum() { } "###); - let meta_items: Vec<_> = input - .attrs - .into_iter() - .map(|attr| attr.parse_meta().unwrap()) - .collect(); + let meta_items: Vec<_> = input.attrs.into_iter().map(|attr| attr.meta).collect(); snapshot!(meta_items, @r###" [ @@ -336,64 +318,22 @@ fn test_enum() { segments: [ PathSegment { ident: "doc", - arguments: None, }, ], }, - lit: " See the std::result module documentation for details.", + value: Expr::Lit { + lit: " See the std::result module documentation for details.", + }, }, - Path(Path { + Meta::Path { segments: [ PathSegment { ident: "must_use", - arguments: None, }, ], - }), - ] - "###); -} - -#[test] -fn test_attr_with_path() { - let input = quote! { - #[::attr_args::identity - fn main() { assert_eq!(foo(), "Hello, world!"); }] - struct Dummy; - }; - - snapshot!(input as DeriveInput, @r###" - DeriveInput { - attrs: [ - Attribute { - style: Outer, - path: Path { - leading_colon: Some, - segments: [ - PathSegment { - ident: "attr_args", - arguments: None, - }, - PathSegment { - ident: "identity", - arguments: None, - }, - ], - }, - tokens: TokenStream(`fn main () { assert_eq ! (foo () , "Hello, world!") ; }`), - }, - ], - vis: Inherited, - ident: "Dummy", - generics: Generics, - data: Data::Struct { - fields: Unit, - semi_token: Some, }, - } + ] "###); - - assert!(input.attrs[0].parse_meta().is_err()); } #[test] @@ -403,33 +343,7 @@ fn test_attr_with_non_mod_style_path() { struct S; }; - snapshot!(input as DeriveInput, @r###" - DeriveInput { - attrs: [ - Attribute { - style: Outer, - path: Path { - segments: [ - PathSegment { - ident: "inert", - arguments: None, - }, - ], - }, - tokens: TokenStream(`< T >`), - }, - ], - vis: Inherited, - ident: "S", - generics: Generics, - data: Data::Struct { - fields: Unit, - semi_token: Some, - }, - } - "###); - - assert!(input.attrs[0].parse_meta().is_err()); + syn::parse2::<DeriveInput>(input).unwrap_err(); } #[test] @@ -443,45 +357,40 @@ fn test_attr_with_mod_style_path_with_self() { DeriveInput { attrs: [ Attribute { - style: Outer, - path: Path { + style: AttrStyle::Outer, + meta: Meta::Path { segments: [ PathSegment { ident: "foo", - arguments: None, }, PathSegment { ident: "self", - arguments: None, }, ], }, - tokens: TokenStream(``), }, ], - vis: Inherited, + vis: Visibility::Inherited, ident: "S", generics: Generics, data: Data::Struct { - fields: Unit, + fields: Fields::Unit, semi_token: Some, }, } "###); - snapshot!(input.attrs[0].parse_meta().unwrap(), @r###" - Path(Path { + snapshot!(&input.attrs[0].meta, @r###" + Meta::Path { segments: [ PathSegment { ident: "foo", - arguments: None, }, PathSegment { ident: "self", - arguments: None, }, ], - }) + } "###); } @@ -500,7 +409,6 @@ fn test_pub_restricted() { segments: [ PathSegment { ident: "m", - arguments: None, }, ], }, @@ -517,11 +425,9 @@ fn test_pub_restricted() { segments: [ PathSegment { ident: "m", - arguments: None, }, PathSegment { ident: "n", - arguments: None, }, ], }, @@ -531,7 +437,6 @@ fn test_pub_restricted() { segments: [ PathSegment { ident: "u8", - arguments: None, }, ], }, @@ -546,25 +451,6 @@ fn test_pub_restricted() { } #[test] -fn test_vis_crate() { - let input = quote! { - crate struct S; - }; - - snapshot!(input as DeriveInput, @r###" - DeriveInput { - vis: Visibility::Crate, - ident: "S", - generics: Generics, - data: Data::Struct { - fields: Unit, - semi_token: Some, - }, - } - "###); -} - -#[test] fn test_pub_restricted_crate() { let input = quote! { pub(crate) struct S; @@ -577,7 +463,6 @@ fn test_pub_restricted_crate() { segments: [ PathSegment { ident: "crate", - arguments: None, }, ], }, @@ -585,7 +470,7 @@ fn test_pub_restricted_crate() { ident: "S", generics: Generics, data: Data::Struct { - fields: Unit, + fields: Fields::Unit, semi_token: Some, }, } @@ -605,7 +490,6 @@ fn test_pub_restricted_super() { segments: [ PathSegment { ident: "super", - arguments: None, }, ], }, @@ -613,7 +497,7 @@ fn test_pub_restricted_super() { ident: "S", generics: Generics, data: Data::Struct { - fields: Unit, + fields: Fields::Unit, semi_token: Some, }, } @@ -634,7 +518,6 @@ fn test_pub_restricted_in_super() { segments: [ PathSegment { ident: "super", - arguments: None, }, ], }, @@ -642,7 +525,7 @@ fn test_pub_restricted_in_super() { ident: "S", generics: Generics, data: Data::Struct { - fields: Unit, + fields: Fields::Unit, semi_token: Some, }, } @@ -657,11 +540,11 @@ fn test_fields_on_unit_struct() { snapshot!(input as DeriveInput, @r###" DeriveInput { - vis: Inherited, + vis: Visibility::Inherited, ident: "S", generics: Generics, data: Data::Struct { - fields: Unit, + fields: Fields::Unit, semi_token: Some, }, } @@ -686,14 +569,14 @@ fn test_fields_on_named_struct() { snapshot!(input as DeriveInput, @r###" DeriveInput { - vis: Inherited, + vis: Visibility::Inherited, ident: "S", generics: Generics, data: Data::Struct { fields: Fields::Named { named: [ Field { - vis: Inherited, + vis: Visibility::Inherited, ident: Some("foo"), colon_token: Some, ty: Type::Path { @@ -701,7 +584,6 @@ fn test_fields_on_named_struct() { segments: [ PathSegment { ident: "i32", - arguments: None, }, ], }, @@ -716,7 +598,6 @@ fn test_fields_on_named_struct() { segments: [ PathSegment { ident: "String", - arguments: None, }, ], }, @@ -736,7 +617,7 @@ fn test_fields_on_named_struct() { snapshot!(data.fields.into_iter().collect::<Vec<_>>(), @r###" [ Field { - vis: Inherited, + vis: Visibility::Inherited, ident: Some("foo"), colon_token: Some, ty: Type::Path { @@ -744,7 +625,6 @@ fn test_fields_on_named_struct() { segments: [ PathSegment { ident: "i32", - arguments: None, }, ], }, @@ -759,7 +639,6 @@ fn test_fields_on_named_struct() { segments: [ PathSegment { ident: "String", - arguments: None, }, ], }, @@ -777,20 +656,19 @@ fn test_fields_on_tuple_struct() { snapshot!(input as DeriveInput, @r###" DeriveInput { - vis: Inherited, + vis: Visibility::Inherited, ident: "S", generics: Generics, data: Data::Struct { fields: Fields::Unnamed { unnamed: [ Field { - vis: Inherited, + vis: Visibility::Inherited, ty: Type::Path { path: Path { segments: [ PathSegment { ident: "i32", - arguments: None, }, ], }, @@ -803,7 +681,6 @@ fn test_fields_on_tuple_struct() { segments: [ PathSegment { ident: "String", - arguments: None, }, ], }, @@ -824,13 +701,12 @@ fn test_fields_on_tuple_struct() { snapshot!(data.fields.iter().collect::<Vec<_>>(), @r###" [ Field { - vis: Inherited, + vis: Visibility::Inherited, ty: Type::Path { path: Path { segments: [ PathSegment { ident: "i32", - arguments: None, }, ], }, @@ -843,7 +719,6 @@ fn test_fields_on_tuple_struct() { segments: [ PathSegment { ident: "String", - arguments: None, }, ], }, @@ -862,24 +737,22 @@ fn test_ambiguous_crate() { snapshot!(input as DeriveInput, @r###" DeriveInput { - vis: Inherited, + vis: Visibility::Inherited, ident: "S", generics: Generics, data: Data::Struct { fields: Fields::Unnamed { unnamed: [ Field { - vis: Inherited, + vis: Visibility::Inherited, ty: Type::Path { path: Path { segments: [ PathSegment { ident: "crate", - arguments: None, }, PathSegment { ident: "X", - arguments: None, }, ], }, diff --git a/vendor/syn/tests/test_expr.rs b/vendor/syn/tests/test_expr.rs index e5b151fd8..c7230c6dc 100644 --- a/vendor/syn/tests/test_expr.rs +++ b/vendor/syn/tests/test_expr.rs @@ -1,9 +1,10 @@ +#![allow(clippy::uninlined_format_args)] + #[macro_use] mod macros; use proc_macro2::{Delimiter, Group, Ident, Punct, Spacing, Span, TokenStream, TokenTree}; use quote::quote; -use std::iter::FromIterator; use syn::{Expr, ExprRange}; #[test] @@ -11,8 +12,8 @@ fn test_expr_parse() { let tokens = quote!(..100u32); snapshot!(tokens as Expr, @r###" Expr::Range { - limits: HalfOpen, - to: Some(Expr::Lit { + limits: RangeLimits::HalfOpen, + end: Some(Expr::Lit { lit: 100u32, }), } @@ -21,8 +22,8 @@ fn test_expr_parse() { let tokens = quote!(..100u32); snapshot!(tokens as ExprRange, @r###" ExprRange { - limits: HalfOpen, - to: Some(Expr::Lit { + limits: RangeLimits::HalfOpen, + end: Some(Expr::Lit { lit: 100u32, }), } @@ -41,7 +42,6 @@ fn test_await() { segments: [ PathSegment { ident: "fut", - arguments: None, }, ], }, @@ -61,16 +61,15 @@ fn test_tuple_multi_index() { segments: [ PathSegment { ident: "tuple", - arguments: None, }, ], }, }, - member: Unnamed(Index { + member: Member::Unnamed(Index { index: 0, }), }, - member: Unnamed(Index { + member: Member::Unnamed(Index { index: 0, }), } @@ -114,7 +113,6 @@ fn test_macro_variable_func() { segments: [ PathSegment { ident: "f", - arguments: None, }, ], }, @@ -134,39 +132,34 @@ fn test_macro_variable_func() { Expr::Call { attrs: [ Attribute { - style: Outer, - path: Path { + style: AttrStyle::Outer, + meta: Meta::Path { segments: [ PathSegment { ident: "outside", - arguments: None, }, ], }, - tokens: TokenStream(``), }, ], func: Expr::Group { expr: Expr::Path { attrs: [ Attribute { - style: Outer, - path: Path { + style: AttrStyle::Outer, + meta: Meta::Path { segments: [ PathSegment { ident: "inside", - arguments: None, }, ], }, - tokens: TokenStream(``), }, ], path: Path { segments: [ PathSegment { ident: "f", - arguments: None, }, ], }, @@ -192,11 +185,10 @@ fn test_macro_variable_macro() { segments: [ PathSegment { ident: "m", - arguments: None, }, ], }, - delimiter: Paren, + delimiter: MacroDelimiter::Paren, tokens: TokenStream(``), }, } @@ -217,7 +209,6 @@ fn test_macro_variable_struct() { segments: [ PathSegment { ident: "S", - arguments: None, }, ], }, @@ -249,7 +240,6 @@ fn test_macro_variable_match_arm() { segments: [ PathSegment { ident: "v", - arguments: None, }, ], }, @@ -261,16 +251,14 @@ fn test_macro_variable_match_arm() { expr: Expr::Tuple { attrs: [ Attribute { - style: Outer, - path: Path { + style: AttrStyle::Outer, + meta: Meta::Path { segments: [ PathSegment { ident: "a", - arguments: None, }, ], }, - tokens: TokenStream(``), }, ], }, @@ -289,9 +277,9 @@ fn test_closure_vs_rangefull() { snapshot!(tokens as Expr, @r###" Expr::MethodCall { receiver: Expr::Closure { - output: Default, + output: ReturnType::Default, body: Expr::Range { - limits: HalfOpen, + limits: RangeLimits::HalfOpen, }, }, method: "method", @@ -304,3 +292,21 @@ fn test_postfix_operator_after_cast() { syn::parse_str::<Expr>("|| &x as T[0]").unwrap_err(); syn::parse_str::<Expr>("|| () as ()()").unwrap_err(); } + +#[test] +fn test_ranges() { + syn::parse_str::<Expr>("..").unwrap(); + syn::parse_str::<Expr>("..hi").unwrap(); + syn::parse_str::<Expr>("lo..").unwrap(); + syn::parse_str::<Expr>("lo..hi").unwrap(); + + syn::parse_str::<Expr>("..=").unwrap_err(); + syn::parse_str::<Expr>("..=hi").unwrap(); + syn::parse_str::<Expr>("lo..=").unwrap_err(); + syn::parse_str::<Expr>("lo..=hi").unwrap(); + + syn::parse_str::<Expr>("...").unwrap_err(); + syn::parse_str::<Expr>("...hi").unwrap_err(); + syn::parse_str::<Expr>("lo...").unwrap_err(); + syn::parse_str::<Expr>("lo...hi").unwrap_err(); +} diff --git a/vendor/syn/tests/test_generics.rs b/vendor/syn/tests/test_generics.rs index 330f02f4d..51119adc8 100644 --- a/vendor/syn/tests/test_generics.rs +++ b/vendor/syn/tests/test_generics.rs @@ -1,4 +1,8 @@ -#![allow(clippy::too_many_lines)] +#![allow( + clippy::manual_let_else, + clippy::too_many_lines, + clippy::uninlined_format_args +)] #[macro_use] mod macros; @@ -14,17 +18,17 @@ fn test_split_for_impl() { snapshot!(input as DeriveInput, @r###" DeriveInput { - vis: Inherited, + vis: Visibility::Inherited, ident: "S", generics: Generics { lt_token: Some, params: [ - Lifetime(LifetimeDef { + GenericParam::Lifetime(LifetimeParam { lifetime: Lifetime { ident: "a", }, }), - Lifetime(LifetimeDef { + GenericParam::Lifetime(LifetimeParam { lifetime: Lifetime { ident: "b", }, @@ -35,27 +39,25 @@ fn test_split_for_impl() { }, ], }), - Type(TypeParam { + GenericParam::Type(TypeParam { attrs: [ Attribute { - style: Outer, - path: Path { + style: AttrStyle::Outer, + meta: Meta::Path { segments: [ PathSegment { ident: "may_dangle", - arguments: None, }, ], }, - tokens: TokenStream(``), }, ], ident: "T", colon_token: Some, bounds: [ - Lifetime(Lifetime { + TypeParamBound::Lifetime { ident: "a", - }), + }, ], eq_token: Some, default: Some(Type::Tuple), @@ -64,25 +66,22 @@ fn test_split_for_impl() { gt_token: Some, where_clause: Some(WhereClause { predicates: [ - Type(PredicateType { + WherePredicate::Type(PredicateType { bounded_ty: Type::Path { path: Path { segments: [ PathSegment { ident: "T", - arguments: None, }, ], }, }, bounds: [ - Trait(TraitBound { - modifier: None, + TypeParamBound::Trait(TraitBound { path: Path { segments: [ PathSegment { ident: "Debug", - arguments: None, }, ], }, @@ -93,7 +92,7 @@ fn test_split_for_impl() { }), }, data: Data::Struct { - fields: Unit, + fields: Fields::Unit, semi_token: Some, }, } @@ -128,27 +127,25 @@ fn test_split_for_impl() { fn test_ty_param_bound() { let tokens = quote!('a); snapshot!(tokens as TypeParamBound, @r###" - Lifetime(Lifetime { + TypeParamBound::Lifetime { ident: "a", - }) + } "###); let tokens = quote!('_); snapshot!(tokens as TypeParamBound, @r###" - Lifetime(Lifetime { + TypeParamBound::Lifetime { ident: "_", - }) + } "###); let tokens = quote!(Debug); snapshot!(tokens as TypeParamBound, @r###" - Trait(TraitBound { - modifier: None, + TypeParamBound::Trait(TraitBound { path: Path { segments: [ PathSegment { ident: "Debug", - arguments: None, }, ], }, @@ -157,13 +154,12 @@ fn test_ty_param_bound() { let tokens = quote!(?Sized); snapshot!(tokens as TypeParamBound, @r###" - Trait(TraitBound { - modifier: Maybe, + TypeParamBound::Trait(TraitBound { + modifier: TraitBoundModifier::Maybe, path: Path { segments: [ PathSegment { ident: "Sized", - arguments: None, }, ], }, @@ -185,45 +181,42 @@ fn test_fn_precedence_in_where_clause() { snapshot!(input as ItemFn, @r###" ItemFn { - vis: Inherited, + vis: Visibility::Inherited, sig: Signature { ident: "f", generics: Generics { lt_token: Some, params: [ - Type(TypeParam { + GenericParam::Type(TypeParam { ident: "G", }), ], gt_token: Some, where_clause: Some(WhereClause { predicates: [ - Type(PredicateType { + WherePredicate::Type(PredicateType { bounded_ty: Type::Path { path: Path { segments: [ PathSegment { ident: "G", - arguments: None, }, ], }, }, bounds: [ - Trait(TraitBound { - modifier: None, + TypeParamBound::Trait(TraitBound { path: Path { segments: [ PathSegment { ident: "FnOnce", arguments: PathArguments::Parenthesized { - output: Type( + output: ReturnType::Type( Type::Path { path: Path { segments: [ PathSegment { ident: "i32", - arguments: None, }, ], }, @@ -234,13 +227,11 @@ fn test_fn_precedence_in_where_clause() { ], }, }), - Trait(TraitBound { - modifier: None, + TypeParamBound::Trait(TraitBound { path: Path { segments: [ PathSegment { ident: "Send", - arguments: None, }, ], }, @@ -250,7 +241,7 @@ fn test_fn_precedence_in_where_clause() { ], }), }, - output: Default, + output: ReturnType::Default, }, block: Block, } diff --git a/vendor/syn/tests/test_grouping.rs b/vendor/syn/tests/test_grouping.rs index 9eb7eee9b..6a73a9244 100644 --- a/vendor/syn/tests/test_grouping.rs +++ b/vendor/syn/tests/test_grouping.rs @@ -1,8 +1,9 @@ +#![allow(clippy::uninlined_format_args)] + #[macro_use] mod macros; use proc_macro2::{Delimiter, Group, Literal, Punct, Spacing, TokenStream, TokenTree}; -use std::iter::FromIterator; use syn::Expr; #[test] @@ -29,20 +30,20 @@ fn test_grouping() { left: Expr::Lit { lit: 1i32, }, - op: Add, + op: BinOp::Add, right: Expr::Binary { left: Expr::Group { expr: Expr::Binary { left: Expr::Lit { lit: 2i32, }, - op: Add, + op: BinOp::Add, right: Expr::Lit { lit: 3i32, }, }, }, - op: Mul, + op: BinOp::Mul, right: Expr::Lit { lit: 4i32, }, diff --git a/vendor/syn/tests/test_item.rs b/vendor/syn/tests/test_item.rs index 96df4b1aa..9b0e1c9ff 100644 --- a/vendor/syn/tests/test_item.rs +++ b/vendor/syn/tests/test_item.rs @@ -1,9 +1,10 @@ +#![allow(clippy::uninlined_format_args)] + #[macro_use] mod macros; use proc_macro2::{Delimiter, Group, Ident, Span, TokenStream, TokenTree}; use quote::quote; -use std::iter::FromIterator; use syn::{Item, ItemTrait}; #[test] @@ -21,23 +22,21 @@ fn test_macro_variable_attr() { Item::Fn { attrs: [ Attribute { - style: Outer, - path: Path { + style: AttrStyle::Outer, + meta: Meta::Path { segments: [ PathSegment { ident: "test", - arguments: None, }, ], }, - tokens: TokenStream(``), }, ], - vis: Inherited, + vis: Visibility::Inherited, sig: Signature { ident: "f", generics: Generics, - output: Default, + output: ReturnType::Default, }, block: Block, } @@ -69,7 +68,7 @@ fn test_negative_impl() { snapshot!(tokens as Item, @r###" Item::Impl { generics: Generics, - self_ty: Verbatim(`! Trait`), + self_ty: Type::Verbatim(`! Trait`), } "###); @@ -87,7 +86,6 @@ fn test_negative_impl() { segments: [ PathSegment { ident: "Trait", - arguments: None, }, ], }, @@ -97,7 +95,6 @@ fn test_negative_impl() { segments: [ PathSegment { ident: "T", - arguments: None, }, ], }, @@ -114,7 +111,7 @@ fn test_negative_impl() { snapshot!(tokens as Item, @r###" Item::Impl { generics: Generics, - self_ty: Verbatim(`! !`), + self_ty: Type::Verbatim(`! !`), } "###); } @@ -139,7 +136,6 @@ fn test_macro_variable_impl() { segments: [ PathSegment { ident: "Trait", - arguments: None, }, ], }, @@ -150,7 +146,6 @@ fn test_macro_variable_impl() { segments: [ PathSegment { ident: "Type", - arguments: None, }, ], }, @@ -168,7 +163,7 @@ fn test_supertraits() { let tokens = quote!(trait Trait where {}); snapshot!(tokens as ItemTrait, @r###" ItemTrait { - vis: Inherited, + vis: Visibility::Inherited, ident: "Trait", generics: Generics { where_clause: Some(WhereClause), @@ -180,7 +175,7 @@ fn test_supertraits() { let tokens = quote!(trait Trait: where {}); snapshot!(tokens as ItemTrait, @r###" ItemTrait { - vis: Inherited, + vis: Visibility::Inherited, ident: "Trait", generics: Generics { where_clause: Some(WhereClause), @@ -193,20 +188,18 @@ fn test_supertraits() { let tokens = quote!(trait Trait: Sized where {}); snapshot!(tokens as ItemTrait, @r###" ItemTrait { - vis: Inherited, + vis: Visibility::Inherited, ident: "Trait", generics: Generics { where_clause: Some(WhereClause), }, colon_token: Some, supertraits: [ - Trait(TraitBound { - modifier: None, + TypeParamBound::Trait(TraitBound { path: Path { segments: [ PathSegment { ident: "Sized", - arguments: None, }, ], }, @@ -219,20 +212,18 @@ fn test_supertraits() { let tokens = quote!(trait Trait: Sized + where {}); snapshot!(tokens as ItemTrait, @r###" ItemTrait { - vis: Inherited, + vis: Visibility::Inherited, ident: "Trait", generics: Generics { where_clause: Some(WhereClause), }, colon_token: Some, supertraits: [ - Trait(TraitBound { - modifier: None, + TypeParamBound::Trait(TraitBound { path: Path { segments: [ PathSegment { ident: "Sized", - arguments: None, }, ], }, @@ -253,7 +244,7 @@ fn test_type_empty_bounds() { snapshot!(tokens as ItemTrait, @r###" ItemTrait { - vis: Inherited, + vis: Visibility::Inherited, ident: "Foo", generics: Generics, items: [ @@ -273,7 +264,7 @@ fn test_impl_visibility() { pub default unsafe impl union {} }; - snapshot!(tokens as Item, @"Verbatim(`pub default unsafe impl union { }`)"); + snapshot!(tokens as Item, @"Item::Verbatim(`pub default unsafe impl union { }`)"); } #[test] @@ -288,7 +279,7 @@ fn test_impl_type_parameter_defaults() { generics: Generics { lt_token: Some, params: [ - Type(TypeParam { + GenericParam::Type(TypeParam { ident: "T", eq_token: Some, default: Some(Type::Tuple), @@ -297,7 +288,8 @@ fn test_impl_type_parameter_defaults() { gt_token: Some, }, self_ty: Type::Tuple, - }"###); + } + "###); } #[test] @@ -308,20 +300,18 @@ fn test_impl_trait_trailing_plus() { snapshot!(tokens as Item, @r###" Item::Fn { - vis: Inherited, + vis: Visibility::Inherited, sig: Signature { ident: "f", generics: Generics, - output: Type( + output: ReturnType::Type( Type::ImplTrait { bounds: [ - Trait(TraitBound { - modifier: None, + TypeParamBound::Trait(TraitBound { path: Path { segments: [ PathSegment { ident: "Sized", - arguments: None, }, ], }, diff --git a/vendor/syn/tests/test_iterators.rs b/vendor/syn/tests/test_iterators.rs index 0ab0fb914..5f0eff59e 100644 --- a/vendor/syn/tests/test_iterators.rs +++ b/vendor/syn/tests/test_iterators.rs @@ -1,3 +1,5 @@ +#![allow(clippy::uninlined_format_args)] + use syn::punctuated::{Pair, Punctuated}; use syn::Token; diff --git a/vendor/syn/tests/test_lit.rs b/vendor/syn/tests/test_lit.rs index ebe077c61..82d229001 100644 --- a/vendor/syn/tests/test_lit.rs +++ b/vendor/syn/tests/test_lit.rs @@ -1,11 +1,14 @@ -#![allow(clippy::float_cmp, clippy::non_ascii_literal)] +#![allow( + clippy::float_cmp, + clippy::non_ascii_literal, + clippy::uninlined_format_args +)] #[macro_use] mod macros; use proc_macro2::{Delimiter, Group, Literal, Span, TokenStream, TokenTree}; use quote::ToTokens; -use std::iter::FromIterator; use std::str::FromStr; use syn::{Lit, LitFloat, LitInt, LitStr}; @@ -50,6 +53,10 @@ fn strings() { "\"contains\nnewlines\\\nescaped newlines\"", "contains\nnewlinesescaped newlines", ); + test_string( + "\"escaped newline\\\n \x0C unsupported whitespace\"", + "escaped newline\x0C unsupported whitespace", + ); test_string("r\"raw\nstring\\\nhere\"", "raw\nstring\\\nhere"); test_string("\"...\"q", "..."); test_string("r\"...\"q", "..."); diff --git a/vendor/syn/tests/test_meta.rs b/vendor/syn/tests/test_meta.rs index 9b3f30dee..91a980700 100644 --- a/vendor/syn/tests/test_meta.rs +++ b/vendor/syn/tests/test_meta.rs @@ -1,23 +1,26 @@ -#![allow(clippy::shadow_unrelated, clippy::too_many_lines)] +#![allow( + clippy::shadow_unrelated, + clippy::too_many_lines, + clippy::uninlined_format_args +)] #[macro_use] mod macros; -use syn::{Meta, MetaList, MetaNameValue, NestedMeta}; +use syn::{Meta, MetaList, MetaNameValue}; #[test] fn test_parse_meta_item_word() { let input = "hello"; snapshot!(input as Meta, @r###" - Path(Path { + Meta::Path { segments: [ PathSegment { ident: "hello", - arguments: None, }, ], - }) + } "###); } @@ -32,47 +35,12 @@ fn test_parse_meta_name_value() { segments: [ PathSegment { ident: "foo", - arguments: None, }, ], }, - lit: 5, - } - "###); - - snapshot!(meta as Meta, @r###" - Meta::NameValue { - path: Path { - segments: [ - PathSegment { - ident: "foo", - arguments: None, - }, - ], - }, - lit: 5, - } - "###); - - assert_eq!(meta, inner.into()); -} - -#[test] -fn test_parse_meta_name_value_with_keyword() { - let input = "static = 5"; - let (inner, meta) = (input, input); - - snapshot!(inner as MetaNameValue, @r###" - MetaNameValue { - path: Path { - segments: [ - PathSegment { - ident: "static", - arguments: None, - }, - ], + value: Expr::Lit { + lit: 5, }, - lit: 5, } "###); @@ -81,48 +49,13 @@ fn test_parse_meta_name_value_with_keyword() { path: Path { segments: [ PathSegment { - ident: "static", - arguments: None, - }, - ], - }, - lit: 5, - } - "###); - - assert_eq!(meta, inner.into()); -} - -#[test] -fn test_parse_meta_name_value_with_bool() { - let input = "true = 5"; - let (inner, meta) = (input, input); - - snapshot!(inner as MetaNameValue, @r###" - MetaNameValue { - path: Path { - segments: [ - PathSegment { - ident: "true", - arguments: None, + ident: "foo", }, ], }, - lit: 5, - } - "###); - - snapshot!(meta as Meta, @r###" - Meta::NameValue { - path: Path { - segments: [ - PathSegment { - ident: "true", - arguments: None, - }, - ], + value: Expr::Lit { + lit: 5, }, - lit: 5, } "###); @@ -140,13 +73,11 @@ fn test_parse_meta_item_list_lit() { segments: [ PathSegment { ident: "foo", - arguments: None, }, ], }, - nested: [ - Lit(5), - ], + delimiter: MacroDelimiter::Paren, + tokens: TokenStream(`5`), } "###); @@ -156,13 +87,11 @@ fn test_parse_meta_item_list_lit() { segments: [ PathSegment { ident: "foo", - arguments: None, }, ], }, - nested: [ - Lit(5), - ], + delimiter: MacroDelimiter::Paren, + tokens: TokenStream(`5`), } "###); @@ -180,62 +109,11 @@ fn test_parse_meta_item_multiple() { segments: [ PathSegment { ident: "foo", - arguments: None, }, ], }, - nested: [ - Meta(Path(Path { - segments: [ - PathSegment { - ident: "word", - arguments: None, - }, - ], - })), - Meta(Meta::NameValue { - path: Path { - segments: [ - PathSegment { - ident: "name", - arguments: None, - }, - ], - }, - lit: 5, - }), - Meta(Meta::List { - path: Path { - segments: [ - PathSegment { - ident: "list", - arguments: None, - }, - ], - }, - nested: [ - Meta(Meta::NameValue { - path: Path { - segments: [ - PathSegment { - ident: "name2", - arguments: None, - }, - ], - }, - lit: 6, - }), - ], - }), - Meta(Path(Path { - segments: [ - PathSegment { - ident: "word2", - arguments: None, - }, - ], - })), - ], + delimiter: MacroDelimiter::Paren, + tokens: TokenStream(`word , name = 5 , list (name2 = 6) , word2`), } "###); @@ -245,62 +123,11 @@ fn test_parse_meta_item_multiple() { segments: [ PathSegment { ident: "foo", - arguments: None, }, ], }, - nested: [ - Meta(Path(Path { - segments: [ - PathSegment { - ident: "word", - arguments: None, - }, - ], - })), - Meta(Meta::NameValue { - path: Path { - segments: [ - PathSegment { - ident: "name", - arguments: None, - }, - ], - }, - lit: 5, - }), - Meta(Meta::List { - path: Path { - segments: [ - PathSegment { - ident: "list", - arguments: None, - }, - ], - }, - nested: [ - Meta(Meta::NameValue { - path: Path { - segments: [ - PathSegment { - ident: "name2", - arguments: None, - }, - ], - }, - lit: 6, - }), - ], - }), - Meta(Path(Path { - segments: [ - PathSegment { - ident: "word2", - arguments: None, - }, - ], - })), - ], + delimiter: MacroDelimiter::Paren, + tokens: TokenStream(`word , name = 5 , list (name2 = 6) , word2`), } "###); @@ -308,71 +135,19 @@ fn test_parse_meta_item_multiple() { } #[test] -fn test_parse_nested_meta() { - let input = "5"; - snapshot!(input as NestedMeta, @"Lit(5)"); - - let input = "list(name2 = 6)"; - snapshot!(input as NestedMeta, @r###" - Meta(Meta::List { - path: Path { - segments: [ - PathSegment { - ident: "list", - arguments: None, - }, - ], - }, - nested: [ - Meta(Meta::NameValue { - path: Path { - segments: [ - PathSegment { - ident: "name2", - arguments: None, - }, - ], - }, - lit: 6, - }), - ], - }) - "###); -} - -#[test] fn test_parse_path() { let input = "::serde::Serialize"; snapshot!(input as Meta, @r###" - Path(Path { - leading_colon: Some, - segments: [ - PathSegment { - ident: "serde", - arguments: None, - }, - PathSegment { - ident: "Serialize", - arguments: None, - }, - ], - }) - "###); - - let input = "::serde::Serialize"; - snapshot!(input as NestedMeta, @r###" - Meta(Path(Path { + Meta::Path { leading_colon: Some, segments: [ PathSegment { ident: "serde", - arguments: None, }, PathSegment { ident: "Serialize", - arguments: None, }, ], - })) + } "###); } diff --git a/vendor/syn/tests/test_parse_buffer.rs b/vendor/syn/tests/test_parse_buffer.rs index cc23e9ba6..f2ca59c75 100644 --- a/vendor/syn/tests/test_parse_buffer.rs +++ b/vendor/syn/tests/test_parse_buffer.rs @@ -1,7 +1,6 @@ #![allow(clippy::non_ascii_literal)] use proc_macro2::{Delimiter, Group, Punct, Spacing, TokenStream, TokenTree}; -use std::iter::FromIterator; use syn::parse::{discouraged::Speculative, Parse, ParseStream, Parser, Result}; use syn::{parenthesized, Token}; diff --git a/vendor/syn/tests/test_parse_stream.rs b/vendor/syn/tests/test_parse_stream.rs index cc14fa032..2265dfe87 100644 --- a/vendor/syn/tests/test_parse_stream.rs +++ b/vendor/syn/tests/test_parse_stream.rs @@ -1,12 +1,14 @@ +#![allow(clippy::let_underscore_untyped)] + use syn::ext::IdentExt; use syn::parse::ParseStream; use syn::{Ident, Token}; #[test] fn test_peek() { - _ = |input: ParseStream| { - _ = input.peek(Ident); - _ = input.peek(Ident::peek_any); - _ = input.peek(Token![::]); + let _ = |input: ParseStream| { + let _ = input.peek(Ident); + let _ = input.peek(Ident::peek_any); + let _ = input.peek(Token![::]); }; } diff --git a/vendor/syn/tests/test_pat.rs b/vendor/syn/tests/test_pat.rs index 695e4736e..cab7aa7f6 100644 --- a/vendor/syn/tests/test_pat.rs +++ b/vendor/syn/tests/test_pat.rs @@ -1,14 +1,16 @@ +#![allow(clippy::uninlined_format_args)] + #[macro_use] mod macros; use proc_macro2::{Delimiter, Group, TokenStream, TokenTree}; use quote::quote; -use std::iter::FromIterator; +use syn::parse::Parser; use syn::{Item, Pat, Stmt}; #[test] fn test_pat_ident() { - match syn::parse2(quote!(self)).unwrap() { + match Pat::parse_single.parse2(quote!(self)).unwrap() { Pat::Ident(_) => (), value => panic!("expected PatIdent, got {:?}", value), } @@ -16,7 +18,7 @@ fn test_pat_ident() { #[test] fn test_pat_path() { - match syn::parse2(quote!(self::CONST)).unwrap() { + match Pat::parse_single.parse2(quote!(self::CONST)).unwrap() { Pat::Path(_) => (), value => panic!("expected PatPath, got {:?}", value), } @@ -30,7 +32,7 @@ fn test_leading_vert() { syn::parse_str::<Item>("fn fun1(| A: E) {}").unwrap_err(); syn::parse_str::<Item>("fn fun2(|| A: E) {}").unwrap_err(); - syn::parse_str::<Stmt>("let | () = ();").unwrap(); + syn::parse_str::<Stmt>("let | () = ();").unwrap_err(); syn::parse_str::<Stmt>("let (| A): E;").unwrap(); syn::parse_str::<Stmt>("let (|| A): (E);").unwrap_err(); syn::parse_str::<Stmt>("let (| A,): (E,);").unwrap(); @@ -46,22 +48,50 @@ fn test_leading_vert() { fn test_group() { let group = Group::new(Delimiter::None, quote!(Some(_))); let tokens = TokenStream::from_iter(vec![TokenTree::Group(group)]); + let pat = Pat::parse_single.parse2(tokens).unwrap(); - snapshot!(tokens as Pat, @r###" + snapshot!(pat, @r###" Pat::TupleStruct { path: Path { segments: [ PathSegment { ident: "Some", - arguments: None, }, ], }, - pat: PatTuple { - elems: [ - Pat::Wild, - ], - }, + elems: [ + Pat::Wild, + ], } "###); } + +#[test] +fn test_ranges() { + Pat::parse_single.parse_str("..").unwrap(); + Pat::parse_single.parse_str("..hi").unwrap(); + Pat::parse_single.parse_str("lo..").unwrap(); + Pat::parse_single.parse_str("lo..hi").unwrap(); + + Pat::parse_single.parse_str("..=").unwrap_err(); + Pat::parse_single.parse_str("..=hi").unwrap(); + Pat::parse_single.parse_str("lo..=").unwrap_err(); + Pat::parse_single.parse_str("lo..=hi").unwrap(); + + Pat::parse_single.parse_str("...").unwrap_err(); + Pat::parse_single.parse_str("...hi").unwrap_err(); + Pat::parse_single.parse_str("lo...").unwrap_err(); + Pat::parse_single.parse_str("lo...hi").unwrap(); + + Pat::parse_single.parse_str("[lo..]").unwrap_err(); + Pat::parse_single.parse_str("[..=hi]").unwrap_err(); + Pat::parse_single.parse_str("[(lo..)]").unwrap(); + Pat::parse_single.parse_str("[(..=hi)]").unwrap(); + Pat::parse_single.parse_str("[lo..=hi]").unwrap(); + + Pat::parse_single.parse_str("[_, lo.., _]").unwrap_err(); + Pat::parse_single.parse_str("[_, ..=hi, _]").unwrap_err(); + Pat::parse_single.parse_str("[_, (lo..), _]").unwrap(); + Pat::parse_single.parse_str("[_, (..=hi), _]").unwrap(); + Pat::parse_single.parse_str("[_, lo..=hi, _]").unwrap(); +} diff --git a/vendor/syn/tests/test_path.rs b/vendor/syn/tests/test_path.rs index c732eff70..6aded74e6 100644 --- a/vendor/syn/tests/test_path.rs +++ b/vendor/syn/tests/test_path.rs @@ -1,9 +1,10 @@ +#![allow(clippy::uninlined_format_args)] + #[macro_use] mod macros; use proc_macro2::{Delimiter, Group, Ident, Punct, Spacing, Span, TokenStream, TokenTree}; use quote::{quote, ToTokens}; -use std::iter::FromIterator; use syn::{parse_quote, Expr, Type, TypePath}; #[test] @@ -22,11 +23,9 @@ fn parse_interpolated_leading_component() { segments: [ PathSegment { ident: "first", - arguments: None, }, PathSegment { ident: "rest", - arguments: None, }, ], }, @@ -39,11 +38,9 @@ fn parse_interpolated_leading_component() { segments: [ PathSegment { ident: "first", - arguments: None, }, PathSegment { ident: "rest", - arguments: None, }, ], }, @@ -106,21 +103,26 @@ fn print_incomplete_qpath() { #[test] fn parse_parenthesized_path_arguments_with_disambiguator() { #[rustfmt::skip] - let tokens = quote!(FnOnce::() -> !); + let tokens = quote!(dyn FnOnce::() -> !); snapshot!(tokens as Type, @r###" - Type::Path { - path: Path { - segments: [ - PathSegment { - ident: "FnOnce", - arguments: PathArguments::Parenthesized { - output: Type( - Type::Never, - ), - }, + Type::TraitObject { + dyn_token: Some, + bounds: [ + TypeParamBound::Trait(TraitBound { + path: Path { + segments: [ + PathSegment { + ident: "FnOnce", + arguments: PathArguments::Parenthesized { + output: ReturnType::Type( + Type::Never, + ), + }, + }, + ], }, - ], - }, + }), + ], } "###); } diff --git a/vendor/syn/tests/test_precedence.rs b/vendor/syn/tests/test_precedence.rs index dbcd74f16..e2931ff5a 100644 --- a/vendor/syn/tests/test_precedence.rs +++ b/vendor/syn/tests/test_precedence.rs @@ -4,9 +4,13 @@ #![feature(rustc_private)] #![allow( clippy::explicit_deref_methods, + clippy::let_underscore_untyped, clippy::manual_assert, + clippy::manual_let_else, + clippy::match_like_matches_macro, clippy::match_wildcard_for_single_variants, - clippy::too_many_lines + clippy::too_many_lines, + clippy::uninlined_format_args )] //! The tests in this module do the following: @@ -22,7 +26,9 @@ //! 5. Compare the expressions with one another, if they are not equal fail. extern crate rustc_ast; +extern crate rustc_ast_pretty; extern crate rustc_data_structures; +extern crate rustc_driver; extern crate rustc_span; extern crate thin_vec; @@ -33,8 +39,10 @@ use rayon::iter::{IntoParallelIterator, ParallelIterator}; use regex::Regex; use rustc_ast::ast; use rustc_ast::ptr::P; +use rustc_ast_pretty::pprust; use rustc_span::edition::Edition; use std::fs; +use std::path::Path; use std::process; use std::sync::atomic::{AtomicUsize, Ordering}; use walkdir::{DirEntry, WalkDir}; @@ -47,45 +55,6 @@ mod common; mod repo; -/// Test some pre-set expressions chosen by us. -#[test] -fn test_simple_precedence() { - const EXPRS: &[&str] = &[ - "1 + 2 * 3 + 4", - "1 + 2 * ( 3 + 4 )", - "{ for i in r { } *some_ptr += 1; }", - "{ loop { break 5; } }", - "{ if true { () }.mthd() }", - "{ for i in unsafe { 20 } { } }", - ]; - - let mut failed = 0; - - for input in EXPRS { - let expr = if let Some(expr) = parse::syn_expr(input) { - expr - } else { - failed += 1; - continue; - }; - - let pf = match test_expressions(Edition::Edition2018, vec![expr]) { - (1, 0) => "passed", - (0, 1) => { - failed += 1; - "failed" - } - _ => unreachable!(), - }; - errorf!("=== {}: {}\n", input, pf); - } - - if failed > 0 { - panic!("Failed {} tests", failed); - } -} - -/// Test expressions from rustc, like in `test_round_trip`. #[test] fn test_rustc_precedence() { common::rayon_init(); @@ -121,21 +90,21 @@ fn test_rustc_precedence() { Ok(file) => { let edition = repo::edition(path).parse().unwrap(); let exprs = collect_exprs(file); - test_expressions(edition, exprs) + let (l_passed, l_failed) = test_expressions(path, edition, exprs); + errorf!( + "=== {}: {} passed | {} failed\n", + path.display(), + l_passed, + l_failed, + ); + (l_passed, l_failed) } Err(msg) => { - errorf!("syn failed to parse\n{:?}\n", msg); + errorf!("\nFAIL {} - syn failed to parse: {}\n", path.display(), msg); (0, 1) } }; - errorf!( - "=== {}: {} passed | {} failed\n", - path.display(), - l_passed, - l_failed - ); - passed.fetch_add(l_passed, Ordering::Relaxed); let prev_failed = failed.fetch_add(l_failed, Ordering::Relaxed); @@ -155,7 +124,7 @@ fn test_rustc_precedence() { } } -fn test_expressions(edition: Edition, exprs: Vec<syn::Expr>) -> (usize, usize) { +fn test_expressions(path: &Path, edition: Edition, exprs: Vec<syn::Expr>) -> (usize, usize) { let mut passed = 0; let mut failed = 0; @@ -167,7 +136,7 @@ fn test_expressions(edition: Edition, exprs: Vec<syn::Expr>) -> (usize, usize) { e } else { failed += 1; - errorf!("\nFAIL - librustc failed to parse raw\n"); + errorf!("\nFAIL {} - librustc failed to parse raw\n", path.display()); continue; }; @@ -176,7 +145,10 @@ fn test_expressions(edition: Edition, exprs: Vec<syn::Expr>) -> (usize, usize) { e } else { failed += 1; - errorf!("\nFAIL - librustc failed to parse bracketed\n"); + errorf!( + "\nFAIL {} - librustc failed to parse bracketed\n", + path.display(), + ); continue; }; @@ -184,7 +156,14 @@ fn test_expressions(edition: Edition, exprs: Vec<syn::Expr>) -> (usize, usize) { passed += 1; } else { failed += 1; - errorf!("\nFAIL\n{:?}\n!=\n{:?}\n", syn_ast, librustc_ast); + let syn_program = pprust::expr_to_string(&syn_ast); + let librustc_program = pprust::expr_to_string(&librustc_ast); + errorf!( + "\nFAIL {}\n{}\nsyn != rustc\n{}\n", + path.display(), + syn_program, + librustc_program, + ); } } }); @@ -203,11 +182,14 @@ fn librustc_parse_and_rewrite(input: &str) -> Option<P<ast::Expr>> { /// This method operates on librustc objects. fn librustc_brackets(mut librustc_expr: P<ast::Expr>) -> Option<P<ast::Expr>> { use rustc_ast::ast::{ - Attribute, Block, BorrowKind, Expr, ExprField, ExprKind, GenericArg, Local, LocalKind, Pat, - Stmt, StmtKind, StructExpr, StructRest, Ty, + Attribute, BinOpKind, Block, BorrowKind, Expr, ExprField, ExprKind, GenericArg, + GenericBound, Local, LocalKind, Pat, Stmt, StmtKind, StructExpr, StructRest, + TraitBoundModifier, Ty, }; - use rustc_ast::mut_visit::{noop_visit_generic_arg, noop_visit_local, MutVisitor}; - use rustc_data_structures::map_in_place::MapInPlace; + use rustc_ast::mut_visit::{ + noop_visit_generic_arg, noop_visit_local, noop_visit_param_bound, MutVisitor, + }; + use rustc_data_structures::flat_map_in_place::FlatMapInPlace; use rustc_span::DUMMY_SP; use std::mem; use std::ops::DerefMut; @@ -270,12 +252,15 @@ fn librustc_brackets(mut librustc_expr: P<ast::Expr>) -> Option<P<ast::Expr>> { impl MutVisitor for BracketsVisitor { fn visit_expr(&mut self, e: &mut P<Expr>) { + noop_visit_expr(e, self); match e.kind { - ExprKind::ConstBlock(..) => {} - _ => noop_visit_expr(e, self), - } - match e.kind { - ExprKind::If(..) | ExprKind::Block(..) | ExprKind::Let(..) => {} + ExprKind::Block(..) | ExprKind::If(..) | ExprKind::Let(..) => {} + ExprKind::Binary(binop, ref left, ref right) + if match (&left.kind, binop.node, &right.kind) { + (ExprKind::Let(..), BinOpKind::And, _) + | (_, BinOpKind::And, ExprKind::Let(..)) => true, + _ => false, + } => {} _ => { let inner = mem::replace( e, @@ -304,6 +289,16 @@ fn librustc_brackets(mut librustc_expr: P<ast::Expr>) -> Option<P<ast::Expr>> { } } + fn visit_param_bound(&mut self, bound: &mut GenericBound) { + match bound { + GenericBound::Trait( + _, + TraitBoundModifier::MaybeConst | TraitBoundModifier::MaybeConstMaybe, + ) => {} + _ => noop_visit_param_bound(bound, self), + } + } + fn visit_block(&mut self, block: &mut P<Block>) { self.visit_id(&mut block.id); block @@ -323,15 +318,15 @@ fn librustc_brackets(mut librustc_expr: P<ast::Expr>) -> Option<P<ast::Expr>> { // types yet. We'll look into comparing those in the future. For now // focus on expressions appearing in other places. fn visit_pat(&mut self, pat: &mut P<Pat>) { - _ = pat; + let _ = pat; } fn visit_ty(&mut self, ty: &mut P<Ty>) { - _ = ty; + let _ = ty; } fn visit_attribute(&mut self, attr: &mut Attribute) { - _ = attr; + let _ = attr; } } @@ -348,22 +343,33 @@ fn librustc_brackets(mut librustc_expr: P<ast::Expr>) -> Option<P<ast::Expr>> { /// reveal the precedence of the parsed expressions, and produce a stringified /// form of the resulting expression. fn syn_brackets(syn_expr: syn::Expr) -> syn::Expr { - use syn::fold::{fold_expr, fold_generic_argument, fold_generic_method_argument, Fold}; - use syn::{token, Expr, ExprParen, GenericArgument, GenericMethodArgument, Pat, Stmt, Type}; + use syn::fold::{fold_expr, fold_generic_argument, Fold}; + use syn::{token, BinOp, Expr, ExprParen, GenericArgument, MetaNameValue, Pat, Stmt, Type}; struct ParenthesizeEveryExpr; + + fn needs_paren(expr: &Expr) -> bool { + match expr { + Expr::Group(_) => unreachable!(), + Expr::If(_) | Expr::Unsafe(_) | Expr::Block(_) | Expr::Let(_) => false, + Expr::Binary(bin) => match (&*bin.left, bin.op, &*bin.right) { + (Expr::Let(_), BinOp::And(_), _) | (_, BinOp::And(_), Expr::Let(_)) => false, + _ => true, + }, + _ => true, + } + } + impl Fold for ParenthesizeEveryExpr { fn fold_expr(&mut self, expr: Expr) -> Expr { - match expr { - Expr::Group(_) => unreachable!(), - Expr::If(..) | Expr::Unsafe(..) | Expr::Block(..) | Expr::Let(..) => { - fold_expr(self, expr) - } - _ => Expr::Paren(ExprParen { + if needs_paren(&expr) { + Expr::Paren(ExprParen { attrs: Vec::new(), expr: Box::new(fold_expr(self, expr)), paren_token: token::Paren::default(), - }), + }) + } else { + fold_expr(self, expr) } } @@ -378,35 +384,20 @@ fn syn_brackets(syn_expr: syn::Expr) -> syn::Expr { } } - fn fold_generic_method_argument( - &mut self, - arg: GenericMethodArgument, - ) -> GenericMethodArgument { - match arg { - GenericMethodArgument::Const(arg) => GenericMethodArgument::Const(match arg { - Expr::Block(_) => fold_expr(self, arg), - // Don't wrap unbraced const generic arg as that's invalid syntax. - _ => arg, - }), - _ => fold_generic_method_argument(self, arg), - } - } - fn fold_stmt(&mut self, stmt: Stmt) -> Stmt { match stmt { // Don't wrap toplevel expressions in statements. - Stmt::Expr(e) => Stmt::Expr(fold_expr(self, e)), - Stmt::Semi(e, semi) => { - if let Expr::Verbatim(_) = e { - Stmt::Semi(e, semi) - } else { - Stmt::Semi(fold_expr(self, e), semi) - } - } + Stmt::Expr(Expr::Verbatim(_), Some(_)) => stmt, + Stmt::Expr(e, semi) => Stmt::Expr(fold_expr(self, e), semi), s => s, } } + fn fold_meta_name_value(&mut self, meta: MetaNameValue) -> MetaNameValue { + // Don't turn #[p = "..."] into #[p = ("...")]. + meta + } + // We don't want to look at expressions that might appear in patterns or // types yet. We'll look into comparing those in the future. For now // focus on expressions appearing in other places. @@ -427,7 +418,7 @@ fn syn_brackets(syn_expr: syn::Expr) -> syn::Expr { fn collect_exprs(file: syn::File) -> Vec<syn::Expr> { use syn::fold::Fold; use syn::punctuated::Punctuated; - use syn::{token, ConstParam, Expr, ExprTuple, Path}; + use syn::{token, ConstParam, Expr, ExprTuple, Pat, Path}; struct CollectExprs(Vec<Expr>); impl Fold for CollectExprs { @@ -444,6 +435,10 @@ fn collect_exprs(file: syn::File) -> Vec<syn::Expr> { }) } + fn fold_pat(&mut self, pat: Pat) -> Pat { + pat + } + fn fold_path(&mut self, path: Path) -> Path { // Skip traversing into const generic path arguments path diff --git a/vendor/syn/tests/test_receiver.rs b/vendor/syn/tests/test_receiver.rs index 923df96ba..8decb555c 100644 --- a/vendor/syn/tests/test_receiver.rs +++ b/vendor/syn/tests/test_receiver.rs @@ -1,127 +1,321 @@ -use syn::{parse_quote, FnArg, Receiver, TraitItemMethod}; +#![allow(clippy::uninlined_format_args)] + +#[macro_use] +mod macros; + +use syn::{parse_quote, TraitItemFn}; #[test] fn test_by_value() { - let TraitItemMethod { sig, .. } = parse_quote! { + let TraitItemFn { sig, .. } = parse_quote! { fn by_value(self: Self); }; - match sig.receiver() { - Some(FnArg::Typed(_)) => (), - value => panic!("expected FnArg::Typed, got {:?}", value), - } + snapshot!(&sig.inputs[0], @r###" + FnArg::Receiver(Receiver { + colon_token: Some, + ty: Type::Path { + path: Path { + segments: [ + PathSegment { + ident: "Self", + }, + ], + }, + }, + }) + "###); } #[test] fn test_by_mut_value() { - let TraitItemMethod { sig, .. } = parse_quote! { + let TraitItemFn { sig, .. } = parse_quote! { fn by_mut(mut self: Self); }; - match sig.receiver() { - Some(FnArg::Typed(_)) => (), - value => panic!("expected FnArg::Typed, got {:?}", value), - } + snapshot!(&sig.inputs[0], @r###" + FnArg::Receiver(Receiver { + mutability: Some, + colon_token: Some, + ty: Type::Path { + path: Path { + segments: [ + PathSegment { + ident: "Self", + }, + ], + }, + }, + }) + "###); } #[test] fn test_by_ref() { - let TraitItemMethod { sig, .. } = parse_quote! { + let TraitItemFn { sig, .. } = parse_quote! { fn by_ref(self: &Self); }; - match sig.receiver() { - Some(FnArg::Typed(_)) => (), - value => panic!("expected FnArg::Typed, got {:?}", value), - } + snapshot!(&sig.inputs[0], @r###" + FnArg::Receiver(Receiver { + colon_token: Some, + ty: Type::Reference { + elem: Type::Path { + path: Path { + segments: [ + PathSegment { + ident: "Self", + }, + ], + }, + }, + }, + }) + "###); } #[test] fn test_by_box() { - let TraitItemMethod { sig, .. } = parse_quote! { + let TraitItemFn { sig, .. } = parse_quote! { fn by_box(self: Box<Self>); }; - match sig.receiver() { - Some(FnArg::Typed(_)) => (), - value => panic!("expected FnArg::Typed, got {:?}", value), - } + snapshot!(&sig.inputs[0], @r###" + FnArg::Receiver(Receiver { + colon_token: Some, + ty: Type::Path { + path: Path { + segments: [ + PathSegment { + ident: "Box", + arguments: PathArguments::AngleBracketed { + args: [ + GenericArgument::Type(Type::Path { + path: Path { + segments: [ + PathSegment { + ident: "Self", + }, + ], + }, + }), + ], + }, + }, + ], + }, + }, + }) + "###); } #[test] fn test_by_pin() { - let TraitItemMethod { sig, .. } = parse_quote! { + let TraitItemFn { sig, .. } = parse_quote! { fn by_pin(self: Pin<Self>); }; - match sig.receiver() { - Some(FnArg::Typed(_)) => (), - value => panic!("expected FnArg::Typed, got {:?}", value), - } + snapshot!(&sig.inputs[0], @r###" + FnArg::Receiver(Receiver { + colon_token: Some, + ty: Type::Path { + path: Path { + segments: [ + PathSegment { + ident: "Pin", + arguments: PathArguments::AngleBracketed { + args: [ + GenericArgument::Type(Type::Path { + path: Path { + segments: [ + PathSegment { + ident: "Self", + }, + ], + }, + }), + ], + }, + }, + ], + }, + }, + }) + "###); } #[test] fn test_explicit_type() { - let TraitItemMethod { sig, .. } = parse_quote! { + let TraitItemFn { sig, .. } = parse_quote! { fn explicit_type(self: Pin<MyType>); }; - match sig.receiver() { - Some(FnArg::Typed(_)) => (), - value => panic!("expected FnArg::Typed, got {:?}", value), - } + snapshot!(&sig.inputs[0], @r###" + FnArg::Receiver(Receiver { + colon_token: Some, + ty: Type::Path { + path: Path { + segments: [ + PathSegment { + ident: "Pin", + arguments: PathArguments::AngleBracketed { + args: [ + GenericArgument::Type(Type::Path { + path: Path { + segments: [ + PathSegment { + ident: "MyType", + }, + ], + }, + }), + ], + }, + }, + ], + }, + }, + }) + "###); } #[test] fn test_value_shorthand() { - let TraitItemMethod { sig, .. } = parse_quote! { + let TraitItemFn { sig, .. } = parse_quote! { fn value_shorthand(self); }; - match sig.receiver() { - Some(FnArg::Receiver(Receiver { - reference: None, - mutability: None, - .. - })) => (), - value => panic!("expected FnArg::Receiver without ref/mut, got {:?}", value), - } + snapshot!(&sig.inputs[0], @r###" + FnArg::Receiver(Receiver { + ty: Type::Path { + path: Path { + segments: [ + PathSegment { + ident: "Self", + }, + ], + }, + }, + }) + "###); } #[test] fn test_mut_value_shorthand() { - let TraitItemMethod { sig, .. } = parse_quote! { + let TraitItemFn { sig, .. } = parse_quote! { fn mut_value_shorthand(mut self); }; - match sig.receiver() { - Some(FnArg::Receiver(Receiver { - reference: None, - mutability: Some(_), - .. - })) => (), - value => panic!("expected FnArg::Receiver with mut, got {:?}", value), - } + snapshot!(&sig.inputs[0], @r###" + FnArg::Receiver(Receiver { + mutability: Some, + ty: Type::Path { + path: Path { + segments: [ + PathSegment { + ident: "Self", + }, + ], + }, + }, + }) + "###); } #[test] fn test_ref_shorthand() { - let TraitItemMethod { sig, .. } = parse_quote! { + let TraitItemFn { sig, .. } = parse_quote! { fn ref_shorthand(&self); }; - match sig.receiver() { - Some(FnArg::Receiver(Receiver { - reference: Some(_), - mutability: None, - .. - })) => (), - value => panic!("expected FnArg::Receiver with ref, got {:?}", value), - } + snapshot!(&sig.inputs[0], @r###" + FnArg::Receiver(Receiver { + reference: Some(None), + ty: Type::Reference { + elem: Type::Path { + path: Path { + segments: [ + PathSegment { + ident: "Self", + }, + ], + }, + }, + }, + }) + "###); +} + +#[test] +fn test_ref_shorthand_with_lifetime() { + let TraitItemFn { sig, .. } = parse_quote! { + fn ref_shorthand(&'a self); + }; + snapshot!(&sig.inputs[0], @r###" + FnArg::Receiver(Receiver { + reference: Some(Some(Lifetime { + ident: "a", + })), + ty: Type::Reference { + lifetime: Some(Lifetime { + ident: "a", + }), + elem: Type::Path { + path: Path { + segments: [ + PathSegment { + ident: "Self", + }, + ], + }, + }, + }, + }) + "###); } #[test] fn test_ref_mut_shorthand() { - let TraitItemMethod { sig, .. } = parse_quote! { + let TraitItemFn { sig, .. } = parse_quote! { fn ref_mut_shorthand(&mut self); }; - match sig.receiver() { - Some(FnArg::Receiver(Receiver { - reference: Some(_), - mutability: Some(_), - .. - })) => (), - value => panic!("expected FnArg::Receiver with ref+mut, got {:?}", value), - } + snapshot!(&sig.inputs[0], @r###" + FnArg::Receiver(Receiver { + reference: Some(None), + mutability: Some, + ty: Type::Reference { + mutability: Some, + elem: Type::Path { + path: Path { + segments: [ + PathSegment { + ident: "Self", + }, + ], + }, + }, + }, + }) + "###); +} + +#[test] +fn test_ref_mut_shorthand_with_lifetime() { + let TraitItemFn { sig, .. } = parse_quote! { + fn ref_mut_shorthand(&'a mut self); + }; + snapshot!(&sig.inputs[0], @r###" + FnArg::Receiver(Receiver { + reference: Some(Some(Lifetime { + ident: "a", + })), + mutability: Some, + ty: Type::Reference { + lifetime: Some(Lifetime { + ident: "a", + }), + mutability: Some, + elem: Type::Path { + path: Path { + segments: [ + PathSegment { + ident: "Self", + }, + ], + }, + }, + }, + }) + "###); } diff --git a/vendor/syn/tests/test_round_trip.rs b/vendor/syn/tests/test_round_trip.rs index 9a5801d44..853f45eae 100644 --- a/vendor/syn/tests/test_round_trip.rs +++ b/vendor/syn/tests/test_round_trip.rs @@ -2,10 +2,17 @@ #![cfg(not(miri))] #![recursion_limit = "1024"] #![feature(rustc_private)] -#![allow(clippy::manual_assert)] +#![allow( + clippy::manual_assert, + clippy::manual_let_else, + clippy::match_like_matches_macro, + clippy::uninlined_format_args +)] extern crate rustc_ast; +extern crate rustc_ast_pretty; extern crate rustc_data_structures; +extern crate rustc_driver; extern crate rustc_error_messages; extern crate rustc_errors; extern crate rustc_expand; @@ -21,6 +28,7 @@ use rustc_ast::ast::{ WhereClause, }; use rustc_ast::mut_visit::{self, MutVisitor}; +use rustc_ast_pretty::pprust; use rustc_error_messages::{DiagnosticMessage, LazyFallbackBundle}; use rustc_errors::{translation, Diagnostic, PResult}; use rustc_session::parse::ParseSess; @@ -93,7 +101,9 @@ fn test(path: &Path, failed: &AtomicUsize, abort_after: usize) { rustc_span::create_session_if_not_set_then(edition, |_| { let equal = match panic::catch_unwind(|| { - let sess = ParseSess::new(FilePathMapping::empty()); + let locale_resources = rustc_driver::DEFAULT_LOCALE_RESOURCES.to_vec(); + let file_path_mapping = FilePathMapping::empty(); + let sess = ParseSess::new(locale_resources, file_path_mapping); let before = match librustc_parse(content, &sess) { Ok(before) => before, Err(diagnostic) => { @@ -133,10 +143,10 @@ fn test(path: &Path, failed: &AtomicUsize, abort_after: usize) { true } else { errorf!( - "=== {}: FAIL\nbefore: {:#?}\nafter: {:#?}\n", + "=== {}: FAIL\n{}\n!=\n{}\n", path.display(), - before, - after, + pprust::crate_to_string_for_macros(&before), + pprust::crate_to_string_for_macros(&after), ); false } @@ -161,9 +171,9 @@ fn librustc_parse(content: String, sess: &ParseSess) -> PResult<Crate> { fn translate_message(diagnostic: &Diagnostic) -> String { thread_local! { static FLUENT_BUNDLE: LazyFallbackBundle = { - let resources = rustc_error_messages::DEFAULT_LOCALE_RESOURCES; + let locale_resources = rustc_driver::DEFAULT_LOCALE_RESOURCES.to_vec(); let with_directionality_markers = false; - rustc_error_messages::fallback_fluent_bundle(resources, with_directionality_markers) + rustc_error_messages::fallback_fluent_bundle(locale_resources, with_directionality_markers) }; } diff --git a/vendor/syn/tests/test_shebang.rs b/vendor/syn/tests/test_shebang.rs index dc26b9aab..4c2a20457 100644 --- a/vendor/syn/tests/test_shebang.rs +++ b/vendor/syn/tests/test_shebang.rs @@ -1,3 +1,5 @@ +#![allow(clippy::uninlined_format_args)] + #[macro_use] mod macros; @@ -10,11 +12,11 @@ fn test_basic() { shebang: Some("#!/usr/bin/env rustx"), items: [ Item::Fn { - vis: Inherited, + vis: Visibility::Inherited, sig: Signature { ident: "main", generics: Generics, - output: Default, + output: ReturnType::Default, }, block: Block, }, @@ -31,25 +33,27 @@ fn test_comment() { File { attrs: [ Attribute { - style: Inner, - path: Path { - segments: [ - PathSegment { - ident: "allow", - arguments: None, - }, - ], + style: AttrStyle::Inner, + meta: Meta::List { + path: Path { + segments: [ + PathSegment { + ident: "allow", + }, + ], + }, + delimiter: MacroDelimiter::Paren, + tokens: TokenStream(`dead_code`), }, - tokens: TokenStream(`(dead_code)`), }, ], items: [ Item::Fn { - vis: Inherited, + vis: Visibility::Inherited, sig: Signature { ident: "main", generics: Generics, - output: Default, + output: ReturnType::Default, }, block: Block, }, diff --git a/vendor/syn/tests/test_size.rs b/vendor/syn/tests/test_size.rs index 32c6edaed..864c0116a 100644 --- a/vendor/syn/tests/test_size.rs +++ b/vendor/syn/tests/test_size.rs @@ -1,28 +1,35 @@ +// Assumes proc-macro2's "span-locations" feature is off. + #![cfg(target_pointer_width = "64")] use std::mem; use syn::{Expr, Item, Lit, Pat, Type}; +#[rustversion::attr(before(2022-11-24), ignore)] #[test] fn test_expr_size() { - assert_eq!(mem::size_of::<Expr>(), 272); + assert_eq!(mem::size_of::<Expr>(), 176); } +#[rustversion::attr(before(2022-09-09), ignore)] #[test] fn test_item_size() { - assert_eq!(mem::size_of::<Item>(), 320); + assert_eq!(mem::size_of::<Item>(), 360); } +#[rustversion::attr(before(2022-11-24), ignore)] #[test] fn test_type_size() { - assert_eq!(mem::size_of::<Type>(), 288); + assert_eq!(mem::size_of::<Type>(), 240); } +#[rustversion::attr(before(2021-10-11), ignore)] #[test] fn test_pat_size() { - assert_eq!(mem::size_of::<Pat>(), 144); + assert_eq!(mem::size_of::<Pat>(), 192); } +#[rustversion::attr(before(2022-09-09), ignore)] #[test] fn test_lit_size() { assert_eq!(mem::size_of::<Lit>(), 32); diff --git a/vendor/syn/tests/test_stmt.rs b/vendor/syn/tests/test_stmt.rs index f444e5b49..bc57685df 100644 --- a/vendor/syn/tests/test_stmt.rs +++ b/vendor/syn/tests/test_stmt.rs @@ -1,11 +1,14 @@ -#![allow(clippy::assertions_on_result_states, clippy::non_ascii_literal)] +#![allow( + clippy::assertions_on_result_states, + clippy::non_ascii_literal, + clippy::uninlined_format_args +)] #[macro_use] mod macros; use proc_macro2::{Delimiter, Group, Ident, Span, TokenStream, TokenTree}; use quote::quote; -use std::iter::FromIterator; use syn::Stmt; #[test] @@ -13,10 +16,12 @@ fn test_raw_operator() { let stmt = syn::parse_str::<Stmt>("let _ = &raw const x;").unwrap(); snapshot!(stmt, @r###" - Local(Local { + Stmt::Local { pat: Pat::Wild, - init: Some(Verbatim(`& raw const x`)), - }) + init: Some(LocalInit { + expr: Expr::Verbatim(`& raw const x`), + }), + } "###); } @@ -25,21 +30,22 @@ fn test_raw_variable() { let stmt = syn::parse_str::<Stmt>("let _ = &raw;").unwrap(); snapshot!(stmt, @r###" - Local(Local { + Stmt::Local { pat: Pat::Wild, - init: Some(Expr::Reference { - expr: Expr::Path { - path: Path { - segments: [ - PathSegment { - ident: "raw", - arguments: None, - }, - ], + init: Some(LocalInit { + expr: Expr::Reference { + expr: Expr::Path { + path: Path { + segments: [ + PathSegment { + ident: "raw", + }, + ], + }, }, }, }), - }) + } "###); } @@ -63,13 +69,13 @@ fn test_none_group() { ))]); snapshot!(tokens as Stmt, @r###" - Item(Item::Fn { - vis: Inherited, + Stmt::Item(Item::Fn { + vis: Visibility::Inherited, sig: Signature { asyncness: Some, ident: "f", generics: Generics, - output: Default, + output: ReturnType::Default, }, block: Block, }) @@ -83,11 +89,148 @@ fn test_let_dot_dot() { }; snapshot!(tokens as Stmt, @r###" - Local(Local { + Stmt::Local { pat: Pat::Rest, - init: Some(Expr::Lit { - lit: 10, + init: Some(LocalInit { + expr: Expr::Lit { + lit: 10, + }, + }), + } + "###); +} + +#[test] +fn test_let_else() { + let tokens = quote! { + let Some(x) = None else { return 0; }; + }; + + snapshot!(tokens as Stmt, @r###" + Stmt::Local { + pat: Pat::TupleStruct { + path: Path { + segments: [ + PathSegment { + ident: "Some", + }, + ], + }, + elems: [ + Pat::Ident { + ident: "x", + }, + ], + }, + init: Some(LocalInit { + expr: Expr::Path { + path: Path { + segments: [ + PathSegment { + ident: "None", + }, + ], + }, + }, + diverge: Some(Expr::Block { + block: Block { + stmts: [ + Stmt::Expr( + Expr::Return { + expr: Some(Expr::Lit { + lit: 0, + }), + }, + Some, + ), + ], + }, + }), }), + } + "###); +} + +#[test] +fn test_macros() { + let tokens = quote! { + fn main() { + macro_rules! mac {} + thread_local! { static FOO } + println!(""); + vec![] + } + }; + + snapshot!(tokens as Stmt, @r###" + Stmt::Item(Item::Fn { + vis: Visibility::Inherited, + sig: Signature { + ident: "main", + generics: Generics, + output: ReturnType::Default, + }, + block: Block { + stmts: [ + Stmt::Item(Item::Macro { + ident: Some("mac"), + mac: Macro { + path: Path { + segments: [ + PathSegment { + ident: "macro_rules", + }, + ], + }, + delimiter: MacroDelimiter::Brace, + tokens: TokenStream(``), + }, + }), + Stmt::Macro { + mac: Macro { + path: Path { + segments: [ + PathSegment { + ident: "thread_local", + }, + ], + }, + delimiter: MacroDelimiter::Brace, + tokens: TokenStream(`static FOO`), + }, + }, + Stmt::Macro { + mac: Macro { + path: Path { + segments: [ + PathSegment { + ident: "println", + }, + ], + }, + delimiter: MacroDelimiter::Paren, + tokens: TokenStream(`""`), + }, + semi_token: Some, + }, + Stmt::Expr( + Expr::Macro { + mac: Macro { + path: Path { + segments: [ + PathSegment { + ident: "vec", + }, + ], + }, + delimiter: MacroDelimiter::Bracket, + tokens: TokenStream(``), + }, + }, + None, + ), + ], + }, }) "###); } diff --git a/vendor/syn/tests/test_token_trees.rs b/vendor/syn/tests/test_token_trees.rs index 5b00448af..f5a067fd2 100644 --- a/vendor/syn/tests/test_token_trees.rs +++ b/vendor/syn/tests/test_token_trees.rs @@ -1,3 +1,5 @@ +#![allow(clippy::uninlined_format_args)] + #[macro_use] mod macros; diff --git a/vendor/syn/tests/test_ty.rs b/vendor/syn/tests/test_ty.rs index 335cafa2a..a400a7612 100644 --- a/vendor/syn/tests/test_ty.rs +++ b/vendor/syn/tests/test_ty.rs @@ -1,9 +1,10 @@ +#![allow(clippy::uninlined_format_args)] + #[macro_use] mod macros; use proc_macro2::{Delimiter, Group, Ident, Punct, Spacing, Span, TokenStream, TokenTree}; use quote::quote; -use std::iter::FromIterator; use syn::Type; #[test] @@ -34,12 +35,11 @@ fn test_macro_variable_type() { ident: "ty", arguments: PathArguments::AngleBracketed { args: [ - Type(Type::Path { + GenericArgument::Type(Type::Path { path: Path { segments: [ PathSegment { ident: "T", - arguments: None, }, ], }, @@ -71,12 +71,11 @@ fn test_macro_variable_type() { arguments: PathArguments::AngleBracketed { colon2_token: Some, args: [ - Type(Type::Path { + GenericArgument::Type(Type::Path { path: Path { segments: [ PathSegment { ident: "T", - arguments: None, }, ], }, @@ -108,7 +107,7 @@ fn test_group_angle_brackets() { ident: "Option", arguments: PathArguments::AngleBracketed { args: [ - Type(Type::Group { + GenericArgument::Type(Type::Group { elem: Type::Path { path: Path { segments: [ @@ -116,12 +115,11 @@ fn test_group_angle_brackets() { ident: "Vec", arguments: PathArguments::AngleBracketed { args: [ - Type(Type::Path { + GenericArgument::Type(Type::Path { path: Path { segments: [ PathSegment { ident: "u8", - arguments: None, }, ], }, @@ -160,12 +158,11 @@ fn test_group_colons() { ident: "Vec", arguments: PathArguments::AngleBracketed { args: [ - Type(Type::Path { + GenericArgument::Type(Type::Path { path: Path { segments: [ PathSegment { ident: "u8", - arguments: None, }, ], }, @@ -175,7 +172,6 @@ fn test_group_colons() { }, PathSegment { ident: "Item", - arguments: None, }, ], }, @@ -198,7 +194,6 @@ fn test_group_colons() { segments: [ PathSegment { ident: "T", - arguments: None, }, ], }, @@ -211,7 +206,6 @@ fn test_group_colons() { segments: [ PathSegment { ident: "Element", - arguments: None, }, ], }, @@ -226,15 +220,14 @@ fn test_trait_object() { Type::TraitObject { dyn_token: Some, bounds: [ - Trait(TraitBound { - modifier: None, + TypeParamBound::Trait(TraitBound { lifetimes: Some(BoundLifetimes { lifetimes: [ - LifetimeDef { + GenericParam::Lifetime(LifetimeParam { lifetime: Lifetime { ident: "a", }, - }, + }), ], }), path: Path { @@ -243,7 +236,7 @@ fn test_trait_object() { ident: "Trait", arguments: PathArguments::AngleBracketed { args: [ - Lifetime(Lifetime { + GenericArgument::Lifetime(Lifetime { ident: "a", }), ], @@ -252,9 +245,9 @@ fn test_trait_object() { ], }, }), - Lifetime(Lifetime { + TypeParamBound::Lifetime { ident: "static", - }), + }, ], } "###); @@ -264,16 +257,14 @@ fn test_trait_object() { Type::TraitObject { dyn_token: Some, bounds: [ - Lifetime(Lifetime { + TypeParamBound::Lifetime { ident: "a", - }), - Trait(TraitBound { - modifier: None, + }, + TypeParamBound::Trait(TraitBound { path: Path { segments: [ PathSegment { ident: "Trait", - arguments: None, }, ], }, @@ -294,13 +285,11 @@ fn test_trailing_plus() { snapshot!(tokens as Type, @r###" Type::ImplTrait { bounds: [ - Trait(TraitBound { - modifier: None, + TypeParamBound::Trait(TraitBound { path: Path { segments: [ PathSegment { ident: "Trait", - arguments: None, }, ], }, @@ -315,13 +304,11 @@ fn test_trailing_plus() { Type::TraitObject { dyn_token: Some, bounds: [ - Trait(TraitBound { - modifier: None, + TypeParamBound::Trait(TraitBound { path: Path { segments: [ PathSegment { ident: "Trait", - arguments: None, }, ], }, @@ -335,13 +322,11 @@ fn test_trailing_plus() { snapshot!(tokens as Type, @r###" Type::TraitObject { bounds: [ - Trait(TraitBound { - modifier: None, + TypeParamBound::Trait(TraitBound { path: Path { segments: [ PathSegment { ident: "Trait", - arguments: None, }, ], }, diff --git a/vendor/syn/tests/test_visibility.rs b/vendor/syn/tests/test_visibility.rs index 7b2c00ba3..496e0070b 100644 --- a/vendor/syn/tests/test_visibility.rs +++ b/vendor/syn/tests/test_visibility.rs @@ -1,8 +1,9 @@ +#![allow(clippy::uninlined_format_args)] + #[macro_use] mod macros; use proc_macro2::{Delimiter, Group, Ident, Punct, Spacing, Span, TokenStream, TokenTree}; -use std::iter::FromIterator; use syn::parse::{Parse, ParseStream}; use syn::{DeriveInput, Result, Visibility}; @@ -51,11 +52,6 @@ fn test_pub() { } #[test] -fn test_crate() { - assert_vis_parse!("crate", Ok(Visibility::Crate(_))); -} - -#[test] fn test_inherited() { assert_vis_parse!("", Ok(Visibility::Inherited)); } @@ -128,14 +124,14 @@ fn test_empty_group_vis() { snapshot!(tokens as DeriveInput, @r###" DeriveInput { - vis: Inherited, + vis: Visibility::Inherited, ident: "S", generics: Generics, data: Data::Struct { fields: Fields::Named { named: [ Field { - vis: Inherited, + vis: Visibility::Inherited, ident: Some("f"), colon_token: Some, ty: Type::Tuple, |