From 4d8ee9b0068134c2e4191543a699d4e114c5e5c7 Mon Sep 17 00:00:00 2001 From: Nicolas Silva Date: Wed, 3 Jan 2024 09:33:06 +0000 Subject: [PATCH] Bug 1872658 - Update `wgpu` to revision 46757372cc02d6608124502104a0c225e1744fd7. r=webgpu-reviewers,supply-chain-reviewers,teoxoy Changelog: * #4865 fix present mode for wgl By xiaopengli89 in https://github.com/gfx-rs/wgpu/pull/4865 * #4873 Bump ctor from 0.2.5 to 0.2.6 By dependabot[bot] in https://github.com/gfx-rs/wgpu/pull/4873 * #4874 Bump syn from 2.0.40 to 2.0.41 By dependabot[bot] in https://github.com/gfx-rs/wgpu/pull/4874 * #4869 [naga wgsl-out] Include the `f` suffix on `f32` literals. By jimblandy in https://github.com/gfx-rs/wgpu/pull/4869 * #4850 [naga wgsl-in] Support abstract operands to binary operators. By jimblandy in https://github.com/gfx-rs/wgpu/pull/4850 * #4850 [naga wgsl-in] Support abstract operands to binary operators. By jimblandy in https://github.com/gfx-rs/wgpu/pull/4850 * #4850 [naga wgsl-in] Support abstract operands to binary operators. By jimblandy in https://github.com/gfx-rs/wgpu/pull/4850 * #4850 [naga wgsl-in] Support abstract operands to binary operators. By jimblandy in https://github.com/gfx-rs/wgpu/pull/4850 * #4850 [naga wgsl-in] Support abstract operands to binary operators. By jimblandy in https://github.com/gfx-rs/wgpu/pull/4850 * #4870 [naga wgsl] Let unary operators accept and produce abstract types. By jimblandy in https://github.com/gfx-rs/wgpu/pull/4870 * #4867 Reintroduce buffer snatching Part 1 By nical in https://github.com/gfx-rs/wgpu/pull/4867 * #4882 Bump zerocopy from 0.7.26 to 0.7.31 By dependabot[bot] in https://github.com/gfx-rs/wgpu/pull/4882 * #4878 Buffer snatching part 2 - Refactor create_buffer By nical in https://github.com/gfx-rs/wgpu/pull/4878 * #4815 Add `wgpu` crate features for backends By daxpedda in https://github.com/gfx-rs/wgpu/pull/4815 * #4887 Allow clippy::pattern_type_mismatch By nical in https://github.com/gfx-rs/wgpu/pull/4887 * #4886 Document wgpu & wgpu-core features By Wumpf in https://github.com/gfx-rs/wgpu/pull/4886 * #4826 validation: More detailed on incompatible BGL By scoopr in https://github.com/gfx-rs/wgpu/pull/4826 * #4888 Web: add support for more `RawWindowHandle` variants By daxpedda in https://github.com/gfx-rs/wgpu/pull/4888 * #4890 Bump thiserror from 1.0.50 to 1.0.51 By dependabot[bot] in https://github.com/gfx-rs/wgpu/pull/4890 * #4880 Simplify `ResourceMaps` By nical in https://github.com/gfx-rs/wgpu/pull/4880 * #4891 Make the naga version in trunk as high as the latest published one By nical in https://github.com/gfx-rs/wgpu/pull/4891 * #4893 Avoid allocating memory every time we might log a label By nical in https://github.com/gfx-rs/wgpu/pull/4893 * #4894 Remove some locks in BindGroup By nical in https://github.com/gfx-rs/wgpu/pull/4894 * #4862 Ensure that DeviceLostCallbackC is always called exactly once By bradwerth in https://github.com/gfx-rs/wgpu/pull/4862 * #4900 Support Device fence sharing with dx12 on Windows By sotaroikeda in https://github.com/gfx-rs/wgpu/pull/4900 * #4903 Bump tokio from 1.35.0 to 1.35.1 By dependabot[bot] in https://github.com/gfx-rs/wgpu/pull/4903 * #4895 Check that raw buffers and raw bind groups are valid By nical in https://github.com/gfx-rs/wgpu/pull/4895 * #4901 fix: docs By miaobuao in https://github.com/gfx-rs/wgpu/pull/4901 * #4892 Simplify some code around buffer unmapping By nical in https://github.com/gfx-rs/wgpu/pull/4892 * #4896 Buffer snatching By nical in https://github.com/gfx-rs/wgpu/pull/4896 * #4851 Eagerly release GPU resources when we lose the device. By bradwerth in https://github.com/gfx-rs/wgpu/pull/4851 * #4906 Use nightly for docs By cwfitzgerald in https://github.com/gfx-rs/wgpu/pull/4906 * #4908 Bump syn from 2.0.41 to 2.0.42 By dependabot[bot] in https://github.com/gfx-rs/wgpu/pull/4908 * #4909 Bump profiling from 1.0.12 to 1.0.13 By dependabot[bot] in https://github.com/gfx-rs/wgpu/pull/4909 * #4910 Bump anyhow from 1.0.75 to 1.0.76 By dependabot[bot] in https://github.com/gfx-rs/wgpu/pull/4910 * #4913 Remove id32 Feature By cwfitzgerald in https://github.com/gfx-rs/wgpu/pull/4913 * #4914 Add BGL Deduplication Index Test By cwfitzgerald in https://github.com/gfx-rs/wgpu/pull/4914 * #4921 Fix typo "layout pipeline layout" -> "pipeline layout" By HactarCE in https://github.com/gfx-rs/wgpu/pull/4921 * #4922 Bump winit from 0.29.4 to 0.29.5 By dependabot[bot] in https://github.com/gfx-rs/wgpu/pull/4922 * #4924 Inline `document-features` usage, remove dep. By ErichDonGubler in https://github.com/gfx-rs/wgpu/pull/4924 * #4871 Speed up Naga's `cargo xtask validate wgsl` from 12s to 0.8s By jimblandy in https://github.com/gfx-rs/wgpu/pull/4871 * #4871 Speed up Naga's `cargo xtask validate wgsl` from 12s to 0.8s By jimblandy in https://github.com/gfx-rs/wgpu/pull/4871 * #4871 Speed up Naga's `cargo xtask validate wgsl` from 12s to 0.8s By jimblandy in https://github.com/gfx-rs/wgpu/pull/4871 * #4930 Bump winit from 0.29.5 to 0.29.6 By dependabot[bot] in https://github.com/gfx-rs/wgpu/pull/4930 * #4929 Bump web-time from 0.2.3 to 0.2.4 By dependabot[bot] in https://github.com/gfx-rs/wgpu/pull/4929 * #4902 [naga xtask] Run validation jobs in parallel, using jobserver. By jimblandy in https://github.com/gfx-rs/wgpu/pull/4902 * #4902 [naga xtask] Run validation jobs in parallel, using jobserver. By jimblandy in https://github.com/gfx-rs/wgpu/pull/4902 * #4902 [naga xtask] Run validation jobs in parallel, using jobserver. By jimblandy in https://github.com/gfx-rs/wgpu/pull/4902 * #4902 [naga xtask] Run validation jobs in parallel, using jobserver. By jimblandy in https://github.com/gfx-rs/wgpu/pull/4902 * #4902 [naga xtask] Run validation jobs in parallel, using jobserver. By jimblandy in https://github.com/gfx-rs/wgpu/pull/4902 * #4902 [naga xtask] Run validation jobs in parallel, using jobserver. By jimblandy in https://github.com/gfx-rs/wgpu/pull/4902 * #4902 [naga xtask] Run validation jobs in parallel, using jobserver. By jimblandy in https://github.com/gfx-rs/wgpu/pull/4902 * #4902 [naga xtask] Run validation jobs in parallel, using jobserver. By jimblandy in https://github.com/gfx-rs/wgpu/pull/4902 * #4902 [naga xtask] Run validation jobs in parallel, using jobserver. By jimblandy in https://github.com/gfx-rs/wgpu/pull/4902 * #4902 [naga xtask] Run validation jobs in parallel, using jobserver. By jimblandy in https://github.com/gfx-rs/wgpu/pull/4902 * #4902 [naga xtask] Run validation jobs in parallel, using jobserver. By jimblandy in https://github.com/gfx-rs/wgpu/pull/4902 * #4940 Align `wgpu_types::CompositeAlphaMode` serde serializations to spec By littledivy in https://github.com/gfx-rs/wgpu/pull/4940 * #4936 Bump anyhow from 1.0.76 to 1.0.77 By dependabot[bot] in https://github.com/gfx-rs/wgpu/pull/4936 * #4933 Bump thiserror from 1.0.51 to 1.0.52 By dependabot[bot] in https://github.com/gfx-rs/wgpu/pull/4933 * #4932 Bump syn from 2.0.42 to 2.0.43 By dependabot[bot] in https://github.com/gfx-rs/wgpu/pull/4932 Differential Revision: https://phabricator.services.mozilla.com/D197519 --- .cargo/config.in | 4 +- Cargo.lock | 32 +- gfx/wgpu_bindings/Cargo.toml | 14 +- gfx/wgpu_bindings/moz.yaml | 4 +- supply-chain/audits.toml | 23 +- supply-chain/imports.lock | 35 ++ third_party/rust/naga/.cargo-checksum.json | 2 +- third_party/rust/naga/Cargo.toml | 4 +- third_party/rust/naga/src/back/wgsl/writer.rs | 39 +- third_party/rust/naga/src/front/glsl/token.rs | 2 +- third_party/rust/naga/src/front/wgsl/error.rs | 20 + .../naga/src/front/wgsl/lower/construction.rs | 86 +-- .../naga/src/front/wgsl/lower/conversion.rs | 168 +++++- .../rust/naga/src/front/wgsl/lower/mod.rs | 54 +- .../rust/naga/src/front/wgsl/parse/lexer.rs | 103 ++-- .../rust/naga/src/front/wgsl/parse/number.rs | 59 +-- .../rust/naga/src/proc/constant_evaluator.rs | 59 ++- .../rust/proc-macro2/.cargo-checksum.json | 2 +- third_party/rust/proc-macro2/Cargo.toml | 2 +- third_party/rust/proc-macro2/build.rs | 167 ++++-- third_party/rust/proc-macro2/build/probe.rs | 21 + third_party/rust/proc-macro2/src/fallback.rs | 44 +- third_party/rust/proc-macro2/src/lib.rs | 26 +- third_party/rust/proc-macro2/src/parse.rs | 19 +- third_party/rust/proc-macro2/src/wrapper.rs | 20 +- third_party/rust/quote/.cargo-checksum.json | 2 +- third_party/rust/quote/Cargo.toml | 7 +- third_party/rust/quote/README.md | 14 +- third_party/rust/quote/build.rs | 38 -- third_party/rust/quote/src/ident_fragment.rs | 6 +- third_party/rust/quote/src/lib.rs | 6 +- third_party/rust/quote/src/runtime.rs | 44 +- third_party/rust/quote/src/spanned.rs | 12 - third_party/rust/quote/src/to_tokens.rs | 4 +- .../rust/quote/tests/ui/not-quotable.stderr | 18 +- third_party/rust/syn/.cargo-checksum.json | 2 +- third_party/rust/syn/Cargo.toml | 9 +- third_party/rust/syn/benches/rust.rs | 9 +- third_party/rust/syn/src/attr.rs | 2 +- third_party/rust/syn/src/buffer.rs | 9 +- third_party/rust/syn/src/data.rs | 90 +++- third_party/rust/syn/src/error.rs | 1 + third_party/rust/syn/src/expr.rs | 295 +++++++---- third_party/rust/syn/src/gen/clone.rs | 11 +- third_party/rust/syn/src/gen/debug.rs | 11 +- third_party/rust/syn/src/gen/eq.rs | 19 +- third_party/rust/syn/src/gen/fold.rs | 366 ++++++++++++- third_party/rust/syn/src/gen/hash.rs | 11 +- third_party/rust/syn/src/gen/visit.rs | 364 ++++++++++++- third_party/rust/syn/src/gen/visit_mut.rs | 364 ++++++++++++- third_party/rust/syn/src/generics.rs | 2 +- third_party/rust/syn/src/item.rs | 4 +- third_party/rust/syn/src/lib.rs | 61 ++- third_party/rust/syn/src/lit.rs | 21 +- third_party/rust/syn/src/macros.rs | 89 ++-- third_party/rust/syn/src/meta.rs | 2 +- third_party/rust/syn/src/op.rs | 86 ++- third_party/rust/syn/src/parse.rs | 52 ++ third_party/rust/syn/src/parse_quote.rs | 32 +- third_party/rust/syn/src/pat.rs | 37 +- third_party/rust/syn/src/path.rs | 7 +- third_party/rust/syn/src/restriction.rs | 4 +- third_party/rust/syn/src/stmt.rs | 4 +- third_party/rust/syn/src/ty.rs | 2 +- third_party/rust/syn/tests/common/eq.rs | 66 ++- third_party/rust/syn/tests/debug/gen.rs | 499 +++++++++++++++++- third_party/rust/syn/tests/debug/mod.rs | 12 +- third_party/rust/syn/tests/macros/mod.rs | 26 +- third_party/rust/syn/tests/repo/mod.rs | 3 +- third_party/rust/syn/tests/test_asyncness.rs | 8 +- .../rust/syn/tests/test_derive_input.rs | 14 + third_party/rust/syn/tests/test_expr.rs | 271 ++++++++-- third_party/rust/syn/tests/test_generics.rs | 8 +- third_party/rust/syn/tests/test_item.rs | 10 +- third_party/rust/syn/tests/test_meta.rs | 1 + .../rust/syn/tests/test_parse_buffer.rs | 3 +- .../rust/syn/tests/test_parse_quote.rs | 164 ++++++ .../rust/syn/tests/test_parse_stream.rs | 2 +- third_party/rust/syn/tests/test_pat.rs | 59 ++- third_party/rust/syn/tests/test_path.rs | 2 + third_party/rust/syn/tests/test_precedence.rs | 171 +++--- third_party/rust/syn/tests/test_round_trip.rs | 3 +- third_party/rust/syn/tests/test_shebang.rs | 8 +- third_party/rust/syn/tests/test_size.rs | 4 +- third_party/rust/syn/tests/test_stmt.rs | 94 +++- third_party/rust/syn/tests/test_ty.rs | 64 ++- .../rust/thiserror-impl/.cargo-checksum.json | 2 +- third_party/rust/thiserror-impl/Cargo.toml | 11 +- third_party/rust/thiserror-impl/src/ast.rs | 4 - third_party/rust/thiserror-impl/src/attr.rs | 21 +- third_party/rust/thiserror-impl/src/expand.rs | 227 ++++---- third_party/rust/thiserror-impl/src/lib.rs | 11 +- third_party/rust/thiserror-impl/src/prop.rs | 12 + third_party/rust/thiserror-impl/src/span.rs | 15 + .../rust/thiserror/.cargo-checksum.json | 2 +- third_party/rust/thiserror/Cargo.toml | 15 +- third_party/rust/thiserror/build.rs | 101 +++- third_party/rust/thiserror/build/probe.rs | 32 ++ third_party/rust/thiserror/src/aserror.rs | 2 + third_party/rust/thiserror/src/display.rs | 36 +- third_party/rust/thiserror/src/lib.rs | 21 +- third_party/rust/thiserror/src/provide.rs | 17 +- .../rust/thiserror/tests/test_backtrace.rs | 65 +-- .../rust/thiserror/tests/test_display.rs | 2 + third_party/rust/thiserror/tests/test_expr.rs | 2 +- .../rust/thiserror/tests/test_generics.rs | 2 +- .../rust/thiserror/tests/test_option.rs | 5 +- .../tests/ui/fallback-impl-with-display.rs | 14 + .../ui/fallback-impl-with-display.stderr | 16 + .../tests/ui/from-backtrace-backtrace.rs | 7 +- .../tests/ui/from-backtrace-backtrace.stderr | 6 +- .../tests/ui/invalid-input-impl-anyway.rs | 11 + .../tests/ui/invalid-input-impl-anyway.stderr | 5 + .../thiserror/tests/ui/missing-display.rs | 9 + .../thiserror/tests/ui/missing-display.stderr | 13 + .../rust/thiserror/tests/ui/no-display.stderr | 2 +- .../tests/ui/source-enum-not-error.rs | 4 +- .../tests/ui/source-enum-not-error.stderr | 38 +- .../ui/source-enum-unnamed-field-not-error.rs | 12 + ...source-enum-unnamed-field-not-error.stderr | 22 + .../source-struct-unnamed-field-not-error.rs | 10 + ...urce-struct-unnamed-field-not-error.stderr | 21 + .../tests/ui/transparent-enum-not-error.rs | 9 + .../ui/transparent-enum-not-error.stderr | 23 + ...ransparent-enum-unnamed-field-not-error.rs | 9 + ...parent-enum-unnamed-field-not-error.stderr | 23 + .../tests/ui/transparent-struct-not-error.rs | 9 + .../ui/transparent-struct-not-error.stderr | 21 + ...nsparent-struct-unnamed-field-not-error.rs | 7 + ...rent-struct-unnamed-field-not-error.stderr | 21 + .../rust/wgpu-core/.cargo-checksum.json | 2 +- third_party/rust/wgpu-core/Cargo.toml | 1 - .../rust/wgpu-core/src/binding_model.rs | 28 +- .../rust/wgpu-core/src/command/bind.rs | 86 +++ .../rust/wgpu-core/src/command/bundle.rs | 46 +- .../rust/wgpu-core/src/command/clear.rs | 6 +- .../rust/wgpu-core/src/command/compute.rs | 81 +-- .../rust/wgpu-core/src/command/draw.rs | 8 +- .../rust/wgpu-core/src/command/memory_init.rs | 8 +- third_party/rust/wgpu-core/src/command/mod.rs | 17 +- .../rust/wgpu-core/src/command/query.rs | 11 +- .../rust/wgpu-core/src/command/render.rs | 64 ++- .../rust/wgpu-core/src/command/transfer.rs | 22 +- .../rust/wgpu-core/src/device/global.rs | 233 ++++---- third_party/rust/wgpu-core/src/device/life.rs | 381 ++++++++----- third_party/rust/wgpu-core/src/device/mod.rs | 69 ++- .../rust/wgpu-core/src/device/queue.rs | 40 +- .../rust/wgpu-core/src/device/resource.rs | 94 ++-- third_party/rust/wgpu-core/src/id.rs | 9 - third_party/rust/wgpu-core/src/lib.rs | 53 +- third_party/rust/wgpu-core/src/pipeline.rs | 6 +- third_party/rust/wgpu-core/src/resource.rs | 179 +++++-- third_party/rust/wgpu-core/src/snatch.rs | 86 +++ third_party/rust/wgpu-core/src/storage.rs | 2 +- .../rust/wgpu-core/src/track/buffer.rs | 8 +- third_party/rust/wgpu-core/src/track/mod.rs | 4 +- third_party/rust/wgpu-core/src/track/range.rs | 4 +- .../rust/wgpu-core/src/track/stateless.rs | 2 +- third_party/rust/wgpu-core/src/validation.rs | 2 +- .../rust/wgpu-hal/.cargo-checksum.json | 2 +- third_party/rust/wgpu-hal/Cargo.toml | 2 +- third_party/rust/wgpu-hal/src/dx12/device.rs | 2 +- third_party/rust/wgpu-hal/src/dx12/mod.rs | 6 + third_party/rust/wgpu-hal/src/gles/adapter.rs | 2 +- third_party/rust/wgpu-hal/src/gles/web.rs | 33 +- third_party/rust/wgpu-hal/src/gles/wgl.rs | 2 +- .../rust/wgpu-hal/src/vulkan/instance.rs | 6 +- .../rust/wgpu-types/.cargo-checksum.json | 2 +- third_party/rust/wgpu-types/src/lib.rs | 2 +- 169 files changed, 5461 insertions(+), 1685 deletions(-) create mode 100644 third_party/rust/proc-macro2/build/probe.rs delete mode 100644 third_party/rust/quote/build.rs create mode 100644 third_party/rust/syn/tests/test_parse_quote.rs create mode 100644 third_party/rust/thiserror-impl/src/span.rs create mode 100644 third_party/rust/thiserror/build/probe.rs create mode 100644 third_party/rust/thiserror/tests/ui/fallback-impl-with-display.rs create mode 100644 third_party/rust/thiserror/tests/ui/fallback-impl-with-display.stderr create mode 100644 third_party/rust/thiserror/tests/ui/invalid-input-impl-anyway.rs create mode 100644 third_party/rust/thiserror/tests/ui/invalid-input-impl-anyway.stderr create mode 100644 third_party/rust/thiserror/tests/ui/missing-display.rs create mode 100644 third_party/rust/thiserror/tests/ui/missing-display.stderr create mode 100644 third_party/rust/thiserror/tests/ui/source-enum-unnamed-field-not-error.rs create mode 100644 third_party/rust/thiserror/tests/ui/source-enum-unnamed-field-not-error.stderr create mode 100644 third_party/rust/thiserror/tests/ui/source-struct-unnamed-field-not-error.rs create mode 100644 third_party/rust/thiserror/tests/ui/source-struct-unnamed-field-not-error.stderr create mode 100644 third_party/rust/thiserror/tests/ui/transparent-enum-not-error.rs create mode 100644 third_party/rust/thiserror/tests/ui/transparent-enum-not-error.stderr create mode 100644 third_party/rust/thiserror/tests/ui/transparent-enum-unnamed-field-not-error.rs create mode 100644 third_party/rust/thiserror/tests/ui/transparent-enum-unnamed-field-not-error.stderr create mode 100644 third_party/rust/thiserror/tests/ui/transparent-struct-not-error.rs create mode 100644 third_party/rust/thiserror/tests/ui/transparent-struct-not-error.stderr create mode 100644 third_party/rust/thiserror/tests/ui/transparent-struct-unnamed-field-not-error.rs create mode 100644 third_party/rust/thiserror/tests/ui/transparent-struct-unnamed-field-not-error.stderr create mode 100644 third_party/rust/wgpu-core/src/snatch.rs diff --git a/.cargo/config.in b/.cargo/config.in index 214cf6e38ed1b..2deaab3f46a5d 100644 --- a/.cargo/config.in +++ b/.cargo/config.in @@ -25,9 +25,9 @@ git = "https://github.com/franziskuskiefer/cose-rust" rev = "43c22248d136c8b38fe42ea709d08da6355cf04b" replace-with = "vendored-sources" -[source."git+https://github.com/gfx-rs/wgpu?rev=6dc9ccab8592645fda3204be1cfb5929fd7f924d"] +[source."git+https://github.com/gfx-rs/wgpu?rev=46757372cc02d6608124502104a0c225e1744fd7"] git = "https://github.com/gfx-rs/wgpu" -rev = "6dc9ccab8592645fda3204be1cfb5929fd7f924d" +rev = "46757372cc02d6608124502104a0c225e1744fd7" replace-with = "vendored-sources" [source."git+https://github.com/hsivonen/chardetng?rev=3484d3e3ebdc8931493aa5df4d7ee9360a90e76b"] diff --git a/Cargo.lock b/Cargo.lock index b1410b1448784..c0cd98fe98fbe 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1157,7 +1157,7 @@ dependencies = [ [[package]] name = "d3d12" version = "0.7.0" -source = "git+https://github.com/gfx-rs/wgpu?rev=6dc9ccab8592645fda3204be1cfb5929fd7f924d#6dc9ccab8592645fda3204be1cfb5929fd7f924d" +source = "git+https://github.com/gfx-rs/wgpu?rev=46757372cc02d6608124502104a0c225e1744fd7#46757372cc02d6608124502104a0c225e1744fd7" dependencies = [ "bitflags 2.4.0", "libloading", @@ -3795,8 +3795,8 @@ checksum = "a2983372caf4480544083767bf2d27defafe32af49ab4df3a0b7fc90793a3664" [[package]] name = "naga" -version = "0.14.0" -source = "git+https://github.com/gfx-rs/wgpu?rev=6dc9ccab8592645fda3204be1cfb5929fd7f924d#6dc9ccab8592645fda3204be1cfb5929fd7f924d" +version = "0.14.2" +source = "git+https://github.com/gfx-rs/wgpu?rev=46757372cc02d6608124502104a0c225e1744fd7#46757372cc02d6608124502104a0c225e1744fd7" dependencies = [ "bit-set", "bitflags 2.4.0", @@ -4420,9 +4420,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.69" +version = "1.0.74" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "134c189feb4956b20f6f547d2cf727d4c0fe06722b20a0eec87ed445a97f92da" +checksum = "2de98502f212cfcea8d0bb305bd0f49d7ebdd75b64ba0a68f937d888f4e0d6db" dependencies = [ "unicode-ident", ] @@ -4540,9 +4540,9 @@ checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" [[package]] name = "quote" -version = "1.0.28" +version = "1.0.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b9ab9c7eadfd8df19006f1cf1a4aed13540ed5cbc047010ece5826e10825488" +checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" dependencies = [ "proc-macro2", ] @@ -5404,9 +5404,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.39" +version = "2.0.46" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23e78b90f2fcf45d3e842032ce32e3f2d1545ba6636271dcbf24fa306d87be7a" +checksum = "89456b690ff72fddcecf231caedbe615c59480c93358a93dfae7fc29e3ebbf0e" dependencies = [ "proc-macro2", "quote", @@ -5512,18 +5512,18 @@ checksum = "aac81b6fd6beb5884b0cf3321b8117e6e5d47ecb6fc89f414cfdcca8b2fe2dd8" [[package]] name = "thiserror" -version = "1.0.40" +version = "1.0.56" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "978c9a314bd8dc99be594bc3c175faaa9794be04a5a5e153caba6915336cebac" +checksum = "d54378c645627613241d077a3a79db965db602882668f9136ac42af9ecb730ad" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.40" +version = "1.0.56" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9456a42c5b0d803c8cd86e73dd7cc9edd429499f37a3550d286d5e86720569f" +checksum = "fa0faa943b50f3db30a20aa7e265dbc66076993efed8463e8de414e5d06d3471" dependencies = [ "proc-macro2", "quote", @@ -6412,7 +6412,7 @@ dependencies = [ [[package]] name = "wgpu-core" version = "0.18.0" -source = "git+https://github.com/gfx-rs/wgpu?rev=6dc9ccab8592645fda3204be1cfb5929fd7f924d#6dc9ccab8592645fda3204be1cfb5929fd7f924d" +source = "git+https://github.com/gfx-rs/wgpu?rev=46757372cc02d6608124502104a0c225e1744fd7#46757372cc02d6608124502104a0c225e1744fd7" dependencies = [ "arrayvec", "bit-vec", @@ -6435,7 +6435,7 @@ dependencies = [ [[package]] name = "wgpu-hal" version = "0.18.0" -source = "git+https://github.com/gfx-rs/wgpu?rev=6dc9ccab8592645fda3204be1cfb5929fd7f924d#6dc9ccab8592645fda3204be1cfb5929fd7f924d" +source = "git+https://github.com/gfx-rs/wgpu?rev=46757372cc02d6608124502104a0c225e1744fd7#46757372cc02d6608124502104a0c225e1744fd7" dependencies = [ "android_system_properties", "arrayvec", @@ -6472,7 +6472,7 @@ dependencies = [ [[package]] name = "wgpu-types" version = "0.18.0" -source = "git+https://github.com/gfx-rs/wgpu?rev=6dc9ccab8592645fda3204be1cfb5929fd7f924d#6dc9ccab8592645fda3204be1cfb5929fd7f924d" +source = "git+https://github.com/gfx-rs/wgpu?rev=46757372cc02d6608124502104a0c225e1744fd7#46757372cc02d6608124502104a0c225e1744fd7" dependencies = [ "bitflags 2.4.0", "js-sys", diff --git a/gfx/wgpu_bindings/Cargo.toml b/gfx/wgpu_bindings/Cargo.toml index 83001c20bc5af..7bdcd4c32289a 100644 --- a/gfx/wgpu_bindings/Cargo.toml +++ b/gfx/wgpu_bindings/Cargo.toml @@ -17,7 +17,7 @@ default = [] [dependencies.wgc] package = "wgpu-core" git = "https://github.com/gfx-rs/wgpu" -rev = "6dc9ccab8592645fda3204be1cfb5929fd7f924d" +rev = "46757372cc02d6608124502104a0c225e1744fd7" #Note: "replay" shouldn't ideally be needed, # but it allows us to serialize everything across IPC. features = ["replay", "trace", "serial-pass", "strict_asserts", "wgsl", "api_log_info"] @@ -27,36 +27,36 @@ features = ["replay", "trace", "serial-pass", "strict_asserts", "wgsl", "api_log [target.'cfg(any(target_os = "macos", target_os = "ios"))'.dependencies.wgc] package = "wgpu-core" git = "https://github.com/gfx-rs/wgpu" -rev = "6dc9ccab8592645fda3204be1cfb5929fd7f924d" +rev = "46757372cc02d6608124502104a0c225e1744fd7" features = ["metal"] # We want the wgpu-core Direct3D backends on Windows. [target.'cfg(windows)'.dependencies.wgc] package = "wgpu-core" git = "https://github.com/gfx-rs/wgpu" -rev = "6dc9ccab8592645fda3204be1cfb5929fd7f924d" +rev = "46757372cc02d6608124502104a0c225e1744fd7" features = ["dx12"] # We want the wgpu-core Vulkan backend on Linux and Windows. [target.'cfg(any(windows, all(unix, not(any(target_os = "macos", target_os = "ios")))))'.dependencies.wgc] package = "wgpu-core" git = "https://github.com/gfx-rs/wgpu" -rev = "6dc9ccab8592645fda3204be1cfb5929fd7f924d" +rev = "46757372cc02d6608124502104a0c225e1744fd7" features = ["vulkan"] [dependencies.wgt] package = "wgpu-types" git = "https://github.com/gfx-rs/wgpu" -rev = "6dc9ccab8592645fda3204be1cfb5929fd7f924d" +rev = "46757372cc02d6608124502104a0c225e1744fd7" [dependencies.wgh] package = "wgpu-hal" git = "https://github.com/gfx-rs/wgpu" -rev = "6dc9ccab8592645fda3204be1cfb5929fd7f924d" +rev = "46757372cc02d6608124502104a0c225e1744fd7" [target.'cfg(windows)'.dependencies.d3d12] git = "https://github.com/gfx-rs/wgpu" -rev = "6dc9ccab8592645fda3204be1cfb5929fd7f924d" +rev = "46757372cc02d6608124502104a0c225e1744fd7" [target.'cfg(windows)'.dependencies] winapi = "0.3" diff --git a/gfx/wgpu_bindings/moz.yaml b/gfx/wgpu_bindings/moz.yaml index 5da759f1f8a75..65da492fc3087 100644 --- a/gfx/wgpu_bindings/moz.yaml +++ b/gfx/wgpu_bindings/moz.yaml @@ -20,11 +20,11 @@ origin: # Human-readable identifier for this version/release # Generally "version NNN", "tag SSS", "bookmark SSS" - release: commit 6dc9ccab8592645fda3204be1cfb5929fd7f924d + release: commit 46757372cc02d6608124502104a0c225e1744fd7 # Revision to pull in # Must be a long or short commit SHA (long preferred) - revision: 6dc9ccab8592645fda3204be1cfb5929fd7f924d + revision: 46757372cc02d6608124502104a0c225e1744fd7 license: ['MIT', 'Apache-2.0'] diff --git a/supply-chain/audits.toml b/supply-chain/audits.toml index 717dd3f449c85..9140f24d83b7b 100644 --- a/supply-chain/audits.toml +++ b/supply-chain/audits.toml @@ -1264,9 +1264,12 @@ criteria = "safe-to-deploy" delta = "0.5.0 -> 0.7.0" [[audits.d3d12]] -who = "Erich Gubler " +who = [ + "Erich Gubler ", + "Nicolas Silva ", +] criteria = "safe-to-deploy" -delta = "0.7.0 -> 0.7.0@git:6dc9ccab8592645fda3204be1cfb5929fd7f924d" +delta = "0.7.0 -> 0.7.0@git:46757372cc02d6608124502104a0c225e1744fd7" importable = false [[audits.darling]] @@ -2536,9 +2539,9 @@ criteria = "safe-to-deploy" delta = "0.13.0 -> 0.14.0" [[audits.naga]] -who = "Jim Blandy " +who = ["Jim Blandy ", "Nicolas Silva "] criteria = "safe-to-deploy" -delta = "0.14.0 -> 0.14.0@git:6dc9ccab8592645fda3204be1cfb5929fd7f924d" +delta = "0.14.0 -> 0.14.2@git:46757372cc02d6608124502104a0c225e1744fd7" importable = false [[audits.net2]] @@ -4303,9 +4306,9 @@ criteria = "safe-to-deploy" delta = "0.17.0 -> 0.18.0" [[audits.wgpu-core]] -who = "Jim Blandy " +who = ["Jim Blandy ", "Nicolas Silva "] criteria = "safe-to-deploy" -delta = "0.18.0 -> 0.18.0@git:6dc9ccab8592645fda3204be1cfb5929fd7f924d" +delta = "0.18.0 -> 0.18.0@git:46757372cc02d6608124502104a0c225e1744fd7" importable = false [[audits.wgpu-hal]] @@ -4352,9 +4355,9 @@ criteria = "safe-to-deploy" delta = "0.17.0 -> 0.18.0" [[audits.wgpu-hal]] -who = "Jim Blandy " +who = ["Jim Blandy ", "Nicolas Silva "] criteria = "safe-to-deploy" -delta = "0.18.0 -> 0.18.0@git:6dc9ccab8592645fda3204be1cfb5929fd7f924d" +delta = "0.18.0 -> 0.18.0@git:46757372cc02d6608124502104a0c225e1744fd7" importable = false [[audits.wgpu-types]] @@ -4401,9 +4404,9 @@ criteria = "safe-to-deploy" delta = "0.17.0 -> 0.18.0" [[audits.wgpu-types]] -who = "Jim Blandy " +who = ["Jim Blandy ", "Nicolas Silva "] criteria = "safe-to-deploy" -delta = "0.18.0 -> 0.18.0@git:6dc9ccab8592645fda3204be1cfb5929fd7f924d" +delta = "0.18.0 -> 0.18.0@git:46757372cc02d6608124502104a0c225e1744fd7" importable = false [[audits.whatsys]] diff --git a/supply-chain/imports.lock b/supply-chain/imports.lock index 0b8afead2ac31..204d1d760ad37 100644 --- a/supply-chain/imports.lock +++ b/supply-chain/imports.lock @@ -433,6 +433,13 @@ user-id = 3618 user-login = "dtolnay" user-name = "David Tolnay" +[[publisher.proc-macro2]] +version = "1.0.74" +when = "2024-01-02" +user-id = 3618 +user-login = "dtolnay" +user-name = "David Tolnay" + [[publisher.quote]] version = "1.0.28" when = "2023-05-25" @@ -440,6 +447,13 @@ user-id = 3618 user-login = "dtolnay" user-name = "David Tolnay" +[[publisher.quote]] +version = "1.0.35" +when = "2024-01-02" +user-id = 3618 +user-login = "dtolnay" +user-name = "David Tolnay" + [[publisher.regex]] version = "1.7.1" when = "2023-01-09" @@ -601,6 +615,13 @@ user-id = 3618 user-login = "dtolnay" user-name = "David Tolnay" +[[publisher.syn]] +version = "2.0.46" +when = "2024-01-02" +user-id = 3618 +user-login = "dtolnay" +user-name = "David Tolnay" + [[publisher.termcolor]] version = "1.2.0" when = "2023-01-15" @@ -615,6 +636,20 @@ user-id = 189 user-login = "BurntSushi" user-name = "Andrew Gallant" +[[publisher.thiserror]] +version = "1.0.56" +when = "2024-01-02" +user-id = 3618 +user-login = "dtolnay" +user-name = "David Tolnay" + +[[publisher.thiserror-impl]] +version = "1.0.56" +when = "2024-01-02" +user-id = 3618 +user-login = "dtolnay" +user-name = "David Tolnay" + [[publisher.threadbound]] version = "0.1.5" when = "2022-12-17" diff --git a/third_party/rust/naga/.cargo-checksum.json b/third_party/rust/naga/.cargo-checksum.json index 6d39d1e9925a8..f2a66cdcdb2b4 100644 --- a/third_party/rust/naga/.cargo-checksum.json +++ b/third_party/rust/naga/.cargo-checksum.json @@ -1 +1 @@ -{"files":{".cargo/config.toml":"d7389d2a0c08ec72b79e83a3c76980903e3f9123625c32e69c798721193e2e74","CHANGELOG.md":"772216b2e6d35621ab36c985e8114b54403e2f3fb49bf1f8540c451fd06f8387","Cargo.toml":"5bd726a75d7177a43e517d27d412ac38879231f79795226ebcd0873ff1255fe9","README.md":"a76b47b656e7390265312709b62b357a4f39c7509ec9ebe0b133c5841a8ab60b","benches/criterion.rs":"f45e38b26e1323e934d32623572ff5395a53fed06f760eb1e07b22ed07858a38","src/arena.rs":"33ed2ec7b36429b133ed2a7de6fb9735827f69ea8b6c2ce97f64746a24a5bf36","src/back/dot/mod.rs":"a40050a73ac00c8fa43dd0b45a84fca6959d28c8c99ab3046b01f33c02f8c8f4","src/back/glsl/features.rs":"90c6a6255d550e9d97a04d6b6660c1a7af8e2433dd9379dc1d527693fa56523b","src/back/glsl/keywords.rs":"1546facbaddf696602102f32e47db7afc875f8ca3fbccc2122e0bcc45e022b53","src/back/glsl/mod.rs":"bba387392e3b9b22835d78a1db7d1490e7199cafcb347d54b22373b7b76b2900","src/back/hlsl/conv.rs":"5e40946f2d5ad6589dd2b0570d2c300dd96f92f0f954b829dc54a822de7774e8","src/back/hlsl/help.rs":"8f4ec24f74f3153a58b04f441bef16ecc8d400466d53187b06fb6b60a934a1ec","src/back/hlsl/keywords.rs":"eb4af8d697fb7f3991859d66339b5b2eac27c9fe41b73146ac838b207f462c9c","src/back/hlsl/mod.rs":"c677ebbb649a1c5f85f350d8da7129457d50ff52b1c88c1f0fac4a9d11eb020c","src/back/hlsl/storage.rs":"3170f165ff68d2482f8a8dbfa4bbf4b65d2446a7f208f33eea9eb187bb57eb09","src/back/hlsl/writer.rs":"8e61501bae6982273a525734d3e446694d4bf7a081419ec312c32b354e89d3ef","src/back/mod.rs":"b941caed50c086f49d25e76228d247ba6c2da6dbeea18d968c02dc68bb97f409","src/back/msl/keywords.rs":"998c0d86a26e5cf031c75f35cde28f2b390fe207a2e7d0eed8516ffdb99c1a8e","src/back/msl/mod.rs":"16d905902e30cf900ec924b66ff496adbbbc54af15c59713f358bfac042a625a","src/back/msl/sampler.rs":"9b01d68669e12ff7123243284b85e1a9d2c4d49140bd74ca32dedc007cbf15af","src/back/msl/writer.rs":"9503df4ae10d1d7b6840cb68e2e2ff4f7ed8761b217faa99e6927d87da546071","src/back/spv/block.rs":"2881cbc6c0a3e310a777b61c950dd97bbee5776583fe6ef13ee04095a8214768","src/back/spv/helpers.rs":"a4e260130f39c7345decec40dadf1e94419c8f6d236ce7a53b5300aa72952a1b","src/back/spv/image.rs":"5840a6d5cdffbf30cb20a76ddfdb468041fc6b687a476b3b2fc2553bda6f4af7","src/back/spv/index.rs":"26611dd50df5cfd214900e19415f5374dd301d3b7d3bfedbc5ec0f254328287a","src/back/spv/instructions.rs":"d0ced535fdec49323105a7d6ee40a8ed6b4966ac5f0f40b062f0eb11a531b106","src/back/spv/layout.rs":"e263de53cd2f9a03ad94b82b434ce636609bc1ed435a2d1132951663bfaa8ebd","src/back/spv/mod.rs":"31b0229f59b5784b57851fcf6325095add58af6de3afa85d518a4e266c4b99a9","src/back/spv/ray.rs":"a34bf6b26d873f7270caa45841d9ef291aca8d9732ecd086b14d8856038e1e41","src/back/spv/recyclable.rs":"114db0ea12774d6514f995d07295cb9a42631ab75165fc60980c10e9b5ecb832","src/back/spv/selection.rs":"81e404abfa0a977f7c1f76ccb37a78d13ccadbda229048dad53cc67687cc39db","src/back/spv/writer.rs":"a76a73c0692162da24ab5508bc3ca70eb5e01367fe54472d100e237dbd594467","src/back/wgsl/mod.rs":"2dd12bbea9ace835850192bb68c5760953da6bac6a636073d1eca19381c0c0b6","src/back/wgsl/writer.rs":"f73ae5509da94b72d89d723cda1adfd6ff418146a4e398f1035b90cf472bcff9","src/block.rs":"c69089e5bbb6de6ba24efb15b21d5d434fcabfbc4d48feae948d2a4da135aae7","src/compact/expressions.rs":"7a4c916282a5b484519ed29ab451c7b595d8dea73c83c5c2cf7efc6fbc648fda","src/compact/functions.rs":"174bd9167ecf6353afb8c36d365ba3f9b483233eb4bacf578e50183c7433aa15","src/compact/handle_set_map.rs":"817c5193352d5fd6a61a5c970daba23224e14a65aea15f8f1c8679c99f834ca2","src/compact/mod.rs":"8abea7a8a9870d953fb628a32bac2bc15e87e077910cb95aa1f26e58a0a35c2a","src/compact/statements.rs":"4df33ee9589300e769e75c674bdc30578e93704ec3eb2aabc7132121745b55c8","src/compact/types.rs":"18343f2ca2c123eea2531cffc1d54a7798797caccecaa1f9b8c4fd5dd6ca1a05","src/front/glsl/ast.rs":"2ae292c09fed43951e20ec6ce0b7b99efe91726cf90487d6c129137b08618e01","src/front/glsl/builtins.rs":"d35501d5b42b61c261da24436b82eafdf96371b1600d148648d90d041f736ae4","src/front/glsl/context.rs":"2f07a63209258a8459ae6a6ef8277313c4dc771ab96ef6f5ab3a383a0d3599ba","src/front/glsl/error.rs":"08409f8cc13b73c6eda938ff7ebf2b46e9d27c66d718d640ad8d6a33fddbb7a1","src/front/glsl/functions.rs":"60838c34b8295112e5696b52d710acebb93e0a982e05f8eb87d3b80f52eb7793","src/front/glsl/lex.rs":"08736ae8beb955da5b0e6e3e0f45995a824995f7096d516a2910417e9c7afa32","src/front/glsl/mod.rs":"c8e435a894d641e6c92fcd7d357d51e1136af1a69410fbaedb88c7262b2269df","src/front/glsl/offset.rs":"9358602ca4f9ef21d5066d674dae757bf88fdf5c289c4360534354d13bd41dc0","src/front/glsl/parser.rs":"fe5291512db412b33b6c09d5b3dcf7c54ff6ec55b47f0a078dcc11695e78471d","src/front/glsl/parser/declarations.rs":"d637cc52e553910a2e97b70b3366c15aefbe737f413adb11c27efd184c1fbf9d","src/front/glsl/parser/expressions.rs":"520cfc9402d5fbd48e52ef1d36562c6b74794c09ec33ec1ebb10aa48d129b66f","src/front/glsl/parser/functions.rs":"670ca6bba5a56f3919968658966b05ba824c2d76427b8927d4b111f715091629","src/front/glsl/parser/types.rs":"0971bc98cbde1d70c0ced1717c8726a12a5bfafa9a72b127ed242db5435ec8a8","src/front/glsl/parser_tests.rs":"fc2120fff132af850b52f9ac5d19f0c2fce7997b17ba49881b155d173359cfd3","src/front/glsl/token.rs":"42325adbef5bfc9e6f9e40e7ed3cbfa7ef498c05799fdb7694b123e6450410e1","src/front/glsl/types.rs":"58c9cf3d570dff8cb68f2931faf5b18e875e510741bf035ec10b9ff6df27c5d8","src/front/glsl/variables.rs":"fb2a09e386b6e98ca9fb8fb744afac1e8b19d1b67c6ede5c474e3ba860d3d4cb","src/front/interpolator.rs":"9b6ca498d5fbd9bc1515510a04e303a00b324121d7285da3c955cfe18eb4224c","src/front/mod.rs":"6f77ca3ff925cc16e5ae46132bd6196ca4c9c80a7db123f0d2ec09aae93ba51f","src/front/spv/convert.rs":"9b4ecc53131b6250cde4cae93557eb467127e9e8d0536d29a851538684ae5371","src/front/spv/error.rs":"3129fd1fe346441d61d0f641734df7e919919db15df706788d16402ebf480607","src/front/spv/function.rs":"3a3f0c07862750f79f8ebc273c5df11efc67272566458410f776bd8fa271a0f8","src/front/spv/image.rs":"5d55cfbf6752732a594114cd09a9a207216e1ee85d8f2c9bc4310217a55ea321","src/front/spv/mod.rs":"ccbeb4b80959c00323b2459e316b7c5c7e3f313ab94f2151fa44a2dee6255d4e","src/front/spv/null.rs":"e1446d99d04c76a9c3bbd24dd9b20c4711ce8a918a9b403be6cccbde1175b3b4","src/front/type_gen.rs":"b4f1df23380e06c9fdad4140810ce96ab041dbb1d371a07045b4e0069aa8ba55","src/front/wgsl/error.rs":"70a6820f8eb156ef61aa3d33efe9385352404b9415dda63eea0c60540a5c3b69","src/front/wgsl/index.rs":"2b9a4929a46bd822d3ed6f9a150e24d437e5bdca8293eb748aebe80ce7e74153","src/front/wgsl/lower/construction.rs":"48b2c1b0ef93345bc3cdbf1af29690cc128a4507f0b9d7d908a136f4c0fd48ca","src/front/wgsl/lower/conversion.rs":"2f84a83fd2d5bdc6f5737b63a74f24ae8b0fcc96c08786c728974debb42d9aa2","src/front/wgsl/lower/mod.rs":"59df2e00495e136eb59a0d3cb6c5990a31b914cd9f6e488355a597cd72cc0f01","src/front/wgsl/mod.rs":"02b194a0a29ef7281f71b424564e18ada4a8b1a0d8c26ec40b6be195bd4c4904","src/front/wgsl/parse/ast.rs":"c7eaae40179f0889f2b142d3b31968cbfab6d3cfe02e425912c6da8dadac51df","src/front/wgsl/parse/conv.rs":"01b25edbe80b263a3fa51bc980c075630bb31d4af851441323383eb4f3b83360","src/front/wgsl/parse/lexer.rs":"bff1d0e3cd920b2e9342b521bed7483595556b90088dc0b22e1599900585ff8e","src/front/wgsl/parse/mod.rs":"3b4895a2baf91c719b95f0afb6441ffac2036c2a9ff817e633882fd257afcc38","src/front/wgsl/parse/number.rs":"623423471a13cf9a45662ee3ac01554644ac544338c7493cfe6087549bab91f7","src/front/wgsl/tests.rs":"39d0b44d0f073a7599c88b7c4efd1572886f3af074fa2015454623be313b297f","src/front/wgsl/to_wgsl.rs":"2e2e30d86b07f209b866e530d3a882803bf28b39ce379052561a749f628e8e28","src/keywords/mod.rs":"0138f3931f8af0b0a05174549d0fd2152945b027dc3febefc1bbd676581d2e45","src/keywords/wgsl.rs":"7c3b364b60ca29cb8a68ef781de9ecd28b76b74bed18bf18a35d2ebffaa855ab","src/lib.rs":"c5d91c603ae310a7ef9ff8444898959a3dbbc32ba262cabb1fd5682823921d98","src/proc/constant_evaluator.rs":"8a282bd99957ac99e48564f2927f13682b43da68383913f76b4ef43064f3a56b","src/proc/emitter.rs":"39ac886c651e2ad33c06a676a7e4826a0e93de0af660c01e8e4b1f7406742f88","src/proc/index.rs":"f4250f6944c2b631e8140979024e8deb86fa8d5352d8641ba954a388b2c0940e","src/proc/layouter.rs":"b3d061c87424f36981c902716f37ab7b72f2bb2d0c2d7e900c51149318ea1a0a","src/proc/mod.rs":"221472328c410213fe9e794a1d2336af3798cc0e9f2cd027c754ea29f251cbfc","src/proc/namer.rs":"7328fac41e40890c64c7ee2fa985a4395424f18b08d30f30ca2583fdabd2fd35","src/proc/terminator.rs":"13c59bf00f5b26171d971effc421091f5e00dedddd246c2daa44fe65aeda060a","src/proc/typifier.rs":"99de19270d01c12ec49d14323aa1d9b8774f1ee715804af7235deff70739ba3d","src/span.rs":"6560599f20b8bc2de746ee9fd6b05c32bb630af914fce8845d84fdc72f9a636c","src/valid/analyzer.rs":"8472b98f16a4a4a0fa7079197db25696f77ef3e1602a7cddea1930daebd27917","src/valid/compose.rs":"83e4c09c39f853cf085b83b87e48b3db571da619132960d3ec954ebdfb0a74f2","src/valid/expression.rs":"1cdbd594dbdb33d8473d93c11112cf717e262bb8c35cee10b01db4322b2237d7","src/valid/function.rs":"5ec31146aacf7daae689836ff3e2978f075f2cc62b3fd829d09c760a6e606501","src/valid/handles.rs":"0878915e67b16d7c41cf8245d9ab3b3f4a604e7d4e87527ea40e03efcbf1f74a","src/valid/interface.rs":"6ddf5f8d5150342d2e8c754a71c92c85d8533fd1d4c6b7a83a05b508e8e8114d","src/valid/mod.rs":"9e2bafa06bea16db2c5a8f825eed4d008c474b87cda2fc7e82ca7a21229c6f20","src/valid/type.rs":"09e18bb9510dbb0cfb4a8ac054afee4c4f56063d614159ab5b956aa1e5850468"},"package":null} \ No newline at end of file +{"files":{".cargo/config.toml":"d7389d2a0c08ec72b79e83a3c76980903e3f9123625c32e69c798721193e2e74","CHANGELOG.md":"772216b2e6d35621ab36c985e8114b54403e2f3fb49bf1f8540c451fd06f8387","Cargo.toml":"db839f1b4ab6abd390be6fceaa0c79b0b7a61eed2ab2cf88a90ed92339167837","README.md":"a76b47b656e7390265312709b62b357a4f39c7509ec9ebe0b133c5841a8ab60b","benches/criterion.rs":"f45e38b26e1323e934d32623572ff5395a53fed06f760eb1e07b22ed07858a38","src/arena.rs":"33ed2ec7b36429b133ed2a7de6fb9735827f69ea8b6c2ce97f64746a24a5bf36","src/back/dot/mod.rs":"a40050a73ac00c8fa43dd0b45a84fca6959d28c8c99ab3046b01f33c02f8c8f4","src/back/glsl/features.rs":"90c6a6255d550e9d97a04d6b6660c1a7af8e2433dd9379dc1d527693fa56523b","src/back/glsl/keywords.rs":"1546facbaddf696602102f32e47db7afc875f8ca3fbccc2122e0bcc45e022b53","src/back/glsl/mod.rs":"bba387392e3b9b22835d78a1db7d1490e7199cafcb347d54b22373b7b76b2900","src/back/hlsl/conv.rs":"5e40946f2d5ad6589dd2b0570d2c300dd96f92f0f954b829dc54a822de7774e8","src/back/hlsl/help.rs":"8f4ec24f74f3153a58b04f441bef16ecc8d400466d53187b06fb6b60a934a1ec","src/back/hlsl/keywords.rs":"eb4af8d697fb7f3991859d66339b5b2eac27c9fe41b73146ac838b207f462c9c","src/back/hlsl/mod.rs":"c677ebbb649a1c5f85f350d8da7129457d50ff52b1c88c1f0fac4a9d11eb020c","src/back/hlsl/storage.rs":"3170f165ff68d2482f8a8dbfa4bbf4b65d2446a7f208f33eea9eb187bb57eb09","src/back/hlsl/writer.rs":"8e61501bae6982273a525734d3e446694d4bf7a081419ec312c32b354e89d3ef","src/back/mod.rs":"b941caed50c086f49d25e76228d247ba6c2da6dbeea18d968c02dc68bb97f409","src/back/msl/keywords.rs":"998c0d86a26e5cf031c75f35cde28f2b390fe207a2e7d0eed8516ffdb99c1a8e","src/back/msl/mod.rs":"16d905902e30cf900ec924b66ff496adbbbc54af15c59713f358bfac042a625a","src/back/msl/sampler.rs":"9b01d68669e12ff7123243284b85e1a9d2c4d49140bd74ca32dedc007cbf15af","src/back/msl/writer.rs":"9503df4ae10d1d7b6840cb68e2e2ff4f7ed8761b217faa99e6927d87da546071","src/back/spv/block.rs":"2881cbc6c0a3e310a777b61c950dd97bbee5776583fe6ef13ee04095a8214768","src/back/spv/helpers.rs":"a4e260130f39c7345decec40dadf1e94419c8f6d236ce7a53b5300aa72952a1b","src/back/spv/image.rs":"5840a6d5cdffbf30cb20a76ddfdb468041fc6b687a476b3b2fc2553bda6f4af7","src/back/spv/index.rs":"26611dd50df5cfd214900e19415f5374dd301d3b7d3bfedbc5ec0f254328287a","src/back/spv/instructions.rs":"d0ced535fdec49323105a7d6ee40a8ed6b4966ac5f0f40b062f0eb11a531b106","src/back/spv/layout.rs":"e263de53cd2f9a03ad94b82b434ce636609bc1ed435a2d1132951663bfaa8ebd","src/back/spv/mod.rs":"31b0229f59b5784b57851fcf6325095add58af6de3afa85d518a4e266c4b99a9","src/back/spv/ray.rs":"a34bf6b26d873f7270caa45841d9ef291aca8d9732ecd086b14d8856038e1e41","src/back/spv/recyclable.rs":"114db0ea12774d6514f995d07295cb9a42631ab75165fc60980c10e9b5ecb832","src/back/spv/selection.rs":"81e404abfa0a977f7c1f76ccb37a78d13ccadbda229048dad53cc67687cc39db","src/back/spv/writer.rs":"a76a73c0692162da24ab5508bc3ca70eb5e01367fe54472d100e237dbd594467","src/back/wgsl/mod.rs":"2dd12bbea9ace835850192bb68c5760953da6bac6a636073d1eca19381c0c0b6","src/back/wgsl/writer.rs":"15ba0e1ab7358b725d1cbc2e0b0b2284c33cc240ae84b20e186519efbb5d96d9","src/block.rs":"c69089e5bbb6de6ba24efb15b21d5d434fcabfbc4d48feae948d2a4da135aae7","src/compact/expressions.rs":"7a4c916282a5b484519ed29ab451c7b595d8dea73c83c5c2cf7efc6fbc648fda","src/compact/functions.rs":"174bd9167ecf6353afb8c36d365ba3f9b483233eb4bacf578e50183c7433aa15","src/compact/handle_set_map.rs":"817c5193352d5fd6a61a5c970daba23224e14a65aea15f8f1c8679c99f834ca2","src/compact/mod.rs":"8abea7a8a9870d953fb628a32bac2bc15e87e077910cb95aa1f26e58a0a35c2a","src/compact/statements.rs":"4df33ee9589300e769e75c674bdc30578e93704ec3eb2aabc7132121745b55c8","src/compact/types.rs":"18343f2ca2c123eea2531cffc1d54a7798797caccecaa1f9b8c4fd5dd6ca1a05","src/front/glsl/ast.rs":"2ae292c09fed43951e20ec6ce0b7b99efe91726cf90487d6c129137b08618e01","src/front/glsl/builtins.rs":"d35501d5b42b61c261da24436b82eafdf96371b1600d148648d90d041f736ae4","src/front/glsl/context.rs":"2f07a63209258a8459ae6a6ef8277313c4dc771ab96ef6f5ab3a383a0d3599ba","src/front/glsl/error.rs":"08409f8cc13b73c6eda938ff7ebf2b46e9d27c66d718d640ad8d6a33fddbb7a1","src/front/glsl/functions.rs":"60838c34b8295112e5696b52d710acebb93e0a982e05f8eb87d3b80f52eb7793","src/front/glsl/lex.rs":"08736ae8beb955da5b0e6e3e0f45995a824995f7096d516a2910417e9c7afa32","src/front/glsl/mod.rs":"c8e435a894d641e6c92fcd7d357d51e1136af1a69410fbaedb88c7262b2269df","src/front/glsl/offset.rs":"9358602ca4f9ef21d5066d674dae757bf88fdf5c289c4360534354d13bd41dc0","src/front/glsl/parser.rs":"fe5291512db412b33b6c09d5b3dcf7c54ff6ec55b47f0a078dcc11695e78471d","src/front/glsl/parser/declarations.rs":"d637cc52e553910a2e97b70b3366c15aefbe737f413adb11c27efd184c1fbf9d","src/front/glsl/parser/expressions.rs":"520cfc9402d5fbd48e52ef1d36562c6b74794c09ec33ec1ebb10aa48d129b66f","src/front/glsl/parser/functions.rs":"670ca6bba5a56f3919968658966b05ba824c2d76427b8927d4b111f715091629","src/front/glsl/parser/types.rs":"0971bc98cbde1d70c0ced1717c8726a12a5bfafa9a72b127ed242db5435ec8a8","src/front/glsl/parser_tests.rs":"fc2120fff132af850b52f9ac5d19f0c2fce7997b17ba49881b155d173359cfd3","src/front/glsl/token.rs":"fbfa7dd1b90e10ec92ffb994fa4eea7bd8a309feec6372cacbacbd92900c3336","src/front/glsl/types.rs":"58c9cf3d570dff8cb68f2931faf5b18e875e510741bf035ec10b9ff6df27c5d8","src/front/glsl/variables.rs":"fb2a09e386b6e98ca9fb8fb744afac1e8b19d1b67c6ede5c474e3ba860d3d4cb","src/front/interpolator.rs":"9b6ca498d5fbd9bc1515510a04e303a00b324121d7285da3c955cfe18eb4224c","src/front/mod.rs":"6f77ca3ff925cc16e5ae46132bd6196ca4c9c80a7db123f0d2ec09aae93ba51f","src/front/spv/convert.rs":"9b4ecc53131b6250cde4cae93557eb467127e9e8d0536d29a851538684ae5371","src/front/spv/error.rs":"3129fd1fe346441d61d0f641734df7e919919db15df706788d16402ebf480607","src/front/spv/function.rs":"3a3f0c07862750f79f8ebc273c5df11efc67272566458410f776bd8fa271a0f8","src/front/spv/image.rs":"5d55cfbf6752732a594114cd09a9a207216e1ee85d8f2c9bc4310217a55ea321","src/front/spv/mod.rs":"ccbeb4b80959c00323b2459e316b7c5c7e3f313ab94f2151fa44a2dee6255d4e","src/front/spv/null.rs":"e1446d99d04c76a9c3bbd24dd9b20c4711ce8a918a9b403be6cccbde1175b3b4","src/front/type_gen.rs":"b4f1df23380e06c9fdad4140810ce96ab041dbb1d371a07045b4e0069aa8ba55","src/front/wgsl/error.rs":"dfe96023d82afaa028644568ac550a3ccef053c9f2a6d787d5f14db59a4c7c65","src/front/wgsl/index.rs":"2b9a4929a46bd822d3ed6f9a150e24d437e5bdca8293eb748aebe80ce7e74153","src/front/wgsl/lower/construction.rs":"db15eadf96157ac741eb46d73380df8e326c84402fa49196e8d5a8b52579a626","src/front/wgsl/lower/conversion.rs":"961b19bf8ddd4667c6caf854a1889f3d6477757f4125538c3e9ca7d730975dd7","src/front/wgsl/lower/mod.rs":"3c05236144dda95de54460820aa6586437c5344ee170a083b4fb1085cde24711","src/front/wgsl/mod.rs":"02b194a0a29ef7281f71b424564e18ada4a8b1a0d8c26ec40b6be195bd4c4904","src/front/wgsl/parse/ast.rs":"c7eaae40179f0889f2b142d3b31968cbfab6d3cfe02e425912c6da8dadac51df","src/front/wgsl/parse/conv.rs":"01b25edbe80b263a3fa51bc980c075630bb31d4af851441323383eb4f3b83360","src/front/wgsl/parse/lexer.rs":"17db87d0017f8f9a80fa151b8545f04e1b40c4e5feef6197f4a117efa03488bf","src/front/wgsl/parse/mod.rs":"3b4895a2baf91c719b95f0afb6441ffac2036c2a9ff817e633882fd257afcc38","src/front/wgsl/parse/number.rs":"43b2a03963e61ee047eeac144ab817bf9f9e9a9517b26b68ff40f2f6236de05d","src/front/wgsl/tests.rs":"39d0b44d0f073a7599c88b7c4efd1572886f3af074fa2015454623be313b297f","src/front/wgsl/to_wgsl.rs":"2e2e30d86b07f209b866e530d3a882803bf28b39ce379052561a749f628e8e28","src/keywords/mod.rs":"0138f3931f8af0b0a05174549d0fd2152945b027dc3febefc1bbd676581d2e45","src/keywords/wgsl.rs":"7c3b364b60ca29cb8a68ef781de9ecd28b76b74bed18bf18a35d2ebffaa855ab","src/lib.rs":"c5d91c603ae310a7ef9ff8444898959a3dbbc32ba262cabb1fd5682823921d98","src/proc/constant_evaluator.rs":"112563dea58b1f2dc32644f71931c667bfbf3e5131ce4f7040d6d162c20ab951","src/proc/emitter.rs":"39ac886c651e2ad33c06a676a7e4826a0e93de0af660c01e8e4b1f7406742f88","src/proc/index.rs":"f4250f6944c2b631e8140979024e8deb86fa8d5352d8641ba954a388b2c0940e","src/proc/layouter.rs":"b3d061c87424f36981c902716f37ab7b72f2bb2d0c2d7e900c51149318ea1a0a","src/proc/mod.rs":"221472328c410213fe9e794a1d2336af3798cc0e9f2cd027c754ea29f251cbfc","src/proc/namer.rs":"7328fac41e40890c64c7ee2fa985a4395424f18b08d30f30ca2583fdabd2fd35","src/proc/terminator.rs":"13c59bf00f5b26171d971effc421091f5e00dedddd246c2daa44fe65aeda060a","src/proc/typifier.rs":"99de19270d01c12ec49d14323aa1d9b8774f1ee715804af7235deff70739ba3d","src/span.rs":"6560599f20b8bc2de746ee9fd6b05c32bb630af914fce8845d84fdc72f9a636c","src/valid/analyzer.rs":"8472b98f16a4a4a0fa7079197db25696f77ef3e1602a7cddea1930daebd27917","src/valid/compose.rs":"83e4c09c39f853cf085b83b87e48b3db571da619132960d3ec954ebdfb0a74f2","src/valid/expression.rs":"1cdbd594dbdb33d8473d93c11112cf717e262bb8c35cee10b01db4322b2237d7","src/valid/function.rs":"5ec31146aacf7daae689836ff3e2978f075f2cc62b3fd829d09c760a6e606501","src/valid/handles.rs":"0878915e67b16d7c41cf8245d9ab3b3f4a604e7d4e87527ea40e03efcbf1f74a","src/valid/interface.rs":"6ddf5f8d5150342d2e8c754a71c92c85d8533fd1d4c6b7a83a05b508e8e8114d","src/valid/mod.rs":"9e2bafa06bea16db2c5a8f825eed4d008c474b87cda2fc7e82ca7a21229c6f20","src/valid/type.rs":"09e18bb9510dbb0cfb4a8ac054afee4c4f56063d614159ab5b956aa1e5850468"},"package":null} \ No newline at end of file diff --git a/third_party/rust/naga/Cargo.toml b/third_party/rust/naga/Cargo.toml index 456573e070a4f..046386ce594d2 100644 --- a/third_party/rust/naga/Cargo.toml +++ b/third_party/rust/naga/Cargo.toml @@ -13,7 +13,7 @@ edition = "2021" rust-version = "1.65" name = "naga" -version = "0.14.0" +version = "0.14.2" authors = ["gfx-rs developers"] exclude = [ "bin/**/*", @@ -51,7 +51,7 @@ bitflags = "2.2" log = "0.4" num-traits = "0.2" rustc-hash = "1.1.0" -thiserror = "1.0.21" +thiserror = "1.0.52" [dependencies.arbitrary] version = "1.3" diff --git a/third_party/rust/naga/src/back/wgsl/writer.rs b/third_party/rust/naga/src/back/wgsl/writer.rs index 28faaf6690691..c737934f5e3c5 100644 --- a/third_party/rust/naga/src/back/wgsl/writer.rs +++ b/third_party/rust/naga/src/back/wgsl/writer.rs @@ -1087,25 +1087,30 @@ impl Writer { use crate::Expression; match expressions[expr] { - Expression::Literal(literal) => { - match literal { - // Floats are written using `Debug` instead of `Display` because it always appends the - // decimal part even it's zero - crate::Literal::F32(value) => write!(self.out, "{:?}", value)?, - crate::Literal::U32(value) => write!(self.out, "{}u", value)?, - crate::Literal::I32(value) => write!(self.out, "{}i", value)?, - crate::Literal::Bool(value) => write!(self.out, "{}", value)?, - crate::Literal::F64(value) => write!(self.out, "{:?}lf", value)?, - crate::Literal::I64(_) => { - return Err(Error::Custom("unsupported i64 literal".to_string())); - } - crate::Literal::AbstractInt(_) | crate::Literal::AbstractFloat(_) => { - return Err(Error::Custom( - "Abstract types should not appear in IR presented to backends".into(), - )); + Expression::Literal(literal) => match literal { + crate::Literal::F32(value) => write!(self.out, "{}f", value)?, + crate::Literal::U32(value) => write!(self.out, "{}u", value)?, + crate::Literal::I32(value) => { + // `-2147483648i` is not valid WGSL. The most negative `i32` + // value can only be expressed in WGSL using AbstractInt and + // a unary negation operator. + if value == i32::MIN { + write!(self.out, "i32(-2147483648)")?; + } else { + write!(self.out, "{}i", value)?; } } - } + crate::Literal::Bool(value) => write!(self.out, "{}", value)?, + crate::Literal::F64(value) => write!(self.out, "{:?}lf", value)?, + crate::Literal::I64(_) => { + return Err(Error::Custom("unsupported i64 literal".to_string())); + } + crate::Literal::AbstractInt(_) | crate::Literal::AbstractFloat(_) => { + return Err(Error::Custom( + "Abstract types should not appear in IR presented to backends".into(), + )); + } + }, Expression::Constant(handle) => { let constant = &module.constants[handle]; if constant.name.is_some() { diff --git a/third_party/rust/naga/src/front/glsl/token.rs b/third_party/rust/naga/src/front/glsl/token.rs index 74f10cbf85dcd..4c3b5d4a25970 100644 --- a/third_party/rust/naga/src/front/glsl/token.rs +++ b/third_party/rust/naga/src/front/glsl/token.rs @@ -1,4 +1,4 @@ -pub use pp_rs::token::{Float, Integer, Location, PreprocessorError, Token as PPToken}; +pub use pp_rs::token::{Float, Integer, Location, Token as PPToken}; use super::ast::Precision; use crate::{Interpolation, Sampling, Span, Type}; diff --git a/third_party/rust/naga/src/front/wgsl/error.rs b/third_party/rust/naga/src/front/wgsl/error.rs index fffa28817b0f9..5b3657f1f1bdd 100644 --- a/third_party/rust/naga/src/front/wgsl/error.rs +++ b/third_party/rust/naga/src/front/wgsl/error.rs @@ -257,6 +257,12 @@ pub enum Error<'a> { source_span: Span, source_type: String, }, + AutoConversionLeafScalar { + dest_span: Span, + dest_scalar: String, + source_span: Span, + source_type: String, + }, ConcretizationFailed { expr_span: Span, expr_type: String, @@ -738,6 +744,20 @@ impl<'a> Error<'a> { ], notes: vec![], }, + Error::AutoConversionLeafScalar { dest_span, ref dest_scalar, source_span, ref source_type } => ParseError { + message: format!("automatic conversions cannot convert elements of `{source_type}` to `{dest_scalar}`"), + labels: vec![ + ( + dest_span, + format!("a value with elements of type {dest_scalar} is required here").into(), + ), + ( + source_span, + format!("this expression has type {source_type}").into(), + ) + ], + notes: vec![], + }, Error::ConcretizationFailed { expr_span, ref expr_type, ref scalar, ref inner } => ParseError { message: format!("failed to convert expression to a concrete type: {}", inner), labels: vec![ diff --git a/third_party/rust/naga/src/front/wgsl/lower/construction.rs b/third_party/rust/naga/src/front/wgsl/lower/construction.rs index 96cc45bfa53b6..e996e35227f02 100644 --- a/third_party/rust/naga/src/front/wgsl/lower/construction.rs +++ b/third_party/rust/naga/src/front/wgsl/lower/construction.rs @@ -5,7 +5,6 @@ use crate::{Handle, Span}; use crate::front::wgsl::error::Error; use crate::front::wgsl::lower::{ExpressionContext, Lowerer}; -use crate::front::wgsl::Scalar; /// A cooked form of `ast::ConstructorType` that uses Naga types whenever /// possible. @@ -300,7 +299,10 @@ impl<'source, 'temp> Lowerer<'source, 'temp> { }, Constructor::Type((_, &crate::TypeInner::Vector { size, scalar })), ) => { - ctx.convert_slice_to_common_scalar(std::slice::from_mut(&mut component), scalar)?; + ctx.convert_slice_to_common_leaf_scalar( + std::slice::from_mut(&mut component), + scalar, + )?; expr = crate::Expression::Splat { size, value: component, @@ -316,10 +318,11 @@ impl<'source, 'temp> Lowerer<'source, 'temp> { Constructor::PartialVector { size }, ) => { let consensus_scalar = - automatic_conversion_consensus(&components, ctx).map_err(|index| { - Error::InvalidConstructorComponentType(spans[index], index as i32) - })?; - ctx.convert_slice_to_common_scalar(&mut components, consensus_scalar)?; + ctx.automatic_conversion_consensus(&components) + .map_err(|index| { + Error::InvalidConstructorComponentType(spans[index], index as i32) + })?; + ctx.convert_slice_to_common_leaf_scalar(&mut components, consensus_scalar)?; let inner = consensus_scalar.to_inner_vector(size); let ty = ctx.ensure_type_exists(inner); expr = crate::Expression::Compose { ty, components }; @@ -343,14 +346,15 @@ impl<'source, 'temp> Lowerer<'source, 'temp> { Constructor::PartialMatrix { columns, rows }, ) if components.len() == columns as usize * rows as usize => { let consensus_scalar = - automatic_conversion_consensus(&components, ctx).map_err(|index| { - Error::InvalidConstructorComponentType(spans[index], index as i32) - })?; + ctx.automatic_conversion_consensus(&components) + .map_err(|index| { + Error::InvalidConstructorComponentType(spans[index], index as i32) + })?; // We actually only accept floating-point elements. let consensus_scalar = consensus_scalar .automatic_conversion_combine(crate::Scalar::ABSTRACT_FLOAT) .unwrap_or(consensus_scalar); - ctx.convert_slice_to_common_scalar(&mut components, consensus_scalar)?; + ctx.convert_slice_to_common_leaf_scalar(&mut components, consensus_scalar)?; let vec_ty = ctx.ensure_type_exists(consensus_scalar.to_inner_vector(rows)); let components = components @@ -420,10 +424,11 @@ impl<'source, 'temp> Lowerer<'source, 'temp> { Constructor::PartialMatrix { columns, rows }, ) => { let consensus_scalar = - automatic_conversion_consensus(&components, ctx).map_err(|index| { - Error::InvalidConstructorComponentType(spans[index], index as i32) - })?; - ctx.convert_slice_to_common_scalar(&mut components, consensus_scalar)?; + ctx.automatic_conversion_consensus(&components) + .map_err(|index| { + Error::InvalidConstructorComponentType(spans[index], index as i32) + })?; + ctx.convert_slice_to_common_leaf_scalar(&mut components, consensus_scalar)?; let ty = ctx.ensure_type_exists(crate::TypeInner::Matrix { columns, rows, @@ -456,10 +461,10 @@ impl<'source, 'temp> Lowerer<'source, 'temp> { // Array constructor - infer type (components, Constructor::PartialArray) => { let mut components = components.into_components_vec(); - if let Ok(consensus_scalar) = automatic_conversion_consensus(&components, ctx) { + if let Ok(consensus_scalar) = ctx.automatic_conversion_consensus(&components) { // Note that this will *not* necessarily convert all the // components to the same type! The `automatic_conversion_consensus` - // function only considers the parameters' leaf scalar + // method only considers the parameters' leaf scalar // types; the parameters themselves could be any mix of // vectors, matrices, and scalars. // @@ -471,7 +476,7 @@ impl<'source, 'temp> Lowerer<'source, 'temp> { // do. And if this array construction is not well-typed, // these conversions will not make it so, and we can let // validation catch the error. - ctx.convert_slice_to_common_scalar(&mut components, consensus_scalar)?; + ctx.convert_slice_to_common_leaf_scalar(&mut components, consensus_scalar)?; } else { // There's no consensus scalar. Emit the `Compose` // expression anyway, and let validation catch the problem. @@ -609,50 +614,3 @@ impl<'source, 'temp> Lowerer<'source, 'temp> { Ok(handle) } } - -/// Find the consensus scalar of `components` under WGSL's automatic -/// conversions. -/// -/// If `components` can all be converted to any common scalar via -/// WGSL's automatic conversions, return the best such scalar. -/// -/// The `components` slice must not be empty. All elements' types must -/// have been resolved. -/// -/// If `components` are definitely not acceptable as arguments to such -/// constructors, return `Err(i)`, where `i` is the index in -/// `components` of some problematic argument. -/// -/// This function doesn't fully type-check the arguments - it only -/// considers their leaf scalar types. This means it may return `Ok` -/// even when the Naga validator will reject the resulting -/// construction expression later. -fn automatic_conversion_consensus( - components: &[Handle], - ctx: &ExpressionContext<'_, '_, '_>, -) -> Result { - let types = &ctx.module.types; - let mut inners = components - .iter() - .map(|&c| ctx.typifier()[c].inner_with(types)); - log::debug!( - "wgsl automatic_conversion_consensus: {:?}", - inners - .clone() - .map(|inner| inner.to_wgsl(&ctx.module.to_ctx())) - .collect::>() - ); - let mut best = inners.next().unwrap().scalar().ok_or(0_usize)?; - for (inner, i) in inners.zip(1..) { - let scalar = inner.scalar().ok_or(i)?; - match best.automatic_conversion_combine(scalar) { - Some(new_best) => { - best = new_best; - } - None => return Err(i), - } - } - - log::debug!(" consensus: {:?}", best.to_wgsl()); - Ok(best) -} diff --git a/third_party/rust/naga/src/front/wgsl/lower/conversion.rs b/third_party/rust/naga/src/front/wgsl/lower/conversion.rs index 01acf8b9d3b07..2a2690f096a57 100644 --- a/third_party/rust/naga/src/front/wgsl/lower/conversion.rs +++ b/third_party/rust/naga/src/front/wgsl/lower/conversion.rs @@ -51,21 +51,80 @@ impl<'source, 'temp, 'out> super::ExpressionContext<'source, 'temp, 'out> { } }; - let converted = if let crate::TypeInner::Array { .. } = *goal_inner { - let span = self.get_expression_span(expr); + self.convert_leaf_scalar(expr, expr_span, goal_scalar) + } + + /// Try to convert `expr`'s leaf scalar to `goal` using automatic conversions. + /// + /// If no conversions are necessary, return `expr` unchanged. + /// + /// If automatic conversions cannot convert `expr` to `goal_scalar`, return + /// an [`AutoConversionLeafScalar`] error. + /// + /// Although the Load Rule is one of the automatic conversions, this + /// function assumes it has already been applied if appropriate, as + /// indicated by the fact that the Rust type of `expr` is not `Typed<_>`. + /// + /// [`AutoConversionLeafScalar`]: super::Error::AutoConversionLeafScalar + pub fn try_automatic_conversion_for_leaf_scalar( + &mut self, + expr: Handle, + goal_scalar: crate::Scalar, + goal_span: Span, + ) -> Result, super::Error<'source>> { + let expr_span = self.get_expression_span(expr); + let expr_resolution = super::resolve!(self, expr); + let types = &self.module.types; + let expr_inner = expr_resolution.inner_with(types); + + let make_error = || { + let gctx = &self.module.to_ctx(); + let source_type = expr_resolution.to_wgsl(gctx); + super::Error::AutoConversionLeafScalar { + dest_span: goal_span, + dest_scalar: goal_scalar.to_wgsl(), + source_span: expr_span, + source_type, + } + }; + + let expr_scalar = match expr_inner.scalar() { + Some(scalar) => scalar, + None => return Err(make_error()), + }; + + if expr_scalar == goal_scalar { + return Ok(expr); + } + + if !expr_scalar.automatically_converts_to(goal_scalar) { + return Err(make_error()); + } + + assert!(expr_scalar.is_abstract()); + + self.convert_leaf_scalar(expr, expr_span, goal_scalar) + } + + fn convert_leaf_scalar( + &mut self, + expr: Handle, + expr_span: Span, + goal_scalar: crate::Scalar, + ) -> Result, super::Error<'source>> { + let expr_inner = super::resolve_inner!(self, expr); + if let crate::TypeInner::Array { .. } = *expr_inner { self.as_const_evaluator() - .cast_array(expr, goal_scalar, span) - .map_err(|err| super::Error::ConstantEvaluatorError(err, span))? + .cast_array(expr, goal_scalar, expr_span) + .map_err(|err| super::Error::ConstantEvaluatorError(err, expr_span)) } else { let cast = crate::Expression::As { expr, kind: goal_scalar.kind, convert: Some(goal_scalar.width), }; - self.append_expression(cast, expr_span)? - }; - - Ok(converted) + self.append_expression(cast, expr_span) + } } /// Try to convert `exprs` to `goal_ty` using WGSL's automatic conversions. @@ -130,6 +189,28 @@ impl<'source, 'temp, 'out> super::ExpressionContext<'source, 'temp, 'out> { Ok(()) } + /// Convert `expr` to the leaf scalar type `scalar`. + pub fn convert_to_leaf_scalar( + &mut self, + expr: &mut Handle, + goal: crate::Scalar, + ) -> Result<(), super::Error<'source>> { + let inner = super::resolve_inner!(self, *expr); + // Do nothing if `inner` doesn't even have leaf scalars; + // it's a type error that validation will catch. + if inner.scalar() != Some(goal) { + let cast = crate::Expression::As { + expr: *expr, + kind: goal.kind, + convert: Some(goal.width), + }; + let expr_span = self.get_expression_span(*expr); + *expr = self.append_expression(cast, expr_span)?; + } + + Ok(()) + } + /// Convert all expressions in `exprs` to a common scalar type. /// /// Note that the caller is responsible for making sure these @@ -140,24 +221,13 @@ impl<'source, 'temp, 'out> super::ExpressionContext<'source, 'temp, 'out> { /// themselves whether the casts we we generate are justified, /// perhaps by calling `TypeInner::automatically_converts_to` or /// `Scalar::automatic_conversion_combine`. - pub fn convert_slice_to_common_scalar( + pub fn convert_slice_to_common_leaf_scalar( &mut self, exprs: &mut [Handle], goal: crate::Scalar, ) -> Result<(), super::Error<'source>> { for expr in exprs.iter_mut() { - let inner = super::resolve_inner!(self, *expr); - // Do nothing if `inner` doesn't even have leaf scalars; - // it's a type error that validation will catch. - if inner.scalar() != Some(goal) { - let cast = crate::Expression::As { - expr: *expr, - kind: goal.kind, - convert: Some(goal.width), - }; - let expr_span = self.get_expression_span(*expr); - *expr = self.append_expression(cast, expr_span)?; - } + self.convert_to_leaf_scalar(expr, goal)?; } Ok(()) @@ -196,6 +266,57 @@ impl<'source, 'temp, 'out> super::ExpressionContext<'source, 'temp, 'out> { Ok(expr) } + + /// Find the consensus scalar of `components` under WGSL's automatic + /// conversions. + /// + /// If `components` can all be converted to any common scalar via + /// WGSL's automatic conversions, return the best such scalar. + /// + /// The `components` slice must not be empty. All elements' types must + /// have been resolved. + /// + /// If `components` are definitely not acceptable as arguments to such + /// constructors, return `Err(i)`, where `i` is the index in + /// `components` of some problematic argument. + /// + /// This function doesn't fully type-check the arguments - it only + /// considers their leaf scalar types. This means it may return `Ok` + /// even when the Naga validator will reject the resulting + /// construction expression later. + pub fn automatic_conversion_consensus<'handle, I>( + &self, + components: I, + ) -> Result + where + I: IntoIterator>, + I::IntoIter: Clone, // for debugging + { + let types = &self.module.types; + let mut inners = components + .into_iter() + .map(|&c| self.typifier()[c].inner_with(types)); + log::debug!( + "wgsl automatic_conversion_consensus: {:?}", + inners + .clone() + .map(|inner| inner.to_wgsl(&self.module.to_ctx())) + .collect::>() + ); + let mut best = inners.next().unwrap().scalar().ok_or(0_usize)?; + for (inner, i) in inners.zip(1..) { + let scalar = inner.scalar().ok_or(i)?; + match best.automatic_conversion_combine(scalar) { + Some(new_best) => { + best = new_best; + } + None => return Err(i), + } + } + + log::debug!(" consensus: {:?}", best.to_wgsl()); + Ok(best) + } } impl crate::TypeInner { @@ -366,6 +487,11 @@ impl crate::Scalar { } } + /// Return `true` if automatic conversions will covert `self` to `goal`. + pub fn automatically_converts_to(self, goal: Self) -> bool { + self.automatic_conversion_combine(goal) == Some(goal) + } + const fn concretize(self) -> Self { use crate::ScalarKind as Sk; match self.kind { diff --git a/third_party/rust/naga/src/front/wgsl/lower/mod.rs b/third_party/rust/naga/src/front/wgsl/lower/mod.rs index 6486e6cf6b4e9..c38c57267abf9 100644 --- a/third_party/rust/naga/src/front/wgsl/lower/mod.rs +++ b/third_party/rust/naga/src/front/wgsl/lower/mod.rs @@ -1574,7 +1574,7 @@ impl<'source, 'temp> Lowerer<'source, 'temp> { return Ok(Typed::Plain(handle)); } ast::Expression::Unary { op, expr } => { - let expr = self.expression(expr, ctx)?; + let expr = self.expression_for_abstract(expr, ctx)?; Typed::Plain(crate::Expression::Unary { op, expr }) } ast::Expression::AddrOf(expr) => { @@ -1602,11 +1602,7 @@ impl<'source, 'temp> Lowerer<'source, 'temp> { return Ok(Typed::Reference(pointer)); } ast::Expression::Binary { op, left, right } => { - // Load both operands. - let mut left = self.expression(left, ctx)?; - let mut right = self.expression(right, ctx)?; - ctx.binary_op_splat(op, &mut left, &mut right)?; - Typed::Plain(crate::Expression::Binary { op, left, right }) + self.binary(op, left, right, span, ctx)? } ast::Expression::Call { ref function, @@ -1737,6 +1733,52 @@ impl<'source, 'temp> Lowerer<'source, 'temp> { expr.try_map(|handle| ctx.append_expression(handle, span)) } + fn binary( + &mut self, + op: crate::BinaryOperator, + left: Handle>, + right: Handle>, + span: Span, + ctx: &mut ExpressionContext<'source, '_, '_>, + ) -> Result, Error<'source>> { + // Load both operands. + let mut left = self.expression_for_abstract(left, ctx)?; + let mut right = self.expression_for_abstract(right, ctx)?; + + // Convert `scalar op vector` to `vector op vector` by introducing + // `Splat` expressions. + ctx.binary_op_splat(op, &mut left, &mut right)?; + + // Apply automatic conversions. + match op { + // Shift operators require the right operand to be `u32` or + // `vecN`. We can let the validator sort out vector length + // issues, but the right operand must be, or convert to, a u32 leaf + // scalar. + crate::BinaryOperator::ShiftLeft | crate::BinaryOperator::ShiftRight => { + right = + ctx.try_automatic_conversion_for_leaf_scalar(right, crate::Scalar::U32, span)?; + } + + // All other operators follow the same pattern: reconcile the + // scalar leaf types. If there's no reconciliation possible, + // leave the expressions as they are: validation will report the + // problem. + _ => { + ctx.grow_types(left)?; + ctx.grow_types(right)?; + if let Ok(consensus_scalar) = + ctx.automatic_conversion_consensus([left, right].iter()) + { + ctx.convert_to_leaf_scalar(&mut left, consensus_scalar)?; + ctx.convert_to_leaf_scalar(&mut right, consensus_scalar)?; + } + } + } + + Ok(Typed::Plain(crate::Expression::Binary { op, left, right })) + } + /// Generate Naga IR for call expressions and statements, and type /// constructor expressions. /// diff --git a/third_party/rust/naga/src/front/wgsl/parse/lexer.rs b/third_party/rust/naga/src/front/wgsl/parse/lexer.rs index 9fa9416f111c3..d03a448561a26 100644 --- a/third_party/rust/naga/src/front/wgsl/parse/lexer.rs +++ b/third_party/rust/naga/src/front/wgsl/parse/lexer.rs @@ -117,7 +117,6 @@ fn consume_token(input: &str, generic: bool) -> (Token<'_>, &str) { let og_chars = chars.as_str(); match chars.next() { Some('>') => (Token::Arrow, chars.as_str()), - Some('0'..='9' | '.') => consume_number(input), Some('-') => (Token::DecrementOperation, chars.as_str()), Some('=') => (Token::AssignmentOperation(cur), chars.as_str()), _ => (Token::Operation(cur), og_chars), @@ -496,44 +495,60 @@ fn test_numbers() { // MIN / MAX // - // min / max decimal signed integer + // min / max decimal integer sub_test( - "-2147483648i 2147483647i -2147483649i 2147483648i", + "0i 2147483647i 2147483648i", &[ - Token::Number(Ok(Number::I32(i32::MIN))), + Token::Number(Ok(Number::I32(0))), Token::Number(Ok(Number::I32(i32::MAX))), Token::Number(Err(NumberError::NotRepresentable)), - Token::Number(Err(NumberError::NotRepresentable)), ], ); // min / max decimal unsigned integer sub_test( - "0u 4294967295u -1u 4294967296u", + "0u 4294967295u 4294967296u", &[ Token::Number(Ok(Number::U32(u32::MIN))), Token::Number(Ok(Number::U32(u32::MAX))), Token::Number(Err(NumberError::NotRepresentable)), - Token::Number(Err(NumberError::NotRepresentable)), ], ); // min / max hexadecimal signed integer sub_test( - "-0x80000000i 0x7FFFFFFFi -0x80000001i 0x80000000i", + "0x0i 0x7FFFFFFFi 0x80000000i", &[ - Token::Number(Ok(Number::I32(i32::MIN))), + Token::Number(Ok(Number::I32(0))), Token::Number(Ok(Number::I32(i32::MAX))), Token::Number(Err(NumberError::NotRepresentable)), - Token::Number(Err(NumberError::NotRepresentable)), ], ); // min / max hexadecimal unsigned integer sub_test( - "0x0u 0xFFFFFFFFu -0x1u 0x100000000u", + "0x0u 0xFFFFFFFFu 0x100000000u", &[ Token::Number(Ok(Number::U32(u32::MIN))), Token::Number(Ok(Number::U32(u32::MAX))), Token::Number(Err(NumberError::NotRepresentable)), + ], + ); + + // min/max decimal abstract int + sub_test( + "0 9223372036854775807 9223372036854775808", + &[ + Token::Number(Ok(Number::AbstractInt(0))), + Token::Number(Ok(Number::AbstractInt(i64::MAX))), + Token::Number(Err(NumberError::NotRepresentable)), + ], + ); + + // min/max hexadecimal abstract int + sub_test( + "0 0x7fffffffffffffff 0x8000000000000000", + &[ + Token::Number(Ok(Number::AbstractInt(0))), + Token::Number(Ok(Number::AbstractInt(i64::MAX))), Token::Number(Err(NumberError::NotRepresentable)), ], ); @@ -548,77 +563,43 @@ fn test_numbers() { const LARGEST_F32_LESS_THAN_ONE: f32 = 0.99999994; /// ≈ 1 + 2^−23 const SMALLEST_F32_LARGER_THAN_ONE: f32 = 1.0000001; - /// ≈ -(2^127 * (2 − 2^−23)) - const SMALLEST_NORMAL_F32: f32 = f32::MIN; /// ≈ 2^127 * (2 − 2^−23) const LARGEST_NORMAL_F32: f32 = f32::MAX; // decimal floating point sub_test( - "1e-45f 1.1754942e-38f 1.17549435e-38f 0.99999994f 1.0000001f -3.40282347e+38f 3.40282347e+38f", + "1e-45f 1.1754942e-38f 1.17549435e-38f 0.99999994f 1.0000001f 3.40282347e+38f", &[ - Token::Number(Ok(Number::F32( - SMALLEST_POSITIVE_SUBNORMAL_F32, - ))), - Token::Number(Ok(Number::F32( - LARGEST_SUBNORMAL_F32, - ))), - Token::Number(Ok(Number::F32( - SMALLEST_POSITIVE_NORMAL_F32, - ))), - Token::Number(Ok(Number::F32( - LARGEST_F32_LESS_THAN_ONE, - ))), - Token::Number(Ok(Number::F32( - SMALLEST_F32_LARGER_THAN_ONE, - ))), - Token::Number(Ok(Number::F32( - SMALLEST_NORMAL_F32, - ))), - Token::Number(Ok(Number::F32( - LARGEST_NORMAL_F32, - ))), + Token::Number(Ok(Number::F32(SMALLEST_POSITIVE_SUBNORMAL_F32))), + Token::Number(Ok(Number::F32(LARGEST_SUBNORMAL_F32))), + Token::Number(Ok(Number::F32(SMALLEST_POSITIVE_NORMAL_F32))), + Token::Number(Ok(Number::F32(LARGEST_F32_LESS_THAN_ONE))), + Token::Number(Ok(Number::F32(SMALLEST_F32_LARGER_THAN_ONE))), + Token::Number(Ok(Number::F32(LARGEST_NORMAL_F32))), ], ); sub_test( - "-3.40282367e+38f 3.40282367e+38f", + "3.40282367e+38f", &[ - Token::Number(Err(NumberError::NotRepresentable)), // ≈ -2^128 Token::Number(Err(NumberError::NotRepresentable)), // ≈ 2^128 ], ); // hexadecimal floating point sub_test( - "0x1p-149f 0x7FFFFFp-149f 0x1p-126f 0xFFFFFFp-24f 0x800001p-23f -0xFFFFFFp+104f 0xFFFFFFp+104f", + "0x1p-149f 0x7FFFFFp-149f 0x1p-126f 0xFFFFFFp-24f 0x800001p-23f 0xFFFFFFp+104f", &[ - Token::Number(Ok(Number::F32( - SMALLEST_POSITIVE_SUBNORMAL_F32, - ))), - Token::Number(Ok(Number::F32( - LARGEST_SUBNORMAL_F32, - ))), - Token::Number(Ok(Number::F32( - SMALLEST_POSITIVE_NORMAL_F32, - ))), - Token::Number(Ok(Number::F32( - LARGEST_F32_LESS_THAN_ONE, - ))), - Token::Number(Ok(Number::F32( - SMALLEST_F32_LARGER_THAN_ONE, - ))), - Token::Number(Ok(Number::F32( - SMALLEST_NORMAL_F32, - ))), - Token::Number(Ok(Number::F32( - LARGEST_NORMAL_F32, - ))), + Token::Number(Ok(Number::F32(SMALLEST_POSITIVE_SUBNORMAL_F32))), + Token::Number(Ok(Number::F32(LARGEST_SUBNORMAL_F32))), + Token::Number(Ok(Number::F32(SMALLEST_POSITIVE_NORMAL_F32))), + Token::Number(Ok(Number::F32(LARGEST_F32_LESS_THAN_ONE))), + Token::Number(Ok(Number::F32(SMALLEST_F32_LARGER_THAN_ONE))), + Token::Number(Ok(Number::F32(LARGEST_NORMAL_F32))), ], ); sub_test( - "-0x1p128f 0x1p128f 0x1.000001p0f", + "0x1p128f 0x1.000001p0f", &[ - Token::Number(Err(NumberError::NotRepresentable)), // = -2^128 Token::Number(Err(NumberError::NotRepresentable)), // = 2^128 Token::Number(Err(NumberError::NotRepresentable)), ], diff --git a/third_party/rust/naga/src/front/wgsl/parse/number.rs b/third_party/rust/naga/src/front/wgsl/parse/number.rs index fde5e3cee6d47..7b09ac59bbc8b 100644 --- a/third_party/rust/naga/src/front/wgsl/parse/number.rs +++ b/third_party/rust/naga/src/front/wgsl/parse/number.rs @@ -1,5 +1,3 @@ -use std::borrow::Cow; - use crate::front::wgsl::error::NumberError; use crate::front::wgsl::parse::lexer::Token; @@ -20,8 +18,6 @@ pub enum Number { F64(f64), } -// TODO: when implementing Creation-Time Expressions, remove the ability to match the minus sign - pub(in crate::front::wgsl) fn consume_number(input: &str) -> (Token<'_>, &str) { let (result, rest) = parse(input); (Token::Number(result), rest) @@ -64,7 +60,9 @@ enum FloatKind { // | / 0[xX][0-9a-fA-F]+ [pP][+-]?[0-9]+ [fh]? / // You could visualize the regex below via https://debuggex.com to get a rough idea what `parse` is doing -// -?(?:0[xX](?:([0-9a-fA-F]+\.[0-9a-fA-F]*|[0-9a-fA-F]*\.[0-9a-fA-F]+)(?:([pP][+-]?[0-9]+)([fh]?))?|([0-9a-fA-F]+)([pP][+-]?[0-9]+)([fh]?)|([0-9a-fA-F]+)([iu]?))|((?:[0-9]+[eE][+-]?[0-9]+|(?:[0-9]+\.[0-9]*|[0-9]*\.[0-9]+)(?:[eE][+-]?[0-9]+)?))([fh]?)|((?:[0-9]|[1-9][0-9]+))([iufh]?)) +// (?:0[xX](?:([0-9a-fA-F]+\.[0-9a-fA-F]*|[0-9a-fA-F]*\.[0-9a-fA-F]+)(?:([pP][+-]?[0-9]+)([fh]?))?|([0-9a-fA-F]+)([pP][+-]?[0-9]+)([fh]?)|([0-9a-fA-F]+)([iu]?))|((?:[0-9]+[eE][+-]?[0-9]+|(?:[0-9]+\.[0-9]*|[0-9]*\.[0-9]+)(?:[eE][+-]?[0-9]+)?))([fh]?)|((?:[0-9]|[1-9][0-9]+))([iufh]?)) + +// Leading signs are handled as unary operators. fn parse(input: &str) -> (Result, &str) { /// returns `true` and consumes `X` bytes from the given byte buffer @@ -152,8 +150,6 @@ fn parse(input: &str) -> (Result, &str) { let general_extract = ExtractSubStr::start(input, bytes); - let is_negative = consume!(bytes, b'-'); - if consume!(bytes, b'0', b'x' | b'X') { let digits_extract = ExtractSubStr::start(input, bytes); @@ -216,10 +212,7 @@ fn parse(input: &str) -> (Result, &str) { } else { let kind = consume_map!(bytes, [b'i' => IntKind::I32, b'u' => IntKind::U32]); - ( - parse_hex_int(is_negative, digits, kind), - rest_to_str!(bytes), - ) + (parse_hex_int(digits, kind), rest_to_str!(bytes)) } } } else { @@ -272,7 +265,7 @@ fn parse(input: &str) -> (Result, &str) { return (Err(NumberError::Invalid), rest_to_str!(bytes)); } - let digits_with_sign = general_extract.end(bytes); + let digits = general_extract.end(bytes); let kind = consume_map!(bytes, [ b'i' => Kind::Int(IntKind::I32), @@ -282,17 +275,14 @@ fn parse(input: &str) -> (Result, &str) { b'l', b'f' => Kind::Float(FloatKind::F64), ]); - ( - parse_dec(is_negative, digits_with_sign, kind), - rest_to_str!(bytes), - ) + (parse_dec(digits, kind), rest_to_str!(bytes)) } } } } fn parse_hex_float_missing_exponent( - // format: -?0[xX] ( [0-9a-fA-F]+\.[0-9a-fA-F]* | [0-9a-fA-F]*\.[0-9a-fA-F]+ ) + // format: 0[xX] ( [0-9a-fA-F]+\.[0-9a-fA-F]* | [0-9a-fA-F]*\.[0-9a-fA-F]+ ) significand: &str, kind: Option, ) -> Result { @@ -301,7 +291,7 @@ fn parse_hex_float_missing_exponent( } fn parse_hex_float_missing_period( - // format: -?0[xX] [0-9a-fA-F]+ + // format: 0[xX] [0-9a-fA-F]+ significand: &str, // format: [pP][+-]?[0-9]+ exponent: &str, @@ -312,29 +302,22 @@ fn parse_hex_float_missing_period( } fn parse_hex_int( - is_negative: bool, // format: [0-9a-fA-F]+ digits: &str, kind: Option, ) -> Result { - let digits_with_sign = if is_negative { - Cow::Owned(format!("-{digits}")) - } else { - Cow::Borrowed(digits) - }; - parse_int(&digits_with_sign, kind, 16, is_negative) + parse_int(digits, kind, 16) } fn parse_dec( - is_negative: bool, - // format: -? ( [0-9] | [1-9][0-9]+ ) - digits_with_sign: &str, + // format: ( [0-9] | [1-9][0-9]+ ) + digits: &str, kind: Option, ) -> Result { match kind { - None => parse_int(digits_with_sign, None, 10, is_negative), - Some(Kind::Int(kind)) => parse_int(digits_with_sign, Some(kind), 10, is_negative), - Some(Kind::Float(kind)) => parse_dec_float(digits_with_sign, Some(kind)), + None => parse_int(digits, None, 10), + Some(Kind::Int(kind)) => parse_int(digits, Some(kind), 10), + Some(Kind::Float(kind)) => parse_dec_float(digits, Some(kind)), } } @@ -363,7 +346,7 @@ fn parse_dec( // Therefore we only check for overflow manually for decimal floating point literals -// input format: -?0[xX] ( [0-9a-fA-F]+\.[0-9a-fA-F]* | [0-9a-fA-F]*\.[0-9a-fA-F]+ ) [pP][+-]?[0-9]+ +// input format: 0[xX] ( [0-9a-fA-F]+\.[0-9a-fA-F]* | [0-9a-fA-F]*\.[0-9a-fA-F]+ ) [pP][+-]?[0-9]+ fn parse_hex_float(input: &str, kind: Option) -> Result { match kind { None => match hexf_parse::parse_hexf64(input, false) { @@ -385,8 +368,8 @@ fn parse_hex_float(input: &str, kind: Option) -> Result) -> Result { match kind { None => { @@ -411,12 +394,7 @@ fn parse_dec_float(input: &str, kind: Option) -> Result, - radix: u32, - is_negative: bool, -) -> Result { +fn parse_int(input: &str, kind: Option, radix: u32) -> Result { fn map_err(e: core::num::ParseIntError) -> NumberError { match *e.kind() { core::num::IntErrorKind::PosOverflow | core::num::IntErrorKind::NegOverflow => { @@ -434,7 +412,6 @@ fn parse_int( Ok(num) => Ok(Number::I32(num)), Err(e) => Err(map_err(e)), }, - Some(IntKind::U32) if is_negative => Err(NumberError::NotRepresentable), Some(IntKind::U32) => match u32::from_str_radix(input, radix) { Ok(num) => Ok(Number::U32(num)), Err(e) => Err(map_err(e)), diff --git a/third_party/rust/naga/src/proc/constant_evaluator.rs b/third_party/rust/naga/src/proc/constant_evaluator.rs index 5c71bc167db02..82efeece4e476 100644 --- a/third_party/rust/naga/src/proc/constant_evaluator.rs +++ b/third_party/rust/naga/src/proc/constant_evaluator.rs @@ -141,7 +141,7 @@ pub enum ConstantEvaluatorError { InvalidAccessIndexTy, #[error("Constants don't support array length expressions")] ArrayLength, - #[error("Cannot cast type `{from}` to `{to}`")] + #[error("Cannot cast scalar components of expression `{from}` to type `{to}`")] InvalidCastArg { from: String, to: String }, #[error("Cannot apply the unary op to the argument")] InvalidUnaryOpArg, @@ -989,15 +989,11 @@ impl<'a> ConstantEvaluator<'a> { let expr = self.eval_zero_value(expr, span)?; let make_error = || -> Result<_, ConstantEvaluatorError> { - let ty = self.resolve_type(expr)?; + let from = format!("{:?} {:?}", expr, self.expressions[expr]); - #[cfg(feature = "wgsl-in")] - let from = ty.to_wgsl(&self.to_ctx()); #[cfg(feature = "wgsl-in")] let to = target.to_wgsl(); - #[cfg(not(feature = "wgsl-in"))] - let from = format!("{ty:?}"); #[cfg(not(feature = "wgsl-in"))] let to = format!("{target:?}"); @@ -1195,8 +1191,10 @@ impl<'a> ConstantEvaluator<'a> { let expr = match self.expressions[expr] { Expression::Literal(value) => Expression::Literal(match op { UnaryOperator::Negate => match value { - Literal::I32(v) => Literal::I32(-v), + Literal::I32(v) => Literal::I32(v.wrapping_neg()), Literal::F32(v) => Literal::F32(-v), + Literal::AbstractInt(v) => Literal::AbstractInt(v.wrapping_neg()), + Literal::AbstractFloat(v) => Literal::AbstractFloat(-v), _ => return Err(ConstantEvaluatorError::InvalidUnaryOpArg), }, UnaryOperator::LogicalNot => match value { @@ -1206,6 +1204,7 @@ impl<'a> ConstantEvaluator<'a> { UnaryOperator::BitwiseNot => match value { Literal::I32(v) => Literal::I32(!v), Literal::U32(v) => Literal::U32(!v), + Literal::AbstractInt(v) => Literal::AbstractInt(!v), _ => return Err(ConstantEvaluatorError::InvalidUnaryOpArg), }, }), @@ -1325,6 +1324,47 @@ impl<'a> ConstantEvaluator<'a> { BinaryOperator::Modulo => a % b, _ => return Err(ConstantEvaluatorError::InvalidBinaryOpArgs), }), + (Literal::AbstractInt(a), Literal::AbstractInt(b)) => { + Literal::AbstractInt(match op { + BinaryOperator::Add => a.checked_add(b).ok_or_else(|| { + ConstantEvaluatorError::Overflow("addition".into()) + })?, + BinaryOperator::Subtract => a.checked_sub(b).ok_or_else(|| { + ConstantEvaluatorError::Overflow("subtraction".into()) + })?, + BinaryOperator::Multiply => a.checked_mul(b).ok_or_else(|| { + ConstantEvaluatorError::Overflow("multiplication".into()) + })?, + BinaryOperator::Divide => a.checked_div(b).ok_or_else(|| { + if b == 0 { + ConstantEvaluatorError::DivisionByZero + } else { + ConstantEvaluatorError::Overflow("division".into()) + } + })?, + BinaryOperator::Modulo => a.checked_rem(b).ok_or_else(|| { + if b == 0 { + ConstantEvaluatorError::RemainderByZero + } else { + ConstantEvaluatorError::Overflow("remainder".into()) + } + })?, + BinaryOperator::And => a & b, + BinaryOperator::ExclusiveOr => a ^ b, + BinaryOperator::InclusiveOr => a | b, + _ => return Err(ConstantEvaluatorError::InvalidBinaryOpArgs), + }) + } + (Literal::AbstractFloat(a), Literal::AbstractFloat(b)) => { + Literal::AbstractFloat(match op { + BinaryOperator::Add => a + b, + BinaryOperator::Subtract => a - b, + BinaryOperator::Multiply => a * b, + BinaryOperator::Divide => a / b, + BinaryOperator::Modulo => a % b, + _ => return Err(ConstantEvaluatorError::InvalidBinaryOpArgs), + }) + } (Literal::Bool(a), Literal::Bool(b)) => Literal::Bool(match op { BinaryOperator::LogicalAnd => a && b, BinaryOperator::LogicalOr => a || b, @@ -1550,7 +1590,10 @@ impl<'a> ConstantEvaluator<'a> { }; Tr::Value(TypeInner::Vector { scalar, size }) } - _ => return Err(ConstantEvaluatorError::SubexpressionsAreNotConstant), + _ => { + log::debug!("resolve_type: SubexpressionsAreNotConstant"); + return Err(ConstantEvaluatorError::SubexpressionsAreNotConstant); + } }; Ok(resolution) diff --git a/third_party/rust/proc-macro2/.cargo-checksum.json b/third_party/rust/proc-macro2/.cargo-checksum.json index 9d2b5e1f25165..4182e024667db 100644 --- a/third_party/rust/proc-macro2/.cargo-checksum.json +++ b/third_party/rust/proc-macro2/.cargo-checksum.json @@ -1 +1 @@ -{"files":{"Cargo.toml":"01a9ffc0f14fe891a6a75927a22429879d06ea732b24ab1229838e6c827d9630","LICENSE-APACHE":"62c7a1e35f56406896d7aa7ca52d0cc0d272ac022b5d2796e7d6905db8a3636a","LICENSE-MIT":"23f18e03dc49df91622fe2a76176497404e46ced8a715d9d2b67a7446571cca3","README.md":"c609b6865476d6c35879784e9155367a97a0da496aa5c3c61488440a20f59883","build.rs":"6b0b19a3af5248513b186b9c28c133f5af34a1d11122c0268c68e89724aa40fa","rust-toolchain.toml":"6bbb61302978c736b2da03e4fb40e3beab908f85d533ab46fd541e637b5f3e0f","src/detection.rs":"ed9a5f9a979ab01247d7a68eeb1afa3c13209334c5bfff0f9289cb07e5bb4e8b","src/extra.rs":"d378a9e799e5c49933b067cd38f5364d16a152ef337eef86ce42fdc86005ddf3","src/fallback.rs":"11b005c95258ad50362bcaa9b778aab15a8d49a0c434cd2b42afff98416ae1fe","src/lib.rs":"99a6acbddbe01cd906ac243a3db52a28b9fbb2bdc5f238f992d15fb0cebdbcdc","src/location.rs":"f55d2e61f1bb1af65e14ed04c9e91eb1ddbf8430e8c05f2048d1cd538d27368e","src/marker.rs":"43f5a18f5059f1a16507c047b3b7387afee7f25ac45ba4eb1621ca7fa733eb01","src/parse.rs":"6ceaad0a6375af9a202cf8df6ebe72e1bce9543b1f0db71ea03929ac02c3a8b8","src/rcvec.rs":"1c3c48c4f819927cc445ae15ca3bb06775feff2fd1cb21901ae4c40c7e6b4e82","src/wrapper.rs":"06624150b94f4fd9ada30b2c9ad6936ea695d05c2138ceb14f2304e757133d52","tests/comments.rs":"31115b3a56c83d93eef2fb4c9566bf4543e302560732986161b98aef504785ed","tests/features.rs":"a86deb8644992a4eb64d9fd493eff16f9cf9c5cb6ade3a634ce0c990cf87d559","tests/marker.rs":"3190ee07dae510251f360db701ce257030f94a479b6689c3a9ef804bd5d8d099","tests/test.rs":"7511be57e097b15403cf36feb858b4aabdc832fac7024571059a559a7e2ed2a0","tests/test_fmt.rs":"b7743b612af65f2c88cbe109d50a093db7aa7e87f9e37bf45b7bbaeb240aa020","tests/test_size.rs":"acf05963c1e62052d769d237b50844a2c59b4182b491231b099a4f74e5456ab0"},"package":"134c189feb4956b20f6f547d2cf727d4c0fe06722b20a0eec87ed445a97f92da"} \ No newline at end of file +{"files":{"Cargo.toml":"2b572df7ca3583e05948248eecbef46d434271598e2e7f688c846fcbe803e8ac","LICENSE-APACHE":"62c7a1e35f56406896d7aa7ca52d0cc0d272ac022b5d2796e7d6905db8a3636a","LICENSE-MIT":"23f18e03dc49df91622fe2a76176497404e46ced8a715d9d2b67a7446571cca3","README.md":"c609b6865476d6c35879784e9155367a97a0da496aa5c3c61488440a20f59883","build.rs":"8b4facae0d125ca3b437b4f5ebcd6ea3da3fcc65fcfc2cf357ae544423aa4568","build/probe.rs":"827da142d033f027d9f2a52ffdc0a619c7c34a2a280635e38c64fcd46cf7b635","rust-toolchain.toml":"6bbb61302978c736b2da03e4fb40e3beab908f85d533ab46fd541e637b5f3e0f","src/detection.rs":"ed9a5f9a979ab01247d7a68eeb1afa3c13209334c5bfff0f9289cb07e5bb4e8b","src/extra.rs":"d378a9e799e5c49933b067cd38f5364d16a152ef337eef86ce42fdc86005ddf3","src/fallback.rs":"df10a5ac00a2bbc0d4a9b9fce33578727c7d24eb2ac8d13c8350ef7897a6175c","src/lib.rs":"8a5f92addc5d4af4b372118ec0fa9bb0202ec7d32e4a8223a7e2e0b628ea0908","src/location.rs":"f55d2e61f1bb1af65e14ed04c9e91eb1ddbf8430e8c05f2048d1cd538d27368e","src/marker.rs":"43f5a18f5059f1a16507c047b3b7387afee7f25ac45ba4eb1621ca7fa733eb01","src/parse.rs":"4b77cddbc2752bc4d38a65acd8b96b6786c5220d19b1e1b37810257b5d24132d","src/rcvec.rs":"1c3c48c4f819927cc445ae15ca3bb06775feff2fd1cb21901ae4c40c7e6b4e82","src/wrapper.rs":"9c22b5001a262700f74ea1f9f9f33a309622ba155d74d8f4e954013eede6212a","tests/comments.rs":"31115b3a56c83d93eef2fb4c9566bf4543e302560732986161b98aef504785ed","tests/features.rs":"a86deb8644992a4eb64d9fd493eff16f9cf9c5cb6ade3a634ce0c990cf87d559","tests/marker.rs":"3190ee07dae510251f360db701ce257030f94a479b6689c3a9ef804bd5d8d099","tests/test.rs":"7511be57e097b15403cf36feb858b4aabdc832fac7024571059a559a7e2ed2a0","tests/test_fmt.rs":"b7743b612af65f2c88cbe109d50a093db7aa7e87f9e37bf45b7bbaeb240aa020","tests/test_size.rs":"acf05963c1e62052d769d237b50844a2c59b4182b491231b099a4f74e5456ab0"},"package":"2de98502f212cfcea8d0bb305bd0f49d7ebdd75b64ba0a68f937d888f4e0d6db"} \ No newline at end of file diff --git a/third_party/rust/proc-macro2/Cargo.toml b/third_party/rust/proc-macro2/Cargo.toml index 6f4ed46ff6dd7..0cd2ef9e5d1ca 100644 --- a/third_party/rust/proc-macro2/Cargo.toml +++ b/third_party/rust/proc-macro2/Cargo.toml @@ -13,7 +13,7 @@ edition = "2021" rust-version = "1.56" name = "proc-macro2" -version = "1.0.69" +version = "1.0.74" authors = [ "David Tolnay ", "Alex Crichton ", diff --git a/third_party/rust/proc-macro2/build.rs b/third_party/rust/proc-macro2/build.rs index 9f0fb51e61bba..3347f878ac30f 100644 --- a/third_party/rust/proc-macro2/build.rs +++ b/third_party/rust/proc-macro2/build.rs @@ -35,17 +35,14 @@ // 1.57+. use std::env; -use std::process::Command; +use std::ffi::OsString; +use std::path::Path; +use std::process::{self, Command, Stdio}; use std::str; use std::u32; fn main() { - println!("cargo:rerun-if-changed=build.rs"); - - let version = rustc_version().unwrap_or(RustcVersion { - minor: u32::MAX, - nightly: false, - }); + let rustc = rustc_minor_version().unwrap_or(u32::MAX); let docs_rs = env::var_os("DOCS_RS").is_some(); let semver_exempt = cfg!(procmacro2_semver_exempt) || docs_rs; @@ -58,76 +55,148 @@ fn main() { println!("cargo:rustc-cfg=span_locations"); } - if version.minor < 57 { + if rustc < 57 { println!("cargo:rustc-cfg=no_is_available"); } - if version.minor < 66 { + if rustc < 66 { println!("cargo:rustc-cfg=no_source_text"); } if !cfg!(feature = "proc-macro") { + println!("cargo:rerun-if-changed=build.rs"); return; } - if version.nightly || !semver_exempt { + println!("cargo:rerun-if-changed=build/probe.rs"); + + let proc_macro_span; + let consider_rustc_bootstrap; + if compile_probe(false) { + // This is a nightly or dev compiler, so it supports unstable features + // regardless of RUSTC_BOOTSTRAP. No need to rerun build script if + // RUSTC_BOOTSTRAP is changed. + proc_macro_span = true; + consider_rustc_bootstrap = false; + } else if let Some(rustc_bootstrap) = env::var_os("RUSTC_BOOTSTRAP") { + if compile_probe(true) { + // This is a stable or beta compiler for which the user has set + // RUSTC_BOOTSTRAP to turn on unstable features. Rerun build script + // if they change it. + proc_macro_span = true; + consider_rustc_bootstrap = true; + } else if rustc_bootstrap == "1" { + // This compiler does not support the proc macro Span API in the + // form that proc-macro2 expects. No need to pay attention to + // RUSTC_BOOTSTRAP. + proc_macro_span = false; + consider_rustc_bootstrap = false; + } else { + // This is a stable or beta compiler for which RUSTC_BOOTSTRAP is + // set to restrict the use of unstable features by this crate. + proc_macro_span = false; + consider_rustc_bootstrap = true; + } + } else { + // Without RUSTC_BOOTSTRAP, this compiler does not support the proc + // macro Span API in the form that proc-macro2 expects, but try again if + // the user turns on unstable features. + proc_macro_span = false; + consider_rustc_bootstrap = true; + } + + if proc_macro_span || !semver_exempt { println!("cargo:rustc-cfg=wrap_proc_macro"); } - if version.nightly && feature_allowed("proc_macro_span") { + if proc_macro_span { println!("cargo:rustc-cfg=proc_macro_span"); } - if semver_exempt && version.nightly { + if semver_exempt && proc_macro_span { println!("cargo:rustc-cfg=super_unstable"); } + + if consider_rustc_bootstrap { + println!("cargo:rerun-if-env-changed=RUSTC_BOOTSTRAP"); + } } -struct RustcVersion { - minor: u32, - nightly: bool, +fn compile_probe(rustc_bootstrap: bool) -> bool { + if env::var_os("RUSTC_STAGE").is_some() { + // We are running inside rustc bootstrap. This is a highly non-standard + // environment with issues such as: + // + // https://github.com/rust-lang/cargo/issues/11138 + // https://github.com/rust-lang/rust/issues/114839 + // + // Let's just not use nightly features here. + return false; + } + + let rustc = cargo_env_var("RUSTC"); + let out_dir = cargo_env_var("OUT_DIR"); + let probefile = Path::new("build").join("probe.rs"); + + // Make sure to pick up Cargo rustc configuration. + let mut cmd = if let Some(wrapper) = env::var_os("RUSTC_WRAPPER") { + let mut cmd = Command::new(wrapper); + // The wrapper's first argument is supposed to be the path to rustc. + cmd.arg(rustc); + cmd + } else { + Command::new(rustc) + }; + + if !rustc_bootstrap { + cmd.env_remove("RUSTC_BOOTSTRAP"); + } + + cmd.stderr(Stdio::null()) + .arg("--edition=2021") + .arg("--crate-name=proc_macro2") + .arg("--crate-type=lib") + .arg("--emit=dep-info,metadata") + .arg("--out-dir") + .arg(out_dir) + .arg(probefile); + + if let Some(target) = env::var_os("TARGET") { + cmd.arg("--target").arg(target); + } + + // If Cargo wants to set RUSTFLAGS, use that. + if let Ok(rustflags) = env::var("CARGO_ENCODED_RUSTFLAGS") { + if !rustflags.is_empty() { + for arg in rustflags.split('\x1f') { + cmd.arg(arg); + } + } + } + + match cmd.status() { + Ok(status) => status.success(), + Err(_) => false, + } } -fn rustc_version() -> Option { - let rustc = env::var_os("RUSTC")?; +fn rustc_minor_version() -> Option { + let rustc = cargo_env_var("RUSTC"); let output = Command::new(rustc).arg("--version").output().ok()?; let version = str::from_utf8(&output.stdout).ok()?; - let nightly = version.contains("nightly") || version.contains("dev"); let mut pieces = version.split('.'); if pieces.next() != Some("rustc 1") { return None; } - let minor = pieces.next()?.parse().ok()?; - Some(RustcVersion { minor, nightly }) + pieces.next()?.parse().ok() } -fn feature_allowed(feature: &str) -> bool { - // Recognized formats: - // - // -Z allow-features=feature1,feature2 - // - // -Zallow-features=feature1,feature2 - - let flags_var; - let flags_var_string; - let flags = if let Some(encoded_rustflags) = env::var_os("CARGO_ENCODED_RUSTFLAGS") { - flags_var = encoded_rustflags; - flags_var_string = flags_var.to_string_lossy(); - flags_var_string.split('\x1f') - } else { - return true; - }; - - for mut flag in flags { - if flag.starts_with("-Z") { - flag = &flag["-Z".len()..]; - } - if flag.starts_with("allow-features=") { - flag = &flag["allow-features=".len()..]; - return flag.split(',').any(|allowed| allowed == feature); - } - } - - // No allow-features= flag, allowed by default. - true +fn cargo_env_var(key: &str) -> OsString { + env::var_os(key).unwrap_or_else(|| { + eprintln!( + "Environment variable ${} is not set during execution of build script", + key, + ); + process::exit(1); + }) } diff --git a/third_party/rust/proc-macro2/build/probe.rs b/third_party/rust/proc-macro2/build/probe.rs new file mode 100644 index 0000000000000..5afa13a125b1a --- /dev/null +++ b/third_party/rust/proc-macro2/build/probe.rs @@ -0,0 +1,21 @@ +// This code exercises the surface area that we expect of Span's unstable API. +// If the current toolchain is able to compile it, then proc-macro2 is able to +// offer these APIs too. + +#![feature(proc_macro_span)] + +extern crate proc_macro; + +use core::ops::RangeBounds; +use proc_macro::{Literal, Span}; + +pub fn join(this: &Span, other: Span) -> Option { + this.join(other) +} + +pub fn subspan>(this: &Literal, range: R) -> Option { + this.subspan(range) +} + +// Include in sccache cache key. +const _: Option<&str> = option_env!("RUSTC_BOOTSTRAP"); diff --git a/third_party/rust/proc-macro2/src/fallback.rs b/third_party/rust/proc-macro2/src/fallback.rs index 7f559cfbc4d18..55773bcc0e391 100644 --- a/third_party/rust/proc-macro2/src/fallback.rs +++ b/third_party/rust/proc-macro2/src/fallback.rs @@ -347,7 +347,7 @@ impl FileInfo { fn offset_line_column(&self, offset: usize) -> LineColumn { assert!(self.span_within(Span { lo: offset as u32, - hi: offset as u32 + hi: offset as u32, })); let offset = offset - self.span.lo as usize; match self.lines.binary_search(&offset) { @@ -755,22 +755,32 @@ pub(crate) struct Ident { } impl Ident { - fn _new(string: &str, raw: bool, span: Span) -> Self { - validate_ident(string, raw); + #[track_caller] + pub fn new_checked(string: &str, span: Span) -> Self { + validate_ident(string); + Ident::new_unchecked(string, span) + } + pub fn new_unchecked(string: &str, span: Span) -> Self { Ident { sym: string.to_owned(), span, - raw, + raw: false, } } - pub fn new(string: &str, span: Span) -> Self { - Ident::_new(string, false, span) + #[track_caller] + pub fn new_raw_checked(string: &str, span: Span) -> Self { + validate_ident_raw(string); + Ident::new_raw_unchecked(string, span) } - pub fn new_raw(string: &str, span: Span) -> Self { - Ident::_new(string, true, span) + pub fn new_raw_unchecked(string: &str, span: Span) -> Self { + Ident { + sym: string.to_owned(), + span, + raw: true, + } } pub fn span(&self) -> Span { @@ -790,7 +800,8 @@ pub(crate) fn is_ident_continue(c: char) -> bool { unicode_ident::is_xid_continue(c) } -fn validate_ident(string: &str, raw: bool) { +#[track_caller] +fn validate_ident(string: &str) { if string.is_empty() { panic!("Ident is not allowed to be empty; use Option"); } @@ -816,14 +827,17 @@ fn validate_ident(string: &str, raw: bool) { if !ident_ok(string) { panic!("{:?} is not a valid Ident", string); } +} - if raw { - match string { - "_" | "super" | "self" | "Self" | "crate" => { - panic!("`r#{}` cannot be a raw identifier", string); - } - _ => {} +#[track_caller] +fn validate_ident_raw(string: &str) { + validate_ident(string); + + match string { + "_" | "super" | "self" | "Self" | "crate" => { + panic!("`r#{}` cannot be a raw identifier", string); } + _ => {} } } diff --git a/third_party/rust/proc-macro2/src/lib.rs b/third_party/rust/proc-macro2/src/lib.rs index 56d986b4f9d51..643ffdcb2c03e 100644 --- a/third_party/rust/proc-macro2/src/lib.rs +++ b/third_party/rust/proc-macro2/src/lib.rs @@ -86,13 +86,15 @@ //! a different thread. // Proc-macro2 types in rustdoc of other crates get linked to here. -#![doc(html_root_url = "https://docs.rs/proc-macro2/1.0.69")] +#![doc(html_root_url = "https://docs.rs/proc-macro2/1.0.74")] #![cfg_attr(any(proc_macro_span, super_unstable), feature(proc_macro_span))] #![cfg_attr(super_unstable, feature(proc_macro_def_site))] #![cfg_attr(doc_cfg, feature(doc_cfg))] +#![deny(unsafe_op_in_unsafe_fn)] #![allow( clippy::cast_lossless, clippy::cast_possible_truncation, + clippy::checked_conversions, clippy::doc_markdown, clippy::items_after_statements, clippy::iter_without_into_iter, @@ -120,6 +122,15 @@ compile_error! {"\ build script as well. "} +#[cfg(all( + procmacro2_nightly_testing, + feature = "proc-macro", + not(proc_macro_span) +))] +compile_error! {"\ + Build script probe failed to compile. +"} + extern crate alloc; #[cfg(feature = "proc-macro")] @@ -160,6 +171,7 @@ use std::error::Error; use std::path::PathBuf; #[cfg(span_locations)] +#[cfg_attr(doc_cfg, doc(cfg(feature = "span-locations")))] pub use crate::location::LineColumn; /// An abstract stream of tokens, or more concretely a sequence of token trees. @@ -949,8 +961,9 @@ impl Ident { /// style="padding-right:0;">syn::parse_str::<Ident> /// rather than `Ident::new`. + #[track_caller] pub fn new(string: &str, span: Span) -> Self { - Ident::_new(imp::Ident::new(string, span.inner)) + Ident::_new(imp::Ident::new_checked(string, span.inner)) } /// Same as `Ident::new`, but creates a raw identifier (`r#ident`). The @@ -958,12 +971,9 @@ impl Ident { /// (including keywords, e.g. `fn`). Keywords which are usable in path /// segments (e.g. `self`, `super`) are not supported, and will cause a /// panic. + #[track_caller] pub fn new_raw(string: &str, span: Span) -> Self { - Ident::_new_raw(string, span) - } - - fn _new_raw(string: &str, span: Span) -> Self { - Ident::_new(imp::Ident::new_raw(string, span.inner)) + Ident::_new(imp::Ident::new_raw_checked(string, span.inner)) } /// Returns the span of this `Ident`. @@ -1240,7 +1250,7 @@ impl Literal { // representation. This is not public API other than for quote. #[doc(hidden)] pub unsafe fn from_str_unchecked(repr: &str) -> Self { - Literal::_new(imp::Literal::from_str_unchecked(repr)) + Literal::_new(unsafe { imp::Literal::from_str_unchecked(repr) }) } } diff --git a/third_party/rust/proc-macro2/src/parse.rs b/third_party/rust/proc-macro2/src/parse.rs index 1430d736e96f0..07239bc3adf54 100644 --- a/third_party/rust/proc-macro2/src/parse.rs +++ b/third_party/rust/proc-macro2/src/parse.rs @@ -1,5 +1,5 @@ use crate::fallback::{ - is_ident_continue, is_ident_start, Group, LexError, Literal, Span, TokenStream, + self, is_ident_continue, is_ident_start, Group, LexError, Literal, Span, TokenStream, TokenStreamBuilder, }; use crate::{Delimiter, Punct, Spacing, TokenTree}; @@ -300,7 +300,10 @@ fn ident_any(input: Cursor) -> PResult { let (rest, sym) = ident_not_raw(rest)?; if !raw { - let ident = crate::Ident::new(sym, crate::Span::call_site()); + let ident = crate::Ident::_new(crate::imp::Ident::new_unchecked( + sym, + fallback::Span::call_site(), + )); return Ok((rest, ident)); } @@ -309,7 +312,10 @@ fn ident_any(input: Cursor) -> PResult { _ => {} } - let ident = crate::Ident::_new_raw(sym, crate::Span::call_site()); + let ident = crate::Ident::_new(crate::imp::Ident::new_raw_unchecked( + sym, + fallback::Span::call_site(), + )); Ok((rest, ident)) } @@ -908,12 +914,13 @@ fn doc_comment<'a>(input: Cursor<'a>, trees: &mut TokenStreamBuilder) -> PResult #[cfg(span_locations)] let lo = input.off; let (rest, (comment, inner)) = doc_comment_contents(input)?; - let span = crate::Span::_new_fallback(Span { + let fallback_span = Span { #[cfg(span_locations)] lo, #[cfg(span_locations)] hi: rest.off, - }); + }; + let span = crate::Span::_new_fallback(fallback_span); let mut scan_for_bare_cr = comment; while let Some(cr) = scan_for_bare_cr.find('\r') { @@ -934,7 +941,7 @@ fn doc_comment<'a>(input: Cursor<'a>, trees: &mut TokenStreamBuilder) -> PResult trees.push_token_from_parser(TokenTree::Punct(bang)); } - let doc_ident = crate::Ident::new("doc", span); + let doc_ident = crate::Ident::_new(crate::imp::Ident::new_unchecked("doc", fallback_span)); let mut equal = Punct::new('=', Spacing::Alone); equal.set_span(span); let mut literal = crate::Literal::string(comment); diff --git a/third_party/rust/proc-macro2/src/wrapper.rs b/third_party/rust/proc-macro2/src/wrapper.rs index 860b6b7758685..a5d49b5e7e325 100644 --- a/third_party/rust/proc-macro2/src/wrapper.rs +++ b/third_party/rust/proc-macro2/src/wrapper.rs @@ -639,20 +639,30 @@ pub(crate) enum Ident { } impl Ident { - pub fn new(string: &str, span: Span) -> Self { + #[track_caller] + pub fn new_checked(string: &str, span: Span) -> Self { match span { Span::Compiler(s) => Ident::Compiler(proc_macro::Ident::new(string, s)), - Span::Fallback(s) => Ident::Fallback(fallback::Ident::new(string, s)), + Span::Fallback(s) => Ident::Fallback(fallback::Ident::new_checked(string, s)), } } - pub fn new_raw(string: &str, span: Span) -> Self { + pub fn new_unchecked(string: &str, span: fallback::Span) -> Self { + Ident::Fallback(fallback::Ident::new_unchecked(string, span)) + } + + #[track_caller] + pub fn new_raw_checked(string: &str, span: Span) -> Self { match span { Span::Compiler(s) => Ident::Compiler(proc_macro::Ident::new_raw(string, s)), - Span::Fallback(s) => Ident::Fallback(fallback::Ident::new_raw(string, s)), + Span::Fallback(s) => Ident::Fallback(fallback::Ident::new_raw_checked(string, s)), } } + pub fn new_raw_unchecked(string: &str, span: fallback::Span) -> Self { + Ident::Fallback(fallback::Ident::new_raw_unchecked(string, span)) + } + pub fn span(&self) -> Span { match self { Ident::Compiler(t) => Span::Compiler(t.span()), @@ -752,7 +762,7 @@ impl Literal { if inside_proc_macro() { Literal::Compiler(proc_macro::Literal::from_str(repr).expect("invalid literal")) } else { - Literal::Fallback(fallback::Literal::from_str_unchecked(repr)) + Literal::Fallback(unsafe { fallback::Literal::from_str_unchecked(repr) }) } } diff --git a/third_party/rust/quote/.cargo-checksum.json b/third_party/rust/quote/.cargo-checksum.json index 13798a979c658..0d900a272d563 100644 --- a/third_party/rust/quote/.cargo-checksum.json +++ b/third_party/rust/quote/.cargo-checksum.json @@ -1 +1 @@ -{"files":{"Cargo.toml":"04fa432ffe813738cb59dc66248022406bbff02ad50a6ec5445e0cfa89e7c5cb","LICENSE-APACHE":"62c7a1e35f56406896d7aa7ca52d0cc0d272ac022b5d2796e7d6905db8a3636a","LICENSE-MIT":"23f18e03dc49df91622fe2a76176497404e46ced8a715d9d2b67a7446571cca3","README.md":"15d3ee300a69f4eec5f81b74fce4652fa22ce84d44413379bc756e4aaca23300","build.rs":"3733c86ae2733629f873f93c2f45da30164beee8de9ee0833099fac6a05a3e6b","rust-toolchain.toml":"6bbb61302978c736b2da03e4fb40e3beab908f85d533ab46fd541e637b5f3e0f","src/ext.rs":"9881576cac3e476a4bf04f9b601cf9a53b79399fb0ca9634e8b861ac91709843","src/format.rs":"c595015418f35e6992e710441b9999f09b2afe4678b138039d670d100c0bdd86","src/ident_fragment.rs":"6b3b6621cd20bae776d2455f2b05f04433d8ce617c113e83a3683edef0667d1f","src/lib.rs":"71df353876cc945acc3e8cabfb640c1c691601dfb8aeb0470fb1b8556a2abaea","src/runtime.rs":"31b2159986c68dc1c78801a92f795435dbc0bcea859ca342df280889e82c6c4d","src/spanned.rs":"0ccaae1137af5f3e54eae75c3bdc637be74cfa56a857f2c0f85a041c9ba26838","src/to_tokens.rs":"99bb6f467289c32af6c1f7af0d45cc6ac7b31e2436774e616770152a49e6ac0f","tests/compiletest.rs":"022a8e400ef813d7ea1875b944549cee5125f6a995dc33e93b48cba3e1b57bd1","tests/test.rs":"3be80741f84a707376c230d9cf70ce9537caa359691d8d4c34968e28175e4ad7","tests/ui/does-not-have-iter-interpolated-dup.rs":"ad13eea21d4cdd2ab6c082f633392e1ff20fb0d1af5f2177041e0bf7f30da695","tests/ui/does-not-have-iter-interpolated-dup.stderr":"90a4bdb9267535f5d2785940148338d6b7d905548051d2c9c5dcbd58f2c11d8e","tests/ui/does-not-have-iter-interpolated.rs":"83a5b3f240651adcbe4b6e51076d76d653ad439b37442cf4054f1fd3c073f3b7","tests/ui/does-not-have-iter-interpolated.stderr":"ae7c2739554c862b331705e82781aa4687a4375210cef6ae899a4be4a4ec2d97","tests/ui/does-not-have-iter-separated.rs":"fe413c48331d5e3a7ae5fef6a5892a90c72f610d54595879eb49d0a94154ba3f","tests/ui/does-not-have-iter-separated.stderr":"03fd560979ebcd5aa6f83858bc2c3c01ba6546c16335101275505304895c1ae9","tests/ui/does-not-have-iter.rs":"09dc9499d861b63cebb0848b855b78e2dc9497bfde37ba6339f3625ae009a62f","tests/ui/does-not-have-iter.stderr":"d6da483c29e232ced72059bbdf05d31afb1df9e02954edaa9cfaea1ec6df72dc","tests/ui/not-quotable.rs":"5759d0884943417609f28faadc70254a3e2fd3d9bd6ff7297a3fb70a77fafd8a","tests/ui/not-quotable.stderr":"efcace9419fdf64d6beca7e135c3b7daff74038d4449475896cbe8cbf2566ade","tests/ui/not-repeatable.rs":"a4b115c04e4e41049a05f5b69450503fbffeba031218b4189cb931839f7f9a9c","tests/ui/not-repeatable.stderr":"594249d59d16f039c16816f1aaf9933176994e296fcf81d1b8b24d5b66ae0d0a","tests/ui/wrong-type-span.rs":"6195e35ea844c0c52ba1cff5d790c3a371af6915d137d377834ad984229ef9ea","tests/ui/wrong-type-span.stderr":"cad072e40e0ecc04f375122ae41aede2f0da2a9244492b3fcf70249e59d1b128"},"package":"1b9ab9c7eadfd8df19006f1cf1a4aed13540ed5cbc047010ece5826e10825488"} \ No newline at end of file +{"files":{"Cargo.toml":"0ec1e0fd36354750321a12d04a5e4d9a8d5dc6a8af753183de50da55fc10391b","LICENSE-APACHE":"62c7a1e35f56406896d7aa7ca52d0cc0d272ac022b5d2796e7d6905db8a3636a","LICENSE-MIT":"23f18e03dc49df91622fe2a76176497404e46ced8a715d9d2b67a7446571cca3","README.md":"626e7079eab0baacf0fcaf3e244f407b2014ebaeca45905d72e8fb8bed18aaea","rust-toolchain.toml":"6bbb61302978c736b2da03e4fb40e3beab908f85d533ab46fd541e637b5f3e0f","src/ext.rs":"9881576cac3e476a4bf04f9b601cf9a53b79399fb0ca9634e8b861ac91709843","src/format.rs":"c595015418f35e6992e710441b9999f09b2afe4678b138039d670d100c0bdd86","src/ident_fragment.rs":"0b3e6c2129e55910fd2d240e1e7efba6f1796801d24352d1c0bfbceb0e8b678f","src/lib.rs":"cef1b4c031d401fb87e88a2ed51858c5f8f471e62a6261c1ef0f55ef9e1906a1","src/runtime.rs":"7f37326edaeac2c42ed806b447eeba12e36dd4b1bc25fbf52f8eb23140f3be7a","src/spanned.rs":"3ccf5120593f35787442c0a37d243e802c5262e7f8b35aed503873008ec035c5","src/to_tokens.rs":"1c76311fcc82098e630056d71fd6f3929194ee31b0840e2aa643ed7e78026e3e","tests/compiletest.rs":"022a8e400ef813d7ea1875b944549cee5125f6a995dc33e93b48cba3e1b57bd1","tests/test.rs":"3be80741f84a707376c230d9cf70ce9537caa359691d8d4c34968e28175e4ad7","tests/ui/does-not-have-iter-interpolated-dup.rs":"ad13eea21d4cdd2ab6c082f633392e1ff20fb0d1af5f2177041e0bf7f30da695","tests/ui/does-not-have-iter-interpolated-dup.stderr":"90a4bdb9267535f5d2785940148338d6b7d905548051d2c9c5dcbd58f2c11d8e","tests/ui/does-not-have-iter-interpolated.rs":"83a5b3f240651adcbe4b6e51076d76d653ad439b37442cf4054f1fd3c073f3b7","tests/ui/does-not-have-iter-interpolated.stderr":"ae7c2739554c862b331705e82781aa4687a4375210cef6ae899a4be4a4ec2d97","tests/ui/does-not-have-iter-separated.rs":"fe413c48331d5e3a7ae5fef6a5892a90c72f610d54595879eb49d0a94154ba3f","tests/ui/does-not-have-iter-separated.stderr":"03fd560979ebcd5aa6f83858bc2c3c01ba6546c16335101275505304895c1ae9","tests/ui/does-not-have-iter.rs":"09dc9499d861b63cebb0848b855b78e2dc9497bfde37ba6339f3625ae009a62f","tests/ui/does-not-have-iter.stderr":"d6da483c29e232ced72059bbdf05d31afb1df9e02954edaa9cfaea1ec6df72dc","tests/ui/not-quotable.rs":"5759d0884943417609f28faadc70254a3e2fd3d9bd6ff7297a3fb70a77fafd8a","tests/ui/not-quotable.stderr":"459bdadbf1e73b9401cf7d5d578dc053774bb4e5aa25ad2abf25d6b0f61aa306","tests/ui/not-repeatable.rs":"a4b115c04e4e41049a05f5b69450503fbffeba031218b4189cb931839f7f9a9c","tests/ui/not-repeatable.stderr":"594249d59d16f039c16816f1aaf9933176994e296fcf81d1b8b24d5b66ae0d0a","tests/ui/wrong-type-span.rs":"6195e35ea844c0c52ba1cff5d790c3a371af6915d137d377834ad984229ef9ea","tests/ui/wrong-type-span.stderr":"cad072e40e0ecc04f375122ae41aede2f0da2a9244492b3fcf70249e59d1b128"},"package":"291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef"} \ No newline at end of file diff --git a/third_party/rust/quote/Cargo.toml b/third_party/rust/quote/Cargo.toml index d4afa36424306..f3222c25dbd25 100644 --- a/third_party/rust/quote/Cargo.toml +++ b/third_party/rust/quote/Cargo.toml @@ -11,9 +11,9 @@ [package] edition = "2018" -rust-version = "1.31" +rust-version = "1.56" name = "quote" -version = "1.0.28" +version = "1.0.35" authors = ["David Tolnay "] autobenches = false description = "Quasi-quoting macro quote!(...)" @@ -28,13 +28,14 @@ license = "MIT OR Apache-2.0" repository = "https://github.com/dtolnay/quote" [package.metadata.docs.rs] +rustdoc-args = ["--generate-link-to-definition"] targets = ["x86_64-unknown-linux-gnu"] [lib] doc-scrape-examples = false [dependencies.proc-macro2] -version = "1.0.52" +version = "1.0.74" default-features = false [dev-dependencies.rustversion] diff --git a/third_party/rust/quote/README.md b/third_party/rust/quote/README.md index 4d1a9738127a6..bfc91a9753094 100644 --- a/third_party/rust/quote/README.md +++ b/third_party/rust/quote/README.md @@ -34,7 +34,7 @@ macros. quote = "1.0" ``` -*Version requirement: Quote supports rustc 1.31 and up.*
+*Version requirement: Quote supports rustc 1.56 and up.*
[*Release notes*](https://github.com/dtolnay/quote/releases)
@@ -240,6 +240,18 @@ convenient for a human to read and debug. Be aware that no kind of hygiene or span information is retained when tokens are written to a file; the conversion from tokens to source code is lossy. +Example usage in build.rs: + +```rust +let output = quote! { ... }; +let syntax_tree = syn::parse2(output).unwrap(); +let formatted = prettyplease::unparse(&syntax_tree); + +let out_dir = env::var_os("OUT_DIR").unwrap(); +let dest_path = Path::new(&out_dir).join("out.rs"); +fs::write(dest_path, formatted).unwrap(); +``` + [prettyplease]: https://github.com/dtolnay/prettyplease
diff --git a/third_party/rust/quote/build.rs b/third_party/rust/quote/build.rs deleted file mode 100644 index a7e6b2cdae31e..0000000000000 --- a/third_party/rust/quote/build.rs +++ /dev/null @@ -1,38 +0,0 @@ -use std::env; -use std::process::{self, Command}; -use std::str; - -fn main() { - println!("cargo:rerun-if-changed=build.rs"); - - let version = match rustc_version() { - Some(version) => version, - None => return, - }; - - if version.minor < 31 { - eprintln!("Minimum supported rustc version is 1.31"); - process::exit(1); - } - - if version.minor < 53 { - // https://github.com/rust-lang/rust/issues/43081 - println!("cargo:rustc-cfg=needs_invalid_span_workaround"); - } -} - -struct RustcVersion { - minor: u32, -} - -fn rustc_version() -> Option { - 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()?; - Some(RustcVersion { minor }) -} diff --git a/third_party/rust/quote/src/ident_fragment.rs b/third_party/rust/quote/src/ident_fragment.rs index e7e8a3d9443ae..6c2a9a87acb41 100644 --- a/third_party/rust/quote/src/ident_fragment.rs +++ b/third_party/rust/quote/src/ident_fragment.rs @@ -1,6 +1,6 @@ +use alloc::borrow::Cow; use core::fmt; use proc_macro2::{Ident, Span}; -use std::borrow::Cow; /// Specialized formatting trait used by `format_ident!`. /// @@ -49,8 +49,8 @@ impl IdentFragment for Ident { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { let id = self.to_string(); - if id.starts_with("r#") { - fmt::Display::fmt(&id[2..], f) + if let Some(id) = id.strip_prefix("r#") { + fmt::Display::fmt(id, f) } else { fmt::Display::fmt(&id[..], f) } diff --git a/third_party/rust/quote/src/lib.rs b/third_party/rust/quote/src/lib.rs index 0b5e7d8f6eecd..8b97abd79d568 100644 --- a/third_party/rust/quote/src/lib.rs +++ b/third_party/rust/quote/src/lib.rs @@ -92,7 +92,7 @@ //! [prettyplease]: https://github.com/dtolnay/prettyplease // Quote types in rustdoc of other crates get linked to here. -#![doc(html_root_url = "https://docs.rs/quote/1.0.28")] +#![doc(html_root_url = "https://docs.rs/quote/1.0.35")] #![allow( clippy::doc_markdown, clippy::missing_errors_doc, @@ -102,6 +102,8 @@ clippy::wrong_self_convention, )] +extern crate alloc; + #[cfg(feature = "proc-macro")] extern crate proc_macro; @@ -426,7 +428,7 @@ pub mod spanned; /// appears suffixed as integer literals by interpolating them as [`syn::Index`] /// instead. /// -/// [`syn::Index`]: https://docs.rs/syn/1.0/syn/struct.Index.html +/// [`syn::Index`]: https://docs.rs/syn/2.0/syn/struct.Index.html /// /// ```compile_fail /// let i = 0usize..self.fields.len(); diff --git a/third_party/rust/quote/src/runtime.rs b/third_party/rust/quote/src/runtime.rs index 4e3d4fd03a027..eff044a9578cc 100644 --- a/third_party/rust/quote/src/runtime.rs +++ b/third_party/rust/quote/src/runtime.rs @@ -5,11 +5,21 @@ use core::iter; use core::ops::BitOr; use proc_macro2::{Group, Ident, Punct, Spacing, TokenTree}; +#[doc(hidden)] +pub use alloc::format; +#[doc(hidden)] pub use core::option::Option; -pub use proc_macro2::{Delimiter, Span, TokenStream}; -pub use std::format; +#[doc(hidden)] +pub type Delimiter = proc_macro2::Delimiter; +#[doc(hidden)] +pub type Span = proc_macro2::Span; +#[doc(hidden)] +pub type TokenStream = proc_macro2::TokenStream; + +#[doc(hidden)] pub struct HasIterator; // True +#[doc(hidden)] pub struct ThereIsNoIteratorInRepetition; // False impl BitOr for ThereIsNoIteratorInRepetition { @@ -46,14 +56,16 @@ impl BitOr for HasIterator { /// These traits expose a `quote_into_iter` method which should allow calling /// whichever impl happens to be applicable. Calling that method repeatedly on /// the returned value should be idempotent. +#[doc(hidden)] pub mod ext { use super::RepInterp; use super::{HasIterator as HasIter, ThereIsNoIteratorInRepetition as DoesNotHaveIter}; use crate::ToTokens; + use alloc::collections::btree_set::{self, BTreeSet}; use core::slice; - use std::collections::btree_set::{self, BTreeSet}; /// Extension trait providing the `quote_into_iter` method on iterators. + #[doc(hidden)] pub trait RepIteratorExt: Iterator + Sized { fn quote_into_iter(self) -> (Self, HasIter) { (self, HasIter) @@ -65,6 +77,7 @@ pub mod ext { /// Extension trait providing the `quote_into_iter` method for /// non-iterable types. These types interpolate the same value in each /// iteration of the repetition. + #[doc(hidden)] pub trait RepToTokensExt { /// Pretend to be an iterator for the purposes of `quote_into_iter`. /// This allows repeated calls to `quote_into_iter` to continue @@ -82,6 +95,7 @@ pub mod ext { /// Extension trait providing the `quote_into_iter` method for types that /// can be referenced as an iterator. + #[doc(hidden)] pub trait RepAsIteratorExt<'q> { type Iter: Iterator; @@ -140,6 +154,7 @@ pub mod ext { // Helper type used within interpolations to allow for repeated binding names. // Implements the relevant traits, and exports a dummy `next()` method. #[derive(Copy, Clone)] +#[doc(hidden)] pub struct RepInterp(pub T); impl RepInterp { @@ -166,6 +181,7 @@ impl ToTokens for RepInterp { } } +#[doc(hidden)] #[inline] pub fn get_span(span: T) -> GetSpan { GetSpan(GetSpanInner(GetSpanBase(span))) @@ -222,10 +238,12 @@ mod get_span { } } +#[doc(hidden)] pub fn push_group(tokens: &mut TokenStream, delimiter: Delimiter, inner: TokenStream) { tokens.append(Group::new(delimiter, inner)); } +#[doc(hidden)] pub fn push_group_spanned( tokens: &mut TokenStream, span: Span, @@ -237,11 +255,13 @@ pub fn push_group_spanned( tokens.append(g); } +#[doc(hidden)] pub fn parse(tokens: &mut TokenStream, s: &str) { let s: TokenStream = s.parse().expect("invalid token stream"); tokens.extend(iter::once(s)); } +#[doc(hidden)] pub fn parse_spanned(tokens: &mut TokenStream, span: Span, s: &str) { let s: TokenStream = s.parse().expect("invalid token stream"); tokens.extend(s.into_iter().map(|t| respan_token_tree(t, span))); @@ -264,15 +284,18 @@ fn respan_token_tree(mut token: TokenTree, span: Span) -> TokenTree { token } +#[doc(hidden)] pub fn push_ident(tokens: &mut TokenStream, s: &str) { let span = Span::call_site(); push_ident_spanned(tokens, span, s); } +#[doc(hidden)] pub fn push_ident_spanned(tokens: &mut TokenStream, span: Span, s: &str) { tokens.append(ident_maybe_raw(s, span)); } +#[doc(hidden)] pub fn push_lifetime(tokens: &mut TokenStream, lifetime: &str) { struct Lifetime<'a> { name: &'a str, @@ -303,6 +326,7 @@ pub fn push_lifetime(tokens: &mut TokenStream, lifetime: &str) { }); } +#[doc(hidden)] pub fn push_lifetime_spanned(tokens: &mut TokenStream, span: Span, lifetime: &str) { struct Lifetime<'a> { name: &'a str, @@ -339,9 +363,11 @@ pub fn push_lifetime_spanned(tokens: &mut TokenStream, span: Span, lifetime: &st macro_rules! push_punct { ($name:ident $spanned:ident $char1:tt) => { + #[doc(hidden)] pub fn $name(tokens: &mut TokenStream) { tokens.append(Punct::new($char1, Spacing::Alone)); } + #[doc(hidden)] pub fn $spanned(tokens: &mut TokenStream, span: Span) { let mut punct = Punct::new($char1, Spacing::Alone); punct.set_span(span); @@ -349,10 +375,12 @@ macro_rules! push_punct { } }; ($name:ident $spanned:ident $char1:tt $char2:tt) => { + #[doc(hidden)] pub fn $name(tokens: &mut TokenStream) { tokens.append(Punct::new($char1, Spacing::Joint)); tokens.append(Punct::new($char2, Spacing::Alone)); } + #[doc(hidden)] pub fn $spanned(tokens: &mut TokenStream, span: Span) { let mut punct = Punct::new($char1, Spacing::Joint); punct.set_span(span); @@ -363,11 +391,13 @@ macro_rules! push_punct { } }; ($name:ident $spanned:ident $char1:tt $char2:tt $char3:tt) => { + #[doc(hidden)] pub fn $name(tokens: &mut TokenStream) { tokens.append(Punct::new($char1, Spacing::Joint)); tokens.append(Punct::new($char2, Spacing::Joint)); tokens.append(Punct::new($char3, Spacing::Alone)); } + #[doc(hidden)] pub fn $spanned(tokens: &mut TokenStream, span: Span) { let mut punct = Punct::new($char1, Spacing::Joint); punct.set_span(span); @@ -427,24 +457,27 @@ push_punct!(push_star push_star_spanned '*'); push_punct!(push_sub push_sub_spanned '-'); push_punct!(push_sub_eq push_sub_eq_spanned '-' '='); +#[doc(hidden)] pub fn push_underscore(tokens: &mut TokenStream) { push_underscore_spanned(tokens, Span::call_site()); } +#[doc(hidden)] pub fn push_underscore_spanned(tokens: &mut TokenStream, span: Span) { tokens.append(Ident::new("_", span)); } // Helper method for constructing identifiers from the `format_ident!` macro, // handling `r#` prefixes. +#[doc(hidden)] pub fn mk_ident(id: &str, span: Option) -> Ident { let span = span.unwrap_or_else(Span::call_site); ident_maybe_raw(id, span) } fn ident_maybe_raw(id: &str, span: Span) -> Ident { - if id.starts_with("r#") { - Ident::new_raw(&id[2..], span) + if let Some(id) = id.strip_prefix("r#") { + Ident::new_raw(id, span) } else { Ident::new(id, span) } @@ -457,6 +490,7 @@ fn ident_maybe_raw(id: &str, span: Span) -> Ident { // `Octal`, `LowerHex`, `UpperHex`, and `Binary` to allow for their use within // `format_ident!`. #[derive(Copy, Clone)] +#[doc(hidden)] pub struct IdentFragmentAdapter(pub T); impl IdentFragmentAdapter { diff --git a/third_party/rust/quote/src/spanned.rs b/third_party/rust/quote/src/spanned.rs index efc2e8bce2280..6eba64445d895 100644 --- a/third_party/rust/quote/src/spanned.rs +++ b/third_party/rust/quote/src/spanned.rs @@ -26,20 +26,8 @@ impl Spanned for T { } fn join_spans(tokens: TokenStream) -> Span { - #[cfg(not(needs_invalid_span_workaround))] let mut iter = tokens.into_iter().map(|tt| tt.span()); - #[cfg(needs_invalid_span_workaround)] - let mut iter = tokens.into_iter().filter_map(|tt| { - let span = tt.span(); - let debug = format!("{:?}", span); - if debug.ends_with("bytes(0..0)") { - None - } else { - Some(span) - } - }); - let first = match iter.next() { Some(span) => span, None => return Span::call_site(), diff --git a/third_party/rust/quote/src/to_tokens.rs b/third_party/rust/quote/src/to_tokens.rs index 57487217eeae9..23b6ec2c08025 100644 --- a/third_party/rust/quote/src/to_tokens.rs +++ b/third_party/rust/quote/src/to_tokens.rs @@ -1,8 +1,8 @@ use super::TokenStreamExt; +use alloc::borrow::Cow; +use alloc::rc::Rc; use core::iter; use proc_macro2::{Group, Ident, Literal, Punct, Span, TokenStream, TokenTree}; -use std::borrow::Cow; -use std::rc::Rc; /// Types that can be interpolated inside a `quote!` invocation. /// diff --git a/third_party/rust/quote/tests/ui/not-quotable.stderr b/third_party/rust/quote/tests/ui/not-quotable.stderr index 79d46548d5912..35cb6f2b11902 100644 --- a/third_party/rust/quote/tests/ui/not-quotable.stderr +++ b/third_party/rust/quote/tests/ui/not-quotable.stderr @@ -8,13 +8,13 @@ error[E0277]: the trait bound `Ipv4Addr: ToTokens` is not satisfied | required by a bound introduced by this call | = help: the following other types implement trait `ToTokens`: - &'a T - &'a mut T - Box - Cow<'a, T> - Option - Rc - RepInterp - String - and 23 others + bool + char + isize + i8 + i16 + i32 + i64 + i128 + and $N others = note: this error originates in the macro `quote` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/third_party/rust/syn/.cargo-checksum.json b/third_party/rust/syn/.cargo-checksum.json index ffbe7650089c6..d7fff05ba5f05 100644 --- a/third_party/rust/syn/.cargo-checksum.json +++ b/third_party/rust/syn/.cargo-checksum.json @@ -1 +1 @@ -{"files":{"Cargo.toml":"f47dd3099b90161054b6b694a5e6307429c94e54f04df2683537a0cd1dfb4ee0","LICENSE-APACHE":"62c7a1e35f56406896d7aa7ca52d0cc0d272ac022b5d2796e7d6905db8a3636a","LICENSE-MIT":"23f18e03dc49df91622fe2a76176497404e46ced8a715d9d2b67a7446571cca3","README.md":"f6904878f9082d7d267b6d0d737ef211ff165cfd039a4d45ad88e9861f3e217f","benches/file.rs":"0a0527c78d849148cbb6118b4d36f72da7d4add865ba1a410e0a1be9e8dbfe0e","benches/rust.rs":"c006f01aacf95f61e5d6f4064be4040896a37a9632fb3dcfd9bc2a7ab171741d","src/attr.rs":"bd5ffae18a363162f7d9c12a1b6c1d023070cbf1b060c98ebc38ef79f1de9c67","src/bigint.rs":"0299829b2f7a1a798fe2f7bc1680e4a10f9b6f4a852d09af4da2deab466c4242","src/buffer.rs":"3ef1c3302acc4f9976484fd11c28981a5ff245cf4f3b8b888b7f065c8614881e","src/custom_keyword.rs":"b2e25cbe73d237b459140a38083ee21e4836ea444859b033f400652414630290","src/custom_punctuation.rs":"c2c344c9cdbebc66a5833eb0f9ded817ce9807dbb75b616283b2b60960d1ffb0","src/data.rs":"09ce487d27f7dd79031b390c8344fc6361d64b05064ee25dba1489cf3aa56128","src/derive.rs":"3132e7f064725c7ca43f26daee93ec78037d46a935c6b0758af905cff450c15c","src/discouraged.rs":"482970b03bdee3cbc30c034f644e3293b25387db46300da5d8d8efd97dad8507","src/drops.rs":"013385f1dd95663f1afab41abc1e2eea04181998644828935ca564c74d6462ae","src/error.rs":"8dbb17978f688e12bcce58232f05c0ca9ed9de1fe511440793fb958da2fc93b9","src/export.rs":"b260cc49da1da3489e7755832bc8015cfad79e84f6c74e237f65ae25a2385e56","src/expr.rs":"4260279c392b594e36cee9709f668ebccb9a7be69192e24734341e6b3189374c","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":"305fe1db2b5b7039e79104a6e8ead11b1ee3c009f31f2a2bbebca10e494188cd","src/gen/hash.rs":"4ca8239c681ea5fd7b16bb61bff9034bff09680c088f5a16e90e99013e55742f","src/gen/visit.rs":"cbd0ebe18da62614c66a7900ef67350a5efee261bcdfff6cffc1ea6c4e754e34","src/gen/visit_mut.rs":"1b2a260ab3a6465eed6164f6d2c0cec977f9c3ca912f6bed81f8599b4d8f5cb0","src/gen_helper.rs":"750caab67ba0ba11a95ea28cd38026485227bb4aa114cdb497472386f60fdb35","src/generics.rs":"cb1a0374c523a469d48b1db7316166559034d437fb4f6cc5661511edb8aba32c","src/group.rs":"f5911e9cf2dc2dffab546590167c48de30409cb7708aa3307d22be143df720e4","src/ident.rs":"1b2d86d2e380b1fa83aee6ed113c47f0b482a229c25be428dac921deec0b4852","src/item.rs":"00ae729a00854f15203dbcbf2251910658eb052130de243144dcbec68be37919","src/lib.rs":"254307de790ddbdad664bd7507b91443edb287f1245c09c3a550ccf8882ad92e","src/lifetime.rs":"64abfd72af5dd271b2de1a8304ca0899b90da7750df9dec2ee8102bceb08a426","src/lit.rs":"3a70ebbc81563b967d2cbf589b6980a5b202ee3379d5d401e01a4c2af124d7ae","src/lookahead.rs":"376092f91a1c32e1b277db0a6790fdda151c9ec51bd971fe6a6545b5b9e73b5d","src/mac.rs":"b1cf73f34a27a8f1429125e726623a524fb5dce875eb68ead3beaffa976442c3","src/macros.rs":"64fce3fda990306cfae5f0409918946ff7c9e98ecad963932e6c1436c0b0d4c2","src/meta.rs":"9df61ebaa405ef743ba1629b39ee5e806f9ead77694a1027f192da860270c83d","src/op.rs":"fe5db7c3373b956234ea8a1a7d129a06e5aef5db77c44c1c2fedb4aaa667ac56","src/parse.rs":"4d6c7935de1c2762ddb20ddf8e0b3de934e5ca26143aa8ba3a7fcc09f8c91893","src/parse_macro_input.rs":"4a753b2a6dbfefd6dc93852d66b4f6d73ebd6b8b9be74019fc476f429b9a892d","src/parse_quote.rs":"08c8f4eaedeffaac73170b59921d140f63f4a01c243993dff050b4b848d0ac1f","src/pat.rs":"4d99c5ed6a08e6adfd0f6c31438befd3f03e48982a36bb2544962d9db7805a4a","src/path.rs":"8079943ec924ad5338e4bfa16b15b8ea0d6d27092396b62667eadcd0b98f20db","src/print.rs":"22910bf0521ab868ebd7c62601c55912d12cfb400c65723e08e5cfa3a2d111c0","src/punctuated.rs":"dffaab15b9215c70d7db416e8d4c44b78c43ba2f255485e6211363f0f0fea063","src/restriction.rs":"62efbc127d7e7316dd1070c0e976872de6238b2602bba1fb35df18511b4e7199","src/sealed.rs":"6ece3b3dcb30f6bb98b93d83759ca7712ee8592bef9c0511141039c38765db0e","src/span.rs":"0a48e375e5c9768f6f64174a91ba6a255f4b021e2fb3548d8494e617f142601b","src/spanned.rs":"1bba75d73dd4dc5be6c4e11fdd72686d340fb25b5808830bd603ddc840beabdc","src/stmt.rs":"321d445f681c46ac30644504df2a8afc333a1dde0371159e9e077a17eed16548","src/thread.rs":"1f1deb1272525ab2af9a36aac4bce8f65b0e315adb1656641fd7075662f49222","src/token.rs":"e6b2373fb0465158d267bd25eac16266bd4b492d7dbe8ae4b5405a841a1ac57d","src/tt.rs":"32490509abcc4a5a3c7eb5628337172b3b49d30697d2f7b7df4d8045255c13da","src/ty.rs":"1d11c614298f25a8fa42165a01d6545fc699a446d7f3f8630162c7f478b26886","src/verbatim.rs":"87cbe82a90f48efb57ffd09141042698b3e011a21d0d5412154d80324b0a5ef0","src/whitespace.rs":"718a80c12cdd145358e2690f0f68ff7779a91ec17ce9fde9bb755f635fce69ad","tests/common/eq.rs":"147342055d118d8ec7c64ea6b0224e61c4ac058e7395058f379668b07fe99345","tests/common/mod.rs":"432ad35577f836a20b517d8c26ed994ac25fe73ef2f461c67688b61b99762015","tests/common/parse.rs":"246ddf1d303a9dbbc380e8d0689bd851cef3c3146d09d2627175deb9203b003d","tests/debug/gen.rs":"bc638d0fcb4a007d658535b60eec09cf4dc2c4907062832cb94fe6960a0d7e01","tests/debug/mod.rs":"dd87563bbd359401790a9c4185178539929ff9fa35a6998657af82a85731fe4c","tests/macros/mod.rs":"4c84bd9e82df255258671b6a57b0f2a3e4bef2127a2e8b842a4b6f3037b7fc5c","tests/regression.rs":"e9565ea0efecb4136f099164ffcfa26e1996b0a27fb9c6659e90ad9bdd42e7b6","tests/regression/issue1108.rs":"f32db35244a674e22ff824ca9e5bbec2184e287b59f022db68c418b5878a2edc","tests/regression/issue1235.rs":"a2266b10c3f7c7af5734817ab0a3e8b309b51e7d177b63f26e67e6b744d280b0","tests/repo/mod.rs":"9ab41309422dbf26543de6f67fa975239c33c9bfdd5ff772ee6b46b716ea60cf","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":"96af622fa5dfba122a63bf68927ba7e5d818c233d85f5fb01765b3a1b5b67411","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":"8e30c2d7837673a742d77aef01212788bbd099182dd5c1d10ee474cfeb786c39","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":"d3c34f2e5ffe22f7bdacff7ab6af71b24ba8150fdcc640f3c3e28db3491a556a","tests/test_receiver.rs":"af64117acd66fbf42edc476f731ecd20c88009d9cb641dbd7a1d6384ae99ae73","tests/test_round_trip.rs":"61183de56bf70c628659b9529f794b9f138904959f919f08f3b8176ba62c76ef","tests/test_shebang.rs":"06d3acabed004767d8b3a0389bde7485a6719cad6a0d0b4ac2c7439b03586651","tests/test_should_parse.rs":"1d3535698a446e2755bfc360676bdb161841a1f454cdef6e7556c6d06a95c89d","tests/test_size.rs":"78c14995718c2f8d5a7296c8f524601c30f91a5586e1402c0775977a4f814406","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":"23e78b90f2fcf45d3e842032ce32e3f2d1545ba6636271dcbf24fa306d87be7a"} \ No newline at end of file +{"files":{"Cargo.toml":"47642f5e708d66cfec0c0e8f414db37af5dbd530234ccdd17b41c176b52d93a9","LICENSE-APACHE":"62c7a1e35f56406896d7aa7ca52d0cc0d272ac022b5d2796e7d6905db8a3636a","LICENSE-MIT":"23f18e03dc49df91622fe2a76176497404e46ced8a715d9d2b67a7446571cca3","README.md":"f6904878f9082d7d267b6d0d737ef211ff165cfd039a4d45ad88e9861f3e217f","benches/file.rs":"0a0527c78d849148cbb6118b4d36f72da7d4add865ba1a410e0a1be9e8dbfe0e","benches/rust.rs":"84dedb2d912a19ce3b8c15cda3bbcdb2994996167fe4435f71d1b5f74590299d","src/attr.rs":"2833aadc7f0e180caeae32793f41e120467a38bb0635b0a3c33546cf29584635","src/bigint.rs":"0299829b2f7a1a798fe2f7bc1680e4a10f9b6f4a852d09af4da2deab466c4242","src/buffer.rs":"30a9fffaf1b7a4fd8ca7eed5a9cde7a13d75d0b7b92569975bee1e7083d2555e","src/custom_keyword.rs":"b2e25cbe73d237b459140a38083ee21e4836ea444859b033f400652414630290","src/custom_punctuation.rs":"c2c344c9cdbebc66a5833eb0f9ded817ce9807dbb75b616283b2b60960d1ffb0","src/data.rs":"106be8b10d62ddf4fd636cf682b72a43748b25069a32cd2ff59333b3c8478695","src/derive.rs":"3132e7f064725c7ca43f26daee93ec78037d46a935c6b0758af905cff450c15c","src/discouraged.rs":"482970b03bdee3cbc30c034f644e3293b25387db46300da5d8d8efd97dad8507","src/drops.rs":"013385f1dd95663f1afab41abc1e2eea04181998644828935ca564c74d6462ae","src/error.rs":"f3d051067081857384fc54499e1ce4e90c5a1eb6a3c20a646295d5942ec83ca0","src/export.rs":"b260cc49da1da3489e7755832bc8015cfad79e84f6c74e237f65ae25a2385e56","src/expr.rs":"5700c529bab1634c83371ae5bc65be17eb634a11334e6d581e6cf100fefa4d75","src/ext.rs":"3cf2d869812e5be894aa1c48bf074da262143fb2df1c9ac1b5ee965bf2a96a1c","src/file.rs":"a4d510dd0e2756bd54983dfa747601918c801e987cbf92deab44cdca6a201aeb","src/gen/clone.rs":"837df226926225f7f084ad4deb98a379dc98d079270ea5ae5db2f74d3a23bcb8","src/gen/debug.rs":"9532acd0fe48ea06073519956cae063882f89ef6f3579c32d9c1b3efb115a499","src/gen/eq.rs":"86279869463047ab62e01f72e2a166a6bbcf2e2082bec3e4679f8876ceac4ae9","src/gen/fold.rs":"33ce8928a4ba1e66517890244ce61089cebf19142e03220b227f60a10ba35f7f","src/gen/hash.rs":"4f0ab10b7aaddea9f988b02fe1946d6f81b8e51f75b5a1777ab0be67ed278816","src/gen/visit.rs":"33251b48083c41640a5f5b1fe6c6658ba62cb76dac0b630efaa5e18471bd06c2","src/gen/visit_mut.rs":"ff9fafdda337c6bf2f2d4ca3ce75714fabe45a98e14d729fd5b7b392499a1cc8","src/gen_helper.rs":"750caab67ba0ba11a95ea28cd38026485227bb4aa114cdb497472386f60fdb35","src/generics.rs":"699923668dfb2e5a129dab0f1f333f2f49d52d0a79c9314b8806e72c802169f5","src/group.rs":"f5911e9cf2dc2dffab546590167c48de30409cb7708aa3307d22be143df720e4","src/ident.rs":"1b2d86d2e380b1fa83aee6ed113c47f0b482a229c25be428dac921deec0b4852","src/item.rs":"f595bbd12d87a6d5ff86ea98b4f5be5f5ba47d33b86fba7e08cbea4d3a8d8953","src/lib.rs":"359f54d2e9548bfbbc23141d4c70c3068f32683ada372ccd133b7686efee4d5f","src/lifetime.rs":"64abfd72af5dd271b2de1a8304ca0899b90da7750df9dec2ee8102bceb08a426","src/lit.rs":"b382c85f0b81faebdf2e97a198afb5904738955ce130f5393b548430c2a17f9b","src/lookahead.rs":"376092f91a1c32e1b277db0a6790fdda151c9ec51bd971fe6a6545b5b9e73b5d","src/mac.rs":"b1cf73f34a27a8f1429125e726623a524fb5dce875eb68ead3beaffa976442c3","src/macros.rs":"e68e246752d67307f9afb5ada6c1d689ddc0b0d9a51d40ba6191427d1e1b8bdc","src/meta.rs":"603dfd4fd71d9e4a5a33cb8ba8a9a1160b78898e3f41ccd5b1be503f47edea92","src/op.rs":"09a8dece03265aa1a9cd36c73f4ed7f783e311e4166c88671cf5ba833fb51d21","src/parse.rs":"1320c3b54f8c5dff87fd06d2b27e8dcd5edbe682c6946335eba30ace989d4bce","src/parse_macro_input.rs":"4a753b2a6dbfefd6dc93852d66b4f6d73ebd6b8b9be74019fc476f429b9a892d","src/parse_quote.rs":"6bf1498244557fcecff9247091b7c701e9b2775cd061ff936c52eeffb101278b","src/pat.rs":"3178f18832928b835df3140639b7e741f6dfbd8adafe463637f04063a545dc0d","src/path.rs":"d90644e63e8f87b09651ea09694934bdccfeb863f270a6de617828098602f8cd","src/print.rs":"22910bf0521ab868ebd7c62601c55912d12cfb400c65723e08e5cfa3a2d111c0","src/punctuated.rs":"dffaab15b9215c70d7db416e8d4c44b78c43ba2f255485e6211363f0f0fea063","src/restriction.rs":"1aed612ed2f39ab3f8edbb72a8f2aa506e5b6eb4d9f05f1b97d9bb32369a3fc9","src/sealed.rs":"6ece3b3dcb30f6bb98b93d83759ca7712ee8592bef9c0511141039c38765db0e","src/span.rs":"0a48e375e5c9768f6f64174a91ba6a255f4b021e2fb3548d8494e617f142601b","src/spanned.rs":"1bba75d73dd4dc5be6c4e11fdd72686d340fb25b5808830bd603ddc840beabdc","src/stmt.rs":"fe7d7fd60ad1d6841c7a3602ae7e5d0ea9fcba2aeba82eb6f85d41b5c722ee64","src/thread.rs":"1f1deb1272525ab2af9a36aac4bce8f65b0e315adb1656641fd7075662f49222","src/token.rs":"e6b2373fb0465158d267bd25eac16266bd4b492d7dbe8ae4b5405a841a1ac57d","src/tt.rs":"32490509abcc4a5a3c7eb5628337172b3b49d30697d2f7b7df4d8045255c13da","src/ty.rs":"3298c372eb743f8bb60d0e761506e92911f8ec0f29e1fedb0730c3400958d0c9","src/verbatim.rs":"87cbe82a90f48efb57ffd09141042698b3e011a21d0d5412154d80324b0a5ef0","src/whitespace.rs":"718a80c12cdd145358e2690f0f68ff7779a91ec17ce9fde9bb755f635fce69ad","tests/common/eq.rs":"d87b07c88cdb890d230fff55bd713e62b3571aba7edc869664213f424de06718","tests/common/mod.rs":"432ad35577f836a20b517d8c26ed994ac25fe73ef2f461c67688b61b99762015","tests/common/parse.rs":"246ddf1d303a9dbbc380e8d0689bd851cef3c3146d09d2627175deb9203b003d","tests/debug/gen.rs":"daa5be1f3dc2379d5067137e0106874e0f3ed5eba7f2a8436fdada0bf33d7186","tests/debug/mod.rs":"b56136586267ae1812a937b69215dd053ada2c21717771d89dcd3ce52bcb27f5","tests/macros/mod.rs":"ac0ef6edc8d4a740c620eb73ac69e81ae442d3f73bcb37cc49845e483a296194","tests/regression.rs":"e9565ea0efecb4136f099164ffcfa26e1996b0a27fb9c6659e90ad9bdd42e7b6","tests/regression/issue1108.rs":"f32db35244a674e22ff824ca9e5bbec2184e287b59f022db68c418b5878a2edc","tests/regression/issue1235.rs":"a2266b10c3f7c7af5734817ab0a3e8b309b51e7d177b63f26e67e6b744d280b0","tests/repo/mod.rs":"d92f0f9afa0613e95ab8ed1e7ec9b4d863b6eff5b790371ed8eac86f44902bf1","tests/repo/progress.rs":"c08d0314a7f3ecf760d471f27da3cd2a500aeb9f1c8331bffb2aa648f9fabf3f","tests/test_asyncness.rs":"8982f6bc4e36510f924e288247473403e72697389ce9dda4e4b5ab0a8e49259f","tests/test_attribute.rs":"b35550a43bbd187bb330997ba36f90c65d8fc489135b1d32ef4547f145cb7612","tests/test_derive_input.rs":"99c4e6e45e3322ea9e269b309059c8a00fda1dcc03aed41f6e7d8c7e0a72fa2b","tests/test_expr.rs":"f7726efc959b860aa8aca6c51bc10c466cb1957774c1dfac24c3907cd8ea99a6","tests/test_generics.rs":"2fcc8575d695b568f3724b3b33d853b8fa6d9864eb816b5e3ca82420682e6155","tests/test_grouping.rs":"ecbe3324878b2e2be42640a3dec198620cff18731fcb95ee7e94eacd11d2fec1","tests/test_ident.rs":"9eb53d1e21edf23e7c9e14dc74dcc2b2538e9221e19dbcc0a44e3acc2e90f3f6","tests/test_item.rs":"9398997f2be33c89de52eb40f8c2fce86cf4ce5810fe709d2f20916ed6e2bb47","tests/test_iterators.rs":"f4dacb5f3a8e0473dfb0d27f05270d41e79eddb4759b1fad3e88e379b4731e17","tests/test_lit.rs":"8e30c2d7837673a742d77aef01212788bbd099182dd5c1d10ee474cfeb786c39","tests/test_meta.rs":"70fd75b42d1d913f05825c9e8280a4802e81de0b2343ad876850d2b7c588f0bf","tests/test_parse_buffer.rs":"92f5e898c1a6625011497f8cc8684eac0311850566ae9ab1848444305c9bdddf","tests/test_parse_quote.rs":"5bb7ec6773c3b878b3abedf17952948e707d8990b7e131605ee03d31f9ecae5b","tests/test_parse_stream.rs":"91a7ec997ea67d3c9d3028495345d89f2f67eb01bf11af3f99a1cef42a41aa05","tests/test_pat.rs":"8467fbef7cba36e6ce105cbc1a038b13ec154505bd34c863a18cfdfeac02c0b1","tests/test_path.rs":"b202244f034e58bf17e4c39bef696b0567e0ed42a63427ed4866acd14aaa90df","tests/test_precedence.rs":"f8b57c4a10ad249d3c6984cbe5db56a0c1e1381900dbc837fdc6f0e7f19221a7","tests/test_receiver.rs":"af64117acd66fbf42edc476f731ecd20c88009d9cb641dbd7a1d6384ae99ae73","tests/test_round_trip.rs":"61345d746dc03f99ec7e9e23fa6e5fe80526175d863f12d42163f7fa11d8c5cb","tests/test_shebang.rs":"98e8a6690c04e0aad2893b747593620b51836fe704f50f5c6fe352609837138a","tests/test_should_parse.rs":"1d3535698a446e2755bfc360676bdb161841a1f454cdef6e7556c6d06a95c89d","tests/test_size.rs":"b446868d55ae820196aad03dba3aa3529b727ac0465113c6fc66706423a73350","tests/test_stmt.rs":"761946f7d020f37dcc9f3a6c4b17c8d26c30d609193ac13c0672a2833b80f6dc","tests/test_token_trees.rs":"d012da9c3c861073711b006bf6ffdc073821fb9fb0a08733628cdae57124d1f5","tests/test_ty.rs":"e0262eb0c65c06a5bd8781cf0e256d7f093182202e8160623f00de98594845d2","tests/test_visibility.rs":"cf4c93997cd88821ef7f8e2dd5d1586175cce4614407cd3bdf371ecc4d8abc44","tests/zzz_stable.rs":"2a862e59cb446235ed99aec0e6ada8e16d3ecc30229b29d825b7c0bbc2602989"},"package":"89456b690ff72fddcecf231caedbe615c59480c93358a93dfae7fc29e3ebbf0e"} \ No newline at end of file diff --git a/third_party/rust/syn/Cargo.toml b/third_party/rust/syn/Cargo.toml index 56cf07e4ffff6..d9889804b5ea5 100644 --- a/third_party/rust/syn/Cargo.toml +++ b/third_party/rust/syn/Cargo.toml @@ -13,7 +13,7 @@ edition = "2021" rust-version = "1.56" name = "syn" -version = "2.0.39" +version = "2.0.46" authors = ["David Tolnay "] include = [ "/benches/**", @@ -75,11 +75,11 @@ required-features = [ ] [dependencies.proc-macro2] -version = "1.0.67" +version = "1.0.74" default-features = false [dependencies.quote] -version = "1.0.28" +version = "1.0.35" optional = true default-features = false @@ -104,9 +104,6 @@ version = "1" [dev-dependencies.ref-cast] version = "1" -[dev-dependencies.regex] -version = "1" - [dev-dependencies.reqwest] version = "0.11" features = ["blocking"] diff --git a/third_party/rust/syn/benches/rust.rs b/third_party/rust/syn/benches/rust.rs index 643976188dde4..15536db4c8ca2 100644 --- a/third_party/rust/syn/benches/rust.rs +++ b/third_party/rust/syn/benches/rust.rs @@ -6,6 +6,7 @@ #![cfg_attr(not(syn_only), feature(rustc_private))] #![recursion_limit = "1024"] #![allow( + clippy::arc_with_non_send_sync, clippy::cast_lossless, clippy::let_underscore_untyped, clippy::manual_let_else, @@ -53,7 +54,7 @@ mod librustc_parse { use rustc_data_structures::sync::Lrc; use rustc_error_messages::FluentBundle; - use rustc_errors::{emitter::Emitter, translation::Translate, Diagnostic, Handler}; + use rustc_errors::{emitter::Emitter, translation::Translate, DiagCtxt, Diagnostic}; use rustc_session::parse::ParseSess; use rustc_span::source_map::{FilePathMapping, SourceMap}; use rustc_span::{edition::Edition, FileName}; @@ -78,10 +79,10 @@ mod librustc_parse { } rustc_span::create_session_if_not_set_then(Edition::Edition2018, |_| { - let cm = Lrc::new(SourceMap::new(FilePathMapping::empty())); + let source_map = Lrc::new(SourceMap::new(FilePathMapping::empty())); let emitter = Box::new(SilentEmitter); - let handler = Handler::with_emitter(emitter); - let sess = ParseSess::with_span_handler(handler, cm); + let handler = DiagCtxt::with_emitter(emitter); + let sess = ParseSess::with_dcx(handler, source_map); if let Err(diagnostic) = rustc_parse::parse_crate_from_source_str( FileName::Custom("bench".to_owned()), content.to_owned(), diff --git a/third_party/rust/syn/src/attr.rs b/third_party/rust/syn/src/attr.rs index 34d5515a56860..b6c4675b763fb 100644 --- a/third_party/rust/syn/src/attr.rs +++ b/third_party/rust/syn/src/attr.rs @@ -616,7 +616,7 @@ impl<'a> FilterAttrs<'a> for &'a [Attribute] { #[cfg(feature = "parsing")] pub(crate) mod parsing { use super::*; - use crate::parse::discouraged::Speculative; + use crate::parse::discouraged::Speculative as _; use crate::parse::{Parse, ParseStream, Result}; use std::fmt::{self, Display}; diff --git a/third_party/rust/syn/src/buffer.rs b/third_party/rust/syn/src/buffer.rs index 564ccc75775c8..86dec46afda0d 100644 --- a/third_party/rust/syn/src/buffer.rs +++ b/third_party/rust/syn/src/buffer.rs @@ -128,11 +128,11 @@ impl<'a> Cursor<'a> { // past it, unless `ptr == scope`, which means that we're at the edge of // our cursor's scope. We should only have `ptr != scope` at the exit // from None-delimited groups entered with `ignore_none`. - while let Entry::End(_) = *ptr { + while let Entry::End(_) = unsafe { &*ptr } { if ptr == scope { break; } - ptr = ptr.add(1); + ptr = unsafe { ptr.add(1) }; } Cursor { @@ -154,7 +154,7 @@ impl<'a> Cursor<'a> { /// If the cursor is looking at an `Entry::Group`, the bumped cursor will /// point at the first token in the group (with the same scope end). unsafe fn bump_ignore_group(self) -> Cursor<'a> { - Cursor::create(self.ptr.offset(1), self.scope) + unsafe { Cursor::create(self.ptr.offset(1), self.scope) } } /// While the cursor is looking at a `None`-delimited group, move it to look @@ -389,7 +389,7 @@ impl<'a> PartialEq for Cursor<'a> { impl<'a> PartialOrd for Cursor<'a> { fn partial_cmp(&self, other: &Self) -> Option { if same_buffer(*self, *other) { - Some(self.ptr.cmp(&other.ptr)) + Some(cmp_assuming_same_buffer(*self, *other)) } else { None } @@ -413,7 +413,6 @@ fn start_of_buffer(cursor: Cursor) -> *const Entry { } } -#[cfg(any(feature = "full", feature = "derive"))] pub(crate) fn cmp_assuming_same_buffer(a: Cursor, b: Cursor) -> Ordering { a.ptr.cmp(&b.ptr) } diff --git a/third_party/rust/syn/src/data.rs b/third_party/rust/syn/src/data.rs index 431c0857d4bf2..134b76bb41328 100644 --- a/third_party/rust/syn/src/data.rs +++ b/third_party/rust/syn/src/data.rs @@ -156,7 +156,9 @@ ast_struct! { #[cfg(feature = "parsing")] pub(crate) mod parsing { use super::*; - use crate::ext::IdentExt; + use crate::ext::IdentExt as _; + #[cfg(not(feature = "full"))] + use crate::parse::discouraged::Speculative as _; use crate::parse::{Parse, ParseStream, Result}; #[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))] @@ -174,7 +176,20 @@ pub(crate) mod parsing { }; let discriminant = if input.peek(Token![=]) { let eq_token: Token![=] = input.parse()?; + #[cfg(feature = "full")] let discriminant: Expr = input.parse()?; + #[cfg(not(feature = "full"))] + let discriminant = { + let begin = input.fork(); + let ahead = input.fork(); + let mut discriminant: Result = ahead.parse(); + if discriminant.is_ok() { + input.advance_to(&ahead); + } else if scan_lenient_discriminant(input).is_ok() { + discriminant = Ok(Expr::Verbatim(verbatim::between(&begin, input))); + } + discriminant? + }; Some((eq_token, discriminant)) } else { None @@ -188,6 +203,79 @@ pub(crate) mod parsing { } } + #[cfg(not(feature = "full"))] + pub(crate) fn scan_lenient_discriminant(input: ParseStream) -> Result<()> { + use proc_macro2::Delimiter::{self, Brace, Bracket, Parenthesis}; + + let consume = |delimiter: Delimiter| { + Result::unwrap(input.step(|cursor| match cursor.group(delimiter) { + Some((_inside, _span, rest)) => Ok((true, rest)), + None => Ok((false, *cursor)), + })) + }; + + macro_rules! consume { + [$token:tt] => { + input.parse::>().unwrap().is_some() + }; + } + + let mut initial = true; + let mut depth = 0usize; + loop { + if initial { + if consume![&] { + input.parse::>()?; + } else if consume![if] || consume![match] || consume![while] { + depth += 1; + } else if input.parse::>()?.is_some() + || (consume(Brace) || consume(Bracket) || consume(Parenthesis)) + || (consume![async] || consume![const] || consume![loop] || consume![unsafe]) + && (consume(Brace) || break) + { + initial = false; + } else if consume![let] { + while !consume![=] { + if !((consume![|] || consume![ref] || consume![mut] || consume![@]) + || (consume![!] || input.parse::>()?.is_some()) + || (consume![..=] || consume![..] || consume![&] || consume![_]) + || (consume(Brace) || consume(Bracket) || consume(Parenthesis))) + { + path::parsing::qpath(input, true)?; + } + } + } else if input.parse::>()?.is_some() && !consume![:] { + break; + } else if input.parse::().is_err() { + path::parsing::qpath(input, true)?; + initial = consume![!] || depth == 0 && input.peek(token::Brace); + } + } else if input.is_empty() || input.peek(Token![,]) { + return Ok(()); + } else if depth > 0 && consume(Brace) { + if consume![else] && !consume(Brace) { + initial = consume![if] || break; + } else { + depth -= 1; + } + } else if input.parse::().is_ok() || (consume![..] | consume![=]) { + initial = true; + } else if consume![.] { + if input.parse::>()?.is_none() + && (input.parse::()?.is_named() && consume![::]) + { + AngleBracketedGenericArguments::do_parse(None, input)?; + } + } else if consume![as] { + input.parse::()?; + } else if !(consume(Brace) || consume(Bracket) || consume(Parenthesis)) { + break; + } + } + + Err(input.error("unsupported expression")) + } + #[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))] impl Parse for FieldsNamed { fn parse(input: ParseStream) -> Result { diff --git a/third_party/rust/syn/src/error.rs b/third_party/rust/syn/src/error.rs index 3fe31d5ce9faf..d59e08fd0c054 100644 --- a/third_party/rust/syn/src/error.rs +++ b/third_party/rust/syn/src/error.rs @@ -185,6 +185,7 @@ impl Error { /// When in doubt it's recommended to stick to `Error::new` (or /// `ParseStream::error`)! #[cfg(feature = "printing")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "printing")))] pub fn new_spanned(tokens: T, message: U) -> Self { return new_spanned(tokens.into_token_stream(), message.to_string()); diff --git a/third_party/rust/syn/src/expr.rs b/third_party/rust/syn/src/expr.rs index 22400be329fb5..a417508b591f9 100644 --- a/third_party/rust/syn/src/expr.rs +++ b/third_party/rust/syn/src/expr.rs @@ -357,6 +357,7 @@ ast_struct! { ast_struct! { /// A const block: `const { ... }`. + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub struct ExprConst #full { pub attrs: Vec, pub const_token: Token![const], @@ -443,6 +444,7 @@ ast_struct! { ast_struct! { /// The inferred value of a const generic argument, denoted `_`. + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub struct ExprInfer #full { pub attrs: Vec, pub underscore_token: Token![_], @@ -483,6 +485,7 @@ ast_struct! { ast_struct! { /// A macro invocation expression: `format!("{}", q)`. + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "full", feature = "derive"))))] pub struct ExprMacro { pub attrs: Vec, pub mac: Macro, @@ -503,8 +506,8 @@ ast_struct! { ast_struct! { /// A method call expression: `x.foo::(a, b)`. - #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] - pub struct ExprMethodCall #full { + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "full", feature = "derive"))))] + pub struct ExprMethodCall { pub attrs: Vec, pub receiver: Box, pub dot_token: Token![.], @@ -551,8 +554,8 @@ ast_struct! { ast_struct! { /// A referencing operation: `&a` or `&mut a`. - #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] - pub struct ExprReference #full { + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "full", feature = "derive"))))] + pub struct ExprReference { pub attrs: Vec, pub and_token: Token![&], pub mutability: Option, @@ -587,8 +590,8 @@ ast_struct! { /// /// The `rest` provides the value of the remaining fields as in `S { a: /// 1, b: 1, ..rest }`. - #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] - pub struct ExprStruct #full { + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "full", feature = "derive"))))] + pub struct ExprStruct { pub attrs: Vec, pub qself: Option, pub path: Path, @@ -840,10 +843,9 @@ impl IdentFragment for Index { } } -#[cfg(feature = "full")] ast_struct! { /// A field-value pair in a struct literal. - #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "full", feature = "derive"))))] pub struct FieldValue { pub attrs: Vec, pub member: Member, @@ -955,31 +957,10 @@ pub(crate) fn requires_terminator(expr: &Expr) -> bool { } #[cfg(feature = "parsing")] -pub(crate) mod parsing { - use super::*; - #[cfg(feature = "full")] - use crate::ext::IdentExt; - use crate::parse::discouraged::Speculative; - #[cfg(feature = "full")] - use crate::parse::ParseBuffer; - use crate::parse::{Parse, ParseStream, Result}; - use crate::path; - use std::cmp::Ordering; +mod precedence { + use super::BinOp; - mod kw { - crate::custom_keyword!(builtin); - crate::custom_keyword!(raw); - } - - // When we're parsing expressions which occur before blocks, like in an if - // statement's condition, we cannot parse a struct literal. - // - // Struct literals are ambiguous in certain positions - // https://github.com/rust-lang/rfcs/pull/92 - #[cfg(feature = "full")] - pub(crate) struct AllowStruct(bool); - - enum Precedence { + pub(crate) enum Precedence { Any, Assign, Range, @@ -996,7 +977,7 @@ pub(crate) mod parsing { } impl Precedence { - fn of(op: &BinOp) -> Self { + pub(crate) fn of(op: &BinOp) -> Self { match op { BinOp::Add(_) | BinOp::Sub(_) => Precedence::Arithmetic, BinOp::Mul(_) | BinOp::Div(_) | BinOp::Rem(_) => Precedence::Term, @@ -1025,6 +1006,33 @@ pub(crate) mod parsing { } } } +} + +#[cfg(feature = "parsing")] +pub(crate) mod parsing { + use super::precedence::Precedence; + use super::*; + #[cfg(feature = "full")] + use crate::ext::IdentExt as _; + use crate::parse::discouraged::Speculative as _; + #[cfg(feature = "full")] + use crate::parse::ParseBuffer; + use crate::parse::{Parse, ParseStream, Result}; + use crate::path; + use std::cmp::Ordering; + + mod kw { + crate::custom_keyword!(builtin); + crate::custom_keyword!(raw); + } + + // When we're parsing expressions which occur before blocks, like in an if + // statement's condition, we cannot parse a struct literal. + // + // Struct literals are ambiguous in certain positions + // https://github.com/rust-lang/rfcs/pull/92 + #[cfg(feature = "full")] + pub(crate) struct AllowStruct(bool); #[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))] impl Parse for Expr { @@ -1354,23 +1362,8 @@ pub(crate) mod parsing { #[cfg(feature = "full")] fn expr_attrs(input: ParseStream) -> Result> { let mut attrs = Vec::new(); - loop { - if input.peek(token::Group) { - let ahead = input.fork(); - let group = crate::group::parse_group(&ahead)?; - if !group.content.peek(Token![#]) || group.content.peek2(Token![!]) { - break; - } - let attr = group.content.call(attr::parsing::single_parse_outer)?; - if !group.content.is_empty() { - break; - } - attrs.push(attr); - } else if input.peek(Token![#]) { - attrs.push(input.call(attr::parsing::single_parse_outer)?); - } else { - break; - } + while !input.peek(token::Group) && input.peek(Token![#]) { + attrs.push(input.call(attr::parsing::single_parse_outer)?); } Ok(attrs) } @@ -1383,6 +1376,10 @@ pub(crate) mod parsing { fn unary_expr(input: ParseStream, allow_struct: AllowStruct) -> Result { let begin = input.fork(); let attrs = input.call(expr_attrs)?; + if input.peek(token::Group) { + return trailer_expr(begin, attrs, input, allow_struct); + } + if input.peek(Token![&]) { let and_token: Token![&] = input.parse()?; let raw: Option = if input.peek(kw::raw) @@ -1416,7 +1413,14 @@ pub(crate) mod parsing { #[cfg(not(feature = "full"))] fn unary_expr(input: ParseStream) -> Result { - if input.peek(Token![*]) || input.peek(Token![!]) || input.peek(Token![-]) { + if input.peek(Token![&]) { + Ok(Expr::Reference(ExprReference { + attrs: Vec::new(), + and_token: input.parse()?, + mutability: input.parse()?, + expr: Box::new(unary_expr(input)?), + })) + } else if input.peek(Token![*]) || input.peek(Token![!]) || input.peek(Token![-]) { Ok(Expr::Unary(ExprUnary { attrs: Vec::new(), op: input.parse()?, @@ -1560,17 +1564,45 @@ pub(crate) mod parsing { && !input.peek2(Token![await]) { let mut dot_token: Token![.] = input.parse()?; + let float_token: Option = 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![::]) { + let colon2_token: Token![::] = input.parse()?; + let turbofish = + AngleBracketedGenericArguments::do_parse(Some(colon2_token), input)?; + Some(turbofish) + } else { + None + }; + + if turbofish.is_some() || input.peek(token::Paren) { + if let Member::Named(method) = member { + let content; + e = Expr::MethodCall(ExprMethodCall { + attrs: Vec::new(), + receiver: Box::new(e), + dot_token, + method, + turbofish, + paren_token: parenthesized!(content in input), + args: content.parse_terminated(Expr::parse, Token![,])?, + }); + continue; + } + } + e = Expr::Field(ExprField { attrs: Vec::new(), base: Box::new(e), dot_token, - member: input.parse()?, + member, }); } else if input.peek(token::Bracket) { let content; @@ -1592,12 +1624,8 @@ pub(crate) mod parsing { // interactions, as they are fully contained. #[cfg(feature = "full")] fn atom_expr(input: ParseStream, allow_struct: AllowStruct) -> Result { - if input.peek(token::Group) - && !input.peek2(Token![::]) - && !input.peek2(Token![!]) - && !input.peek2(token::Brace) - { - input.call(expr_group).map(Expr::Group) + if input.peek(token::Group) { + expr_group(input, allow_struct) } else if input.peek(Lit) { input.parse().map(Expr::Lit) } else if input.peek(Token![async]) @@ -1663,39 +1691,40 @@ pub(crate) mod parsing { } else if input.peek(Token![_]) { input.parse().map(Expr::Infer) } else if input.peek(Lifetime) { - let the_label: Label = input.parse()?; - let mut expr = if input.peek(Token![while]) { - Expr::While(input.parse()?) - } else if input.peek(Token![for]) { - Expr::ForLoop(input.parse()?) - } else if input.peek(Token![loop]) { - Expr::Loop(input.parse()?) - } else if input.peek(token::Brace) { - Expr::Block(input.parse()?) - } else { - return Err(input.error("expected loop or block expression")); - }; - match &mut expr { - Expr::While(ExprWhile { label, .. }) - | Expr::ForLoop(ExprForLoop { label, .. }) - | Expr::Loop(ExprLoop { label, .. }) - | Expr::Block(ExprBlock { label, .. }) => *label = Some(the_label), - _ => unreachable!(), - } - Ok(expr) + atom_labeled(input) } else { Err(input.error("expected an expression")) } } + #[cfg(feature = "full")] + fn atom_labeled(input: ParseStream) -> Result { + let the_label: Label = input.parse()?; + let mut expr = if input.peek(Token![while]) { + Expr::While(input.parse()?) + } else if input.peek(Token![for]) { + Expr::ForLoop(input.parse()?) + } else if input.peek(Token![loop]) { + Expr::Loop(input.parse()?) + } else if input.peek(token::Brace) { + Expr::Block(input.parse()?) + } else { + return Err(input.error("expected loop or block expression")); + }; + match &mut expr { + Expr::While(ExprWhile { label, .. }) + | Expr::ForLoop(ExprForLoop { label, .. }) + | Expr::Loop(ExprLoop { label, .. }) + | Expr::Block(ExprBlock { label, .. }) => *label = Some(the_label), + _ => unreachable!(), + } + Ok(expr) + } + #[cfg(not(feature = "full"))] fn atom_expr(input: ParseStream) -> Result { - if input.peek(token::Group) - && !input.peek2(Token![::]) - && !input.peek2(Token![!]) - && !input.peek2(token::Brace) - { - input.call(expr_group).map(Expr::Group) + if input.peek(token::Group) { + expr_group(input) } else if input.peek(Lit) { input.parse().map(Expr::Lit) } else if input.peek(token::Paren) { @@ -1746,7 +1775,21 @@ pub(crate) mod parsing { #[cfg(feature = "full")] allow_struct: AllowStruct, ) -> Result { let (qself, path) = path::parsing::qpath(input, true)?; + rest_of_path_or_macro_or_struct( + qself, + path, + input, + #[cfg(feature = "full")] + allow_struct, + ) + } + fn rest_of_path_or_macro_or_struct( + qself: Option, + path: Path, + input: ParseStream, + #[cfg(feature = "full")] allow_struct: AllowStruct, + ) -> Result { if qself.is_none() && input.peek(Token![!]) && !input.peek(Token![!=]) @@ -1765,7 +1808,8 @@ pub(crate) mod parsing { })); } - #[cfg(feature = "full")] + #[cfg(not(feature = "full"))] + let allow_struct = (true,); if allow_struct.0 && input.peek(token::Brace) { return expr_struct_helper(input, qself, path).map(Expr::Struct); } @@ -1915,7 +1959,15 @@ pub(crate) mod parsing { #[cfg(feature = "full")] pub(crate) fn expr_early(input: ParseStream) -> Result { let mut attrs = input.call(expr_attrs)?; - let mut expr = if input.peek(Token![if]) { + let mut expr = if input.peek(token::Group) { + let allow_struct = AllowStruct(true); + let atom = expr_group(input, allow_struct)?; + if continue_parsing_early(&atom) { + trailer_helper(input, atom)? + } else { + atom + } + } else if input.peek(Token![if]) { Expr::If(input.parse()?) } else if input.peek(Token![while]) { Expr::While(input.parse()?) @@ -1935,15 +1987,20 @@ pub(crate) mod parsing { Expr::Const(input.parse()?) } else if input.peek(token::Brace) { Expr::Block(input.parse()?) + } else if input.peek(Lifetime) { + atom_labeled(input)? } else { let allow_struct = AllowStruct(true); - let mut expr = unary_expr(input, allow_struct)?; + unary_expr(input, allow_struct)? + }; + if continue_parsing_early(&expr) { attrs.extend(expr.replace_attrs(Vec::new())); expr.replace_attrs(attrs); + let allow_struct = AllowStruct(true); return parse_expr(input, expr, allow_struct, Precedence::Any); - }; + } if input.peek(Token![.]) && !input.peek(Token![..]) || input.peek(Token![?]) { expr = trailer_helper(input, expr)?; @@ -1960,6 +2017,25 @@ pub(crate) mod parsing { Ok(expr) } + #[cfg(feature = "full")] + fn continue_parsing_early(mut expr: &Expr) -> bool { + while let Expr::Group(group) = expr { + expr = &group.expr; + } + match expr { + Expr::If(_) + | Expr::While(_) + | Expr::ForLoop(_) + | Expr::Loop(_) + | Expr::Match(_) + | Expr::TryBlock(_) + | Expr::Unsafe(_) + | Expr::Const(_) + | Expr::Block(_) => false, + _ => true, + } + } + #[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))] impl Parse for ExprLit { fn parse(input: ParseStream) -> Result { @@ -1970,13 +2046,38 @@ pub(crate) mod parsing { } } - fn expr_group(input: ParseStream) -> Result { + fn expr_group( + input: ParseStream, + #[cfg(feature = "full")] allow_struct: AllowStruct, + ) -> Result { let group = crate::group::parse_group(input)?; - Ok(ExprGroup { + let mut inner: Expr = group.content.parse()?; + + match inner { + Expr::Path(mut expr) if expr.attrs.is_empty() => { + let grouped_len = expr.path.segments.len(); + Path::parse_rest(input, &mut expr.path, true)?; + match rest_of_path_or_macro_or_struct( + expr.qself, + expr.path, + input, + #[cfg(feature = "full")] + allow_struct, + )? { + Expr::Path(expr) if expr.path.segments.len() == grouped_len => { + inner = Expr::Path(expr); + } + extended => return Ok(extended), + } + } + _ => {} + } + + Ok(Expr::Group(ExprGroup { attrs: Vec::new(), group_token: group.token, - expr: group.content.parse()?, - }) + expr: Box::new(inner), + })) } #[cfg(feature = "full")] @@ -2517,7 +2618,6 @@ pub(crate) mod parsing { }) } - #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))] impl Parse for FieldValue { fn parse(input: ParseStream) -> Result { @@ -2547,7 +2647,6 @@ pub(crate) mod parsing { } } - #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))] impl Parse for ExprStruct { fn parse(input: ParseStream) -> Result { @@ -2556,7 +2655,6 @@ pub(crate) mod parsing { } } - #[cfg(feature = "full")] fn expr_struct_helper( input: ParseStream, qself: Option, @@ -2815,9 +2913,8 @@ pub(crate) mod parsing { Ok(!trailing_dot) } - #[cfg(feature = "full")] impl Member { - fn is_named(&self) -> bool { + pub(crate) fn is_named(&self) -> bool { match self { Member::Named(_) => true, Member::Unnamed(_) => false, @@ -3163,7 +3260,6 @@ pub(crate) mod printing { } } - #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "printing")))] impl ToTokens for ExprMethodCall { fn to_tokens(&self, tokens: &mut TokenStream) { @@ -3207,7 +3303,6 @@ pub(crate) mod printing { } } - #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "printing")))] impl ToTokens for ExprReference { fn to_tokens(&self, tokens: &mut TokenStream) { @@ -3241,7 +3336,6 @@ pub(crate) mod printing { } } - #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "printing")))] impl ToTokens for ExprStruct { fn to_tokens(&self, tokens: &mut TokenStream) { @@ -3358,7 +3452,6 @@ pub(crate) mod printing { } } - #[cfg(feature = "full")] #[cfg_attr(doc_cfg, doc(cfg(feature = "printing")))] impl ToTokens for FieldValue { fn to_tokens(&self, tokens: &mut TokenStream) { diff --git a/third_party/rust/syn/src/gen/clone.rs b/third_party/rust/syn/src/gen/clone.rs index d275f51145754..95936794afc4e 100644 --- a/third_party/rust/syn/src/gen/clone.rs +++ b/third_party/rust/syn/src/gen/clone.rs @@ -266,19 +266,16 @@ impl Clone for Expr { Expr::Macro(v0) => Expr::Macro(v0.clone()), #[cfg(feature = "full")] Expr::Match(v0) => Expr::Match(v0.clone()), - #[cfg(feature = "full")] Expr::MethodCall(v0) => Expr::MethodCall(v0.clone()), Expr::Paren(v0) => Expr::Paren(v0.clone()), Expr::Path(v0) => Expr::Path(v0.clone()), #[cfg(feature = "full")] Expr::Range(v0) => Expr::Range(v0.clone()), - #[cfg(feature = "full")] Expr::Reference(v0) => Expr::Reference(v0.clone()), #[cfg(feature = "full")] Expr::Repeat(v0) => Expr::Repeat(v0.clone()), #[cfg(feature = "full")] Expr::Return(v0) => Expr::Return(v0.clone()), - #[cfg(feature = "full")] Expr::Struct(v0) => Expr::Struct(v0.clone()), #[cfg(feature = "full")] Expr::Try(v0) => Expr::Try(v0.clone()), @@ -577,7 +574,7 @@ impl Clone for ExprMatch { } } } -#[cfg(feature = "full")] +#[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(doc_cfg, doc(cfg(feature = "clone-impls")))] impl Clone for ExprMethodCall { fn clone(&self) -> Self { @@ -626,7 +623,7 @@ impl Clone for ExprRange { } } } -#[cfg(feature = "full")] +#[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(doc_cfg, doc(cfg(feature = "clone-impls")))] impl Clone for ExprReference { fn clone(&self) -> Self { @@ -662,7 +659,7 @@ impl Clone for ExprReturn { } } } -#[cfg(feature = "full")] +#[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(doc_cfg, doc(cfg(feature = "clone-impls")))] impl Clone for ExprStruct { fn clone(&self) -> Self { @@ -791,7 +788,7 @@ impl Clone for FieldPat { } } } -#[cfg(feature = "full")] +#[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(doc_cfg, doc(cfg(feature = "clone-impls")))] impl Clone for FieldValue { fn clone(&self) -> Self { diff --git a/third_party/rust/syn/src/gen/debug.rs b/third_party/rust/syn/src/gen/debug.rs index 837fe99f4c89b..553497ba4d140 100644 --- a/third_party/rust/syn/src/gen/debug.rs +++ b/third_party/rust/syn/src/gen/debug.rs @@ -432,19 +432,16 @@ impl Debug for Expr { Expr::Macro(v0) => v0.debug(formatter, "Macro"), #[cfg(feature = "full")] Expr::Match(v0) => v0.debug(formatter, "Match"), - #[cfg(feature = "full")] 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::Range(v0) => v0.debug(formatter, "Range"), - #[cfg(feature = "full")] Expr::Reference(v0) => v0.debug(formatter, "Reference"), #[cfg(feature = "full")] Expr::Repeat(v0) => v0.debug(formatter, "Repeat"), #[cfg(feature = "full")] Expr::Return(v0) => v0.debug(formatter, "Return"), - #[cfg(feature = "full")] Expr::Struct(v0) => v0.debug(formatter, "Struct"), #[cfg(feature = "full")] Expr::Try(v0) => v0.debug(formatter, "Try"), @@ -862,7 +859,7 @@ impl Debug for ExprMatch { self.debug(formatter, "ExprMatch") } } -#[cfg(feature = "full")] +#[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Debug for ExprMethodCall { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { @@ -931,7 +928,7 @@ impl Debug for ExprRange { self.debug(formatter, "ExprRange") } } -#[cfg(feature = "full")] +#[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Debug for ExprReference { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { @@ -982,7 +979,7 @@ impl Debug for ExprReturn { self.debug(formatter, "ExprReturn") } } -#[cfg(feature = "full")] +#[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Debug for ExprStruct { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { @@ -1152,7 +1149,7 @@ impl Debug for FieldPat { formatter.finish() } } -#[cfg(feature = "full")] +#[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Debug for FieldValue { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { diff --git a/third_party/rust/syn/src/gen/eq.rs b/third_party/rust/syn/src/gen/eq.rs index a7479c300b5a8..a1fb3b45e41d5 100644 --- a/third_party/rust/syn/src/gen/eq.rs +++ b/third_party/rust/syn/src/gen/eq.rs @@ -285,19 +285,16 @@ impl PartialEq for Expr { (Expr::Macro(self0), Expr::Macro(other0)) => self0 == other0, #[cfg(feature = "full")] (Expr::Match(self0), Expr::Match(other0)) => self0 == other0, - #[cfg(feature = "full")] (Expr::MethodCall(self0), Expr::MethodCall(other0)) => self0 == other0, (Expr::Paren(self0), Expr::Paren(other0)) => self0 == other0, (Expr::Path(self0), Expr::Path(other0)) => self0 == other0, #[cfg(feature = "full")] (Expr::Range(self0), Expr::Range(other0)) => self0 == other0, - #[cfg(feature = "full")] (Expr::Reference(self0), Expr::Reference(other0)) => self0 == other0, #[cfg(feature = "full")] (Expr::Repeat(self0), Expr::Repeat(other0)) => self0 == other0, #[cfg(feature = "full")] (Expr::Return(self0), Expr::Return(other0)) => self0 == other0, - #[cfg(feature = "full")] (Expr::Struct(self0), Expr::Struct(other0)) => self0 == other0, #[cfg(feature = "full")] (Expr::Try(self0), Expr::Try(other0)) => self0 == other0, @@ -560,10 +557,10 @@ impl PartialEq for ExprMatch { self.attrs == other.attrs && self.expr == other.expr && self.arms == other.arms } } -#[cfg(feature = "full")] +#[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Eq for ExprMethodCall {} -#[cfg(feature = "full")] +#[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl PartialEq for ExprMethodCall { fn eq(&self, other: &Self) -> bool { @@ -603,10 +600,10 @@ impl PartialEq for ExprRange { && self.limits == other.limits && self.end == other.end } } -#[cfg(feature = "full")] +#[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Eq for ExprReference {} -#[cfg(feature = "full")] +#[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl PartialEq for ExprReference { fn eq(&self, other: &Self) -> bool { @@ -634,10 +631,10 @@ impl PartialEq for ExprReturn { self.attrs == other.attrs && self.expr == other.expr } } -#[cfg(feature = "full")] +#[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Eq for ExprStruct {} -#[cfg(feature = "full")] +#[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl PartialEq for ExprStruct { fn eq(&self, other: &Self) -> bool { @@ -752,10 +749,10 @@ impl PartialEq for FieldPat { && self.colon_token == other.colon_token && self.pat == other.pat } } -#[cfg(feature = "full")] +#[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Eq for FieldValue {} -#[cfg(feature = "full")] +#[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl PartialEq for FieldValue { fn eq(&self, other: &Self) -> bool { diff --git a/third_party/rust/syn/src/gen/fold.rs b/third_party/rust/syn/src/gen/fold.rs index 8ea6c75fc92f0..6bd058b0d71d6 100644 --- a/third_party/rust/syn/src/gen/fold.rs +++ b/third_party/rust/syn/src/gen/fold.rs @@ -30,10 +30,12 @@ macro_rules! full { /// [module documentation]: self pub trait Fold { #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn fold_abi(&mut self, i: Abi) -> Abi { fold_abi(self, i) } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn fold_angle_bracketed_generic_arguments( &mut self, i: AngleBracketedGenericArguments, @@ -41,294 +43,367 @@ pub trait Fold { fold_angle_bracketed_generic_arguments(self, i) } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn fold_arm(&mut self, i: Arm) -> Arm { fold_arm(self, i) } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(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"))] + #[cfg_attr(doc_cfg, doc(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"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn fold_attr_style(&mut self, i: AttrStyle) -> AttrStyle { fold_attr_style(self, i) } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn fold_attribute(&mut self, i: Attribute) -> Attribute { fold_attribute(self, i) } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn fold_bare_fn_arg(&mut self, i: BareFnArg) -> BareFnArg { fold_bare_fn_arg(self, i) } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn fold_bare_variadic(&mut self, i: BareVariadic) -> BareVariadic { fold_bare_variadic(self, i) } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn fold_bin_op(&mut self, i: BinOp) -> BinOp { fold_bin_op(self, i) } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn fold_block(&mut self, i: Block) -> Block { fold_block(self, i) } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn fold_bound_lifetimes(&mut self, i: BoundLifetimes) -> BoundLifetimes { fold_bound_lifetimes(self, i) } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn fold_const_param(&mut self, i: ConstParam) -> ConstParam { fold_const_param(self, i) } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn fold_constraint(&mut self, i: Constraint) -> Constraint { fold_constraint(self, i) } #[cfg(feature = "derive")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "derive")))] fn fold_data(&mut self, i: Data) -> Data { fold_data(self, i) } #[cfg(feature = "derive")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "derive")))] fn fold_data_enum(&mut self, i: DataEnum) -> DataEnum { fold_data_enum(self, i) } #[cfg(feature = "derive")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "derive")))] fn fold_data_struct(&mut self, i: DataStruct) -> DataStruct { fold_data_struct(self, i) } #[cfg(feature = "derive")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "derive")))] fn fold_data_union(&mut self, i: DataUnion) -> DataUnion { fold_data_union(self, i) } #[cfg(feature = "derive")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "derive")))] fn fold_derive_input(&mut self, i: DeriveInput) -> DeriveInput { fold_derive_input(self, i) } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn fold_expr(&mut self, i: Expr) -> Expr { fold_expr(self, i) } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn fold_expr_array(&mut self, i: ExprArray) -> ExprArray { fold_expr_array(self, i) } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn fold_expr_assign(&mut self, i: ExprAssign) -> ExprAssign { fold_expr_assign(self, i) } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn fold_expr_async(&mut self, i: ExprAsync) -> ExprAsync { fold_expr_async(self, i) } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn fold_expr_await(&mut self, i: ExprAwait) -> ExprAwait { fold_expr_await(self, i) } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn fold_expr_binary(&mut self, i: ExprBinary) -> ExprBinary { fold_expr_binary(self, i) } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn fold_expr_block(&mut self, i: ExprBlock) -> ExprBlock { fold_expr_block(self, i) } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn fold_expr_break(&mut self, i: ExprBreak) -> ExprBreak { fold_expr_break(self, i) } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn fold_expr_call(&mut self, i: ExprCall) -> ExprCall { fold_expr_call(self, i) } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn fold_expr_cast(&mut self, i: ExprCast) -> ExprCast { fold_expr_cast(self, i) } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn fold_expr_closure(&mut self, i: ExprClosure) -> ExprClosure { fold_expr_closure(self, i) } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn fold_expr_const(&mut self, i: ExprConst) -> ExprConst { fold_expr_const(self, i) } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn fold_expr_continue(&mut self, i: ExprContinue) -> ExprContinue { fold_expr_continue(self, i) } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn fold_expr_field(&mut self, i: ExprField) -> ExprField { fold_expr_field(self, i) } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn fold_expr_for_loop(&mut self, i: ExprForLoop) -> ExprForLoop { fold_expr_for_loop(self, i) } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn fold_expr_group(&mut self, i: ExprGroup) -> ExprGroup { fold_expr_group(self, i) } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn fold_expr_if(&mut self, i: ExprIf) -> ExprIf { fold_expr_if(self, i) } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn fold_expr_index(&mut self, i: ExprIndex) -> ExprIndex { fold_expr_index(self, i) } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn fold_expr_infer(&mut self, i: ExprInfer) -> ExprInfer { fold_expr_infer(self, i) } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn fold_expr_let(&mut self, i: ExprLet) -> ExprLet { fold_expr_let(self, i) } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn fold_expr_lit(&mut self, i: ExprLit) -> ExprLit { fold_expr_lit(self, i) } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn fold_expr_loop(&mut self, i: ExprLoop) -> ExprLoop { fold_expr_loop(self, i) } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn fold_expr_macro(&mut self, i: ExprMacro) -> ExprMacro { fold_expr_macro(self, i) } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn fold_expr_match(&mut self, i: ExprMatch) -> ExprMatch { fold_expr_match(self, i) } - #[cfg(feature = "full")] + #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn fold_expr_method_call(&mut self, i: ExprMethodCall) -> ExprMethodCall { fold_expr_method_call(self, i) } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn fold_expr_paren(&mut self, i: ExprParen) -> ExprParen { fold_expr_paren(self, i) } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn fold_expr_path(&mut self, i: ExprPath) -> ExprPath { fold_expr_path(self, i) } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn fold_expr_range(&mut self, i: ExprRange) -> ExprRange { fold_expr_range(self, i) } - #[cfg(feature = "full")] + #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn fold_expr_reference(&mut self, i: ExprReference) -> ExprReference { fold_expr_reference(self, i) } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn fold_expr_repeat(&mut self, i: ExprRepeat) -> ExprRepeat { fold_expr_repeat(self, i) } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn fold_expr_return(&mut self, i: ExprReturn) -> ExprReturn { fold_expr_return(self, i) } - #[cfg(feature = "full")] + #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn fold_expr_struct(&mut self, i: ExprStruct) -> ExprStruct { fold_expr_struct(self, i) } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn fold_expr_try(&mut self, i: ExprTry) -> ExprTry { fold_expr_try(self, i) } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn fold_expr_try_block(&mut self, i: ExprTryBlock) -> ExprTryBlock { fold_expr_try_block(self, i) } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn fold_expr_tuple(&mut self, i: ExprTuple) -> ExprTuple { fold_expr_tuple(self, i) } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn fold_expr_unary(&mut self, i: ExprUnary) -> ExprUnary { fold_expr_unary(self, i) } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn fold_expr_unsafe(&mut self, i: ExprUnsafe) -> ExprUnsafe { fold_expr_unsafe(self, i) } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn fold_expr_while(&mut self, i: ExprWhile) -> ExprWhile { fold_expr_while(self, i) } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn fold_expr_yield(&mut self, i: ExprYield) -> ExprYield { fold_expr_yield(self, i) } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn fold_field(&mut self, i: Field) -> Field { fold_field(self, i) } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn fold_field_mutability(&mut self, i: FieldMutability) -> FieldMutability { fold_field_mutability(self, i) } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn fold_field_pat(&mut self, i: FieldPat) -> FieldPat { fold_field_pat(self, i) } - #[cfg(feature = "full")] + #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn fold_field_value(&mut self, i: FieldValue) -> FieldValue { fold_field_value(self, i) } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn fold_fields(&mut self, i: Fields) -> Fields { fold_fields(self, i) } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn fold_fields_named(&mut self, i: FieldsNamed) -> FieldsNamed { fold_fields_named(self, i) } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn fold_fields_unnamed(&mut self, i: FieldsUnnamed) -> FieldsUnnamed { fold_fields_unnamed(self, i) } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn fold_file(&mut self, i: File) -> File { fold_file(self, i) } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn fold_fn_arg(&mut self, i: FnArg) -> FnArg { fold_fn_arg(self, i) } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn fold_foreign_item(&mut self, i: ForeignItem) -> ForeignItem { fold_foreign_item(self, i) } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn fold_foreign_item_fn(&mut self, i: ForeignItemFn) -> ForeignItemFn { fold_foreign_item_fn(self, i) } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn fold_foreign_item_macro(&mut self, i: ForeignItemMacro) -> ForeignItemMacro { fold_foreign_item_macro(self, i) } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn fold_foreign_item_static(&mut self, i: ForeignItemStatic) -> ForeignItemStatic { fold_foreign_item_static(self, i) } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn fold_foreign_item_type(&mut self, i: ForeignItemType) -> ForeignItemType { fold_foreign_item_type(self, i) } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn fold_generic_argument(&mut self, i: GenericArgument) -> GenericArgument { fold_generic_argument(self, i) } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn fold_generic_param(&mut self, i: GenericParam) -> GenericParam { fold_generic_param(self, i) } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn fold_generics(&mut self, i: Generics) -> Generics { fold_generics(self, i) } @@ -336,98 +411,122 @@ pub trait Fold { fold_ident(self, i) } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn fold_impl_item(&mut self, i: ImplItem) -> ImplItem { fold_impl_item(self, i) } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn fold_impl_item_const(&mut self, i: ImplItemConst) -> ImplItemConst { fold_impl_item_const(self, i) } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn fold_impl_item_fn(&mut self, i: ImplItemFn) -> ImplItemFn { fold_impl_item_fn(self, i) } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn fold_impl_item_macro(&mut self, i: ImplItemMacro) -> ImplItemMacro { fold_impl_item_macro(self, i) } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn fold_impl_item_type(&mut self, i: ImplItemType) -> ImplItemType { fold_impl_item_type(self, i) } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn fold_impl_restriction(&mut self, i: ImplRestriction) -> ImplRestriction { fold_impl_restriction(self, i) } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn fold_index(&mut self, i: Index) -> Index { fold_index(self, i) } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn fold_item(&mut self, i: Item) -> Item { fold_item(self, i) } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn fold_item_const(&mut self, i: ItemConst) -> ItemConst { fold_item_const(self, i) } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn fold_item_enum(&mut self, i: ItemEnum) -> ItemEnum { fold_item_enum(self, i) } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn fold_item_extern_crate(&mut self, i: ItemExternCrate) -> ItemExternCrate { fold_item_extern_crate(self, i) } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn fold_item_fn(&mut self, i: ItemFn) -> ItemFn { fold_item_fn(self, i) } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn fold_item_foreign_mod(&mut self, i: ItemForeignMod) -> ItemForeignMod { fold_item_foreign_mod(self, i) } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn fold_item_impl(&mut self, i: ItemImpl) -> ItemImpl { fold_item_impl(self, i) } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn fold_item_macro(&mut self, i: ItemMacro) -> ItemMacro { fold_item_macro(self, i) } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn fold_item_mod(&mut self, i: ItemMod) -> ItemMod { fold_item_mod(self, i) } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn fold_item_static(&mut self, i: ItemStatic) -> ItemStatic { fold_item_static(self, i) } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn fold_item_struct(&mut self, i: ItemStruct) -> ItemStruct { fold_item_struct(self, i) } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn fold_item_trait(&mut self, i: ItemTrait) -> ItemTrait { fold_item_trait(self, i) } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn fold_item_trait_alias(&mut self, i: ItemTraitAlias) -> ItemTraitAlias { fold_item_trait_alias(self, i) } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn fold_item_type(&mut self, i: ItemType) -> ItemType { fold_item_type(self, i) } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn fold_item_union(&mut self, i: ItemUnion) -> ItemUnion { fold_item_union(self, i) } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn fold_item_use(&mut self, i: ItemUse) -> ItemUse { fold_item_use(self, i) } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn fold_label(&mut self, i: Label) -> Label { fold_label(self, i) } @@ -435,6 +534,7 @@ pub trait Fold { fold_lifetime(self, i) } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn fold_lifetime_param(&mut self, i: LifetimeParam) -> LifetimeParam { fold_lifetime_param(self, i) } @@ -463,38 +563,47 @@ pub trait Fold { fold_lit_str(self, i) } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn fold_local(&mut self, i: Local) -> Local { fold_local(self, i) } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn fold_local_init(&mut self, i: LocalInit) -> LocalInit { fold_local_init(self, i) } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn fold_macro(&mut self, i: Macro) -> Macro { fold_macro(self, i) } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn fold_macro_delimiter(&mut self, i: MacroDelimiter) -> MacroDelimiter { fold_macro_delimiter(self, i) } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn fold_member(&mut self, i: Member) -> Member { fold_member(self, i) } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn fold_meta(&mut self, i: Meta) -> Meta { fold_meta(self, i) } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn fold_meta_list(&mut self, i: MetaList) -> MetaList { fold_meta_list(self, i) } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn fold_meta_name_value(&mut self, i: MetaNameValue) -> MetaNameValue { fold_meta_name_value(self, i) } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn fold_parenthesized_generic_arguments( &mut self, i: ParenthesizedGenericArguments, @@ -502,90 +611,112 @@ pub trait Fold { fold_parenthesized_generic_arguments(self, i) } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn fold_pat(&mut self, i: Pat) -> Pat { fold_pat(self, i) } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn fold_pat_ident(&mut self, i: PatIdent) -> PatIdent { fold_pat_ident(self, i) } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn fold_pat_or(&mut self, i: PatOr) -> PatOr { fold_pat_or(self, i) } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn fold_pat_paren(&mut self, i: PatParen) -> PatParen { fold_pat_paren(self, i) } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn fold_pat_reference(&mut self, i: PatReference) -> PatReference { fold_pat_reference(self, i) } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn fold_pat_rest(&mut self, i: PatRest) -> PatRest { fold_pat_rest(self, i) } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn fold_pat_slice(&mut self, i: PatSlice) -> PatSlice { fold_pat_slice(self, i) } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn fold_pat_struct(&mut self, i: PatStruct) -> PatStruct { fold_pat_struct(self, i) } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn fold_pat_tuple(&mut self, i: PatTuple) -> PatTuple { fold_pat_tuple(self, i) } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn fold_pat_tuple_struct(&mut self, i: PatTupleStruct) -> PatTupleStruct { fold_pat_tuple_struct(self, i) } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn fold_pat_type(&mut self, i: PatType) -> PatType { fold_pat_type(self, i) } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn fold_pat_wild(&mut self, i: PatWild) -> PatWild { fold_pat_wild(self, i) } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn fold_path(&mut self, i: Path) -> Path { fold_path(self, i) } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn fold_path_arguments(&mut self, i: PathArguments) -> PathArguments { fold_path_arguments(self, i) } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn fold_path_segment(&mut self, i: PathSegment) -> PathSegment { fold_path_segment(self, i) } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn fold_predicate_lifetime(&mut self, i: PredicateLifetime) -> PredicateLifetime { fold_predicate_lifetime(self, i) } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn fold_predicate_type(&mut self, i: PredicateType) -> PredicateType { fold_predicate_type(self, i) } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn fold_qself(&mut self, i: QSelf) -> QSelf { fold_qself(self, i) } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn fold_range_limits(&mut self, i: RangeLimits) -> RangeLimits { fold_range_limits(self, i) } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn fold_receiver(&mut self, i: Receiver) -> Receiver { fold_receiver(self, i) } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn fold_return_type(&mut self, i: ReturnType) -> ReturnType { fold_return_type(self, i) } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn fold_signature(&mut self, i: Signature) -> Signature { fold_signature(self, i) } @@ -593,22 +724,27 @@ pub trait Fold { fold_span(self, i) } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn fold_static_mutability(&mut self, i: StaticMutability) -> StaticMutability { fold_static_mutability(self, i) } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn fold_stmt(&mut self, i: Stmt) -> Stmt { fold_stmt(self, i) } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn fold_stmt_macro(&mut self, i: StmtMacro) -> StmtMacro { fold_stmt_macro(self, i) } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn fold_trait_bound(&mut self, i: TraitBound) -> TraitBound { fold_trait_bound(self, i) } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn fold_trait_bound_modifier( &mut self, i: TraitBoundModifier, @@ -616,147 +752,183 @@ pub trait Fold { fold_trait_bound_modifier(self, i) } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn fold_trait_item(&mut self, i: TraitItem) -> TraitItem { fold_trait_item(self, i) } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn fold_trait_item_const(&mut self, i: TraitItemConst) -> TraitItemConst { fold_trait_item_const(self, i) } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn fold_trait_item_fn(&mut self, i: TraitItemFn) -> TraitItemFn { fold_trait_item_fn(self, i) } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn fold_trait_item_macro(&mut self, i: TraitItemMacro) -> TraitItemMacro { fold_trait_item_macro(self, i) } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn fold_trait_item_type(&mut self, i: TraitItemType) -> TraitItemType { fold_trait_item_type(self, i) } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn fold_type(&mut self, i: Type) -> Type { fold_type(self, i) } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn fold_type_array(&mut self, i: TypeArray) -> TypeArray { fold_type_array(self, i) } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn fold_type_bare_fn(&mut self, i: TypeBareFn) -> TypeBareFn { fold_type_bare_fn(self, i) } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn fold_type_group(&mut self, i: TypeGroup) -> TypeGroup { fold_type_group(self, i) } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn fold_type_impl_trait(&mut self, i: TypeImplTrait) -> TypeImplTrait { fold_type_impl_trait(self, i) } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn fold_type_infer(&mut self, i: TypeInfer) -> TypeInfer { fold_type_infer(self, i) } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn fold_type_macro(&mut self, i: TypeMacro) -> TypeMacro { fold_type_macro(self, i) } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn fold_type_never(&mut self, i: TypeNever) -> TypeNever { fold_type_never(self, i) } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn fold_type_param(&mut self, i: TypeParam) -> TypeParam { fold_type_param(self, i) } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn fold_type_param_bound(&mut self, i: TypeParamBound) -> TypeParamBound { fold_type_param_bound(self, i) } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn fold_type_paren(&mut self, i: TypeParen) -> TypeParen { fold_type_paren(self, i) } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn fold_type_path(&mut self, i: TypePath) -> TypePath { fold_type_path(self, i) } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn fold_type_ptr(&mut self, i: TypePtr) -> TypePtr { fold_type_ptr(self, i) } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn fold_type_reference(&mut self, i: TypeReference) -> TypeReference { fold_type_reference(self, i) } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn fold_type_slice(&mut self, i: TypeSlice) -> TypeSlice { fold_type_slice(self, i) } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn fold_type_trait_object(&mut self, i: TypeTraitObject) -> TypeTraitObject { fold_type_trait_object(self, i) } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn fold_type_tuple(&mut self, i: TypeTuple) -> TypeTuple { fold_type_tuple(self, i) } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn fold_un_op(&mut self, i: UnOp) -> UnOp { fold_un_op(self, i) } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn fold_use_glob(&mut self, i: UseGlob) -> UseGlob { fold_use_glob(self, i) } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn fold_use_group(&mut self, i: UseGroup) -> UseGroup { fold_use_group(self, i) } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn fold_use_name(&mut self, i: UseName) -> UseName { fold_use_name(self, i) } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn fold_use_path(&mut self, i: UsePath) -> UsePath { fold_use_path(self, i) } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn fold_use_rename(&mut self, i: UseRename) -> UseRename { fold_use_rename(self, i) } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn fold_use_tree(&mut self, i: UseTree) -> UseTree { fold_use_tree(self, i) } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn fold_variadic(&mut self, i: Variadic) -> Variadic { fold_variadic(self, i) } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn fold_variant(&mut self, i: Variant) -> Variant { fold_variant(self, i) } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn fold_vis_restricted(&mut self, i: VisRestricted) -> VisRestricted { fold_vis_restricted(self, i) } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn fold_visibility(&mut self, i: Visibility) -> Visibility { fold_visibility(self, i) } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn fold_where_clause(&mut self, i: WhereClause) -> WhereClause { fold_where_clause(self, i) } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn fold_where_predicate(&mut self, i: WherePredicate) -> WherePredicate { fold_where_predicate(self, i) } } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn fold_abi(f: &mut F, node: Abi) -> Abi where F: Fold + ?Sized, @@ -767,6 +939,7 @@ where } } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn fold_angle_bracketed_generic_arguments( f: &mut F, node: AngleBracketedGenericArguments, @@ -782,6 +955,7 @@ where } } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn fold_arm(f: &mut F, node: Arm) -> Arm where F: Fold + ?Sized, @@ -796,6 +970,7 @@ where } } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn fold_assoc_const(f: &mut F, node: AssocConst) -> AssocConst where F: Fold + ?Sized, @@ -808,6 +983,7 @@ where } } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn fold_assoc_type(f: &mut F, node: AssocType) -> AssocType where F: Fold + ?Sized, @@ -820,6 +996,7 @@ where } } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn fold_attr_style(f: &mut F, node: AttrStyle) -> AttrStyle where F: Fold + ?Sized, @@ -830,6 +1007,7 @@ where } } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn fold_attribute(f: &mut F, node: Attribute) -> Attribute where F: Fold + ?Sized, @@ -842,6 +1020,7 @@ where } } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn fold_bare_fn_arg(f: &mut F, node: BareFnArg) -> BareFnArg where F: Fold + ?Sized, @@ -853,6 +1032,7 @@ where } } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn fold_bare_variadic(f: &mut F, node: BareVariadic) -> BareVariadic where F: Fold + ?Sized, @@ -865,6 +1045,7 @@ where } } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn fold_bin_op(f: &mut F, node: BinOp) -> BinOp where F: Fold + ?Sized, @@ -901,6 +1082,7 @@ where } } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn fold_block(f: &mut F, node: Block) -> Block where F: Fold + ?Sized, @@ -911,6 +1093,7 @@ where } } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn fold_bound_lifetimes(f: &mut F, node: BoundLifetimes) -> BoundLifetimes where F: Fold + ?Sized, @@ -923,6 +1106,7 @@ where } } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn fold_const_param(f: &mut F, node: ConstParam) -> ConstParam where F: Fold + ?Sized, @@ -938,6 +1122,7 @@ where } } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn fold_constraint(f: &mut F, node: Constraint) -> Constraint where F: Fold + ?Sized, @@ -950,6 +1135,7 @@ where } } #[cfg(feature = "derive")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "derive")))] pub fn fold_data(f: &mut F, node: Data) -> Data where F: Fold + ?Sized, @@ -961,6 +1147,7 @@ where } } #[cfg(feature = "derive")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "derive")))] pub fn fold_data_enum(f: &mut F, node: DataEnum) -> DataEnum where F: Fold + ?Sized, @@ -972,6 +1159,7 @@ where } } #[cfg(feature = "derive")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "derive")))] pub fn fold_data_struct(f: &mut F, node: DataStruct) -> DataStruct where F: Fold + ?Sized, @@ -983,6 +1171,7 @@ where } } #[cfg(feature = "derive")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "derive")))] pub fn fold_data_union(f: &mut F, node: DataUnion) -> DataUnion where F: Fold + ?Sized, @@ -993,6 +1182,7 @@ where } } #[cfg(feature = "derive")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "derive")))] pub fn fold_derive_input(f: &mut F, node: DeriveInput) -> DeriveInput where F: Fold + ?Sized, @@ -1006,6 +1196,7 @@ where } } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn fold_expr(f: &mut F, node: Expr) -> Expr where F: Fold + ?Sized, @@ -1041,17 +1232,15 @@ where 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))) + Expr::MethodCall(f.fold_expr_method_call(_binding_0)) } Expr::Paren(_binding_0) => Expr::Paren(f.fold_expr_paren(_binding_0)), Expr::Path(_binding_0) => Expr::Path(f.fold_expr_path(_binding_0)), Expr::Range(_binding_0) => Expr::Range(full!(f.fold_expr_range(_binding_0))), - Expr::Reference(_binding_0) => { - Expr::Reference(full!(f.fold_expr_reference(_binding_0))) - } + Expr::Reference(_binding_0) => Expr::Reference(f.fold_expr_reference(_binding_0)), Expr::Repeat(_binding_0) => Expr::Repeat(full!(f.fold_expr_repeat(_binding_0))), Expr::Return(_binding_0) => Expr::Return(full!(f.fold_expr_return(_binding_0))), - Expr::Struct(_binding_0) => Expr::Struct(full!(f.fold_expr_struct(_binding_0))), + Expr::Struct(_binding_0) => Expr::Struct(f.fold_expr_struct(_binding_0)), Expr::Try(_binding_0) => Expr::Try(full!(f.fold_expr_try(_binding_0))), Expr::TryBlock(_binding_0) => { Expr::TryBlock(full!(f.fold_expr_try_block(_binding_0))) @@ -1065,6 +1254,7 @@ where } } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn fold_expr_array(f: &mut F, node: ExprArray) -> ExprArray where F: Fold + ?Sized, @@ -1076,6 +1266,7 @@ where } } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn fold_expr_assign(f: &mut F, node: ExprAssign) -> ExprAssign where F: Fold + ?Sized, @@ -1088,6 +1279,7 @@ where } } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn fold_expr_async(f: &mut F, node: ExprAsync) -> ExprAsync where F: Fold + ?Sized, @@ -1100,6 +1292,7 @@ where } } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn fold_expr_await(f: &mut F, node: ExprAwait) -> ExprAwait where F: Fold + ?Sized, @@ -1112,6 +1305,7 @@ where } } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn fold_expr_binary(f: &mut F, node: ExprBinary) -> ExprBinary where F: Fold + ?Sized, @@ -1124,6 +1318,7 @@ where } } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn fold_expr_block(f: &mut F, node: ExprBlock) -> ExprBlock where F: Fold + ?Sized, @@ -1135,6 +1330,7 @@ where } } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn fold_expr_break(f: &mut F, node: ExprBreak) -> ExprBreak where F: Fold + ?Sized, @@ -1147,6 +1343,7 @@ where } } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn fold_expr_call(f: &mut F, node: ExprCall) -> ExprCall where F: Fold + ?Sized, @@ -1159,6 +1356,7 @@ where } } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn fold_expr_cast(f: &mut F, node: ExprCast) -> ExprCast where F: Fold + ?Sized, @@ -1171,6 +1369,7 @@ where } } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn fold_expr_closure(f: &mut F, node: ExprClosure) -> ExprClosure where F: Fold + ?Sized, @@ -1190,6 +1389,7 @@ where } } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn fold_expr_const(f: &mut F, node: ExprConst) -> ExprConst where F: Fold + ?Sized, @@ -1201,6 +1401,7 @@ where } } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn fold_expr_continue(f: &mut F, node: ExprContinue) -> ExprContinue where F: Fold + ?Sized, @@ -1212,6 +1413,7 @@ where } } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn fold_expr_field(f: &mut F, node: ExprField) -> ExprField where F: Fold + ?Sized, @@ -1224,6 +1426,7 @@ where } } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn fold_expr_for_loop(f: &mut F, node: ExprForLoop) -> ExprForLoop where F: Fold + ?Sized, @@ -1239,6 +1442,7 @@ where } } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn fold_expr_group(f: &mut F, node: ExprGroup) -> ExprGroup where F: Fold + ?Sized, @@ -1250,6 +1454,7 @@ where } } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn fold_expr_if(f: &mut F, node: ExprIf) -> ExprIf where F: Fold + ?Sized, @@ -1264,6 +1469,7 @@ where } } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn fold_expr_index(f: &mut F, node: ExprIndex) -> ExprIndex where F: Fold + ?Sized, @@ -1276,6 +1482,7 @@ where } } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn fold_expr_infer(f: &mut F, node: ExprInfer) -> ExprInfer where F: Fold + ?Sized, @@ -1286,6 +1493,7 @@ where } } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn fold_expr_let(f: &mut F, node: ExprLet) -> ExprLet where F: Fold + ?Sized, @@ -1299,6 +1507,7 @@ where } } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn fold_expr_lit(f: &mut F, node: ExprLit) -> ExprLit where F: Fold + ?Sized, @@ -1309,6 +1518,7 @@ where } } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn fold_expr_loop(f: &mut F, node: ExprLoop) -> ExprLoop where F: Fold + ?Sized, @@ -1321,6 +1531,7 @@ where } } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn fold_expr_macro(f: &mut F, node: ExprMacro) -> ExprMacro where F: Fold + ?Sized, @@ -1331,6 +1542,7 @@ where } } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn fold_expr_match(f: &mut F, node: ExprMatch) -> ExprMatch where F: Fold + ?Sized, @@ -1343,7 +1555,8 @@ where arms: FoldHelper::lift(node.arms, |it| f.fold_arm(it)), } } -#[cfg(feature = "full")] +#[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn fold_expr_method_call(f: &mut F, node: ExprMethodCall) -> ExprMethodCall where F: Fold + ?Sized, @@ -1360,6 +1573,7 @@ where } } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn fold_expr_paren(f: &mut F, node: ExprParen) -> ExprParen where F: Fold + ?Sized, @@ -1371,6 +1585,7 @@ where } } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn fold_expr_path(f: &mut F, node: ExprPath) -> ExprPath where F: Fold + ?Sized, @@ -1382,6 +1597,7 @@ where } } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn fold_expr_range(f: &mut F, node: ExprRange) -> ExprRange where F: Fold + ?Sized, @@ -1393,7 +1609,8 @@ where end: (node.end).map(|it| Box::new(f.fold_expr(*it))), } } -#[cfg(feature = "full")] +#[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn fold_expr_reference(f: &mut F, node: ExprReference) -> ExprReference where F: Fold + ?Sized, @@ -1406,6 +1623,7 @@ where } } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn fold_expr_repeat(f: &mut F, node: ExprRepeat) -> ExprRepeat where F: Fold + ?Sized, @@ -1419,6 +1637,7 @@ where } } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn fold_expr_return(f: &mut F, node: ExprReturn) -> ExprReturn where F: Fold + ?Sized, @@ -1429,7 +1648,8 @@ where expr: (node.expr).map(|it| Box::new(f.fold_expr(*it))), } } -#[cfg(feature = "full")] +#[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn fold_expr_struct(f: &mut F, node: ExprStruct) -> ExprStruct where F: Fold + ?Sized, @@ -1445,6 +1665,7 @@ where } } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn fold_expr_try(f: &mut F, node: ExprTry) -> ExprTry where F: Fold + ?Sized, @@ -1456,6 +1677,7 @@ where } } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn fold_expr_try_block(f: &mut F, node: ExprTryBlock) -> ExprTryBlock where F: Fold + ?Sized, @@ -1467,6 +1689,7 @@ where } } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn fold_expr_tuple(f: &mut F, node: ExprTuple) -> ExprTuple where F: Fold + ?Sized, @@ -1478,6 +1701,7 @@ where } } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn fold_expr_unary(f: &mut F, node: ExprUnary) -> ExprUnary where F: Fold + ?Sized, @@ -1489,6 +1713,7 @@ where } } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn fold_expr_unsafe(f: &mut F, node: ExprUnsafe) -> ExprUnsafe where F: Fold + ?Sized, @@ -1500,6 +1725,7 @@ where } } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn fold_expr_while(f: &mut F, node: ExprWhile) -> ExprWhile where F: Fold + ?Sized, @@ -1513,6 +1739,7 @@ where } } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn fold_expr_yield(f: &mut F, node: ExprYield) -> ExprYield where F: Fold + ?Sized, @@ -1524,6 +1751,7 @@ where } } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn fold_field(f: &mut F, node: Field) -> Field where F: Fold + ?Sized, @@ -1538,6 +1766,7 @@ where } } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn fold_field_mutability(f: &mut F, node: FieldMutability) -> FieldMutability where F: Fold + ?Sized, @@ -1547,6 +1776,7 @@ where } } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn fold_field_pat(f: &mut F, node: FieldPat) -> FieldPat where F: Fold + ?Sized, @@ -1558,7 +1788,8 @@ where pat: Box::new(f.fold_pat(*node.pat)), } } -#[cfg(feature = "full")] +#[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn fold_field_value(f: &mut F, node: FieldValue) -> FieldValue where F: Fold + ?Sized, @@ -1571,6 +1802,7 @@ where } } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn fold_fields(f: &mut F, node: Fields) -> Fields where F: Fold + ?Sized, @@ -1582,6 +1814,7 @@ where } } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn fold_fields_named(f: &mut F, node: FieldsNamed) -> FieldsNamed where F: Fold + ?Sized, @@ -1592,6 +1825,7 @@ where } } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn fold_fields_unnamed(f: &mut F, node: FieldsUnnamed) -> FieldsUnnamed where F: Fold + ?Sized, @@ -1602,6 +1836,7 @@ where } } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn fold_file(f: &mut F, node: File) -> File where F: Fold + ?Sized, @@ -1613,6 +1848,7 @@ where } } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn fold_fn_arg(f: &mut F, node: FnArg) -> FnArg where F: Fold + ?Sized, @@ -1623,6 +1859,7 @@ where } } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn fold_foreign_item(f: &mut F, node: ForeignItem) -> ForeignItem where F: Fold + ?Sized, @@ -1644,6 +1881,7 @@ where } } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn fold_foreign_item_fn(f: &mut F, node: ForeignItemFn) -> ForeignItemFn where F: Fold + ?Sized, @@ -1656,6 +1894,7 @@ where } } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn fold_foreign_item_macro(f: &mut F, node: ForeignItemMacro) -> ForeignItemMacro where F: Fold + ?Sized, @@ -1667,6 +1906,7 @@ where } } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn fold_foreign_item_static( f: &mut F, node: ForeignItemStatic, @@ -1686,6 +1926,7 @@ where } } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn fold_foreign_item_type(f: &mut F, node: ForeignItemType) -> ForeignItemType where F: Fold + ?Sized, @@ -1700,6 +1941,7 @@ where } } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn fold_generic_argument(f: &mut F, node: GenericArgument) -> GenericArgument where F: Fold + ?Sized, @@ -1726,6 +1968,7 @@ where } } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn fold_generic_param(f: &mut F, node: GenericParam) -> GenericParam where F: Fold + ?Sized, @@ -1743,6 +1986,7 @@ where } } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn fold_generics(f: &mut F, node: Generics) -> Generics where F: Fold + ?Sized, @@ -1764,6 +2008,7 @@ where node } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn fold_impl_item(f: &mut F, node: ImplItem) -> ImplItem where F: Fold + ?Sized, @@ -1781,6 +2026,7 @@ where } } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn fold_impl_item_const(f: &mut F, node: ImplItemConst) -> ImplItemConst where F: Fold + ?Sized, @@ -1800,6 +2046,7 @@ where } } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn fold_impl_item_fn(f: &mut F, node: ImplItemFn) -> ImplItemFn where F: Fold + ?Sized, @@ -1813,6 +2060,7 @@ where } } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn fold_impl_item_macro(f: &mut F, node: ImplItemMacro) -> ImplItemMacro where F: Fold + ?Sized, @@ -1824,6 +2072,7 @@ where } } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn fold_impl_item_type(f: &mut F, node: ImplItemType) -> ImplItemType where F: Fold + ?Sized, @@ -1841,6 +2090,7 @@ where } } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn fold_impl_restriction(f: &mut F, node: ImplRestriction) -> ImplRestriction where F: Fold + ?Sized, @@ -1848,6 +2098,7 @@ where match node {} } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn fold_index(f: &mut F, node: Index) -> Index where F: Fold + ?Sized, @@ -1858,6 +2109,7 @@ where } } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn fold_item(f: &mut F, node: Item) -> Item where F: Fold + ?Sized, @@ -1888,6 +2140,7 @@ where } } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn fold_item_const(f: &mut F, node: ItemConst) -> ItemConst where F: Fold + ?Sized, @@ -1906,6 +2159,7 @@ where } } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn fold_item_enum(f: &mut F, node: ItemEnum) -> ItemEnum where F: Fold + ?Sized, @@ -1921,6 +2175,7 @@ where } } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn fold_item_extern_crate(f: &mut F, node: ItemExternCrate) -> ItemExternCrate where F: Fold + ?Sized, @@ -1936,6 +2191,7 @@ where } } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn fold_item_fn(f: &mut F, node: ItemFn) -> ItemFn where F: Fold + ?Sized, @@ -1948,6 +2204,7 @@ where } } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn fold_item_foreign_mod(f: &mut F, node: ItemForeignMod) -> ItemForeignMod where F: Fold + ?Sized, @@ -1961,6 +2218,7 @@ where } } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn fold_item_impl(f: &mut F, node: ItemImpl) -> ItemImpl where F: Fold + ?Sized, @@ -1978,6 +2236,7 @@ where } } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn fold_item_macro(f: &mut F, node: ItemMacro) -> ItemMacro where F: Fold + ?Sized, @@ -1990,6 +2249,7 @@ where } } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn fold_item_mod(f: &mut F, node: ItemMod) -> ItemMod where F: Fold + ?Sized, @@ -2006,6 +2266,7 @@ where } } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn fold_item_static(f: &mut F, node: ItemStatic) -> ItemStatic where F: Fold + ?Sized, @@ -2024,6 +2285,7 @@ where } } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn fold_item_struct(f: &mut F, node: ItemStruct) -> ItemStruct where F: Fold + ?Sized, @@ -2039,6 +2301,7 @@ where } } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn fold_item_trait(f: &mut F, node: ItemTrait) -> ItemTrait where F: Fold + ?Sized, @@ -2062,6 +2325,7 @@ where } } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn fold_item_trait_alias(f: &mut F, node: ItemTraitAlias) -> ItemTraitAlias where F: Fold + ?Sized, @@ -2078,6 +2342,7 @@ where } } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn fold_item_type(f: &mut F, node: ItemType) -> ItemType where F: Fold + ?Sized, @@ -2094,6 +2359,7 @@ where } } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn fold_item_union(f: &mut F, node: ItemUnion) -> ItemUnion where F: Fold + ?Sized, @@ -2108,6 +2374,7 @@ where } } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn fold_item_use(f: &mut F, node: ItemUse) -> ItemUse where F: Fold + ?Sized, @@ -2122,6 +2389,7 @@ where } } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn fold_label(f: &mut F, node: Label) -> Label where F: Fold + ?Sized, @@ -2141,6 +2409,7 @@ where } } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn fold_lifetime_param(f: &mut F, node: LifetimeParam) -> LifetimeParam where F: Fold + ?Sized, @@ -2231,6 +2500,7 @@ where node } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn fold_local(f: &mut F, node: Local) -> Local where F: Fold + ?Sized, @@ -2244,6 +2514,7 @@ where } } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn fold_local_init(f: &mut F, node: LocalInit) -> LocalInit where F: Fold + ?Sized, @@ -2255,6 +2526,7 @@ where } } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn fold_macro(f: &mut F, node: Macro) -> Macro where F: Fold + ?Sized, @@ -2267,6 +2539,7 @@ where } } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn fold_macro_delimiter(f: &mut F, node: MacroDelimiter) -> MacroDelimiter where F: Fold + ?Sized, @@ -2278,6 +2551,7 @@ where } } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn fold_member(f: &mut F, node: Member) -> Member where F: Fold + ?Sized, @@ -2288,6 +2562,7 @@ where } } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn fold_meta(f: &mut F, node: Meta) -> Meta where F: Fold + ?Sized, @@ -2301,6 +2576,7 @@ where } } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn fold_meta_list(f: &mut F, node: MetaList) -> MetaList where F: Fold + ?Sized, @@ -2312,6 +2588,7 @@ where } } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn fold_meta_name_value(f: &mut F, node: MetaNameValue) -> MetaNameValue where F: Fold + ?Sized, @@ -2323,6 +2600,7 @@ where } } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn fold_parenthesized_generic_arguments( f: &mut F, node: ParenthesizedGenericArguments, @@ -2337,6 +2615,7 @@ where } } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn fold_pat(f: &mut F, node: Pat) -> Pat where F: Fold + ?Sized, @@ -2364,6 +2643,7 @@ where } } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn fold_pat_ident(f: &mut F, node: PatIdent) -> PatIdent where F: Fold + ?Sized, @@ -2377,6 +2657,7 @@ where } } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn fold_pat_or(f: &mut F, node: PatOr) -> PatOr where F: Fold + ?Sized, @@ -2388,6 +2669,7 @@ where } } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn fold_pat_paren(f: &mut F, node: PatParen) -> PatParen where F: Fold + ?Sized, @@ -2399,6 +2681,7 @@ where } } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn fold_pat_reference(f: &mut F, node: PatReference) -> PatReference where F: Fold + ?Sized, @@ -2411,6 +2694,7 @@ where } } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn fold_pat_rest(f: &mut F, node: PatRest) -> PatRest where F: Fold + ?Sized, @@ -2421,6 +2705,7 @@ where } } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn fold_pat_slice(f: &mut F, node: PatSlice) -> PatSlice where F: Fold + ?Sized, @@ -2432,6 +2717,7 @@ where } } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn fold_pat_struct(f: &mut F, node: PatStruct) -> PatStruct where F: Fold + ?Sized, @@ -2446,6 +2732,7 @@ where } } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn fold_pat_tuple(f: &mut F, node: PatTuple) -> PatTuple where F: Fold + ?Sized, @@ -2457,6 +2744,7 @@ where } } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn fold_pat_tuple_struct(f: &mut F, node: PatTupleStruct) -> PatTupleStruct where F: Fold + ?Sized, @@ -2470,6 +2758,7 @@ where } } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn fold_pat_type(f: &mut F, node: PatType) -> PatType where F: Fold + ?Sized, @@ -2482,6 +2771,7 @@ where } } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn fold_pat_wild(f: &mut F, node: PatWild) -> PatWild where F: Fold + ?Sized, @@ -2492,6 +2782,7 @@ where } } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn fold_path(f: &mut F, node: Path) -> Path where F: Fold + ?Sized, @@ -2502,6 +2793,7 @@ where } } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn fold_path_arguments(f: &mut F, node: PathArguments) -> PathArguments where F: Fold + ?Sized, @@ -2521,6 +2813,7 @@ where } } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn fold_path_segment(f: &mut F, node: PathSegment) -> PathSegment where F: Fold + ?Sized, @@ -2531,6 +2824,7 @@ where } } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn fold_predicate_lifetime( f: &mut F, node: PredicateLifetime, @@ -2545,6 +2839,7 @@ where } } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn fold_predicate_type(f: &mut F, node: PredicateType) -> PredicateType where F: Fold + ?Sized, @@ -2557,6 +2852,7 @@ where } } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn fold_qself(f: &mut F, node: QSelf) -> QSelf where F: Fold + ?Sized, @@ -2570,6 +2866,7 @@ where } } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn fold_range_limits(f: &mut F, node: RangeLimits) -> RangeLimits where F: Fold + ?Sized, @@ -2580,6 +2877,7 @@ where } } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn fold_receiver(f: &mut F, node: Receiver) -> Receiver where F: Fold + ?Sized, @@ -2595,6 +2893,7 @@ where } } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn fold_return_type(f: &mut F, node: ReturnType) -> ReturnType where F: Fold + ?Sized, @@ -2607,6 +2906,7 @@ where } } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn fold_signature(f: &mut F, node: Signature) -> Signature where F: Fold + ?Sized, @@ -2632,6 +2932,7 @@ where node } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn fold_static_mutability(f: &mut F, node: StaticMutability) -> StaticMutability where F: Fold + ?Sized, @@ -2642,6 +2943,7 @@ where } } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn fold_stmt(f: &mut F, node: Stmt) -> Stmt where F: Fold + ?Sized, @@ -2656,6 +2958,7 @@ where } } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn fold_stmt_macro(f: &mut F, node: StmtMacro) -> StmtMacro where F: Fold + ?Sized, @@ -2667,6 +2970,7 @@ where } } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn fold_trait_bound(f: &mut F, node: TraitBound) -> TraitBound where F: Fold + ?Sized, @@ -2679,6 +2983,7 @@ where } } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn fold_trait_bound_modifier( f: &mut F, node: TraitBoundModifier, @@ -2692,6 +2997,7 @@ where } } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn fold_trait_item(f: &mut F, node: TraitItem) -> TraitItem where F: Fold + ?Sized, @@ -2711,6 +3017,7 @@ where } } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn fold_trait_item_const(f: &mut F, node: TraitItemConst) -> TraitItemConst where F: Fold + ?Sized, @@ -2727,6 +3034,7 @@ where } } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn fold_trait_item_fn(f: &mut F, node: TraitItemFn) -> TraitItemFn where F: Fold + ?Sized, @@ -2739,6 +3047,7 @@ where } } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn fold_trait_item_macro(f: &mut F, node: TraitItemMacro) -> TraitItemMacro where F: Fold + ?Sized, @@ -2750,6 +3059,7 @@ where } } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn fold_trait_item_type(f: &mut F, node: TraitItemType) -> TraitItemType where F: Fold + ?Sized, @@ -2766,6 +3076,7 @@ where } } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn fold_type(f: &mut F, node: Type) -> Type where F: Fold + ?Sized, @@ -2793,6 +3104,7 @@ where } } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn fold_type_array(f: &mut F, node: TypeArray) -> TypeArray where F: Fold + ?Sized, @@ -2805,6 +3117,7 @@ where } } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn fold_type_bare_fn(f: &mut F, node: TypeBareFn) -> TypeBareFn where F: Fold + ?Sized, @@ -2821,6 +3134,7 @@ where } } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn fold_type_group(f: &mut F, node: TypeGroup) -> TypeGroup where F: Fold + ?Sized, @@ -2831,6 +3145,7 @@ where } } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn fold_type_impl_trait(f: &mut F, node: TypeImplTrait) -> TypeImplTrait where F: Fold + ?Sized, @@ -2841,6 +3156,7 @@ where } } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn fold_type_infer(f: &mut F, node: TypeInfer) -> TypeInfer where F: Fold + ?Sized, @@ -2850,6 +3166,7 @@ where } } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn fold_type_macro(f: &mut F, node: TypeMacro) -> TypeMacro where F: Fold + ?Sized, @@ -2859,6 +3176,7 @@ where } } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn fold_type_never(f: &mut F, node: TypeNever) -> TypeNever where F: Fold + ?Sized, @@ -2868,6 +3186,7 @@ where } } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn fold_type_param(f: &mut F, node: TypeParam) -> TypeParam where F: Fold + ?Sized, @@ -2882,6 +3201,7 @@ where } } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn fold_type_param_bound(f: &mut F, node: TypeParamBound) -> TypeParamBound where F: Fold + ?Sized, @@ -2897,6 +3217,7 @@ where } } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn fold_type_paren(f: &mut F, node: TypeParen) -> TypeParen where F: Fold + ?Sized, @@ -2907,6 +3228,7 @@ where } } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn fold_type_path(f: &mut F, node: TypePath) -> TypePath where F: Fold + ?Sized, @@ -2917,6 +3239,7 @@ where } } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn fold_type_ptr(f: &mut F, node: TypePtr) -> TypePtr where F: Fold + ?Sized, @@ -2929,6 +3252,7 @@ where } } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn fold_type_reference(f: &mut F, node: TypeReference) -> TypeReference where F: Fold + ?Sized, @@ -2941,6 +3265,7 @@ where } } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn fold_type_slice(f: &mut F, node: TypeSlice) -> TypeSlice where F: Fold + ?Sized, @@ -2951,6 +3276,7 @@ where } } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn fold_type_trait_object(f: &mut F, node: TypeTraitObject) -> TypeTraitObject where F: Fold + ?Sized, @@ -2961,6 +3287,7 @@ where } } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn fold_type_tuple(f: &mut F, node: TypeTuple) -> TypeTuple where F: Fold + ?Sized, @@ -2971,6 +3298,7 @@ where } } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn fold_un_op(f: &mut F, node: UnOp) -> UnOp where F: Fold + ?Sized, @@ -2982,6 +3310,7 @@ where } } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn fold_use_glob(f: &mut F, node: UseGlob) -> UseGlob where F: Fold + ?Sized, @@ -2991,6 +3320,7 @@ where } } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn fold_use_group(f: &mut F, node: UseGroup) -> UseGroup where F: Fold + ?Sized, @@ -3001,6 +3331,7 @@ where } } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn fold_use_name(f: &mut F, node: UseName) -> UseName where F: Fold + ?Sized, @@ -3010,6 +3341,7 @@ where } } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn fold_use_path(f: &mut F, node: UsePath) -> UsePath where F: Fold + ?Sized, @@ -3021,6 +3353,7 @@ where } } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn fold_use_rename(f: &mut F, node: UseRename) -> UseRename where F: Fold + ?Sized, @@ -3032,6 +3365,7 @@ where } } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn fold_use_tree(f: &mut F, node: UseTree) -> UseTree where F: Fold + ?Sized, @@ -3045,6 +3379,7 @@ where } } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn fold_variadic(f: &mut F, node: Variadic) -> Variadic where F: Fold + ?Sized, @@ -3057,6 +3392,7 @@ where } } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn fold_variant(f: &mut F, node: Variant) -> Variant where F: Fold + ?Sized, @@ -3069,6 +3405,7 @@ where } } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn fold_vis_restricted(f: &mut F, node: VisRestricted) -> VisRestricted where F: Fold + ?Sized, @@ -3081,6 +3418,7 @@ where } } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn fold_visibility(f: &mut F, node: Visibility) -> Visibility where F: Fold + ?Sized, @@ -3094,6 +3432,7 @@ where } } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn fold_where_clause(f: &mut F, node: WhereClause) -> WhereClause where F: Fold + ?Sized, @@ -3104,6 +3443,7 @@ where } } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn fold_where_predicate(f: &mut F, node: WherePredicate) -> WherePredicate where F: Fold + ?Sized, diff --git a/third_party/rust/syn/src/gen/hash.rs b/third_party/rust/syn/src/gen/hash.rs index 40dfc57f3024b..1c753419aa312 100644 --- a/third_party/rust/syn/src/gen/hash.rs +++ b/third_party/rust/syn/src/gen/hash.rs @@ -440,7 +440,6 @@ impl Hash for Expr { state.write_u8(22u8); v0.hash(state); } - #[cfg(feature = "full")] Expr::MethodCall(v0) => { state.write_u8(23u8); v0.hash(state); @@ -458,7 +457,6 @@ impl Hash for Expr { state.write_u8(26u8); v0.hash(state); } - #[cfg(feature = "full")] Expr::Reference(v0) => { state.write_u8(27u8); v0.hash(state); @@ -473,7 +471,6 @@ impl Hash for Expr { state.write_u8(29u8); v0.hash(state); } - #[cfg(feature = "full")] Expr::Struct(v0) => { state.write_u8(30u8); v0.hash(state); @@ -798,7 +795,7 @@ impl Hash for ExprMatch { self.arms.hash(state); } } -#[cfg(feature = "full")] +#[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Hash for ExprMethodCall { fn hash(&self, state: &mut H) @@ -848,7 +845,7 @@ impl Hash for ExprRange { self.end.hash(state); } } -#[cfg(feature = "full")] +#[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Hash for ExprReference { fn hash(&self, state: &mut H) @@ -883,7 +880,7 @@ impl Hash for ExprReturn { self.expr.hash(state); } } -#[cfg(feature = "full")] +#[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Hash for ExprStruct { fn hash(&self, state: &mut H) @@ -1020,7 +1017,7 @@ impl Hash for FieldPat { self.pat.hash(state); } } -#[cfg(feature = "full")] +#[cfg(any(feature = "derive", feature = "full"))] #[cfg_attr(doc_cfg, doc(cfg(feature = "extra-traits")))] impl Hash for FieldValue { fn hash(&self, state: &mut H) diff --git a/third_party/rust/syn/src/gen/visit.rs b/third_party/rust/syn/src/gen/visit.rs index fe81fb63ced08..572e0ad952721 100644 --- a/third_party/rust/syn/src/gen/visit.rs +++ b/third_party/rust/syn/src/gen/visit.rs @@ -29,10 +29,12 @@ macro_rules! skip { /// [module documentation]: self pub trait Visit<'ast> { #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_abi(&mut self, i: &'ast Abi) { visit_abi(self, i); } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_angle_bracketed_generic_arguments( &mut self, i: &'ast AngleBracketedGenericArguments, @@ -40,294 +42,367 @@ pub trait Visit<'ast> { visit_angle_bracketed_generic_arguments(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_arm(&mut self, i: &'ast Arm) { visit_arm(self, i); } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(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"))] + #[cfg_attr(doc_cfg, doc(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"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_attr_style(&mut self, i: &'ast AttrStyle) { visit_attr_style(self, i); } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_attribute(&mut self, i: &'ast Attribute) { visit_attribute(self, i); } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_bare_fn_arg(&mut self, i: &'ast BareFnArg) { visit_bare_fn_arg(self, i); } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_bare_variadic(&mut self, i: &'ast BareVariadic) { visit_bare_variadic(self, i); } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_bin_op(&mut self, i: &'ast BinOp) { visit_bin_op(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_block(&mut self, i: &'ast Block) { visit_block(self, i); } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_bound_lifetimes(&mut self, i: &'ast BoundLifetimes) { visit_bound_lifetimes(self, i); } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_const_param(&mut self, i: &'ast ConstParam) { visit_const_param(self, i); } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_constraint(&mut self, i: &'ast Constraint) { visit_constraint(self, i); } #[cfg(feature = "derive")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "derive")))] fn visit_data(&mut self, i: &'ast Data) { visit_data(self, i); } #[cfg(feature = "derive")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "derive")))] fn visit_data_enum(&mut self, i: &'ast DataEnum) { visit_data_enum(self, i); } #[cfg(feature = "derive")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "derive")))] fn visit_data_struct(&mut self, i: &'ast DataStruct) { visit_data_struct(self, i); } #[cfg(feature = "derive")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "derive")))] fn visit_data_union(&mut self, i: &'ast DataUnion) { visit_data_union(self, i); } #[cfg(feature = "derive")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "derive")))] fn visit_derive_input(&mut self, i: &'ast DeriveInput) { visit_derive_input(self, i); } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_expr(&mut self, i: &'ast Expr) { visit_expr(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_expr_array(&mut self, i: &'ast ExprArray) { visit_expr_array(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_expr_assign(&mut self, i: &'ast ExprAssign) { visit_expr_assign(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_expr_async(&mut self, i: &'ast ExprAsync) { visit_expr_async(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_expr_await(&mut self, i: &'ast ExprAwait) { visit_expr_await(self, i); } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_expr_binary(&mut self, i: &'ast ExprBinary) { visit_expr_binary(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_expr_block(&mut self, i: &'ast ExprBlock) { visit_expr_block(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_expr_break(&mut self, i: &'ast ExprBreak) { visit_expr_break(self, i); } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_expr_call(&mut self, i: &'ast ExprCall) { visit_expr_call(self, i); } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_expr_cast(&mut self, i: &'ast ExprCast) { visit_expr_cast(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_expr_closure(&mut self, i: &'ast ExprClosure) { visit_expr_closure(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_expr_const(&mut self, i: &'ast ExprConst) { visit_expr_const(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_expr_continue(&mut self, i: &'ast ExprContinue) { visit_expr_continue(self, i); } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_expr_field(&mut self, i: &'ast ExprField) { visit_expr_field(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_expr_for_loop(&mut self, i: &'ast ExprForLoop) { visit_expr_for_loop(self, i); } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_expr_group(&mut self, i: &'ast ExprGroup) { visit_expr_group(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_expr_if(&mut self, i: &'ast ExprIf) { visit_expr_if(self, i); } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_expr_index(&mut self, i: &'ast ExprIndex) { visit_expr_index(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_expr_infer(&mut self, i: &'ast ExprInfer) { visit_expr_infer(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_expr_let(&mut self, i: &'ast ExprLet) { visit_expr_let(self, i); } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_expr_lit(&mut self, i: &'ast ExprLit) { visit_expr_lit(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_expr_loop(&mut self, i: &'ast ExprLoop) { visit_expr_loop(self, i); } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_expr_macro(&mut self, i: &'ast ExprMacro) { visit_expr_macro(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_expr_match(&mut self, i: &'ast ExprMatch) { visit_expr_match(self, i); } - #[cfg(feature = "full")] + #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_expr_method_call(&mut self, i: &'ast ExprMethodCall) { visit_expr_method_call(self, i); } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_expr_paren(&mut self, i: &'ast ExprParen) { visit_expr_paren(self, i); } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_expr_path(&mut self, i: &'ast ExprPath) { visit_expr_path(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_expr_range(&mut self, i: &'ast ExprRange) { visit_expr_range(self, i); } - #[cfg(feature = "full")] + #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_expr_reference(&mut self, i: &'ast ExprReference) { visit_expr_reference(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_expr_repeat(&mut self, i: &'ast ExprRepeat) { visit_expr_repeat(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_expr_return(&mut self, i: &'ast ExprReturn) { visit_expr_return(self, i); } - #[cfg(feature = "full")] + #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_expr_struct(&mut self, i: &'ast ExprStruct) { visit_expr_struct(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_expr_try(&mut self, i: &'ast ExprTry) { visit_expr_try(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_expr_try_block(&mut self, i: &'ast ExprTryBlock) { visit_expr_try_block(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_expr_tuple(&mut self, i: &'ast ExprTuple) { visit_expr_tuple(self, i); } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_expr_unary(&mut self, i: &'ast ExprUnary) { visit_expr_unary(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_expr_unsafe(&mut self, i: &'ast ExprUnsafe) { visit_expr_unsafe(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_expr_while(&mut self, i: &'ast ExprWhile) { visit_expr_while(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_expr_yield(&mut self, i: &'ast ExprYield) { visit_expr_yield(self, i); } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_field(&mut self, i: &'ast Field) { visit_field(self, i); } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_field_mutability(&mut self, i: &'ast FieldMutability) { visit_field_mutability(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_field_pat(&mut self, i: &'ast FieldPat) { visit_field_pat(self, i); } - #[cfg(feature = "full")] + #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_field_value(&mut self, i: &'ast FieldValue) { visit_field_value(self, i); } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_fields(&mut self, i: &'ast Fields) { visit_fields(self, i); } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_fields_named(&mut self, i: &'ast FieldsNamed) { visit_fields_named(self, i); } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_fields_unnamed(&mut self, i: &'ast FieldsUnnamed) { visit_fields_unnamed(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_file(&mut self, i: &'ast File) { visit_file(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_fn_arg(&mut self, i: &'ast FnArg) { visit_fn_arg(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_foreign_item(&mut self, i: &'ast ForeignItem) { visit_foreign_item(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_foreign_item_fn(&mut self, i: &'ast ForeignItemFn) { visit_foreign_item_fn(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_foreign_item_macro(&mut self, i: &'ast ForeignItemMacro) { visit_foreign_item_macro(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_foreign_item_static(&mut self, i: &'ast ForeignItemStatic) { visit_foreign_item_static(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_foreign_item_type(&mut self, i: &'ast ForeignItemType) { visit_foreign_item_type(self, i); } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_generic_argument(&mut self, i: &'ast GenericArgument) { visit_generic_argument(self, i); } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_generic_param(&mut self, i: &'ast GenericParam) { visit_generic_param(self, i); } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_generics(&mut self, i: &'ast Generics) { visit_generics(self, i); } @@ -335,98 +410,122 @@ pub trait Visit<'ast> { visit_ident(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_impl_item(&mut self, i: &'ast ImplItem) { visit_impl_item(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_impl_item_const(&mut self, i: &'ast ImplItemConst) { visit_impl_item_const(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_impl_item_fn(&mut self, i: &'ast ImplItemFn) { visit_impl_item_fn(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_impl_item_macro(&mut self, i: &'ast ImplItemMacro) { visit_impl_item_macro(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_impl_item_type(&mut self, i: &'ast ImplItemType) { visit_impl_item_type(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_impl_restriction(&mut self, i: &'ast ImplRestriction) { visit_impl_restriction(self, i); } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_index(&mut self, i: &'ast Index) { visit_index(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_item(&mut self, i: &'ast Item) { visit_item(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_item_const(&mut self, i: &'ast ItemConst) { visit_item_const(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_item_enum(&mut self, i: &'ast ItemEnum) { visit_item_enum(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_item_extern_crate(&mut self, i: &'ast ItemExternCrate) { visit_item_extern_crate(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_item_fn(&mut self, i: &'ast ItemFn) { visit_item_fn(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_item_foreign_mod(&mut self, i: &'ast ItemForeignMod) { visit_item_foreign_mod(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_item_impl(&mut self, i: &'ast ItemImpl) { visit_item_impl(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_item_macro(&mut self, i: &'ast ItemMacro) { visit_item_macro(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_item_mod(&mut self, i: &'ast ItemMod) { visit_item_mod(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_item_static(&mut self, i: &'ast ItemStatic) { visit_item_static(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_item_struct(&mut self, i: &'ast ItemStruct) { visit_item_struct(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_item_trait(&mut self, i: &'ast ItemTrait) { visit_item_trait(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_item_trait_alias(&mut self, i: &'ast ItemTraitAlias) { visit_item_trait_alias(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_item_type(&mut self, i: &'ast ItemType) { visit_item_type(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_item_union(&mut self, i: &'ast ItemUnion) { visit_item_union(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_item_use(&mut self, i: &'ast ItemUse) { visit_item_use(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_label(&mut self, i: &'ast Label) { visit_label(self, i); } @@ -434,6 +533,7 @@ pub trait Visit<'ast> { visit_lifetime(self, i); } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_lifetime_param(&mut self, i: &'ast LifetimeParam) { visit_lifetime_param(self, i); } @@ -462,38 +562,47 @@ pub trait Visit<'ast> { visit_lit_str(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_local(&mut self, i: &'ast Local) { visit_local(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_local_init(&mut self, i: &'ast LocalInit) { visit_local_init(self, i); } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_macro(&mut self, i: &'ast Macro) { visit_macro(self, i); } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_macro_delimiter(&mut self, i: &'ast MacroDelimiter) { visit_macro_delimiter(self, i); } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_member(&mut self, i: &'ast Member) { visit_member(self, i); } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_meta(&mut self, i: &'ast Meta) { visit_meta(self, i); } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_meta_list(&mut self, i: &'ast MetaList) { visit_meta_list(self, i); } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_meta_name_value(&mut self, i: &'ast MetaNameValue) { visit_meta_name_value(self, i); } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_parenthesized_generic_arguments( &mut self, i: &'ast ParenthesizedGenericArguments, @@ -501,90 +610,112 @@ pub trait Visit<'ast> { visit_parenthesized_generic_arguments(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_pat(&mut self, i: &'ast Pat) { visit_pat(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_pat_ident(&mut self, i: &'ast PatIdent) { visit_pat_ident(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_pat_or(&mut self, i: &'ast PatOr) { visit_pat_or(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_pat_paren(&mut self, i: &'ast PatParen) { visit_pat_paren(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_pat_reference(&mut self, i: &'ast PatReference) { visit_pat_reference(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_pat_rest(&mut self, i: &'ast PatRest) { visit_pat_rest(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_pat_slice(&mut self, i: &'ast PatSlice) { visit_pat_slice(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_pat_struct(&mut self, i: &'ast PatStruct) { visit_pat_struct(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_pat_tuple(&mut self, i: &'ast PatTuple) { visit_pat_tuple(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_pat_tuple_struct(&mut self, i: &'ast PatTupleStruct) { visit_pat_tuple_struct(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_pat_type(&mut self, i: &'ast PatType) { visit_pat_type(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_pat_wild(&mut self, i: &'ast PatWild) { visit_pat_wild(self, i); } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_path(&mut self, i: &'ast Path) { visit_path(self, i); } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_path_arguments(&mut self, i: &'ast PathArguments) { visit_path_arguments(self, i); } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_path_segment(&mut self, i: &'ast PathSegment) { visit_path_segment(self, i); } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_predicate_lifetime(&mut self, i: &'ast PredicateLifetime) { visit_predicate_lifetime(self, i); } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_predicate_type(&mut self, i: &'ast PredicateType) { visit_predicate_type(self, i); } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_qself(&mut self, i: &'ast QSelf) { visit_qself(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_range_limits(&mut self, i: &'ast RangeLimits) { visit_range_limits(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_receiver(&mut self, i: &'ast Receiver) { visit_receiver(self, i); } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_return_type(&mut self, i: &'ast ReturnType) { visit_return_type(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_signature(&mut self, i: &'ast Signature) { visit_signature(self, i); } @@ -592,167 +723,208 @@ pub trait Visit<'ast> { visit_span(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_static_mutability(&mut self, i: &'ast StaticMutability) { visit_static_mutability(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_stmt(&mut self, i: &'ast Stmt) { visit_stmt(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_stmt_macro(&mut self, i: &'ast StmtMacro) { visit_stmt_macro(self, i); } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_trait_bound(&mut self, i: &'ast TraitBound) { visit_trait_bound(self, i); } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_trait_bound_modifier(&mut self, i: &'ast TraitBoundModifier) { visit_trait_bound_modifier(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_trait_item(&mut self, i: &'ast TraitItem) { visit_trait_item(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_trait_item_const(&mut self, i: &'ast TraitItemConst) { visit_trait_item_const(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_trait_item_fn(&mut self, i: &'ast TraitItemFn) { visit_trait_item_fn(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_trait_item_macro(&mut self, i: &'ast TraitItemMacro) { visit_trait_item_macro(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_trait_item_type(&mut self, i: &'ast TraitItemType) { visit_trait_item_type(self, i); } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_type(&mut self, i: &'ast Type) { visit_type(self, i); } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_type_array(&mut self, i: &'ast TypeArray) { visit_type_array(self, i); } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_type_bare_fn(&mut self, i: &'ast TypeBareFn) { visit_type_bare_fn(self, i); } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_type_group(&mut self, i: &'ast TypeGroup) { visit_type_group(self, i); } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_type_impl_trait(&mut self, i: &'ast TypeImplTrait) { visit_type_impl_trait(self, i); } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_type_infer(&mut self, i: &'ast TypeInfer) { visit_type_infer(self, i); } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_type_macro(&mut self, i: &'ast TypeMacro) { visit_type_macro(self, i); } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_type_never(&mut self, i: &'ast TypeNever) { visit_type_never(self, i); } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_type_param(&mut self, i: &'ast TypeParam) { visit_type_param(self, i); } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_type_param_bound(&mut self, i: &'ast TypeParamBound) { visit_type_param_bound(self, i); } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_type_paren(&mut self, i: &'ast TypeParen) { visit_type_paren(self, i); } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_type_path(&mut self, i: &'ast TypePath) { visit_type_path(self, i); } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_type_ptr(&mut self, i: &'ast TypePtr) { visit_type_ptr(self, i); } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_type_reference(&mut self, i: &'ast TypeReference) { visit_type_reference(self, i); } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_type_slice(&mut self, i: &'ast TypeSlice) { visit_type_slice(self, i); } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_type_trait_object(&mut self, i: &'ast TypeTraitObject) { visit_type_trait_object(self, i); } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_type_tuple(&mut self, i: &'ast TypeTuple) { visit_type_tuple(self, i); } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_un_op(&mut self, i: &'ast UnOp) { visit_un_op(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_use_glob(&mut self, i: &'ast UseGlob) { visit_use_glob(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_use_group(&mut self, i: &'ast UseGroup) { visit_use_group(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_use_name(&mut self, i: &'ast UseName) { visit_use_name(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_use_path(&mut self, i: &'ast UsePath) { visit_use_path(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_use_rename(&mut self, i: &'ast UseRename) { visit_use_rename(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_use_tree(&mut self, i: &'ast UseTree) { visit_use_tree(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_variadic(&mut self, i: &'ast Variadic) { visit_variadic(self, i); } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_variant(&mut self, i: &'ast Variant) { visit_variant(self, i); } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_vis_restricted(&mut self, i: &'ast VisRestricted) { visit_vis_restricted(self, i); } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_visibility(&mut self, i: &'ast Visibility) { visit_visibility(self, i); } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_where_clause(&mut self, i: &'ast WhereClause) { visit_where_clause(self, i); } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_where_predicate(&mut self, i: &'ast WherePredicate) { visit_where_predicate(self, i); } } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_abi<'ast, V>(v: &mut V, node: &'ast Abi) where V: Visit<'ast> + ?Sized, @@ -763,6 +935,7 @@ where } } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_angle_bracketed_generic_arguments<'ast, V>( v: &mut V, node: &'ast AngleBracketedGenericArguments, @@ -779,6 +952,7 @@ where skip!(node.gt_token); } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_arm<'ast, V>(v: &mut V, node: &'ast Arm) where V: Visit<'ast> + ?Sized, @@ -796,6 +970,7 @@ where skip!(node.comma); } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_assoc_const<'ast, V>(v: &mut V, node: &'ast AssocConst) where V: Visit<'ast> + ?Sized, @@ -808,6 +983,7 @@ where v.visit_expr(&node.value); } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_assoc_type<'ast, V>(v: &mut V, node: &'ast AssocType) where V: Visit<'ast> + ?Sized, @@ -820,6 +996,7 @@ where v.visit_type(&node.ty); } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_attr_style<'ast, V>(v: &mut V, node: &'ast AttrStyle) where V: Visit<'ast> + ?Sized, @@ -832,6 +1009,7 @@ where } } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_attribute<'ast, V>(v: &mut V, node: &'ast Attribute) where V: Visit<'ast> + ?Sized, @@ -842,6 +1020,7 @@ where v.visit_meta(&node.meta); } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_bare_fn_arg<'ast, V>(v: &mut V, node: &'ast BareFnArg) where V: Visit<'ast> + ?Sized, @@ -856,6 +1035,7 @@ where v.visit_type(&node.ty); } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_bare_variadic<'ast, V>(v: &mut V, node: &'ast BareVariadic) where V: Visit<'ast> + ?Sized, @@ -871,6 +1051,7 @@ where skip!(node.comma); } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_bin_op<'ast, V>(v: &mut V, node: &'ast BinOp) where V: Visit<'ast> + ?Sized, @@ -963,6 +1144,7 @@ where } } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_block<'ast, V>(v: &mut V, node: &'ast Block) where V: Visit<'ast> + ?Sized, @@ -973,6 +1155,7 @@ where } } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_bound_lifetimes<'ast, V>(v: &mut V, node: &'ast BoundLifetimes) where V: Visit<'ast> + ?Sized, @@ -986,6 +1169,7 @@ where skip!(node.gt_token); } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_const_param<'ast, V>(v: &mut V, node: &'ast ConstParam) where V: Visit<'ast> + ?Sized, @@ -1003,6 +1187,7 @@ where } } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_constraint<'ast, V>(v: &mut V, node: &'ast Constraint) where V: Visit<'ast> + ?Sized, @@ -1018,6 +1203,7 @@ where } } #[cfg(feature = "derive")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "derive")))] pub fn visit_data<'ast, V>(v: &mut V, node: &'ast Data) where V: Visit<'ast> + ?Sized, @@ -1035,6 +1221,7 @@ where } } #[cfg(feature = "derive")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "derive")))] pub fn visit_data_enum<'ast, V>(v: &mut V, node: &'ast DataEnum) where V: Visit<'ast> + ?Sized, @@ -1047,6 +1234,7 @@ where } } #[cfg(feature = "derive")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "derive")))] pub fn visit_data_struct<'ast, V>(v: &mut V, node: &'ast DataStruct) where V: Visit<'ast> + ?Sized, @@ -1056,6 +1244,7 @@ where skip!(node.semi_token); } #[cfg(feature = "derive")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "derive")))] pub fn visit_data_union<'ast, V>(v: &mut V, node: &'ast DataUnion) where V: Visit<'ast> + ?Sized, @@ -1064,6 +1253,7 @@ where v.visit_fields_named(&node.fields); } #[cfg(feature = "derive")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "derive")))] pub fn visit_derive_input<'ast, V>(v: &mut V, node: &'ast DeriveInput) where V: Visit<'ast> + ?Sized, @@ -1077,6 +1267,7 @@ where v.visit_data(&node.data); } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_expr<'ast, V>(v: &mut V, node: &'ast Expr) where V: Visit<'ast> + ?Sized, @@ -1152,7 +1343,7 @@ where full!(v.visit_expr_match(_binding_0)); } Expr::MethodCall(_binding_0) => { - full!(v.visit_expr_method_call(_binding_0)); + v.visit_expr_method_call(_binding_0); } Expr::Paren(_binding_0) => { v.visit_expr_paren(_binding_0); @@ -1164,7 +1355,7 @@ where full!(v.visit_expr_range(_binding_0)); } Expr::Reference(_binding_0) => { - full!(v.visit_expr_reference(_binding_0)); + v.visit_expr_reference(_binding_0); } Expr::Repeat(_binding_0) => { full!(v.visit_expr_repeat(_binding_0)); @@ -1173,7 +1364,7 @@ where full!(v.visit_expr_return(_binding_0)); } Expr::Struct(_binding_0) => { - full!(v.visit_expr_struct(_binding_0)); + v.visit_expr_struct(_binding_0); } Expr::Try(_binding_0) => { full!(v.visit_expr_try(_binding_0)); @@ -1202,6 +1393,7 @@ where } } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_expr_array<'ast, V>(v: &mut V, node: &'ast ExprArray) where V: Visit<'ast> + ?Sized, @@ -1216,6 +1408,7 @@ where } } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_expr_assign<'ast, V>(v: &mut V, node: &'ast ExprAssign) where V: Visit<'ast> + ?Sized, @@ -1228,6 +1421,7 @@ where v.visit_expr(&*node.right); } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_expr_async<'ast, V>(v: &mut V, node: &'ast ExprAsync) where V: Visit<'ast> + ?Sized, @@ -1240,6 +1434,7 @@ where v.visit_block(&node.block); } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_expr_await<'ast, V>(v: &mut V, node: &'ast ExprAwait) where V: Visit<'ast> + ?Sized, @@ -1252,6 +1447,7 @@ where skip!(node.await_token); } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_expr_binary<'ast, V>(v: &mut V, node: &'ast ExprBinary) where V: Visit<'ast> + ?Sized, @@ -1264,6 +1460,7 @@ where v.visit_expr(&*node.right); } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_expr_block<'ast, V>(v: &mut V, node: &'ast ExprBlock) where V: Visit<'ast> + ?Sized, @@ -1277,6 +1474,7 @@ where v.visit_block(&node.block); } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_expr_break<'ast, V>(v: &mut V, node: &'ast ExprBreak) where V: Visit<'ast> + ?Sized, @@ -1293,6 +1491,7 @@ where } } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_expr_call<'ast, V>(v: &mut V, node: &'ast ExprCall) where V: Visit<'ast> + ?Sized, @@ -1308,6 +1507,7 @@ where } } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_expr_cast<'ast, V>(v: &mut V, node: &'ast ExprCast) where V: Visit<'ast> + ?Sized, @@ -1320,6 +1520,7 @@ where v.visit_type(&*node.ty); } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_expr_closure<'ast, V>(v: &mut V, node: &'ast ExprClosure) where V: Visit<'ast> + ?Sized, @@ -1344,6 +1545,7 @@ where v.visit_expr(&*node.body); } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_expr_const<'ast, V>(v: &mut V, node: &'ast ExprConst) where V: Visit<'ast> + ?Sized, @@ -1355,6 +1557,7 @@ where v.visit_block(&node.block); } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_expr_continue<'ast, V>(v: &mut V, node: &'ast ExprContinue) where V: Visit<'ast> + ?Sized, @@ -1368,6 +1571,7 @@ where } } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_expr_field<'ast, V>(v: &mut V, node: &'ast ExprField) where V: Visit<'ast> + ?Sized, @@ -1380,6 +1584,7 @@ where v.visit_member(&node.member); } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_expr_for_loop<'ast, V>(v: &mut V, node: &'ast ExprForLoop) where V: Visit<'ast> + ?Sized, @@ -1397,6 +1602,7 @@ where v.visit_block(&node.body); } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_expr_group<'ast, V>(v: &mut V, node: &'ast ExprGroup) where V: Visit<'ast> + ?Sized, @@ -1408,6 +1614,7 @@ where v.visit_expr(&*node.expr); } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_expr_if<'ast, V>(v: &mut V, node: &'ast ExprIf) where V: Visit<'ast> + ?Sized, @@ -1424,6 +1631,7 @@ where } } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_expr_index<'ast, V>(v: &mut V, node: &'ast ExprIndex) where V: Visit<'ast> + ?Sized, @@ -1436,6 +1644,7 @@ where v.visit_expr(&*node.index); } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_expr_infer<'ast, V>(v: &mut V, node: &'ast ExprInfer) where V: Visit<'ast> + ?Sized, @@ -1446,6 +1655,7 @@ where skip!(node.underscore_token); } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_expr_let<'ast, V>(v: &mut V, node: &'ast ExprLet) where V: Visit<'ast> + ?Sized, @@ -1459,6 +1669,7 @@ where v.visit_expr(&*node.expr); } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_expr_lit<'ast, V>(v: &mut V, node: &'ast ExprLit) where V: Visit<'ast> + ?Sized, @@ -1469,6 +1680,7 @@ where v.visit_lit(&node.lit); } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_expr_loop<'ast, V>(v: &mut V, node: &'ast ExprLoop) where V: Visit<'ast> + ?Sized, @@ -1483,6 +1695,7 @@ where v.visit_block(&node.body); } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_expr_macro<'ast, V>(v: &mut V, node: &'ast ExprMacro) where V: Visit<'ast> + ?Sized, @@ -1493,6 +1706,7 @@ where v.visit_macro(&node.mac); } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_expr_match<'ast, V>(v: &mut V, node: &'ast ExprMatch) where V: Visit<'ast> + ?Sized, @@ -1507,7 +1721,8 @@ where v.visit_arm(it); } } -#[cfg(feature = "full")] +#[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_expr_method_call<'ast, V>(v: &mut V, node: &'ast ExprMethodCall) where V: Visit<'ast> + ?Sized, @@ -1528,6 +1743,7 @@ where } } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_expr_paren<'ast, V>(v: &mut V, node: &'ast ExprParen) where V: Visit<'ast> + ?Sized, @@ -1539,6 +1755,7 @@ where v.visit_expr(&*node.expr); } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_expr_path<'ast, V>(v: &mut V, node: &'ast ExprPath) where V: Visit<'ast> + ?Sized, @@ -1552,6 +1769,7 @@ where v.visit_path(&node.path); } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_expr_range<'ast, V>(v: &mut V, node: &'ast ExprRange) where V: Visit<'ast> + ?Sized, @@ -1567,7 +1785,8 @@ where v.visit_expr(&**it); } } -#[cfg(feature = "full")] +#[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_expr_reference<'ast, V>(v: &mut V, node: &'ast ExprReference) where V: Visit<'ast> + ?Sized, @@ -1580,6 +1799,7 @@ where v.visit_expr(&*node.expr); } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_expr_repeat<'ast, V>(v: &mut V, node: &'ast ExprRepeat) where V: Visit<'ast> + ?Sized, @@ -1593,6 +1813,7 @@ where v.visit_expr(&*node.len); } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_expr_return<'ast, V>(v: &mut V, node: &'ast ExprReturn) where V: Visit<'ast> + ?Sized, @@ -1605,7 +1826,8 @@ where v.visit_expr(&**it); } } -#[cfg(feature = "full")] +#[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_expr_struct<'ast, V>(v: &mut V, node: &'ast ExprStruct) where V: Visit<'ast> + ?Sized, @@ -1628,6 +1850,7 @@ where } } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_expr_try<'ast, V>(v: &mut V, node: &'ast ExprTry) where V: Visit<'ast> + ?Sized, @@ -1639,6 +1862,7 @@ where skip!(node.question_token); } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_expr_try_block<'ast, V>(v: &mut V, node: &'ast ExprTryBlock) where V: Visit<'ast> + ?Sized, @@ -1650,6 +1874,7 @@ where v.visit_block(&node.block); } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_expr_tuple<'ast, V>(v: &mut V, node: &'ast ExprTuple) where V: Visit<'ast> + ?Sized, @@ -1664,6 +1889,7 @@ where } } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_expr_unary<'ast, V>(v: &mut V, node: &'ast ExprUnary) where V: Visit<'ast> + ?Sized, @@ -1675,6 +1901,7 @@ where v.visit_expr(&*node.expr); } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_expr_unsafe<'ast, V>(v: &mut V, node: &'ast ExprUnsafe) where V: Visit<'ast> + ?Sized, @@ -1686,6 +1913,7 @@ where v.visit_block(&node.block); } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_expr_while<'ast, V>(v: &mut V, node: &'ast ExprWhile) where V: Visit<'ast> + ?Sized, @@ -1701,6 +1929,7 @@ where v.visit_block(&node.body); } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_expr_yield<'ast, V>(v: &mut V, node: &'ast ExprYield) where V: Visit<'ast> + ?Sized, @@ -1714,6 +1943,7 @@ where } } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_field<'ast, V>(v: &mut V, node: &'ast Field) where V: Visit<'ast> + ?Sized, @@ -1730,6 +1960,7 @@ where v.visit_type(&node.ty); } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_field_mutability<'ast, V>(v: &mut V, node: &'ast FieldMutability) where V: Visit<'ast> + ?Sized, @@ -1739,6 +1970,7 @@ where } } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_field_pat<'ast, V>(v: &mut V, node: &'ast FieldPat) where V: Visit<'ast> + ?Sized, @@ -1750,7 +1982,8 @@ where skip!(node.colon_token); v.visit_pat(&*node.pat); } -#[cfg(feature = "full")] +#[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_field_value<'ast, V>(v: &mut V, node: &'ast FieldValue) where V: Visit<'ast> + ?Sized, @@ -1763,6 +1996,7 @@ where v.visit_expr(&node.expr); } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_fields<'ast, V>(v: &mut V, node: &'ast Fields) where V: Visit<'ast> + ?Sized, @@ -1778,6 +2012,7 @@ where } } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_fields_named<'ast, V>(v: &mut V, node: &'ast FieldsNamed) where V: Visit<'ast> + ?Sized, @@ -1789,6 +2024,7 @@ where } } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_fields_unnamed<'ast, V>(v: &mut V, node: &'ast FieldsUnnamed) where V: Visit<'ast> + ?Sized, @@ -1800,6 +2036,7 @@ where } } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_file<'ast, V>(v: &mut V, node: &'ast File) where V: Visit<'ast> + ?Sized, @@ -1813,6 +2050,7 @@ where } } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_fn_arg<'ast, V>(v: &mut V, node: &'ast FnArg) where V: Visit<'ast> + ?Sized, @@ -1827,6 +2065,7 @@ where } } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_foreign_item<'ast, V>(v: &mut V, node: &'ast ForeignItem) where V: Visit<'ast> + ?Sized, @@ -1850,6 +2089,7 @@ where } } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_foreign_item_fn<'ast, V>(v: &mut V, node: &'ast ForeignItemFn) where V: Visit<'ast> + ?Sized, @@ -1862,6 +2102,7 @@ where skip!(node.semi_token); } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_foreign_item_macro<'ast, V>(v: &mut V, node: &'ast ForeignItemMacro) where V: Visit<'ast> + ?Sized, @@ -1873,6 +2114,7 @@ where skip!(node.semi_token); } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_foreign_item_static<'ast, V>(v: &mut V, node: &'ast ForeignItemStatic) where V: Visit<'ast> + ?Sized, @@ -1889,6 +2131,7 @@ where skip!(node.semi_token); } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_foreign_item_type<'ast, V>(v: &mut V, node: &'ast ForeignItemType) where V: Visit<'ast> + ?Sized, @@ -1903,6 +2146,7 @@ where skip!(node.semi_token); } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_generic_argument<'ast, V>(v: &mut V, node: &'ast GenericArgument) where V: Visit<'ast> + ?Sized, @@ -1929,6 +2173,7 @@ where } } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_generic_param<'ast, V>(v: &mut V, node: &'ast GenericParam) where V: Visit<'ast> + ?Sized, @@ -1946,6 +2191,7 @@ where } } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_generics<'ast, V>(v: &mut V, node: &'ast Generics) where V: Visit<'ast> + ?Sized, @@ -1967,6 +2213,7 @@ where v.visit_span(&node.span()); } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_impl_item<'ast, V>(v: &mut V, node: &'ast ImplItem) where V: Visit<'ast> + ?Sized, @@ -1990,6 +2237,7 @@ where } } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_impl_item_const<'ast, V>(v: &mut V, node: &'ast ImplItemConst) where V: Visit<'ast> + ?Sized, @@ -2009,6 +2257,7 @@ where skip!(node.semi_token); } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_impl_item_fn<'ast, V>(v: &mut V, node: &'ast ImplItemFn) where V: Visit<'ast> + ?Sized, @@ -2022,6 +2271,7 @@ where v.visit_block(&node.block); } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_impl_item_macro<'ast, V>(v: &mut V, node: &'ast ImplItemMacro) where V: Visit<'ast> + ?Sized, @@ -2033,6 +2283,7 @@ where skip!(node.semi_token); } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_impl_item_type<'ast, V>(v: &mut V, node: &'ast ImplItemType) where V: Visit<'ast> + ?Sized, @@ -2050,6 +2301,7 @@ where skip!(node.semi_token); } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_impl_restriction<'ast, V>(v: &mut V, node: &'ast ImplRestriction) where V: Visit<'ast> + ?Sized, @@ -2057,6 +2309,7 @@ where match *node {} } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_index<'ast, V>(v: &mut V, node: &'ast Index) where V: Visit<'ast> + ?Sized, @@ -2065,6 +2318,7 @@ where v.visit_span(&node.span); } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_item<'ast, V>(v: &mut V, node: &'ast Item) where V: Visit<'ast> + ?Sized, @@ -2121,6 +2375,7 @@ where } } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_item_const<'ast, V>(v: &mut V, node: &'ast ItemConst) where V: Visit<'ast> + ?Sized, @@ -2139,6 +2394,7 @@ where skip!(node.semi_token); } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_item_enum<'ast, V>(v: &mut V, node: &'ast ItemEnum) where V: Visit<'ast> + ?Sized, @@ -2157,6 +2413,7 @@ where } } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_item_extern_crate<'ast, V>(v: &mut V, node: &'ast ItemExternCrate) where V: Visit<'ast> + ?Sized, @@ -2175,6 +2432,7 @@ where skip!(node.semi_token); } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_item_fn<'ast, V>(v: &mut V, node: &'ast ItemFn) where V: Visit<'ast> + ?Sized, @@ -2187,6 +2445,7 @@ where v.visit_block(&*node.block); } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_item_foreign_mod<'ast, V>(v: &mut V, node: &'ast ItemForeignMod) where V: Visit<'ast> + ?Sized, @@ -2202,6 +2461,7 @@ where } } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_item_impl<'ast, V>(v: &mut V, node: &'ast ItemImpl) where V: Visit<'ast> + ?Sized, @@ -2225,6 +2485,7 @@ where } } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_item_macro<'ast, V>(v: &mut V, node: &'ast ItemMacro) where V: Visit<'ast> + ?Sized, @@ -2239,6 +2500,7 @@ where skip!(node.semi_token); } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_item_mod<'ast, V>(v: &mut V, node: &'ast ItemMod) where V: Visit<'ast> + ?Sized, @@ -2259,6 +2521,7 @@ where skip!(node.semi); } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_item_static<'ast, V>(v: &mut V, node: &'ast ItemStatic) where V: Visit<'ast> + ?Sized, @@ -2277,6 +2540,7 @@ where skip!(node.semi_token); } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_item_struct<'ast, V>(v: &mut V, node: &'ast ItemStruct) where V: Visit<'ast> + ?Sized, @@ -2292,6 +2556,7 @@ where skip!(node.semi_token); } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_item_trait<'ast, V>(v: &mut V, node: &'ast ItemTrait) where V: Visit<'ast> + ?Sized, @@ -2319,6 +2584,7 @@ where } } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_item_trait_alias<'ast, V>(v: &mut V, node: &'ast ItemTraitAlias) where V: Visit<'ast> + ?Sized, @@ -2338,6 +2604,7 @@ where skip!(node.semi_token); } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_item_type<'ast, V>(v: &mut V, node: &'ast ItemType) where V: Visit<'ast> + ?Sized, @@ -2354,6 +2621,7 @@ where skip!(node.semi_token); } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_item_union<'ast, V>(v: &mut V, node: &'ast ItemUnion) where V: Visit<'ast> + ?Sized, @@ -2368,6 +2636,7 @@ where v.visit_fields_named(&node.fields); } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_item_use<'ast, V>(v: &mut V, node: &'ast ItemUse) where V: Visit<'ast> + ?Sized, @@ -2382,6 +2651,7 @@ where skip!(node.semi_token); } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_label<'ast, V>(v: &mut V, node: &'ast Label) where V: Visit<'ast> + ?Sized, @@ -2397,6 +2667,7 @@ where v.visit_ident(&node.ident); } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_lifetime_param<'ast, V>(v: &mut V, node: &'ast LifetimeParam) where V: Visit<'ast> + ?Sized, @@ -2474,6 +2745,7 @@ where V: Visit<'ast> + ?Sized, {} #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_local<'ast, V>(v: &mut V, node: &'ast Local) where V: Visit<'ast> + ?Sized, @@ -2489,6 +2761,7 @@ where skip!(node.semi_token); } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_local_init<'ast, V>(v: &mut V, node: &'ast LocalInit) where V: Visit<'ast> + ?Sized, @@ -2501,6 +2774,7 @@ where } } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_macro<'ast, V>(v: &mut V, node: &'ast Macro) where V: Visit<'ast> + ?Sized, @@ -2511,6 +2785,7 @@ where skip!(node.tokens); } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_macro_delimiter<'ast, V>(v: &mut V, node: &'ast MacroDelimiter) where V: Visit<'ast> + ?Sized, @@ -2528,6 +2803,7 @@ where } } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_member<'ast, V>(v: &mut V, node: &'ast Member) where V: Visit<'ast> + ?Sized, @@ -2542,6 +2818,7 @@ where } } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_meta<'ast, V>(v: &mut V, node: &'ast Meta) where V: Visit<'ast> + ?Sized, @@ -2559,6 +2836,7 @@ where } } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_meta_list<'ast, V>(v: &mut V, node: &'ast MetaList) where V: Visit<'ast> + ?Sized, @@ -2568,6 +2846,7 @@ where skip!(node.tokens); } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_meta_name_value<'ast, V>(v: &mut V, node: &'ast MetaNameValue) where V: Visit<'ast> + ?Sized, @@ -2577,6 +2856,7 @@ where v.visit_expr(&node.value); } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_parenthesized_generic_arguments<'ast, V>( v: &mut V, node: &'ast ParenthesizedGenericArguments, @@ -2592,6 +2872,7 @@ where v.visit_return_type(&node.output); } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_pat<'ast, V>(v: &mut V, node: &'ast Pat) where V: Visit<'ast> + ?Sized, @@ -2651,6 +2932,7 @@ where } } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_pat_ident<'ast, V>(v: &mut V, node: &'ast PatIdent) where V: Visit<'ast> + ?Sized, @@ -2667,6 +2949,7 @@ where } } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_pat_or<'ast, V>(v: &mut V, node: &'ast PatOr) where V: Visit<'ast> + ?Sized, @@ -2681,6 +2964,7 @@ where } } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_pat_paren<'ast, V>(v: &mut V, node: &'ast PatParen) where V: Visit<'ast> + ?Sized, @@ -2692,6 +2976,7 @@ where v.visit_pat(&*node.pat); } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_pat_reference<'ast, V>(v: &mut V, node: &'ast PatReference) where V: Visit<'ast> + ?Sized, @@ -2704,6 +2989,7 @@ where v.visit_pat(&*node.pat); } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_pat_rest<'ast, V>(v: &mut V, node: &'ast PatRest) where V: Visit<'ast> + ?Sized, @@ -2714,6 +3000,7 @@ where skip!(node.dot2_token); } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_pat_slice<'ast, V>(v: &mut V, node: &'ast PatSlice) where V: Visit<'ast> + ?Sized, @@ -2728,6 +3015,7 @@ where } } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_pat_struct<'ast, V>(v: &mut V, node: &'ast PatStruct) where V: Visit<'ast> + ?Sized, @@ -2749,6 +3037,7 @@ where } } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_pat_tuple<'ast, V>(v: &mut V, node: &'ast PatTuple) where V: Visit<'ast> + ?Sized, @@ -2763,6 +3052,7 @@ where } } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_pat_tuple_struct<'ast, V>(v: &mut V, node: &'ast PatTupleStruct) where V: Visit<'ast> + ?Sized, @@ -2781,6 +3071,7 @@ where } } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_pat_type<'ast, V>(v: &mut V, node: &'ast PatType) where V: Visit<'ast> + ?Sized, @@ -2793,6 +3084,7 @@ where v.visit_type(&*node.ty); } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_pat_wild<'ast, V>(v: &mut V, node: &'ast PatWild) where V: Visit<'ast> + ?Sized, @@ -2803,6 +3095,7 @@ where skip!(node.underscore_token); } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_path<'ast, V>(v: &mut V, node: &'ast Path) where V: Visit<'ast> + ?Sized, @@ -2814,6 +3107,7 @@ where } } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_path_arguments<'ast, V>(v: &mut V, node: &'ast PathArguments) where V: Visit<'ast> + ?Sized, @@ -2829,6 +3123,7 @@ where } } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_path_segment<'ast, V>(v: &mut V, node: &'ast PathSegment) where V: Visit<'ast> + ?Sized, @@ -2837,6 +3132,7 @@ where v.visit_path_arguments(&node.arguments); } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_predicate_lifetime<'ast, V>(v: &mut V, node: &'ast PredicateLifetime) where V: Visit<'ast> + ?Sized, @@ -2849,6 +3145,7 @@ where } } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_predicate_type<'ast, V>(v: &mut V, node: &'ast PredicateType) where V: Visit<'ast> + ?Sized, @@ -2864,6 +3161,7 @@ where } } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_qself<'ast, V>(v: &mut V, node: &'ast QSelf) where V: Visit<'ast> + ?Sized, @@ -2875,6 +3173,7 @@ where skip!(node.gt_token); } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_range_limits<'ast, V>(v: &mut V, node: &'ast RangeLimits) where V: Visit<'ast> + ?Sized, @@ -2889,6 +3188,7 @@ where } } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_receiver<'ast, V>(v: &mut V, node: &'ast Receiver) where V: Visit<'ast> + ?Sized, @@ -2908,6 +3208,7 @@ where v.visit_type(&*node.ty); } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_return_type<'ast, V>(v: &mut V, node: &'ast ReturnType) where V: Visit<'ast> + ?Sized, @@ -2921,6 +3222,7 @@ where } } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_signature<'ast, V>(v: &mut V, node: &'ast Signature) where V: Visit<'ast> + ?Sized, @@ -2949,6 +3251,7 @@ where V: Visit<'ast> + ?Sized, {} #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_static_mutability<'ast, V>(v: &mut V, node: &'ast StaticMutability) where V: Visit<'ast> + ?Sized, @@ -2961,6 +3264,7 @@ where } } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_stmt<'ast, V>(v: &mut V, node: &'ast Stmt) where V: Visit<'ast> + ?Sized, @@ -2982,6 +3286,7 @@ where } } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_stmt_macro<'ast, V>(v: &mut V, node: &'ast StmtMacro) where V: Visit<'ast> + ?Sized, @@ -2993,6 +3298,7 @@ where skip!(node.semi_token); } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_trait_bound<'ast, V>(v: &mut V, node: &'ast TraitBound) where V: Visit<'ast> + ?Sized, @@ -3005,6 +3311,7 @@ where v.visit_path(&node.path); } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_trait_bound_modifier<'ast, V>(v: &mut V, node: &'ast TraitBoundModifier) where V: Visit<'ast> + ?Sized, @@ -3017,6 +3324,7 @@ where } } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_trait_item<'ast, V>(v: &mut V, node: &'ast TraitItem) where V: Visit<'ast> + ?Sized, @@ -3040,6 +3348,7 @@ where } } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_trait_item_const<'ast, V>(v: &mut V, node: &'ast TraitItemConst) where V: Visit<'ast> + ?Sized, @@ -3059,6 +3368,7 @@ where skip!(node.semi_token); } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_trait_item_fn<'ast, V>(v: &mut V, node: &'ast TraitItemFn) where V: Visit<'ast> + ?Sized, @@ -3073,6 +3383,7 @@ where skip!(node.semi_token); } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_trait_item_macro<'ast, V>(v: &mut V, node: &'ast TraitItemMacro) where V: Visit<'ast> + ?Sized, @@ -3084,6 +3395,7 @@ where skip!(node.semi_token); } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_trait_item_type<'ast, V>(v: &mut V, node: &'ast TraitItemType) where V: Visit<'ast> + ?Sized, @@ -3106,6 +3418,7 @@ where skip!(node.semi_token); } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_type<'ast, V>(v: &mut V, node: &'ast Type) where V: Visit<'ast> + ?Sized, @@ -3159,6 +3472,7 @@ where } } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_type_array<'ast, V>(v: &mut V, node: &'ast TypeArray) where V: Visit<'ast> + ?Sized, @@ -3169,6 +3483,7 @@ where v.visit_expr(&node.len); } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_type_bare_fn<'ast, V>(v: &mut V, node: &'ast TypeBareFn) where V: Visit<'ast> + ?Sized, @@ -3192,6 +3507,7 @@ where v.visit_return_type(&node.output); } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_type_group<'ast, V>(v: &mut V, node: &'ast TypeGroup) where V: Visit<'ast> + ?Sized, @@ -3200,6 +3516,7 @@ where v.visit_type(&*node.elem); } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_type_impl_trait<'ast, V>(v: &mut V, node: &'ast TypeImplTrait) where V: Visit<'ast> + ?Sized, @@ -3211,6 +3528,7 @@ where } } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_type_infer<'ast, V>(v: &mut V, node: &'ast TypeInfer) where V: Visit<'ast> + ?Sized, @@ -3218,6 +3536,7 @@ where skip!(node.underscore_token); } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_type_macro<'ast, V>(v: &mut V, node: &'ast TypeMacro) where V: Visit<'ast> + ?Sized, @@ -3225,6 +3544,7 @@ where v.visit_macro(&node.mac); } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_type_never<'ast, V>(v: &mut V, node: &'ast TypeNever) where V: Visit<'ast> + ?Sized, @@ -3232,6 +3552,7 @@ where skip!(node.bang_token); } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_type_param<'ast, V>(v: &mut V, node: &'ast TypeParam) where V: Visit<'ast> + ?Sized, @@ -3251,6 +3572,7 @@ where } } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_type_param_bound<'ast, V>(v: &mut V, node: &'ast TypeParamBound) where V: Visit<'ast> + ?Sized, @@ -3268,6 +3590,7 @@ where } } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_type_paren<'ast, V>(v: &mut V, node: &'ast TypeParen) where V: Visit<'ast> + ?Sized, @@ -3276,6 +3599,7 @@ where v.visit_type(&*node.elem); } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_type_path<'ast, V>(v: &mut V, node: &'ast TypePath) where V: Visit<'ast> + ?Sized, @@ -3286,6 +3610,7 @@ where v.visit_path(&node.path); } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_type_ptr<'ast, V>(v: &mut V, node: &'ast TypePtr) where V: Visit<'ast> + ?Sized, @@ -3296,6 +3621,7 @@ where v.visit_type(&*node.elem); } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_type_reference<'ast, V>(v: &mut V, node: &'ast TypeReference) where V: Visit<'ast> + ?Sized, @@ -3308,6 +3634,7 @@ where v.visit_type(&*node.elem); } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_type_slice<'ast, V>(v: &mut V, node: &'ast TypeSlice) where V: Visit<'ast> + ?Sized, @@ -3316,6 +3643,7 @@ where v.visit_type(&*node.elem); } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_type_trait_object<'ast, V>(v: &mut V, node: &'ast TypeTraitObject) where V: Visit<'ast> + ?Sized, @@ -3327,6 +3655,7 @@ where } } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_type_tuple<'ast, V>(v: &mut V, node: &'ast TypeTuple) where V: Visit<'ast> + ?Sized, @@ -3338,6 +3667,7 @@ where } } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_un_op<'ast, V>(v: &mut V, node: &'ast UnOp) where V: Visit<'ast> + ?Sized, @@ -3355,6 +3685,7 @@ where } } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_use_glob<'ast, V>(v: &mut V, node: &'ast UseGlob) where V: Visit<'ast> + ?Sized, @@ -3362,6 +3693,7 @@ where skip!(node.star_token); } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_use_group<'ast, V>(v: &mut V, node: &'ast UseGroup) where V: Visit<'ast> + ?Sized, @@ -3373,6 +3705,7 @@ where } } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_use_name<'ast, V>(v: &mut V, node: &'ast UseName) where V: Visit<'ast> + ?Sized, @@ -3380,6 +3713,7 @@ where v.visit_ident(&node.ident); } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_use_path<'ast, V>(v: &mut V, node: &'ast UsePath) where V: Visit<'ast> + ?Sized, @@ -3389,6 +3723,7 @@ where v.visit_use_tree(&*node.tree); } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_use_rename<'ast, V>(v: &mut V, node: &'ast UseRename) where V: Visit<'ast> + ?Sized, @@ -3398,6 +3733,7 @@ where v.visit_ident(&node.rename); } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_use_tree<'ast, V>(v: &mut V, node: &'ast UseTree) where V: Visit<'ast> + ?Sized, @@ -3421,6 +3757,7 @@ where } } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_variadic<'ast, V>(v: &mut V, node: &'ast Variadic) where V: Visit<'ast> + ?Sized, @@ -3436,6 +3773,7 @@ where skip!(node.comma); } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_variant<'ast, V>(v: &mut V, node: &'ast Variant) where V: Visit<'ast> + ?Sized, @@ -3451,6 +3789,7 @@ where } } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_vis_restricted<'ast, V>(v: &mut V, node: &'ast VisRestricted) where V: Visit<'ast> + ?Sized, @@ -3461,6 +3800,7 @@ where v.visit_path(&*node.path); } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_visibility<'ast, V>(v: &mut V, node: &'ast Visibility) where V: Visit<'ast> + ?Sized, @@ -3476,6 +3816,7 @@ where } } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_where_clause<'ast, V>(v: &mut V, node: &'ast WhereClause) where V: Visit<'ast> + ?Sized, @@ -3487,6 +3828,7 @@ where } } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_where_predicate<'ast, V>(v: &mut V, node: &'ast WherePredicate) where V: Visit<'ast> + ?Sized, diff --git a/third_party/rust/syn/src/gen/visit_mut.rs b/third_party/rust/syn/src/gen/visit_mut.rs index 9e7d16ff60981..3e81aae41b8d7 100644 --- a/third_party/rust/syn/src/gen/visit_mut.rs +++ b/third_party/rust/syn/src/gen/visit_mut.rs @@ -30,10 +30,12 @@ macro_rules! skip { /// [module documentation]: self pub trait VisitMut { #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_abi_mut(&mut self, i: &mut Abi) { visit_abi_mut(self, i); } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_angle_bracketed_generic_arguments_mut( &mut self, i: &mut AngleBracketedGenericArguments, @@ -41,294 +43,367 @@ pub trait VisitMut { visit_angle_bracketed_generic_arguments_mut(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_arm_mut(&mut self, i: &mut Arm) { visit_arm_mut(self, i); } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(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"))] + #[cfg_attr(doc_cfg, doc(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"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_attr_style_mut(&mut self, i: &mut AttrStyle) { visit_attr_style_mut(self, i); } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_attribute_mut(&mut self, i: &mut Attribute) { visit_attribute_mut(self, i); } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_bare_fn_arg_mut(&mut self, i: &mut BareFnArg) { visit_bare_fn_arg_mut(self, i); } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_bare_variadic_mut(&mut self, i: &mut BareVariadic) { visit_bare_variadic_mut(self, i); } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_bin_op_mut(&mut self, i: &mut BinOp) { visit_bin_op_mut(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_block_mut(&mut self, i: &mut Block) { visit_block_mut(self, i); } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_bound_lifetimes_mut(&mut self, i: &mut BoundLifetimes) { visit_bound_lifetimes_mut(self, i); } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_const_param_mut(&mut self, i: &mut ConstParam) { visit_const_param_mut(self, i); } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_constraint_mut(&mut self, i: &mut Constraint) { visit_constraint_mut(self, i); } #[cfg(feature = "derive")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "derive")))] fn visit_data_mut(&mut self, i: &mut Data) { visit_data_mut(self, i); } #[cfg(feature = "derive")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "derive")))] fn visit_data_enum_mut(&mut self, i: &mut DataEnum) { visit_data_enum_mut(self, i); } #[cfg(feature = "derive")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "derive")))] fn visit_data_struct_mut(&mut self, i: &mut DataStruct) { visit_data_struct_mut(self, i); } #[cfg(feature = "derive")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "derive")))] fn visit_data_union_mut(&mut self, i: &mut DataUnion) { visit_data_union_mut(self, i); } #[cfg(feature = "derive")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "derive")))] fn visit_derive_input_mut(&mut self, i: &mut DeriveInput) { visit_derive_input_mut(self, i); } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_expr_mut(&mut self, i: &mut Expr) { visit_expr_mut(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_expr_array_mut(&mut self, i: &mut ExprArray) { visit_expr_array_mut(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_expr_assign_mut(&mut self, i: &mut ExprAssign) { visit_expr_assign_mut(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_expr_async_mut(&mut self, i: &mut ExprAsync) { visit_expr_async_mut(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_expr_await_mut(&mut self, i: &mut ExprAwait) { visit_expr_await_mut(self, i); } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_expr_binary_mut(&mut self, i: &mut ExprBinary) { visit_expr_binary_mut(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_expr_block_mut(&mut self, i: &mut ExprBlock) { visit_expr_block_mut(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_expr_break_mut(&mut self, i: &mut ExprBreak) { visit_expr_break_mut(self, i); } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_expr_call_mut(&mut self, i: &mut ExprCall) { visit_expr_call_mut(self, i); } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_expr_cast_mut(&mut self, i: &mut ExprCast) { visit_expr_cast_mut(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_expr_closure_mut(&mut self, i: &mut ExprClosure) { visit_expr_closure_mut(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_expr_const_mut(&mut self, i: &mut ExprConst) { visit_expr_const_mut(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_expr_continue_mut(&mut self, i: &mut ExprContinue) { visit_expr_continue_mut(self, i); } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_expr_field_mut(&mut self, i: &mut ExprField) { visit_expr_field_mut(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_expr_for_loop_mut(&mut self, i: &mut ExprForLoop) { visit_expr_for_loop_mut(self, i); } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_expr_group_mut(&mut self, i: &mut ExprGroup) { visit_expr_group_mut(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_expr_if_mut(&mut self, i: &mut ExprIf) { visit_expr_if_mut(self, i); } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_expr_index_mut(&mut self, i: &mut ExprIndex) { visit_expr_index_mut(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_expr_infer_mut(&mut self, i: &mut ExprInfer) { visit_expr_infer_mut(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_expr_let_mut(&mut self, i: &mut ExprLet) { visit_expr_let_mut(self, i); } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_expr_lit_mut(&mut self, i: &mut ExprLit) { visit_expr_lit_mut(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_expr_loop_mut(&mut self, i: &mut ExprLoop) { visit_expr_loop_mut(self, i); } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_expr_macro_mut(&mut self, i: &mut ExprMacro) { visit_expr_macro_mut(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_expr_match_mut(&mut self, i: &mut ExprMatch) { visit_expr_match_mut(self, i); } - #[cfg(feature = "full")] + #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_expr_method_call_mut(&mut self, i: &mut ExprMethodCall) { visit_expr_method_call_mut(self, i); } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_expr_paren_mut(&mut self, i: &mut ExprParen) { visit_expr_paren_mut(self, i); } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_expr_path_mut(&mut self, i: &mut ExprPath) { visit_expr_path_mut(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_expr_range_mut(&mut self, i: &mut ExprRange) { visit_expr_range_mut(self, i); } - #[cfg(feature = "full")] + #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_expr_reference_mut(&mut self, i: &mut ExprReference) { visit_expr_reference_mut(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_expr_repeat_mut(&mut self, i: &mut ExprRepeat) { visit_expr_repeat_mut(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_expr_return_mut(&mut self, i: &mut ExprReturn) { visit_expr_return_mut(self, i); } - #[cfg(feature = "full")] + #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_expr_struct_mut(&mut self, i: &mut ExprStruct) { visit_expr_struct_mut(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_expr_try_mut(&mut self, i: &mut ExprTry) { visit_expr_try_mut(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_expr_try_block_mut(&mut self, i: &mut ExprTryBlock) { visit_expr_try_block_mut(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_expr_tuple_mut(&mut self, i: &mut ExprTuple) { visit_expr_tuple_mut(self, i); } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_expr_unary_mut(&mut self, i: &mut ExprUnary) { visit_expr_unary_mut(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_expr_unsafe_mut(&mut self, i: &mut ExprUnsafe) { visit_expr_unsafe_mut(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_expr_while_mut(&mut self, i: &mut ExprWhile) { visit_expr_while_mut(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_expr_yield_mut(&mut self, i: &mut ExprYield) { visit_expr_yield_mut(self, i); } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_field_mut(&mut self, i: &mut Field) { visit_field_mut(self, i); } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(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")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_field_pat_mut(&mut self, i: &mut FieldPat) { visit_field_pat_mut(self, i); } - #[cfg(feature = "full")] + #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_field_value_mut(&mut self, i: &mut FieldValue) { visit_field_value_mut(self, i); } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_fields_mut(&mut self, i: &mut Fields) { visit_fields_mut(self, i); } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_fields_named_mut(&mut self, i: &mut FieldsNamed) { visit_fields_named_mut(self, i); } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_fields_unnamed_mut(&mut self, i: &mut FieldsUnnamed) { visit_fields_unnamed_mut(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_file_mut(&mut self, i: &mut File) { visit_file_mut(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_fn_arg_mut(&mut self, i: &mut FnArg) { visit_fn_arg_mut(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_foreign_item_mut(&mut self, i: &mut ForeignItem) { visit_foreign_item_mut(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_foreign_item_fn_mut(&mut self, i: &mut ForeignItemFn) { visit_foreign_item_fn_mut(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_foreign_item_macro_mut(&mut self, i: &mut ForeignItemMacro) { visit_foreign_item_macro_mut(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_foreign_item_static_mut(&mut self, i: &mut ForeignItemStatic) { visit_foreign_item_static_mut(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_foreign_item_type_mut(&mut self, i: &mut ForeignItemType) { visit_foreign_item_type_mut(self, i); } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_generic_argument_mut(&mut self, i: &mut GenericArgument) { visit_generic_argument_mut(self, i); } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_generic_param_mut(&mut self, i: &mut GenericParam) { visit_generic_param_mut(self, i); } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_generics_mut(&mut self, i: &mut Generics) { visit_generics_mut(self, i); } @@ -336,98 +411,122 @@ pub trait VisitMut { visit_ident_mut(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_impl_item_mut(&mut self, i: &mut ImplItem) { visit_impl_item_mut(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_impl_item_const_mut(&mut self, i: &mut ImplItemConst) { visit_impl_item_const_mut(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_impl_item_fn_mut(&mut self, i: &mut ImplItemFn) { visit_impl_item_fn_mut(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_impl_item_macro_mut(&mut self, i: &mut ImplItemMacro) { visit_impl_item_macro_mut(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_impl_item_type_mut(&mut self, i: &mut ImplItemType) { visit_impl_item_type_mut(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(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"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_index_mut(&mut self, i: &mut Index) { visit_index_mut(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_item_mut(&mut self, i: &mut Item) { visit_item_mut(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_item_const_mut(&mut self, i: &mut ItemConst) { visit_item_const_mut(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_item_enum_mut(&mut self, i: &mut ItemEnum) { visit_item_enum_mut(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_item_extern_crate_mut(&mut self, i: &mut ItemExternCrate) { visit_item_extern_crate_mut(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_item_fn_mut(&mut self, i: &mut ItemFn) { visit_item_fn_mut(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_item_foreign_mod_mut(&mut self, i: &mut ItemForeignMod) { visit_item_foreign_mod_mut(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_item_impl_mut(&mut self, i: &mut ItemImpl) { visit_item_impl_mut(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_item_macro_mut(&mut self, i: &mut ItemMacro) { visit_item_macro_mut(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_item_mod_mut(&mut self, i: &mut ItemMod) { visit_item_mod_mut(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_item_static_mut(&mut self, i: &mut ItemStatic) { visit_item_static_mut(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_item_struct_mut(&mut self, i: &mut ItemStruct) { visit_item_struct_mut(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_item_trait_mut(&mut self, i: &mut ItemTrait) { visit_item_trait_mut(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_item_trait_alias_mut(&mut self, i: &mut ItemTraitAlias) { visit_item_trait_alias_mut(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_item_type_mut(&mut self, i: &mut ItemType) { visit_item_type_mut(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_item_union_mut(&mut self, i: &mut ItemUnion) { visit_item_union_mut(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_item_use_mut(&mut self, i: &mut ItemUse) { visit_item_use_mut(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_label_mut(&mut self, i: &mut Label) { visit_label_mut(self, i); } @@ -435,6 +534,7 @@ pub trait VisitMut { visit_lifetime_mut(self, i); } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_lifetime_param_mut(&mut self, i: &mut LifetimeParam) { visit_lifetime_param_mut(self, i); } @@ -463,38 +563,47 @@ pub trait VisitMut { visit_lit_str_mut(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_local_mut(&mut self, i: &mut Local) { visit_local_mut(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(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"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_macro_mut(&mut self, i: &mut Macro) { visit_macro_mut(self, i); } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_macro_delimiter_mut(&mut self, i: &mut MacroDelimiter) { visit_macro_delimiter_mut(self, i); } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_member_mut(&mut self, i: &mut Member) { visit_member_mut(self, i); } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_meta_mut(&mut self, i: &mut Meta) { visit_meta_mut(self, i); } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_meta_list_mut(&mut self, i: &mut MetaList) { visit_meta_list_mut(self, i); } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_meta_name_value_mut(&mut self, i: &mut MetaNameValue) { visit_meta_name_value_mut(self, i); } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_parenthesized_generic_arguments_mut( &mut self, i: &mut ParenthesizedGenericArguments, @@ -502,90 +611,112 @@ pub trait VisitMut { visit_parenthesized_generic_arguments_mut(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_pat_mut(&mut self, i: &mut Pat) { visit_pat_mut(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_pat_ident_mut(&mut self, i: &mut PatIdent) { visit_pat_ident_mut(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_pat_or_mut(&mut self, i: &mut PatOr) { visit_pat_or_mut(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_pat_paren_mut(&mut self, i: &mut PatParen) { visit_pat_paren_mut(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_pat_reference_mut(&mut self, i: &mut PatReference) { visit_pat_reference_mut(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_pat_rest_mut(&mut self, i: &mut PatRest) { visit_pat_rest_mut(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_pat_slice_mut(&mut self, i: &mut PatSlice) { visit_pat_slice_mut(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_pat_struct_mut(&mut self, i: &mut PatStruct) { visit_pat_struct_mut(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_pat_tuple_mut(&mut self, i: &mut PatTuple) { visit_pat_tuple_mut(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_pat_tuple_struct_mut(&mut self, i: &mut PatTupleStruct) { visit_pat_tuple_struct_mut(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_pat_type_mut(&mut self, i: &mut PatType) { visit_pat_type_mut(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_pat_wild_mut(&mut self, i: &mut PatWild) { visit_pat_wild_mut(self, i); } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_path_mut(&mut self, i: &mut Path) { visit_path_mut(self, i); } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_path_arguments_mut(&mut self, i: &mut PathArguments) { visit_path_arguments_mut(self, i); } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_path_segment_mut(&mut self, i: &mut PathSegment) { visit_path_segment_mut(self, i); } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_predicate_lifetime_mut(&mut self, i: &mut PredicateLifetime) { visit_predicate_lifetime_mut(self, i); } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_predicate_type_mut(&mut self, i: &mut PredicateType) { visit_predicate_type_mut(self, i); } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_qself_mut(&mut self, i: &mut QSelf) { visit_qself_mut(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_range_limits_mut(&mut self, i: &mut RangeLimits) { visit_range_limits_mut(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_receiver_mut(&mut self, i: &mut Receiver) { visit_receiver_mut(self, i); } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_return_type_mut(&mut self, i: &mut ReturnType) { visit_return_type_mut(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_signature_mut(&mut self, i: &mut Signature) { visit_signature_mut(self, i); } @@ -593,167 +724,208 @@ pub trait VisitMut { visit_span_mut(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_static_mutability_mut(&mut self, i: &mut StaticMutability) { visit_static_mutability_mut(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_stmt_mut(&mut self, i: &mut Stmt) { visit_stmt_mut(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(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"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_trait_bound_mut(&mut self, i: &mut TraitBound) { visit_trait_bound_mut(self, i); } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_trait_bound_modifier_mut(&mut self, i: &mut TraitBoundModifier) { visit_trait_bound_modifier_mut(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_trait_item_mut(&mut self, i: &mut TraitItem) { visit_trait_item_mut(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_trait_item_const_mut(&mut self, i: &mut TraitItemConst) { visit_trait_item_const_mut(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_trait_item_fn_mut(&mut self, i: &mut TraitItemFn) { visit_trait_item_fn_mut(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_trait_item_macro_mut(&mut self, i: &mut TraitItemMacro) { visit_trait_item_macro_mut(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_trait_item_type_mut(&mut self, i: &mut TraitItemType) { visit_trait_item_type_mut(self, i); } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_type_mut(&mut self, i: &mut Type) { visit_type_mut(self, i); } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_type_array_mut(&mut self, i: &mut TypeArray) { visit_type_array_mut(self, i); } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_type_bare_fn_mut(&mut self, i: &mut TypeBareFn) { visit_type_bare_fn_mut(self, i); } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_type_group_mut(&mut self, i: &mut TypeGroup) { visit_type_group_mut(self, i); } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_type_impl_trait_mut(&mut self, i: &mut TypeImplTrait) { visit_type_impl_trait_mut(self, i); } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_type_infer_mut(&mut self, i: &mut TypeInfer) { visit_type_infer_mut(self, i); } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_type_macro_mut(&mut self, i: &mut TypeMacro) { visit_type_macro_mut(self, i); } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_type_never_mut(&mut self, i: &mut TypeNever) { visit_type_never_mut(self, i); } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_type_param_mut(&mut self, i: &mut TypeParam) { visit_type_param_mut(self, i); } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_type_param_bound_mut(&mut self, i: &mut TypeParamBound) { visit_type_param_bound_mut(self, i); } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_type_paren_mut(&mut self, i: &mut TypeParen) { visit_type_paren_mut(self, i); } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_type_path_mut(&mut self, i: &mut TypePath) { visit_type_path_mut(self, i); } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_type_ptr_mut(&mut self, i: &mut TypePtr) { visit_type_ptr_mut(self, i); } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_type_reference_mut(&mut self, i: &mut TypeReference) { visit_type_reference_mut(self, i); } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_type_slice_mut(&mut self, i: &mut TypeSlice) { visit_type_slice_mut(self, i); } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_type_trait_object_mut(&mut self, i: &mut TypeTraitObject) { visit_type_trait_object_mut(self, i); } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_type_tuple_mut(&mut self, i: &mut TypeTuple) { visit_type_tuple_mut(self, i); } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_un_op_mut(&mut self, i: &mut UnOp) { visit_un_op_mut(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_use_glob_mut(&mut self, i: &mut UseGlob) { visit_use_glob_mut(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_use_group_mut(&mut self, i: &mut UseGroup) { visit_use_group_mut(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_use_name_mut(&mut self, i: &mut UseName) { visit_use_name_mut(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_use_path_mut(&mut self, i: &mut UsePath) { visit_use_path_mut(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_use_rename_mut(&mut self, i: &mut UseRename) { visit_use_rename_mut(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_use_tree_mut(&mut self, i: &mut UseTree) { visit_use_tree_mut(self, i); } #[cfg(feature = "full")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] fn visit_variadic_mut(&mut self, i: &mut Variadic) { visit_variadic_mut(self, i); } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_variant_mut(&mut self, i: &mut Variant) { visit_variant_mut(self, i); } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_vis_restricted_mut(&mut self, i: &mut VisRestricted) { visit_vis_restricted_mut(self, i); } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_visibility_mut(&mut self, i: &mut Visibility) { visit_visibility_mut(self, i); } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_where_clause_mut(&mut self, i: &mut WhereClause) { visit_where_clause_mut(self, i); } #[cfg(any(feature = "derive", feature = "full"))] + #[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] fn visit_where_predicate_mut(&mut self, i: &mut WherePredicate) { visit_where_predicate_mut(self, i); } } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_abi_mut(v: &mut V, node: &mut Abi) where V: VisitMut + ?Sized, @@ -764,6 +936,7 @@ where } } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_angle_bracketed_generic_arguments_mut( v: &mut V, node: &mut AngleBracketedGenericArguments, @@ -780,6 +953,7 @@ where skip!(node.gt_token); } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_arm_mut(v: &mut V, node: &mut Arm) where V: VisitMut + ?Sized, @@ -797,6 +971,7 @@ where skip!(node.comma); } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_assoc_const_mut(v: &mut V, node: &mut AssocConst) where V: VisitMut + ?Sized, @@ -809,6 +984,7 @@ where v.visit_expr_mut(&mut node.value); } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_assoc_type_mut(v: &mut V, node: &mut AssocType) where V: VisitMut + ?Sized, @@ -821,6 +997,7 @@ where v.visit_type_mut(&mut node.ty); } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_attr_style_mut(v: &mut V, node: &mut AttrStyle) where V: VisitMut + ?Sized, @@ -833,6 +1010,7 @@ where } } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_attribute_mut(v: &mut V, node: &mut Attribute) where V: VisitMut + ?Sized, @@ -843,6 +1021,7 @@ where v.visit_meta_mut(&mut node.meta); } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_bare_fn_arg_mut(v: &mut V, node: &mut BareFnArg) where V: VisitMut + ?Sized, @@ -857,6 +1036,7 @@ where v.visit_type_mut(&mut node.ty); } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_bare_variadic_mut(v: &mut V, node: &mut BareVariadic) where V: VisitMut + ?Sized, @@ -872,6 +1052,7 @@ where skip!(node.comma); } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_bin_op_mut(v: &mut V, node: &mut BinOp) where V: VisitMut + ?Sized, @@ -964,6 +1145,7 @@ where } } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_block_mut(v: &mut V, node: &mut Block) where V: VisitMut + ?Sized, @@ -974,6 +1156,7 @@ where } } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_bound_lifetimes_mut(v: &mut V, node: &mut BoundLifetimes) where V: VisitMut + ?Sized, @@ -987,6 +1170,7 @@ where skip!(node.gt_token); } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_const_param_mut(v: &mut V, node: &mut ConstParam) where V: VisitMut + ?Sized, @@ -1004,6 +1188,7 @@ where } } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_constraint_mut(v: &mut V, node: &mut Constraint) where V: VisitMut + ?Sized, @@ -1019,6 +1204,7 @@ where } } #[cfg(feature = "derive")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "derive")))] pub fn visit_data_mut(v: &mut V, node: &mut Data) where V: VisitMut + ?Sized, @@ -1036,6 +1222,7 @@ where } } #[cfg(feature = "derive")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "derive")))] pub fn visit_data_enum_mut(v: &mut V, node: &mut DataEnum) where V: VisitMut + ?Sized, @@ -1048,6 +1235,7 @@ where } } #[cfg(feature = "derive")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "derive")))] pub fn visit_data_struct_mut(v: &mut V, node: &mut DataStruct) where V: VisitMut + ?Sized, @@ -1057,6 +1245,7 @@ where skip!(node.semi_token); } #[cfg(feature = "derive")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "derive")))] pub fn visit_data_union_mut(v: &mut V, node: &mut DataUnion) where V: VisitMut + ?Sized, @@ -1065,6 +1254,7 @@ where v.visit_fields_named_mut(&mut node.fields); } #[cfg(feature = "derive")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "derive")))] pub fn visit_derive_input_mut(v: &mut V, node: &mut DeriveInput) where V: VisitMut + ?Sized, @@ -1078,6 +1268,7 @@ where v.visit_data_mut(&mut node.data); } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_expr_mut(v: &mut V, node: &mut Expr) where V: VisitMut + ?Sized, @@ -1153,7 +1344,7 @@ where full!(v.visit_expr_match_mut(_binding_0)); } Expr::MethodCall(_binding_0) => { - full!(v.visit_expr_method_call_mut(_binding_0)); + v.visit_expr_method_call_mut(_binding_0); } Expr::Paren(_binding_0) => { v.visit_expr_paren_mut(_binding_0); @@ -1165,7 +1356,7 @@ where full!(v.visit_expr_range_mut(_binding_0)); } Expr::Reference(_binding_0) => { - full!(v.visit_expr_reference_mut(_binding_0)); + v.visit_expr_reference_mut(_binding_0); } Expr::Repeat(_binding_0) => { full!(v.visit_expr_repeat_mut(_binding_0)); @@ -1174,7 +1365,7 @@ where full!(v.visit_expr_return_mut(_binding_0)); } Expr::Struct(_binding_0) => { - full!(v.visit_expr_struct_mut(_binding_0)); + v.visit_expr_struct_mut(_binding_0); } Expr::Try(_binding_0) => { full!(v.visit_expr_try_mut(_binding_0)); @@ -1203,6 +1394,7 @@ where } } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_expr_array_mut(v: &mut V, node: &mut ExprArray) where V: VisitMut + ?Sized, @@ -1217,6 +1409,7 @@ where } } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_expr_assign_mut(v: &mut V, node: &mut ExprAssign) where V: VisitMut + ?Sized, @@ -1229,6 +1422,7 @@ where v.visit_expr_mut(&mut *node.right); } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_expr_async_mut(v: &mut V, node: &mut ExprAsync) where V: VisitMut + ?Sized, @@ -1241,6 +1435,7 @@ where v.visit_block_mut(&mut node.block); } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_expr_await_mut(v: &mut V, node: &mut ExprAwait) where V: VisitMut + ?Sized, @@ -1253,6 +1448,7 @@ where skip!(node.await_token); } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_expr_binary_mut(v: &mut V, node: &mut ExprBinary) where V: VisitMut + ?Sized, @@ -1265,6 +1461,7 @@ where v.visit_expr_mut(&mut *node.right); } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_expr_block_mut(v: &mut V, node: &mut ExprBlock) where V: VisitMut + ?Sized, @@ -1278,6 +1475,7 @@ where v.visit_block_mut(&mut node.block); } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_expr_break_mut(v: &mut V, node: &mut ExprBreak) where V: VisitMut + ?Sized, @@ -1294,6 +1492,7 @@ where } } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_expr_call_mut(v: &mut V, node: &mut ExprCall) where V: VisitMut + ?Sized, @@ -1309,6 +1508,7 @@ where } } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_expr_cast_mut(v: &mut V, node: &mut ExprCast) where V: VisitMut + ?Sized, @@ -1321,6 +1521,7 @@ where v.visit_type_mut(&mut *node.ty); } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_expr_closure_mut(v: &mut V, node: &mut ExprClosure) where V: VisitMut + ?Sized, @@ -1345,6 +1546,7 @@ where v.visit_expr_mut(&mut *node.body); } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_expr_const_mut(v: &mut V, node: &mut ExprConst) where V: VisitMut + ?Sized, @@ -1356,6 +1558,7 @@ where v.visit_block_mut(&mut node.block); } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_expr_continue_mut(v: &mut V, node: &mut ExprContinue) where V: VisitMut + ?Sized, @@ -1369,6 +1572,7 @@ where } } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_expr_field_mut(v: &mut V, node: &mut ExprField) where V: VisitMut + ?Sized, @@ -1381,6 +1585,7 @@ where v.visit_member_mut(&mut node.member); } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_expr_for_loop_mut(v: &mut V, node: &mut ExprForLoop) where V: VisitMut + ?Sized, @@ -1398,6 +1603,7 @@ where v.visit_block_mut(&mut node.body); } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_expr_group_mut(v: &mut V, node: &mut ExprGroup) where V: VisitMut + ?Sized, @@ -1409,6 +1615,7 @@ where v.visit_expr_mut(&mut *node.expr); } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_expr_if_mut(v: &mut V, node: &mut ExprIf) where V: VisitMut + ?Sized, @@ -1425,6 +1632,7 @@ where } } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_expr_index_mut(v: &mut V, node: &mut ExprIndex) where V: VisitMut + ?Sized, @@ -1437,6 +1645,7 @@ where v.visit_expr_mut(&mut *node.index); } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_expr_infer_mut(v: &mut V, node: &mut ExprInfer) where V: VisitMut + ?Sized, @@ -1447,6 +1656,7 @@ where skip!(node.underscore_token); } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_expr_let_mut(v: &mut V, node: &mut ExprLet) where V: VisitMut + ?Sized, @@ -1460,6 +1670,7 @@ where v.visit_expr_mut(&mut *node.expr); } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_expr_lit_mut(v: &mut V, node: &mut ExprLit) where V: VisitMut + ?Sized, @@ -1470,6 +1681,7 @@ where v.visit_lit_mut(&mut node.lit); } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_expr_loop_mut(v: &mut V, node: &mut ExprLoop) where V: VisitMut + ?Sized, @@ -1484,6 +1696,7 @@ where v.visit_block_mut(&mut node.body); } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_expr_macro_mut(v: &mut V, node: &mut ExprMacro) where V: VisitMut + ?Sized, @@ -1494,6 +1707,7 @@ where v.visit_macro_mut(&mut node.mac); } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_expr_match_mut(v: &mut V, node: &mut ExprMatch) where V: VisitMut + ?Sized, @@ -1508,7 +1722,8 @@ where v.visit_arm_mut(it); } } -#[cfg(feature = "full")] +#[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_expr_method_call_mut(v: &mut V, node: &mut ExprMethodCall) where V: VisitMut + ?Sized, @@ -1529,6 +1744,7 @@ where } } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_expr_paren_mut(v: &mut V, node: &mut ExprParen) where V: VisitMut + ?Sized, @@ -1540,6 +1756,7 @@ where v.visit_expr_mut(&mut *node.expr); } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_expr_path_mut(v: &mut V, node: &mut ExprPath) where V: VisitMut + ?Sized, @@ -1553,6 +1770,7 @@ where v.visit_path_mut(&mut node.path); } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_expr_range_mut(v: &mut V, node: &mut ExprRange) where V: VisitMut + ?Sized, @@ -1568,7 +1786,8 @@ where v.visit_expr_mut(&mut **it); } } -#[cfg(feature = "full")] +#[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_expr_reference_mut(v: &mut V, node: &mut ExprReference) where V: VisitMut + ?Sized, @@ -1581,6 +1800,7 @@ where v.visit_expr_mut(&mut *node.expr); } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_expr_repeat_mut(v: &mut V, node: &mut ExprRepeat) where V: VisitMut + ?Sized, @@ -1594,6 +1814,7 @@ where v.visit_expr_mut(&mut *node.len); } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_expr_return_mut(v: &mut V, node: &mut ExprReturn) where V: VisitMut + ?Sized, @@ -1606,7 +1827,8 @@ where v.visit_expr_mut(&mut **it); } } -#[cfg(feature = "full")] +#[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_expr_struct_mut(v: &mut V, node: &mut ExprStruct) where V: VisitMut + ?Sized, @@ -1629,6 +1851,7 @@ where } } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_expr_try_mut(v: &mut V, node: &mut ExprTry) where V: VisitMut + ?Sized, @@ -1640,6 +1863,7 @@ where skip!(node.question_token); } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_expr_try_block_mut(v: &mut V, node: &mut ExprTryBlock) where V: VisitMut + ?Sized, @@ -1651,6 +1875,7 @@ where v.visit_block_mut(&mut node.block); } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_expr_tuple_mut(v: &mut V, node: &mut ExprTuple) where V: VisitMut + ?Sized, @@ -1665,6 +1890,7 @@ where } } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_expr_unary_mut(v: &mut V, node: &mut ExprUnary) where V: VisitMut + ?Sized, @@ -1676,6 +1902,7 @@ where v.visit_expr_mut(&mut *node.expr); } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_expr_unsafe_mut(v: &mut V, node: &mut ExprUnsafe) where V: VisitMut + ?Sized, @@ -1687,6 +1914,7 @@ where v.visit_block_mut(&mut node.block); } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_expr_while_mut(v: &mut V, node: &mut ExprWhile) where V: VisitMut + ?Sized, @@ -1702,6 +1930,7 @@ where v.visit_block_mut(&mut node.body); } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_expr_yield_mut(v: &mut V, node: &mut ExprYield) where V: VisitMut + ?Sized, @@ -1715,6 +1944,7 @@ where } } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_field_mut(v: &mut V, node: &mut Field) where V: VisitMut + ?Sized, @@ -1731,6 +1961,7 @@ where v.visit_type_mut(&mut node.ty); } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_field_mutability_mut(v: &mut V, node: &mut FieldMutability) where V: VisitMut + ?Sized, @@ -1740,6 +1971,7 @@ where } } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_field_pat_mut(v: &mut V, node: &mut FieldPat) where V: VisitMut + ?Sized, @@ -1751,7 +1983,8 @@ where skip!(node.colon_token); v.visit_pat_mut(&mut *node.pat); } -#[cfg(feature = "full")] +#[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_field_value_mut(v: &mut V, node: &mut FieldValue) where V: VisitMut + ?Sized, @@ -1764,6 +1997,7 @@ where v.visit_expr_mut(&mut node.expr); } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_fields_mut(v: &mut V, node: &mut Fields) where V: VisitMut + ?Sized, @@ -1779,6 +2013,7 @@ where } } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_fields_named_mut(v: &mut V, node: &mut FieldsNamed) where V: VisitMut + ?Sized, @@ -1790,6 +2025,7 @@ where } } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_fields_unnamed_mut(v: &mut V, node: &mut FieldsUnnamed) where V: VisitMut + ?Sized, @@ -1801,6 +2037,7 @@ where } } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_file_mut(v: &mut V, node: &mut File) where V: VisitMut + ?Sized, @@ -1814,6 +2051,7 @@ where } } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_fn_arg_mut(v: &mut V, node: &mut FnArg) where V: VisitMut + ?Sized, @@ -1828,6 +2066,7 @@ where } } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_foreign_item_mut(v: &mut V, node: &mut ForeignItem) where V: VisitMut + ?Sized, @@ -1851,6 +2090,7 @@ where } } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_foreign_item_fn_mut(v: &mut V, node: &mut ForeignItemFn) where V: VisitMut + ?Sized, @@ -1863,6 +2103,7 @@ where skip!(node.semi_token); } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_foreign_item_macro_mut(v: &mut V, node: &mut ForeignItemMacro) where V: VisitMut + ?Sized, @@ -1874,6 +2115,7 @@ where skip!(node.semi_token); } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_foreign_item_static_mut(v: &mut V, node: &mut ForeignItemStatic) where V: VisitMut + ?Sized, @@ -1890,6 +2132,7 @@ where skip!(node.semi_token); } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_foreign_item_type_mut(v: &mut V, node: &mut ForeignItemType) where V: VisitMut + ?Sized, @@ -1904,6 +2147,7 @@ where skip!(node.semi_token); } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_generic_argument_mut(v: &mut V, node: &mut GenericArgument) where V: VisitMut + ?Sized, @@ -1930,6 +2174,7 @@ where } } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_generic_param_mut(v: &mut V, node: &mut GenericParam) where V: VisitMut + ?Sized, @@ -1947,6 +2192,7 @@ where } } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_generics_mut(v: &mut V, node: &mut Generics) where V: VisitMut + ?Sized, @@ -1970,6 +2216,7 @@ where node.set_span(span); } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_impl_item_mut(v: &mut V, node: &mut ImplItem) where V: VisitMut + ?Sized, @@ -1993,6 +2240,7 @@ where } } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_impl_item_const_mut(v: &mut V, node: &mut ImplItemConst) where V: VisitMut + ?Sized, @@ -2012,6 +2260,7 @@ where skip!(node.semi_token); } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_impl_item_fn_mut(v: &mut V, node: &mut ImplItemFn) where V: VisitMut + ?Sized, @@ -2025,6 +2274,7 @@ where v.visit_block_mut(&mut node.block); } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_impl_item_macro_mut(v: &mut V, node: &mut ImplItemMacro) where V: VisitMut + ?Sized, @@ -2036,6 +2286,7 @@ where skip!(node.semi_token); } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_impl_item_type_mut(v: &mut V, node: &mut ImplItemType) where V: VisitMut + ?Sized, @@ -2053,6 +2304,7 @@ where skip!(node.semi_token); } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_impl_restriction_mut(v: &mut V, node: &mut ImplRestriction) where V: VisitMut + ?Sized, @@ -2060,6 +2312,7 @@ where match *node {} } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_index_mut(v: &mut V, node: &mut Index) where V: VisitMut + ?Sized, @@ -2068,6 +2321,7 @@ where v.visit_span_mut(&mut node.span); } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_item_mut(v: &mut V, node: &mut Item) where V: VisitMut + ?Sized, @@ -2124,6 +2378,7 @@ where } } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_item_const_mut(v: &mut V, node: &mut ItemConst) where V: VisitMut + ?Sized, @@ -2142,6 +2397,7 @@ where skip!(node.semi_token); } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_item_enum_mut(v: &mut V, node: &mut ItemEnum) where V: VisitMut + ?Sized, @@ -2160,6 +2416,7 @@ where } } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_item_extern_crate_mut(v: &mut V, node: &mut ItemExternCrate) where V: VisitMut + ?Sized, @@ -2178,6 +2435,7 @@ where skip!(node.semi_token); } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_item_fn_mut(v: &mut V, node: &mut ItemFn) where V: VisitMut + ?Sized, @@ -2190,6 +2448,7 @@ where v.visit_block_mut(&mut *node.block); } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_item_foreign_mod_mut(v: &mut V, node: &mut ItemForeignMod) where V: VisitMut + ?Sized, @@ -2205,6 +2464,7 @@ where } } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_item_impl_mut(v: &mut V, node: &mut ItemImpl) where V: VisitMut + ?Sized, @@ -2228,6 +2488,7 @@ where } } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_item_macro_mut(v: &mut V, node: &mut ItemMacro) where V: VisitMut + ?Sized, @@ -2242,6 +2503,7 @@ where skip!(node.semi_token); } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_item_mod_mut(v: &mut V, node: &mut ItemMod) where V: VisitMut + ?Sized, @@ -2262,6 +2524,7 @@ where skip!(node.semi); } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_item_static_mut(v: &mut V, node: &mut ItemStatic) where V: VisitMut + ?Sized, @@ -2280,6 +2543,7 @@ where skip!(node.semi_token); } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_item_struct_mut(v: &mut V, node: &mut ItemStruct) where V: VisitMut + ?Sized, @@ -2295,6 +2559,7 @@ where skip!(node.semi_token); } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_item_trait_mut(v: &mut V, node: &mut ItemTrait) where V: VisitMut + ?Sized, @@ -2322,6 +2587,7 @@ where } } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_item_trait_alias_mut(v: &mut V, node: &mut ItemTraitAlias) where V: VisitMut + ?Sized, @@ -2341,6 +2607,7 @@ where skip!(node.semi_token); } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_item_type_mut(v: &mut V, node: &mut ItemType) where V: VisitMut + ?Sized, @@ -2357,6 +2624,7 @@ where skip!(node.semi_token); } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_item_union_mut(v: &mut V, node: &mut ItemUnion) where V: VisitMut + ?Sized, @@ -2371,6 +2639,7 @@ where v.visit_fields_named_mut(&mut node.fields); } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_item_use_mut(v: &mut V, node: &mut ItemUse) where V: VisitMut + ?Sized, @@ -2385,6 +2654,7 @@ where skip!(node.semi_token); } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_label_mut(v: &mut V, node: &mut Label) where V: VisitMut + ?Sized, @@ -2400,6 +2670,7 @@ where v.visit_ident_mut(&mut node.ident); } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_lifetime_param_mut(v: &mut V, node: &mut LifetimeParam) where V: VisitMut + ?Sized, @@ -2477,6 +2748,7 @@ where V: VisitMut + ?Sized, {} #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_local_mut(v: &mut V, node: &mut Local) where V: VisitMut + ?Sized, @@ -2492,6 +2764,7 @@ where skip!(node.semi_token); } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_local_init_mut(v: &mut V, node: &mut LocalInit) where V: VisitMut + ?Sized, @@ -2504,6 +2777,7 @@ where } } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_macro_mut(v: &mut V, node: &mut Macro) where V: VisitMut + ?Sized, @@ -2514,6 +2788,7 @@ where skip!(node.tokens); } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_macro_delimiter_mut(v: &mut V, node: &mut MacroDelimiter) where V: VisitMut + ?Sized, @@ -2531,6 +2806,7 @@ where } } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_member_mut(v: &mut V, node: &mut Member) where V: VisitMut + ?Sized, @@ -2545,6 +2821,7 @@ where } } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_meta_mut(v: &mut V, node: &mut Meta) where V: VisitMut + ?Sized, @@ -2562,6 +2839,7 @@ where } } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_meta_list_mut(v: &mut V, node: &mut MetaList) where V: VisitMut + ?Sized, @@ -2571,6 +2849,7 @@ where skip!(node.tokens); } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_meta_name_value_mut(v: &mut V, node: &mut MetaNameValue) where V: VisitMut + ?Sized, @@ -2580,6 +2859,7 @@ where v.visit_expr_mut(&mut node.value); } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_parenthesized_generic_arguments_mut( v: &mut V, node: &mut ParenthesizedGenericArguments, @@ -2595,6 +2875,7 @@ where v.visit_return_type_mut(&mut node.output); } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_pat_mut(v: &mut V, node: &mut Pat) where V: VisitMut + ?Sized, @@ -2654,6 +2935,7 @@ where } } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_pat_ident_mut(v: &mut V, node: &mut PatIdent) where V: VisitMut + ?Sized, @@ -2670,6 +2952,7 @@ where } } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_pat_or_mut(v: &mut V, node: &mut PatOr) where V: VisitMut + ?Sized, @@ -2684,6 +2967,7 @@ where } } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_pat_paren_mut(v: &mut V, node: &mut PatParen) where V: VisitMut + ?Sized, @@ -2695,6 +2979,7 @@ where v.visit_pat_mut(&mut *node.pat); } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_pat_reference_mut(v: &mut V, node: &mut PatReference) where V: VisitMut + ?Sized, @@ -2707,6 +2992,7 @@ where v.visit_pat_mut(&mut *node.pat); } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_pat_rest_mut(v: &mut V, node: &mut PatRest) where V: VisitMut + ?Sized, @@ -2717,6 +3003,7 @@ where skip!(node.dot2_token); } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_pat_slice_mut(v: &mut V, node: &mut PatSlice) where V: VisitMut + ?Sized, @@ -2731,6 +3018,7 @@ where } } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_pat_struct_mut(v: &mut V, node: &mut PatStruct) where V: VisitMut + ?Sized, @@ -2752,6 +3040,7 @@ where } } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_pat_tuple_mut(v: &mut V, node: &mut PatTuple) where V: VisitMut + ?Sized, @@ -2766,6 +3055,7 @@ where } } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_pat_tuple_struct_mut(v: &mut V, node: &mut PatTupleStruct) where V: VisitMut + ?Sized, @@ -2784,6 +3074,7 @@ where } } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_pat_type_mut(v: &mut V, node: &mut PatType) where V: VisitMut + ?Sized, @@ -2796,6 +3087,7 @@ where v.visit_type_mut(&mut *node.ty); } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_pat_wild_mut(v: &mut V, node: &mut PatWild) where V: VisitMut + ?Sized, @@ -2806,6 +3098,7 @@ where skip!(node.underscore_token); } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_path_mut(v: &mut V, node: &mut Path) where V: VisitMut + ?Sized, @@ -2817,6 +3110,7 @@ where } } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_path_arguments_mut(v: &mut V, node: &mut PathArguments) where V: VisitMut + ?Sized, @@ -2832,6 +3126,7 @@ where } } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_path_segment_mut(v: &mut V, node: &mut PathSegment) where V: VisitMut + ?Sized, @@ -2840,6 +3135,7 @@ where v.visit_path_arguments_mut(&mut node.arguments); } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_predicate_lifetime_mut(v: &mut V, node: &mut PredicateLifetime) where V: VisitMut + ?Sized, @@ -2852,6 +3148,7 @@ where } } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_predicate_type_mut(v: &mut V, node: &mut PredicateType) where V: VisitMut + ?Sized, @@ -2867,6 +3164,7 @@ where } } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_qself_mut(v: &mut V, node: &mut QSelf) where V: VisitMut + ?Sized, @@ -2878,6 +3176,7 @@ where skip!(node.gt_token); } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_range_limits_mut(v: &mut V, node: &mut RangeLimits) where V: VisitMut + ?Sized, @@ -2892,6 +3191,7 @@ where } } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_receiver_mut(v: &mut V, node: &mut Receiver) where V: VisitMut + ?Sized, @@ -2911,6 +3211,7 @@ where v.visit_type_mut(&mut *node.ty); } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_return_type_mut(v: &mut V, node: &mut ReturnType) where V: VisitMut + ?Sized, @@ -2924,6 +3225,7 @@ where } } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_signature_mut(v: &mut V, node: &mut Signature) where V: VisitMut + ?Sized, @@ -2952,6 +3254,7 @@ where V: VisitMut + ?Sized, {} #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_static_mutability_mut(v: &mut V, node: &mut StaticMutability) where V: VisitMut + ?Sized, @@ -2964,6 +3267,7 @@ where } } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_stmt_mut(v: &mut V, node: &mut Stmt) where V: VisitMut + ?Sized, @@ -2985,6 +3289,7 @@ where } } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_stmt_macro_mut(v: &mut V, node: &mut StmtMacro) where V: VisitMut + ?Sized, @@ -2996,6 +3301,7 @@ where skip!(node.semi_token); } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_trait_bound_mut(v: &mut V, node: &mut TraitBound) where V: VisitMut + ?Sized, @@ -3008,6 +3314,7 @@ where v.visit_path_mut(&mut node.path); } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_trait_bound_modifier_mut(v: &mut V, node: &mut TraitBoundModifier) where V: VisitMut + ?Sized, @@ -3020,6 +3327,7 @@ where } } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_trait_item_mut(v: &mut V, node: &mut TraitItem) where V: VisitMut + ?Sized, @@ -3043,6 +3351,7 @@ where } } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_trait_item_const_mut(v: &mut V, node: &mut TraitItemConst) where V: VisitMut + ?Sized, @@ -3062,6 +3371,7 @@ where skip!(node.semi_token); } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_trait_item_fn_mut(v: &mut V, node: &mut TraitItemFn) where V: VisitMut + ?Sized, @@ -3076,6 +3386,7 @@ where skip!(node.semi_token); } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_trait_item_macro_mut(v: &mut V, node: &mut TraitItemMacro) where V: VisitMut + ?Sized, @@ -3087,6 +3398,7 @@ where skip!(node.semi_token); } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_trait_item_type_mut(v: &mut V, node: &mut TraitItemType) where V: VisitMut + ?Sized, @@ -3109,6 +3421,7 @@ where skip!(node.semi_token); } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_type_mut(v: &mut V, node: &mut Type) where V: VisitMut + ?Sized, @@ -3162,6 +3475,7 @@ where } } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_type_array_mut(v: &mut V, node: &mut TypeArray) where V: VisitMut + ?Sized, @@ -3172,6 +3486,7 @@ where v.visit_expr_mut(&mut node.len); } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_type_bare_fn_mut(v: &mut V, node: &mut TypeBareFn) where V: VisitMut + ?Sized, @@ -3195,6 +3510,7 @@ where v.visit_return_type_mut(&mut node.output); } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_type_group_mut(v: &mut V, node: &mut TypeGroup) where V: VisitMut + ?Sized, @@ -3203,6 +3519,7 @@ where v.visit_type_mut(&mut *node.elem); } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_type_impl_trait_mut(v: &mut V, node: &mut TypeImplTrait) where V: VisitMut + ?Sized, @@ -3214,6 +3531,7 @@ where } } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_type_infer_mut(v: &mut V, node: &mut TypeInfer) where V: VisitMut + ?Sized, @@ -3221,6 +3539,7 @@ where skip!(node.underscore_token); } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_type_macro_mut(v: &mut V, node: &mut TypeMacro) where V: VisitMut + ?Sized, @@ -3228,6 +3547,7 @@ where v.visit_macro_mut(&mut node.mac); } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_type_never_mut(v: &mut V, node: &mut TypeNever) where V: VisitMut + ?Sized, @@ -3235,6 +3555,7 @@ where skip!(node.bang_token); } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_type_param_mut(v: &mut V, node: &mut TypeParam) where V: VisitMut + ?Sized, @@ -3254,6 +3575,7 @@ where } } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_type_param_bound_mut(v: &mut V, node: &mut TypeParamBound) where V: VisitMut + ?Sized, @@ -3271,6 +3593,7 @@ where } } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_type_paren_mut(v: &mut V, node: &mut TypeParen) where V: VisitMut + ?Sized, @@ -3279,6 +3602,7 @@ where v.visit_type_mut(&mut *node.elem); } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_type_path_mut(v: &mut V, node: &mut TypePath) where V: VisitMut + ?Sized, @@ -3289,6 +3613,7 @@ where v.visit_path_mut(&mut node.path); } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_type_ptr_mut(v: &mut V, node: &mut TypePtr) where V: VisitMut + ?Sized, @@ -3299,6 +3624,7 @@ where v.visit_type_mut(&mut *node.elem); } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_type_reference_mut(v: &mut V, node: &mut TypeReference) where V: VisitMut + ?Sized, @@ -3311,6 +3637,7 @@ where v.visit_type_mut(&mut *node.elem); } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_type_slice_mut(v: &mut V, node: &mut TypeSlice) where V: VisitMut + ?Sized, @@ -3319,6 +3646,7 @@ where v.visit_type_mut(&mut *node.elem); } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_type_trait_object_mut(v: &mut V, node: &mut TypeTraitObject) where V: VisitMut + ?Sized, @@ -3330,6 +3658,7 @@ where } } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_type_tuple_mut(v: &mut V, node: &mut TypeTuple) where V: VisitMut + ?Sized, @@ -3341,6 +3670,7 @@ where } } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_un_op_mut(v: &mut V, node: &mut UnOp) where V: VisitMut + ?Sized, @@ -3358,6 +3688,7 @@ where } } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_use_glob_mut(v: &mut V, node: &mut UseGlob) where V: VisitMut + ?Sized, @@ -3365,6 +3696,7 @@ where skip!(node.star_token); } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_use_group_mut(v: &mut V, node: &mut UseGroup) where V: VisitMut + ?Sized, @@ -3376,6 +3708,7 @@ where } } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_use_name_mut(v: &mut V, node: &mut UseName) where V: VisitMut + ?Sized, @@ -3383,6 +3716,7 @@ where v.visit_ident_mut(&mut node.ident); } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_use_path_mut(v: &mut V, node: &mut UsePath) where V: VisitMut + ?Sized, @@ -3392,6 +3726,7 @@ where v.visit_use_tree_mut(&mut *node.tree); } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_use_rename_mut(v: &mut V, node: &mut UseRename) where V: VisitMut + ?Sized, @@ -3401,6 +3736,7 @@ where v.visit_ident_mut(&mut node.rename); } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_use_tree_mut(v: &mut V, node: &mut UseTree) where V: VisitMut + ?Sized, @@ -3424,6 +3760,7 @@ where } } #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub fn visit_variadic_mut(v: &mut V, node: &mut Variadic) where V: VisitMut + ?Sized, @@ -3439,6 +3776,7 @@ where skip!(node.comma); } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_variant_mut(v: &mut V, node: &mut Variant) where V: VisitMut + ?Sized, @@ -3454,6 +3792,7 @@ where } } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_vis_restricted_mut(v: &mut V, node: &mut VisRestricted) where V: VisitMut + ?Sized, @@ -3464,6 +3803,7 @@ where v.visit_path_mut(&mut *node.path); } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_visibility_mut(v: &mut V, node: &mut Visibility) where V: VisitMut + ?Sized, @@ -3479,6 +3819,7 @@ where } } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_where_clause_mut(v: &mut V, node: &mut WhereClause) where V: VisitMut + ?Sized, @@ -3490,6 +3831,7 @@ where } } #[cfg(any(feature = "derive", feature = "full"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "derive", feature = "full"))))] pub fn visit_where_predicate_mut(v: &mut V, node: &mut WherePredicate) where V: VisitMut + ?Sized, diff --git a/third_party/rust/syn/src/generics.rs b/third_party/rust/syn/src/generics.rs index 2ad913d1da04b..aed50e30477ca 100644 --- a/third_party/rust/syn/src/generics.rs +++ b/third_party/rust/syn/src/generics.rs @@ -532,7 +532,7 @@ ast_struct! { #[cfg(feature = "parsing")] pub(crate) mod parsing { use super::*; - use crate::ext::IdentExt; + use crate::ext::IdentExt as _; use crate::parse::{Parse, ParseStream, Result}; #[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))] diff --git a/third_party/rust/syn/src/item.rs b/third_party/rust/syn/src/item.rs index ee91f5914cef5..b56f8b239e72f 100644 --- a/third_party/rust/syn/src/item.rs +++ b/third_party/rust/syn/src/item.rs @@ -890,8 +890,8 @@ ast_enum! { #[cfg(feature = "parsing")] pub(crate) mod parsing { use super::*; - use crate::ext::IdentExt; - use crate::parse::discouraged::Speculative; + use crate::ext::IdentExt as _; + use crate::parse::discouraged::Speculative as _; use crate::parse::{Parse, ParseBuffer, ParseStream, Result}; #[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))] diff --git a/third_party/rust/syn/src/lib.rs b/third_party/rust/syn/src/lib.rs index a3df727a975f9..19c27a2f59037 100644 --- a/third_party/rust/syn/src/lib.rs +++ b/third_party/rust/syn/src/lib.rs @@ -249,8 +249,9 @@ //! 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/2.0.39")] +#![doc(html_root_url = "https://docs.rs/syn/2.0.46")] #![cfg_attr(doc_cfg, feature(doc_cfg))] +#![deny(unsafe_op_in_unsafe_fn)] #![allow(non_camel_case_types)] #![allow( clippy::bool_to_int_with_if, @@ -260,6 +261,7 @@ clippy::cast_ptr_alignment, clippy::default_trait_access, clippy::derivable_impls, + clippy::diverging_sub_expression, clippy::doc_markdown, clippy::expl_impl_clone_on_copy, clippy::explicit_auto_deref, @@ -290,6 +292,7 @@ clippy::too_many_arguments, clippy::too_many_lines, clippy::trivially_copy_pass_by_ref, + clippy::uninhabited_references, clippy::uninlined_format_args, clippy::unnecessary_box_returns, clippy::unnecessary_unwrap, @@ -313,6 +316,7 @@ pub mod token; #[cfg(any(feature = "full", feature = "derive"))] mod attr; #[cfg(any(feature = "full", feature = "derive"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "full", feature = "derive"))))] pub use crate::attr::{AttrStyle, Attribute, Meta, MetaList, MetaNameValue}; mod bigint; @@ -328,11 +332,13 @@ mod custom_punctuation; #[cfg(any(feature = "full", feature = "derive"))] mod data; #[cfg(any(feature = "full", feature = "derive"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "full", feature = "derive"))))] pub use crate::data::{Field, Fields, FieldsNamed, FieldsUnnamed, Variant}; #[cfg(any(feature = "full", feature = "derive"))] mod derive; #[cfg(feature = "derive")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "derive")))] pub use crate::derive::{Data, DataEnum, DataStruct, DataUnion, DeriveInput}; mod drops; @@ -343,14 +349,21 @@ pub use crate::error::{Error, Result}; #[cfg(any(feature = "full", feature = "derive"))] mod expr; #[cfg(feature = "full")] -pub use crate::expr::{Arm, FieldValue, Label, RangeLimits}; +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] +pub use crate::expr::{Arm, Label, RangeLimits}; #[cfg(any(feature = "full", feature = "derive"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "full", feature = "derive"))))] pub use crate::expr::{ - 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, ExprUnary, ExprUnsafe, ExprWhile, ExprYield, Index, Member, + Expr, ExprBinary, ExprCall, ExprCast, ExprField, ExprIndex, ExprLit, ExprMacro, ExprMethodCall, + ExprParen, ExprPath, ExprReference, ExprStruct, ExprUnary, FieldValue, Index, Member, +}; +#[cfg(any(feature = "full", feature = "derive"))] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] +pub use crate::expr::{ + ExprArray, ExprAssign, ExprAsync, ExprAwait, ExprBlock, ExprBreak, ExprClosure, ExprConst, + ExprContinue, ExprForLoop, ExprGroup, ExprIf, ExprInfer, ExprLet, ExprLoop, ExprMatch, + ExprRange, ExprRepeat, ExprReturn, ExprTry, ExprTryBlock, ExprTuple, ExprUnsafe, ExprWhile, + ExprYield, }; #[cfg(feature = "parsing")] @@ -360,17 +373,23 @@ pub mod ext; #[cfg(feature = "full")] mod file; #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub use crate::file::File; #[cfg(any(feature = "full", feature = "derive"))] mod generics; #[cfg(any(feature = "full", feature = "derive"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "full", feature = "derive"))))] pub use crate::generics::{ BoundLifetimes, ConstParam, GenericParam, Generics, LifetimeParam, PredicateLifetime, PredicateType, TraitBound, TraitBoundModifier, TypeParam, TypeParamBound, WhereClause, WherePredicate, }; #[cfg(all(any(feature = "full", feature = "derive"), feature = "printing"))] +#[cfg_attr( + doc_cfg, + doc(cfg(all(any(feature = "full", feature = "derive"), feature = "printing"))) +)] pub use crate::generics::{ImplGenerics, Turbofish, TypeGenerics}; mod ident; @@ -380,6 +399,7 @@ pub use crate::ident::Ident; #[cfg(feature = "full")] mod item; #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub use crate::item::{ FnArg, ForeignItem, ForeignItemFn, ForeignItemMacro, ForeignItemStatic, ForeignItemType, ImplItem, ImplItemConst, ImplItemFn, ImplItemMacro, ImplItemType, ImplRestriction, Item, @@ -394,10 +414,10 @@ mod lifetime; pub use crate::lifetime::Lifetime; mod lit; +#[doc(hidden)] // https://github.com/dtolnay/syn/issues/1566 +pub use crate::lit::StrStyle; #[doc(inline)] -pub use crate::lit::{ - Lit, LitBool, LitByte, LitByteStr, LitChar, LitFloat, LitInt, LitStr, StrStyle, -}; +pub use crate::lit::{Lit, LitBool, LitByte, LitByteStr, LitChar, LitFloat, LitInt, LitStr}; #[cfg(feature = "parsing")] mod lookahead; @@ -405,6 +425,7 @@ mod lookahead; #[cfg(any(feature = "full", feature = "derive"))] mod mac; #[cfg(any(feature = "full", feature = "derive"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "full", feature = "derive"))))] pub use crate::mac::{Macro, MacroDelimiter}; #[cfg(all(feature = "parsing", any(feature = "full", feature = "derive")))] @@ -417,6 +438,7 @@ pub mod meta; #[cfg(any(feature = "full", feature = "derive"))] mod op; #[cfg(any(feature = "full", feature = "derive"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "full", feature = "derive"))))] pub use crate::op::{BinOp, UnOp}; #[cfg(feature = "parsing")] @@ -432,11 +454,13 @@ mod parse_quote; #[cfg(feature = "full")] mod pat; #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(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")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub use crate::pat::{ FieldPat, Pat, PatIdent, PatOr, PatParen, PatReference, PatRest, PatSlice, PatStruct, PatTuple, PatTupleStruct, PatType, PatWild, @@ -445,6 +469,7 @@ pub use crate::pat::{ #[cfg(any(feature = "full", feature = "derive"))] mod path; #[cfg(any(feature = "full", feature = "derive"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "full", feature = "derive"))))] pub use crate::path::{ AngleBracketedGenericArguments, AssocConst, AssocType, Constraint, GenericArgument, ParenthesizedGenericArguments, Path, PathArguments, PathSegment, QSelf, @@ -458,6 +483,7 @@ pub mod punctuated; #[cfg(any(feature = "full", feature = "derive"))] mod restriction; #[cfg(any(feature = "full", feature = "derive"))] +#[cfg_attr(doc_cfg, doc(cfg(any(feature = "full", feature = "derive"))))] pub use crate::restriction::{FieldMutability, VisRestricted, Visibility}; mod sealed; @@ -471,6 +497,7 @@ pub mod spanned; #[cfg(feature = "full")] mod stmt; #[cfg(feature = "full")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub use crate::stmt::{Block, Local, LocalInit, Stmt, StmtMacro}; mod thread; @@ -481,6 +508,7 @@ mod tt; #[cfg(any(feature = "full", feature = "derive"))] mod ty; #[cfg(any(feature = "full", feature = "derive"))] +#[cfg_attr(doc_cfg, doc(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, @@ -813,8 +841,17 @@ mod gen { mod helper; } -#[cfg(any(feature = "fold", feature = "visit", feature = "visit-mut"))] -pub use crate::gen::*; +#[cfg(feature = "fold")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "fold")))] +pub use crate::gen::fold; + +#[cfg(feature = "visit")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "visit")))] +pub use crate::gen::visit; + +#[cfg(feature = "visit-mut")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "visit-mut")))] +pub use crate::gen::visit_mut; // Not public API. #[doc(hidden)] diff --git a/third_party/rust/syn/src/lit.rs b/third_party/rust/syn/src/lit.rs index f7426ce81804c..24524bb1f4744 100644 --- a/third_party/rust/syn/src/lit.rs +++ b/third_party/rust/syn/src/lit.rs @@ -784,17 +784,16 @@ pub_if_not_doc! { } } -ast_enum! { - /// The style of a string literal, either plain quoted or a raw string like - /// `r##"data"##`. - pub enum StrStyle #no_visit { - /// An ordinary string like `"data"`. - Cooked, - /// A raw string like `r##"data"##`. - /// - /// The unsigned integer is the number of `#` symbols used. - Raw(usize), - } +/// The style of a string literal, either plain quoted or a raw string like +/// `r##"data"##`. +#[doc(hidden)] // https://github.com/dtolnay/syn/issues/1566 +pub enum StrStyle { + /// An ordinary string like `"data"`. + Cooked, + /// A raw string like `r##"data"##`. + /// + /// The unsigned integer is the number of `#` symbols used. + Raw(usize), } #[cfg(feature = "parsing")] diff --git a/third_party/rust/syn/src/macros.rs b/third_party/rust/syn/src/macros.rs index 06ceb542dac39..46d283252629b 100644 --- a/third_party/rust/syn/src/macros.rs +++ b/third_party/rust/syn/src/macros.rs @@ -4,14 +4,17 @@ )] macro_rules! ast_struct { ( - [$($attrs_pub:tt)*] - struct $name:ident #full $($rest:tt)* + $(#[$attr:meta])* + $pub:ident $struct:ident $name:ident #full $body:tt ) => { + check_keyword_matches!(pub $pub); + check_keyword_matches!(struct $struct); + #[cfg(feature = "full")] - $($attrs_pub)* struct $name $($rest)* + $(#[$attr])* $pub $struct $name $body #[cfg(not(feature = "full"))] - $($attrs_pub)* struct $name { + $(#[$attr])* $pub $struct $name { _noconstruct: ::std::marker::PhantomData<::proc_macro2::Span>, } @@ -24,35 +27,26 @@ macro_rules! ast_struct { }; ( - [$($attrs_pub:tt)*] - struct $name:ident $($rest:tt)* + $(#[$attr:meta])* + $pub:ident $struct:ident $name:ident $body:tt ) => { - $($attrs_pub)* struct $name $($rest)* - }; + check_keyword_matches!(pub $pub); + check_keyword_matches!(struct $struct); - ($($t:tt)*) => { - strip_attrs_pub!(ast_struct!($($t)*)); + $(#[$attr])* $pub $struct $name $body }; } +#[cfg(any(feature = "full", feature = "derive"))] macro_rules! ast_enum { - // Drop the `#no_visit` attribute, if present. ( - [$($attrs_pub:tt)*] - enum $name:ident #no_visit $($rest:tt)* - ) => ( - ast_enum!([$($attrs_pub)*] enum $name $($rest)*); - ); + $(#[$enum_attr:meta])* + $pub:ident $enum:ident $name:ident $body:tt + ) => { + check_keyword_matches!(pub $pub); + check_keyword_matches!(enum $enum); - ( - [$($attrs_pub:tt)*] - enum $name:ident $($rest:tt)* - ) => ( - $($attrs_pub)* enum $name $($rest)* - ); - - ($($t:tt)*) => { - strip_attrs_pub!(ast_enum!($($t)*)); + $(#[$enum_attr])* $pub $enum $name $body }; } @@ -60,16 +54,19 @@ macro_rules! ast_enum_of_structs { ( $(#[$enum_attr:meta])* $pub:ident $enum:ident $name:ident $body:tt - $($remaining:tt)* ) => { - ast_enum!($(#[$enum_attr])* $pub $enum $name $body); - ast_enum_of_structs_impl!($pub $enum $name $body $($remaining)*); + check_keyword_matches!(pub $pub); + check_keyword_matches!(enum $enum); + + $(#[$enum_attr])* $pub $enum $name $body + + ast_enum_of_structs_impl!($name $body); }; } macro_rules! ast_enum_of_structs_impl { ( - $pub:ident $enum:ident $name:ident { + $name:ident { $( $(#[cfg $cfg_attr:tt])* $(#[doc $($doc_attr:tt)*])* @@ -77,9 +74,6 @@ macro_rules! ast_enum_of_structs_impl { )* } ) => { - check_keyword_matches!(pub $pub); - check_keyword_matches!(enum $enum); - $($( ast_enum_from_struct!($name::$variant, $($member)::+); )*)* @@ -154,32 +148,29 @@ macro_rules! generate_to_tokens { }; } -macro_rules! strip_attrs_pub { - ($mac:ident!($(#[$m:meta])* $pub:ident $($t:tt)*)) => { - check_keyword_matches!(pub $pub); - - $mac!([$(#[$m])* $pub] $($t)*); - }; -} - -macro_rules! check_keyword_matches { - (enum enum) => {}; - (pub pub) => {}; -} - // Rustdoc bug: does not respect the doc(hidden) on some items. #[cfg(all(doc, feature = "parsing"))] macro_rules! pub_if_not_doc { - ($(#[$m:meta])* pub $($item:tt)*) => { + ($(#[$m:meta])* $pub:ident $($item:tt)*) => { + check_keyword_matches!(pub $pub); + $(#[$m])* - pub(crate) $($item)* + $pub(crate) $($item)* }; } #[cfg(all(not(doc), feature = "parsing"))] macro_rules! pub_if_not_doc { - ($(#[$m:meta])* pub $($item:tt)*) => { + ($(#[$m:meta])* $pub:ident $($item:tt)*) => { + check_keyword_matches!(pub $pub); + $(#[$m])* - pub $($item)* + $pub $($item)* }; } + +macro_rules! check_keyword_matches { + (enum enum) => {}; + (pub pub) => {}; + (struct struct) => {}; +} diff --git a/third_party/rust/syn/src/meta.rs b/third_party/rust/syn/src/meta.rs index f17b2802d0ad4..66a0a467bea7b 100644 --- a/third_party/rust/syn/src/meta.rs +++ b/third_party/rust/syn/src/meta.rs @@ -1,6 +1,6 @@ //! Facility for interpreting structured content inside of an `Attribute`. -use crate::ext::IdentExt; +use crate::ext::IdentExt as _; use crate::lit::Lit; use crate::parse::{Error, ParseStream, Parser, Result}; use crate::path::{Path, PathSegment}; diff --git a/third_party/rust/syn/src/op.rs b/third_party/rust/syn/src/op.rs index bff72c8ba9804..c231285b95a01 100644 --- a/third_party/rust/syn/src/op.rs +++ b/third_party/rust/syn/src/op.rs @@ -81,56 +81,8 @@ pub(crate) mod parsing { use super::*; use crate::parse::{Parse, ParseStream, Result}; - fn parse_binop(input: ParseStream) -> Result { - if input.peek(Token![&&]) { - input.parse().map(BinOp::And) - } else if input.peek(Token![||]) { - input.parse().map(BinOp::Or) - } else if input.peek(Token![<<]) { - input.parse().map(BinOp::Shl) - } else if input.peek(Token![>>]) { - input.parse().map(BinOp::Shr) - } else if input.peek(Token![==]) { - input.parse().map(BinOp::Eq) - } else if input.peek(Token![<=]) { - input.parse().map(BinOp::Le) - } else if input.peek(Token![!=]) { - input.parse().map(BinOp::Ne) - } else if input.peek(Token![>=]) { - input.parse().map(BinOp::Ge) - } else if input.peek(Token![+]) { - input.parse().map(BinOp::Add) - } else if input.peek(Token![-]) { - input.parse().map(BinOp::Sub) - } else if input.peek(Token![*]) { - input.parse().map(BinOp::Mul) - } else if input.peek(Token![/]) { - input.parse().map(BinOp::Div) - } else if input.peek(Token![%]) { - input.parse().map(BinOp::Rem) - } else if input.peek(Token![^]) { - input.parse().map(BinOp::BitXor) - } else if input.peek(Token![&]) { - input.parse().map(BinOp::BitAnd) - } else if input.peek(Token![|]) { - input.parse().map(BinOp::BitOr) - } else if input.peek(Token![<]) { - input.parse().map(BinOp::Lt) - } else if input.peek(Token![>]) { - input.parse().map(BinOp::Gt) - } else { - Err(input.error("expected binary operator")) - } - } - #[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))] impl Parse for BinOp { - #[cfg(not(feature = "full"))] - fn parse(input: ParseStream) -> Result { - parse_binop(input) - } - - #[cfg(feature = "full")] fn parse(input: ParseStream) -> Result { if input.peek(Token![+=]) { input.parse().map(BinOp::AddAssign) @@ -152,8 +104,44 @@ pub(crate) mod parsing { input.parse().map(BinOp::ShlAssign) } else if input.peek(Token![>>=]) { input.parse().map(BinOp::ShrAssign) + } else if input.peek(Token![&&]) { + input.parse().map(BinOp::And) + } else if input.peek(Token![||]) { + input.parse().map(BinOp::Or) + } else if input.peek(Token![<<]) { + input.parse().map(BinOp::Shl) + } else if input.peek(Token![>>]) { + input.parse().map(BinOp::Shr) + } else if input.peek(Token![==]) { + input.parse().map(BinOp::Eq) + } else if input.peek(Token![<=]) { + input.parse().map(BinOp::Le) + } else if input.peek(Token![!=]) { + input.parse().map(BinOp::Ne) + } else if input.peek(Token![>=]) { + input.parse().map(BinOp::Ge) + } else if input.peek(Token![+]) { + input.parse().map(BinOp::Add) + } else if input.peek(Token![-]) { + input.parse().map(BinOp::Sub) + } else if input.peek(Token![*]) { + input.parse().map(BinOp::Mul) + } else if input.peek(Token![/]) { + input.parse().map(BinOp::Div) + } else if input.peek(Token![%]) { + input.parse().map(BinOp::Rem) + } else if input.peek(Token![^]) { + input.parse().map(BinOp::BitXor) + } else if input.peek(Token![&]) { + input.parse().map(BinOp::BitAnd) + } else if input.peek(Token![|]) { + input.parse().map(BinOp::BitOr) + } else if input.peek(Token![<]) { + input.parse().map(BinOp::Lt) + } else if input.peek(Token![>]) { + input.parse().map(BinOp::Gt) } else { - parse_binop(input) + Err(input.error("expected binary operator")) } } } diff --git a/third_party/rust/syn/src/parse.rs b/third_party/rust/syn/src/parse.rs index 50fe110b588d3..13f488d143269 100644 --- a/third_party/rust/syn/src/parse.rs +++ b/third_party/rust/syn/src/parse.rs @@ -1096,6 +1096,58 @@ impl<'a> ParseBuffer<'a> { /// /// Cursors are immutable so no operations you perform against the cursor /// will affect the state of this parse stream. + /// + /// # Example + /// + /// ``` + /// use proc_macro2::TokenStream; + /// use syn::buffer::Cursor; + /// use syn::parse::{ParseStream, Result}; + /// + /// // Run a parser that returns T, but get its output as TokenStream instead of T. + /// // This works without T needing to implement ToTokens. + /// fn recognize_token_stream( + /// recognizer: fn(ParseStream) -> Result, + /// ) -> impl Fn(ParseStream) -> Result { + /// move |input| { + /// let begin = input.cursor(); + /// recognizer(input)?; + /// let end = input.cursor(); + /// Ok(tokens_between(begin, end)) + /// } + /// } + /// + /// // Collect tokens between two cursors as a TokenStream. + /// fn tokens_between(begin: Cursor, end: Cursor) -> TokenStream { + /// assert!(begin <= end); + /// + /// let mut cursor = begin; + /// let mut tokens = TokenStream::new(); + /// while cursor < end { + /// let (token, next) = cursor.token_tree().unwrap(); + /// tokens.extend(std::iter::once(token)); + /// cursor = next; + /// } + /// tokens + /// } + /// + /// fn main() { + /// use quote::quote; + /// use syn::parse::{Parse, Parser}; + /// use syn::Token; + /// + /// // Parse syn::Type as a TokenStream, surrounded by angle brackets. + /// fn example(input: ParseStream) -> Result { + /// let _langle: Token![<] = input.parse()?; + /// let ty = recognize_token_stream(syn::Type::parse)(input)?; + /// let _rangle: Token![>] = input.parse()?; + /// Ok(ty) + /// } + /// + /// let tokens = quote! { u8> }; + /// println!("{}", example.parse2(tokens).unwrap()); + /// } + /// ``` pub fn cursor(&self) -> Cursor<'a> { self.cell.get() } diff --git a/third_party/rust/syn/src/parse_quote.rs b/third_party/rust/syn/src/parse_quote.rs index 59e51b41ea17c..18de474505a4a 100644 --- a/third_party/rust/syn/src/parse_quote.rs +++ b/third_party/rust/syn/src/parse_quote.rs @@ -136,7 +136,7 @@ impl ParseQuote for T { use crate::punctuated::Punctuated; #[cfg(any(feature = "full", feature = "derive"))] -use crate::{attr, Attribute}; +use crate::{attr, Attribute, Field, FieldMutability, Ident, Type, Visibility}; #[cfg(feature = "full")] use crate::{Block, Pat, Stmt}; @@ -151,6 +151,36 @@ impl ParseQuote for Attribute { } } +#[cfg(any(feature = "full", feature = "derive"))] +impl ParseQuote for Field { + fn parse(input: ParseStream) -> Result { + let attrs = input.call(Attribute::parse_outer)?; + let vis: Visibility = input.parse()?; + + let ident: Option; + let colon_token: Option; + let is_named = input.peek(Ident) && input.peek2(Token![:]) && !input.peek2(Token![::]); + if is_named { + ident = Some(input.parse()?); + colon_token = Some(input.parse()?); + } else { + ident = None; + colon_token = None; + } + + let ty: Type = input.parse()?; + + Ok(Field { + attrs, + vis, + mutability: FieldMutability::None, + ident, + colon_token, + ty, + }) + } +} + #[cfg(feature = "full")] impl ParseQuote for Pat { fn parse(input: ParseStream) -> Result { diff --git a/third_party/rust/syn/src/pat.rs b/third_party/rust/syn/src/pat.rs index df7da5bbe4606..c835d772f0533 100644 --- a/third_party/rust/syn/src/pat.rs +++ b/third_party/rust/syn/src/pat.rs @@ -117,6 +117,7 @@ ast_struct! { ast_struct! { /// A parenthesized pattern: `(A | B)`. + #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))] pub struct PatParen { pub attrs: Vec, pub paren_token: token::Paren, @@ -226,8 +227,8 @@ ast_struct! { #[cfg(feature = "parsing")] pub(crate) mod parsing { use super::*; - use crate::ext::IdentExt; - use crate::parse::{ParseBuffer, ParseStream, Result}; + use crate::ext::IdentExt as _; + use crate::parse::{Parse, ParseBuffer, ParseStream, Result}; use crate::path; #[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))] @@ -354,6 +355,18 @@ pub(crate) mod parsing { } } + #[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))] + impl Parse for PatType { + fn parse(input: ParseStream) -> Result { + Ok(PatType { + attrs: Vec::new(), + pat: Box::new(Pat::parse_single(input)?), + colon_token: input.parse()?, + ty: input.parse()?, + }) + } + } + fn multi_pat_impl(input: ParseStream, leading_vert: Option) -> Result { let mut pat = Pat::parse_single(input)?; if leading_vert.is_some() @@ -506,15 +519,6 @@ pub(crate) mod parsing { }) } - impl Member { - fn is_unnamed(&self) -> bool { - match self { - Member::Named(_) => false, - Member::Unnamed(_) => true, - } - } - } - fn field_pat(input: ParseStream) -> Result { let begin = input.fork(); let boxed: Option = input.parse()?; @@ -528,7 +532,7 @@ pub(crate) mod parsing { }?; if boxed.is_none() && by_ref.is_none() && mutability.is_none() && input.peek(Token![:]) - || member.is_unnamed() + || !member.is_named() { return Ok(FieldPat { attrs: Vec::new(), @@ -856,6 +860,15 @@ mod printing { tokens.append_all(self.attrs.outer()); self.paren_token.surround(tokens, |tokens| { self.elems.to_tokens(tokens); + // If there is only one element, a trailing comma is needed to + // distinguish PatTuple from PatParen, unless this is `(..)` + // which is a tuple pattern even without comma. + if self.elems.len() == 1 + && !self.elems.trailing_punct() + && !matches!(self.elems[0], Pat::Rest { .. }) + { + ::default().to_tokens(tokens); + } }); } } diff --git a/third_party/rust/syn/src/path.rs b/third_party/rust/syn/src/path.rs index b9d96e669a244..975154a31c50e 100644 --- a/third_party/rust/syn/src/path.rs +++ b/third_party/rust/syn/src/path.rs @@ -277,7 +277,7 @@ ast_struct! { pub(crate) mod parsing { use super::*; - use crate::ext::IdentExt; + use crate::ext::IdentExt as _; use crate::parse::{Parse, ParseStream, Result}; #[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))] @@ -424,7 +424,10 @@ pub(crate) mod parsing { Self::do_parse(Some(colon2_token), input) } - fn do_parse(colon2_token: Option, input: ParseStream) -> Result { + pub(crate) fn do_parse( + colon2_token: Option, + input: ParseStream, + ) -> Result { Ok(AngleBracketedGenericArguments { colon2_token, lt_token: input.parse()?, diff --git a/third_party/rust/syn/src/restriction.rs b/third_party/rust/syn/src/restriction.rs index 97c7f5ae32238..e66b17f3b58f7 100644 --- a/third_party/rust/syn/src/restriction.rs +++ b/third_party/rust/syn/src/restriction.rs @@ -58,8 +58,8 @@ ast_enum! { #[cfg(feature = "parsing")] pub(crate) mod parsing { use super::*; - use crate::ext::IdentExt; - use crate::parse::discouraged::Speculative; + use crate::ext::IdentExt as _; + use crate::parse::discouraged::Speculative as _; use crate::parse::{Parse, ParseStream, Result}; #[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))] diff --git a/third_party/rust/syn/src/stmt.rs b/third_party/rust/syn/src/stmt.rs index fb67feccb27f3..b6d0664be7f56 100644 --- a/third_party/rust/syn/src/stmt.rs +++ b/third_party/rust/syn/src/stmt.rs @@ -75,7 +75,7 @@ ast_struct! { #[cfg(feature = "parsing")] pub(crate) mod parsing { use super::*; - use crate::parse::discouraged::Speculative; + use crate::parse::discouraged::Speculative as _; use crate::parse::{Parse, ParseStream, Result}; use proc_macro2::TokenStream; @@ -200,7 +200,7 @@ pub(crate) mod parsing { } } - if input.peek(Token![let]) { + if input.peek(Token![let]) && !input.peek(token::Group) { stmt_local(input, attrs).map(Stmt::Local) } else if input.peek(Token![pub]) || input.peek(Token![crate]) && !input.peek2(Token![::]) diff --git a/third_party/rust/syn/src/ty.rs b/third_party/rust/syn/src/ty.rs index 0f41fe4fa1394..a5049f0808e31 100644 --- a/third_party/rust/syn/src/ty.rs +++ b/third_party/rust/syn/src/ty.rs @@ -264,7 +264,7 @@ ast_enum! { #[cfg(feature = "parsing")] pub(crate) mod parsing { use super::*; - use crate::ext::IdentExt; + use crate::ext::IdentExt as _; use crate::parse::{Parse, ParseStream, Result}; use crate::path; use proc_macro2::Span; diff --git a/third_party/rust/syn/tests/common/eq.rs b/third_party/rust/syn/tests/common/eq.rs index 8e334c3305495..8ecbe46a36f82 100644 --- a/third_party/rust/syn/tests/common/eq.rs +++ b/third_party/rust/syn/tests/common/eq.rs @@ -13,7 +13,6 @@ use rustc_ast::ast::Arm; use rustc_ast::ast::AssocConstraint; use rustc_ast::ast::AssocConstraintKind; use rustc_ast::ast::AssocItemKind; -use rustc_ast::ast::Async; use rustc_ast::ast::AttrArgs; use rustc_ast::ast::AttrArgsEq; use rustc_ast::ast::AttrId; @@ -27,6 +26,7 @@ use rustc_ast::ast::BindingAnnotation; use rustc_ast::ast::Block; use rustc_ast::ast::BlockCheckMode; use rustc_ast::ast::BorrowKind; +use rustc_ast::ast::BoundConstness; use rustc_ast::ast::BoundPolarity; use rustc_ast::ast::ByRef; use rustc_ast::ast::CaptureBy; @@ -34,6 +34,7 @@ use rustc_ast::ast::Closure; use rustc_ast::ast::ClosureBinder; use rustc_ast::ast::Const; use rustc_ast::ast::ConstItem; +use rustc_ast::ast::CoroutineKind; use rustc_ast::ast::Crate; use rustc_ast::ast::Defaultness; use rustc_ast::ast::DelimArgs; @@ -49,6 +50,7 @@ use rustc_ast::ast::FnDecl; use rustc_ast::ast::FnHeader; use rustc_ast::ast::FnRetTy; use rustc_ast::ast::FnSig; +use rustc_ast::ast::ForLoopKind; use rustc_ast::ast::ForeignItemKind; use rustc_ast::ast::ForeignMod; use rustc_ast::ast::FormatAlignment; @@ -109,6 +111,7 @@ use rustc_ast::ast::Param; use rustc_ast::ast::ParenthesizedArgs; use rustc_ast::ast::Pat; use rustc_ast::ast::PatField; +use rustc_ast::ast::PatFieldsRest; use rustc_ast::ast::PatKind; use rustc_ast::ast::Path; use rustc_ast::ast::PathSegment; @@ -126,7 +129,7 @@ use rustc_ast::ast::StructExpr; use rustc_ast::ast::StructRest; use rustc_ast::ast::Term; use rustc_ast::ast::Trait; -use rustc_ast::ast::TraitBoundModifier; +use rustc_ast::ast::TraitBoundModifiers; use rustc_ast::ast::TraitObjectSyntax; use rustc_ast::ast::TraitRef; use rustc_ast::ast::Ty; @@ -151,8 +154,8 @@ use rustc_ast::ast::WhereRegionPredicate; use rustc_ast::ptr::P; use rustc_ast::token::{self, CommentKind, Delimiter, Lit, Nonterminal, Token, TokenKind}; use rustc_ast::tokenstream::{ - AttrTokenStream, AttrTokenTree, AttributesData, DelimSpan, LazyAttrTokenStream, Spacing, - TokenStream, TokenTree, + AttrTokenStream, AttrTokenTree, AttributesData, DelimSpacing, DelimSpan, LazyAttrTokenStream, + Spacing, TokenStream, TokenTree, }; use rustc_data_structures::sync::Lrc; use rustc_span::source_map::Spanned; @@ -457,17 +460,18 @@ 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 constness asyncness movability fn_decl body !fn_decl_span !fn_arg_span); +spanless_eq_struct!(Closure; binder capture_clause constness coroutine_kind movability fn_decl body !fn_decl_span !fn_arg_span); spanless_eq_struct!(ConstItem; defaultness generics ty expr); spanless_eq_struct!(Crate; attrs items spans id is_placeholder); spanless_eq_struct!(DelimArgs; dspan delim tokens); +spanless_eq_struct!(DelimSpacing; open close); 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!(FnHeader; constness coroutine_kind unsafety ext); spanless_eq_struct!(FnSig; header decl span); spanless_eq_struct!(ForeignMod; unsafety abi items); spanless_eq_struct!(FormatArgPosition; index kind span); @@ -506,6 +510,7 @@ 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); +spanless_eq_struct!(TraitBoundModifiers; constness polarity); spanless_eq_struct!(TraitRef; path ref_id); spanless_eq_struct!(Ty; id kind span tokens); spanless_eq_struct!(TyAlias; defaultness generics where_clauses !where_predicates_split bounds ty); @@ -520,23 +525,24 @@ spanless_eq_struct!(WhereRegionPredicate; span lifetime bounds); spanless_eq_enum!(AngleBracketedArg; Arg(0) Constraint(0)); spanless_eq_enum!(AssocConstraintKind; Equality(term) Bound(bounds)); spanless_eq_enum!(AssocItemKind; Const(0) 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)); spanless_eq_enum!(AttrStyle; Outer Inner); -spanless_eq_enum!(AttrTokenTree; Token(0 1) Delimited(0 1 2) Attributes(0)); +spanless_eq_enum!(AttrTokenTree; Token(0 1) Delimited(0 1 2 3) Attributes(0)); spanless_eq_enum!(BinOpKind; Add Sub Mul Div Rem And Or BitXor BitAnd BitOr Shl Shr Eq Lt Le Ne Ge Gt); spanless_eq_enum!(BlockCheckMode; Default Unsafe(0)); spanless_eq_enum!(BorrowKind; Ref Raw); +spanless_eq_enum!(BoundConstness; Never Always(0) Maybe(0)); spanless_eq_enum!(BoundPolarity; Positive Negative(0) Maybe(0)); spanless_eq_enum!(ByRef; Yes No); -spanless_eq_enum!(CaptureBy; Value Ref); +spanless_eq_enum!(CaptureBy; Value(move_kw) Ref); spanless_eq_enum!(ClosureBinder; NotPresent For(span generic_params)); spanless_eq_enum!(Const; Yes(0) No); spanless_eq_enum!(Defaultness; Default(0) Final); 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!(ForLoopKind; For ForAwait); 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); @@ -546,7 +552,7 @@ 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!(GenBlockKind; Async Gen); +spanless_eq_enum!(GenBlockKind; Async Gen AsyncGen); 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)); @@ -564,31 +570,34 @@ spanless_eq_enum!(MacStmtStyle; Semicolon Braces NoBraces); spanless_eq_enum!(ModKind; Loaded(0 1 2) Unloaded); spanless_eq_enum!(Movability; Static Movable); spanless_eq_enum!(Mutability; Mut Not); +spanless_eq_enum!(PatFieldsRest; Rest None); spanless_eq_enum!(RangeEnd; Included(0) Excluded); spanless_eq_enum!(RangeLimits; HalfOpen Closed); spanless_eq_enum!(StmtKind; Local(0) Item(0) Expr(0) Semi(0) Empty MacCall(0)); spanless_eq_enum!(StrStyle; Cooked Raw(0)); spanless_eq_enum!(StructRest; Base(0) Rest(0) None); spanless_eq_enum!(Term; Ty(0) Const(0)); -spanless_eq_enum!(TokenTree; Token(0 1) Delimited(0 1 2)); -spanless_eq_enum!(TraitBoundModifier; None Negative Maybe MaybeConst MaybeConstNegative MaybeConstMaybe); +spanless_eq_enum!(TokenTree; Token(0 1) Delimited(0 1 2 3)); spanless_eq_enum!(TraitObjectSyntax; Dyn DynStar None); spanless_eq_enum!(UintTy; Usize U8 U16 U32 U64 U128); spanless_eq_enum!(UnOp; Deref Not Neg); spanless_eq_enum!(Unsafe; Yes(0) No); spanless_eq_enum!(UnsafeSource; CompilerGenerated UserProvided); spanless_eq_enum!(UseTreeKind; Simple(0) Nested(0) Glob); -spanless_eq_enum!(VariantData; Struct(0 1) Tuple(0 1) Unit(0)); +spanless_eq_enum!(VariantData; Struct(fields recovered) 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!(CoroutineKind; Async(span closure_id return_impl_trait_id) + Gen(span closure_id return_impl_trait_id) + AsyncGen(span closure_id return_impl_trait_id)); 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 3) - 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) Gen(0 1 2) Await(0 1) TryBlock(0) Assign(0 1 2) AssignOp(0 1 2) - Field(0 1) Index(0 1 2) Underscore Range(0 1 2) Path(0 1) AddrOf(0 1 2) - Break(0 1) Continue(0) Ret(0) InlineAsm(0) OffsetOf(0 1) MacCall(0) - Struct(0) Repeat(0 1) Paren(0) Try(0) Yield(0) Yeet(0) Become(0) - IncludedBytes(0) FormatArgs(0) Err); + If(0 1 2) While(0 1 2) ForLoop(pat iter body label kind) Loop(0 1 2) + Match(0 1) Closure(0) Block(0 1) Gen(0 1 2) Await(0 1) TryBlock(0) + Assign(0 1 2) AssignOp(0 1 2) Field(0 1) Index(0 1 2) Underscore + Range(0 1 2) Path(0 1) AddrOf(0 1 2) Break(0 1) Continue(0) Ret(0) + InlineAsm(0) OffsetOf(0 1) MacCall(0) Struct(0) Repeat(0 1) Paren(0) Try(0) + Yield(0) Yeet(0) Become(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)); @@ -599,7 +608,7 @@ spanless_eq_enum!(LitKind; Str(0 1) ByteStr(0 1) CStr(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)); + Never Paren(0) MacCall(0)); spanless_eq_enum!(TyKind; Slice(0) Array(0 1) Ptr(0) Ref(0 1) BareFn(0) Never Tup(0) AnonStruct(0) AnonUnion(0) Path(0 1) TraitObject(0 1) ImplTrait(0 1) Paren(0) Typeof(0) Infer ImplicitSelf MacCall(0) Err CVarArgs); @@ -655,12 +664,15 @@ impl SpanlessEq for TokenKind { _ => false, }, (TokenKind::Interpolated(this), TokenKind::Interpolated(other)) => { - match (this.as_ref(), other.as_ref()) { - (Nonterminal::NtExpr(this), Nonterminal::NtExpr(other)) => { - SpanlessEq::eq(this, other) + let (this, this_span) = this.as_ref(); + let (other, other_span) = other.as_ref(); + SpanlessEq::eq(this_span, other_span) + && match (this, other) { + (Nonterminal::NtExpr(this), Nonterminal::NtExpr(other)) => { + SpanlessEq::eq(this, other) + } + _ => this == other, } - _ => this == other, - } } _ => self == other, } @@ -725,7 +737,7 @@ fn doc_comment<'a>( } } let stream = match trees.next() { - Some(TokenTree::Delimited(_span, Delimiter::Bracket, stream)) => stream, + Some(TokenTree::Delimited(_span, _spacing, Delimiter::Bracket, stream)) => stream, _ => return false, }; let mut trees = stream.trees(); @@ -769,7 +781,7 @@ fn is_escaped_literal_token(token: &Token, unescaped: Symbol) -> bool { Token { kind: TokenKind::Interpolated(nonterminal), span: _, - } => match nonterminal.as_ref() { + } => match &nonterminal.0 { Nonterminal::NtExpr(expr) => match &expr.kind { ExprKind::Lit(lit) => is_escaped_lit(lit, unescaped), _ => false, diff --git a/third_party/rust/syn/tests/debug/gen.rs b/third_party/rust/syn/tests/debug/gen.rs index 3f92598d7d77e..1548d8b6ba298 100644 --- a/third_party/rust/syn/tests/debug/gen.rs +++ b/third_party/rust/syn/tests/debug/gen.rs @@ -301,9 +301,7 @@ impl Debug for Lite { impl Debug for Lite { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { let mut formatter = formatter.debug_struct("Block"); - if !self.value.stmts.is_empty() { - formatter.field("stmts", Lite(&self.value.stmts)); - } + formatter.field("stmts", Lite(&self.value.stmts)); formatter.finish() } } @@ -4662,3 +4660,498 @@ impl Debug for Lite { } } } +impl Debug for Lite { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("Token![abstract]") + } +} +impl Debug for Lite { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("Token![&]") + } +} +impl Debug for Lite { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("Token![&&]") + } +} +impl Debug for Lite { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("Token![&=]") + } +} +impl Debug for Lite { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("Token![as]") + } +} +impl Debug for Lite { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("Token![async]") + } +} +impl Debug for Lite { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("Token![@]") + } +} +impl Debug for Lite { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("Token![auto]") + } +} +impl Debug for Lite { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("Token![await]") + } +} +impl Debug for Lite { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("Token![become]") + } +} +impl Debug for Lite { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("Token![box]") + } +} +impl Debug for Lite { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("Token![break]") + } +} +impl Debug for Lite { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("Token![^]") + } +} +impl Debug for Lite { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("Token![^=]") + } +} +impl Debug for Lite { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("Token![:]") + } +} +impl Debug for Lite { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("Token![,]") + } +} +impl Debug for Lite { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("Token![const]") + } +} +impl Debug for Lite { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("Token![continue]") + } +} +impl Debug for Lite { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("Token![crate]") + } +} +impl Debug for Lite { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("Token![default]") + } +} +impl Debug for Lite { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("Token![do]") + } +} +impl Debug for Lite { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("Token![$]") + } +} +impl Debug for Lite { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("Token![.]") + } +} +impl Debug for Lite { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("Token![..]") + } +} +impl Debug for Lite { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("Token![...]") + } +} +impl Debug for Lite { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("Token![..=]") + } +} +impl Debug for Lite { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("Token![dyn]") + } +} +impl Debug for Lite { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("Token![else]") + } +} +impl Debug for Lite { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("Token![enum]") + } +} +impl Debug for Lite { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("Token![=]") + } +} +impl Debug for Lite { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("Token![==]") + } +} +impl Debug for Lite { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("Token![extern]") + } +} +impl Debug for Lite { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("Token![=>]") + } +} +impl Debug for Lite { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("Token![final]") + } +} +impl Debug for Lite { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("Token![fn]") + } +} +impl Debug for Lite { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("Token![for]") + } +} +impl Debug for Lite { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("Token![>=]") + } +} +impl Debug for Lite { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("Token![>]") + } +} +impl Debug for Lite { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("Token![if]") + } +} +impl Debug for Lite { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("Token![impl]") + } +} +impl Debug for Lite { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("Token![in]") + } +} +impl Debug for Lite { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("Token![<-]") + } +} +impl Debug for Lite { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("Token![<=]") + } +} +impl Debug for Lite { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("Token![let]") + } +} +impl Debug for Lite { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("Token![loop]") + } +} +impl Debug for Lite { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("Token![<]") + } +} +impl Debug for Lite { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("Token![macro]") + } +} +impl Debug for Lite { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("Token![match]") + } +} +impl Debug for Lite { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("Token![-]") + } +} +impl Debug for Lite { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("Token![-=]") + } +} +impl Debug for Lite { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("Token![mod]") + } +} +impl Debug for Lite { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("Token![move]") + } +} +impl Debug for Lite { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("Token![mut]") + } +} +impl Debug for Lite { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("Token![!=]") + } +} +impl Debug for Lite { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("Token![!]") + } +} +impl Debug for Lite { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("Token![|]") + } +} +impl Debug for Lite { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("Token![|=]") + } +} +impl Debug for Lite { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("Token![||]") + } +} +impl Debug for Lite { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("Token![override]") + } +} +impl Debug for Lite { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("Token![::]") + } +} +impl Debug for Lite { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("Token![%]") + } +} +impl Debug for Lite { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("Token![%=]") + } +} +impl Debug for Lite { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("Token![+]") + } +} +impl Debug for Lite { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("Token![+=]") + } +} +impl Debug for Lite { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("Token![#]") + } +} +impl Debug for Lite { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("Token![priv]") + } +} +impl Debug for Lite { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("Token![pub]") + } +} +impl Debug for Lite { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("Token![?]") + } +} +impl Debug for Lite { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("Token![->]") + } +} +impl Debug for Lite { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("Token![ref]") + } +} +impl Debug for Lite { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("Token![return]") + } +} +impl Debug for Lite { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("Token![Self]") + } +} +impl Debug for Lite { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("Token![self]") + } +} +impl Debug for Lite { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("Token![;]") + } +} +impl Debug for Lite { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("Token![<<]") + } +} +impl Debug for Lite { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("Token![<<=]") + } +} +impl Debug for Lite { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("Token![>>]") + } +} +impl Debug for Lite { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("Token![>>=]") + } +} +impl Debug for Lite { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("Token![/]") + } +} +impl Debug for Lite { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("Token![/=]") + } +} +impl Debug for Lite { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("Token![*]") + } +} +impl Debug for Lite { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("Token![*=]") + } +} +impl Debug for Lite { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("Token![static]") + } +} +impl Debug for Lite { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("Token![struct]") + } +} +impl Debug for Lite { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("Token![super]") + } +} +impl Debug for Lite { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("Token![~]") + } +} +impl Debug for Lite { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("Token![trait]") + } +} +impl Debug for Lite { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("Token![try]") + } +} +impl Debug for Lite { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("Token![type]") + } +} +impl Debug for Lite { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("Token![typeof]") + } +} +impl Debug for Lite { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("Token![_]") + } +} +impl Debug for Lite { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("Token![union]") + } +} +impl Debug for Lite { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("Token![unsafe]") + } +} +impl Debug for Lite { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("Token![unsized]") + } +} +impl Debug for Lite { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("Token![use]") + } +} +impl Debug for Lite { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("Token![virtual]") + } +} +impl Debug for Lite { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("Token![where]") + } +} +impl Debug for Lite { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("Token![while]") + } +} +impl Debug for Lite { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("Token![yield]") + } +} diff --git a/third_party/rust/syn/tests/debug/mod.rs b/third_party/rust/syn/tests/debug/mod.rs index caf9eed804af7..c9925a6d5c769 100644 --- a/third_party/rust/syn/tests/debug/mod.rs +++ b/third_party/rust/syn/tests/debug/mod.rs @@ -115,12 +115,16 @@ where impl Debug for Lite> where Lite: Debug, + Lite

: Debug, { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - formatter - .debug_list() - .entries(self.value.iter().map(Lite)) - .finish() + let mut list = formatter.debug_list(); + for pair in self.pairs() { + let (node, punct) = pair.into_tuple(); + list.entry(Lite(node)); + list.entries(punct.map(Lite)); + } + list.finish() } } diff --git a/third_party/rust/syn/tests/macros/mod.rs b/third_party/rust/syn/tests/macros/mod.rs index 3bfbe03898c99..d27c3913396aa 100644 --- a/third_party/rust/syn/tests/macros/mod.rs +++ b/third_party/rust/syn/tests/macros/mod.rs @@ -3,7 +3,8 @@ #[path = "../debug/mod.rs"] pub mod debug; -use syn::parse::{Parse, Result}; +use std::str::FromStr; +use syn::parse::Result; macro_rules! errorf { ($($tt:tt)*) => {{ @@ -35,7 +36,8 @@ macro_rules! snapshot { macro_rules! snapshot_impl { (($expr:ident) as $t:ty, @$snapshot:literal) => { - let $expr = crate::macros::Tokens::parse::<$t>($expr).unwrap(); + let tokens = crate::macros::TryIntoTokens::try_into_tokens($expr).unwrap(); + let $expr: $t = syn::parse_quote!(#tokens); let debug = crate::macros::debug::Lite(&$expr); if !cfg!(miri) { #[allow(clippy::needless_raw_string_hashes)] // https://github.com/mitsuhiko/insta/issues/389 @@ -45,7 +47,8 @@ macro_rules! snapshot_impl { } }; (($($expr:tt)*) as $t:ty, @$snapshot:literal) => {{ - let syntax_tree = crate::macros::Tokens::parse::<$t>($($expr)*).unwrap(); + let tokens = crate::macros::TryIntoTokens::try_into_tokens($($expr)*).unwrap(); + let syntax_tree: $t = syn::parse_quote!(#tokens); let debug = crate::macros::debug::Lite(&syntax_tree); if !cfg!(miri) { #[allow(clippy::needless_raw_string_hashes)] @@ -71,18 +74,19 @@ macro_rules! snapshot_impl { }; } -pub trait Tokens { - fn parse(self) -> Result; +pub trait TryIntoTokens { + fn try_into_tokens(self) -> Result; } -impl<'a> Tokens for &'a str { - fn parse(self) -> Result { - syn::parse_str(self) +impl<'a> TryIntoTokens for &'a str { + fn try_into_tokens(self) -> Result { + let tokens = proc_macro2::TokenStream::from_str(self)?; + Ok(tokens) } } -impl Tokens for proc_macro2::TokenStream { - fn parse(self) -> Result { - syn::parse2(self) +impl TryIntoTokens for proc_macro2::TokenStream { + fn try_into_tokens(self) -> Result { + Ok(self) } } diff --git a/third_party/rust/syn/tests/repo/mod.rs b/third_party/rust/syn/tests/repo/mod.rs index 9d5dfa2f716d1..6aedd2ccdfe67 100644 --- a/third_party/rust/syn/tests/repo/mod.rs +++ b/third_party/rust/syn/tests/repo/mod.rs @@ -13,7 +13,7 @@ use std::path::{Path, PathBuf}; use tar::Archive; use walkdir::{DirEntry, WalkDir}; -const REVISION: &str = "a2f5f9691b6ce64c1703feaf9363710dfd7a56cf"; +const REVISION: &str = "b10cfcd65fd7f7b1ab9beb34798b2108de003452"; #[rustfmt::skip] static EXCLUDE_FILES: &[&str] = &[ @@ -49,6 +49,7 @@ static EXCLUDE_FILES: &[&str] = &[ // TODO: gen blocks and functions // https://github.com/dtolnay/syn/issues/1526 + "compiler/rustc_codegen_cranelift/example/gen_block_iterate.rs", "tests/ui/coroutine/gen_block_is_iter.rs", "tests/ui/coroutine/gen_block_iterate.rs", diff --git a/third_party/rust/syn/tests/test_asyncness.rs b/third_party/rust/syn/tests/test_asyncness.rs index 6bc5a16370c22..9968934490d72 100644 --- a/third_party/rust/syn/tests/test_asyncness.rs +++ b/third_party/rust/syn/tests/test_asyncness.rs @@ -18,7 +18,9 @@ fn test_async_fn() { generics: Generics, output: ReturnType::Default, }, - block: Block, + block: Block { + stmts: [], + }, } "###); } @@ -32,7 +34,9 @@ fn test_async_closure() { asyncness: Some, output: ReturnType::Default, body: Expr::Block { - block: Block, + block: Block { + stmts: [], + }, }, } "###); diff --git a/third_party/rust/syn/tests/test_derive_input.rs b/third_party/rust/syn/tests/test_derive_input.rs index 3ec6aecbc6351..c3d31eb0e91a5 100644 --- a/third_party/rust/syn/tests/test_derive_input.rs +++ b/third_party/rust/syn/tests/test_derive_input.rs @@ -78,6 +78,7 @@ fn test_struct() { }, }, }, + Token![,], Field { vis: Visibility::Public, ident: Some("attrs"), @@ -157,6 +158,7 @@ fn test_union() { colon_token: Some, ty: Type::Tuple, }, + Token![,], Field { vis: Visibility::Inherited, ident: Some("value"), @@ -232,6 +234,7 @@ fn test_enum() { GenericParam::Type(TypeParam { ident: "T", }), + Token![,], GenericParam::Type(TypeParam { ident: "E", }), @@ -259,6 +262,7 @@ fn test_enum() { ], }, }, + Token![,], Variant { ident: "Err", fields: Fields::Unnamed { @@ -278,6 +282,7 @@ fn test_enum() { ], }, }, + Token![,], Variant { ident: "Surprise", fields: Fields::Unit, @@ -285,6 +290,7 @@ fn test_enum() { lit: 0isize, }), }, + Token![,], Variant { ident: "ProcMacroHack", fields: Fields::Unit, @@ -294,6 +300,7 @@ fn test_enum() { Expr::Lit { lit: 0, }, + Token![,], Expr::Lit { lit: "data", }, @@ -363,6 +370,7 @@ fn test_attr_with_mod_style_path_with_self() { PathSegment { ident: "foo", }, + Token![::], PathSegment { ident: "self", }, @@ -386,6 +394,7 @@ fn test_attr_with_mod_style_path_with_self() { PathSegment { ident: "foo", }, + Token![::], PathSegment { ident: "self", }, @@ -426,6 +435,7 @@ fn test_pub_restricted() { PathSegment { ident: "m", }, + Token![::], PathSegment { ident: "n", }, @@ -589,6 +599,7 @@ fn test_fields_on_named_struct() { }, }, }, + Token![,], Field { vis: Visibility::Public, ident: Some("bar"), @@ -603,6 +614,7 @@ fn test_fields_on_named_struct() { }, }, }, + Token![,], ], }, }, @@ -674,6 +686,7 @@ fn test_fields_on_tuple_struct() { }, }, }, + Token![,], Field { vis: Visibility::Public, ty: Type::Path { @@ -751,6 +764,7 @@ fn test_ambiguous_crate() { PathSegment { ident: "crate", }, + Token![::], PathSegment { ident: "X", }, diff --git a/third_party/rust/syn/tests/test_expr.rs b/third_party/rust/syn/tests/test_expr.rs index 2574ea5487c72..daf0d63c3b580 100644 --- a/third_party/rust/syn/tests/test_expr.rs +++ b/third_party/rust/syn/tests/test_expr.rs @@ -3,9 +3,10 @@ #[macro_use] mod macros; -use proc_macro2::{Delimiter, Group, Ident, Punct, Spacing, Span, TokenStream, TokenTree}; -use quote::quote; -use syn::{Expr, ExprRange, Stmt}; +use proc_macro2::{Delimiter, Group}; +use quote::{quote, ToTokens as _}; +use syn::punctuated::Punctuated; +use syn::{parse_quote, token, Expr, ExprRange, ExprTuple, Stmt, Token}; #[test] fn test_expr_parse() { @@ -100,10 +101,8 @@ fn test_tuple_multi_index() { #[test] fn test_macro_variable_func() { // mimics the token stream corresponding to `$fn()` - let tokens = TokenStream::from_iter(vec![ - TokenTree::Group(Group::new(Delimiter::None, quote! { f })), - TokenTree::Group(Group::new(Delimiter::Parenthesis, TokenStream::new())), - ]); + let path = Group::new(Delimiter::None, quote!(f)); + let tokens = quote!(#path()); snapshot!(tokens as Expr, @r###" Expr::Call { @@ -121,12 +120,8 @@ fn test_macro_variable_func() { } "###); - let tokens = TokenStream::from_iter(vec![ - TokenTree::Punct(Punct::new('#', Spacing::Alone)), - TokenTree::Group(Group::new(Delimiter::Bracket, quote! { outside })), - TokenTree::Group(Group::new(Delimiter::None, quote! { #[inside] f })), - TokenTree::Group(Group::new(Delimiter::Parenthesis, TokenStream::new())), - ]); + let path = Group::new(Delimiter::None, quote! { #[inside] f }); + let tokens = quote!(#[outside] #path()); snapshot!(tokens as Expr, @r###" Expr::Call { @@ -172,11 +167,8 @@ fn test_macro_variable_func() { #[test] fn test_macro_variable_macro() { // mimics the token stream corresponding to `$macro!()` - let tokens = TokenStream::from_iter(vec![ - TokenTree::Group(Group::new(Delimiter::None, quote! { m })), - TokenTree::Punct(Punct::new('!', Spacing::Alone)), - TokenTree::Group(Group::new(Delimiter::Parenthesis, TokenStream::new())), - ]); + let mac = Group::new(Delimiter::None, quote!(m)); + let tokens = quote!(#mac!()); snapshot!(tokens as Expr, @r###" Expr::Macro { @@ -198,10 +190,8 @@ fn test_macro_variable_macro() { #[test] fn test_macro_variable_struct() { // mimics the token stream corresponding to `$struct {}` - let tokens = TokenStream::from_iter(vec![ - TokenTree::Group(Group::new(Delimiter::None, quote! { S })), - TokenTree::Group(Group::new(Delimiter::Brace, TokenStream::new())), - ]); + let s = Group::new(Delimiter::None, quote! { S }); + let tokens = quote!(#s {}); snapshot!(tokens as Expr, @r###" Expr::Struct { @@ -216,23 +206,36 @@ fn test_macro_variable_struct() { "###); } +#[test] +fn test_macro_variable_unary() { + // mimics the token stream corresponding to `$expr.method()` where expr is `&self` + let inner = Group::new(Delimiter::None, quote!(&self)); + let tokens = quote!(#inner.method()); + snapshot!(tokens as Expr, @r###" + Expr::MethodCall { + receiver: Expr::Group { + expr: Expr::Reference { + expr: Expr::Path { + path: Path { + segments: [ + PathSegment { + ident: "self", + }, + ], + }, + }, + }, + }, + method: "method", + } + "###); +} + #[test] fn test_macro_variable_match_arm() { // mimics the token stream corresponding to `match v { _ => $expr }` - let tokens = TokenStream::from_iter(vec![ - TokenTree::Ident(Ident::new("match", Span::call_site())), - TokenTree::Ident(Ident::new("v", Span::call_site())), - TokenTree::Group(Group::new( - Delimiter::Brace, - TokenStream::from_iter(vec![ - TokenTree::Punct(Punct::new('_', Spacing::Alone)), - TokenTree::Punct(Punct::new('=', Spacing::Joint)), - TokenTree::Punct(Punct::new('>', Spacing::Alone)), - TokenTree::Group(Group::new(Delimiter::None, quote! { #[a] () })), - ]), - )), - ]); - + let expr = Group::new(Delimiter::None, quote! { #[a] () }); + let tokens = quote!(match v { _ => #expr }); snapshot!(tokens as Expr, @r###" Expr::Match { expr: Expr::Path { @@ -267,6 +270,40 @@ fn test_macro_variable_match_arm() { ], } "###); + + let expr = Group::new(Delimiter::None, quote!(loop {} + 1)); + let tokens = quote!(match v { _ => #expr }); + snapshot!(tokens as Expr, @r###" + Expr::Match { + expr: Expr::Path { + path: Path { + segments: [ + PathSegment { + ident: "v", + }, + ], + }, + }, + arms: [ + Arm { + pat: Pat::Wild, + body: Expr::Group { + expr: Expr::Binary { + left: Expr::Loop { + body: Block { + stmts: [], + }, + }, + op: BinOp::Add, + right: Expr::Lit { + lit: 1, + }, + }, + }, + }, + ], + } + "###); } // https://github.com/dtolnay/syn/issues/1019 @@ -339,3 +376,165 @@ fn test_ambiguous_label() { syn::parse2::(stmt).unwrap_err(); } } + +#[test] +fn test_extended_interpolated_path() { + let path = Group::new(Delimiter::None, quote!(a::b)); + + let tokens = quote!(if #path {}); + snapshot!(tokens as Expr, @r###" + Expr::If { + cond: Expr::Group { + expr: Expr::Path { + path: Path { + segments: [ + PathSegment { + ident: "a", + }, + Token![::], + PathSegment { + ident: "b", + }, + ], + }, + }, + }, + then_branch: Block { + stmts: [], + }, + } + "###); + + let tokens = quote!(#path {}); + snapshot!(tokens as Expr, @r###" + Expr::Struct { + path: Path { + segments: [ + PathSegment { + ident: "a", + }, + Token![::], + PathSegment { + ident: "b", + }, + ], + }, + } + "###); + + let tokens = quote!(#path :: c); + snapshot!(tokens as Expr, @r###" + Expr::Path { + path: Path { + segments: [ + PathSegment { + ident: "a", + }, + Token![::], + PathSegment { + ident: "b", + }, + Token![::], + PathSegment { + ident: "c", + }, + ], + }, + } + "###); + + let nested = Group::new(Delimiter::None, quote!(a::b || true)); + let tokens = quote!(if #nested && false {}); + snapshot!(tokens as Expr, @r###" + Expr::If { + cond: Expr::Binary { + left: Expr::Group { + expr: Expr::Binary { + left: Expr::Path { + path: Path { + segments: [ + PathSegment { + ident: "a", + }, + Token![::], + PathSegment { + ident: "b", + }, + ], + }, + }, + op: BinOp::Or, + right: Expr::Lit { + lit: Lit::Bool { + value: true, + }, + }, + }, + }, + op: BinOp::And, + right: Expr::Lit { + lit: Lit::Bool { + value: false, + }, + }, + }, + then_branch: Block { + stmts: [], + }, + } + "###); +} + +#[test] +fn test_tuple_comma() { + let mut expr = ExprTuple { + attrs: Vec::new(), + paren_token: token::Paren::default(), + elems: Punctuated::new(), + }; + snapshot!(expr.to_token_stream() as Expr, @"Expr::Tuple"); + + expr.elems.push_value(parse_quote!(continue)); + // Must not parse to Expr::Paren + snapshot!(expr.to_token_stream() as Expr, @r###" + Expr::Tuple { + elems: [ + Expr::Continue, + Token![,], + ], + } + "###); + + expr.elems.push_punct(::default()); + snapshot!(expr.to_token_stream() as Expr, @r###" + Expr::Tuple { + elems: [ + Expr::Continue, + Token![,], + ], + } + "###); + + expr.elems.push_value(parse_quote!(continue)); + snapshot!(expr.to_token_stream() as Expr, @r###" + Expr::Tuple { + elems: [ + Expr::Continue, + Token![,], + Expr::Continue, + ], + } + "###); + + expr.elems.push_punct(::default()); + snapshot!(expr.to_token_stream() as Expr, @r###" + Expr::Tuple { + elems: [ + Expr::Continue, + Token![,], + Expr::Continue, + Token![,], + ], + } + "###); +} diff --git a/third_party/rust/syn/tests/test_generics.rs b/third_party/rust/syn/tests/test_generics.rs index 51119adc84e79..3faf0dba59ef6 100644 --- a/third_party/rust/syn/tests/test_generics.rs +++ b/third_party/rust/syn/tests/test_generics.rs @@ -28,6 +28,7 @@ fn test_split_for_impl() { ident: "a", }, }), + Token![,], GenericParam::Lifetime(LifetimeParam { lifetime: Lifetime { ident: "b", @@ -39,6 +40,7 @@ fn test_split_for_impl() { }, ], }), + Token![,], GenericParam::Type(TypeParam { attrs: [ Attribute { @@ -227,6 +229,7 @@ fn test_fn_precedence_in_where_clause() { ], }, }), + Token![+], TypeParamBound::Trait(TraitBound { path: Path { segments: [ @@ -238,12 +241,15 @@ fn test_fn_precedence_in_where_clause() { }), ], }), + Token![,], ], }), }, output: ReturnType::Default, }, - block: Block, + block: Block { + stmts: [], + }, } "###); diff --git a/third_party/rust/syn/tests/test_item.rs b/third_party/rust/syn/tests/test_item.rs index 9b0e1c9ff0295..db9e3ab515e11 100644 --- a/third_party/rust/syn/tests/test_item.rs +++ b/third_party/rust/syn/tests/test_item.rs @@ -38,7 +38,9 @@ fn test_macro_variable_attr() { generics: Generics, output: ReturnType::Default, }, - block: Block, + block: Block { + stmts: [], + }, } "###); } @@ -228,6 +230,7 @@ fn test_supertraits() { ], }, }), + Token![+], ], } "###); @@ -316,11 +319,14 @@ fn test_impl_trait_trailing_plus() { ], }, }), + Token![+], ], }, ), }, - block: Block, + block: Block { + stmts: [], + }, } "###); } diff --git a/third_party/rust/syn/tests/test_meta.rs b/third_party/rust/syn/tests/test_meta.rs index 91a9807000f7a..d991c38e45cee 100644 --- a/third_party/rust/syn/tests/test_meta.rs +++ b/third_party/rust/syn/tests/test_meta.rs @@ -144,6 +144,7 @@ fn test_parse_path() { PathSegment { ident: "serde", }, + Token![::], PathSegment { ident: "Serialize", }, diff --git a/third_party/rust/syn/tests/test_parse_buffer.rs b/third_party/rust/syn/tests/test_parse_buffer.rs index f2ca59c7561a5..2205b50b29e9e 100644 --- a/third_party/rust/syn/tests/test_parse_buffer.rs +++ b/third_party/rust/syn/tests/test_parse_buffer.rs @@ -1,7 +1,8 @@ #![allow(clippy::non_ascii_literal)] use proc_macro2::{Delimiter, Group, Punct, Spacing, TokenStream, TokenTree}; -use syn::parse::{discouraged::Speculative, Parse, ParseStream, Parser, Result}; +use syn::parse::discouraged::Speculative as _; +use syn::parse::{Parse, ParseStream, Parser, Result}; use syn::{parenthesized, Token}; #[test] diff --git a/third_party/rust/syn/tests/test_parse_quote.rs b/third_party/rust/syn/tests/test_parse_quote.rs new file mode 100644 index 0000000000000..73aae709afdec --- /dev/null +++ b/third_party/rust/syn/tests/test_parse_quote.rs @@ -0,0 +1,164 @@ +#[macro_use] +mod macros; + +use syn::punctuated::Punctuated; +use syn::{parse_quote, Attribute, Field, Lit, Pat, Stmt, Token}; + +#[test] +fn test_attribute() { + let attr: Attribute = parse_quote!(#[test]); + snapshot!(attr, @r###" + Attribute { + style: AttrStyle::Outer, + meta: Meta::Path { + segments: [ + PathSegment { + ident: "test", + }, + ], + }, + } + "###); + + let attr: Attribute = parse_quote!(#![no_std]); + snapshot!(attr, @r###" + Attribute { + style: AttrStyle::Inner, + meta: Meta::Path { + segments: [ + PathSegment { + ident: "no_std", + }, + ], + }, + } + "###); +} + +#[test] +fn test_field() { + let field: Field = parse_quote!(pub enabled: bool); + snapshot!(field, @r###" + Field { + vis: Visibility::Public, + ident: Some("enabled"), + colon_token: Some, + ty: Type::Path { + path: Path { + segments: [ + PathSegment { + ident: "bool", + }, + ], + }, + }, + } + "###); + + let field: Field = parse_quote!(primitive::bool); + snapshot!(field, @r###" + Field { + vis: Visibility::Inherited, + ty: Type::Path { + path: Path { + segments: [ + PathSegment { + ident: "primitive", + }, + Token![::], + PathSegment { + ident: "bool", + }, + ], + }, + }, + } + "###); +} + +#[test] +fn test_pat() { + let pat: Pat = parse_quote!(Some(false) | None); + snapshot!(&pat, @r###" + Pat::Or { + cases: [ + Pat::TupleStruct { + path: Path { + segments: [ + PathSegment { + ident: "Some", + }, + ], + }, + elems: [ + Pat::Lit(ExprLit { + lit: Lit::Bool { + value: false, + }, + }), + ], + }, + Token![|], + Pat::Ident { + ident: "None", + }, + ], + } + "###); + + let boxed_pat: Box = parse_quote!(Some(false) | None); + assert_eq!(*boxed_pat, pat); +} + +#[test] +fn test_punctuated() { + let punctuated: Punctuated = parse_quote!(true | true); + snapshot!(punctuated, @r###" + [ + Lit::Bool { + value: true, + }, + Token![|], + Lit::Bool { + value: true, + }, + ] + "###); + + let punctuated: Punctuated = parse_quote!(true | true |); + snapshot!(punctuated, @r###" + [ + Lit::Bool { + value: true, + }, + Token![|], + Lit::Bool { + value: true, + }, + Token![|], + ] + "###); +} + +#[test] +fn test_vec_stmt() { + let stmts: Vec = parse_quote! { + let _; + true + }; + snapshot!(stmts, @r###" + [ + Stmt::Local { + pat: Pat::Wild, + }, + Stmt::Expr( + Expr::Lit { + lit: Lit::Bool { + value: true, + }, + }, + None, + ), + ] + "###); +} diff --git a/third_party/rust/syn/tests/test_parse_stream.rs b/third_party/rust/syn/tests/test_parse_stream.rs index 2265dfe8728b5..6e4a5a505fd9e 100644 --- a/third_party/rust/syn/tests/test_parse_stream.rs +++ b/third_party/rust/syn/tests/test_parse_stream.rs @@ -1,6 +1,6 @@ #![allow(clippy::let_underscore_untyped)] -use syn::ext::IdentExt; +use syn::ext::IdentExt as _; use syn::parse::ParseStream; use syn::{Ident, Token}; diff --git a/third_party/rust/syn/tests/test_pat.rs b/third_party/rust/syn/tests/test_pat.rs index cab7aa7f6d5f9..7b5f8b02571b8 100644 --- a/third_party/rust/syn/tests/test_pat.rs +++ b/third_party/rust/syn/tests/test_pat.rs @@ -4,9 +4,10 @@ mod macros; use proc_macro2::{Delimiter, Group, TokenStream, TokenTree}; -use quote::quote; +use quote::{quote, ToTokens as _}; use syn::parse::Parser; -use syn::{Item, Pat, Stmt}; +use syn::punctuated::Punctuated; +use syn::{parse_quote, token, Item, Pat, PatTuple, Stmt, Token}; #[test] fn test_pat_ident() { @@ -95,3 +96,57 @@ fn test_ranges() { Pat::parse_single.parse_str("[_, (..=hi), _]").unwrap(); Pat::parse_single.parse_str("[_, lo..=hi, _]").unwrap(); } + +#[test] +fn test_tuple_comma() { + let mut expr = PatTuple { + attrs: Vec::new(), + paren_token: token::Paren::default(), + elems: Punctuated::new(), + }; + snapshot!(expr.to_token_stream() as Pat, @"Pat::Tuple"); + + expr.elems.push_value(parse_quote!(_)); + // Must not parse to Pat::Paren + snapshot!(expr.to_token_stream() as Pat, @r###" + Pat::Tuple { + elems: [ + Pat::Wild, + Token![,], + ], + } + "###); + + expr.elems.push_punct(::default()); + snapshot!(expr.to_token_stream() as Pat, @r###" + Pat::Tuple { + elems: [ + Pat::Wild, + Token![,], + ], + } + "###); + + expr.elems.push_value(parse_quote!(_)); + snapshot!(expr.to_token_stream() as Pat, @r###" + Pat::Tuple { + elems: [ + Pat::Wild, + Token![,], + Pat::Wild, + ], + } + "###); + + expr.elems.push_punct(::default()); + snapshot!(expr.to_token_stream() as Pat, @r###" + Pat::Tuple { + elems: [ + Pat::Wild, + Token![,], + Pat::Wild, + Token![,], + ], + } + "###); +} diff --git a/third_party/rust/syn/tests/test_path.rs b/third_party/rust/syn/tests/test_path.rs index 6aded74e6a785..2873441abd570 100644 --- a/third_party/rust/syn/tests/test_path.rs +++ b/third_party/rust/syn/tests/test_path.rs @@ -24,6 +24,7 @@ fn parse_interpolated_leading_component() { PathSegment { ident: "first", }, + Token![::], PathSegment { ident: "rest", }, @@ -39,6 +40,7 @@ fn parse_interpolated_leading_component() { PathSegment { ident: "first", }, + Token![::], PathSegment { ident: "rest", }, diff --git a/third_party/rust/syn/tests/test_precedence.rs b/third_party/rust/syn/tests/test_precedence.rs index bf0510bb3898a..026bece505762 100644 --- a/third_party/rust/syn/tests/test_precedence.rs +++ b/third_party/rust/syn/tests/test_precedence.rs @@ -1,8 +1,25 @@ +//! This test does the following for every file in the rust-lang/rust repo: +//! +//! 1. Parse the file using syn into a syn::File. +//! 2. Extract every syn::Expr from the file. +//! 3. Print each expr to a string of source code. +//! 4. Parse the source code using librustc_parse into a rustc_ast::Expr. +//! 5. For both the syn::Expr and rustc_ast::Expr, crawl the syntax tree to +//! insert parentheses surrounding every subexpression. +//! 6. Serialize the fully parenthesized syn::Expr to a string of source code. +//! 7. Parse the fully parenthesized source code using librustc_parse. +//! 8. Compare the rustc_ast::Expr resulting from parenthesizing using rustc +//! data structures vs syn data structures, ignoring spans. If they agree, +//! rustc's parser and syn's parser have identical handling of expression +//! precedence. + #![cfg(not(syn_disable_nightly_tests))] #![cfg(not(miri))] #![recursion_limit = "1024"] #![feature(rustc_private)] #![allow( + clippy::blocks_in_conditions, + clippy::doc_markdown, clippy::explicit_deref_methods, clippy::let_underscore_untyped, clippy::manual_assert, @@ -13,18 +30,6 @@ clippy::uninlined_format_args )] -//! The tests in this module do the following: -//! -//! 1. Parse a given expression in both `syn` and `librustc`. -//! 2. Fold over the expression adding brackets around each subexpression (with -//! some complications - see the `syn_brackets` and `librustc_brackets` -//! methods). -//! 3. Serialize the `syn` expression back into a string, and re-parse it with -//! `librustc`. -//! 4. Respan all of the expressions, replacing the spans with the default -//! spans. -//! 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; @@ -35,8 +40,7 @@ extern crate thin_vec; use crate::common::eq::SpanlessEq; use crate::common::parse; -use quote::quote; -use regex::Regex; +use quote::ToTokens; use rustc_ast::ast; use rustc_ast::ptr::P; use rustc_ast_pretty::pprust; @@ -66,12 +70,8 @@ fn test_rustc_precedence() { let passed = AtomicUsize::new(0); let failed = AtomicUsize::new(0); - // 2018 edition is hard - let edition_regex = Regex::new(r"\b(async|try)[!(]").unwrap(); - repo::for_each_rust_file(|path| { let content = fs::read_to_string(path).unwrap(); - let content = edition_regex.replace_all(&content, "_$0"); let (l_passed, l_failed) = match syn::parse_file(&content) { Ok(file) => { @@ -117,41 +117,65 @@ fn test_expressions(path: &Path, edition: Edition, exprs: Vec) -> (us rustc_span::create_session_if_not_set_then(edition, |_| { for expr in exprs { - let raw = quote!(#expr).to_string(); - - let librustc_ast = if let Some(e) = librustc_parse_and_rewrite(&raw) { + let source_code = expr.to_token_stream().to_string(); + let librustc_ast = if let Some(e) = librustc_parse_and_rewrite(&source_code) { e } else { failed += 1; - errorf!("\nFAIL {} - librustc failed to parse raw\n", path.display()); + errorf!( + "\nFAIL {} - librustc failed to parse original\n", + path.display(), + ); continue; }; - let syn_expr = syn_brackets(expr); - let syn_ast = if let Some(e) = parse::librustc_expr("e!(#syn_expr).to_string()) { + let syn_parenthesized_code = + syn_parenthesize(expr.clone()).to_token_stream().to_string(); + let syn_ast = if let Some(e) = parse::librustc_expr(&syn_parenthesized_code) { e } else { failed += 1; errorf!( - "\nFAIL {} - librustc failed to parse bracketed\n", + "\nFAIL {} - librustc failed to parse parenthesized\n", path.display(), ); continue; }; - if SpanlessEq::eq(&syn_ast, &librustc_ast) { - passed += 1; - } else { + if !SpanlessEq::eq(&syn_ast, &librustc_ast) { failed += 1; - let syn_program = pprust::expr_to_string(&syn_ast); - let librustc_program = pprust::expr_to_string(&librustc_ast); + let syn_pretty = pprust::expr_to_string(&syn_ast); + let librustc_pretty = pprust::expr_to_string(&librustc_ast); errorf!( "\nFAIL {}\n{}\nsyn != rustc\n{}\n", path.display(), - syn_program, - librustc_program, + syn_pretty, + librustc_pretty, + ); + continue; + } + + let expr_invisible = make_parens_invisible(expr); + let Ok(reparsed_expr_invisible) = syn::parse2(expr_invisible.to_token_stream()) else { + failed += 1; + errorf!( + "\nFAIL {} - syn failed to parse invisible delimiters\n{}\n", + path.display(), + source_code, + ); + continue; + }; + if expr_invisible != reparsed_expr_invisible { + failed += 1; + errorf!( + "\nFAIL {} - mismatch after parsing invisible delimiters\n{}\n", + path.display(), + source_code, ); + continue; } + + passed += 1; } }); @@ -159,19 +183,14 @@ fn test_expressions(path: &Path, edition: Edition, exprs: Vec) -> (us } fn librustc_parse_and_rewrite(input: &str) -> Option> { - parse::librustc_expr(input).and_then(librustc_brackets) + parse::librustc_expr(input).map(librustc_parenthesize) } -/// Wrap every expression which is not already wrapped in parens with parens, to -/// reveal the precedence of the parsed expressions, and produce a stringified -/// form of the resulting expression. -/// -/// This method operates on librustc objects. -fn librustc_brackets(mut librustc_expr: P) -> Option> { +fn librustc_parenthesize(mut librustc_expr: P) -> P { use rustc_ast::ast::{ - AssocItem, AssocItemKind, Attribute, BinOpKind, Block, BorrowKind, Expr, ExprField, - ExprKind, GenericArg, GenericBound, ItemKind, Local, LocalKind, Pat, Stmt, StmtKind, - StructExpr, StructRest, TraitBoundModifier, Ty, + AssocItem, AssocItemKind, Attribute, BinOpKind, Block, BorrowKind, BoundConstness, Expr, + ExprField, ExprKind, GenericArg, GenericBound, ItemKind, Local, LocalKind, Pat, Stmt, + StmtKind, StructExpr, StructRest, TraitBoundModifiers, Ty, }; use rustc_ast::mut_visit::{ noop_flat_map_assoc_item, noop_visit_generic_arg, noop_visit_item_kind, noop_visit_local, @@ -184,9 +203,7 @@ fn librustc_brackets(mut librustc_expr: P) -> Option> { use std::ops::DerefMut; use thin_vec::ThinVec; - struct BracketsVisitor { - failed: bool, - } + struct FullyParenthesize; fn contains_let_chain(expr: &Expr) -> bool { match &expr.kind { @@ -250,7 +267,7 @@ fn librustc_brackets(mut librustc_expr: P) -> Option> { } } - impl MutVisitor for BracketsVisitor { + impl MutVisitor for FullyParenthesize { fn visit_expr(&mut self, e: &mut P) { noop_visit_expr(e, self); match e.kind { @@ -288,7 +305,10 @@ fn librustc_brackets(mut librustc_expr: P) -> Option> { match bound { GenericBound::Trait( _, - TraitBoundModifier::MaybeConst | TraitBoundModifier::MaybeConstMaybe, + TraitBoundModifiers { + constness: BoundConstness::Maybe(_), + .. + }, ) => {} _ => noop_visit_param_bound(bound, self), } @@ -358,23 +378,16 @@ fn librustc_brackets(mut librustc_expr: P) -> Option> { } } - let mut folder = BracketsVisitor { failed: false }; + let mut folder = FullyParenthesize; folder.visit_expr(&mut librustc_expr); - if folder.failed { - None - } else { - Some(librustc_expr) - } + librustc_expr } -/// Wrap every expression which is not already wrapped in parens with parens, to -/// 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 { +fn syn_parenthesize(syn_expr: syn::Expr) -> syn::Expr { use syn::fold::{fold_expr, fold_generic_argument, Fold}; use syn::{token, BinOp, Expr, ExprParen, GenericArgument, MetaNameValue, Pat, Stmt, Type}; - struct ParenthesizeEveryExpr; + struct FullyParenthesize; fn parenthesize(expr: Expr) -> Expr { Expr::Paren(ExprParen { @@ -404,7 +417,7 @@ fn syn_brackets(syn_expr: syn::Expr) -> syn::Expr { } } - impl Fold for ParenthesizeEveryExpr { + impl Fold for FullyParenthesize { fn fold_expr(&mut self, expr: Expr) -> Expr { let needs_paren = needs_paren(&expr); let folded = fold_expr(self, expr); @@ -452,10 +465,48 @@ fn syn_brackets(syn_expr: syn::Expr) -> syn::Expr { } } - let mut folder = ParenthesizeEveryExpr; + let mut folder = FullyParenthesize; folder.fold_expr(syn_expr) } +fn make_parens_invisible(expr: syn::Expr) -> syn::Expr { + use syn::fold::{fold_expr, fold_stmt, Fold}; + use syn::{token, Expr, ExprGroup, ExprParen, Stmt}; + + struct MakeParensInvisible; + + impl Fold for MakeParensInvisible { + fn fold_expr(&mut self, mut expr: Expr) -> Expr { + if let Expr::Paren(paren) = expr { + expr = Expr::Group(ExprGroup { + attrs: paren.attrs, + group_token: token::Group(paren.paren_token.span.join()), + expr: paren.expr, + }); + } + fold_expr(self, expr) + } + + fn fold_stmt(&mut self, stmt: Stmt) -> Stmt { + if let Stmt::Expr(expr @ (Expr::Binary(_) | Expr::Cast(_)), None) = stmt { + Stmt::Expr( + Expr::Paren(ExprParen { + attrs: Vec::new(), + paren_token: token::Paren::default(), + expr: Box::new(fold_expr(self, expr)), + }), + None, + ) + } else { + fold_stmt(self, stmt) + } + } + } + + let mut folder = MakeParensInvisible; + folder.fold_expr(expr) +} + /// Walk through a crate collecting all expressions we can find in it. fn collect_exprs(file: syn::File) -> Vec { use syn::fold::Fold; diff --git a/third_party/rust/syn/tests/test_round_trip.rs b/third_party/rust/syn/tests/test_round_trip.rs index c0af30d29cbaa..a673fffa74ec8 100644 --- a/third_party/rust/syn/tests/test_round_trip.rs +++ b/third_party/rust/syn/tests/test_round_trip.rs @@ -3,6 +3,7 @@ #![recursion_limit = "1024"] #![feature(rustc_private)] #![allow( + clippy::blocks_in_conditions, clippy::manual_assert, clippy::manual_let_else, clippy::match_like_matches_macro, @@ -164,7 +165,7 @@ fn translate_message(diagnostic: &Diagnostic) -> Cow<'static, str> { }; } - let message = &diagnostic.message[0].0; + let message = &diagnostic.messages[0].0; let args = translation::to_fluent_args(diagnostic.args()); let (identifier, attr) = match message { diff --git a/third_party/rust/syn/tests/test_shebang.rs b/third_party/rust/syn/tests/test_shebang.rs index 4c2a204573385..843916180f85a 100644 --- a/third_party/rust/syn/tests/test_shebang.rs +++ b/third_party/rust/syn/tests/test_shebang.rs @@ -18,7 +18,9 @@ fn test_basic() { generics: Generics, output: ReturnType::Default, }, - block: Block, + block: Block { + stmts: [], + }, }, ], } @@ -55,7 +57,9 @@ fn test_comment() { generics: Generics, output: ReturnType::Default, }, - block: Block, + block: Block { + stmts: [], + }, }, ], } diff --git a/third_party/rust/syn/tests/test_size.rs b/third_party/rust/syn/tests/test_size.rs index 943fcd354b8a3..d64a3ab6eb0a6 100644 --- a/third_party/rust/syn/tests/test_size.rs +++ b/third_party/rust/syn/tests/test_size.rs @@ -29,8 +29,8 @@ fn test_pat_size() { assert_eq!(mem::size_of::(), 184); } -#[rustversion::attr(before(2022-09-09), ignore)] +#[rustversion::attr(before(2023-12-20), ignore)] #[test] fn test_lit_size() { - assert_eq!(mem::size_of::(), 32); + assert_eq!(mem::size_of::(), 24); } diff --git a/third_party/rust/syn/tests/test_stmt.rs b/third_party/rust/syn/tests/test_stmt.rs index bc57685df79b3..61890a40eccb5 100644 --- a/third_party/rust/syn/tests/test_stmt.rs +++ b/third_party/rust/syn/tests/test_stmt.rs @@ -8,8 +8,9 @@ mod macros; use proc_macro2::{Delimiter, Group, Ident, Span, TokenStream, TokenTree}; -use quote::quote; -use syn::Stmt; +use quote::{quote, ToTokens as _}; +use syn::parse::Parser as _; +use syn::{Block, Stmt}; #[test] fn test_raw_operator() { @@ -67,7 +68,6 @@ fn test_none_group() { TokenTree::Group(Group::new(Delimiter::Brace, TokenStream::new())), ]), ))]); - snapshot!(tokens as Stmt, @r###" Stmt::Item(Item::Fn { vis: Visibility::Inherited, @@ -77,9 +77,37 @@ fn test_none_group() { generics: Generics, output: ReturnType::Default, }, - block: Block, + block: Block { + stmts: [], + }, }) "###); + + let tokens = Group::new(Delimiter::None, quote!(let None = None)).to_token_stream(); + let stmts = Block::parse_within.parse2(tokens).unwrap(); + snapshot!(stmts, @r###" + [ + Stmt::Expr( + Expr::Group { + expr: Expr::Let { + pat: Pat::Ident { + ident: "None", + }, + expr: Expr::Path { + path: Path { + segments: [ + PathSegment { + ident: "None", + }, + ], + }, + }, + }, + }, + None, + ), + ] + "###); } #[test] @@ -234,3 +262,61 @@ fn test_macros() { }) "###); } + +#[test] +fn test_early_parse_loop() { + // The following is an Expr::Loop followed by Expr::Tuple. It is not an + // Expr::Call. + let tokens = quote! { + loop {} + () + }; + + let stmts = Block::parse_within.parse2(tokens).unwrap(); + + snapshot!(stmts, @r###" + [ + Stmt::Expr( + Expr::Loop { + body: Block { + stmts: [], + }, + }, + None, + ), + Stmt::Expr( + Expr::Tuple, + None, + ), + ] + "###); + + let tokens = quote! { + 'a: loop {} + () + }; + + let stmts = Block::parse_within.parse2(tokens).unwrap(); + + snapshot!(stmts, @r###" + [ + Stmt::Expr( + Expr::Loop { + label: Some(Label { + name: Lifetime { + ident: "a", + }, + }), + body: Block { + stmts: [], + }, + }, + None, + ), + Stmt::Expr( + Expr::Tuple, + None, + ), + ] + "###); +} diff --git a/third_party/rust/syn/tests/test_ty.rs b/third_party/rust/syn/tests/test_ty.rs index a400a761242c1..06453934f8f9f 100644 --- a/third_party/rust/syn/tests/test_ty.rs +++ b/third_party/rust/syn/tests/test_ty.rs @@ -4,8 +4,9 @@ mod macros; use proc_macro2::{Delimiter, Group, Ident, Punct, Spacing, Span, TokenStream, TokenTree}; -use quote::quote; -use syn::Type; +use quote::{quote, ToTokens as _}; +use syn::punctuated::Punctuated; +use syn::{parse_quote, token, Token, Type, TypeTuple}; #[test] fn test_mut_self() { @@ -170,6 +171,7 @@ fn test_group_colons() { ], }, }, + Token![::], PathSegment { ident: "Item", }, @@ -245,6 +247,7 @@ fn test_trait_object() { ], }, }), + Token![+], TypeParamBound::Lifetime { ident: "static", }, @@ -260,6 +263,7 @@ fn test_trait_object() { TypeParamBound::Lifetime { ident: "a", }, + Token![+], TypeParamBound::Trait(TraitBound { path: Path { segments: [ @@ -294,6 +298,7 @@ fn test_trailing_plus() { ], }, }), + Token![+], ], } "###); @@ -313,6 +318,7 @@ fn test_trailing_plus() { ], }, }), + Token![+], ], } "###); @@ -331,6 +337,60 @@ fn test_trailing_plus() { ], }, }), + Token![+], + ], + } + "###); +} + +#[test] +fn test_tuple_comma() { + let mut expr = TypeTuple { + paren_token: token::Paren::default(), + elems: Punctuated::new(), + }; + snapshot!(expr.to_token_stream() as Type, @"Type::Tuple"); + + expr.elems.push_value(parse_quote!(_)); + // Must not parse to Type::Paren + snapshot!(expr.to_token_stream() as Type, @r###" + Type::Tuple { + elems: [ + Type::Infer, + Token![,], + ], + } + "###); + + expr.elems.push_punct(::default()); + snapshot!(expr.to_token_stream() as Type, @r###" + Type::Tuple { + elems: [ + Type::Infer, + Token![,], + ], + } + "###); + + expr.elems.push_value(parse_quote!(_)); + snapshot!(expr.to_token_stream() as Type, @r###" + Type::Tuple { + elems: [ + Type::Infer, + Token![,], + Type::Infer, + ], + } + "###); + + expr.elems.push_punct(::default()); + snapshot!(expr.to_token_stream() as Type, @r###" + Type::Tuple { + elems: [ + Type::Infer, + Token![,], + Type::Infer, + Token![,], ], } "###); diff --git a/third_party/rust/thiserror-impl/.cargo-checksum.json b/third_party/rust/thiserror-impl/.cargo-checksum.json index a05c1451f8b4a..f091d556de469 100644 --- a/third_party/rust/thiserror-impl/.cargo-checksum.json +++ b/third_party/rust/thiserror-impl/.cargo-checksum.json @@ -1 +1 @@ -{"files":{"Cargo.toml":"f0ec2f02a8e4b3d1ba232448e49f5ab3865f89dff475a10cae26d498c9b43b04","LICENSE-APACHE":"62c7a1e35f56406896d7aa7ca52d0cc0d272ac022b5d2796e7d6905db8a3636a","LICENSE-MIT":"23f18e03dc49df91622fe2a76176497404e46ced8a715d9d2b67a7446571cca3","src/ast.rs":"c7601e8394f5ee304365c520181f0dbeaa807ddaa71ce4a8618ea1a70f81b3b2","src/attr.rs":"26dca4c6b2ae3a2457bb4ed8e7e869539f4fdfd9e92e29b36c2bbc2c072b387d","src/expand.rs":"cb5ce6771c95eccd9c2137c02550a1d575c50607168d4a7d82edb5cd32d9b36b","src/fmt.rs":"d63d39120c18712596f9f2a1715821148c2becd4d8bad5bc1b307210a84dbe98","src/generics.rs":"2076cde22271be355a8131a77add4b93f83ab0af4317cd2df5471fffa4f95c66","src/lib.rs":"7d023310cd3db670554ce108a6afd94e1ae3c55c83661d4b9fcebdf1865b9e4b","src/prop.rs":"6709932aee8f9d217f40cd644629c0ecb2f46d333ae8a1398e8d745534f4e028","src/valid.rs":"ac95253944fd360d3578d0643a7baabb2cfa6bf9fbced7a6ce1f7b0529a3bb98"},"package":"f9456a42c5b0d803c8cd86e73dd7cc9edd429499f37a3550d286d5e86720569f"} \ No newline at end of file +{"files":{"Cargo.toml":"b387bf85702168709e2619d65e68e1860dca1021ddd91346a09ec8bd1cc80471","LICENSE-APACHE":"62c7a1e35f56406896d7aa7ca52d0cc0d272ac022b5d2796e7d6905db8a3636a","LICENSE-MIT":"23f18e03dc49df91622fe2a76176497404e46ced8a715d9d2b67a7446571cca3","src/ast.rs":"e2fbc32e91cd462757107c1f8ab2f888f08c865ac71270583f9e11b83e3c32ca","src/attr.rs":"ad5319f053a18ec3841300b2ae553ffa005749ba7099fe4b318126223e4dcbdf","src/expand.rs":"9469753e0949556848183084e0f22521c6300d38ca0de196441446c50f350d3c","src/fmt.rs":"d63d39120c18712596f9f2a1715821148c2becd4d8bad5bc1b307210a84dbe98","src/generics.rs":"2076cde22271be355a8131a77add4b93f83ab0af4317cd2df5471fffa4f95c66","src/lib.rs":"5eea86c771e643328ad9bc3b881cce4bf9d50adae1b33e0d07645bdd9044003d","src/prop.rs":"5ba613e38430831259f20b258f33d57dcb783fbaeeb49e5faffa7b2a7be99e67","src/span.rs":"430460a4fa0d1fa9c627c1ddd575d2b101778fea84217591e1a93a5f6a2a0132","src/valid.rs":"ac95253944fd360d3578d0643a7baabb2cfa6bf9fbced7a6ce1f7b0529a3bb98"},"package":"fa0faa943b50f3db30a20aa7e265dbc66076993efed8463e8de414e5d06d3471"} \ No newline at end of file diff --git a/third_party/rust/thiserror-impl/Cargo.toml b/third_party/rust/thiserror-impl/Cargo.toml index bf6147075e469..fffdf5c3a4333 100644 --- a/third_party/rust/thiserror-impl/Cargo.toml +++ b/third_party/rust/thiserror-impl/Cargo.toml @@ -10,26 +10,27 @@ # See Cargo.toml.orig for the original contents. [package] -edition = "2018" +edition = "2021" rust-version = "1.56" name = "thiserror-impl" -version = "1.0.40" +version = "1.0.56" authors = ["David Tolnay "] description = "Implementation detail of the `thiserror` crate" license = "MIT OR Apache-2.0" repository = "https://github.com/dtolnay/thiserror" [package.metadata.docs.rs] +rustdoc-args = ["--generate-link-to-definition"] targets = ["x86_64-unknown-linux-gnu"] [lib] proc-macro = true [dependencies.proc-macro2] -version = "1.0" +version = "1.0.74" [dependencies.quote] -version = "1.0" +version = "1.0.35" [dependencies.syn] -version = "2.0" +version = "2.0.46" diff --git a/third_party/rust/thiserror-impl/src/ast.rs b/third_party/rust/thiserror-impl/src/ast.rs index 2aa7246c82d0e..9e069289801db 100644 --- a/third_party/rust/thiserror-impl/src/ast.rs +++ b/third_party/rust/thiserror-impl/src/ast.rs @@ -12,7 +12,6 @@ pub enum Input<'a> { } pub struct Struct<'a> { - pub original: &'a DeriveInput, pub attrs: Attrs<'a>, pub ident: Ident, pub generics: &'a Generics, @@ -20,7 +19,6 @@ pub struct Struct<'a> { } pub struct Enum<'a> { - pub original: &'a DeriveInput, pub attrs: Attrs<'a>, pub ident: Ident, pub generics: &'a Generics, @@ -65,7 +63,6 @@ impl<'a> Struct<'a> { display.expand_shorthand(&fields); } Ok(Struct { - original: node, attrs, ident: node.ident.clone(), generics: &node.generics, @@ -96,7 +93,6 @@ impl<'a> Enum<'a> { }) .collect::>()?; Ok(Enum { - original: node, attrs, ident: node.ident.clone(), generics: &node.generics, diff --git a/third_party/rust/thiserror-impl/src/attr.rs b/third_party/rust/thiserror-impl/src/attr.rs index 0b1b89dce3bf1..4beb8c96281d5 100644 --- a/third_party/rust/thiserror-impl/src/attr.rs +++ b/third_party/rust/thiserror-impl/src/attr.rs @@ -1,7 +1,6 @@ use proc_macro2::{Delimiter, Group, Span, TokenStream, TokenTree}; use quote::{format_ident, quote, ToTokens}; use std::collections::BTreeSet as Set; -use std::iter::FromIterator; use syn::parse::ParseStream; use syn::{ braced, bracketed, parenthesized, token, Attribute, Error, Ident, Index, LitInt, LitStr, Meta, @@ -57,13 +56,13 @@ pub fn get(input: &[Attribute]) -> Result { if attr.path().is_ident("error") { parse_error_attribute(&mut attrs, attr)?; } else if attr.path().is_ident("source") { - require_empty_attribute(attr)?; + attr.meta.require_path_only()?; if attrs.source.is_some() { return Err(Error::new_spanned(attr, "duplicate #[source] attribute")); } attrs.source = Some(attr); } else if attr.path().is_ident("backtrace") { - require_empty_attribute(attr)?; + attr.meta.require_path_only()?; if attrs.backtrace.is_some() { return Err(Error::new_spanned(attr, "duplicate #[backtrace] attribute")); } @@ -193,24 +192,12 @@ fn parse_token_expr(input: ParseStream, mut begin_expr: bool) -> Result Result<()> { - let error_span = match &attr.meta { - Meta::Path(_) => return Ok(()), - Meta::List(meta) => meta.delimiter.span().open(), - Meta::NameValue(meta) => meta.eq_token.span, - }; - Err(Error::new( - error_span, - "unexpected token in thiserror attribute", - )) -} - impl ToTokens for Display<'_> { fn to_tokens(&self, tokens: &mut TokenStream) { let fmt = &self.fmt; let args = &self.args; tokens.extend(quote! { - write!(__formatter, #fmt #args) + ::core::write!(__formatter, #fmt #args) }); } } @@ -218,6 +205,6 @@ impl ToTokens for Display<'_> { impl ToTokens for Trait { fn to_tokens(&self, tokens: &mut TokenStream) { let trait_name = format_ident!("{}", format!("{:?}", self)); - tokens.extend(quote!(std::fmt::#trait_name)); + tokens.extend(quote!(::core::fmt::#trait_name)); } } diff --git a/third_party/rust/thiserror-impl/src/expand.rs b/third_party/rust/thiserror-impl/src/expand.rs index ef8eaf31b7868..1b44513a23993 100644 --- a/third_party/rust/thiserror-impl/src/expand.rs +++ b/third_party/rust/thiserror-impl/src/expand.rs @@ -1,16 +1,24 @@ use crate::ast::{Enum, Field, Input, Struct}; use crate::attr::Trait; use crate::generics::InferredBounds; +use crate::span::MemberSpan; use proc_macro2::TokenStream; use quote::{format_ident, quote, quote_spanned, ToTokens}; use std::collections::BTreeSet as Set; -use syn::spanned::Spanned; -use syn::{ - Data, DeriveInput, GenericArgument, Member, PathArguments, Result, Token, Type, Visibility, -}; +use syn::{DeriveInput, GenericArgument, Member, PathArguments, Result, Token, Type}; -pub fn derive(node: &DeriveInput) -> Result { - let input = Input::from_syn(node)?; +pub fn derive(input: &DeriveInput) -> TokenStream { + match try_expand(input) { + Ok(expanded) => expanded, + // If there are invalid attributes in the input, expand to an Error impl + // anyway to minimize spurious knock-on errors in other code that uses + // this type as an Error. + Err(error) => fallback(input, error), + } +} + +fn try_expand(input: &DeriveInput) -> Result { + let input = Input::from_syn(input)?; input.validate()?; Ok(match input { Input::Struct(input) => impl_struct(input), @@ -18,18 +26,44 @@ pub fn derive(node: &DeriveInput) -> Result { }) } +fn fallback(input: &DeriveInput, error: syn::Error) -> TokenStream { + let ty = &input.ident; + let (impl_generics, ty_generics, where_clause) = input.generics.split_for_impl(); + + let error = error.to_compile_error(); + + quote! { + #error + + #[allow(unused_qualifications)] + impl #impl_generics std::error::Error for #ty #ty_generics #where_clause + where + // Work around trivial bounds being unstable. + // https://github.com/rust-lang/rust/issues/48214 + for<'workaround> #ty #ty_generics: ::core::fmt::Debug, + {} + + #[allow(unused_qualifications)] + impl #impl_generics ::core::fmt::Display for #ty #ty_generics #where_clause { + fn fmt(&self, __formatter: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { + ::core::unreachable!() + } + } + } +} + fn impl_struct(input: Struct) -> TokenStream { let ty = &input.ident; let (impl_generics, ty_generics, where_clause) = input.generics.split_for_impl(); let mut error_inferred_bounds = InferredBounds::new(); - let source_body = if input.attrs.transparent.is_some() { + let source_body = if let Some(transparent_attr) = &input.attrs.transparent { let only_field = &input.fields[0]; if only_field.contains_generic { error_inferred_bounds.insert(only_field.ty, quote!(std::error::Error)); } let member = &only_field.member; - Some(quote! { + Some(quote_spanned! {transparent_attr.span=> std::error::Error::source(self.#member.as_dyn_error()) }) } else if let Some(source_field) = input.source_field() { @@ -39,73 +73,75 @@ fn impl_struct(input: Struct) -> TokenStream { error_inferred_bounds.insert(ty, quote!(std::error::Error + 'static)); } let asref = if type_is_option(source_field.ty) { - Some(quote_spanned!(source.span()=> .as_ref()?)) + Some(quote_spanned!(source.member_span()=> .as_ref()?)) } else { None }; - let dyn_error = quote_spanned!(source.span()=> self.#source #asref.as_dyn_error()); + let dyn_error = quote_spanned! {source_field.source_span()=> + self.#source #asref.as_dyn_error() + }; Some(quote! { - std::option::Option::Some(#dyn_error) + ::core::option::Option::Some(#dyn_error) }) } else { None }; let source_method = source_body.map(|body| { quote! { - fn source(&self) -> std::option::Option<&(dyn std::error::Error + 'static)> { - use thiserror::__private::AsDynError; + fn source(&self) -> ::core::option::Option<&(dyn std::error::Error + 'static)> { + use thiserror::__private::AsDynError as _; #body } } }); let provide_method = input.backtrace_field().map(|backtrace_field| { - let demand = quote!(demand); + let request = quote!(request); let backtrace = &backtrace_field.member; let body = if let Some(source_field) = input.source_field() { let source = &source_field.member; let source_provide = if type_is_option(source_field.ty) { - quote_spanned! {source.span()=> - if let std::option::Option::Some(source) = &self.#source { - source.thiserror_provide(#demand); + quote_spanned! {source.member_span()=> + if let ::core::option::Option::Some(source) = &self.#source { + source.thiserror_provide(#request); } } } else { - quote_spanned! {source.span()=> - self.#source.thiserror_provide(#demand); + quote_spanned! {source.member_span()=> + self.#source.thiserror_provide(#request); } }; let self_provide = if source == backtrace { None } else if type_is_option(backtrace_field.ty) { Some(quote! { - if let std::option::Option::Some(backtrace) = &self.#backtrace { - #demand.provide_ref::(backtrace); + if let ::core::option::Option::Some(backtrace) = &self.#backtrace { + #request.provide_ref::(backtrace); } }) } else { Some(quote! { - #demand.provide_ref::(&self.#backtrace); + #request.provide_ref::(&self.#backtrace); }) }; quote! { - use thiserror::__private::ThiserrorProvide; + use thiserror::__private::ThiserrorProvide as _; #source_provide #self_provide } } else if type_is_option(backtrace_field.ty) { quote! { - if let std::option::Option::Some(backtrace) = &self.#backtrace { - #demand.provide_ref::(backtrace); + if let ::core::option::Option::Some(backtrace) = &self.#backtrace { + #request.provide_ref::(backtrace); } } } else { quote! { - #demand.provide_ref::(&self.#backtrace); + #request.provide_ref::(&self.#backtrace); } }; quote! { - fn provide<'_demand>(&'_demand self, #demand: &mut std::any::Demand<'_demand>) { + fn provide<'_request>(&'_request self, #request: &mut std::error::Request<'_request>) { #body } } @@ -116,18 +152,11 @@ fn impl_struct(input: Struct) -> TokenStream { let only_field = &input.fields[0].member; display_implied_bounds.insert((0, Trait::Display)); Some(quote! { - std::fmt::Display::fmt(&self.#only_field, __formatter) + ::core::fmt::Display::fmt(&self.#only_field, __formatter) }) } else if let Some(display) = &input.attrs.display { display_implied_bounds = display.implied_bounds.clone(); - let use_as_display = if display.has_bonus_display { - Some(quote! { - #[allow(unused_imports)] - use thiserror::__private::{DisplayAsDisplay, PathAsDisplay}; - }) - } else { - None - }; + let use_as_display = use_as_display(display.has_bonus_display); let pat = fields_pat(&input.fields); Some(quote! { #use_as_display @@ -149,9 +178,9 @@ fn impl_struct(input: Struct) -> TokenStream { let display_where_clause = display_inferred_bounds.augment_where_clause(input.generics); quote! { #[allow(unused_qualifications)] - impl #impl_generics std::fmt::Display for #ty #ty_generics #display_where_clause { + impl #impl_generics ::core::fmt::Display for #ty #ty_generics #display_where_clause { #[allow(clippy::used_underscore_binding)] - fn fmt(&self, __formatter: &mut std::fmt::Formatter) -> std::fmt::Result { + fn fmt(&self, __formatter: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { #body } } @@ -164,7 +193,7 @@ fn impl_struct(input: Struct) -> TokenStream { let body = from_initializer(from_field, backtrace_field); quote! { #[allow(unused_qualifications)] - impl #impl_generics std::convert::From<#from> for #ty #ty_generics #where_clause { + impl #impl_generics ::core::convert::From<#from> for #ty #ty_generics #where_clause { #[allow(deprecated)] fn from(source: #from) -> Self { #ty #body @@ -173,7 +202,6 @@ fn impl_struct(input: Struct) -> TokenStream { } }); - let error_trait = spanned_error_trait(input.original); if input.generics.type_params().next().is_some() { let self_token = ::default(); error_inferred_bounds.insert(self_token, Trait::Debug); @@ -183,7 +211,7 @@ fn impl_struct(input: Struct) -> TokenStream { quote! { #[allow(unused_qualifications)] - impl #impl_generics #error_trait for #ty #ty_generics #error_where_clause { + impl #impl_generics std::error::Error for #ty #ty_generics #error_where_clause { #source_method #provide_method } @@ -200,13 +228,15 @@ fn impl_enum(input: Enum) -> TokenStream { let source_method = if input.has_source() { let arms = input.variants.iter().map(|variant| { let ident = &variant.ident; - if variant.attrs.transparent.is_some() { + if let Some(transparent_attr) = &variant.attrs.transparent { let only_field = &variant.fields[0]; if only_field.contains_generic { error_inferred_bounds.insert(only_field.ty, quote!(std::error::Error)); } let member = &only_field.member; - let source = quote!(std::error::Error::source(transparent.as_dyn_error())); + let source = quote_spanned! {transparent_attr.span=> + std::error::Error::source(transparent.as_dyn_error()) + }; quote! { #ty::#ident {#member: transparent} => #source, } @@ -217,24 +247,26 @@ fn impl_enum(input: Enum) -> TokenStream { error_inferred_bounds.insert(ty, quote!(std::error::Error + 'static)); } let asref = if type_is_option(source_field.ty) { - Some(quote_spanned!(source.span()=> .as_ref()?)) + Some(quote_spanned!(source.member_span()=> .as_ref()?)) } else { None }; let varsource = quote!(source); - let dyn_error = quote_spanned!(source.span()=> #varsource #asref.as_dyn_error()); + let dyn_error = quote_spanned! {source_field.source_span()=> + #varsource #asref.as_dyn_error() + }; quote! { - #ty::#ident {#source: #varsource, ..} => std::option::Option::Some(#dyn_error), + #ty::#ident {#source: #varsource, ..} => ::core::option::Option::Some(#dyn_error), } } else { quote! { - #ty::#ident {..} => std::option::Option::None, + #ty::#ident {..} => ::core::option::Option::None, } } }); Some(quote! { - fn source(&self) -> std::option::Option<&(dyn std::error::Error + 'static)> { - use thiserror::__private::AsDynError; + fn source(&self) -> ::core::option::Option<&(dyn std::error::Error + 'static)> { + use thiserror::__private::AsDynError as _; #[allow(deprecated)] match self { #(#arms)* @@ -246,7 +278,7 @@ fn impl_enum(input: Enum) -> TokenStream { }; let provide_method = if input.has_backtrace() { - let demand = quote!(demand); + let request = quote!(request); let arms = input.variants.iter().map(|variant| { let ident = &variant.ident; match (variant.backtrace_field(), variant.source_field()) { @@ -257,25 +289,25 @@ fn impl_enum(input: Enum) -> TokenStream { let source = &source_field.member; let varsource = quote!(source); let source_provide = if type_is_option(source_field.ty) { - quote_spanned! {source.span()=> - if let std::option::Option::Some(source) = #varsource { - source.thiserror_provide(#demand); + quote_spanned! {source.member_span()=> + if let ::core::option::Option::Some(source) = #varsource { + source.thiserror_provide(#request); } } } else { - quote_spanned! {source.span()=> - #varsource.thiserror_provide(#demand); + quote_spanned! {source.member_span()=> + #varsource.thiserror_provide(#request); } }; let self_provide = if type_is_option(backtrace_field.ty) { quote! { - if let std::option::Option::Some(backtrace) = backtrace { - #demand.provide_ref::(backtrace); + if let ::core::option::Option::Some(backtrace) = backtrace { + #request.provide_ref::(backtrace); } } } else { quote! { - #demand.provide_ref::(backtrace); + #request.provide_ref::(backtrace); } }; quote! { @@ -284,7 +316,7 @@ fn impl_enum(input: Enum) -> TokenStream { #source: #varsource, .. } => { - use thiserror::__private::ThiserrorProvide; + use thiserror::__private::ThiserrorProvide as _; #source_provide #self_provide } @@ -296,19 +328,19 @@ fn impl_enum(input: Enum) -> TokenStream { let backtrace = &backtrace_field.member; let varsource = quote!(source); let source_provide = if type_is_option(source_field.ty) { - quote_spanned! {backtrace.span()=> - if let std::option::Option::Some(source) = #varsource { - source.thiserror_provide(#demand); + quote_spanned! {backtrace.member_span()=> + if let ::core::option::Option::Some(source) = #varsource { + source.thiserror_provide(#request); } } } else { - quote_spanned! {backtrace.span()=> - #varsource.thiserror_provide(#demand); + quote_spanned! {backtrace.member_span()=> + #varsource.thiserror_provide(#request); } }; quote! { #ty::#ident {#backtrace: #varsource, ..} => { - use thiserror::__private::ThiserrorProvide; + use thiserror::__private::ThiserrorProvide as _; #source_provide } } @@ -317,13 +349,13 @@ fn impl_enum(input: Enum) -> TokenStream { let backtrace = &backtrace_field.member; let body = if type_is_option(backtrace_field.ty) { quote! { - if let std::option::Option::Some(backtrace) = backtrace { - #demand.provide_ref::(backtrace); + if let ::core::option::Option::Some(backtrace) = backtrace { + #request.provide_ref::(backtrace); } } } else { quote! { - #demand.provide_ref::(backtrace); + #request.provide_ref::(backtrace); } }; quote! { @@ -338,7 +370,7 @@ fn impl_enum(input: Enum) -> TokenStream { } }); Some(quote! { - fn provide<'_demand>(&'_demand self, #demand: &mut std::any::Demand<'_demand>) { + fn provide<'_request>(&'_request self, #request: &mut std::error::Request<'_request>) { #[allow(deprecated)] match self { #(#arms)* @@ -351,19 +383,13 @@ fn impl_enum(input: Enum) -> TokenStream { let display_impl = if input.has_display() { let mut display_inferred_bounds = InferredBounds::new(); - let use_as_display = if input.variants.iter().any(|v| { + let has_bonus_display = input.variants.iter().any(|v| { v.attrs .display .as_ref() .map_or(false, |display| display.has_bonus_display) - }) { - Some(quote! { - #[allow(unused_imports)] - use thiserror::__private::{DisplayAsDisplay, PathAsDisplay}; - }) - } else { - None - }; + }); + let use_as_display = use_as_display(has_bonus_display); let void_deref = if input.variants.is_empty() { Some(quote!(*)) } else { @@ -382,7 +408,7 @@ fn impl_enum(input: Enum) -> TokenStream { Member::Unnamed(index) => format_ident!("_{}", index), }; display_implied_bounds.insert((0, Trait::Display)); - quote!(std::fmt::Display::fmt(#only_field, __formatter)) + quote!(::core::fmt::Display::fmt(#only_field, __formatter)) } }; for (field, bound) in display_implied_bounds { @@ -401,8 +427,8 @@ fn impl_enum(input: Enum) -> TokenStream { let display_where_clause = display_inferred_bounds.augment_where_clause(input.generics); Some(quote! { #[allow(unused_qualifications)] - impl #impl_generics std::fmt::Display for #ty #ty_generics #display_where_clause { - fn fmt(&self, __formatter: &mut std::fmt::Formatter) -> std::fmt::Result { + impl #impl_generics ::core::fmt::Display for #ty #ty_generics #display_where_clause { + fn fmt(&self, __formatter: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { #use_as_display #[allow(unused_variables, deprecated, clippy::used_underscore_binding)] match #void_deref self { @@ -423,7 +449,7 @@ fn impl_enum(input: Enum) -> TokenStream { let body = from_initializer(from_field, backtrace_field); Some(quote! { #[allow(unused_qualifications)] - impl #impl_generics std::convert::From<#from> for #ty #ty_generics #where_clause { + impl #impl_generics ::core::convert::From<#from> for #ty #ty_generics #where_clause { #[allow(deprecated)] fn from(source: #from) -> Self { #ty::#variant #body @@ -432,7 +458,6 @@ fn impl_enum(input: Enum) -> TokenStream { }) }); - let error_trait = spanned_error_trait(input.original); if input.generics.type_params().next().is_some() { let self_token = ::default(); error_inferred_bounds.insert(self_token, Trait::Debug); @@ -442,7 +467,7 @@ fn impl_enum(input: Enum) -> TokenStream { quote! { #[allow(unused_qualifications)] - impl #impl_generics #error_trait for #ty #ty_generics #error_where_clause { + impl #impl_generics std::error::Error for #ty #ty_generics #error_where_clause { #source_method #provide_method } @@ -466,10 +491,20 @@ fn fields_pat(fields: &[Field]) -> TokenStream { } } +fn use_as_display(needs_as_display: bool) -> Option { + if needs_as_display { + Some(quote! { + use thiserror::__private::AsDisplay as _; + }) + } else { + None + } +} + fn from_initializer(from_field: &Field, backtrace_field: Option<&Field>) -> TokenStream { let from_member = &from_field.member; let some_source = if type_is_option(from_field.ty) { - quote!(std::option::Option::Some(source)) + quote!(::core::option::Option::Some(source)) } else { quote!(source) }; @@ -477,11 +512,11 @@ fn from_initializer(from_field: &Field, backtrace_field: Option<&Field>) -> Toke let backtrace_member = &backtrace_field.member; if type_is_option(backtrace_field.ty) { quote! { - #backtrace_member: std::option::Option::Some(std::backtrace::Backtrace::capture()), + #backtrace_member: ::core::option::Option::Some(std::backtrace::Backtrace::capture()), } } else { quote! { - #backtrace_member: std::convert::From::from(std::backtrace::Backtrace::capture()), + #backtrace_member: ::core::convert::From::from(std::backtrace::Backtrace::capture()), } } }); @@ -525,21 +560,3 @@ fn type_parameter_of_option(ty: &Type) -> Option<&Type> { _ => None, } } - -fn spanned_error_trait(input: &DeriveInput) -> TokenStream { - let vis_span = match &input.vis { - Visibility::Public(vis) => Some(vis.span), - Visibility::Restricted(vis) => Some(vis.pub_token.span), - Visibility::Inherited => None, - }; - let data_span = match &input.data { - Data::Struct(data) => data.struct_token.span, - Data::Enum(data) => data.enum_token.span, - Data::Union(data) => data.union_token.span, - }; - let first_span = vis_span.unwrap_or(data_span); - let last_span = input.ident.span(); - let path = quote_spanned!(first_span=> std::error::); - let error = quote_spanned!(last_span=> Error); - quote!(#path #error) -} diff --git a/third_party/rust/thiserror-impl/src/lib.rs b/third_party/rust/thiserror-impl/src/lib.rs index f0fc969170652..58f4bb5b5ddec 100644 --- a/third_party/rust/thiserror-impl/src/lib.rs +++ b/third_party/rust/thiserror-impl/src/lib.rs @@ -1,14 +1,16 @@ #![allow( - clippy::blocks_in_if_conditions, + clippy::blocks_in_conditions, clippy::cast_lossless, clippy::cast_possible_truncation, clippy::manual_find, + clippy::manual_let_else, clippy::manual_map, clippy::map_unwrap_or, + clippy::module_name_repetitions, clippy::needless_pass_by_value, - clippy::option_if_let_else, clippy::range_plus_one, clippy::single_match_else, + clippy::struct_field_names, clippy::too_many_lines, clippy::wrong_self_convention )] @@ -21,6 +23,7 @@ mod expand; mod fmt; mod generics; mod prop; +mod span; mod valid; use proc_macro::TokenStream; @@ -29,7 +32,5 @@ use syn::{parse_macro_input, DeriveInput}; #[proc_macro_derive(Error, attributes(backtrace, error, from, source))] pub fn derive_error(input: TokenStream) -> TokenStream { let input = parse_macro_input!(input as DeriveInput); - expand::derive(&input) - .unwrap_or_else(|err| err.to_compile_error()) - .into() + expand::derive(&input).into() } diff --git a/third_party/rust/thiserror-impl/src/prop.rs b/third_party/rust/thiserror-impl/src/prop.rs index 6d8a924c1172d..2867cd312ab3a 100644 --- a/third_party/rust/thiserror-impl/src/prop.rs +++ b/third_party/rust/thiserror-impl/src/prop.rs @@ -1,4 +1,6 @@ use crate::ast::{Enum, Field, Struct, Variant}; +use crate::span::MemberSpan; +use proc_macro2::Span; use syn::{Member, Type}; impl Struct<'_> { @@ -70,6 +72,16 @@ impl Field<'_> { pub(crate) fn is_backtrace(&self) -> bool { type_is_backtrace(self.ty) } + + pub(crate) fn source_span(&self) -> Span { + if let Some(source_attr) = &self.attrs.source { + source_attr.path().get_ident().unwrap().span() + } else if let Some(from_attr) = &self.attrs.from { + from_attr.path().get_ident().unwrap().span() + } else { + self.member.member_span() + } + } } fn from_field<'a, 'b>(fields: &'a [Field<'b>]) -> Option<&'a Field<'b>> { diff --git a/third_party/rust/thiserror-impl/src/span.rs b/third_party/rust/thiserror-impl/src/span.rs new file mode 100644 index 0000000000000..c1237ddfc52de --- /dev/null +++ b/third_party/rust/thiserror-impl/src/span.rs @@ -0,0 +1,15 @@ +use proc_macro2::Span; +use syn::Member; + +pub trait MemberSpan { + fn member_span(&self) -> Span; +} + +impl MemberSpan for Member { + fn member_span(&self) -> Span { + match self { + Member::Named(ident) => ident.span(), + Member::Unnamed(index) => index.span, + } + } +} diff --git a/third_party/rust/thiserror/.cargo-checksum.json b/third_party/rust/thiserror/.cargo-checksum.json index ad4300a7e15dd..cee7027f7416f 100644 --- a/third_party/rust/thiserror/.cargo-checksum.json +++ b/third_party/rust/thiserror/.cargo-checksum.json @@ -1 +1 @@ -{"files":{"Cargo.toml":"3a25d0550abd84a575c7a90e15509bcdde1c546780707a8633b963378e33c8f8","LICENSE-APACHE":"62c7a1e35f56406896d7aa7ca52d0cc0d272ac022b5d2796e7d6905db8a3636a","LICENSE-MIT":"23f18e03dc49df91622fe2a76176497404e46ced8a715d9d2b67a7446571cca3","README.md":"106c5a937767d49503e1fc5eae1b924f57f15decd8583720a3c652483e348a64","build.rs":"8b8d9cbf84b9a2fd108b49ecb4bae327da688d80b818acda9ee17170c788e193","rust-toolchain.toml":"6bbb61302978c736b2da03e4fb40e3beab908f85d533ab46fd541e637b5f3e0f","src/aserror.rs":"c93bd9191f26a7599043b397e26822564d9bafaa339a19861182a9909e8a3811","src/display.rs":"63c492bfa8b8e9180ad5abcbe63c1173b4ad490c47ec33cac9a338f96c8f8e42","src/lib.rs":"fbdfd87ec64d9dd66a288aaab5e58c29c2c69a79f2e2943b1a7522b5d17d93f4","src/provide.rs":"b2f7a33f44f44a03e94f54cc4b79ba2dcc5fcf0fdf64b07cdd9588a6544c8d8e","tests/compiletest.rs":"022a8e400ef813d7ea1875b944549cee5125f6a995dc33e93b48cba3e1b57bd1","tests/test_backtrace.rs":"fd1f326bc23e6c1611a51bc43c1d5092b32ee18a1613abe20da0818e5729c0ed","tests/test_deprecated.rs":"7b80a10f090a3982da017556d3d71398abcead59afd8278c7b9d9b1f7b66c7b3","tests/test_display.rs":"f7d023365adbd47a24cb62cea02905503fd54705cbfdffdfdb3412dc210737a9","tests/test_error.rs":"d06dca3c38f22d7ce4e27dadd6c0f78e5cefe3a2ebbc5fe44abc9ddd5ee1985f","tests/test_expr.rs":"388402702a3be4ffcd0574d66733e8932bf7d5de37544a00ecb0e4f8d8246da4","tests/test_from.rs":"36bd22be7b048cd187a19076aeac1456040f20a0b677b01c6003998b63439ea1","tests/test_generics.rs":"4f33747e3f62550d5af94687679af230ef92fbb3247ae4b41df46792a040e4dc","tests/test_lints.rs":"c17d79d77edfcdd4b8f6dcdcd1c70ad065cfbc747e1a618ac6343315d0b59ea4","tests/test_option.rs":"3a82af1ad206444b9955e3f2fda508d70f887ad0b7f7986bafc17496f63b07ab","tests/test_path.rs":"ef5452c7e828a0179f5ace7e19f95b9762aa887caf10244adbfe36ded712c090","tests/test_source.rs":"f2f04f11bf8a709eddb1c68f113cda0c2be87e56800d6b9d991bedd545b4642f","tests/test_transparent.rs":"cd8d5be14d00d610a1782104bea6c013618501dab5c3625178ecfcf66e31f939","tests/ui/bad-field-attr.rs":"c5b567e3091969a01061843fb2d95c5e1aa3fa81edfeecdf416a84a6fba40aa8","tests/ui/bad-field-attr.stderr":"78f576d5ec66464a77f1cdf0f5bb7dcdf18f7f04f1165983a6239ec59d908ea3","tests/ui/concat-display.rs":"3995bd6b3bdd67df7bb16499775d89600c0dd20895633fe807396a64c117078d","tests/ui/concat-display.stderr":"256dfde61ee689ebe51588b135e2e030bdf95ba5adef1cb59f588c797bbdeef2","tests/ui/duplicate-enum-source.rs":"bfe28ce18042d446a76c7411aa233598211ce1157fdd3cb87bff3b3fa7c33131","tests/ui/duplicate-enum-source.stderr":"3d32fead420b27b4497be49080bc3b78f7f0ba339ead3de6c94e5dc20302c18f","tests/ui/duplicate-fmt.rs":"af53b66445bcce076a114376747f176b42c060a156563a41ccb638ae14c451fd","tests/ui/duplicate-fmt.stderr":"998bb121ce6f1595fd99529a7a1b06451b6bf476924337dce5524a83a7a5f1a1","tests/ui/duplicate-struct-source.rs":"f3d5f8e3d6fccfcdbb630db291353709583a920c6bf46f9f9de9966b67ea4c0f","tests/ui/duplicate-struct-source.stderr":"fb761d76668ac42357cf37b03c0abdbae5de0a828034990850291c9cb6ab766d","tests/ui/duplicate-transparent.rs":"41a9447e85f1a47027023442acde55c3d8610ec46d91b39bd43a42d7a004d747","tests/ui/duplicate-transparent.stderr":"4975abad43e973df158f18098d9bcb9dc39f8e75d3e733ed5d6620d1ee065c11","tests/ui/from-backtrace-backtrace.rs":"1fd51c5a1f7f6b6ee676d9fc798b6276ef2ce75def33d07f0e4b7bbde3291859","tests/ui/from-backtrace-backtrace.stderr":"f9774e9dad51374501ef4a55fa2dacece4d1c70e29ca18761394bdb80a9a74da","tests/ui/from-not-source.rs":"744a55aeffe11066830159ac023c33aaa5576e313b341fa24440ee13dfe3ac98","tests/ui/from-not-source.stderr":"525038e8b841707b927434cca4549168f73bd305faca17552a0d1fffa542ccc4","tests/ui/lifetime.rs":"e72e0391695e47fcd07edbf3819f114e468e2097086ec687781c7c8d6b4b7da7","tests/ui/lifetime.stderr":"d889a23f71324afe95dafc5f9d15337fbdbc9977cb8924f0cafe3a3becf4ced7","tests/ui/missing-fmt.rs":"bc9e2830e54c2474ff6c27a766ed3dee88d29e40f93f30e8d64d63233866c17d","tests/ui/missing-fmt.stderr":"9a20ccee9b660fe31a5b3199307b48580bb8305cb9ce33d97d3fc767a0cfc614","tests/ui/no-display.rs":"962245372272d23e9833311c15e73221b3c7da822a2ff90189613af56ffb5c2e","tests/ui/no-display.stderr":"d7bdecccb74d21677361fb7f89dc784dc859258afcf663fa1c48da6c172a61aa","tests/ui/source-enum-not-error.rs":"7c57c63b3ec37bc456738acea2e1038de5b0f32fe7e83984037d7ad1ed921737","tests/ui/source-enum-not-error.stderr":"feac587e2436fd7bed73e7265dceb31b495587f1a8eea5c5fefd9da66b912dac","tests/ui/source-struct-not-error.rs":"09fb7713637242dca9192585a6daeb8d732dc1c1d0fa522b74f1c98618e6d949","tests/ui/source-struct-not-error.stderr":"66fb5fa85d59f11d8b5f7ec99469a843c51943b0010e554bdf56376a0614a2ca","tests/ui/transparent-display.rs":"b3c59583eb64b0b5a246444456d03cf52d51bcdc08885023600dbb44fd87e5f2","tests/ui/transparent-display.stderr":"16d538914e0d92026bde4b4bec75660217da9ecc6b621d12d2eb81d33ed1d1da","tests/ui/transparent-enum-many.rs":"2a40a764fb4683bff57973eec61507a6c00f7d4d7a32da6e7bd0190c2e445434","tests/ui/transparent-enum-many.stderr":"f1d78c1d6d8edbef153420db4fb9ca3dc6076fa043b5b1bc0cd291daa417a3ea","tests/ui/transparent-enum-source.rs":"18f606a98ac0a53f08dc56f5f923b9cbe75d25ed34479c777b48dac305d5968c","tests/ui/transparent-enum-source.stderr":"1b2e0ac53951034575d43ec0396c4e2b3cfb272db2aef8d6baa13a7e1632cc84","tests/ui/transparent-struct-many.rs":"72c6b6c1a44c203d3bc68989b2f1ec092531ef75b745432824c3776c290326f6","tests/ui/transparent-struct-many.stderr":"7bd0536dbb54a0ce7d4a8e66ca7624a1b132d8a1d1e4fecca642ec77494ac01c","tests/ui/transparent-struct-source.rs":"863fa691ed7d27e8767da58d9ee11fd40d6642274b36338ca1074c07964ea2b3","tests/ui/transparent-struct-source.stderr":"267dab65929e67d32347fb467a00b43af931f8205d727d7671938580217fc70e","tests/ui/unexpected-field-fmt.rs":"29fba7b4d81c642ec8e47cfe053aa515acf9080a86d65e685363a48993becfe3","tests/ui/unexpected-field-fmt.stderr":"20731c4a08af04bed3ff513903adadd690b6bc532b15604557e7f25575a8338f","tests/ui/unexpected-struct-source.rs":"c6cbe882d622635c216feb8290b1bd536ce0ec4feee16bc087667a21b3641d5c","tests/ui/unexpected-struct-source.stderr":"7c8227513478f6cc09e8a28be337c8a0e758a06ca5978d774c91bd43c4a54043","tests/ui/union.rs":"331adff27cebd8b95b03b6742cc8247331fda1f961e1590ed39c8d39f50cf1d8","tests/ui/union.stderr":"5f67ad29753d6fb14bc03aef7d4a1f660ee7796e469c037efbf8b13456934ad3"},"package":"978c9a314bd8dc99be594bc3c175faaa9794be04a5a5e153caba6915336cebac"} \ No newline at end of file +{"files":{"Cargo.toml":"d78abe9a046d804b1c51260cefe516c36dfbb9994edfe47175bbd838cd46f68f","LICENSE-APACHE":"62c7a1e35f56406896d7aa7ca52d0cc0d272ac022b5d2796e7d6905db8a3636a","LICENSE-MIT":"23f18e03dc49df91622fe2a76176497404e46ced8a715d9d2b67a7446571cca3","README.md":"106c5a937767d49503e1fc5eae1b924f57f15decd8583720a3c652483e348a64","build.rs":"532f6ac494cdddfad3267067a46969a8052b02c1bd94567361f7103ab0dc8c28","build/probe.rs":"3245569a228727091f335db44c7c2f729729b2dfac9f46c1143eb179439f223d","rust-toolchain.toml":"6bbb61302978c736b2da03e4fb40e3beab908f85d533ab46fd541e637b5f3e0f","src/aserror.rs":"cf3c98abb2b9e06afa3c4aba0df14938417c3e330315863437561cbb3573888b","src/display.rs":"0adeeeb524c6bee06de179d54e82a43dc12d2c5b7f69f6fd268ba4611ebf5233","src/lib.rs":"074676e9bbe9402ebe3f41dedcaa289774e47e075d10e2f523d2dcbd8f648f79","src/provide.rs":"8007e22953bacfcc57bb7d12a03fbeb0acece5d2ec889cf55522a4e071d26df3","tests/compiletest.rs":"022a8e400ef813d7ea1875b944549cee5125f6a995dc33e93b48cba3e1b57bd1","tests/test_backtrace.rs":"a8f038490fb881463c0e8c36557617c47cf2d181f16c00525d4d139c7964fade","tests/test_deprecated.rs":"7b80a10f090a3982da017556d3d71398abcead59afd8278c7b9d9b1f7b66c7b3","tests/test_display.rs":"28e0f938fe0f6354529c35722eff04830451e27718145c27522c9acf7f8a6639","tests/test_error.rs":"d06dca3c38f22d7ce4e27dadd6c0f78e5cefe3a2ebbc5fe44abc9ddd5ee1985f","tests/test_expr.rs":"d35b11040ebc547467f52571051854e3e094d52b8e229fa3d44700d5f40959a2","tests/test_from.rs":"36bd22be7b048cd187a19076aeac1456040f20a0b677b01c6003998b63439ea1","tests/test_generics.rs":"adc61f0d5fe8d53796848d44fb0373be5eab19a1eeb6a7172bc6f0dd7b91199c","tests/test_lints.rs":"c17d79d77edfcdd4b8f6dcdcd1c70ad065cfbc747e1a618ac6343315d0b59ea4","tests/test_option.rs":"ac30d929c019d6c54d1c1792b09e43c18dc0e4123b82051ff9e5db5e63c15e43","tests/test_path.rs":"ef5452c7e828a0179f5ace7e19f95b9762aa887caf10244adbfe36ded712c090","tests/test_source.rs":"f2f04f11bf8a709eddb1c68f113cda0c2be87e56800d6b9d991bedd545b4642f","tests/test_transparent.rs":"cd8d5be14d00d610a1782104bea6c013618501dab5c3625178ecfcf66e31f939","tests/ui/bad-field-attr.rs":"c5b567e3091969a01061843fb2d95c5e1aa3fa81edfeecdf416a84a6fba40aa8","tests/ui/bad-field-attr.stderr":"78f576d5ec66464a77f1cdf0f5bb7dcdf18f7f04f1165983a6239ec59d908ea3","tests/ui/concat-display.rs":"3995bd6b3bdd67df7bb16499775d89600c0dd20895633fe807396a64c117078d","tests/ui/concat-display.stderr":"256dfde61ee689ebe51588b135e2e030bdf95ba5adef1cb59f588c797bbdeef2","tests/ui/duplicate-enum-source.rs":"bfe28ce18042d446a76c7411aa233598211ce1157fdd3cb87bff3b3fa7c33131","tests/ui/duplicate-enum-source.stderr":"3d32fead420b27b4497be49080bc3b78f7f0ba339ead3de6c94e5dc20302c18f","tests/ui/duplicate-fmt.rs":"af53b66445bcce076a114376747f176b42c060a156563a41ccb638ae14c451fd","tests/ui/duplicate-fmt.stderr":"998bb121ce6f1595fd99529a7a1b06451b6bf476924337dce5524a83a7a5f1a1","tests/ui/duplicate-struct-source.rs":"f3d5f8e3d6fccfcdbb630db291353709583a920c6bf46f9f9de9966b67ea4c0f","tests/ui/duplicate-struct-source.stderr":"fb761d76668ac42357cf37b03c0abdbae5de0a828034990850291c9cb6ab766d","tests/ui/duplicate-transparent.rs":"41a9447e85f1a47027023442acde55c3d8610ec46d91b39bd43a42d7a004d747","tests/ui/duplicate-transparent.stderr":"4975abad43e973df158f18098d9bcb9dc39f8e75d3e733ed5d6620d1ee065c11","tests/ui/fallback-impl-with-display.rs":"141a8efbabe3fdac584bec8a61e6cceb58a34a70b825f6277037bf9d591150eb","tests/ui/fallback-impl-with-display.stderr":"1b3dad712b97598fbee70125471de1a8106eb161d42ce1f790ae07be8c8984ba","tests/ui/from-backtrace-backtrace.rs":"0caac64486c0eb9c076553c0502d468fbc477602a9a2595165a1dcd95524e5ff","tests/ui/from-backtrace-backtrace.stderr":"e24156ae0828878f3282341732b6e032eaa8cb4b4db366a6b5437ed0731d40a7","tests/ui/from-not-source.rs":"744a55aeffe11066830159ac023c33aaa5576e313b341fa24440ee13dfe3ac98","tests/ui/from-not-source.stderr":"525038e8b841707b927434cca4549168f73bd305faca17552a0d1fffa542ccc4","tests/ui/invalid-input-impl-anyway.rs":"6de91f71ddf038dffa3b9da33763a2ec3a5aa0047528e19ba998d5efe3aada5b","tests/ui/invalid-input-impl-anyway.stderr":"fa2725053cd87fc37f87546b377e6e5eed95c45e2a960863303b21a1935fdddb","tests/ui/lifetime.rs":"e72e0391695e47fcd07edbf3819f114e468e2097086ec687781c7c8d6b4b7da7","tests/ui/lifetime.stderr":"d889a23f71324afe95dafc5f9d15337fbdbc9977cb8924f0cafe3a3becf4ced7","tests/ui/missing-display.rs":"c1fd1bc0ec0fb103d7f7b128837f717d49485662839899d570b3c983f1332888","tests/ui/missing-display.stderr":"a8de0f1559da9320ee99ef334937d532d9e9f40a32ed7f8ce56fb465628bff96","tests/ui/missing-fmt.rs":"bc9e2830e54c2474ff6c27a766ed3dee88d29e40f93f30e8d64d63233866c17d","tests/ui/missing-fmt.stderr":"9a20ccee9b660fe31a5b3199307b48580bb8305cb9ce33d97d3fc767a0cfc614","tests/ui/no-display.rs":"962245372272d23e9833311c15e73221b3c7da822a2ff90189613af56ffb5c2e","tests/ui/no-display.stderr":"9e2161baf5f66ab22370322f2e66e7633bf04b1ec07ef656e904b984bcc45d09","tests/ui/source-enum-not-error.rs":"3add5e7b4503d964bcae0848904822e1473c1d08c5a146c2df5347314ce1b8df","tests/ui/source-enum-not-error.stderr":"c093580558a259489eef92728d19aeca3b6c27ec17c39a02a75f0a924b095675","tests/ui/source-enum-unnamed-field-not-error.rs":"a98989e908b84a8e6e6dceef02af7bdd1098a444d229950f67ed4f54d55c62e7","tests/ui/source-enum-unnamed-field-not-error.stderr":"45b520f44e6fd10792d7f48e8ca7bc89850aa039278cba7c9f6ea11aa6378494","tests/ui/source-struct-not-error.rs":"09fb7713637242dca9192585a6daeb8d732dc1c1d0fa522b74f1c98618e6d949","tests/ui/source-struct-not-error.stderr":"66fb5fa85d59f11d8b5f7ec99469a843c51943b0010e554bdf56376a0614a2ca","tests/ui/source-struct-unnamed-field-not-error.rs":"eee605a9aafbb093666393e25cef4f7d7b8e90d518b9fadbdbed9685c66ccfcd","tests/ui/source-struct-unnamed-field-not-error.stderr":"38e4bd380ff1637c179b277ea1beb0a1ce688d191e5a9502ee69ab752e9ba70f","tests/ui/transparent-display.rs":"b3c59583eb64b0b5a246444456d03cf52d51bcdc08885023600dbb44fd87e5f2","tests/ui/transparent-display.stderr":"16d538914e0d92026bde4b4bec75660217da9ecc6b621d12d2eb81d33ed1d1da","tests/ui/transparent-enum-many.rs":"2a40a764fb4683bff57973eec61507a6c00f7d4d7a32da6e7bd0190c2e445434","tests/ui/transparent-enum-many.stderr":"f1d78c1d6d8edbef153420db4fb9ca3dc6076fa043b5b1bc0cd291daa417a3ea","tests/ui/transparent-enum-not-error.rs":"f6315993e68bc71d6d4d39afa4d059695308ef785f92cc0d1df3e9ff55be2a9a","tests/ui/transparent-enum-not-error.stderr":"e485c39f861ab66a6a41f0a423b1b13ba277968210284148883b350b5d629ccc","tests/ui/transparent-enum-source.rs":"18f606a98ac0a53f08dc56f5f923b9cbe75d25ed34479c777b48dac305d5968c","tests/ui/transparent-enum-source.stderr":"1b2e0ac53951034575d43ec0396c4e2b3cfb272db2aef8d6baa13a7e1632cc84","tests/ui/transparent-enum-unnamed-field-not-error.rs":"0c720567e9e0f87921055dfa9f607661725377633445e01a4b5048c7a7a50a85","tests/ui/transparent-enum-unnamed-field-not-error.stderr":"6b8ba244eba94006039d10f35bdd7526136bcff4751b13313ab12283d5bdc24c","tests/ui/transparent-struct-many.rs":"72c6b6c1a44c203d3bc68989b2f1ec092531ef75b745432824c3776c290326f6","tests/ui/transparent-struct-many.stderr":"7bd0536dbb54a0ce7d4a8e66ca7624a1b132d8a1d1e4fecca642ec77494ac01c","tests/ui/transparent-struct-not-error.rs":"fd814d3141c9182b1267b558d9daef8dd6e8b6462e1ad42b197f3a1c0703dce2","tests/ui/transparent-struct-not-error.stderr":"bb8b856515b34711c046f195b4267d2bb21309c5d3ac0a39d6660c55dadafb41","tests/ui/transparent-struct-source.rs":"863fa691ed7d27e8767da58d9ee11fd40d6642274b36338ca1074c07964ea2b3","tests/ui/transparent-struct-source.stderr":"267dab65929e67d32347fb467a00b43af931f8205d727d7671938580217fc70e","tests/ui/transparent-struct-unnamed-field-not-error.rs":"fbff5874be44a5dcc347693d7929537256b187dfec467ed72c9968c095228d8d","tests/ui/transparent-struct-unnamed-field-not-error.stderr":"684d4ed4325f2e7fb95c84a6d231585b2be313990c41222fda66b99a84e7b884","tests/ui/unexpected-field-fmt.rs":"29fba7b4d81c642ec8e47cfe053aa515acf9080a86d65e685363a48993becfe3","tests/ui/unexpected-field-fmt.stderr":"20731c4a08af04bed3ff513903adadd690b6bc532b15604557e7f25575a8338f","tests/ui/unexpected-struct-source.rs":"c6cbe882d622635c216feb8290b1bd536ce0ec4feee16bc087667a21b3641d5c","tests/ui/unexpected-struct-source.stderr":"7c8227513478f6cc09e8a28be337c8a0e758a06ca5978d774c91bd43c4a54043","tests/ui/union.rs":"331adff27cebd8b95b03b6742cc8247331fda1f961e1590ed39c8d39f50cf1d8","tests/ui/union.stderr":"5f67ad29753d6fb14bc03aef7d4a1f660ee7796e469c037efbf8b13456934ad3"},"package":"d54378c645627613241d077a3a79db965db602882668f9136ac42af9ecb730ad"} \ No newline at end of file diff --git a/third_party/rust/thiserror/Cargo.toml b/third_party/rust/thiserror/Cargo.toml index 4d3905b713a2c..7871761242057 100644 --- a/third_party/rust/thiserror/Cargo.toml +++ b/third_party/rust/thiserror/Cargo.toml @@ -10,10 +10,10 @@ # See Cargo.toml.orig for the original contents. [package] -edition = "2018" +edition = "2021" rust-version = "1.56" name = "thiserror" -version = "1.0.40" +version = "1.0.56" authors = ["David Tolnay "] description = "derive(Error)" documentation = "https://docs.rs/thiserror" @@ -28,20 +28,21 @@ license = "MIT OR Apache-2.0" repository = "https://github.com/dtolnay/thiserror" [package.metadata.docs.rs] +rustdoc-args = ["--generate-link-to-definition"] targets = ["x86_64-unknown-linux-gnu"] [dependencies.thiserror-impl] -version = "=1.0.40" +version = "=1.0.56" [dev-dependencies.anyhow] -version = "1.0.65" +version = "1.0.73" [dev-dependencies.ref-cast] -version = "1.0" +version = "1.0.18" [dev-dependencies.rustversion] -version = "1.0" +version = "1.0.13" [dev-dependencies.trybuild] -version = "1.0.66" +version = "1.0.81" features = ["diff"] diff --git a/third_party/rust/thiserror/build.rs b/third_party/rust/thiserror/build.rs index 004dfb0159743..0b995d8ea0882 100644 --- a/third_party/rust/thiserror/build.rs +++ b/third_party/rust/thiserror/build.rs @@ -1,34 +1,70 @@ use std::env; -use std::fs; +use std::ffi::OsString; use std::path::Path; -use std::process::{Command, ExitStatus, Stdio}; -use std::str; +use std::process::{self, Command, Stdio}; -// This code exercises the surface area that we expect of the Provider API. If -// the current toolchain is able to compile it, then thiserror is able to use -// providers for backtrace support. -const PROBE: &str = r#" - #![feature(provide_any)] +fn main() { + println!("cargo:rerun-if-changed=build/probe.rs"); - use std::any::{Demand, Provider}; + let error_generic_member_access; + let consider_rustc_bootstrap; + if compile_probe(false) { + // This is a nightly or dev compiler, so it supports unstable features + // regardless of RUSTC_BOOTSTRAP. No need to rerun build script if + // RUSTC_BOOTSTRAP is changed. + error_generic_member_access = true; + consider_rustc_bootstrap = false; + } else if let Some(rustc_bootstrap) = env::var_os("RUSTC_BOOTSTRAP") { + if compile_probe(true) { + // This is a stable or beta compiler for which the user has set + // RUSTC_BOOTSTRAP to turn on unstable features. Rerun build script + // if they change it. + error_generic_member_access = true; + consider_rustc_bootstrap = true; + } else if rustc_bootstrap == "1" { + // This compiler does not support the generic member access API in + // the form that thiserror expects. No need to pay attention to + // RUSTC_BOOTSTRAP. + error_generic_member_access = false; + consider_rustc_bootstrap = false; + } else { + // This is a stable or beta compiler for which RUSTC_BOOTSTRAP is + // set to restrict the use of unstable features by this crate. + error_generic_member_access = false; + consider_rustc_bootstrap = true; + } + } else { + // Without RUSTC_BOOTSTRAP, this compiler does not support the generic + // member access API in the form that thiserror expects, but try again + // if the user turns on unstable features. + error_generic_member_access = false; + consider_rustc_bootstrap = true; + } - fn _f<'a, P: Provider>(p: &'a P, demand: &mut Demand<'a>) { - p.provide(demand); + if error_generic_member_access { + println!("cargo:rustc-cfg=error_generic_member_access"); } -"#; -fn main() { - match compile_probe() { - Some(status) if status.success() => println!("cargo:rustc-cfg=provide_any"), - _ => {} + if consider_rustc_bootstrap { + println!("cargo:rerun-if-env-changed=RUSTC_BOOTSTRAP"); } } -fn compile_probe() -> Option { - let rustc = env::var_os("RUSTC")?; - let out_dir = env::var_os("OUT_DIR")?; - let probefile = Path::new(&out_dir).join("probe.rs"); - fs::write(&probefile, PROBE).ok()?; +fn compile_probe(rustc_bootstrap: bool) -> bool { + if env::var_os("RUSTC_STAGE").is_some() { + // We are running inside rustc bootstrap. This is a highly non-standard + // environment with issues such as: + // + // https://github.com/rust-lang/cargo/issues/11138 + // https://github.com/rust-lang/rust/issues/114839 + // + // Let's just not use nightly features here. + return false; + } + + let rustc = cargo_env_var("RUSTC"); + let out_dir = cargo_env_var("OUT_DIR"); + let probefile = Path::new("build").join("probe.rs"); // Make sure to pick up Cargo rustc configuration. let mut cmd = if let Some(wrapper) = env::var_os("RUSTC_WRAPPER") { @@ -40,11 +76,15 @@ fn compile_probe() -> Option { Command::new(rustc) }; + if !rustc_bootstrap { + cmd.env_remove("RUSTC_BOOTSTRAP"); + } + cmd.stderr(Stdio::null()) .arg("--edition=2018") - .arg("--crate-name=thiserror_build") + .arg("--crate-name=thiserror") .arg("--crate-type=lib") - .arg("--emit=metadata") + .arg("--emit=dep-info,metadata") .arg("--out-dir") .arg(out_dir) .arg(probefile); @@ -62,5 +102,18 @@ fn compile_probe() -> Option { } } - cmd.status().ok() + match cmd.status() { + Ok(status) => status.success(), + Err(_) => false, + } +} + +fn cargo_env_var(key: &str) -> OsString { + env::var_os(key).unwrap_or_else(|| { + eprintln!( + "Environment variable ${} is not set during execution of build script", + key, + ); + process::exit(1); + }) } diff --git a/third_party/rust/thiserror/build/probe.rs b/third_party/rust/thiserror/build/probe.rs new file mode 100644 index 0000000000000..0dce6f5b3aaaa --- /dev/null +++ b/third_party/rust/thiserror/build/probe.rs @@ -0,0 +1,32 @@ +// This code exercises the surface area that we expect of the Error generic +// member access API. If the current toolchain is able to compile it, then +// thiserror is able to provide backtrace support. + +#![feature(error_generic_member_access)] + +use std::error::{Error, Request}; +use std::fmt::{self, Debug, Display}; + +struct MyError(Thing); +struct Thing; + +impl Debug for MyError { + fn fmt(&self, _formatter: &mut fmt::Formatter) -> fmt::Result { + unimplemented!() + } +} + +impl Display for MyError { + fn fmt(&self, _formatter: &mut fmt::Formatter) -> fmt::Result { + unimplemented!() + } +} + +impl Error for MyError { + fn provide<'a>(&'a self, request: &mut Request<'a>) { + request.provide_ref(&self.0); + } +} + +// Include in sccache cache key. +const _: Option<&str> = option_env!("RUSTC_BOOTSTRAP"); diff --git a/third_party/rust/thiserror/src/aserror.rs b/third_party/rust/thiserror/src/aserror.rs index 5fea84ef885dd..54fc6f119fbd3 100644 --- a/third_party/rust/thiserror/src/aserror.rs +++ b/third_party/rust/thiserror/src/aserror.rs @@ -1,6 +1,7 @@ use std::error::Error; use std::panic::UnwindSafe; +#[doc(hidden)] pub trait AsDynError<'a>: Sealed { fn as_dyn_error(&self) -> &(dyn Error + 'a); } @@ -40,6 +41,7 @@ impl<'a> AsDynError<'a> for dyn Error + Send + Sync + UnwindSafe + 'a { } } +#[doc(hidden)] pub trait Sealed {} impl<'a, T: Error + 'a> Sealed for T {} impl<'a> Sealed for dyn Error + 'a {} diff --git a/third_party/rust/thiserror/src/display.rs b/third_party/rust/thiserror/src/display.rs index 0eb0dd9e201c6..27098f167aa02 100644 --- a/third_party/rust/thiserror/src/display.rs +++ b/third_party/rust/thiserror/src/display.rs @@ -1,28 +1,40 @@ use std::fmt::Display; use std::path::{self, Path, PathBuf}; -pub trait DisplayAsDisplay { - fn as_display(&self) -> Self; +#[doc(hidden)] +pub trait AsDisplay<'a> { + // TODO: convert to generic associated type. + // https://github.com/dtolnay/thiserror/pull/253 + type Target: Display; + + fn as_display(&'a self) -> Self::Target; } -impl DisplayAsDisplay for &T { - fn as_display(&self) -> Self { - self +impl<'a, T> AsDisplay<'a> for &T +where + T: Display + 'a, +{ + type Target = &'a T; + + fn as_display(&'a self) -> Self::Target { + *self } } -pub trait PathAsDisplay { - fn as_display(&self) -> path::Display<'_>; -} +impl<'a> AsDisplay<'a> for Path { + type Target = path::Display<'a>; -impl PathAsDisplay for Path { - fn as_display(&self) -> path::Display<'_> { + #[inline] + fn as_display(&'a self) -> Self::Target { self.display() } } -impl PathAsDisplay for PathBuf { - fn as_display(&self) -> path::Display<'_> { +impl<'a> AsDisplay<'a> for PathBuf { + type Target = path::Display<'a>; + + #[inline] + fn as_display(&'a self) -> Self::Target { self.display() } } diff --git a/third_party/rust/thiserror/src/lib.rs b/third_party/rust/thiserror/src/lib.rs index 94bd860942797..73e6e217361ec 100644 --- a/third_party/rust/thiserror/src/lib.rs +++ b/third_party/rust/thiserror/src/lib.rs @@ -228,19 +228,21 @@ //! //! [`anyhow`]: https://github.com/dtolnay/anyhow -#![doc(html_root_url = "https://docs.rs/thiserror/1.0.40")] +#![doc(html_root_url = "https://docs.rs/thiserror/1.0.56")] #![allow( - // Clippy bug: https://github.com/rust-lang/rust-clippy/issues/7421 - clippy::doc_markdown, clippy::module_name_repetitions, + clippy::needless_lifetimes, clippy::return_self_not_must_use, - clippy::wildcard_imports, + clippy::wildcard_imports )] -#![cfg_attr(provide_any, feature(provide_any))] +#![cfg_attr(error_generic_member_access, feature(error_generic_member_access))] + +#[cfg(all(thiserror_nightly_testing, not(error_generic_member_access)))] +compile_error!("Build script probe failed to compile."); mod aserror; mod display; -#[cfg(provide_any)] +#[cfg(error_generic_member_access)] mod provide; pub use thiserror_impl::*; @@ -248,8 +250,11 @@ pub use thiserror_impl::*; // Not public API. #[doc(hidden)] pub mod __private { + #[doc(hidden)] pub use crate::aserror::AsDynError; - pub use crate::display::{DisplayAsDisplay, PathAsDisplay}; - #[cfg(provide_any)] + #[doc(hidden)] + pub use crate::display::AsDisplay; + #[cfg(error_generic_member_access)] + #[doc(hidden)] pub use crate::provide::ThiserrorProvide; } diff --git a/third_party/rust/thiserror/src/provide.rs b/third_party/rust/thiserror/src/provide.rs index 524e7435d784e..7b4e922389bcc 100644 --- a/third_party/rust/thiserror/src/provide.rs +++ b/third_party/rust/thiserror/src/provide.rs @@ -1,15 +1,20 @@ -use std::any::{Demand, Provider}; +use std::error::{Error, Request}; +#[doc(hidden)] pub trait ThiserrorProvide: Sealed { - fn thiserror_provide<'a>(&'a self, demand: &mut Demand<'a>); + fn thiserror_provide<'a>(&'a self, request: &mut Request<'a>); } -impl ThiserrorProvide for T { +impl ThiserrorProvide for T +where + T: Error + ?Sized, +{ #[inline] - fn thiserror_provide<'a>(&'a self, demand: &mut Demand<'a>) { - self.provide(demand); + fn thiserror_provide<'a>(&'a self, request: &mut Request<'a>) { + self.provide(request); } } +#[doc(hidden)] pub trait Sealed {} -impl Sealed for T {} +impl Sealed for T {} diff --git a/third_party/rust/thiserror/tests/test_backtrace.rs b/third_party/rust/thiserror/tests/test_backtrace.rs index 43f68b8b7e54b..4710d45bc976c 100644 --- a/third_party/rust/thiserror/tests/test_backtrace.rs +++ b/third_party/rust/thiserror/tests/test_backtrace.rs @@ -1,7 +1,4 @@ -#![cfg_attr( - thiserror_nightly_testing, - feature(error_generic_member_access, provide_any) -)] +#![cfg_attr(thiserror_nightly_testing, feature(error_generic_member_access))] use thiserror::Error; @@ -19,9 +16,8 @@ pub struct InnerBacktrace { #[cfg(thiserror_nightly_testing)] pub mod structs { use super::{Inner, InnerBacktrace}; - use std::any; use std::backtrace::Backtrace; - use std::error::Error; + use std::error::{self, Error}; use std::sync::Arc; use thiserror::Error; @@ -106,75 +102,56 @@ pub mod structs { let error = PlainBacktrace { backtrace: Backtrace::capture(), }; - assert!(any::request_ref::(&error).is_some()); + assert!(error::request_ref::(&error).is_some()); let error = ExplicitBacktrace { backtrace: Backtrace::capture(), }; - assert!(any::request_ref::(&error).is_some()); + assert!(error::request_ref::(&error).is_some()); let error = OptBacktrace { backtrace: Some(Backtrace::capture()), }; - assert!(any::request_ref::(&error).is_some()); + assert!(error::request_ref::(&error).is_some()); let error = ArcBacktrace { backtrace: Arc::new(Backtrace::capture()), }; - assert!(any::request_ref::(&error).is_some()); + assert!(error::request_ref::(&error).is_some()); let error = BacktraceFrom::from(Inner); - assert!(any::request_ref::(&error).is_some()); + assert!(error::request_ref::(&error).is_some()); let error = CombinedBacktraceFrom::from(InnerBacktrace { backtrace: Backtrace::capture(), }); - assert!(any::request_ref::(&error).is_some()); + assert!(error::request_ref::(&error).is_some()); let error = OptBacktraceFrom::from(Inner); - assert!(any::request_ref::(&error).is_some()); + assert!(error::request_ref::(&error).is_some()); let error = ArcBacktraceFrom::from(Inner); - assert!(any::request_ref::(&error).is_some()); + assert!(error::request_ref::(&error).is_some()); let error = AnyhowBacktrace { source: anyhow::Error::msg("..."), }; - assert!(any::request_ref::(&error).is_some()); + assert!(error::request_ref::(&error).is_some()); let error = BoxDynErrorBacktrace { source: Box::new(PlainBacktrace { backtrace: Backtrace::capture(), }), }; - assert!(any::request_ref::(&error).is_some()); - } - - // https://github.com/dtolnay/thiserror/issues/185 -- std::error::Error and - // std::any::Provide both have a method called 'provide', so directly - // calling it from generated code could be ambiguous. - #[test] - fn test_provide_name_collision() { - use std::any::Provider; - - #[derive(Error, Debug)] - #[error("...")] - struct MyError { - #[source] - #[backtrace] - x: std::io::Error, - } - - let _: dyn Error; - let _: dyn Provider; + assert!(error::request_ref::(&error).is_some()); } } #[cfg(thiserror_nightly_testing)] pub mod enums { use super::{Inner, InnerBacktrace}; - use std::any; use std::backtrace::Backtrace; + use std::error; use std::sync::Arc; use thiserror::Error; @@ -259,36 +236,36 @@ pub mod enums { let error = PlainBacktrace::Test { backtrace: Backtrace::capture(), }; - assert!(any::request_ref::(&error).is_some()); + assert!(error::request_ref::(&error).is_some()); let error = ExplicitBacktrace::Test { backtrace: Backtrace::capture(), }; - assert!(any::request_ref::(&error).is_some()); + assert!(error::request_ref::(&error).is_some()); let error = OptBacktrace::Test { backtrace: Some(Backtrace::capture()), }; - assert!(any::request_ref::(&error).is_some()); + assert!(error::request_ref::(&error).is_some()); let error = ArcBacktrace::Test { backtrace: Arc::new(Backtrace::capture()), }; - assert!(any::request_ref::(&error).is_some()); + assert!(error::request_ref::(&error).is_some()); let error = BacktraceFrom::from(Inner); - assert!(any::request_ref::(&error).is_some()); + assert!(error::request_ref::(&error).is_some()); let error = CombinedBacktraceFrom::from(InnerBacktrace { backtrace: Backtrace::capture(), }); - assert!(any::request_ref::(&error).is_some()); + assert!(error::request_ref::(&error).is_some()); let error = OptBacktraceFrom::from(Inner); - assert!(any::request_ref::(&error).is_some()); + assert!(error::request_ref::(&error).is_some()); let error = ArcBacktraceFrom::from(Inner); - assert!(any::request_ref::(&error).is_some()); + assert!(error::request_ref::(&error).is_some()); } } diff --git a/third_party/rust/thiserror/tests/test_display.rs b/third_party/rust/thiserror/tests/test_display.rs index 99ce2fdede7aa..6f603882eb2d7 100644 --- a/third_party/rust/thiserror/tests/test_display.rs +++ b/third_party/rust/thiserror/tests/test_display.rs @@ -1,3 +1,5 @@ +#![allow(clippy::uninlined_format_args)] + use std::fmt::{self, Display}; use thiserror::Error; diff --git a/third_party/rust/thiserror/tests/test_expr.rs b/third_party/rust/thiserror/tests/test_expr.rs index 34de56087bb3b..028f34ee2bda8 100644 --- a/third_party/rust/thiserror/tests/test_expr.rs +++ b/third_party/rust/thiserror/tests/test_expr.rs @@ -1,4 +1,4 @@ -#![allow(clippy::iter_cloned_collect, clippy::option_if_let_else)] +#![allow(clippy::iter_cloned_collect, clippy::uninlined_format_args)] use std::fmt::Display; use thiserror::Error; diff --git a/third_party/rust/thiserror/tests/test_generics.rs b/third_party/rust/thiserror/tests/test_generics.rs index 4ab9f3778655d..c94d95ef8a8fe 100644 --- a/third_party/rust/thiserror/tests/test_generics.rs +++ b/third_party/rust/thiserror/tests/test_generics.rs @@ -1,4 +1,4 @@ -#![allow(clippy::needless_late_init)] +#![allow(clippy::needless_late_init, clippy::uninlined_format_args)] use std::fmt::{self, Debug, Display}; use thiserror::Error; diff --git a/third_party/rust/thiserror/tests/test_option.rs b/third_party/rust/thiserror/tests/test_option.rs index ed5287dc92720..232e5a3bb52bf 100644 --- a/third_party/rust/thiserror/tests/test_option.rs +++ b/third_party/rust/thiserror/tests/test_option.rs @@ -1,7 +1,4 @@ -#![cfg_attr( - thiserror_nightly_testing, - feature(error_generic_member_access, provide_any) -)] +#![cfg_attr(thiserror_nightly_testing, feature(error_generic_member_access))] #[cfg(thiserror_nightly_testing)] pub mod structs { diff --git a/third_party/rust/thiserror/tests/ui/fallback-impl-with-display.rs b/third_party/rust/thiserror/tests/ui/fallback-impl-with-display.rs new file mode 100644 index 0000000000000..3341187315985 --- /dev/null +++ b/third_party/rust/thiserror/tests/ui/fallback-impl-with-display.rs @@ -0,0 +1,14 @@ +use std::fmt::{self, Display}; +use thiserror::Error; + +#[derive(Error, Debug)] +#[error] +pub struct MyError; + +impl Display for MyError { + fn fmt(&self, _formatter: &mut fmt::Formatter) -> fmt::Result { + unimplemented!() + } +} + +fn main() {} diff --git a/third_party/rust/thiserror/tests/ui/fallback-impl-with-display.stderr b/third_party/rust/thiserror/tests/ui/fallback-impl-with-display.stderr new file mode 100644 index 0000000000000..6bd3730731c84 --- /dev/null +++ b/third_party/rust/thiserror/tests/ui/fallback-impl-with-display.stderr @@ -0,0 +1,16 @@ +error: expected attribute arguments in parentheses: #[error(...)] + --> tests/ui/fallback-impl-with-display.rs:5:3 + | +5 | #[error] + | ^^^^^ + +error[E0119]: conflicting implementations of trait `std::fmt::Display` for type `MyError` + --> tests/ui/fallback-impl-with-display.rs:4:10 + | +4 | #[derive(Error, Debug)] + | ^^^^^ conflicting implementation for `MyError` +... +8 | impl Display for MyError { + | ------------------------ first implementation here + | + = note: this error originates in the derive macro `Error` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/third_party/rust/thiserror/tests/ui/from-backtrace-backtrace.rs b/third_party/rust/thiserror/tests/ui/from-backtrace-backtrace.rs index 8f411bf5d890e..3b781ac4e1f42 100644 --- a/third_party/rust/thiserror/tests/ui/from-backtrace-backtrace.rs +++ b/third_party/rust/thiserror/tests/ui/from-backtrace-backtrace.rs @@ -5,6 +5,11 @@ use thiserror::Error; #[derive(Error, Debug)] #[error("...")] -pub struct Error(#[from] #[backtrace] std::io::Error, Backtrace); +pub struct Error( + #[from] + #[backtrace] + std::io::Error, + Backtrace, +); fn main() {} diff --git a/third_party/rust/thiserror/tests/ui/from-backtrace-backtrace.stderr b/third_party/rust/thiserror/tests/ui/from-backtrace-backtrace.stderr index 55d647b425652..5c0b9a3bfa243 100644 --- a/third_party/rust/thiserror/tests/ui/from-backtrace-backtrace.stderr +++ b/third_party/rust/thiserror/tests/ui/from-backtrace-backtrace.stderr @@ -1,5 +1,5 @@ error: deriving From requires no fields other than source and backtrace - --> tests/ui/from-backtrace-backtrace.rs:8:18 + --> tests/ui/from-backtrace-backtrace.rs:9:5 | -8 | pub struct Error(#[from] #[backtrace] std::io::Error, Backtrace); - | ^^^^^^^ +9 | #[from] + | ^^^^^^^ diff --git a/third_party/rust/thiserror/tests/ui/invalid-input-impl-anyway.rs b/third_party/rust/thiserror/tests/ui/invalid-input-impl-anyway.rs new file mode 100644 index 0000000000000..0a0bcbee8ed51 --- /dev/null +++ b/third_party/rust/thiserror/tests/ui/invalid-input-impl-anyway.rs @@ -0,0 +1,11 @@ +use thiserror::Error; + +#[derive(Error, Debug)] +#[error] +pub struct MyError; + +fn main() { + // No error on the following line. Thiserror emits an Error impl despite the + // bad attribute. + _ = &MyError as &dyn std::error::Error; +} diff --git a/third_party/rust/thiserror/tests/ui/invalid-input-impl-anyway.stderr b/third_party/rust/thiserror/tests/ui/invalid-input-impl-anyway.stderr new file mode 100644 index 0000000000000..b98c31e9c6b01 --- /dev/null +++ b/third_party/rust/thiserror/tests/ui/invalid-input-impl-anyway.stderr @@ -0,0 +1,5 @@ +error: expected attribute arguments in parentheses: #[error(...)] + --> tests/ui/invalid-input-impl-anyway.rs:4:3 + | +4 | #[error] + | ^^^^^ diff --git a/third_party/rust/thiserror/tests/ui/missing-display.rs b/third_party/rust/thiserror/tests/ui/missing-display.rs new file mode 100644 index 0000000000000..31e23fe683d73 --- /dev/null +++ b/third_party/rust/thiserror/tests/ui/missing-display.rs @@ -0,0 +1,9 @@ +use thiserror::Error; + +#[derive(Error, Debug)] +pub enum MyError { + First, + Second, +} + +fn main() {} diff --git a/third_party/rust/thiserror/tests/ui/missing-display.stderr b/third_party/rust/thiserror/tests/ui/missing-display.stderr new file mode 100644 index 0000000000000..48c9ded9fa174 --- /dev/null +++ b/third_party/rust/thiserror/tests/ui/missing-display.stderr @@ -0,0 +1,13 @@ +error[E0277]: `MyError` doesn't implement `std::fmt::Display` + --> tests/ui/missing-display.rs:4:10 + | +4 | pub enum MyError { + | ^^^^^^^ `MyError` cannot be formatted with the default formatter + | + = help: the trait `std::fmt::Display` is not implemented for `MyError` + = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead +note: required by a bound in `std::error::Error` + --> $RUST/core/src/error.rs + | + | pub trait Error: Debug + Display { + | ^^^^^^^ required by this bound in `Error` diff --git a/third_party/rust/thiserror/tests/ui/no-display.stderr b/third_party/rust/thiserror/tests/ui/no-display.stderr index 76818e1e5e0f8..0f47c24b6211a 100644 --- a/third_party/rust/thiserror/tests/ui/no-display.stderr +++ b/third_party/rust/thiserror/tests/ui/no-display.stderr @@ -9,7 +9,7 @@ error[E0599]: the method `as_display` exists for reference `&NoDisplay`, but its | = note: the following trait bounds were not satisfied: `NoDisplay: std::fmt::Display` - which is required by `&NoDisplay: DisplayAsDisplay` + which is required by `&NoDisplay: AsDisplay<'_>` note: the trait `std::fmt::Display` must be implemented --> $RUST/core/src/fmt/mod.rs | diff --git a/third_party/rust/thiserror/tests/ui/source-enum-not-error.rs b/third_party/rust/thiserror/tests/ui/source-enum-not-error.rs index 3eb0d3e866e75..dae2285b830c8 100644 --- a/third_party/rust/thiserror/tests/ui/source-enum-not-error.rs +++ b/third_party/rust/thiserror/tests/ui/source-enum-not-error.rs @@ -6,9 +6,7 @@ pub struct NotError; #[derive(Error, Debug)] #[error("...")] pub enum ErrorEnum { - Broken { - source: NotError, - }, + Broken { source: NotError }, } fn main() {} diff --git a/third_party/rust/thiserror/tests/ui/source-enum-not-error.stderr b/third_party/rust/thiserror/tests/ui/source-enum-not-error.stderr index 750c69eb3e9cf..4c44742d54523 100644 --- a/third_party/rust/thiserror/tests/ui/source-enum-not-error.stderr +++ b/third_party/rust/thiserror/tests/ui/source-enum-not-error.stderr @@ -1,22 +1,22 @@ error[E0599]: the method `as_dyn_error` exists for reference `&NotError`, but its trait bounds were not satisfied - --> tests/ui/source-enum-not-error.rs:10:9 - | -4 | pub struct NotError; - | ------------------- - | | - | doesn't satisfy `NotError: AsDynError<'_>` - | doesn't satisfy `NotError: std::error::Error` + --> tests/ui/source-enum-not-error.rs:9:14 + | +4 | pub struct NotError; + | ------------------- + | | + | doesn't satisfy `NotError: AsDynError<'_>` + | doesn't satisfy `NotError: std::error::Error` ... -10 | source: NotError, - | ^^^^^^ method cannot be called on `&NotError` due to unsatisfied trait bounds - | - = note: the following trait bounds were not satisfied: - `NotError: std::error::Error` - which is required by `NotError: AsDynError<'_>` - `&NotError: std::error::Error` - which is required by `&NotError: AsDynError<'_>` +9 | Broken { source: NotError }, + | ^^^^^^ method cannot be called on `&NotError` due to unsatisfied trait bounds + | + = note: the following trait bounds were not satisfied: + `NotError: std::error::Error` + which is required by `NotError: AsDynError<'_>` + `&NotError: std::error::Error` + which is required by `&NotError: AsDynError<'_>` note: the trait `std::error::Error` must be implemented - --> $RUST/core/src/error.rs - | - | pub trait Error: Debug + Display { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + --> $RUST/core/src/error.rs + | + | pub trait Error: Debug + Display { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/third_party/rust/thiserror/tests/ui/source-enum-unnamed-field-not-error.rs b/third_party/rust/thiserror/tests/ui/source-enum-unnamed-field-not-error.rs new file mode 100644 index 0000000000000..a877c2cd0fb95 --- /dev/null +++ b/third_party/rust/thiserror/tests/ui/source-enum-unnamed-field-not-error.rs @@ -0,0 +1,12 @@ +use thiserror::Error; + +#[derive(Debug)] +pub struct NotError; + +#[derive(Error, Debug)] +#[error("...")] +pub enum ErrorEnum { + Broken(#[source] NotError), +} + +fn main() {} diff --git a/third_party/rust/thiserror/tests/ui/source-enum-unnamed-field-not-error.stderr b/third_party/rust/thiserror/tests/ui/source-enum-unnamed-field-not-error.stderr new file mode 100644 index 0000000000000..da6d225f863b3 --- /dev/null +++ b/third_party/rust/thiserror/tests/ui/source-enum-unnamed-field-not-error.stderr @@ -0,0 +1,22 @@ +error[E0599]: the method `as_dyn_error` exists for reference `&NotError`, but its trait bounds were not satisfied + --> tests/ui/source-enum-unnamed-field-not-error.rs:9:14 + | +4 | pub struct NotError; + | ------------------- + | | + | doesn't satisfy `NotError: AsDynError<'_>` + | doesn't satisfy `NotError: std::error::Error` +... +9 | Broken(#[source] NotError), + | ^^^^^^ method cannot be called on `&NotError` due to unsatisfied trait bounds + | + = note: the following trait bounds were not satisfied: + `NotError: std::error::Error` + which is required by `NotError: AsDynError<'_>` + `&NotError: std::error::Error` + which is required by `&NotError: AsDynError<'_>` +note: the trait `std::error::Error` must be implemented + --> $RUST/core/src/error.rs + | + | pub trait Error: Debug + Display { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/third_party/rust/thiserror/tests/ui/source-struct-unnamed-field-not-error.rs b/third_party/rust/thiserror/tests/ui/source-struct-unnamed-field-not-error.rs new file mode 100644 index 0000000000000..160b6b247ff5a --- /dev/null +++ b/third_party/rust/thiserror/tests/ui/source-struct-unnamed-field-not-error.rs @@ -0,0 +1,10 @@ +use thiserror::Error; + +#[derive(Debug)] +struct NotError; + +#[derive(Error, Debug)] +#[error("...")] +pub struct ErrorStruct(#[source] NotError); + +fn main() {} diff --git a/third_party/rust/thiserror/tests/ui/source-struct-unnamed-field-not-error.stderr b/third_party/rust/thiserror/tests/ui/source-struct-unnamed-field-not-error.stderr new file mode 100644 index 0000000000000..a23f26823f3db --- /dev/null +++ b/third_party/rust/thiserror/tests/ui/source-struct-unnamed-field-not-error.stderr @@ -0,0 +1,21 @@ +error[E0599]: the method `as_dyn_error` exists for struct `NotError`, but its trait bounds were not satisfied + --> tests/ui/source-struct-unnamed-field-not-error.rs:8:26 + | +4 | struct NotError; + | --------------- + | | + | method `as_dyn_error` not found for this struct + | doesn't satisfy `NotError: AsDynError<'_>` + | doesn't satisfy `NotError: std::error::Error` +... +8 | pub struct ErrorStruct(#[source] NotError); + | ^^^^^^ method cannot be called on `NotError` due to unsatisfied trait bounds + | + = note: the following trait bounds were not satisfied: + `NotError: std::error::Error` + which is required by `NotError: AsDynError<'_>` +note: the trait `std::error::Error` must be implemented + --> $RUST/core/src/error.rs + | + | pub trait Error: Debug + Display { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/third_party/rust/thiserror/tests/ui/transparent-enum-not-error.rs b/third_party/rust/thiserror/tests/ui/transparent-enum-not-error.rs new file mode 100644 index 0000000000000..80ccfc973a8e9 --- /dev/null +++ b/third_party/rust/thiserror/tests/ui/transparent-enum-not-error.rs @@ -0,0 +1,9 @@ +use thiserror::Error; + +#[derive(Error, Debug)] +pub enum Error { + #[error(transparent)] + Other { message: String }, +} + +fn main() {} diff --git a/third_party/rust/thiserror/tests/ui/transparent-enum-not-error.stderr b/third_party/rust/thiserror/tests/ui/transparent-enum-not-error.stderr new file mode 100644 index 0000000000000..9be51434a697e --- /dev/null +++ b/third_party/rust/thiserror/tests/ui/transparent-enum-not-error.stderr @@ -0,0 +1,23 @@ +error[E0599]: the method `as_dyn_error` exists for reference `&String`, but its trait bounds were not satisfied + --> tests/ui/transparent-enum-not-error.rs:5:13 + | +5 | #[error(transparent)] + | ^^^^^^^^^^^ method cannot be called on `&String` due to unsatisfied trait bounds + | + ::: $RUST/alloc/src/string.rs + | + | pub struct String { + | ----------------- + | | + | doesn't satisfy `String: AsDynError<'_>` + | doesn't satisfy `String: std::error::Error` + | + = note: the following trait bounds were not satisfied: + `String: std::error::Error` + which is required by `String: AsDynError<'_>` + `&String: std::error::Error` + which is required by `&String: AsDynError<'_>` + `str: Sized` + which is required by `str: AsDynError<'_>` + `str: std::error::Error` + which is required by `str: AsDynError<'_>` diff --git a/third_party/rust/thiserror/tests/ui/transparent-enum-unnamed-field-not-error.rs b/third_party/rust/thiserror/tests/ui/transparent-enum-unnamed-field-not-error.rs new file mode 100644 index 0000000000000..87c32e0b6cfbe --- /dev/null +++ b/third_party/rust/thiserror/tests/ui/transparent-enum-unnamed-field-not-error.rs @@ -0,0 +1,9 @@ +use thiserror::Error; + +#[derive(Error, Debug)] +pub enum Error { + #[error(transparent)] + Other(String), +} + +fn main() {} diff --git a/third_party/rust/thiserror/tests/ui/transparent-enum-unnamed-field-not-error.stderr b/third_party/rust/thiserror/tests/ui/transparent-enum-unnamed-field-not-error.stderr new file mode 100644 index 0000000000000..3d23c3a0e57d4 --- /dev/null +++ b/third_party/rust/thiserror/tests/ui/transparent-enum-unnamed-field-not-error.stderr @@ -0,0 +1,23 @@ +error[E0599]: the method `as_dyn_error` exists for reference `&String`, but its trait bounds were not satisfied + --> tests/ui/transparent-enum-unnamed-field-not-error.rs:5:13 + | +5 | #[error(transparent)] + | ^^^^^^^^^^^ method cannot be called on `&String` due to unsatisfied trait bounds + | + ::: $RUST/alloc/src/string.rs + | + | pub struct String { + | ----------------- + | | + | doesn't satisfy `String: AsDynError<'_>` + | doesn't satisfy `String: std::error::Error` + | + = note: the following trait bounds were not satisfied: + `String: std::error::Error` + which is required by `String: AsDynError<'_>` + `&String: std::error::Error` + which is required by `&String: AsDynError<'_>` + `str: Sized` + which is required by `str: AsDynError<'_>` + `str: std::error::Error` + which is required by `str: AsDynError<'_>` diff --git a/third_party/rust/thiserror/tests/ui/transparent-struct-not-error.rs b/third_party/rust/thiserror/tests/ui/transparent-struct-not-error.rs new file mode 100644 index 0000000000000..811ff539589f0 --- /dev/null +++ b/third_party/rust/thiserror/tests/ui/transparent-struct-not-error.rs @@ -0,0 +1,9 @@ +use thiserror::Error; + +#[derive(Error, Debug)] +#[error(transparent)] +pub struct Error { + message: String, +} + +fn main() {} diff --git a/third_party/rust/thiserror/tests/ui/transparent-struct-not-error.stderr b/third_party/rust/thiserror/tests/ui/transparent-struct-not-error.stderr new file mode 100644 index 0000000000000..d67a694467b05 --- /dev/null +++ b/third_party/rust/thiserror/tests/ui/transparent-struct-not-error.stderr @@ -0,0 +1,21 @@ +error[E0599]: the method `as_dyn_error` exists for struct `String`, but its trait bounds were not satisfied + --> tests/ui/transparent-struct-not-error.rs:4:9 + | +4 | #[error(transparent)] + | ^^^^^^^^^^^ method cannot be called on `String` due to unsatisfied trait bounds + | + ::: $RUST/alloc/src/string.rs + | + | pub struct String { + | ----------------- + | | + | doesn't satisfy `String: AsDynError<'_>` + | doesn't satisfy `String: std::error::Error` + | + = note: the following trait bounds were not satisfied: + `String: std::error::Error` + which is required by `String: AsDynError<'_>` + `str: Sized` + which is required by `str: AsDynError<'_>` + `str: std::error::Error` + which is required by `str: AsDynError<'_>` diff --git a/third_party/rust/thiserror/tests/ui/transparent-struct-unnamed-field-not-error.rs b/third_party/rust/thiserror/tests/ui/transparent-struct-unnamed-field-not-error.rs new file mode 100644 index 0000000000000..b4f7fbbfd5e2e --- /dev/null +++ b/third_party/rust/thiserror/tests/ui/transparent-struct-unnamed-field-not-error.rs @@ -0,0 +1,7 @@ +use thiserror::Error; + +#[derive(Error, Debug)] +#[error(transparent)] +pub struct Error(String); + +fn main() {} diff --git a/third_party/rust/thiserror/tests/ui/transparent-struct-unnamed-field-not-error.stderr b/third_party/rust/thiserror/tests/ui/transparent-struct-unnamed-field-not-error.stderr new file mode 100644 index 0000000000000..f715a1517553b --- /dev/null +++ b/third_party/rust/thiserror/tests/ui/transparent-struct-unnamed-field-not-error.stderr @@ -0,0 +1,21 @@ +error[E0599]: the method `as_dyn_error` exists for struct `String`, but its trait bounds were not satisfied + --> tests/ui/transparent-struct-unnamed-field-not-error.rs:4:9 + | +4 | #[error(transparent)] + | ^^^^^^^^^^^ method cannot be called on `String` due to unsatisfied trait bounds + | + ::: $RUST/alloc/src/string.rs + | + | pub struct String { + | ----------------- + | | + | doesn't satisfy `String: AsDynError<'_>` + | doesn't satisfy `String: std::error::Error` + | + = note: the following trait bounds were not satisfied: + `String: std::error::Error` + which is required by `String: AsDynError<'_>` + `str: Sized` + which is required by `str: AsDynError<'_>` + `str: std::error::Error` + which is required by `str: AsDynError<'_>` diff --git a/third_party/rust/wgpu-core/.cargo-checksum.json b/third_party/rust/wgpu-core/.cargo-checksum.json index 79e2a71914c32..491e1ccb1456e 100644 --- a/third_party/rust/wgpu-core/.cargo-checksum.json +++ b/third_party/rust/wgpu-core/.cargo-checksum.json @@ -1 +1 @@ -{"files":{"Cargo.toml":"7d8b06bcc217e1e9a23ad63e2e9d9403f2ef58ab257c222233403c3e57a642e7","LICENSE.APACHE":"a6cba85bc92e0cff7a450b1d873c0eaa2e9fc96bf472df0247a26bec77bf3ff9","LICENSE.MIT":"c7fea58d1cfe49634cd92e54fc10a9d871f4b275321a4cd8c09e449122caaeb4","src/any_surface.rs":"c5e961783be28548681c3c38579ea0b5724c5336848216a423e83a0db2208ece","src/binding_model.rs":"ba1849e89e7dae7cd29635b57dc3140e47389e7aa38732b03c4cad693444680c","src/command/bind.rs":"85bbab812222f9bc11893059304cac850616818b00857fadac4885b978e4cfe2","src/command/bundle.rs":"7836b3740ad32168fdfb4241dbc91839d695c019abd3c38e3decec332b7e82c2","src/command/clear.rs":"1d2e1ffd6646eab56a7fd30167085c9f5fc5c695420fc7ce145cf48e748ef194","src/command/compute.rs":"296864d4f9e9a98f368d64910146480e38e2f895eee98a97d947dd593033f87c","src/command/draw.rs":"3687cbde422a29f28c1c3d17e132d912b3b4b2bcc98efca68d1ee0d563a5bf56","src/command/memory_init.rs":"ffe5c301f19a17285523ee8fd5e7bf5abd5e50e9a3716f5713ac99ab135d9f5e","src/command/mod.rs":"9ffa26b0306067ad63fc61fbde985ad98d495a2ad739f51bf54a39f702f45d3a","src/command/query.rs":"f31db3f1282109baa59e6dcd7b2e674c7858a2c64f58fc6eb3a4d0c546935af5","src/command/render.rs":"61a9f34d813700606b49224d9de19773c49eb3dd42fa4027357a334dc63e2579","src/command/transfer.rs":"60969f020bddfb88a0c3b459b72b94d3a9a96cc635d20e88d016765d0fb94ba5","src/conv.rs":"7e3ffe33b47a6fd3617aabf9f11cc68f1ccbee2c7343b8dbbcd0e8f3447e1ad8","src/device/any_device.rs":"2cb2be0fd078d65039692d309d8688cf4a02fb768579cf22c93cfa514d20ad7f","src/device/global.rs":"634619218859faa1dbd789b79a9ae2186cef950c50e3f9b1c4850d36bd1c8f16","src/device/life.rs":"a3d52432d7aff41d9f5bcf3b2da70d73f28847516d5909894328b78d2867b7ee","src/device/mod.rs":"d6a8ce711b8891c469c4b47348a3ce48d84ea4a356c0b05ec7e128d21a440562","src/device/queue.rs":"9525b939e49b4c2860928c04a660a4556b34bfbed23e00318635a5ad46bce061","src/device/resource.rs":"d067f54b1708b799babc468991ec7433616069931224a9b3c3d28d1c20c14b23","src/device/trace.rs":"9a8ec674567a8866a6bd1ed2ad06e474bd2504ed91f228d3040cb6db18fe5f2b","src/error.rs":"32680e922acfb1f1d6842177179768d365c575a8baa402da9d5a43a2357b0dbf","src/global.rs":"c0a590e0136bf19a63ddc87dd3f0bbfbe24bcb810d0ccfc6c5f26631750d63ea","src/hal_api.rs":"3ee0f5e66b313fd1b8c79b3d73f0f1dbde88676b651d79518fa2dc5aff0ab856","src/hub.rs":"4cec8de74a661bb628040ff457d38faf8c92d0824c4d5a4955834d56ebd25926","src/id.rs":"76f6fbff7ac094b2d81e98e198b9d8785f11885e42015208fc362c368298c41f","src/identity.rs":"0701f6f41e754dde2bebc567a87c25b353dfab40b79a322990dbfa477739ab8c","src/init_tracker/buffer.rs":"61eb9cfaa312135b7a937ff6a3117f531b5b7323fae6553a41d6de9bc106d7e0","src/init_tracker/mod.rs":"0867f79f83555390d0982d1dc6dcf0d4340e10cb89aa633d3c3ecc45deb3c78c","src/init_tracker/texture.rs":"030fd594bf9948fad391390d85c5e1fec7eaf67b6e812c60f2dd59bc4fda8fd5","src/instance.rs":"e1d4af51bb445850d9e2d7d12b239413bb555f07f95d3a1851cc73443c5c18f0","src/lib.rs":"a7c46d675920b64284bf0494b749a9ffd3661a8c3ce6d4e00c399e5414dbf12d","src/pipeline.rs":"2ae1c803ba37d2114a31aa87a515555e7fc42b337f169f7a1cd7ce4568f92f30","src/present.rs":"7751da30b27eed7521be7af166c6a07468eda47bf96206082cc33df6f77ec0d8","src/registry.rs":"c259ca61dd5f2b632ff2ee871f82727921fa48dee15253872799af1dda77484b","src/resource.rs":"b1e8dad1ddb5ae480e7338796f0176c886da7f6a280da1655f3154819c873877","src/storage.rs":"6ba6416522ba2f1d2a279c220960aabdfb071c4e0ade888c8cbc2b91325c4203","src/track/buffer.rs":"a6762fad8bf5b257d37fb8844f0ee44ecb04f052c58655404b8af0036ac929e5","src/track/metadata.rs":"f8994ad91db7f3bb1b7f8b8b0f6884753d733ce28238b36f31da2230706f848e","src/track/mod.rs":"5fdef0bcf20999fda97342e261341809394dcad3ee97e2bc2429c5a1e41d48d5","src/track/range.rs":"5bbfed6e103b3234d9de8e42057022da6d628c2cc1db6bb51b88f87f2d8adf8b","src/track/stateless.rs":"65142de8e8425eee26e32bfef8169af3ed0e98455d5e470517717a3c15e8036c","src/track/texture.rs":"d4e92ef3400cf48b2e76d8b7c1e4c6a1cef0d3d060c6abdb46b9a3b386bc9dc9","src/validation.rs":"4bd36b7b02ad0122fda719790d40cc68058e0f8e3ba3cd622f1d76db377320f9"},"package":null} \ No newline at end of file +{"files":{"Cargo.toml":"f7d6539341f7ff8362c314e0c1b9bf95eea7dad87af191e28bc30e3c53de28fd","LICENSE.APACHE":"a6cba85bc92e0cff7a450b1d873c0eaa2e9fc96bf472df0247a26bec77bf3ff9","LICENSE.MIT":"c7fea58d1cfe49634cd92e54fc10a9d871f4b275321a4cd8c09e449122caaeb4","src/any_surface.rs":"c5e961783be28548681c3c38579ea0b5724c5336848216a423e83a0db2208ece","src/binding_model.rs":"ad6667fd22e3a56fb09d35f077a1d94203c0d1ef36832492971a8143ad109ca2","src/command/bind.rs":"fcfbefdbdde10a1add947308ef3e80ed2acd8b6459bc7e0c25b0bbb38b1144ff","src/command/bundle.rs":"db63658fb05d548d593599e3fa0fb9c42f56419e35d97b56011c913c906c7c13","src/command/clear.rs":"f7a1c3374949885652fde94658a14e09dac84fc41d58c352e585c764d9a14f3c","src/command/compute.rs":"c393569da1377e136180560dbc19b1314b6527ae0e0cb2834a9222052f9bffce","src/command/draw.rs":"79db78560c6046f309f103f224750260ff926550846336bebd186252b4732fbc","src/command/memory_init.rs":"9c982099046ee174e1574d3f841e712831a84dd0948ebe2ffcb51e01c5104fa7","src/command/mod.rs":"dd22c5eab57f6f03373c41bfda2a55666ee61dfb2482a1126f959a48d0ad81c8","src/command/query.rs":"8c21df7d24e49664f70b364bd9daf575bebe5c17a456f346f0a98d4e6c810636","src/command/render.rs":"795fd6e78e91ee6f4f54856cdddbb680745d0accda802533f88e205de135436a","src/command/transfer.rs":"6012000a420c2e177c00a6df91b15ac58e947f5422d67bb8db5843a2a3fff134","src/conv.rs":"7e3ffe33b47a6fd3617aabf9f11cc68f1ccbee2c7343b8dbbcd0e8f3447e1ad8","src/device/any_device.rs":"2cb2be0fd078d65039692d309d8688cf4a02fb768579cf22c93cfa514d20ad7f","src/device/global.rs":"ed1580f15bdec3927b736101b78dc34fec40d92ed4ead15a0e1b5f70e72d5675","src/device/life.rs":"9c9d2c21852bc1b9e133bfdea33b89abbbe9d849ad5c00d09863fe5594792e40","src/device/mod.rs":"45ad9b826f296cbef9470c3cfc705f832198587b45847ddd0ea4ddd5eb55f7eb","src/device/queue.rs":"7ec005a04371d0cb191bc067074ac83f95dc751e5f1145e1cb7935b76b2b3716","src/device/resource.rs":"396bfda6c181826288484426f4fa170376256e1d29df916e1f265d2397e5987d","src/device/trace.rs":"9a8ec674567a8866a6bd1ed2ad06e474bd2504ed91f228d3040cb6db18fe5f2b","src/error.rs":"32680e922acfb1f1d6842177179768d365c575a8baa402da9d5a43a2357b0dbf","src/global.rs":"c0a590e0136bf19a63ddc87dd3f0bbfbe24bcb810d0ccfc6c5f26631750d63ea","src/hal_api.rs":"3ee0f5e66b313fd1b8c79b3d73f0f1dbde88676b651d79518fa2dc5aff0ab856","src/hub.rs":"4cec8de74a661bb628040ff457d38faf8c92d0824c4d5a4955834d56ebd25926","src/id.rs":"2c73422b2b5f0ce4a5bc3fce79bb3d3a370cda7aa6680c2239829ffc5a85d869","src/identity.rs":"0701f6f41e754dde2bebc567a87c25b353dfab40b79a322990dbfa477739ab8c","src/init_tracker/buffer.rs":"61eb9cfaa312135b7a937ff6a3117f531b5b7323fae6553a41d6de9bc106d7e0","src/init_tracker/mod.rs":"0867f79f83555390d0982d1dc6dcf0d4340e10cb89aa633d3c3ecc45deb3c78c","src/init_tracker/texture.rs":"030fd594bf9948fad391390d85c5e1fec7eaf67b6e812c60f2dd59bc4fda8fd5","src/instance.rs":"e1d4af51bb445850d9e2d7d12b239413bb555f07f95d3a1851cc73443c5c18f0","src/lib.rs":"ab61469bc2d9bdcc47b73435a0d438ba413c5619ab653180a56e8e2aefe93c74","src/pipeline.rs":"bd6e242f0f5408da0a675066092129281aadd5ab0051c036821b34c17992c1da","src/present.rs":"7751da30b27eed7521be7af166c6a07468eda47bf96206082cc33df6f77ec0d8","src/registry.rs":"c259ca61dd5f2b632ff2ee871f82727921fa48dee15253872799af1dda77484b","src/resource.rs":"e3c22585dd85dc79a4c5b50a7302392421bfc16dbac6de14592440deeeb7ee8a","src/snatch.rs":"2de558dda543329d70be35ed72dffdeba816814f6f0059d720a568abd47e40a7","src/storage.rs":"02be927de5c85f5f59a1c847bbdc8e9e02fb976c39fb7e3078a8f9fbff929934","src/track/buffer.rs":"c5ae73d1d84bcfb5a17c31f43de661cd0bf931e15e9fd92ad18fd31a88b05330","src/track/metadata.rs":"f8994ad91db7f3bb1b7f8b8b0f6884753d733ce28238b36f31da2230706f848e","src/track/mod.rs":"25015210f4f960f1daf4891a13d5b6ac48aad87cbc158a0bcdb1f718219f6e20","src/track/range.rs":"2a15794e79b0470d5ba6b3267173a42f34312878e1cb288f198d2854a7888e53","src/track/stateless.rs":"43ec668f56c962f255b900a773a537dde1c21dd0b2e3804271786fb90e9cfffa","src/track/texture.rs":"d4e92ef3400cf48b2e76d8b7c1e4c6a1cef0d3d060c6abdb46b9a3b386bc9dc9","src/validation.rs":"6933c349d155f647778134696c53cbd641419a959505f2f0a3db31fcceefc8b4"},"package":null} \ No newline at end of file diff --git a/third_party/rust/wgpu-core/Cargo.toml b/third_party/rust/wgpu-core/Cargo.toml index 85a5e896e4c40..300e0f57f20ab 100644 --- a/third_party/rust/wgpu-core/Cargo.toml +++ b/third_party/rust/wgpu-core/Cargo.toml @@ -89,7 +89,6 @@ fragile-send-sync-non-atomic-wasm = [ "wgt/fragile-send-sync-non-atomic-wasm", ] gles = ["hal/gles"] -id32 = [] link = ["hal/link"] metal = ["hal/metal"] renderdoc = ["hal/renderdoc"] diff --git a/third_party/rust/wgpu-core/src/binding_model.rs b/third_party/rust/wgpu-core/src/binding_model.rs index 1b5cff866847d..c5db9b02c47ad 100644 --- a/third_party/rust/wgpu-core/src/binding_model.rs +++ b/third_party/rust/wgpu-core/src/binding_model.rs @@ -9,6 +9,7 @@ use crate::{ init_tracker::{BufferInitTrackerAction, TextureInitTrackerAction}, resource::{Resource, ResourceInfo, ResourceType}, resource_log, + snatch::SnatchGuard, track::{BindGroupStates, UsageConflict}, validation::{MissingBufferUsageError, MissingTextureUsageError}, FastHashMap, Label, @@ -16,7 +17,6 @@ use crate::{ use arrayvec::ArrayVec; -use parking_lot::RwLock; #[cfg(feature = "replay")] use serde::Deserialize; #[cfg(feature = "trace")] @@ -467,7 +467,7 @@ pub struct BindGroupLayout { impl Drop for BindGroupLayout { fn drop(&mut self) { if let Some(raw) = self.raw.take() { - resource_log!("Destroy raw BindGroupLayout {}", self.info.label()); + resource_log!("Destroy raw BindGroupLayout {:?}", self.info.label()); unsafe { use hal::Device; self.device.raw().destroy_bind_group_layout(raw); @@ -605,7 +605,7 @@ pub struct PipelineLayout { impl Drop for PipelineLayout { fn drop(&mut self) { if let Some(raw) = self.raw.take() { - resource_log!("Destroy raw PipelineLayout {}", self.info.label()); + resource_log!("Destroy raw PipelineLayout {:?}", self.info.label()); unsafe { use hal::Device; self.device.raw().destroy_pipeline_layout(raw); @@ -815,9 +815,9 @@ pub struct BindGroup { pub(crate) layout: Arc>, pub(crate) info: ResourceInfo, pub(crate) used: BindGroupStates, - pub(crate) used_buffer_ranges: RwLock>>, - pub(crate) used_texture_ranges: RwLock>>, - pub(crate) dynamic_binding_info: RwLock>, + pub(crate) used_buffer_ranges: Vec>, + pub(crate) used_texture_ranges: Vec>, + pub(crate) dynamic_binding_info: Vec, /// Actual binding sizes for buffers that don't have `min_binding_size` /// specified in BGL. Listed in the order of iteration of `BGL.entries`. pub(crate) late_buffer_binding_sizes: Vec, @@ -826,7 +826,7 @@ pub struct BindGroup { impl Drop for BindGroup { fn drop(&mut self) { if let Some(raw) = self.raw.take() { - resource_log!("Destroy raw BindGroup {}", self.info.label()); + resource_log!("Destroy raw BindGroup {:?}", self.info.label()); unsafe { use hal::Device; self.device.raw().destroy_bind_group(raw); @@ -836,8 +836,13 @@ impl Drop for BindGroup { } impl BindGroup { - pub(crate) fn raw(&self) -> &A::BindGroup { - self.raw.as_ref().unwrap() + pub(crate) fn raw(&self, guard: &SnatchGuard) -> Option<&A::BindGroup> { + for buffer in &self.used_buffer_ranges { + // Clippy insist on writing it this way. The idea is to return None + // if any of the raw buffer is not valid anymore. + let _ = buffer.buffer.raw(guard)?; + } + self.raw.as_ref() } pub(crate) fn validate_dynamic_bindings( &self, @@ -845,17 +850,16 @@ impl BindGroup { offsets: &[wgt::DynamicOffset], limits: &wgt::Limits, ) -> Result<(), BindError> { - if self.dynamic_binding_info.read().len() != offsets.len() { + if self.dynamic_binding_info.len() != offsets.len() { return Err(BindError::MismatchedDynamicOffsetCount { group: bind_group_index, - expected: self.dynamic_binding_info.read().len(), + expected: self.dynamic_binding_info.len(), actual: offsets.len(), }); } for (idx, (info, &offset)) in self .dynamic_binding_info - .read() .iter() .zip(offsets.iter()) .enumerate() diff --git a/third_party/rust/wgpu-core/src/command/bind.rs b/third_party/rust/wgpu-core/src/command/bind.rs index 66b95a6df97c3..6bf849a42a969 100644 --- a/third_party/rust/wgpu-core/src/command/bind.rs +++ b/third_party/rust/wgpu-core/src/command/bind.rs @@ -53,6 +53,79 @@ mod compat { fn is_incompatible(&self) -> bool { self.expected.is_none() || !self.is_valid() } + + // Describe how bind group layouts are incompatible, for validation + // error message. + fn bgl_diff(&self) -> Vec { + let mut diff = Vec::new(); + + if let Some(expected_bgl) = self.expected.as_ref() { + diff.push(format!( + "Should be compatible with bind group layout with label = `{}`", + expected_bgl.label() + )); + if let Some(assigned_bgl) = self.assigned.as_ref() { + diff.push(format!( + "Assigned bind group layout with label = `{}`", + assigned_bgl.label() + )); + for (id, e_entry) in &expected_bgl.entries { + if let Some(a_entry) = assigned_bgl.entries.get(id) { + if a_entry.binding != e_entry.binding { + diff.push(format!( + "Entry {id} binding expected {}, got {}", + e_entry.binding, a_entry.binding + )); + } + if a_entry.count != e_entry.count { + diff.push(format!( + "Entry {id} count expected {:?}, got {:?}", + e_entry.count, a_entry.count + )); + } + if a_entry.ty != e_entry.ty { + diff.push(format!( + "Entry {id} type expected {:?}, got {:?}", + e_entry.ty, a_entry.ty + )); + } + if a_entry.visibility != e_entry.visibility { + diff.push(format!( + "Entry {id} visibility expected {:?}, got {:?}", + e_entry.visibility, a_entry.visibility + )); + } + } else { + diff.push(format!("Entry {id} not found in assigned bindgroup layout")) + } + } + + assigned_bgl.entries.iter().for_each(|(id, _e_entry)| { + if !expected_bgl.entries.contains_key(id) { + diff.push(format!("Entry {id} not found in expected bindgroup layout")) + } + }); + } else { + diff.push( + "Assigned bindgroup layout is implicit, expected explicit".to_owned(), + ); + } + } else if let Some(assigned_bgl) = self.assigned.as_ref() { + diff.push(format!( + "Assigned bind group layout = `{}`", + assigned_bgl.label() + )); + diff.push( + "Assigned bindgroup layout is not implicit, expected implicit".to_owned(), + ); + } + + if diff.is_empty() { + diff.push("But no differences found? (internal error)".to_owned()) + } + + diff + } } #[derive(Debug, Default)] @@ -121,6 +194,15 @@ mod compat { } }) } + + pub fn bgl_diff(&self) -> Vec { + for e in &self.entries { + if !e.is_valid() { + return e.bgl_diff(); + } + } + vec![String::from("No differences detected? (internal error)")] + } } } @@ -274,6 +356,10 @@ impl Binder { self.manager.invalid_mask() } + pub(super) fn bgl_diff(&self) -> Vec { + self.manager.bgl_diff() + } + /// Scan active buffer bindings corresponding to layouts without `min_binding_size` specified. pub(super) fn check_late_buffer_bindings( &self, diff --git a/third_party/rust/wgpu-core/src/command/bundle.rs b/third_party/rust/wgpu-core/src/command/bundle.rs index 82648e0e1c66e..f9b71affce698 100644 --- a/third_party/rust/wgpu-core/src/command/bundle.rs +++ b/third_party/rust/wgpu-core/src/command/bundle.rs @@ -318,10 +318,10 @@ impl RenderBundleEncoder { next_dynamic_offset = offsets_range.end; let offsets = &base.dynamic_offsets[offsets_range.clone()]; - if bind_group.dynamic_binding_info.read().len() != offsets.len() { + if bind_group.dynamic_binding_info.len() != offsets.len() { return Err(RenderCommandError::InvalidDynamicOffsetCount { actual: offsets.len(), - expected: bind_group.dynamic_binding_info.read().len(), + expected: bind_group.dynamic_binding_info.len(), }) .map_pass_err(scope); } @@ -330,7 +330,7 @@ impl RenderBundleEncoder { for (offset, info) in offsets .iter() .map(|offset| *offset as wgt::BufferAddress) - .zip(bind_group.dynamic_binding_info.read().iter()) + .zip(bind_group.dynamic_binding_info.iter()) { let (alignment, limit_name) = buffer_binding_type_alignment(&device.limits, info.binding_type); @@ -342,8 +342,8 @@ impl RenderBundleEncoder { } } - buffer_memory_init_actions.extend_from_slice(&bind_group.used_buffer_ranges.read()); - texture_memory_init_actions.extend_from_slice(&bind_group.used_texture_ranges.read()); + buffer_memory_init_actions.extend_from_slice(&bind_group.used_buffer_ranges); + texture_memory_init_actions.extend_from_slice(&bind_group.used_texture_ranges); state.set_bind_group(index, bind_group_guard.get(bind_group_id).as_ref().unwrap(), &bind_group.layout, offsets_range); unsafe { @@ -712,6 +712,8 @@ pub enum CreateRenderBundleError { pub enum ExecutionError { #[error("Buffer {0:?} is destroyed")] DestroyedBuffer(id::BufferId), + #[error("BindGroup {0:?} is invalid")] + InvalidBindGroup(id::BindGroupId), #[error("Using {0} in a render bundle is not implemented")] Unimplemented(&'static str), } @@ -722,6 +724,9 @@ impl PrettyError for ExecutionError { Self::DestroyedBuffer(id) => { fmt.buffer_label(&id); } + Self::InvalidBindGroup(id) => { + fmt.bind_group_label(&id); + } Self::Unimplemented(_reason) => {} }; } @@ -785,6 +790,8 @@ impl RenderBundle { } } + let snatch_guard = self.device.snatchable_lock.read(); + for command in self.base.commands.iter() { match *command { RenderCommand::SetBindGroup { @@ -794,11 +801,14 @@ impl RenderBundle { } => { let bind_groups = trackers.bind_groups.read(); let bind_group = bind_groups.get(bind_group_id).unwrap(); + let raw_bg = bind_group + .raw(&snatch_guard) + .ok_or(ExecutionError::InvalidBindGroup(bind_group_id))?; unsafe { raw.set_bind_group( pipeline_layout.as_ref().unwrap().raw(), index, - bind_group.raw(), + raw_bg, &offsets[..num_dynamic_offsets as usize], ) }; @@ -818,7 +828,11 @@ impl RenderBundle { size, } => { let buffers = trackers.buffers.read(); - let buffer = buffers.get(buffer_id).unwrap().raw(); + let buffer: &A::Buffer = buffers + .get(buffer_id) + .ok_or(ExecutionError::DestroyedBuffer(buffer_id))? + .raw(&snatch_guard) + .ok_or(ExecutionError::DestroyedBuffer(buffer_id))?; let bb = hal::BufferBinding { buffer, offset, @@ -833,7 +847,11 @@ impl RenderBundle { size, } => { let buffers = trackers.buffers.read(); - let buffer = buffers.get(buffer_id).unwrap().raw(); + let buffer = buffers + .get(buffer_id) + .ok_or(ExecutionError::DestroyedBuffer(buffer_id))? + .raw(&snatch_guard) + .ok_or(ExecutionError::DestroyedBuffer(buffer_id))?; let bb = hal::BufferBinding { buffer, offset, @@ -912,7 +930,11 @@ impl RenderBundle { indexed: false, } => { let buffers = trackers.buffers.read(); - let buffer = buffers.get(buffer_id).unwrap().raw(); + let buffer = buffers + .get(buffer_id) + .ok_or(ExecutionError::DestroyedBuffer(buffer_id))? + .raw(&snatch_guard) + .ok_or(ExecutionError::DestroyedBuffer(buffer_id))?; unsafe { raw.draw_indirect(buffer, offset, 1) }; } RenderCommand::MultiDrawIndirect { @@ -922,7 +944,11 @@ impl RenderBundle { indexed: true, } => { let buffers = trackers.buffers.read(); - let buffer = buffers.get(buffer_id).unwrap().raw(); + let buffer = buffers + .get(buffer_id) + .ok_or(ExecutionError::DestroyedBuffer(buffer_id))? + .raw(&snatch_guard) + .ok_or(ExecutionError::DestroyedBuffer(buffer_id))?; unsafe { raw.draw_indexed_indirect(buffer, offset, 1) }; } RenderCommand::MultiDrawIndirect { .. } diff --git a/third_party/rust/wgpu-core/src/command/clear.rs b/third_party/rust/wgpu-core/src/command/clear.rs index d2dd1bbe1a6df..b58738999e3f8 100644 --- a/third_party/rust/wgpu-core/src/command/clear.rs +++ b/third_party/rust/wgpu-core/src/command/clear.rs @@ -102,9 +102,10 @@ impl Global { .set_single(dst_buffer, hal::BufferUses::COPY_DST) .ok_or(ClearError::InvalidBuffer(dst))? }; + let snatch_guard = dst_buffer.device.snatchable_lock.read(); let dst_raw = dst_buffer .raw - .as_ref() + .get(&snatch_guard) .ok_or(ClearError::InvalidBuffer(dst))?; if !dst_buffer.usage.contains(BufferUsages::COPY_DST) { return Err(ClearError::MissingCopyDstUsageFlag(Some(dst), None)); @@ -145,8 +146,9 @@ impl Global { MemoryInitKind::ImplicitlyInitialized, ), ); + // actual hal barrier & operation - let dst_barrier = dst_pending.map(|pending| pending.into_hal(&dst_buffer)); + let dst_barrier = dst_pending.map(|pending| pending.into_hal(&dst_buffer, &snatch_guard)); let cmd_buf_raw = cmd_buf_data.encoder.open(); unsafe { cmd_buf_raw.transition_buffers(dst_barrier.into_iter()); diff --git a/third_party/rust/wgpu-core/src/command/compute.rs b/third_party/rust/wgpu-core/src/command/compute.rs index c457a33186731..5be83a6b14537 100644 --- a/third_party/rust/wgpu-core/src/command/compute.rs +++ b/third_party/rust/wgpu-core/src/command/compute.rs @@ -1,4 +1,5 @@ use crate::resource::Resource; +use crate::snatch::SnatchGuard; use crate::{ binding_model::{ BindError, BindGroup, LateMinBufferBindingSizeMismatch, PushConstantUploadError, @@ -172,12 +173,8 @@ pub struct ComputePassDescriptor<'a> { pub enum DispatchError { #[error("Compute pipeline must be set")] MissingPipeline, - #[error("The pipeline layout, associated with the current compute pipeline, contains a bind group layout at index {index} which is incompatible with the bind group layout associated with the bind group at {index}")] - IncompatibleBindGroup { - index: u32, - //expected: BindGroupLayoutId, - //provided: Option<(BindGroupLayoutId, BindGroupId)>, - }, + #[error("Incompatible bind group at index {index} in the current compute pipeline")] + IncompatibleBindGroup { index: u32, diff: Vec }, #[error( "Each current dispatch group size dimension ({current:?}) must be less or equal to {limit}" )] @@ -191,8 +188,8 @@ pub enum DispatchError { pub enum ComputePassErrorInner { #[error(transparent)] Encoder(#[from] CommandEncoderError), - #[error("Bind group {0:?} is invalid")] - InvalidBindGroup(id::BindGroupId), + #[error("Bind group at index {0:?} is invalid")] + InvalidBindGroup(usize), #[error("Device {0:?} is invalid")] InvalidDevice(DeviceId), #[error("Bind group index {index} is greater than the device's requested `max_bind_group` limit {max}")] @@ -235,15 +232,17 @@ impl PrettyError for ComputePassErrorInner { fn fmt_pretty(&self, fmt: &mut ErrorFormatter) { fmt.error(self); match *self { - Self::InvalidBindGroup(id) => { - fmt.bind_group_label(&id); - } Self::InvalidPipeline(id) => { fmt.compute_pipeline_label(&id); } Self::InvalidIndirectBuffer(id) => { fmt.buffer_label(&id); } + Self::Dispatch(DispatchError::IncompatibleBindGroup { ref diff, .. }) => { + for d in diff { + fmt.note(&d); + } + } _ => {} }; } @@ -290,8 +289,11 @@ impl State { let bind_mask = self.binder.invalid_mask(); if bind_mask != 0 { //let (expected, provided) = self.binder.entries[index as usize].info(); + let index = bind_mask.trailing_zeros(); + return Err(DispatchError::IncompatibleBindGroup { - index: bind_mask.trailing_zeros(), + index, + diff: self.binder.bgl_diff(), }); } if self.pipeline.is_none() { @@ -310,6 +312,7 @@ impl State { base_trackers: &mut Tracker, bind_group_guard: &Storage, id::BindGroupId>, indirect_buffer: Option, + snatch_guard: &SnatchGuard, ) -> Result<(), UsageConflict> { for id in self.binder.list_active() { unsafe { self.scope.merge_bind_group(&bind_group_guard[id].used)? }; @@ -335,7 +338,7 @@ impl State { log::trace!("Encoding dispatch barriers"); - CommandBuffer::drain_barriers(raw_encoder, base_trackers); + CommandBuffer::drain_barriers(raw_encoder, base_trackers, snatch_guard); Ok(()) } } @@ -453,6 +456,8 @@ impl Global { None }; + let snatch_guard = device.snatchable_lock.read(); + tracker.set_size( Some(&*buffer_guard), Some(&*texture_guard), @@ -512,27 +517,23 @@ impl Global { let bind_group = tracker .bind_groups .add_single(&*bind_group_guard, bind_group_id) - .ok_or(ComputePassErrorInner::InvalidBindGroup(bind_group_id)) + .ok_or(ComputePassErrorInner::InvalidBindGroup(index as usize)) .map_pass_err(scope)?; bind_group .validate_dynamic_bindings(index, &temp_offsets, &cmd_buf.limits) .map_pass_err(scope)?; buffer_memory_init_actions.extend( - bind_group - .used_buffer_ranges - .read() - .iter() - .filter_map(|action| { - action - .buffer - .initialization_status - .read() - .check_action(action) - }), + bind_group.used_buffer_ranges.iter().filter_map(|action| { + action + .buffer + .initialization_status + .read() + .check_action(action) + }), ); - for action in bind_group.used_texture_ranges.read().iter() { + for action in bind_group.used_texture_ranges.iter() { pending_discard_init_fixups .extend(texture_memory_actions.register_init_action(action)); } @@ -546,7 +547,10 @@ impl Global { let pipeline_layout = pipeline_layout.as_ref().unwrap().raw(); for (i, e) in entries.iter().enumerate() { if let Some(group) = e.group.as_ref() { - let raw_bg = group.raw(); + let raw_bg = group + .raw(&snatch_guard) + .ok_or(ComputePassErrorInner::InvalidBindGroup(i)) + .map_pass_err(scope)?; unsafe { raw.set_bind_group( pipeline_layout, @@ -590,7 +594,10 @@ impl Global { if !entries.is_empty() { for (i, e) in entries.iter().enumerate() { if let Some(group) = e.group.as_ref() { - let raw_bg = group.raw(); + let raw_bg = group + .raw(&snatch_guard) + .ok_or(ComputePassErrorInner::InvalidBindGroup(i)) + .map_pass_err(scope)?; unsafe { raw.set_bind_group( pipeline.layout.raw(), @@ -673,7 +680,13 @@ impl Global { state.is_ready().map_pass_err(scope)?; state - .flush_states(raw, &mut intermediate_trackers, &*bind_group_guard, None) + .flush_states( + raw, + &mut intermediate_trackers, + &*bind_group_guard, + None, + &snatch_guard, + ) .map_pass_err(scope)?; let groups_size_limit = cmd_buf.limits.max_compute_workgroups_per_dimension; @@ -727,7 +740,7 @@ impl Global { let buf_raw = indirect_buffer .raw - .as_ref() + .get(&snatch_guard) .ok_or(ComputePassErrorInner::InvalidIndirectBuffer(buffer_id)) .map_pass_err(scope)?; @@ -747,6 +760,7 @@ impl Global { &mut intermediate_trackers, &*bind_group_guard, Some(buffer_id), + &snatch_guard, ) .map_pass_err(scope)?; unsafe { @@ -860,7 +874,12 @@ impl Global { &mut tracker.textures, device, ); - CommandBuffer::insert_barriers_from_tracker(transit, tracker, &intermediate_trackers); + CommandBuffer::insert_barriers_from_tracker( + transit, + tracker, + &intermediate_trackers, + &snatch_guard, + ); // Close the command buffer, and swap it with the previous. encoder.close_and_swap(); diff --git a/third_party/rust/wgpu-core/src/command/draw.rs b/third_party/rust/wgpu-core/src/command/draw.rs index c5b0bb7527ebf..ab3b6fa475070 100644 --- a/third_party/rust/wgpu-core/src/command/draw.rs +++ b/third_party/rust/wgpu-core/src/command/draw.rs @@ -25,12 +25,8 @@ pub enum DrawError { MissingVertexBuffer { index: u32 }, #[error("Index buffer must be set")] MissingIndexBuffer, - #[error("The pipeline layout, associated with the current render pipeline, contains a bind group layout at index {index} which is incompatible with the bind group layout associated with the bind group at {index}")] - IncompatibleBindGroup { - index: u32, - //expected: BindGroupLayoutId, - //provided: Option<(BindGroupLayoutId, BindGroupId)>, - }, + #[error("Incompatible bind group at index {index} in the current render pipeline")] + IncompatibleBindGroup { index: u32, diff: Vec }, #[error("Vertex {last_vertex} extends beyond limit {vertex_limit} imposed by the buffer in slot {slot}. Did you bind the correct `Vertex` step-rate vertex buffer?")] VertexBeyondLimit { last_vertex: u32, diff --git a/third_party/rust/wgpu-core/src/command/memory_init.rs b/third_party/rust/wgpu-core/src/command/memory_init.rs index f10c85e2be273..81456ece0a051 100644 --- a/third_party/rust/wgpu-core/src/command/memory_init.rs +++ b/third_party/rust/wgpu-core/src/command/memory_init.rs @@ -223,12 +223,16 @@ impl BakedCommands { .unwrap() .1; - let raw_buf = buffer.raw.as_ref().ok_or(DestroyedBufferError(buffer_id))?; + let snatch_guard = buffer.device.snatchable_lock.read(); + let raw_buf = buffer + .raw + .get(&snatch_guard) + .ok_or(DestroyedBufferError(buffer_id))?; unsafe { self.encoder.transition_buffers( transition - .map(|pending| pending.into_hal(&buffer)) + .map(|pending| pending.into_hal(&buffer, &snatch_guard)) .into_iter(), ); } diff --git a/third_party/rust/wgpu-core/src/command/mod.rs b/third_party/rust/wgpu-core/src/command/mod.rs index fce9d2c6a100c..f7880e6ee8fd3 100644 --- a/third_party/rust/wgpu-core/src/command/mod.rs +++ b/third_party/rust/wgpu-core/src/command/mod.rs @@ -22,6 +22,7 @@ use crate::device::Device; use crate::error::{ErrorFormatter, PrettyError}; use crate::hub::Hub; use crate::id::CommandBufferId; +use crate::snatch::SnatchGuard; use crate::init_tracker::BufferInitTrackerAction; use crate::resource::{Resource, ResourceInfo, ResourceType}; @@ -138,7 +139,7 @@ impl Drop for CommandBuffer { if self.data.lock().is_none() { return; } - resource_log!("resource::CommandBuffer::drop {}", self.info.label()); + resource_log!("resource::CommandBuffer::drop {:?}", self.info.label()); let mut baked = self.extract_baked_commands(); unsafe { baked.encoder.reset_all(baked.list.into_iter()); @@ -193,32 +194,38 @@ impl CommandBuffer { raw: &mut A::CommandEncoder, base: &mut Tracker, head: &Tracker, + snatch_guard: &SnatchGuard, ) { profiling::scope!("insert_barriers"); base.buffers.set_from_tracker(&head.buffers); base.textures.set_from_tracker(&head.textures); - Self::drain_barriers(raw, base); + Self::drain_barriers(raw, base, snatch_guard); } pub(crate) fn insert_barriers_from_scope( raw: &mut A::CommandEncoder, base: &mut Tracker, head: &UsageScope, + snatch_guard: &SnatchGuard, ) { profiling::scope!("insert_barriers"); base.buffers.set_from_usage_scope(&head.buffers); base.textures.set_from_usage_scope(&head.textures); - Self::drain_barriers(raw, base); + Self::drain_barriers(raw, base, snatch_guard); } - pub(crate) fn drain_barriers(raw: &mut A::CommandEncoder, base: &mut Tracker) { + pub(crate) fn drain_barriers( + raw: &mut A::CommandEncoder, + base: &mut Tracker, + snatch_guard: &SnatchGuard, + ) { profiling::scope!("drain_barriers"); - let buffer_barriers = base.buffers.drain_transitions(); + let buffer_barriers = base.buffers.drain_transitions(snatch_guard); let (transitions, textures) = base.textures.drain_transitions(); let texture_barriers = transitions .into_iter() diff --git a/third_party/rust/wgpu-core/src/command/query.rs b/third_party/rust/wgpu-core/src/command/query.rs index 3d4404b41e617..daf5ed47c86c7 100644 --- a/third_party/rust/wgpu-core/src/command/query.rs +++ b/third_party/rust/wgpu-core/src/command/query.rs @@ -430,7 +430,10 @@ impl Global { .set_single(dst_buffer, hal::BufferUses::COPY_DST) .ok_or(QueryError::InvalidBuffer(destination))? }; - let dst_barrier = dst_pending.map(|pending| pending.into_hal(&dst_buffer)); + + let snatch_guard = dst_buffer.device.snatchable_lock.read(); + + let dst_barrier = dst_pending.map(|pending| pending.into_hal(&dst_buffer, &snatch_guard)); if !dst_buffer.usage.contains(wgt::BufferUsages::QUERY_RESOLVE) { return Err(ResolveError::MissingBufferUsage.into()); @@ -476,12 +479,16 @@ impl Global { MemoryInitKind::ImplicitlyInitialized, )); + let raw_dst_buffer = dst_buffer + .raw(&snatch_guard) + .ok_or(QueryError::InvalidBuffer(destination))?; + unsafe { raw_encoder.transition_buffers(dst_barrier.into_iter()); raw_encoder.copy_query_results( query_set.raw(), start_query..end_query, - dst_buffer.raw(), + raw_dst_buffer, destination_offset, wgt::BufferSize::new_unchecked(stride as u64), ); diff --git a/third_party/rust/wgpu-core/src/command/render.rs b/third_party/rust/wgpu-core/src/command/render.rs index a2bb291a00dac..2ffd88ea7a1b6 100644 --- a/third_party/rust/wgpu-core/src/command/render.rs +++ b/third_party/rust/wgpu-core/src/command/render.rs @@ -441,6 +441,7 @@ impl State { //let (expected, provided) = self.binder.entries[index as usize].info(); return Err(DrawError::IncompatibleBindGroup { index: bind_mask.trailing_zeros(), + diff: self.binder.bgl_diff(), }); } if self.pipeline.is_none() { @@ -575,6 +576,8 @@ pub enum RenderPassErrorInner { SurfaceTextureDropped, #[error("Not enough memory left for render pass")] OutOfMemory, + #[error("The bind group at index {0:?} is invalid")] + InvalidBindGroup(usize), #[error("Unable to clear non-present/read-only depth")] InvalidDepthOps, #[error("Unable to clear non-present/read-only stencil")] @@ -643,6 +646,11 @@ impl PrettyError for RenderPassErrorInner { if let Self::InvalidAttachment(id) = *self { fmt.texture_view_label_with_key(&id, "attachment"); }; + if let Self::Draw(DrawError::IncompatibleBindGroup { diff, .. }) = self { + for d in diff { + fmt.note(&d); + } + }; } } @@ -1308,8 +1316,11 @@ impl Global { let hub = A::hub(self); + let cmd_buf = CommandBuffer::get_encoder(hub, encoder_id).map_pass_err(init_scope)?; + let device = &cmd_buf.device; + let snatch_guard = device.snatchable_lock.read(); + let (scope, pending_discard_init_fixups) = { - let cmd_buf = CommandBuffer::get_encoder(hub, encoder_id).map_pass_err(init_scope)?; let mut cmd_buf_data = cmd_buf.data.lock(); let cmd_buf_data = cmd_buf_data.as_mut().unwrap(); @@ -1324,7 +1335,6 @@ impl Global { }); } - let device = &cmd_buf.device; if !device.is_valid() { return Err(DeviceError::Lost).map_pass_err(init_scope); } @@ -1454,19 +1464,15 @@ impl Global { // is held to the bind group itself. buffer_memory_init_actions.extend( - bind_group - .used_buffer_ranges - .read() - .iter() - .filter_map(|action| { - action - .buffer - .initialization_status - .read() - .check_action(action) - }), + bind_group.used_buffer_ranges.iter().filter_map(|action| { + action + .buffer + .initialization_status + .read() + .check_action(action) + }), ); - for action in bind_group.used_texture_ranges.read().iter() { + for action in bind_group.used_texture_ranges.iter() { info.pending_discard_init_fixups .extend(texture_memory_actions.register_init_action(action)); } @@ -1480,7 +1486,10 @@ impl Global { let pipeline_layout = pipeline_layout.as_ref().unwrap().raw(); for (i, e) in entries.iter().enumerate() { if let Some(group) = e.group.as_ref() { - let raw_bg = group.raw(); + let raw_bg = group + .raw(&snatch_guard) + .ok_or(RenderPassErrorInner::InvalidBindGroup(i)) + .map_pass_err(scope)?; unsafe { raw.set_bind_group( pipeline_layout, @@ -1558,7 +1567,10 @@ impl Global { if !entries.is_empty() { for (i, e) in entries.iter().enumerate() { if let Some(group) = e.group.as_ref() { - let raw_bg = group.raw(); + let raw_bg = group + .raw(&snatch_guard) + .ok_or(RenderPassErrorInner::InvalidBindGroup(i)) + .map_pass_err(scope)?; unsafe { raw.set_bind_group( pipeline.layout.raw(), @@ -1639,7 +1651,7 @@ impl Global { .map_pass_err(scope)?; let buf_raw = buffer .raw - .as_ref() + .get(&snatch_guard) .ok_or(RenderCommandError::DestroyedBuffer(buffer_id)) .map_pass_err(scope)?; @@ -1701,7 +1713,7 @@ impl Global { .map_pass_err(scope)?; let buf_raw = buffer .raw - .as_ref() + .get(&snatch_guard) .ok_or(RenderCommandError::DestroyedBuffer(buffer_id)) .map_pass_err(scope)?; @@ -1991,7 +2003,7 @@ impl Global { .map_pass_err(scope)?; let indirect_raw = indirect_buffer .raw - .as_ref() + .get(&snatch_guard) .ok_or(RenderCommandError::DestroyedBuffer(buffer_id)) .map_pass_err(scope)?; @@ -2063,7 +2075,7 @@ impl Global { .map_pass_err(scope)?; let indirect_raw = indirect_buffer .raw - .as_ref() + .get(&snatch_guard) .ok_or(RenderCommandError::DestroyedBuffer(buffer_id)) .map_pass_err(scope)?; @@ -2080,7 +2092,7 @@ impl Global { .map_pass_err(scope)?; let count_raw = count_buffer .raw - .as_ref() + .get(&snatch_guard) .ok_or(RenderCommandError::DestroyedBuffer(count_buffer_id)) .map_pass_err(scope)?; @@ -2328,6 +2340,9 @@ impl Global { ExecutionError::DestroyedBuffer(id) => { RenderCommandError::DestroyedBuffer(id) } + ExecutionError::InvalidBindGroup(id) => { + RenderCommandError::InvalidBindGroup(id) + } ExecutionError::Unimplemented(what) => { RenderCommandError::Unimplemented(what) } @@ -2385,7 +2400,12 @@ impl Global { .map_err(RenderCommandError::InvalidQuerySet) .map_pass_err(PassErrorScope::QueryReset)?; - super::CommandBuffer::insert_barriers_from_scope(transit, tracker, &scope); + super::CommandBuffer::insert_barriers_from_scope( + transit, + tracker, + &scope, + &snatch_guard, + ); } *status = CommandEncoderStatus::Recording; diff --git a/third_party/rust/wgpu-core/src/command/transfer.rs b/third_party/rust/wgpu-core/src/command/transfer.rs index 7ec1bcaebdce5..359bfbfae3fac 100644 --- a/third_party/rust/wgpu-core/src/command/transfer.rs +++ b/third_party/rust/wgpu-core/src/command/transfer.rs @@ -597,6 +597,8 @@ impl Global { }); } + let snatch_guard = device.snatchable_lock.read(); + let (src_buffer, src_pending) = { let buffer_guard = hub.buffers.read(); let src_buffer = buffer_guard @@ -610,13 +612,13 @@ impl Global { }; let src_raw = src_buffer .raw - .as_ref() + .get(&snatch_guard) .ok_or(TransferError::InvalidBuffer(source))?; if !src_buffer.usage.contains(BufferUsages::COPY_SRC) { return Err(TransferError::MissingCopySrcUsageFlag.into()); } // expecting only a single barrier - let src_barrier = src_pending.map(|pending| pending.into_hal(&src_buffer)); + let src_barrier = src_pending.map(|pending| pending.into_hal(&src_buffer, &snatch_guard)); let (dst_buffer, dst_pending) = { let buffer_guard = hub.buffers.read(); @@ -631,12 +633,12 @@ impl Global { }; let dst_raw = dst_buffer .raw - .as_ref() + .get(&snatch_guard) .ok_or(TransferError::InvalidBuffer(destination))?; if !dst_buffer.usage.contains(BufferUsages::COPY_DST) { return Err(TransferError::MissingCopyDstUsageFlag(Some(destination), None).into()); } - let dst_barrier = dst_pending.map(|pending| pending.into_hal(&dst_buffer)); + let dst_barrier = dst_pending.map(|pending| pending.into_hal(&dst_buffer, &snatch_guard)); if size % wgt::COPY_BUFFER_ALIGNMENT != 0 { return Err(TransferError::UnalignedCopySize(size).into()); @@ -795,6 +797,8 @@ impl Global { &texture_guard, )?; + let snatch_guard = device.snatchable_lock.read(); + let (src_buffer, src_pending) = { let buffer_guard = hub.buffers.read(); let src_buffer = buffer_guard @@ -807,12 +811,12 @@ impl Global { }; let src_raw = src_buffer .raw - .as_ref() + .get(&snatch_guard) .ok_or(TransferError::InvalidBuffer(source.buffer))?; if !src_buffer.usage.contains(BufferUsages::COPY_SRC) { return Err(TransferError::MissingCopySrcUsageFlag.into()); } - let src_barrier = src_pending.map(|pending| pending.into_hal(&src_buffer)); + let src_barrier = src_pending.map(|pending| pending.into_hal(&src_buffer, &snatch_guard)); let dst_pending = tracker .textures @@ -953,6 +957,8 @@ impl Global { &texture_guard, )?; + let snatch_guard = device.snatchable_lock.read(); + let src_pending = tracker .textures .set_single(src_texture, src_range, hal::TextureUses::COPY_SRC) @@ -993,14 +999,14 @@ impl Global { }; let dst_raw = dst_buffer .raw - .as_ref() + .get(&snatch_guard) .ok_or(TransferError::InvalidBuffer(destination.buffer))?; if !dst_buffer.usage.contains(BufferUsages::COPY_DST) { return Err( TransferError::MissingCopyDstUsageFlag(Some(destination.buffer), None).into(), ); } - let dst_barrier = dst_pending.map(|pending| pending.into_hal(&dst_buffer)); + let dst_barrier = dst_pending.map(|pending| pending.into_hal(&dst_buffer, &snatch_guard)); if !src_base.aspect.is_one() { return Err(TransferError::CopyAspectNotOne.into()); diff --git a/third_party/rust/wgpu-core/src/device/global.rs b/third_party/rust/wgpu-core/src/device/global.rs index 7a6caec6c99cd..9575979c8d2e0 100644 --- a/third_party/rust/wgpu-core/src/device/global.rs +++ b/third_party/rust/wgpu-core/src/device/global.rs @@ -3,8 +3,8 @@ use crate::device::trace; use crate::{ api_log, binding_model, command, conv, device::{ - life::WaitIdleError, map_buffer, queue, DeviceError, DeviceLostClosure, HostMap, - IMPLICIT_BIND_GROUP_LAYOUT_ERROR_LABEL, + life::WaitIdleError, map_buffer, queue, DeviceError, DeviceLostClosure, DeviceLostReason, + HostMap, IMPLICIT_BIND_GROUP_LAYOUT_ERROR_LABEL, }, global::Global, hal_api::HalApi, @@ -14,17 +14,24 @@ use crate::{ instance::{self, Adapter, Surface}, pipeline, present, resource::{self, BufferAccessResult}, - resource::{BufferAccessError, BufferMapOperation, Resource}, + resource::{BufferAccessError, BufferMapOperation, CreateBufferError, Resource}, validation::check_buffer_usage, FastHashMap, Label, LabelHelpers as _, }; +use arrayvec::ArrayVec; use hal::Device as _; use parking_lot::RwLock; use wgt::{BufferAddress, TextureFormat}; -use std::{borrow::Cow, iter, ops::Range, ptr, sync::atomic::Ordering}; +use std::{ + borrow::Cow, + iter, + ops::Range, + ptr, + sync::{atomic::Ordering, Arc}, +}; use super::{ImplicitPipelineIds, InvalidDevice, UserClosures}; @@ -140,12 +147,13 @@ impl Global { device_id: DeviceId, desc: &resource::BufferDescriptor, id_in: Input, - ) -> (id::BufferId, Option) { + ) -> (id::BufferId, Option) { profiling::scope!("Device::create_buffer"); let hub = A::hub(self); let fid = hub.buffers.prepare::(id_in); + let mut to_destroy: ArrayVec, 2> = ArrayVec::new(); let error = loop { let device = match hub.devices.get(device_id) { Ok(device) => device, @@ -159,11 +167,7 @@ impl Global { if desc.usage.is_empty() { // Per spec, `usage` must not be zero. - let id = fid.assign_error(desc.label.borrow_or_default()); - return ( - id, - Some(resource::CreateBufferError::InvalidUsage(desc.usage)), - ); + break CreateBufferError::InvalidUsage(desc.usage); } #[cfg(feature = "trace")] @@ -179,36 +183,27 @@ impl Global { let buffer = match device.create_buffer(desc, false) { Ok(buffer) => buffer, Err(e) => { - let id = fid.assign_error(desc.label.borrow_or_default()); - return (id, Some(e)); + break e; } }; - let (id, resource) = fid.assign(buffer); - api_log!("Device::create_buffer({desc:?}) -> {id:?}"); - let buffer_use = if !desc.mapped_at_creation { hal::BufferUses::empty() } else if desc.usage.contains(wgt::BufferUsages::MAP_WRITE) { // buffer is mappable, so we are just doing that at start - let map_size = resource.size; + let map_size = buffer.size; let ptr = if map_size == 0 { std::ptr::NonNull::dangling() } else { - match map_buffer(device.raw(), &resource, 0, map_size, HostMap::Write) { + match map_buffer(device.raw(), &buffer, 0, map_size, HostMap::Write) { Ok(ptr) => ptr, Err(e) => { - device.lock_life().schedule_resource_destruction( - queue::TempResource::Buffer(resource), - !0, - ); - hub.buffers - .force_replace_with_error(id, desc.label.borrow_or_default()); - return (id, Some(e.into())); + to_destroy.push(buffer); + break e.into(); } } }; - *resource.map_state.lock() = resource::BufferMapState::Active { + *buffer.map_state.lock() = resource::BufferMapState::Active { ptr, range: 0..map_size, host: HostMap::Write, @@ -227,45 +222,33 @@ impl Global { let stage = match device.create_buffer(&stage_desc, true) { Ok(stage) => stage, Err(e) => { - device.lock_life().schedule_resource_destruction( - queue::TempResource::Buffer(resource), - !0, - ); - hub.buffers - .force_replace_with_error(id, desc.label.borrow_or_default()); - return (id, Some(e)); + to_destroy.push(buffer); + break e; } }; - let stage_fid = hub.buffers.request(); - let stage = stage_fid.init(stage); - let mapping = match unsafe { device.raw().map_buffer(stage.raw(), 0..stage.size) } { + let snatch_guard = device.snatchable_lock.read(); + let stage_raw = stage.raw(&snatch_guard).unwrap(); + let mapping = match unsafe { device.raw().map_buffer(stage_raw, 0..stage.size) } { Ok(mapping) => mapping, Err(e) => { - let mut life_lock = device.lock_life(); - life_lock.schedule_resource_destruction( - queue::TempResource::Buffer(resource), - !0, - ); - life_lock - .schedule_resource_destruction(queue::TempResource::Buffer(stage), !0); - hub.buffers - .force_replace_with_error(id, desc.label.borrow_or_default()); - return (id, Some(DeviceError::from(e).into())); + to_destroy.push(buffer); + to_destroy.push(stage); + break CreateBufferError::Device(e.into()); } }; - assert_eq!(resource.size % wgt::COPY_BUFFER_ALIGNMENT, 0); + let stage_fid = hub.buffers.request(); + let stage = stage_fid.init(stage); + + assert_eq!(buffer.size % wgt::COPY_BUFFER_ALIGNMENT, 0); // Zero initialize memory and then mark both staging and buffer as initialized // (it's guaranteed that this is the case by the time the buffer is usable) - unsafe { ptr::write_bytes(mapping.ptr.as_ptr(), 0, resource.size as usize) }; - resource - .initialization_status - .write() - .drain(0..resource.size); - stage.initialization_status.write().drain(0..resource.size); - - *resource.map_state.lock() = resource::BufferMapState::Init { + unsafe { ptr::write_bytes(mapping.ptr.as_ptr(), 0, buffer.size as usize) }; + buffer.initialization_status.write().drain(0..buffer.size); + stage.initialization_status.write().drain(0..buffer.size); + + *buffer.map_state.lock() = resource::BufferMapState::Init { ptr: mapping.ptr, needs_flush: !mapping.is_coherent, stage_buffer: stage, @@ -273,6 +256,9 @@ impl Global { hal::BufferUses::COPY_DST }; + let (id, resource) = fid.assign(buffer); + api_log!("Device::create_buffer({desc:?}) -> {id:?}"); + device .trackers .lock() @@ -282,6 +268,15 @@ impl Global { return (id, None); }; + // Error path + + for buffer in to_destroy { + let device = Arc::clone(&buffer.device); + device + .lock_life() + .schedule_resource_destruction(queue::TempResource::Buffer(Arc::new(buffer)), !0); + } + let id = fid.assign_error(desc.label.borrow_or_default()); (id, Some(error)) } @@ -380,6 +375,7 @@ impl Global { .devices .get(device_id) .map_err(|_| DeviceError::Invalid)?; + let snatch_guard = device.snatchable_lock.read(); if !device.is_valid() { return Err(DeviceError::Lost.into()); } @@ -402,7 +398,9 @@ impl Global { }); } - let raw_buf = buffer.raw(); + let raw_buf = buffer + .raw(&snatch_guard) + .ok_or(BufferAccessError::Destroyed)?; unsafe { let mapping = device .raw() @@ -443,6 +441,8 @@ impl Global { return Err(DeviceError::Lost.into()); } + let snatch_guard = device.snatchable_lock.read(); + let buffer = hub .buffers .get(buffer_id) @@ -450,7 +450,9 @@ impl Global { check_buffer_usage(buffer.usage, wgt::BufferUsages::MAP_READ)?; //assert!(buffer isn't used by the GPU); - let raw_buf = buffer.raw(); + let raw_buf = buffer + .raw(&snatch_guard) + .ok_or(BufferAccessError::Destroyed)?; unsafe { let mapping = device .raw() @@ -485,10 +487,15 @@ impl Global { let hub = A::hub(self); - let mut buffer_guard = hub.buffers.write(); - let buffer = buffer_guard - .get_and_mark_destroyed(buffer_id) - .map_err(|_| resource::DestroyError::Invalid)?; + let buffer = { + let mut buffer_guard = hub.buffers.write(); + buffer_guard + .get_and_mark_destroyed(buffer_id) + .map_err(|_| resource::DestroyError::Invalid)? + }; + + let _ = buffer.unmap(); + buffer.destroy() } @@ -498,36 +505,40 @@ impl Global { let hub = A::hub(self); - if let Some(buffer) = hub.buffers.unregister(buffer_id) { - if buffer.ref_count() == 1 { - buffer.destroy().ok(); + let buffer = match hub.buffers.unregister(buffer_id) { + Some(buffer) => buffer, + None => { + return; } + }; - let last_submit_index = buffer.info.submission_index(); + let _ = buffer.unmap(); - let device = buffer.device.clone(); + let last_submit_index = buffer.info.submission_index(); - if device - .pending_writes - .lock() - .as_ref() - .unwrap() - .dst_buffers - .contains_key(&buffer_id) - { - device.lock_life().future_suspected_buffers.push(buffer); - } else { - device - .lock_life() - .suspected_resources - .insert(buffer_id, buffer); - } + let device = buffer.device.clone(); - if wait { - match device.wait_for_submit(last_submit_index) { - Ok(()) => (), - Err(e) => log::error!("Failed to wait for buffer {:?}: {}", buffer_id, e), - } + if device + .pending_writes + .lock() + .as_ref() + .unwrap() + .dst_buffers + .contains_key(&buffer_id) + { + device.lock_life().future_suspected_buffers.push(buffer); + } else { + device + .lock_life() + .suspected_resources + .buffers + .insert(buffer_id, buffer); + } + + if wait { + match device.wait_for_submit(last_submit_index) { + Ok(()) => (), + Err(e) => log::error!("Failed to wait for buffer {:?}: {}", buffer_id, e), } } } @@ -665,7 +676,7 @@ impl Global { device_id: DeviceId, desc: &resource::BufferDescriptor, id_in: Input, - ) -> (id::BufferId, Option) { + ) -> (id::BufferId, Option) { profiling::scope!("Device::create_buffer"); let hub = A::hub(self); @@ -783,6 +794,7 @@ impl Global { device .lock_life() .suspected_resources + .textures .insert(texture_id, texture.clone()); } } @@ -860,6 +872,7 @@ impl Global { view.device .lock_life() .suspected_resources + .texture_views .insert(texture_view_id, view.clone()); if wait { @@ -930,6 +943,7 @@ impl Global { .device .lock_life() .suspected_resources + .samplers .insert(sampler_id, sampler.clone()); } } @@ -1016,6 +1030,7 @@ impl Global { .device .lock_life() .suspected_resources + .bind_group_layouts .insert(bind_group_layout_id, layout.clone()); } } @@ -1079,6 +1094,7 @@ impl Global { .device .lock_life() .suspected_resources + .pipeline_layouts .insert(pipeline_layout_id, layout.clone()); } } @@ -1153,6 +1169,7 @@ impl Global { .device .lock_life() .suspected_resources + .bind_groups .insert(bind_group_id, bind_group.clone()); } } @@ -1447,6 +1464,7 @@ impl Global { .device .lock_life() .suspected_resources + .render_bundles .insert(render_bundle_id, bundle.clone()); } } @@ -1516,6 +1534,7 @@ impl Global { device .lock_life() .suspected_resources + .query_sets .insert(query_set_id, query_set.clone()); } } @@ -1652,10 +1671,12 @@ impl Global { let mut life_lock = device.lock_life(); life_lock .suspected_resources + .render_pipelines .insert(render_pipeline_id, pipeline.clone()); life_lock .suspected_resources + .pipeline_layouts .insert(layout_id, pipeline.layout.clone()); } } @@ -1787,9 +1808,11 @@ impl Global { let mut life_lock = device.lock_life(); life_lock .suspected_resources + .compute_pipelines .insert(compute_pipeline_id, pipeline.clone()); life_lock .suspected_resources + .pipeline_layouts .insert(layout_id, pipeline.layout.clone()); } } @@ -2225,6 +2248,11 @@ impl Global { let hub = A::hub(self); if let Some(device) = hub.devices.unregister(device_id) { + let device_lost_closure = device.lock_life().device_lost_closure.take(); + if let Some(closure) = device_lost_closure { + closure.call(DeviceLostReason::Unknown, String::from("Device dropped.")); + } + // The things `Device::prepare_to_die` takes care are mostly // unnecessary here. We know our queue is empty, so we don't // need to wait for submissions or triage them. We know we were @@ -2240,6 +2268,8 @@ impl Global { } } + // This closure will be called exactly once during "lose the device" + // or when the device is dropped, if it was never lost. pub fn device_set_device_lost_closure( &self, device_id: DeviceId, @@ -2406,7 +2436,8 @@ impl Global { let mut trackers = buffer.device.as_ref().trackers.lock(); trackers.buffers.set_single(&buffer, internal_use); //TODO: Check if draining ALL buffers is correct! - let _ = trackers.buffers.drain_transitions(); + let snatch_guard = device.snatchable_lock.read(); + let _ = trackers.buffers.drain_transitions(&snatch_guard); } buffer @@ -2488,27 +2519,17 @@ impl Global { profiling::scope!("unmap", "Buffer"); api_log!("Buffer::unmap {buffer_id:?}"); - let closure; - { - // Restrict the locks to this scope. - let hub = A::hub(self); + let hub = A::hub(self); - let buffer = hub - .buffers - .get(buffer_id) - .map_err(|_| BufferAccessError::Invalid)?; - if !buffer.device.is_valid() { - return Err(DeviceError::Lost.into()); - } - closure = buffer.buffer_unmap_inner() - } + let buffer = hub + .buffers + .get(buffer_id) + .map_err(|_| BufferAccessError::Invalid)?; - // Note: outside the scope where locks are held when calling the callback - if let Some((mut operation, status)) = closure? { - if let Some(callback) = operation.callback.take() { - callback.call(status); - } + if !buffer.device.is_valid() { + return Err(DeviceError::Lost.into()); } - Ok(()) + + buffer.unmap() } } diff --git a/third_party/rust/wgpu-core/src/device/life.rs b/third_party/rust/wgpu-core/src/device/life.rs index 0193d0987bfa8..08e75ce00a57c 100644 --- a/third_party/rust/wgpu-core/src/device/life.rs +++ b/third_party/rust/wgpu-core/src/device/life.rs @@ -15,7 +15,7 @@ use crate::{ }, pipeline::{ComputePipeline, RenderPipeline}, resource::{ - self, Buffer, QuerySet, Resource, ResourceType, Sampler, StagingBuffer, Texture, + self, Buffer, DestroyedBuffer, QuerySet, Resource, Sampler, StagingBuffer, Texture, TextureView, }, track::{ResourceTracker, Tracker}, @@ -24,101 +24,106 @@ use crate::{ use smallvec::SmallVec; use parking_lot::Mutex; +use std::sync::Arc; use thiserror::Error; -use wgt::WasmNotSendSync; - -use std::{any::Any, sync::Arc}; - -pub(crate) trait ResourceMap: Any + WasmNotSendSync { - fn as_any(&self) -> &dyn Any; - fn as_any_mut(&mut self) -> &mut dyn Any; - fn clear_map(&mut self); - fn extend_map(&mut self, maps: &mut ResourceMaps); -} - -impl ResourceMap for FastHashMap> -where - Id: id::TypedId, - R: Resource, -{ - fn as_any(&self) -> &dyn Any { - self - } - fn as_any_mut(&mut self) -> &mut dyn Any { - self - } - fn clear_map(&mut self) { - self.clear() - } - fn extend_map(&mut self, r: &mut ResourceMaps) { - if let Some(other) = r.maps.get_mut(R::TYPE) { - if let Some(other) = other.as_any_mut().downcast_mut::() { - self.extend(other.drain()); - } - } - } -} /// A struct that keeps lists of resources that are no longer needed by the user. #[derive(Default)] -pub(crate) struct ResourceMaps { - pub(crate) maps: FastHashMap>, +pub(crate) struct ResourceMaps { + pub buffers: FastHashMap>>, + pub staging_buffers: FastHashMap>>, + pub textures: FastHashMap>>, + pub texture_views: FastHashMap>>, + pub samplers: FastHashMap>>, + pub bind_groups: FastHashMap>>, + pub bind_group_layouts: FastHashMap>>, + pub render_pipelines: FastHashMap>>, + pub compute_pipelines: FastHashMap>>, + pub pipeline_layouts: FastHashMap>>, + pub render_bundles: FastHashMap>>, + pub query_sets: FastHashMap>>, + pub destroyed_buffers: FastHashMap>>, } -impl ResourceMaps { - fn add_type(&mut self) -> &mut Self - where - Id: id::TypedId, - R: Resource, - { - let map = FastHashMap::>::default(); - self.maps.insert(R::TYPE, Box::new(map)); - self - } - fn map_mut(&mut self) -> &mut FastHashMap> - where - Id: id::TypedId, - R: Resource, - { - let map = self - .maps - .entry(R::TYPE) - .or_insert_with(|| Box::>>::default()); - let any_map = map.as_mut().as_any_mut(); - let map = any_map.downcast_mut::>>().unwrap(); - map - } - pub(crate) fn new() -> Self { - let mut maps = Self::default(); - maps.add_type::>(); - maps.add_type::>(); - maps.add_type::>(); - maps.add_type::>(); - maps.add_type::>(); - maps.add_type::>(); - maps.add_type::>(); - maps.add_type::>(); - maps.add_type::>(); - maps.add_type::>(); - maps.add_type::>(); - maps.add_type::>(); - maps +impl ResourceMaps { + pub(crate) fn new() -> Self { + ResourceMaps { + buffers: FastHashMap::default(), + staging_buffers: FastHashMap::default(), + textures: FastHashMap::default(), + texture_views: FastHashMap::default(), + samplers: FastHashMap::default(), + bind_groups: FastHashMap::default(), + bind_group_layouts: FastHashMap::default(), + render_pipelines: FastHashMap::default(), + compute_pipelines: FastHashMap::default(), + pipeline_layouts: FastHashMap::default(), + render_bundles: FastHashMap::default(), + query_sets: FastHashMap::default(), + destroyed_buffers: FastHashMap::default(), + } } + pub(crate) fn clear(&mut self) { - self.maps.iter_mut().for_each(|(_t, map)| map.clear_map()); + let ResourceMaps { + buffers, + staging_buffers, + textures, + texture_views, + samplers, + bind_groups, + bind_group_layouts, + render_pipelines, + compute_pipelines, + pipeline_layouts, + render_bundles, + query_sets, + destroyed_buffers, + } = self; + buffers.clear(); + staging_buffers.clear(); + textures.clear(); + texture_views.clear(); + samplers.clear(); + bind_groups.clear(); + bind_group_layouts.clear(); + render_pipelines.clear(); + compute_pipelines.clear(); + pipeline_layouts.clear(); + render_bundles.clear(); + query_sets.clear(); + destroyed_buffers.clear(); } + pub(crate) fn extend(&mut self, mut other: Self) { - self.maps.iter_mut().for_each(|(_t, map)| { - map.extend_map(&mut other); - }); - } - pub(crate) fn insert(&mut self, id: Id, r: Arc) -> &mut Self - where - Id: id::TypedId, - R: Resource, - { - self.map_mut().insert(id, r); - self + let ResourceMaps { + buffers, + staging_buffers, + textures, + texture_views, + samplers, + bind_groups, + bind_group_layouts, + render_pipelines, + compute_pipelines, + pipeline_layouts, + render_bundles, + query_sets, + destroyed_buffers, + } = self; + buffers.extend(other.buffers.drain()); + staging_buffers.extend(other.staging_buffers.drain()); + textures.extend(other.textures.drain()); + texture_views.extend(other.texture_views.drain()); + samplers.extend(other.samplers.drain()); + bind_groups.extend(other.bind_groups.drain()); + bind_group_layouts.extend(other.bind_group_layouts.drain()); + render_pipelines.extend(other.render_pipelines.drain()); + compute_pipelines.extend(other.compute_pipelines.drain()); + pipeline_layouts.extend(other.pipeline_layouts.drain()); + render_bundles.extend(other.render_bundles.drain()); + query_sets.extend(other.query_sets.drain()); + destroyed_buffers.extend(other.destroyed_buffers.drain()); } } @@ -140,7 +145,7 @@ struct ActiveSubmission { /// This includes things like temporary resources and resources that are /// used by submitted commands but have been dropped by the user (meaning that /// this submission is their last reference.) - last_resources: ResourceMaps, + last_resources: ResourceMaps, /// Buffers to be mapped once this submission has completed. mapped: Vec>>, @@ -214,7 +219,7 @@ pub(crate) struct LifetimeTracker { /// Resources whose user handle has died (i.e. drop/destroy has been called) /// and will likely be ready for destruction soon. - pub suspected_resources: ResourceMaps, + pub suspected_resources: ResourceMaps, /// Resources used by queue submissions still in flight. One entry per /// submission, with older submissions appearing before younger. @@ -229,14 +234,14 @@ pub(crate) struct LifetimeTracker { /// These are freed by `LifeTracker::cleanup`, which is called from periodic /// maintenance functions like `Global::device_poll`, and when a device is /// destroyed. - free_resources: ResourceMaps, + free_resources: ResourceMaps, /// Buffers the user has asked us to map, and which are not used by any /// queue submission still in flight. ready_to_map: Vec>>, /// Queue "on_submitted_work_done" closures that were initiated for while there is no - /// currently pending submissions. These cannot be immeidately invoked as they + /// currently pending submissions. These cannot be immediately invoked as they /// must happen _after_ all mapped buffer callbacks are mapped, so we defer them /// here until the next time the device is maintained. work_done_closures: SmallVec<[SubmittedWorkDoneClosure; 1]>, @@ -253,9 +258,9 @@ impl LifetimeTracker { mapped: Vec::new(), future_suspected_buffers: Vec::new(), future_suspected_textures: Vec::new(), - suspected_resources: ResourceMaps::new::(), + suspected_resources: ResourceMaps::new(), active: Vec::new(), - free_resources: ResourceMaps::new::(), + free_resources: ResourceMaps::new(), ready_to_map: Vec::new(), work_done_closures: SmallVec::new(), device_lost_closure: None, @@ -274,17 +279,24 @@ impl LifetimeTracker { temp_resources: impl Iterator>, encoders: Vec>, ) { - let mut last_resources = ResourceMaps::new::(); + let mut last_resources = ResourceMaps::new(); for res in temp_resources { match res { TempResource::Buffer(raw) => { - last_resources.insert(raw.as_info().id(), raw); + last_resources.buffers.insert(raw.as_info().id(), raw); } TempResource::StagingBuffer(raw) => { - last_resources.insert(raw.as_info().id(), raw); + last_resources + .staging_buffers + .insert(raw.as_info().id(), raw); + } + TempResource::DestroyedBuffer(destroyed) => { + last_resources + .destroyed_buffers + .insert(destroyed.id, destroyed); } TempResource::Texture(raw) => { - last_resources.insert(raw.as_info().id(), raw); + last_resources.textures.insert(raw.as_info().id(), raw); } } } @@ -300,10 +312,12 @@ impl LifetimeTracker { pub fn post_submit(&mut self) { for v in self.future_suspected_buffers.drain(..).take(1) { - self.suspected_resources.insert(v.as_info().id(), v); + self.suspected_resources.buffers.insert(v.as_info().id(), v); } for v in self.future_suspected_textures.drain(..).take(1) { - self.suspected_resources.insert(v.as_info().id(), v); + self.suspected_resources + .textures + .insert(v.as_info().id(), v); } } @@ -379,13 +393,16 @@ impl LifetimeTracker { .map_or(&mut self.free_resources, |a| &mut a.last_resources); match temp_resource { TempResource::Buffer(raw) => { - resources.insert(raw.as_info().id(), raw); + resources.buffers.insert(raw.as_info().id(), raw); } TempResource::StagingBuffer(raw) => { - resources.insert(raw.as_info().id(), raw); + resources.staging_buffers.insert(raw.as_info().id(), raw); + } + TempResource::DestroyedBuffer(destroyed) => { + resources.destroyed_buffers.insert(destroyed.id, destroyed); } TempResource::Texture(raw) => { - resources.insert(raw.as_info().id(), raw); + resources.textures.insert(raw.as_info().id(), raw); } } } @@ -408,8 +425,9 @@ impl LifetimeTracker { fn triage_resources( resources_map: &mut FastHashMap>, active: &mut [ActiveSubmission], - free_resources: &mut ResourceMaps, + free_resources: &mut ResourceMaps, trackers: &mut impl ResourceTracker, + get_resource_map: impl Fn(&mut ResourceMaps) -> &mut FastHashMap>, mut on_remove: T, ) -> Vec> where @@ -429,7 +447,7 @@ impl LifetimeTracker { if is_removed { on_remove(&id, resource); removed_resources.push(resource.clone()); - non_referenced_resources.insert(id, resource.clone()); + get_resource_map(non_referenced_resources).insert(id, resource.clone()); } !is_removed }); @@ -442,12 +460,13 @@ impl LifetimeTracker { #[cfg(feature = "trace")] trace: &mut Option<&mut trace::Trace>, ) -> &mut Self { let mut trackers = trackers.lock(); - let resource_map = self.suspected_resources.map_mut(); + let resource_map = &mut self.suspected_resources.render_bundles; let mut removed_resources = Self::triage_resources( resource_map, self.active.as_mut_slice(), &mut self.free_resources, &mut trackers.bundles, + |maps| &mut maps.render_bundles, |_bundle_id, _bundle| { #[cfg(feature = "trace")] if let Some(ref mut t) = *trace { @@ -457,19 +476,27 @@ impl LifetimeTracker { ); removed_resources.drain(..).for_each(|bundle| { for v in bundle.used.buffers.write().drain_resources() { - self.suspected_resources.insert(v.as_info().id(), v); + self.suspected_resources.buffers.insert(v.as_info().id(), v); } for v in bundle.used.textures.write().drain_resources() { - self.suspected_resources.insert(v.as_info().id(), v); + self.suspected_resources + .textures + .insert(v.as_info().id(), v); } for v in bundle.used.bind_groups.write().drain_resources() { - self.suspected_resources.insert(v.as_info().id(), v); + self.suspected_resources + .bind_groups + .insert(v.as_info().id(), v); } for v in bundle.used.render_pipelines.write().drain_resources() { - self.suspected_resources.insert(v.as_info().id(), v); + self.suspected_resources + .render_pipelines + .insert(v.as_info().id(), v); } for v in bundle.used.query_sets.write().drain_resources() { - self.suspected_resources.insert(v.as_info().id(), v); + self.suspected_resources + .query_sets + .insert(v.as_info().id(), v); } }); self @@ -481,12 +508,13 @@ impl LifetimeTracker { #[cfg(feature = "trace")] trace: &mut Option<&mut trace::Trace>, ) -> &mut Self { let mut trackers = trackers.lock(); - let resource_map = self.suspected_resources.map_mut(); + let resource_map = &mut self.suspected_resources.bind_groups; let mut removed_resource = Self::triage_resources( resource_map, self.active.as_mut_slice(), &mut self.free_resources, &mut trackers.bind_groups, + |maps| &mut maps.bind_groups, |_bind_group_id, _bind_group| { #[cfg(feature = "trace")] if let Some(ref mut t) = *trace { @@ -496,23 +524,26 @@ impl LifetimeTracker { ); removed_resource.drain(..).for_each(|bind_group| { for v in bind_group.used.buffers.drain_resources() { - self.suspected_resources.insert(v.as_info().id(), v); + self.suspected_resources.buffers.insert(v.as_info().id(), v); } for v in bind_group.used.textures.drain_resources() { - self.suspected_resources.insert(v.as_info().id(), v); + self.suspected_resources + .textures + .insert(v.as_info().id(), v); } for v in bind_group.used.views.drain_resources() { - self.suspected_resources.insert(v.as_info().id(), v); + self.suspected_resources + .texture_views + .insert(v.as_info().id(), v); } for v in bind_group.used.samplers.drain_resources() { - self.suspected_resources.insert(v.as_info().id(), v); + self.suspected_resources + .samplers + .insert(v.as_info().id(), v); } - //Releasing safely unused resources to decrement refcount - bind_group.used_buffer_ranges.write().clear(); - bind_group.used_texture_ranges.write().clear(); - bind_group.dynamic_binding_info.write().clear(); self.suspected_resources + .bind_group_layouts .insert(bind_group.layout.as_info().id(), bind_group.layout.clone()); }); self @@ -524,12 +555,13 @@ impl LifetimeTracker { #[cfg(feature = "trace")] trace: &mut Option<&mut trace::Trace>, ) -> &mut Self { let mut trackers = trackers.lock(); - let resource_map = self.suspected_resources.map_mut(); + let resource_map = &mut self.suspected_resources.texture_views; let mut removed_resources = Self::triage_resources( resource_map, self.active.as_mut_slice(), &mut self.free_resources, &mut trackers.views, + |maps| &mut maps.texture_views, |_texture_view_id, _texture_view| { #[cfg(feature = "trace")] if let Some(ref mut t) = *trace { @@ -541,6 +573,7 @@ impl LifetimeTracker { let mut lock = texture_view.parent.write(); if let Some(parent_texture) = lock.take() { self.suspected_resources + .textures .insert(parent_texture.as_info().id(), parent_texture); } }); @@ -553,12 +586,13 @@ impl LifetimeTracker { #[cfg(feature = "trace")] trace: &mut Option<&mut trace::Trace>, ) -> &mut Self { let mut trackers = trackers.lock(); - let resource_map = self.suspected_resources.map_mut(); + let resource_map = &mut self.suspected_resources.textures; Self::triage_resources( resource_map, self.active.as_mut_slice(), &mut self.free_resources, &mut trackers.textures, + |maps| &mut maps.textures, |_texture_id, _texture| { #[cfg(feature = "trace")] if let Some(ref mut t) = *trace { @@ -575,12 +609,13 @@ impl LifetimeTracker { #[cfg(feature = "trace")] trace: &mut Option<&mut trace::Trace>, ) -> &mut Self { let mut trackers = trackers.lock(); - let resource_map = self.suspected_resources.map_mut(); + let resource_map = &mut self.suspected_resources.samplers; Self::triage_resources( resource_map, self.active.as_mut_slice(), &mut self.free_resources, &mut trackers.samplers, + |maps| &mut maps.samplers, |_sampler_id, _sampler| { #[cfg(feature = "trace")] if let Some(ref mut t) = *trace { @@ -597,12 +632,13 @@ impl LifetimeTracker { #[cfg(feature = "trace")] trace: &mut Option<&mut trace::Trace>, ) -> &mut Self { let mut trackers = trackers.lock(); - let resource_map = self.suspected_resources.map_mut(); + let resource_map = &mut self.suspected_resources.buffers; let mut removed_resources = Self::triage_resources( resource_map, self.active.as_mut_slice(), &mut self.free_resources, &mut trackers.buffers, + |maps| &mut maps.buffers, |_buffer_id, _buffer| { #[cfg(feature = "trace")] if let Some(ref mut t) = *trace { @@ -616,24 +652,47 @@ impl LifetimeTracker { } = *buffer.map_state.lock() { self.free_resources + .buffers .insert(stage_buffer.as_info().id(), stage_buffer.clone()); } }); self } + fn triage_suspected_destroyed_buffers( + &mut self, + #[cfg(feature = "trace")] trace: &mut Option<&mut trace::Trace>, + ) { + for (id, buffer) in self.suspected_resources.destroyed_buffers.drain() { + let submit_index = buffer.submission_index; + if let Some(resources) = self.active.iter_mut().find(|a| a.index == submit_index) { + resources + .last_resources + .destroyed_buffers + .insert(id, buffer); + } else { + self.free_resources.destroyed_buffers.insert(id, buffer); + } + #[cfg(feature = "trace")] + if let Some(ref mut t) = *trace { + t.add(trace::Action::DestroyBuffer(id)); + } + } + } + fn triage_suspected_compute_pipelines( &mut self, trackers: &Mutex>, #[cfg(feature = "trace")] trace: &mut Option<&mut trace::Trace>, ) -> &mut Self { let mut trackers = trackers.lock(); - let resource_map = self.suspected_resources.map_mut(); + let resource_map = &mut self.suspected_resources.compute_pipelines; let mut removed_resources = Self::triage_resources( resource_map, self.active.as_mut_slice(), &mut self.free_resources, &mut trackers.compute_pipelines, + |maps| &mut maps.compute_pipelines, |_compute_pipeline_id, _compute_pipeline| { #[cfg(feature = "trace")] if let Some(ref mut t) = *trace { @@ -642,7 +701,7 @@ impl LifetimeTracker { }, ); removed_resources.drain(..).for_each(|compute_pipeline| { - self.suspected_resources.insert( + self.suspected_resources.pipeline_layouts.insert( compute_pipeline.layout.as_info().id(), compute_pipeline.layout.clone(), ); @@ -656,12 +715,13 @@ impl LifetimeTracker { #[cfg(feature = "trace")] trace: &mut Option<&mut trace::Trace>, ) -> &mut Self { let mut trackers = trackers.lock(); - let resource_map = self.suspected_resources.map_mut(); + let resource_map = &mut self.suspected_resources.render_pipelines; let mut removed_resources = Self::triage_resources( resource_map, self.active.as_mut_slice(), &mut self.free_resources, &mut trackers.render_pipelines, + |maps| &mut maps.render_pipelines, |_render_pipeline_id, _render_pipeline| { #[cfg(feature = "trace")] if let Some(ref mut t) = *trace { @@ -670,7 +730,7 @@ impl LifetimeTracker { }, ); removed_resources.drain(..).for_each(|render_pipeline| { - self.suspected_resources.insert( + self.suspected_resources.pipeline_layouts.insert( render_pipeline.layout.as_info().id(), render_pipeline.layout.clone(), ); @@ -684,7 +744,7 @@ impl LifetimeTracker { ) -> &mut Self { let mut removed_resources = Vec::new(); self.suspected_resources - .map_mut::>() + .pipeline_layouts .retain(|_pipeline_layout_id, pipeline_layout| { #[cfg(feature = "trace")] if let Some(ref mut t) = *trace { @@ -696,6 +756,7 @@ impl LifetimeTracker { removed_resources.drain(..).for_each(|pipeline_layout| { for bgl in &pipeline_layout.bind_group_layouts { self.suspected_resources + .bind_group_layouts .insert(bgl.as_info().id(), bgl.clone()); } }); @@ -706,9 +767,8 @@ impl LifetimeTracker { &mut self, #[cfg(feature = "trace")] trace: &mut Option<&mut trace::Trace>, ) -> &mut Self { - self.suspected_resources - .map_mut::>() - .retain(|bind_group_layout_id, bind_group_layout| { + self.suspected_resources.bind_group_layouts.retain( + |bind_group_layout_id, bind_group_layout| { //Note: this has to happen after all the suspected pipelines are destroyed //Note: nothing else can bump the refcount since the guard is locked exclusively //Note: same BGL can appear multiple times in the list, but only the last @@ -718,20 +778,23 @@ impl LifetimeTracker { t.add(trace::Action::DestroyBindGroupLayout(*bind_group_layout_id)); } self.free_resources + .bind_group_layouts .insert(*bind_group_layout_id, bind_group_layout.clone()); false - }); + }, + ); self } fn triage_suspected_query_sets(&mut self, trackers: &Mutex>) -> &mut Self { let mut trackers = trackers.lock(); - let resource_map = self.suspected_resources.map_mut(); + let resource_map = &mut self.suspected_resources.query_sets; Self::triage_resources( resource_map, self.active.as_mut_slice(), &mut self.free_resources, &mut trackers.query_sets, + |maps| &mut maps.query_sets, |_query_set_id, _query_set| {}, ); self @@ -739,9 +802,10 @@ impl LifetimeTracker { fn triage_suspected_staging_buffers(&mut self) -> &mut Self { self.suspected_resources - .map_mut::>() + .staging_buffers .retain(|staging_buffer_id, staging_buffer| { self.free_resources + .staging_buffers .insert(*staging_buffer_id, staging_buffer.clone()); false }); @@ -845,6 +909,10 @@ impl LifetimeTracker { #[cfg(feature = "trace")] &mut trace, ); + self.triage_suspected_destroyed_buffers( + #[cfg(feature = "trace")] + &mut trace, + ); } /// Determine which buffers are ready to map, and which must wait for the @@ -899,7 +967,9 @@ impl LifetimeTracker { if is_removed { *buffer.map_state.lock() = resource::BufferMapState::Idle; log::trace!("Buffer ready to map {:?} is not tracked anymore", buffer_id); - self.free_resources.insert(buffer_id, buffer.clone()); + self.free_resources + .buffers + .insert(buffer_id, buffer.clone()); } else { let mapping = match std::mem::replace( &mut *buffer.map_state.lock(), @@ -947,4 +1017,47 @@ impl LifetimeTracker { } pending_callbacks } + + pub(crate) fn release_gpu_resources(&mut self) { + // This is called when the device is lost, which makes every associated + // resource invalid and unusable. This is an opportunity to release all of + // the underlying gpu resources, even though the objects remain visible to + // the user agent. We purge this memory naturally when resources have been + // moved into the appropriate buckets, so this function just needs to + // initiate movement into those buckets, and it can do that by calling + // "destroy" on all the resources we know about which aren't already marked + // for cleanup. + + // During these iterations, we discard all errors. We don't care! + + // Destroy all the mapped buffers. + for buffer in &self.mapped { + let _ = buffer.destroy(); + } + + // Destroy all the unmapped buffers. + for buffer in &self.ready_to_map { + let _ = buffer.destroy(); + } + + // Destroy all the future_suspected_buffers. + for buffer in &self.future_suspected_buffers { + let _ = buffer.destroy(); + } + + // Destroy the buffers in all active submissions. + for submission in &self.active { + for buffer in &submission.mapped { + let _ = buffer.destroy(); + } + } + + // Destroy all the future_suspected_textures. + // TODO: texture.destroy is not implemented + /* + for texture in &self.future_suspected_textures { + let _ = texture.destroy(); + } + */ + } } diff --git a/third_party/rust/wgpu-core/src/device/mod.rs b/third_party/rust/wgpu-core/src/device/mod.rs index b8ebaf46c8e06..0bfa90458a5c4 100644 --- a/third_party/rust/wgpu-core/src/device/mod.rs +++ b/third_party/rust/wgpu-core/src/device/mod.rs @@ -211,7 +211,7 @@ impl UserClosures { not(target_feature = "atomics") ) ))] -pub type DeviceLostCallback = Box; +pub type DeviceLostCallback = Box; #[cfg(not(any( not(target_arch = "wasm32"), all( @@ -219,12 +219,26 @@ pub type DeviceLostCallback = Box; +pub type DeviceLostCallback = Box; + +pub struct DeviceLostClosureRust { + pub callback: DeviceLostCallback, + called: bool, +} + +impl Drop for DeviceLostClosureRust { + fn drop(&mut self) { + if !self.called { + panic!("DeviceLostClosureRust must be called before it is dropped."); + } + } +} #[repr(C)] pub struct DeviceLostClosureC { pub callback: unsafe extern "C" fn(user_data: *mut u8, reason: u8, message: *const c_char), pub user_data: *mut u8, + called: bool, } #[cfg(any( @@ -236,6 +250,14 @@ pub struct DeviceLostClosureC { ))] unsafe impl Send for DeviceLostClosureC {} +impl Drop for DeviceLostClosureC { + fn drop(&mut self) { + if !self.called { + panic!("DeviceLostClosureC must be called before it is dropped."); + } + } +} + pub struct DeviceLostClosure { // We wrap this so creating the enum in the C variant can be unsafe, // allowing our call function to be safe. @@ -249,14 +271,18 @@ pub struct DeviceLostInvocation { } enum DeviceLostClosureInner { - Rust { callback: DeviceLostCallback }, + Rust { inner: DeviceLostClosureRust }, C { inner: DeviceLostClosureC }, } impl DeviceLostClosure { pub fn from_rust(callback: DeviceLostCallback) -> Self { + let inner = DeviceLostClosureRust { + callback, + called: false, + }; Self { - inner: DeviceLostClosureInner::Rust { callback }, + inner: DeviceLostClosureInner::Rust { inner }, } } @@ -267,7 +293,14 @@ impl DeviceLostClosure { /// /// - Both pointers must point to `'static` data, as the callback may happen at /// an unspecified time. - pub unsafe fn from_c(inner: DeviceLostClosureC) -> Self { + pub unsafe fn from_c(closure: DeviceLostClosureC) -> Self { + // Build an inner with the values from closure, ensuring that + // inner.called is false. + let inner = DeviceLostClosureC { + callback: closure.callback, + user_data: closure.user_data, + called: false, + }; Self { inner: DeviceLostClosureInner::C { inner }, } @@ -275,9 +308,21 @@ impl DeviceLostClosure { pub(crate) fn call(self, reason: DeviceLostReason, message: String) { match self.inner { - DeviceLostClosureInner::Rust { callback } => callback(reason, message), + DeviceLostClosureInner::Rust { mut inner } => { + if inner.called { + panic!("DeviceLostClosureRust must only be called once."); + } + inner.called = true; + + (inner.callback)(reason, message) + } // SAFETY: the contract of the call to from_c says that this unsafe is sound. - DeviceLostClosureInner::C { inner } => unsafe { + DeviceLostClosureInner::C { mut inner } => unsafe { + if inner.called { + panic!("DeviceLostClosureC must only be called once."); + } + inner.called = true; + // Ensure message is structured as a null-terminated C string. It only // needs to live as long as the callback invocation. let message = std::ffi::CString::new(message).unwrap(); @@ -294,14 +339,18 @@ fn map_buffer( size: BufferAddress, kind: HostMap, ) -> Result, BufferAccessError> { + let snatch_guard = buffer.device.snatchable_lock.read(); + let raw_buffer = buffer + .raw(&snatch_guard) + .ok_or(BufferAccessError::Destroyed)?; let mapping = unsafe { - raw.map_buffer(buffer.raw(), offset..offset + size) + raw.map_buffer(raw_buffer, offset..offset + size) .map_err(DeviceError::from)? }; *buffer.sync_mapped_writes.lock() = match kind { HostMap::Read if !mapping.is_coherent => unsafe { - raw.invalidate_mapped_ranges(buffer.raw(), iter::once(offset..offset + size)); + raw.invalidate_mapped_ranges(raw_buffer, iter::once(offset..offset + size)); None }, HostMap::Write if !mapping.is_coherent => Some(offset..offset + size), @@ -341,7 +390,7 @@ fn map_buffer( mapped[fill_range].fill(0); if zero_init_needs_flush_now { - unsafe { raw.flush_mapped_ranges(buffer.raw(), iter::once(uninitialized)) }; + unsafe { raw.flush_mapped_ranges(raw_buffer, iter::once(uninitialized)) }; } } diff --git a/third_party/rust/wgpu-core/src/device/queue.rs b/third_party/rust/wgpu-core/src/device/queue.rs index 9a1918c0a14cf..5dff3a19abdba 100644 --- a/third_party/rust/wgpu-core/src/device/queue.rs +++ b/third_party/rust/wgpu-core/src/device/queue.rs @@ -16,8 +16,8 @@ use crate::{ identity::{GlobalIdentityHandlerFactory, Input}, init_tracker::{has_copy_partial_init_tracker_coverage, TextureInitRange}, resource::{ - Buffer, BufferAccessError, BufferMapState, Resource, ResourceInfo, ResourceType, - StagingBuffer, Texture, TextureInner, + Buffer, BufferAccessError, BufferMapState, DestroyedBuffer, Resource, ResourceInfo, + ResourceType, StagingBuffer, Texture, TextureInner, }, resource_log, track, FastHashMap, SubmissionIndex, }; @@ -163,6 +163,7 @@ pub struct WrappedSubmissionIndex { pub enum TempResource { Buffer(Arc>), StagingBuffer(Arc>), + DestroyedBuffer(Arc>), Texture(Arc>), } @@ -593,9 +594,10 @@ impl Global { .set_single(dst, hal::BufferUses::COPY_DST) .ok_or(TransferError::InvalidBuffer(buffer_id))? }; + let snatch_guard = device.snatchable_lock.read(); let dst_raw = dst .raw - .as_ref() + .get(&snatch_guard) .ok_or(TransferError::InvalidBuffer(buffer_id))?; if dst.device.as_info().id() != device.as_info().id() { @@ -618,7 +620,7 @@ impl Global { buffer: inner_buffer.as_ref().unwrap(), usage: hal::BufferUses::MAP_WRITE..hal::BufferUses::COPY_SRC, }) - .chain(transition.map(|pending| pending.into_hal(&dst))); + .chain(transition.map(|pending| pending.into_hal(&dst, &snatch_guard))); let encoder = pending_writes.activate(); unsafe { encoder.transition_buffers(barriers); @@ -1139,6 +1141,8 @@ impl Global { let mut active_executions = Vec::new(); let mut used_surface_textures = track::TextureUsageScope::new(); + let snatch_guard = device.snatchable_lock.read(); + { let mut command_buffer_guard = hub.command_buffers.write(); @@ -1150,8 +1154,7 @@ impl Global { // a temporary one, since the chains are not finished. let mut temp_suspected = device.temp_suspected.lock(); { - let mut suspected = - temp_suspected.replace(ResourceMaps::new::()).unwrap(); + let mut suspected = temp_suspected.replace(ResourceMaps::new()).unwrap(); suspected.clear(); } @@ -1207,8 +1210,8 @@ impl Global { // update submission IDs for buffer in cmd_buf_trackers.buffers.used_resources() { let id = buffer.info.id(); - let raw_buf = match buffer.raw { - Some(ref raw) => raw, + let raw_buf = match buffer.raw.get(&snatch_guard) { + Some(raw) => raw, None => { return Err(QueueSubmitError::DestroyedBuffer(id)); } @@ -1221,7 +1224,11 @@ impl Global { unsafe { device.raw().unmap_buffer(raw_buf) } .map_err(DeviceError::from)?; } - temp_suspected.as_mut().unwrap().insert(id, buffer.clone()); + temp_suspected + .as_mut() + .unwrap() + .buffers + .insert(id, buffer.clone()); } else { match *buffer.map_state.lock() { BufferMapState::Idle => (), @@ -1243,7 +1250,11 @@ impl Global { }; texture.info.use_at(submit_index); if texture.is_unique() { - temp_suspected.as_mut().unwrap().insert(id, texture.clone()); + temp_suspected + .as_mut() + .unwrap() + .textures + .insert(id, texture.clone()); } if should_extend { unsafe { @@ -1259,6 +1270,7 @@ impl Global { temp_suspected .as_mut() .unwrap() + .texture_views .insert(texture_view.as_info().id(), texture_view.clone()); } } @@ -1278,6 +1290,7 @@ impl Global { temp_suspected .as_mut() .unwrap() + .bind_groups .insert(bg.as_info().id(), bg.clone()); } } @@ -1288,7 +1301,7 @@ impl Global { { compute_pipeline.info.use_at(submit_index); if compute_pipeline.is_unique() { - temp_suspected.as_mut().unwrap().insert( + temp_suspected.as_mut().unwrap().compute_pipelines.insert( compute_pipeline.as_info().id(), compute_pipeline.clone(), ); @@ -1299,7 +1312,7 @@ impl Global { { render_pipeline.info.use_at(submit_index); if render_pipeline.is_unique() { - temp_suspected.as_mut().unwrap().insert( + temp_suspected.as_mut().unwrap().render_pipelines.insert( render_pipeline.as_info().id(), render_pipeline.clone(), ); @@ -1311,6 +1324,7 @@ impl Global { temp_suspected .as_mut() .unwrap() + .query_sets .insert(query_set.as_info().id(), query_set.clone()); } } @@ -1331,6 +1345,7 @@ impl Global { temp_suspected .as_mut() .unwrap() + .render_bundles .insert(bundle.as_info().id(), bundle.clone()); } } @@ -1362,6 +1377,7 @@ impl Global { &mut baked.encoder, &mut *trackers, &baked.trackers, + &snatch_guard, ); let transit = unsafe { baked.encoder.end_encoding().unwrap() }; diff --git a/third_party/rust/wgpu-core/src/device/resource.rs b/third_party/rust/wgpu-core/src/device/resource.rs index a3dd162bfba9d..b89ad9abf0d9f 100644 --- a/third_party/rust/wgpu-core/src/device/resource.rs +++ b/third_party/rust/wgpu-core/src/device/resource.rs @@ -26,6 +26,7 @@ use crate::{ TextureViewNotRenderableReason, }, resource_log, + snatch::{SnatchGuard, SnatchLock, Snatchable}, storage::Storage, track::{BindGroupStates, TextureSelector, Tracker}, validation::{self, check_buffer_usage, check_texture_usage}, @@ -94,6 +95,7 @@ pub struct Device { //Note: The submission index here corresponds to the last submission that is done. pub(crate) active_submission_index: AtomicU64, //SubmissionIndex, pub(crate) fence: RwLock>, + pub(crate) snatchable_lock: SnatchLock, /// Is this device valid? Valid is closely associated with "lose the device", /// which can be triggered by various methods, including at the end of device @@ -117,7 +119,7 @@ pub struct Device { life_tracker: Mutex>, /// Temporary storage for resource management functions. Cleared at the end /// of every call (unless an error occurs). - pub(crate) temp_suspected: Mutex>, + pub(crate) temp_suspected: Mutex>>, pub(crate) alignments: hal::Alignments, pub(crate) limits: wgt::Limits, pub(crate) features: wgt::Features, @@ -141,7 +143,7 @@ impl std::fmt::Debug for Device { impl Drop for Device { fn drop(&mut self) { - resource_log!("Destroy raw Device {}", self.info.label()); + resource_log!("Destroy raw Device {:?}", self.info.label()); let raw = self.raw.take().unwrap(); let pending_writes = self.pending_writes.lock().take().unwrap(); pending_writes.dispose(&raw); @@ -254,10 +256,11 @@ impl Device { command_allocator: Mutex::new(Some(com_alloc)), active_submission_index: AtomicU64::new(0), fence: RwLock::new(Some(fence)), + snatchable_lock: unsafe { SnatchLock::new() }, valid: AtomicBool::new(true), trackers: Mutex::new(Tracker::new()), life_tracker: Mutex::new(life::LifetimeTracker::new()), - temp_suspected: Mutex::new(Some(life::ResourceMaps::new::())), + temp_suspected: Mutex::new(Some(life::ResourceMaps::new())), #[cfg(feature = "trace")] trace: Mutex::new(trace_path.and_then(|path| match trace::Trace::new(path) { Ok(mut trace) => { @@ -321,7 +324,7 @@ impl Device { let temp_suspected = self .temp_suspected .lock() - .replace(ResourceMaps::new::()) + .replace(ResourceMaps::new()) .unwrap(); let mut life_tracker = self.lock_life(); @@ -378,15 +381,19 @@ impl Device { // our caller. This will complete the steps for both destroy and for // "lose the device". let mut device_lost_invocations = SmallVec::new(); - if !self.is_valid() - && life_tracker.queue_empty() - && life_tracker.device_lost_closure.is_some() - { - device_lost_invocations.push(DeviceLostInvocation { - closure: life_tracker.device_lost_closure.take().unwrap(), - reason: DeviceLostReason::Destroyed, - message: String::new(), - }); + if !self.is_valid() && life_tracker.queue_empty() { + // We can release gpu resources associated with this device. + life_tracker.release_gpu_resources(); + + // If we have a DeviceLostClosure, build an invocation with the + // reason DeviceLostReason::Destroyed and no message. + if life_tracker.device_lost_closure.is_some() { + device_lost_invocations.push(DeviceLostInvocation { + closure: life_tracker.device_lost_closure.take().unwrap(), + reason: DeviceLostReason::Destroyed, + message: String::new(), + }); + } } let closures = UserClosures { @@ -401,7 +408,7 @@ impl Device { let mut temp_suspected = self .temp_suspected .lock() - .replace(ResourceMaps::new::()) + .replace(ResourceMaps::new()) .unwrap(); temp_suspected.clear(); // As the tracker is cleared/dropped, we need to consider all the resources @@ -409,42 +416,58 @@ impl Device { { for resource in trackers.buffers.used_resources() { if resource.is_unique() { - temp_suspected.insert(resource.as_info().id(), resource.clone()); + temp_suspected + .buffers + .insert(resource.as_info().id(), resource.clone()); } } for resource in trackers.textures.used_resources() { if resource.is_unique() { - temp_suspected.insert(resource.as_info().id(), resource.clone()); + temp_suspected + .textures + .insert(resource.as_info().id(), resource.clone()); } } for resource in trackers.views.used_resources() { if resource.is_unique() { - temp_suspected.insert(resource.as_info().id(), resource.clone()); + temp_suspected + .texture_views + .insert(resource.as_info().id(), resource.clone()); } } for resource in trackers.bind_groups.used_resources() { if resource.is_unique() { - temp_suspected.insert(resource.as_info().id(), resource.clone()); + temp_suspected + .bind_groups + .insert(resource.as_info().id(), resource.clone()); } } for resource in trackers.samplers.used_resources() { if resource.is_unique() { - temp_suspected.insert(resource.as_info().id(), resource.clone()); + temp_suspected + .samplers + .insert(resource.as_info().id(), resource.clone()); } } for resource in trackers.compute_pipelines.used_resources() { if resource.is_unique() { - temp_suspected.insert(resource.as_info().id(), resource.clone()); + temp_suspected + .compute_pipelines + .insert(resource.as_info().id(), resource.clone()); } } for resource in trackers.render_pipelines.used_resources() { if resource.is_unique() { - temp_suspected.insert(resource.as_info().id(), resource.clone()); + temp_suspected + .render_pipelines + .insert(resource.as_info().id(), resource.clone()); } } for resource in trackers.query_sets.used_resources() { if resource.is_unique() { - temp_suspected.insert(resource.as_info().id(), resource.clone()); + temp_suspected + .query_sets + .insert(resource.as_info().id(), resource.clone()); } } } @@ -538,7 +561,7 @@ impl Device { let buffer = unsafe { self.raw().create_buffer(&hal_desc) }.map_err(DeviceError::from)?; Ok(Buffer { - raw: Some(buffer), + raw: Snatchable::new(buffer), device: self.clone(), usage: desc.usage, size: desc.size, @@ -588,7 +611,7 @@ impl Device { debug_assert_eq!(self.as_info().id().backend(), A::VARIANT); Buffer { - raw: Some(hal_buffer), + raw: Snatchable::new(hal_buffer), device: self.clone(), usage: desc.usage, size: desc.size, @@ -1766,6 +1789,7 @@ impl Device { used: &mut BindGroupStates, storage: &'a Storage, id::BufferId>, limits: &wgt::Limits, + snatch_guard: &'a SnatchGuard<'a>, ) -> Result, binding_model::CreateBindGroupError> { use crate::binding_model::CreateBindGroupError as Error; @@ -1818,7 +1842,7 @@ impl Device { check_buffer_usage(buffer.usage, pub_usage)?; let raw_buffer = buffer .raw - .as_ref() + .get(snatch_guard) .ok_or(Error::InvalidBuffer(bb.buffer_id))?; let (bind_size, bind_end) = match bb.size { @@ -1966,6 +1990,7 @@ impl Device { let mut hal_buffers = Vec::new(); let mut hal_samplers = Vec::new(); let mut hal_textures = Vec::new(); + let snatch_guard = self.snatchable_lock.read(); for entry in desc.entries.iter() { let binding = entry.binding; // Find the corresponding declaration in the layout @@ -1985,6 +2010,7 @@ impl Device { &mut used, &*buffer_guard, &self.limits, + &snatch_guard, )?; let res_index = hal_buffers.len(); @@ -2007,6 +2033,7 @@ impl Device { &mut used, &*buffer_guard, &self.limits, + &snatch_guard, )?; hal_buffers.push(bb); } @@ -2173,9 +2200,9 @@ impl Device { layout: layout.clone(), info: ResourceInfo::new(desc.label.borrow_or_default()), used, - used_buffer_ranges: RwLock::new(used_buffer_ranges), - used_texture_ranges: RwLock::new(used_texture_ranges), - dynamic_binding_info: RwLock::new(dynamic_binding_info), + used_buffer_ranges, + used_texture_ranges, + dynamic_binding_info, // collect in the order of BGL iteration late_buffer_binding_sizes: layout .entries @@ -3066,7 +3093,7 @@ impl Device { if validated_stages.contains(wgt::ShaderStages::FRAGMENT) { for (i, output) in io.iter() { match color_targets.get(*i as usize) { - Some(&Some(ref state)) => { + Some(Some(state)) => { validation::check_texture_format(state.format, &output.ty).map_err( |pipeline| { pipeline::CreateRenderPipelineError::ColorState( @@ -3339,9 +3366,13 @@ impl Device { self.valid.store(false, Ordering::Release); // 1) Resolve the GPUDevice device.lost promise. - let closure = self.lock_life().device_lost_closure.take(); + let mut life_lock = self.lock_life(); + let closure = life_lock.device_lost_closure.take(); if let Some(device_lost_closure) = closure { + // It's important to not hold the lock while calling the closure. + drop(life_lock); device_lost_closure.call(DeviceLostReason::Unknown, message.to_string()); + life_lock = self.lock_life(); } // 2) Complete any outstanding mapAsync() steps. @@ -3351,6 +3382,9 @@ impl Device { // since that will prevent any new work from being added to the queues. // Future calls to poll_devices will continue to check the work queues // until they are cleared, and then drop the device. + + // Eagerly release GPU resources. + life_lock.release_gpu_resources(); } } diff --git a/third_party/rust/wgpu-core/src/id.rs b/third_party/rust/wgpu-core/src/id.rs index 1782172c2ad30..739beb71809b8 100644 --- a/third_party/rust/wgpu-core/src/id.rs +++ b/third_party/rust/wgpu-core/src/id.rs @@ -8,17 +8,8 @@ use std::{ }; use wgt::{Backend, WasmNotSendSync}; -#[cfg(feature = "id32")] -type IdType = u32; -#[cfg(not(feature = "id32"))] type IdType = u64; -#[cfg(feature = "id32")] -type NonZeroId = std::num::NonZeroU32; -#[cfg(not(feature = "id32"))] type NonZeroId = std::num::NonZeroU64; -#[cfg(feature = "id32")] -type ZippedIndex = u16; -#[cfg(not(feature = "id32"))] type ZippedIndex = Index; const INDEX_BITS: usize = std::mem::size_of::() * 8; diff --git a/third_party/rust/wgpu-core/src/lib.rs b/third_party/rust/wgpu-core/src/lib.rs index e68debdcb8695..b44248fdae71f 100644 --- a/third_party/rust/wgpu-core/src/lib.rs +++ b/third_party/rust/wgpu-core/src/lib.rs @@ -1,7 +1,38 @@ -/*! This library safely implements WebGPU on native platforms. - * It is designed for integration into browsers, as well as wrapping - * into other language-specific user-friendly libraries. - */ +//! This library safely implements WebGPU on native platforms. +//! It is designed for integration into browsers, as well as wrapping +//! into other language-specific user-friendly libraries. +//! +//! ## Feature flags +// NOTE: feature docs. below should be kept in sync. with `Cargo.toml`! +//! +//! - **`api_log_info`** --- Log all API entry points at info instead of trace level. +//! - **`resource_log_info`** --- Log resource lifecycle management at info instead of trace level. +//! - **`link`** _(enabled by default)_ --- Use static linking for libraries. Disale to manually +//! link. Enabled by default. +//! - **`renderdoc`** --- Support the Renderdoc graphics debugger: +//! [https://renderdoc.org/](https://renderdoc.org/) +//! - **`strict_asserts`** --- Apply run-time checks, even in release builds. These are in addition +//! to the validation carried out at public APIs in all builds. +//! - **`trace`** --- Enable API tracing. +//! - **`replay`** --- Enable API replaying +//! - **`serial-pass`** --- Enable serializable compute/render passes, and bundle encoders. +//! - **`wgsl`** --- Enable `ShaderModuleSource::Wgsl` +//! - **`fragile-send-sync-non-atomic-wasm`** --- Implement `Send` and `Sync` on Wasm, but only if +//! atomics are not enabled. +//! +//! WebGL/WebGPU objects can not be shared between threads. However, it can be useful to +//! artificially mark them as `Send` and `Sync` anyways to make it easier to write cross-platform +//! code. This is technically _very_ unsafe in a multithreaded environment, but on a wasm binary +//! compiled without atomics we know we are definitely not in a multithreaded environment. +//! +//! ### Backends, passed through to wgpu-hal +//! +//! - **`metal`** --- Enable the `metal` backend. +//! - **`vulkan`** --- Enable the `vulkan` backend. +//! - **`gles`** --- Enable the `GLES` backend. +//! +//! This is used for all of GLES, OpenGL, and WebGL. +//! - **`dx12`** --- Enable the `dx12` backend. // When we have no backends, we end up with a lot of dead or otherwise unreachable code. #![cfg_attr( @@ -34,17 +65,15 @@ // For some reason `rustc` can warn about these in const generics even // though they are required. unused_braces, - // Clashes with clippy::pattern_type_mismatch - clippy::needless_borrowed_reference, + // It gets in the way a lot and does not prevent bugs in practice. + clippy::pattern_type_mismatch, )] #![warn( trivial_casts, trivial_numeric_casts, unsafe_op_in_unsafe_fn, unused_extern_crates, - unused_qualifications, - // We don't match on a reference, unless required. - clippy::pattern_type_mismatch, + unused_qualifications )] pub mod any_surface; @@ -64,6 +93,7 @@ pub mod pipeline; pub mod present; pub mod registry; pub mod resource; +mod snatch; pub mod storage; mod track; // This is public for users who pre-compile shaders while still wanting to @@ -221,6 +251,10 @@ define_backend_caller! { gfx_if_vulkan, gfx_if_vulkan_hidden, "vulkan" if all(fe define_backend_caller! { gfx_if_metal, gfx_if_metal_hidden, "metal" if all(feature = "metal", any(target_os = "macos", target_os = "ios")) } define_backend_caller! { gfx_if_dx12, gfx_if_dx12_hidden, "dx12" if all(feature = "dx12", windows) } define_backend_caller! { gfx_if_gles, gfx_if_gles_hidden, "gles" if feature = "gles" } +define_backend_caller! { gfx_if_empty, gfx_if_empty_hidden, "empty" if all( + not(any(feature = "metal", feature = "vulkan", feature = "gles")), + any(target_os = "macos", target_os = "ios"), +) } /// Dispatch on an [`Id`]'s backend to a backend-generic method. /// @@ -275,6 +309,7 @@ macro_rules! gfx_select { wgt::Backend::Metal => $crate::gfx_if_metal!($global.$method::<$crate::api::Metal>( $($param),* )), wgt::Backend::Dx12 => $crate::gfx_if_dx12!($global.$method::<$crate::api::Dx12>( $($param),* )), wgt::Backend::Gl => $crate::gfx_if_gles!($global.$method::<$crate::api::Gles>( $($param),+ )), + wgt::Backend::Empty => $crate::gfx_if_empty!($global.$method::<$crate::api::Empty>( $($param),+ )), other => panic!("Unexpected backend {:?}", other), } }; diff --git a/third_party/rust/wgpu-core/src/pipeline.rs b/third_party/rust/wgpu-core/src/pipeline.rs index 32a0ac880b774..27a58fd9660ce 100644 --- a/third_party/rust/wgpu-core/src/pipeline.rs +++ b/third_party/rust/wgpu-core/src/pipeline.rs @@ -54,7 +54,7 @@ pub struct ShaderModule { impl Drop for ShaderModule { fn drop(&mut self) { if let Some(raw) = self.raw.take() { - resource_log!("Destroy raw ShaderModule {}", self.info.label()); + resource_log!("Destroy raw ShaderModule {:?}", self.info.label()); #[cfg(feature = "trace")] if let Some(ref mut trace) = *self.device.trace.lock() { trace.add(trace::Action::DestroyShaderModule(self.info.id())); @@ -250,7 +250,7 @@ pub struct ComputePipeline { impl Drop for ComputePipeline { fn drop(&mut self) { if let Some(raw) = self.raw.take() { - resource_log!("Destroy raw ComputePipeline {}", self.info.label()); + resource_log!("Destroy raw ComputePipeline {:?}", self.info.label()); unsafe { use hal::Device; self.device.raw().destroy_compute_pipeline(raw); @@ -491,7 +491,7 @@ pub struct RenderPipeline { impl Drop for RenderPipeline { fn drop(&mut self) { if let Some(raw) = self.raw.take() { - resource_log!("Destroy raw RenderPipeline {}", self.info.label()); + resource_log!("Destroy raw RenderPipeline {:?}", self.info.label()); unsafe { use hal::Device; self.device.raw().destroy_render_pipeline(raw); diff --git a/third_party/rust/wgpu-core/src/resource.rs b/third_party/rust/wgpu-core/src/resource.rs index 587b479206981..8f0607e7f926c 100644 --- a/third_party/rust/wgpu-core/src/resource.rs +++ b/third_party/rust/wgpu-core/src/resource.rs @@ -14,6 +14,7 @@ use crate::{ identity::{GlobalIdentityHandlerFactory, IdentityManager}, init_tracker::{BufferInitTracker, TextureInitTracker}, resource, resource_log, + snatch::{SnatchGuard, Snatchable}, track::TextureSelector, validation::MissingBufferUsageError, Label, SubmissionIndex, @@ -93,15 +94,19 @@ impl ResourceInfo { } } - pub(crate) fn label(&self) -> String + pub(crate) fn label(&self) -> &dyn Debug where Id: Debug, { - if let Some(id) = self.id.as_ref() { - format!("[{}] {:?}", self.label, id) - } else { - format!("[{}]", self.label) + if !self.label.is_empty() { + return &self.label; + } + + if let Some(id) = &self.id { + return id; } + + &"" } pub(crate) fn id(&self) -> Id { @@ -395,7 +400,7 @@ pub type BufferDescriptor<'a> = wgt::BufferDescriptor>; #[derive(Debug)] pub struct Buffer { - pub(crate) raw: Option, + pub(crate) raw: Snatchable, pub(crate) device: Arc>, pub(crate) usage: wgt::BufferUsages, pub(crate) size: wgt::BufferAddress, @@ -408,7 +413,7 @@ pub struct Buffer { impl Drop for Buffer { fn drop(&mut self) { if let Some(raw) = self.raw.take() { - resource_log!("Destroy raw Buffer {}", self.info.label()); + resource_log!("Deallocate raw Buffer (dropped) {:?}", self.info.label()); unsafe { use hal::Device; self.device.raw().destroy_buffer(raw); @@ -418,16 +423,29 @@ impl Drop for Buffer { } impl Buffer { - pub(crate) fn raw(&self) -> &A::Buffer { - self.raw.as_ref().unwrap() + pub(crate) fn raw(&self, guard: &SnatchGuard) -> Option<&A::Buffer> { + self.raw.get(guard) } - pub(crate) fn buffer_unmap_inner( - self: &Arc, - ) -> Result, BufferAccessError> { + // Note: This must not be called while holding a lock. + pub(crate) fn unmap(self: &Arc) -> Result<(), BufferAccessError> { + if let Some((mut operation, status)) = self.unmap_inner()? { + if let Some(callback) = operation.callback.take() { + callback.call(status); + } + } + + Ok(()) + } + + fn unmap_inner(self: &Arc) -> Result, BufferAccessError> { use hal::Device; let device = &self.device; + let snatch_guard = device.snatchable_lock.read(); + let raw_buf = self + .raw(&snatch_guard) + .ok_or(BufferAccessError::Destroyed)?; let buffer_id = self.info.id(); log::debug!("Buffer {:?} map state -> Idle", buffer_id); match mem::replace(&mut *self.map_state.lock(), resource::BufferMapState::Idle) { @@ -451,14 +469,13 @@ impl Buffer { let _ = ptr; if needs_flush { unsafe { - device - .raw() - .flush_mapped_ranges(stage_buffer.raw(), iter::once(0..self.size)); + device.raw().flush_mapped_ranges( + stage_buffer.raw(&snatch_guard).unwrap(), + iter::once(0..self.size), + ); } } - let raw_buf = self.raw.as_ref().ok_or(BufferAccessError::Destroyed)?; - self.info .use_at(device.active_submission_index.load(Ordering::Relaxed) + 1); let region = wgt::BufferSize::new(self.size).map(|size| hal::BufferCopy { @@ -467,7 +484,7 @@ impl Buffer { size, }); let transition_src = hal::BufferBarrier { - buffer: stage_buffer.raw(), + buffer: stage_buffer.raw(&snatch_guard).unwrap(), usage: hal::BufferUses::MAP_WRITE..hal::BufferUses::COPY_SRC, }; let transition_dst = hal::BufferBarrier { @@ -483,7 +500,7 @@ impl Buffer { ); if self.size > 0 { encoder.copy_buffer_to_buffer( - stage_buffer.raw(), + stage_buffer.raw(&snatch_guard).unwrap(), raw_buf, region.into_iter(), ); @@ -518,7 +535,7 @@ impl Buffer { unsafe { device .raw() - .unmap_buffer(self.raw()) + .unmap_buffer(raw_buf) .map_err(DeviceError::from)? }; } @@ -527,40 +544,41 @@ impl Buffer { } pub(crate) fn destroy(self: &Arc) -> Result<(), DestroyError> { - let map_closure; - // Restrict the locks to this scope. - { - let device = &self.device; - let buffer_id = self.info.id(); - - map_closure = self.buffer_unmap_inner().unwrap_or(None); - - #[cfg(feature = "trace")] - if let Some(ref mut trace) = *device.trace.lock() { - trace.add(trace::Action::FreeBuffer(buffer_id)); - } - if self.raw.is_none() { - return Err(resource::DestroyError::AlreadyDestroyed); - } + let device = &self.device; + let buffer_id = self.info.id(); - let temp = queue::TempResource::Buffer(self.clone()); - let mut pending_writes = device.pending_writes.lock(); - let pending_writes = pending_writes.as_mut().unwrap(); - if pending_writes.dst_buffers.contains_key(&buffer_id) { - pending_writes.temp_resources.push(temp); - } else { - let last_submit_index = self.info.submission_index(); - device - .lock_life() - .schedule_resource_destruction(temp, last_submit_index); - } + #[cfg(feature = "trace")] + if let Some(ref mut trace) = *device.trace.lock() { + trace.add(trace::Action::FreeBuffer(buffer_id)); } - // Note: outside the scope where locks are held when calling the callback - if let Some((mut operation, status)) = map_closure { - if let Some(callback) = operation.callback.take() { - callback.call(status); - } + let temp = { + let snatch_guard = device.snatchable_lock.write(); + let raw = match self.raw.snatch(snatch_guard) { + Some(raw) => raw, + None => { + return Err(resource::DestroyError::AlreadyDestroyed); + } + }; + + queue::TempResource::DestroyedBuffer(Arc::new(DestroyedBuffer { + raw: Some(raw), + device: Arc::clone(&self.device), + submission_index: self.info.submission_index(), + id: self.info.id.unwrap(), + label: self.info.label.clone(), + })) + }; + + let mut pending_writes = device.pending_writes.lock(); + let pending_writes = pending_writes.as_mut().unwrap(); + if pending_writes.dst_buffers.contains_key(&buffer_id) { + pending_writes.temp_resources.push(temp); + } else { + let last_submit_index = self.info.submission_index(); + device + .lock_life() + .schedule_resource_destruction(temp, last_submit_index); } Ok(()) @@ -598,6 +616,38 @@ impl Resource for Buffer { } } +/// A buffer that has been marked as destroyed and is staged for actual deletion soon. +#[derive(Debug)] +pub struct DestroyedBuffer { + raw: Option, + device: Arc>, + label: String, + pub(crate) id: BufferId, + pub(crate) submission_index: u64, +} + +impl DestroyedBuffer { + pub fn label(&self) -> &dyn Debug { + if !self.label.is_empty() { + return &self.label; + } + + &self.id + } +} + +impl Drop for DestroyedBuffer { + fn drop(&mut self) { + if let Some(raw) = self.raw.take() { + resource_log!("Deallocate raw Buffer (destroyed) {:?}", self.label()); + unsafe { + use hal::Device; + self.device.raw().destroy_buffer(raw); + } + } + } +} + /// A temporary buffer, consumed by the command that uses it. /// /// A [`StagingBuffer`] is designed for one-shot uploads of data to the GPU. It @@ -629,7 +679,7 @@ pub struct StagingBuffer { impl Drop for StagingBuffer { fn drop(&mut self) { if let Some(raw) = self.raw.lock().take() { - resource_log!("Destroy raw StagingBuffer {}", self.info.label()); + resource_log!("Destroy raw StagingBuffer {:?}", self.info.label()); unsafe { use hal::Device; self.device.raw().destroy_buffer(raw); @@ -711,7 +761,7 @@ pub struct Texture { impl Drop for Texture { fn drop(&mut self) { - resource_log!("Destroy raw Texture {}", self.info.label()); + resource_log!("Destroy raw Texture {:?}", self.info.label()); use hal::Device; let mut clear_mode = self.clear_mode.write(); let clear_mode = &mut *clear_mode; @@ -841,6 +891,23 @@ impl Global { hal_device_callback(hal_device) } + /// # Safety + /// + /// - The raw fence handle must not be manually destroyed + pub unsafe fn device_fence_as_hal) -> R, R>( + &self, + id: DeviceId, + hal_fence_callback: F, + ) -> R { + profiling::scope!("Device::fence_as_hal"); + + let hub = A::hub(self); + let device = hub.devices.try_get(id).ok().flatten(); + let hal_fence = device.as_ref().map(|device| device.fence.read()); + + hal_fence_callback(hal_fence.as_deref().unwrap().as_ref()) + } + /// # Safety /// - The raw surface handle must not be manually destroyed pub unsafe fn surface_as_hal) -> R, R>( @@ -1043,7 +1110,7 @@ pub struct TextureView { impl Drop for TextureView { fn drop(&mut self) { if let Some(raw) = self.raw.take() { - resource_log!("Destroy raw TextureView {}", self.info.label()); + resource_log!("Destroy raw TextureView {:?}", self.info.label()); unsafe { use hal::Device; self.device.raw().destroy_texture_view(raw); @@ -1164,7 +1231,7 @@ pub struct Sampler { impl Drop for Sampler { fn drop(&mut self) { - resource_log!("Destroy raw Sampler {}", self.info.label()); + resource_log!("Destroy raw Sampler {:?}", self.info.label()); if let Some(raw) = self.raw.take() { unsafe { use hal::Device; @@ -1261,7 +1328,7 @@ pub struct QuerySet { impl Drop for QuerySet { fn drop(&mut self) { - resource_log!("Destroy raw QuerySet {}", self.info.label()); + resource_log!("Destroy raw QuerySet {:?}", self.info.label()); if let Some(raw) = self.raw.take() { unsafe { use hal::Device; diff --git a/third_party/rust/wgpu-core/src/snatch.rs b/third_party/rust/wgpu-core/src/snatch.rs new file mode 100644 index 0000000000000..db3114076c1c8 --- /dev/null +++ b/third_party/rust/wgpu-core/src/snatch.rs @@ -0,0 +1,86 @@ +#![allow(unused)] + +use parking_lot::{RwLock, RwLockReadGuard, RwLockWriteGuard}; +use std::cell::UnsafeCell; + +/// A guard that provides read access to snatchable data. +pub struct SnatchGuard<'a>(RwLockReadGuard<'a, ()>); +/// A guard that allows snatching the snatchable data. +pub struct ExclusiveSnatchGuard<'a>(RwLockWriteGuard<'a, ()>); + +/// A value that is mostly immutable but can be "snatched" if we need to destroy +/// it early. +/// +/// In order to safely access the underlying data, the device's global snatchable +/// lock must be taken. To guarentee it, methods take a read or write guard of that +/// special lock. +pub struct Snatchable { + value: UnsafeCell>, +} + +impl Snatchable { + pub fn new(val: T) -> Self { + Snatchable { + value: UnsafeCell::new(Some(val)), + } + } + + /// Get read access to the value. Requires a the snatchable lock's read guard. + pub fn get(&self, _guard: &SnatchGuard) -> Option<&T> { + unsafe { (*self.value.get()).as_ref() } + } + + /// Take the value. Requires a the snatchable lock's write guard. + pub fn snatch(&self, _guard: ExclusiveSnatchGuard) -> Option { + unsafe { (*self.value.get()).take() } + } + + /// Take the value without a guard. This can only be used with exclusive access + /// to self, so it does not require locking. + /// + /// Typically useful in a drop implementation. + pub fn take(&mut self) -> Option { + self.value.get_mut().take() + } +} + +// Can't safely print the contents of a snatchable object without holding +// the lock. +impl std::fmt::Debug for Snatchable { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + write!(f, "") + } +} + +unsafe impl Sync for Snatchable {} + +/// A Device-global lock for all snatchable data. +pub struct SnatchLock { + lock: RwLock<()>, +} + +impl SnatchLock { + /// The safety of `Snatchable::get` and `Snatchable::snatch` rely on their using of the + /// right SnatchLock (the one associated to the same device). This method is unsafe + /// to force force sers to think twice about creating a SnatchLock. The only place this + /// method sould be called is when creating the device. + pub unsafe fn new() -> Self { + SnatchLock { + lock: RwLock::new(()), + } + } + + /// Request read access to snatchable resources. + pub fn read(&self) -> SnatchGuard { + SnatchGuard(self.lock.read()) + } + + /// Request write access to snatchable resources. + /// + /// This should only be called when a resource needs to be snatched. This has + /// a high risk of causing lock contention if called concurrently with other + /// wgpu work. + pub fn write(&self) -> ExclusiveSnatchGuard { + ExclusiveSnatchGuard(self.lock.write()) + } +} diff --git a/third_party/rust/wgpu-core/src/storage.rs b/third_party/rust/wgpu-core/src/storage.rs index 9b928839179d6..891b7954e64af 100644 --- a/third_party/rust/wgpu-core/src/storage.rs +++ b/third_party/rust/wgpu-core/src/storage.rs @@ -134,7 +134,7 @@ where pub(crate) fn label_for_invalid_id(&self, id: I) -> &str { let (index, _, _) = id.unzip(); match self.map.get(index as usize) { - Some(&Element::Error(_, ref label)) => label, + Some(Element::Error(_, label)) => label, _ => "", } } diff --git a/third_party/rust/wgpu-core/src/track/buffer.rs b/third_party/rust/wgpu-core/src/track/buffer.rs index 4b2a9a8abe2c8..2c2a6937f9b45 100644 --- a/third_party/rust/wgpu-core/src/track/buffer.rs +++ b/third_party/rust/wgpu-core/src/track/buffer.rs @@ -12,6 +12,7 @@ use crate::{ hal_api::HalApi, id::{BufferId, TypedId}, resource::{Buffer, Resource}, + snatch::SnatchGuard, storage::Storage, track::{ invalid_resource_state, skip_barrier, ResourceMetadata, ResourceMetadataProvider, @@ -387,10 +388,13 @@ impl BufferTracker { } /// Drains all currently pending transitions. - pub fn drain_transitions(&mut self) -> impl Iterator> { + pub fn drain_transitions<'a, 'b: 'a>( + &'b mut self, + snatch_guard: &'a SnatchGuard<'a>, + ) -> impl Iterator> { let buffer_barriers = self.temp.drain(..).map(|pending| { let buf = unsafe { self.metadata.get_resource_unchecked(pending.id as _) }; - pending.into_hal(buf) + pending.into_hal(buf, snatch_guard) }); buffer_barriers } diff --git a/third_party/rust/wgpu-core/src/track/mod.rs b/third_party/rust/wgpu-core/src/track/mod.rs index c2d5dc3c200e3..0f0b22b004aa9 100644 --- a/third_party/rust/wgpu-core/src/track/mod.rs +++ b/third_party/rust/wgpu-core/src/track/mod.rs @@ -106,6 +106,7 @@ use crate::{ hal_api::HalApi, id::{self, TypedId}, pipeline, resource, + snatch::SnatchGuard, storage::Storage, }; @@ -138,8 +139,9 @@ impl PendingTransition { pub fn into_hal<'a, A: HalApi>( self, buf: &'a resource::Buffer, + snatch_guard: &'a SnatchGuard<'a>, ) -> hal::BufferBarrier<'a, A> { - let buffer = buf.raw.as_ref().expect("Buffer is destroyed"); + let buffer = buf.raw.get(snatch_guard).expect("Buffer is destroyed"); hal::BufferBarrier { buffer, usage: self.usage, diff --git a/third_party/rust/wgpu-core/src/track/range.rs b/third_party/rust/wgpu-core/src/track/range.rs index 12c527fb2aafb..3961220c2c469 100644 --- a/third_party/rust/wgpu-core/src/track/range.rs +++ b/third_party/rust/wgpu-core/src/track/range.rs @@ -77,8 +77,8 @@ impl RangedStates { ) -> impl Iterator, &T)> + 'a { self.ranges .iter() - .filter(move |&&(ref inner, ..)| inner.end > range.start && inner.start < range.end) - .map(move |&(ref inner, ref v)| { + .filter(move |&(inner, ..)| inner.end > range.start && inner.start < range.end) + .map(move |(inner, v)| { let new_range = inner.start.max(range.start)..inner.end.min(range.end); (new_range, v) diff --git a/third_party/rust/wgpu-core/src/track/stateless.rs b/third_party/rust/wgpu-core/src/track/stateless.rs index 747a55db6d8e9..b33905f51251d 100644 --- a/third_party/rust/wgpu-core/src/track/stateless.rs +++ b/third_party/rust/wgpu-core/src/track/stateless.rs @@ -42,7 +42,7 @@ impl> StatelessBindGroupSate { let resources = self.resources.lock(); resources .iter() - .map(|&(_, ref resource)| resource.clone()) + .map(|(_, resource)| resource.clone()) .collect::>() .into_iter() } diff --git a/third_party/rust/wgpu-core/src/validation.rs b/third_party/rust/wgpu-core/src/validation.rs index 6eb52376b8021..1c05f47ec59cf 100644 --- a/third_party/rust/wgpu-core/src/validation.rs +++ b/third_party/rust/wgpu-core/src/validation.rs @@ -252,7 +252,7 @@ pub enum StageError { TooManyVaryings { used: u32, limit: u32 }, #[error("Unable to find entry point '{0}'")] MissingEntryPoint(String), - #[error("Shader global {0:?} is not available in the layout pipeline layout")] + #[error("Shader global {0:?} is not available in the pipeline layout")] Binding(naga::ResourceBinding, #[source] BindingError), #[error("Unable to filter the texture ({texture:?}) by the sampler ({sampler:?})")] Filtering { diff --git a/third_party/rust/wgpu-hal/.cargo-checksum.json b/third_party/rust/wgpu-hal/.cargo-checksum.json index 793b537f65de6..d85f5d8612065 100644 --- a/third_party/rust/wgpu-hal/.cargo-checksum.json +++ b/third_party/rust/wgpu-hal/.cargo-checksum.json @@ -1 +1 @@ -{"files":{"Cargo.toml":"289bf888a26074395af97c782640c0a53586ea1228fd2273c6d57f1c1610f82c","LICENSE.APACHE":"a6cba85bc92e0cff7a450b1d873c0eaa2e9fc96bf472df0247a26bec77bf3ff9","LICENSE.MIT":"c7fea58d1cfe49634cd92e54fc10a9d871f4b275321a4cd8c09e449122caaeb4","README.md":"099ee611a911dc19330a61bffcde13663929a51b25ac528ee33ea796d695491e","examples/halmark/main.rs":"5a358026dca068990ea6ea5bb1e5c6c606f5308e869c2c5fd0fef13d80ea061a","examples/halmark/shader.wgsl":"26c256ec36d6f0e9a1647431ca772766bee4382d64eaa718ba7b488dcfb6bcca","examples/raw-gles.em.html":"70fbe68394a1a4522192de1dcfaf7d399f60d7bdf5de70b708f9bb0417427546","examples/raw-gles.rs":"33f536693b08a9f00b0358416be8f368894bf92a2e673b16622fa9c244854c91","examples/ray-traced-triangle/main.rs":"b7f75d04eec75c1ae95fab18ede582b66058eb1f95491617cb0622ad96b9f166","examples/ray-traced-triangle/shader.wgsl":"cc10caf92746724a71f6dd0dbc3a71e57b37c7d1d83278556805a535c0728a9d","src/auxil/dxgi/conv.rs":"760cd4eaa79b530368a30140b96bf73ac4fbdb4025eb95f0bed581638c8bb1cb","src/auxil/dxgi/exception.rs":"fc68c6211c82a912b454c3004185f46a1416bce38ddc5b0555e0def6539cfb27","src/auxil/dxgi/factory.rs":"65c758d6583c2fdac0b3d48d1a0a2a414ff913efc4f3913a38bd660819c3a2e2","src/auxil/dxgi/mod.rs":"a202564d9ac97530b16a234b87d180cd345aae705e082a9b1177dcde813645f9","src/auxil/dxgi/result.rs":"20c8eb03d738062dff198feca6327addb9882ed0462be842c789eadf7dca0573","src/auxil/dxgi/time.rs":"b6f966b250e9424d5d7e4065f2108cba87197c1e30baae6d87083055d1bc5a4b","src/auxil/mod.rs":"17505dc0a8247546bc1b97341c872f368a1f522e4ff51bb8844255e36b2b5186","src/auxil/renderdoc.rs":"c2f849f70f576b0c9b0d32dd155b6a6353f74dff59cbeeaa994a12789d047c0f","src/dx12/adapter.rs":"33c4b790c22115d68db11883a8fb8da194fba0937636a56cc779b7bf48a5ce44","src/dx12/command.rs":"a9dfd160c966870928b3ab98b01df9f8fd05b0517adcb57b4cb28cdc66e0bce1","src/dx12/conv.rs":"94d35f117ae003b07049f3a0bc6c45a0ffda9fb8053233d39c173cfb1b644403","src/dx12/descriptor.rs":"d9e295c48dc7d1759fd121c927c2218c1bde90e9f1b35f2ad01b610b184b614e","src/dx12/device.rs":"ad170b50c519f2799b06192d1fd0ca65346d246eed37ac512f3a0382100244db","src/dx12/instance.rs":"719125a6adb69f16df1a0069c8a1ccb5792169a00abdf2e38cc26b633b15768a","src/dx12/mod.rs":"2be5f031d95b7a6d8700f60d0aa9b9813666db5bd9ac9a1483e79902b981d080","src/dx12/shader_compilation.rs":"0589ed592cbd939f821d2801c82ee973c28844292682d37db84048ba21e6c72b","src/dx12/suballocation.rs":"eec45b2d23e979f7d7f33d982a89ae2f92e528b22f1bb7d2e5dd52582a25a601","src/dx12/types.rs":"9573736baaa0ef607367c3b72144556d24faf677a26bb8df49a4372a1348e06b","src/dx12/view.rs":"b3c80708e62508ec63df7c06001384c543b7ab76bb7334f9f565e3289afe3673","src/empty.rs":"af290b508bc63590b40b94a8e3b163e32f1262f2e20995cab340cfd76386becd","src/gles/adapter.rs":"16bc0c9cc6987269841f7f12023ca12a14e0d746c4bab8d4770abb240a63ed84","src/gles/command.rs":"a544456f3d3ed13bd695a604473af1758ee29b2386872f5663e5395088890177","src/gles/conv.rs":"4c7ce6424cefc2b62b74f1f0f67c2d480f04412a16d27ca83b0471744d7fce96","src/gles/device.rs":"ae7415a7ade56d499b28073492289907edbce13327392cc014812c35ed9effdc","src/gles/egl.rs":"89212bdacbb9dc43eebcc7b74fb612a69d35ffc1dfe2b626820c44c61256c4c9","src/gles/emscripten.rs":"19bb73a9d140645f3f32cd48b002151711a9b8456e213eab5f3a2be79239e147","src/gles/mod.rs":"d02cefb55c78dd496f2eeceb55547b3032b50f31188d20994d90e4a049b2e6a0","src/gles/queue.rs":"53f7184c94f210dd4fb2a264c9a545eac3ccf4ef44e670ff7523a8e9a6c9dd1d","src/gles/shaders/clear.frag":"9133ed8ed97d3641fbb6b5f5ea894a3554c629ccc1b80a5fc9221d7293aa1954","src/gles/shaders/clear.vert":"a543768725f4121ff2e9e1fb5b00644931e9d6f2f946c0ef01968afb5a135abd","src/gles/shaders/srgb_present.frag":"dd9a43c339a2fa4ccf7f6a1854c6f400cabf271a7d5e9230768e9f39d47f3ff5","src/gles/shaders/srgb_present.vert":"6e85d489403d80b81cc94790730bb53b309dfc5eeede8f1ea3412a660f31d357","src/gles/web.rs":"5623c8c78584c5e9182502e0997bd11e627e67ccd23d516e65526f415215de2f","src/gles/wgl.rs":"ec1c958acc903af43c29e60059c2c71257b5735312c15679647daed774ad01a1","src/lib.rs":"ecdf9b417fd71145734530c1dd8b843f69a8ff8a00d2a364794ea5062cc30a92","src/metal/adapter.rs":"d9cec8808210059503ebb4776f2431c83a6e5d8ab1f79a48d321dc2f589a0ca3","src/metal/command.rs":"661b38a75d4f4cd1b0d6957f1f09db0743ec3a13bbafba9baa931894ee193f48","src/metal/conv.rs":"0bce6a8d0ccef16783475803d70d35e03ab7938c19374e22c9d253abe1f8b111","src/metal/device.rs":"c5deeecf475e0aa4b2027c656ea19207716f84b56cfa7c9132dca504d1abebfb","src/metal/mod.rs":"662518044d6464410facd58ff06a80a89e2c9c3cd3fdad69a956ed4546777d2a","src/metal/surface.rs":"01539fa9f22c26fdcca5ee915ca97cf76cecc7fae237347dfc9a813ae13e98cd","src/metal/time.rs":"c32d69f30e846dfcc0e39e01097fb80df63b2bebb6586143bb62494999850246","src/vulkan/adapter.rs":"22e29141efe34674bfa0fd09fa36dd0113f1b0b2786231222a25d5758224f05a","src/vulkan/command.rs":"7c6dd62b1d4a65f8c85b2fada925f9c50b46039ec862b5e700e05e0f546a3288","src/vulkan/conv.rs":"9a2c0398af0e9d48e50348d0fa0366eca90a9d2df3d6c17bee16d37dc5d95c2f","src/vulkan/device.rs":"d2f3068dc3ba8148c849a3bcab1328350e7a99ed5055fbde1647e8c4138f0e81","src/vulkan/instance.rs":"d9a084ac91a2b541b14d8ea565a7a581d281e54ec2828b64e5be2989e0113ed7","src/vulkan/mod.rs":"e69c99bc511567587734ffb16af3cbda8a29ec387c8183c930744cb489b3f492"},"package":null} \ No newline at end of file +{"files":{"Cargo.toml":"01f51d7d1496aef321704cc982c12b4c36a19cf352464606f9177fb6d112dcfd","LICENSE.APACHE":"a6cba85bc92e0cff7a450b1d873c0eaa2e9fc96bf472df0247a26bec77bf3ff9","LICENSE.MIT":"c7fea58d1cfe49634cd92e54fc10a9d871f4b275321a4cd8c09e449122caaeb4","README.md":"099ee611a911dc19330a61bffcde13663929a51b25ac528ee33ea796d695491e","examples/halmark/main.rs":"5a358026dca068990ea6ea5bb1e5c6c606f5308e869c2c5fd0fef13d80ea061a","examples/halmark/shader.wgsl":"26c256ec36d6f0e9a1647431ca772766bee4382d64eaa718ba7b488dcfb6bcca","examples/raw-gles.em.html":"70fbe68394a1a4522192de1dcfaf7d399f60d7bdf5de70b708f9bb0417427546","examples/raw-gles.rs":"33f536693b08a9f00b0358416be8f368894bf92a2e673b16622fa9c244854c91","examples/ray-traced-triangle/main.rs":"b7f75d04eec75c1ae95fab18ede582b66058eb1f95491617cb0622ad96b9f166","examples/ray-traced-triangle/shader.wgsl":"cc10caf92746724a71f6dd0dbc3a71e57b37c7d1d83278556805a535c0728a9d","src/auxil/dxgi/conv.rs":"760cd4eaa79b530368a30140b96bf73ac4fbdb4025eb95f0bed581638c8bb1cb","src/auxil/dxgi/exception.rs":"fc68c6211c82a912b454c3004185f46a1416bce38ddc5b0555e0def6539cfb27","src/auxil/dxgi/factory.rs":"65c758d6583c2fdac0b3d48d1a0a2a414ff913efc4f3913a38bd660819c3a2e2","src/auxil/dxgi/mod.rs":"a202564d9ac97530b16a234b87d180cd345aae705e082a9b1177dcde813645f9","src/auxil/dxgi/result.rs":"20c8eb03d738062dff198feca6327addb9882ed0462be842c789eadf7dca0573","src/auxil/dxgi/time.rs":"b6f966b250e9424d5d7e4065f2108cba87197c1e30baae6d87083055d1bc5a4b","src/auxil/mod.rs":"17505dc0a8247546bc1b97341c872f368a1f522e4ff51bb8844255e36b2b5186","src/auxil/renderdoc.rs":"c2f849f70f576b0c9b0d32dd155b6a6353f74dff59cbeeaa994a12789d047c0f","src/dx12/adapter.rs":"33c4b790c22115d68db11883a8fb8da194fba0937636a56cc779b7bf48a5ce44","src/dx12/command.rs":"a9dfd160c966870928b3ab98b01df9f8fd05b0517adcb57b4cb28cdc66e0bce1","src/dx12/conv.rs":"94d35f117ae003b07049f3a0bc6c45a0ffda9fb8053233d39c173cfb1b644403","src/dx12/descriptor.rs":"d9e295c48dc7d1759fd121c927c2218c1bde90e9f1b35f2ad01b610b184b614e","src/dx12/device.rs":"30af012adfa1bdf9fcc605b66008393f143108adfa003c0ba6f648421a180094","src/dx12/instance.rs":"719125a6adb69f16df1a0069c8a1ccb5792169a00abdf2e38cc26b633b15768a","src/dx12/mod.rs":"715b99af005e0b2a4cccf63f715dd0b6b314e15b81f5cf2e080942459eaf4998","src/dx12/shader_compilation.rs":"0589ed592cbd939f821d2801c82ee973c28844292682d37db84048ba21e6c72b","src/dx12/suballocation.rs":"eec45b2d23e979f7d7f33d982a89ae2f92e528b22f1bb7d2e5dd52582a25a601","src/dx12/types.rs":"9573736baaa0ef607367c3b72144556d24faf677a26bb8df49a4372a1348e06b","src/dx12/view.rs":"b3c80708e62508ec63df7c06001384c543b7ab76bb7334f9f565e3289afe3673","src/empty.rs":"af290b508bc63590b40b94a8e3b163e32f1262f2e20995cab340cfd76386becd","src/gles/adapter.rs":"8ca43533be6e3112dfd952040d7d6ca6eed093c541aa5b92b3d74cb692e8058b","src/gles/command.rs":"a544456f3d3ed13bd695a604473af1758ee29b2386872f5663e5395088890177","src/gles/conv.rs":"4c7ce6424cefc2b62b74f1f0f67c2d480f04412a16d27ca83b0471744d7fce96","src/gles/device.rs":"ae7415a7ade56d499b28073492289907edbce13327392cc014812c35ed9effdc","src/gles/egl.rs":"89212bdacbb9dc43eebcc7b74fb612a69d35ffc1dfe2b626820c44c61256c4c9","src/gles/emscripten.rs":"19bb73a9d140645f3f32cd48b002151711a9b8456e213eab5f3a2be79239e147","src/gles/mod.rs":"d02cefb55c78dd496f2eeceb55547b3032b50f31188d20994d90e4a049b2e6a0","src/gles/queue.rs":"53f7184c94f210dd4fb2a264c9a545eac3ccf4ef44e670ff7523a8e9a6c9dd1d","src/gles/shaders/clear.frag":"9133ed8ed97d3641fbb6b5f5ea894a3554c629ccc1b80a5fc9221d7293aa1954","src/gles/shaders/clear.vert":"a543768725f4121ff2e9e1fb5b00644931e9d6f2f946c0ef01968afb5a135abd","src/gles/shaders/srgb_present.frag":"dd9a43c339a2fa4ccf7f6a1854c6f400cabf271a7d5e9230768e9f39d47f3ff5","src/gles/shaders/srgb_present.vert":"6e85d489403d80b81cc94790730bb53b309dfc5eeede8f1ea3412a660f31d357","src/gles/web.rs":"8f96cce5d680202970c61482803adb3ba92142925c99d5254192e9bc3d0d52ed","src/gles/wgl.rs":"24354905784c437411670c8848670d69002cb5af2942b8a00f7f5445ce68366f","src/lib.rs":"ecdf9b417fd71145734530c1dd8b843f69a8ff8a00d2a364794ea5062cc30a92","src/metal/adapter.rs":"d9cec8808210059503ebb4776f2431c83a6e5d8ab1f79a48d321dc2f589a0ca3","src/metal/command.rs":"661b38a75d4f4cd1b0d6957f1f09db0743ec3a13bbafba9baa931894ee193f48","src/metal/conv.rs":"0bce6a8d0ccef16783475803d70d35e03ab7938c19374e22c9d253abe1f8b111","src/metal/device.rs":"c5deeecf475e0aa4b2027c656ea19207716f84b56cfa7c9132dca504d1abebfb","src/metal/mod.rs":"662518044d6464410facd58ff06a80a89e2c9c3cd3fdad69a956ed4546777d2a","src/metal/surface.rs":"01539fa9f22c26fdcca5ee915ca97cf76cecc7fae237347dfc9a813ae13e98cd","src/metal/time.rs":"c32d69f30e846dfcc0e39e01097fb80df63b2bebb6586143bb62494999850246","src/vulkan/adapter.rs":"22e29141efe34674bfa0fd09fa36dd0113f1b0b2786231222a25d5758224f05a","src/vulkan/command.rs":"7c6dd62b1d4a65f8c85b2fada925f9c50b46039ec862b5e700e05e0f546a3288","src/vulkan/conv.rs":"9a2c0398af0e9d48e50348d0fa0366eca90a9d2df3d6c17bee16d37dc5d95c2f","src/vulkan/device.rs":"d2f3068dc3ba8148c849a3bcab1328350e7a99ed5055fbde1647e8c4138f0e81","src/vulkan/instance.rs":"ccac56ae83c8692e9a96ee0e7d11ecef8493420b8b1893bea314eb1e9c515863","src/vulkan/mod.rs":"e69c99bc511567587734ffb16af3cbda8a29ec387c8183c930744cb489b3f492"},"package":null} \ No newline at end of file diff --git a/third_party/rust/wgpu-hal/Cargo.toml b/third_party/rust/wgpu-hal/Cargo.toml index b7721f0f16516..d88a16a59a866 100644 --- a/third_party/rust/wgpu-hal/Cargo.toml +++ b/third_party/rust/wgpu-hal/Cargo.toml @@ -89,7 +89,7 @@ path = "../naga" features = ["wgsl-in"] [dev-dependencies.winit] -version = "0.29.4" +version = "0.29.6" features = ["android-native-activity"] [features] diff --git a/third_party/rust/wgpu-hal/src/dx12/device.rs b/third_party/rust/wgpu-hal/src/dx12/device.rs index daf14bf712e74..74cc09d6cd023 100644 --- a/third_party/rust/wgpu-hal/src/dx12/device.rs +++ b/third_party/rust/wgpu-hal/src/dx12/device.rs @@ -1514,7 +1514,7 @@ impl crate::Device for super::Device { let hr = unsafe { self.raw.CreateFence( 0, - d3d12_ty::D3D12_FENCE_FLAG_NONE, + d3d12_ty::D3D12_FENCE_FLAG_SHARED, &d3d12_ty::ID3D12Fence::uuidof(), raw.mut_void(), ) diff --git a/third_party/rust/wgpu-hal/src/dx12/mod.rs b/third_party/rust/wgpu-hal/src/dx12/mod.rs index 2d42d5faa1510..e0cd1c15cf66f 100644 --- a/third_party/rust/wgpu-hal/src/dx12/mod.rs +++ b/third_party/rust/wgpu-hal/src/dx12/mod.rs @@ -493,6 +493,12 @@ pub struct Fence { unsafe impl Send for Fence {} unsafe impl Sync for Fence {} +impl Fence { + pub fn raw_fence(&self) -> &d3d12::Fence { + &self.raw + } +} + #[derive(Debug)] pub struct BindGroupLayout { /// Sorted list of entries. diff --git a/third_party/rust/wgpu-hal/src/gles/adapter.rs b/third_party/rust/wgpu-hal/src/gles/adapter.rs index 00db6aba61426..e46c91ab9c146 100644 --- a/third_party/rust/wgpu-hal/src/gles/adapter.rs +++ b/third_party/rust/wgpu-hal/src/gles/adapter.rs @@ -1136,7 +1136,7 @@ impl crate::Adapter for super::Adapter { Some(crate::SurfaceCapabilities { formats, present_modes: if cfg!(windows) { - vec![wgt::PresentMode::Fifo, wgt::PresentMode::Mailbox] + vec![wgt::PresentMode::Fifo, wgt::PresentMode::Immediate] } else { vec![wgt::PresentMode::Fifo] //TODO }, diff --git a/third_party/rust/wgpu-hal/src/gles/web.rs b/third_party/rust/wgpu-hal/src/gles/web.rs index 49236bb94cbe2..cdbe4543d1882 100644 --- a/third_party/rust/wgpu-hal/src/gles/web.rs +++ b/third_party/rust/wgpu-hal/src/gles/web.rs @@ -1,6 +1,6 @@ use glow::HasContext; use parking_lot::{Mutex, RwLock}; -use wasm_bindgen::JsCast; +use wasm_bindgen::{JsCast, JsValue}; use super::TextureFormatDesc; @@ -55,7 +55,7 @@ impl Instance { fn create_surface_from_context( &self, canvas: Canvas, - context_result: Result, wasm_bindgen::JsValue>, + context_result: Result, JsValue>, ) -> Result { let context_object: js_sys::Object = match context_result { Ok(Some(context)) => context, @@ -147,22 +147,33 @@ impl crate::Instance for Instance { _display_handle: raw_window_handle::RawDisplayHandle, window_handle: raw_window_handle::RawWindowHandle, ) -> Result { - if let raw_window_handle::RawWindowHandle::Web(handle) = window_handle { - let canvas: web_sys::HtmlCanvasElement = web_sys::window() + let canvas: web_sys::HtmlCanvasElement = match window_handle { + raw_window_handle::RawWindowHandle::Web(handle) => web_sys::window() .and_then(|win| win.document()) .expect("Cannot get document") .query_selector(&format!("canvas[data-raw-handle=\"{}\"]", handle.id)) .expect("Cannot query for canvas") .expect("Canvas is not found") .dyn_into() - .expect("Failed to downcast to canvas type"); + .expect("Failed to downcast to canvas type"), + raw_window_handle::RawWindowHandle::WebCanvas(handle) => { + let value: &JsValue = unsafe { handle.obj.cast().as_ref() }; + value.clone().unchecked_into() + } + raw_window_handle::RawWindowHandle::WebOffscreenCanvas(handle) => { + let value: &JsValue = unsafe { handle.obj.cast().as_ref() }; + let canvas: web_sys::OffscreenCanvas = value.clone().unchecked_into(); - self.create_surface_from_canvas(canvas) - } else { - Err(crate::InstanceError::new(format!( - "window handle {window_handle:?} is not a web handle" - ))) - } + return self.create_surface_from_offscreen_canvas(canvas); + } + _ => { + return Err(crate::InstanceError::new(format!( + "window handle {window_handle:?} is not a web handle" + ))) + } + }; + + self.create_surface_from_canvas(canvas) } unsafe fn destroy_surface(&self, surface: Surface) { diff --git a/third_party/rust/wgpu-hal/src/gles/wgl.rs b/third_party/rust/wgpu-hal/src/gles/wgl.rs index 6e6860728625f..a09a50330d1f0 100644 --- a/third_party/rust/wgpu-hal/src/gles/wgl.rs +++ b/third_party/rust/wgpu-hal/src/gles/wgl.rs @@ -744,7 +744,7 @@ impl crate::Surface for Surface { } let vsync = match config.present_mode { - wgt::PresentMode::Mailbox => false, + wgt::PresentMode::Immediate => false, wgt::PresentMode::Fifo => true, _ => { log::error!("unsupported present mode: {:?}", config.present_mode); diff --git a/third_party/rust/wgpu-hal/src/vulkan/instance.rs b/third_party/rust/wgpu-hal/src/vulkan/instance.rs index 8eb136b2cb63b..7a527774300a0 100644 --- a/third_party/rust/wgpu-hal/src/vulkan/instance.rs +++ b/third_party/rust/wgpu-hal/src/vulkan/instance.rs @@ -507,7 +507,7 @@ impl super::Instance { Ok(self.create_surface_from_vk_surface_khr(surface)) } - #[cfg(any(target_os = "macos", target_os = "ios"))] + #[cfg(all(any(target_os = "macos", target_os = "ios"), feature = "metal"))] fn create_surface_from_view( &self, view: *mut c_void, @@ -805,13 +805,13 @@ impl crate::Instance for super::Instance { let hinstance = unsafe { GetModuleHandleW(std::ptr::null()) }; self.create_surface_from_hwnd(hinstance as *mut _, handle.hwnd.get() as *mut _) } - #[cfg(target_os = "macos")] + #[cfg(all(target_os = "macos", feature = "metal"))] (Rwh::AppKit(handle), _) if self.shared.extensions.contains(&ext::MetalSurface::name()) => { self.create_surface_from_view(handle.ns_view.as_ptr()) } - #[cfg(target_os = "ios")] + #[cfg(all(target_os = "ios", feature = "metal"))] (Rwh::UiKit(handle), _) if self.shared.extensions.contains(&ext::MetalSurface::name()) => { diff --git a/third_party/rust/wgpu-types/.cargo-checksum.json b/third_party/rust/wgpu-types/.cargo-checksum.json index 9f12b1c965523..b7330333418d6 100644 --- a/third_party/rust/wgpu-types/.cargo-checksum.json +++ b/third_party/rust/wgpu-types/.cargo-checksum.json @@ -1 +1 @@ -{"files":{"Cargo.toml":"18549fb7d7de2ea2481f30292dca63889856a33bd1b3698e16cee6631ab65df4","LICENSE.APACHE":"a6cba85bc92e0cff7a450b1d873c0eaa2e9fc96bf472df0247a26bec77bf3ff9","LICENSE.MIT":"c7fea58d1cfe49634cd92e54fc10a9d871f4b275321a4cd8c09e449122caaeb4","src/assertions.rs":"3fe98027aa73970c8ab7874a3e13dbfd6faa87df2081beb5c83aeec4c60f372f","src/lib.rs":"94bfa8e33adff5dcc422a16d115d580ef95539972de997e4917e2c444022c593","src/math.rs":"4d03039736dd6926feb139bc68734cb59df34ede310427bbf059e5c925e0af3b"},"package":null} \ No newline at end of file +{"files":{"Cargo.toml":"18549fb7d7de2ea2481f30292dca63889856a33bd1b3698e16cee6631ab65df4","LICENSE.APACHE":"a6cba85bc92e0cff7a450b1d873c0eaa2e9fc96bf472df0247a26bec77bf3ff9","LICENSE.MIT":"c7fea58d1cfe49634cd92e54fc10a9d871f4b275321a4cd8c09e449122caaeb4","src/assertions.rs":"3fe98027aa73970c8ab7874a3e13dbfd6faa87df2081beb5c83aeec4c60f372f","src/lib.rs":"30e85d18f040cedb37861ef734a41df9fab730d868b25db3158921aa6bfc44a3","src/math.rs":"4d03039736dd6926feb139bc68734cb59df34ede310427bbf059e5c925e0af3b"},"package":null} \ No newline at end of file diff --git a/third_party/rust/wgpu-types/src/lib.rs b/third_party/rust/wgpu-types/src/lib.rs index e76bebe625f72..43c0f465ee521 100644 --- a/third_party/rust/wgpu-types/src/lib.rs +++ b/third_party/rust/wgpu-types/src/lib.rs @@ -4992,7 +4992,7 @@ pub enum PresentMode { #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] #[cfg_attr(feature = "trace", derive(Serialize))] #[cfg_attr(feature = "replay", derive(Deserialize))] -#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))] +#[cfg_attr(feature = "serde", serde(rename_all = "lowercase"))] pub enum CompositeAlphaMode { /// Chooses either `Opaque` or `Inherit` automatically,depending on the /// `alpha_mode` that the current surface can support.