html-to-markdown 2.23.4 → 2.24.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +7 -7
- data/README.md +9 -7
- data/ext/html-to-markdown-rb/native/Cargo.lock +21 -21
- data/ext/html-to-markdown-rb/native/Cargo.toml +1 -3
- data/lib/html_to_markdown/cli_proxy.rb +5 -2
- data/lib/html_to_markdown/version.rb +1 -1
- data/rust-vendor/cc/.cargo-checksum.json +1 -1
- data/rust-vendor/cc/.cargo_vcs_info.json +1 -1
- data/rust-vendor/cc/CHANGELOG.md +7 -0
- data/rust-vendor/cc/Cargo.lock +1 -1
- data/rust-vendor/cc/Cargo.toml +1 -1
- data/rust-vendor/cc/Cargo.toml.orig +1 -1
- data/rust-vendor/cc/src/target/generated.rs +1 -0
- data/rust-vendor/cc/src/target/parser.rs +4 -0
- data/rust-vendor/html-to-markdown-rs/README.md +1 -1
- data/rust-vendor/html-to-markdown-rs/src/convert_api.rs +90 -15
- data/rust-vendor/html-to-markdown-rs/src/converter/block/preformatted.rs +15 -4
- data/rust-vendor/html-to-markdown-rs/src/converter/handlers/graphic.rs +5 -3
- data/rust-vendor/html-to-markdown-rs/src/converter/media/svg.rs +5 -1
- data/rust-vendor/html-to-markdown-rs/src/converter/text/processing.rs +15 -8
- data/rust-vendor/html-to-markdown-rs/src/converter/utility/preprocessing.rs +43 -18
- data/rust-vendor/html-to-markdown-rs/src/lib.rs +6 -6
- data/rust-vendor/html-to-markdown-rs/src/validation.rs +68 -29
- data/rust-vendor/html-to-markdown-rs/tests/issue_190_regressions.rs +121 -0
- data/rust-vendor/html-to-markdown-rs/tests/skip_images_test.rs +21 -0
- data/rust-vendor/proc-macro2/.cargo-checksum.json +1 -1
- data/rust-vendor/proc-macro2/.cargo_vcs_info.json +1 -1
- data/rust-vendor/proc-macro2/Cargo.lock +14 -89
- data/rust-vendor/proc-macro2/Cargo.toml +1 -1
- data/rust-vendor/proc-macro2/Cargo.toml.orig +1 -1
- data/rust-vendor/proc-macro2/src/fallback.rs +37 -23
- data/rust-vendor/proc-macro2/src/lib.rs +1 -1
- data/rust-vendor/quote/.cargo-checksum.json +1 -1
- data/rust-vendor/quote/.cargo_vcs_info.json +1 -1
- data/rust-vendor/quote/.github/workflows/ci.yml +1 -1
- data/rust-vendor/quote/Cargo.lock +17 -17
- data/rust-vendor/quote/Cargo.toml +1 -1
- data/rust-vendor/quote/Cargo.toml.orig +1 -1
- data/rust-vendor/quote/src/format.rs +2 -2
- data/rust-vendor/quote/src/lib.rs +1 -1
- data/rust-vendor/quote/src/runtime.rs +2 -2
- data/rust-vendor/quote/tests/test.rs +6 -0
- data/rust-vendor/quote/tests/ui/does-not-have-iter-interpolated-dup.stderr +2 -2
- data/rust-vendor/quote/tests/ui/does-not-have-iter-interpolated.stderr +2 -2
- data/rust-vendor/quote/tests/ui/does-not-have-iter-separated.stderr +2 -2
- data/rust-vendor/quote/tests/ui/does-not-have-iter.stderr +2 -2
- data/rust-vendor/quote/tests/ui/not-repeatable.stderr +8 -8
- data/rust-vendor/siphasher/.cargo-checksum.json +1 -1
- data/rust-vendor/siphasher/.cargo_vcs_info.json +1 -1
- data/rust-vendor/siphasher/.github/workflows/issues.yml +17 -0
- data/rust-vendor/siphasher/COPYING +1 -1
- data/rust-vendor/siphasher/Cargo.lock +89 -0
- data/rust-vendor/siphasher/Cargo.toml +23 -13
- data/rust-vendor/siphasher/Cargo.toml.orig +1 -1
- data/rust-vendor/siphasher/src/common.rs +65 -0
- data/rust-vendor/siphasher/src/lib.rs +1 -1
- data/rust-vendor/siphasher/src/sip.rs +2 -68
- data/rust-vendor/siphasher/src/sip128.rs +15 -74
- data/rust-vendor/siphasher/src/tests.rs +1 -1
- data/rust-vendor/siphasher/src/tests128.rs +1 -1
- data/rust-vendor/uuid/.cargo-checksum.json +1 -1
- data/rust-vendor/uuid/.cargo_vcs_info.json +1 -1
- data/rust-vendor/uuid/Cargo.lock +125 -96
- data/rust-vendor/uuid/Cargo.toml +4 -11
- data/rust-vendor/uuid/Cargo.toml.orig +5 -14
- data/rust-vendor/uuid/README.md +3 -3
- data/rust-vendor/uuid/src/builder.rs +2 -1
- data/rust-vendor/uuid/src/external/serde_support.rs +209 -142
- data/rust-vendor/uuid/src/lib.rs +9 -11
- data/rust-vendor/uuid/src/macros.rs +9 -54
- data/rust-vendor/uuid/src/non_nil.rs +49 -2
- data/rust-vendor/web_atoms/.cargo-checksum.json +1 -1
- data/rust-vendor/web_atoms/.cargo_vcs_info.json +1 -1
- data/rust-vendor/web_atoms/Cargo.lock +1 -1
- data/rust-vendor/web_atoms/Cargo.toml +1 -1
- data/rust-vendor/web_atoms/Cargo.toml.orig +1 -1
- data/rust-vendor/web_atoms/local_names.txt +3 -0
- data/rust-vendor/zerocopy/.cargo-checksum.json +1 -1
- data/rust-vendor/zerocopy/.cargo_vcs_info.json +1 -1
- data/rust-vendor/zerocopy/Cargo.lock +5 -9
- data/rust-vendor/zerocopy/Cargo.toml +10 -18
- data/rust-vendor/zerocopy/Cargo.toml.orig +6 -14
- data/rust-vendor/zerocopy/Cargo.toml.std +58 -0
- data/rust-vendor/zerocopy/agent_docs/ui_tests.md +5 -5
- data/rust-vendor/zerocopy/cargo.sh +1 -1
- data/rust-vendor/zerocopy/ci/check_fmt.sh +1 -1
- data/rust-vendor/zerocopy/ci/check_readme.sh +1 -1
- data/rust-vendor/zerocopy/ci/check_stale_stderr.sh +44 -0
- data/rust-vendor/zerocopy/githooks/pre-push +2 -0
- data/rust-vendor/zerocopy/src/byte_slice.rs +1 -1
- data/rust-vendor/zerocopy/src/byteorder.rs +0 -1
- data/rust-vendor/zerocopy/src/impls.rs +334 -118
- data/rust-vendor/zerocopy/src/layout.rs +9 -0
- data/rust-vendor/zerocopy/src/lib.rs +163 -74
- data/rust-vendor/zerocopy/src/macros.rs +4 -8
- data/rust-vendor/zerocopy/src/pointer/inner.rs +4 -4
- data/rust-vendor/zerocopy/src/pointer/invariant.rs +22 -5
- data/rust-vendor/zerocopy/src/pointer/mod.rs +155 -18
- data/rust-vendor/zerocopy/src/pointer/ptr.rs +133 -182
- data/rust-vendor/zerocopy/src/pointer/transmute.rs +99 -106
- data/rust-vendor/zerocopy/src/ref.rs +4 -4
- data/rust-vendor/zerocopy/src/util/macro_util.rs +73 -127
- data/rust-vendor/zerocopy/src/util/macros.rs +61 -150
- data/rust-vendor/zerocopy/src/wrappers.rs +249 -3
- data/rust-vendor/zerocopy/tests/include.rs +67 -0
- data/rust-vendor/zerocopy/tests/ui-msrv/diagnostic-not-implemented-from-bytes.rs +1 -3
- data/rust-vendor/zerocopy/tests/ui-msrv/diagnostic-not-implemented-from-bytes.stderr +6 -6
- data/rust-vendor/zerocopy/tests/ui-msrv/diagnostic-not-implemented-from-zeros.rs +1 -3
- data/rust-vendor/zerocopy/tests/ui-msrv/diagnostic-not-implemented-from-zeros.stderr +4 -4
- data/rust-vendor/zerocopy/tests/ui-msrv/diagnostic-not-implemented-immutable.rs +1 -3
- data/rust-vendor/zerocopy/tests/ui-msrv/diagnostic-not-implemented-immutable.stderr +6 -6
- data/rust-vendor/zerocopy/tests/ui-msrv/diagnostic-not-implemented-into-bytes.rs +1 -3
- data/rust-vendor/zerocopy/tests/ui-msrv/diagnostic-not-implemented-into-bytes.stderr +6 -6
- data/rust-vendor/zerocopy/tests/ui-msrv/diagnostic-not-implemented-issue-1296.rs +1 -3
- data/rust-vendor/zerocopy/tests/ui-msrv/diagnostic-not-implemented-issue-1296.stderr +8 -8
- data/rust-vendor/zerocopy/tests/ui-msrv/diagnostic-not-implemented-known-layout.rs +1 -3
- data/rust-vendor/zerocopy/tests/ui-msrv/diagnostic-not-implemented-known-layout.stderr +6 -6
- data/rust-vendor/zerocopy/tests/ui-msrv/diagnostic-not-implemented-try-from-bytes.rs +1 -3
- data/rust-vendor/zerocopy/tests/ui-msrv/diagnostic-not-implemented-try-from-bytes.stderr +6 -6
- data/rust-vendor/zerocopy/tests/ui-msrv/diagnostic-not-implemented-unaligned.rs +1 -3
- data/rust-vendor/zerocopy/tests/ui-msrv/diagnostic-not-implemented-unaligned.stderr +4 -4
- data/rust-vendor/zerocopy/tests/ui-msrv/include_value_not_from_bytes.rs +3 -5
- data/rust-vendor/zerocopy/tests/ui-msrv/include_value_not_from_bytes.stderr +10 -10
- data/rust-vendor/zerocopy/tests/ui-msrv/include_value_wrong_size.rs +1 -4
- data/rust-vendor/zerocopy/tests/ui-msrv/include_value_wrong_size.stderr +3 -3
- data/rust-vendor/zerocopy/tests/ui-msrv/invalid-impls/invalid-impls.rs +0 -1
- data/rust-vendor/zerocopy/tests/ui-msrv/invalid-impls/invalid-impls.stderr +35 -35
- data/rust-vendor/zerocopy/tests/ui-msrv/transmute-dst-not-frombytes.rs +1 -3
- data/rust-vendor/zerocopy/tests/ui-msrv/transmute-dst-not-frombytes.stderr +6 -6
- data/rust-vendor/zerocopy/tests/ui-msrv/transmute-mut-const.rs +1 -3
- data/rust-vendor/zerocopy/tests/ui-msrv/transmute-mut-const.stderr +10 -10
- data/rust-vendor/zerocopy/tests/ui-msrv/transmute-mut-dst-not-a-reference.rs +0 -2
- data/rust-vendor/zerocopy/tests/ui-msrv/transmute-mut-dst-not-a-reference.stderr +2 -2
- data/rust-vendor/zerocopy/tests/ui-msrv/transmute-mut-dst-not-frombytes.rs +0 -2
- data/rust-vendor/zerocopy/tests/ui-msrv/transmute-mut-dst-not-frombytes.stderr +2 -2
- data/rust-vendor/zerocopy/tests/ui-msrv/transmute-mut-dst-not-intobytes.rs +0 -2
- data/rust-vendor/zerocopy/tests/ui-msrv/transmute-mut-dst-not-intobytes.stderr +2 -2
- data/rust-vendor/zerocopy/tests/ui-msrv/transmute-mut-dst-unsized.rs +0 -2
- data/rust-vendor/zerocopy/tests/ui-msrv/transmute-mut-dst-unsized.stderr +2 -2
- data/rust-vendor/zerocopy/tests/ui-msrv/transmute-mut-src-dst-not-references.rs +0 -2
- data/rust-vendor/zerocopy/tests/ui-msrv/transmute-mut-src-dst-not-references.stderr +2 -2
- data/rust-vendor/zerocopy/tests/ui-msrv/transmute-mut-src-immutable.rs +0 -2
- data/rust-vendor/zerocopy/tests/ui-msrv/transmute-mut-src-immutable.stderr +2 -2
- data/rust-vendor/zerocopy/tests/ui-msrv/transmute-mut-src-not-a-reference.rs +0 -2
- data/rust-vendor/zerocopy/tests/ui-msrv/transmute-mut-src-not-a-reference.stderr +2 -2
- data/rust-vendor/zerocopy/tests/ui-msrv/transmute-mut-src-not-frombytes.rs +0 -2
- data/rust-vendor/zerocopy/tests/ui-msrv/transmute-mut-src-not-frombytes.stderr +2 -2
- data/rust-vendor/zerocopy/tests/ui-msrv/transmute-mut-src-not-intobytes.rs +0 -2
- data/rust-vendor/zerocopy/tests/ui-msrv/transmute-mut-src-not-intobytes.stderr +2 -2
- data/rust-vendor/zerocopy/tests/ui-msrv/transmute-mut-src-unsized.rs +0 -2
- data/rust-vendor/zerocopy/tests/ui-msrv/transmute-mut-src-unsized.stderr +2 -2
- data/rust-vendor/zerocopy/tests/ui-msrv/transmute-ptr-to-usize.rs +0 -2
- data/rust-vendor/zerocopy/tests/ui-msrv/transmute-ptr-to-usize.stderr +4 -4
- data/rust-vendor/zerocopy/tests/ui-msrv/transmute-ref-dst-mutable.rs +0 -2
- data/rust-vendor/zerocopy/tests/ui-msrv/transmute-ref-dst-mutable.stderr +6 -6
- data/rust-vendor/zerocopy/tests/ui-msrv/transmute-ref-dst-not-a-reference.rs +0 -2
- data/rust-vendor/zerocopy/tests/ui-msrv/transmute-ref-dst-not-a-reference.stderr +6 -6
- data/rust-vendor/zerocopy/tests/ui-msrv/transmute-ref-dst-not-frombytes.rs +1 -3
- data/rust-vendor/zerocopy/tests/ui-msrv/transmute-ref-dst-not-frombytes.stderr +6 -6
- data/rust-vendor/zerocopy/tests/ui-msrv/transmute-ref-dst-not-nocell.rs +1 -3
- data/rust-vendor/zerocopy/tests/ui-msrv/transmute-ref-dst-not-nocell.stderr +6 -6
- data/rust-vendor/zerocopy/tests/ui-msrv/transmute-ref-dst-unsized.rs +0 -2
- data/rust-vendor/zerocopy/tests/ui-msrv/transmute-ref-dst-unsized.stderr +2 -2
- data/rust-vendor/zerocopy/tests/ui-msrv/transmute-ref-src-dst-not-references.rs +0 -2
- data/rust-vendor/zerocopy/tests/ui-msrv/transmute-ref-src-dst-not-references.stderr +8 -8
- data/rust-vendor/zerocopy/tests/ui-msrv/transmute-ref-src-not-a-reference.rs +0 -2
- data/rust-vendor/zerocopy/tests/ui-msrv/transmute-ref-src-not-a-reference.stderr +2 -2
- data/rust-vendor/zerocopy/tests/ui-msrv/transmute-ref-src-not-intobytes.rs +1 -3
- data/rust-vendor/zerocopy/tests/ui-msrv/transmute-ref-src-not-intobytes.stderr +12 -12
- data/rust-vendor/zerocopy/tests/ui-msrv/transmute-ref-src-not-nocell.rs +1 -3
- data/rust-vendor/zerocopy/tests/ui-msrv/transmute-ref-src-not-nocell.stderr +12 -12
- data/rust-vendor/zerocopy/tests/ui-msrv/transmute-ref-src-unsized.rs +0 -2
- data/rust-vendor/zerocopy/tests/ui-msrv/transmute-ref-src-unsized.stderr +2 -2
- data/rust-vendor/zerocopy/tests/ui-msrv/transmute-size-decrease.rs +1 -3
- data/rust-vendor/zerocopy/tests/ui-msrv/transmute-size-decrease.stderr +2 -2
- data/rust-vendor/zerocopy/tests/ui-msrv/transmute-size-increase-allow-shrink.rs +1 -3
- data/rust-vendor/zerocopy/tests/ui-msrv/transmute-size-increase-allow-shrink.stderr +2 -2
- data/rust-vendor/zerocopy/tests/ui-msrv/transmute-size-increase.rs +1 -3
- data/rust-vendor/zerocopy/tests/ui-msrv/transmute-size-increase.stderr +2 -2
- data/rust-vendor/zerocopy/tests/ui-msrv/transmute-src-not-intobytes.rs +1 -3
- data/rust-vendor/zerocopy/tests/ui-msrv/transmute-src-not-intobytes.stderr +6 -6
- data/rust-vendor/zerocopy/tests/ui-msrv/try_transmute-dst-not-tryfrombytes.rs +1 -3
- data/rust-vendor/zerocopy/tests/ui-msrv/try_transmute-dst-not-tryfrombytes.stderr +12 -12
- data/rust-vendor/zerocopy/tests/ui-msrv/try_transmute-size-decrease.rs +1 -3
- data/rust-vendor/zerocopy/tests/ui-msrv/try_transmute-size-decrease.stderr +2 -2
- data/rust-vendor/zerocopy/tests/ui-msrv/try_transmute-size-increase.rs +1 -3
- data/rust-vendor/zerocopy/tests/ui-msrv/try_transmute-size-increase.stderr +2 -2
- data/rust-vendor/zerocopy/tests/ui-msrv/try_transmute-src-not-intobytes.rs +1 -3
- data/rust-vendor/zerocopy/tests/ui-msrv/try_transmute-src-not-intobytes.stderr +4 -4
- data/rust-vendor/zerocopy/tests/ui-msrv/try_transmute_mut-alignment-increase.rs +1 -3
- data/rust-vendor/zerocopy/tests/ui-msrv/try_transmute_mut-alignment-increase.stderr +2 -2
- data/rust-vendor/zerocopy/tests/ui-msrv/try_transmute_mut-dst-not-tryfrombytes.rs +1 -3
- data/rust-vendor/zerocopy/tests/ui-msrv/try_transmute_mut-dst-not-tryfrombytes.stderr +16 -16
- data/rust-vendor/zerocopy/tests/ui-msrv/try_transmute_mut-size-decrease.rs +1 -3
- data/rust-vendor/zerocopy/tests/ui-msrv/try_transmute_mut-size-decrease.stderr +2 -2
- data/rust-vendor/zerocopy/tests/ui-msrv/try_transmute_mut-size-increase.rs +1 -3
- data/rust-vendor/zerocopy/tests/ui-msrv/try_transmute_mut-size-increase.stderr +4 -4
- data/rust-vendor/zerocopy/tests/ui-msrv/try_transmute_mut-src-not-frombytes.rs +0 -2
- data/rust-vendor/zerocopy/tests/ui-msrv/try_transmute_mut-src-not-frombytes.stderr +6 -6
- data/rust-vendor/zerocopy/tests/ui-msrv/try_transmute_mut-src-not-intobytes.rs +0 -2
- data/rust-vendor/zerocopy/tests/ui-msrv/try_transmute_mut-src-not-intobytes.stderr +6 -6
- data/rust-vendor/zerocopy/tests/ui-msrv/try_transmute_ref-alignment-increase.rs +1 -3
- data/rust-vendor/zerocopy/tests/ui-msrv/try_transmute_ref-alignment-increase.stderr +2 -2
- data/rust-vendor/zerocopy/tests/ui-msrv/try_transmute_ref-dst-mutable.rs +0 -2
- data/rust-vendor/zerocopy/tests/ui-msrv/try_transmute_ref-dst-mutable.stderr +4 -4
- data/rust-vendor/zerocopy/tests/ui-msrv/try_transmute_ref-dst-not-immutable-tryfrombytes.rs +1 -3
- data/rust-vendor/zerocopy/tests/ui-msrv/try_transmute_ref-dst-not-immutable-tryfrombytes.stderr +16 -16
- data/rust-vendor/zerocopy/tests/ui-msrv/try_transmute_ref-size-decrease.rs +1 -3
- data/rust-vendor/zerocopy/tests/ui-msrv/try_transmute_ref-size-decrease.stderr +2 -2
- data/rust-vendor/zerocopy/tests/ui-msrv/try_transmute_ref-size-increase.rs +1 -3
- data/rust-vendor/zerocopy/tests/ui-msrv/try_transmute_ref-size-increase.stderr +2 -2
- data/rust-vendor/zerocopy/tests/ui-msrv/try_transmute_ref-src-not-immutable-intobytes.rs +1 -3
- data/rust-vendor/zerocopy/tests/ui-msrv/try_transmute_ref-src-not-immutable-intobytes.stderr +8 -8
- data/rust-vendor/zerocopy/tests/ui-nightly/diagnostic-not-implemented-from-bytes.rs +1 -3
- data/rust-vendor/zerocopy/tests/ui-nightly/diagnostic-not-implemented-from-bytes.stderr +15 -15
- data/rust-vendor/zerocopy/tests/ui-nightly/diagnostic-not-implemented-from-zeros.rs +1 -3
- data/rust-vendor/zerocopy/tests/ui-nightly/diagnostic-not-implemented-from-zeros.stderr +12 -12
- data/rust-vendor/zerocopy/tests/ui-nightly/diagnostic-not-implemented-immutable.rs +1 -3
- data/rust-vendor/zerocopy/tests/ui-nightly/diagnostic-not-implemented-immutable.stderr +13 -13
- data/rust-vendor/zerocopy/tests/ui-nightly/diagnostic-not-implemented-into-bytes.rs +1 -3
- data/rust-vendor/zerocopy/tests/ui-nightly/diagnostic-not-implemented-into-bytes.stderr +8 -8
- data/rust-vendor/zerocopy/tests/ui-nightly/diagnostic-not-implemented-issue-1296.rs +1 -3
- data/rust-vendor/zerocopy/tests/ui-nightly/diagnostic-not-implemented-issue-1296.stderr +16 -16
- data/rust-vendor/zerocopy/tests/ui-nightly/diagnostic-not-implemented-known-layout.rs +1 -3
- data/rust-vendor/zerocopy/tests/ui-nightly/diagnostic-not-implemented-known-layout.stderr +8 -8
- data/rust-vendor/zerocopy/tests/ui-nightly/diagnostic-not-implemented-try-from-bytes.rs +1 -3
- data/rust-vendor/zerocopy/tests/ui-nightly/diagnostic-not-implemented-try-from-bytes.stderr +15 -15
- data/rust-vendor/zerocopy/tests/ui-nightly/diagnostic-not-implemented-unaligned.rs +1 -3
- data/rust-vendor/zerocopy/tests/ui-nightly/diagnostic-not-implemented-unaligned.stderr +5 -5
- data/rust-vendor/zerocopy/tests/ui-nightly/include_value_not_from_bytes.rs +3 -5
- data/rust-vendor/zerocopy/tests/ui-nightly/include_value_not_from_bytes.stderr +21 -21
- data/rust-vendor/zerocopy/tests/ui-nightly/include_value_wrong_size.rs +1 -4
- data/rust-vendor/zerocopy/tests/ui-nightly/include_value_wrong_size.stderr +8 -8
- data/rust-vendor/zerocopy/tests/ui-nightly/invalid-impls/invalid-impls.rs +0 -1
- data/rust-vendor/zerocopy/tests/ui-nightly/invalid-impls/invalid-impls.stderr +35 -51
- data/rust-vendor/zerocopy/tests/ui-nightly/ptr-is-invariant-over-v.stderr +2 -2
- data/rust-vendor/zerocopy/tests/ui-nightly/transmute-dst-not-frombytes.rs +1 -3
- data/rust-vendor/zerocopy/tests/ui-nightly/transmute-dst-not-frombytes.stderr +15 -15
- data/rust-vendor/zerocopy/tests/ui-nightly/transmute-mut-const.rs +1 -3
- data/rust-vendor/zerocopy/tests/ui-nightly/transmute-mut-const.stderr +7 -7
- data/rust-vendor/zerocopy/tests/ui-nightly/transmute-mut-dst-not-a-reference.rs +0 -2
- data/rust-vendor/zerocopy/tests/ui-nightly/transmute-mut-dst-not-a-reference.stderr +2 -2
- data/rust-vendor/zerocopy/tests/ui-nightly/transmute-mut-dst-not-frombytes.rs +0 -2
- data/rust-vendor/zerocopy/tests/ui-nightly/transmute-mut-dst-not-frombytes.stderr +12 -12
- data/rust-vendor/zerocopy/tests/ui-nightly/transmute-mut-dst-not-intobytes.rs +0 -2
- data/rust-vendor/zerocopy/tests/ui-nightly/transmute-mut-dst-not-intobytes.stderr +5 -5
- data/rust-vendor/zerocopy/tests/ui-nightly/transmute-mut-dst-unsized.rs +0 -2
- data/rust-vendor/zerocopy/tests/ui-nightly/transmute-mut-dst-unsized.stderr +3 -3
- data/rust-vendor/zerocopy/tests/ui-nightly/transmute-mut-src-dst-not-references.rs +0 -2
- data/rust-vendor/zerocopy/tests/ui-nightly/transmute-mut-src-dst-not-references.stderr +3 -3
- data/rust-vendor/zerocopy/tests/ui-nightly/transmute-mut-src-immutable.rs +0 -2
- data/rust-vendor/zerocopy/tests/ui-nightly/transmute-mut-src-immutable.stderr +2 -2
- data/rust-vendor/zerocopy/tests/ui-nightly/transmute-mut-src-not-a-reference.rs +0 -2
- data/rust-vendor/zerocopy/tests/ui-nightly/transmute-mut-src-not-a-reference.stderr +3 -3
- data/rust-vendor/zerocopy/tests/ui-nightly/transmute-mut-src-not-frombytes.rs +0 -2
- data/rust-vendor/zerocopy/tests/ui-nightly/transmute-mut-src-not-frombytes.stderr +12 -12
- data/rust-vendor/zerocopy/tests/ui-nightly/transmute-mut-src-not-intobytes.rs +0 -2
- data/rust-vendor/zerocopy/tests/ui-nightly/transmute-mut-src-not-intobytes.stderr +5 -5
- data/rust-vendor/zerocopy/tests/ui-nightly/transmute-mut-src-unsized.rs +0 -2
- data/rust-vendor/zerocopy/tests/ui-nightly/transmute-mut-src-unsized.stderr +3 -3
- data/rust-vendor/zerocopy/tests/ui-nightly/transmute-ptr-to-usize.rs +0 -2
- data/rust-vendor/zerocopy/tests/ui-nightly/transmute-ptr-to-usize.stderr +4 -4
- data/rust-vendor/zerocopy/tests/ui-nightly/transmute-ref-dst-mutable.rs +0 -2
- data/rust-vendor/zerocopy/tests/ui-nightly/transmute-ref-dst-mutable.stderr +6 -6
- data/rust-vendor/zerocopy/tests/ui-nightly/transmute-ref-dst-not-a-reference.rs +0 -2
- data/rust-vendor/zerocopy/tests/ui-nightly/transmute-ref-dst-not-a-reference.stderr +6 -6
- data/rust-vendor/zerocopy/tests/ui-nightly/transmute-ref-dst-not-frombytes.rs +1 -3
- data/rust-vendor/zerocopy/tests/ui-nightly/transmute-ref-dst-not-frombytes.stderr +16 -16
- data/rust-vendor/zerocopy/tests/ui-nightly/transmute-ref-dst-not-nocell.rs +1 -3
- data/rust-vendor/zerocopy/tests/ui-nightly/transmute-ref-dst-not-nocell.stderr +14 -14
- data/rust-vendor/zerocopy/tests/ui-nightly/transmute-ref-dst-unsized.rs +0 -2
- data/rust-vendor/zerocopy/tests/ui-nightly/transmute-ref-dst-unsized.stderr +3 -3
- data/rust-vendor/zerocopy/tests/ui-nightly/transmute-ref-src-dst-not-references.rs +0 -2
- data/rust-vendor/zerocopy/tests/ui-nightly/transmute-ref-src-dst-not-references.stderr +9 -9
- data/rust-vendor/zerocopy/tests/ui-nightly/transmute-ref-src-not-a-reference.rs +0 -2
- data/rust-vendor/zerocopy/tests/ui-nightly/transmute-ref-src-not-a-reference.stderr +3 -3
- data/rust-vendor/zerocopy/tests/ui-nightly/transmute-ref-src-not-intobytes.rs +1 -3
- data/rust-vendor/zerocopy/tests/ui-nightly/transmute-ref-src-not-intobytes.stderr +18 -18
- data/rust-vendor/zerocopy/tests/ui-nightly/transmute-ref-src-not-nocell.rs +1 -3
- data/rust-vendor/zerocopy/tests/ui-nightly/transmute-ref-src-not-nocell.stderr +28 -28
- data/rust-vendor/zerocopy/tests/ui-nightly/transmute-ref-src-unsized.rs +0 -2
- data/rust-vendor/zerocopy/tests/ui-nightly/transmute-ref-src-unsized.stderr +3 -3
- data/rust-vendor/zerocopy/tests/ui-nightly/transmute-size-decrease.rs +1 -3
- data/rust-vendor/zerocopy/tests/ui-nightly/transmute-size-decrease.stderr +4 -4
- data/rust-vendor/zerocopy/tests/ui-nightly/transmute-size-increase-allow-shrink.rs +1 -3
- data/rust-vendor/zerocopy/tests/ui-nightly/transmute-size-increase-allow-shrink.stderr +4 -4
- data/rust-vendor/zerocopy/tests/ui-nightly/transmute-size-increase.rs +1 -3
- data/rust-vendor/zerocopy/tests/ui-nightly/transmute-size-increase.stderr +4 -4
- data/rust-vendor/zerocopy/tests/ui-nightly/transmute-src-not-intobytes.rs +1 -3
- data/rust-vendor/zerocopy/tests/ui-nightly/transmute-src-not-intobytes.stderr +8 -8
- data/rust-vendor/zerocopy/tests/ui-nightly/try_transmute-dst-not-tryfrombytes.rs +1 -3
- data/rust-vendor/zerocopy/tests/ui-nightly/try_transmute-dst-not-tryfrombytes.stderr +43 -43
- data/rust-vendor/zerocopy/tests/ui-nightly/try_transmute-size-decrease.rs +1 -3
- data/rust-vendor/zerocopy/tests/ui-nightly/try_transmute-size-decrease.stderr +2 -2
- data/rust-vendor/zerocopy/tests/ui-nightly/try_transmute-size-increase.rs +1 -3
- data/rust-vendor/zerocopy/tests/ui-nightly/try_transmute-size-increase.stderr +2 -2
- data/rust-vendor/zerocopy/tests/ui-nightly/try_transmute-src-not-intobytes.rs +1 -3
- data/rust-vendor/zerocopy/tests/ui-nightly/try_transmute-src-not-intobytes.stderr +8 -8
- data/rust-vendor/zerocopy/tests/ui-nightly/try_transmute_mut-alignment-increase.rs +1 -3
- data/rust-vendor/zerocopy/tests/ui-nightly/try_transmute_mut-alignment-increase.stderr +4 -4
- data/rust-vendor/zerocopy/tests/ui-nightly/try_transmute_mut-dst-not-tryfrombytes.rs +1 -3
- data/rust-vendor/zerocopy/tests/ui-nightly/try_transmute_mut-dst-not-tryfrombytes.stderr +51 -51
- data/rust-vendor/zerocopy/tests/ui-nightly/try_transmute_mut-size-decrease.rs +1 -3
- data/rust-vendor/zerocopy/tests/ui-nightly/try_transmute_mut-size-decrease.stderr +2 -2
- data/rust-vendor/zerocopy/tests/ui-nightly/try_transmute_mut-size-increase.rs +1 -3
- data/rust-vendor/zerocopy/tests/ui-nightly/try_transmute_mut-size-increase.stderr +4 -4
- data/rust-vendor/zerocopy/tests/ui-nightly/try_transmute_mut-src-not-frombytes.rs +0 -2
- data/rust-vendor/zerocopy/tests/ui-nightly/try_transmute_mut-src-not-frombytes.stderr +29 -29
- data/rust-vendor/zerocopy/tests/ui-nightly/try_transmute_mut-src-not-intobytes.rs +0 -2
- data/rust-vendor/zerocopy/tests/ui-nightly/try_transmute_mut-src-not-intobytes.stderr +22 -22
- data/rust-vendor/zerocopy/tests/ui-nightly/try_transmute_ref-alignment-increase.rs +1 -3
- data/rust-vendor/zerocopy/tests/ui-nightly/try_transmute_ref-alignment-increase.stderr +4 -4
- data/rust-vendor/zerocopy/tests/ui-nightly/try_transmute_ref-dst-mutable.rs +0 -2
- data/rust-vendor/zerocopy/tests/ui-nightly/try_transmute_ref-dst-mutable.stderr +6 -6
- data/rust-vendor/zerocopy/tests/ui-nightly/try_transmute_ref-dst-not-immutable-tryfrombytes.rs +1 -3
- data/rust-vendor/zerocopy/tests/ui-nightly/try_transmute_ref-dst-not-immutable-tryfrombytes.stderr +56 -56
- data/rust-vendor/zerocopy/tests/ui-nightly/try_transmute_ref-size-decrease.rs +1 -3
- data/rust-vendor/zerocopy/tests/ui-nightly/try_transmute_ref-size-decrease.stderr +2 -2
- data/rust-vendor/zerocopy/tests/ui-nightly/try_transmute_ref-size-increase.rs +1 -3
- data/rust-vendor/zerocopy/tests/ui-nightly/try_transmute_ref-size-increase.stderr +4 -4
- data/rust-vendor/zerocopy/tests/ui-nightly/try_transmute_ref-src-not-immutable-intobytes.rs +1 -3
- data/rust-vendor/zerocopy/tests/ui-nightly/try_transmute_ref-src-not-immutable-intobytes.stderr +21 -21
- data/rust-vendor/zerocopy/tests/ui-stable/diagnostic-not-implemented-from-bytes.rs +1 -3
- data/rust-vendor/zerocopy/tests/ui-stable/diagnostic-not-implemented-from-bytes.stderr +15 -15
- data/rust-vendor/zerocopy/tests/ui-stable/diagnostic-not-implemented-from-zeros.rs +1 -3
- data/rust-vendor/zerocopy/tests/ui-stable/diagnostic-not-implemented-from-zeros.stderr +12 -12
- data/rust-vendor/zerocopy/tests/ui-stable/diagnostic-not-implemented-immutable.rs +1 -3
- data/rust-vendor/zerocopy/tests/ui-stable/diagnostic-not-implemented-immutable.stderr +13 -13
- data/rust-vendor/zerocopy/tests/ui-stable/diagnostic-not-implemented-into-bytes.rs +1 -3
- data/rust-vendor/zerocopy/tests/ui-stable/diagnostic-not-implemented-into-bytes.stderr +8 -8
- data/rust-vendor/zerocopy/tests/ui-stable/diagnostic-not-implemented-issue-1296.rs +1 -3
- data/rust-vendor/zerocopy/tests/ui-stable/diagnostic-not-implemented-issue-1296.stderr +16 -16
- data/rust-vendor/zerocopy/tests/ui-stable/diagnostic-not-implemented-known-layout.rs +1 -3
- data/rust-vendor/zerocopy/tests/ui-stable/diagnostic-not-implemented-known-layout.stderr +8 -8
- data/rust-vendor/zerocopy/tests/ui-stable/diagnostic-not-implemented-try-from-bytes.rs +1 -3
- data/rust-vendor/zerocopy/tests/ui-stable/diagnostic-not-implemented-try-from-bytes.stderr +15 -15
- data/rust-vendor/zerocopy/tests/ui-stable/diagnostic-not-implemented-unaligned.rs +1 -3
- data/rust-vendor/zerocopy/tests/ui-stable/diagnostic-not-implemented-unaligned.stderr +5 -5
- data/rust-vendor/zerocopy/tests/ui-stable/include_value_not_from_bytes.rs +3 -5
- data/rust-vendor/zerocopy/tests/ui-stable/include_value_not_from_bytes.stderr +21 -21
- data/rust-vendor/zerocopy/tests/ui-stable/include_value_wrong_size.rs +1 -4
- data/rust-vendor/zerocopy/tests/ui-stable/include_value_wrong_size.stderr +8 -8
- data/rust-vendor/zerocopy/tests/ui-stable/invalid-impls/invalid-impls.rs +0 -1
- data/rust-vendor/zerocopy/tests/ui-stable/invalid-impls/invalid-impls.stderr +37 -37
- data/rust-vendor/zerocopy/tests/ui-stable/ptr-is-invariant-over-v.stderr +2 -2
- data/rust-vendor/zerocopy/tests/ui-stable/transmute-dst-not-frombytes.rs +1 -3
- data/rust-vendor/zerocopy/tests/ui-stable/transmute-dst-not-frombytes.stderr +15 -15
- data/rust-vendor/zerocopy/tests/ui-stable/transmute-mut-const.rs +1 -3
- data/rust-vendor/zerocopy/tests/ui-stable/transmute-mut-const.stderr +6 -6
- data/rust-vendor/zerocopy/tests/ui-stable/transmute-mut-dst-not-a-reference.rs +0 -2
- data/rust-vendor/zerocopy/tests/ui-stable/transmute-mut-dst-not-a-reference.stderr +2 -2
- data/rust-vendor/zerocopy/tests/ui-stable/transmute-mut-dst-not-frombytes.rs +0 -2
- data/rust-vendor/zerocopy/tests/ui-stable/transmute-mut-dst-not-frombytes.stderr +11 -11
- data/rust-vendor/zerocopy/tests/ui-stable/transmute-mut-dst-not-intobytes.rs +0 -2
- data/rust-vendor/zerocopy/tests/ui-stable/transmute-mut-dst-not-intobytes.stderr +4 -4
- data/rust-vendor/zerocopy/tests/ui-stable/transmute-mut-dst-unsized.rs +0 -2
- data/rust-vendor/zerocopy/tests/ui-stable/transmute-mut-dst-unsized.stderr +2 -2
- data/rust-vendor/zerocopy/tests/ui-stable/transmute-mut-src-dst-not-references.rs +0 -2
- data/rust-vendor/zerocopy/tests/ui-stable/transmute-mut-src-dst-not-references.stderr +3 -3
- data/rust-vendor/zerocopy/tests/ui-stable/transmute-mut-src-immutable.rs +0 -2
- data/rust-vendor/zerocopy/tests/ui-stable/transmute-mut-src-immutable.stderr +2 -2
- data/rust-vendor/zerocopy/tests/ui-stable/transmute-mut-src-not-a-reference.rs +0 -2
- data/rust-vendor/zerocopy/tests/ui-stable/transmute-mut-src-not-a-reference.stderr +3 -3
- data/rust-vendor/zerocopy/tests/ui-stable/transmute-mut-src-not-frombytes.rs +0 -2
- data/rust-vendor/zerocopy/tests/ui-stable/transmute-mut-src-not-frombytes.stderr +11 -11
- data/rust-vendor/zerocopy/tests/ui-stable/transmute-mut-src-not-intobytes.rs +0 -2
- data/rust-vendor/zerocopy/tests/ui-stable/transmute-mut-src-not-intobytes.stderr +4 -4
- data/rust-vendor/zerocopy/tests/ui-stable/transmute-mut-src-unsized.rs +0 -2
- data/rust-vendor/zerocopy/tests/ui-stable/transmute-mut-src-unsized.stderr +2 -2
- data/rust-vendor/zerocopy/tests/ui-stable/transmute-ptr-to-usize.rs +0 -2
- data/rust-vendor/zerocopy/tests/ui-stable/transmute-ptr-to-usize.stderr +9 -5
- data/rust-vendor/zerocopy/tests/ui-stable/transmute-ref-dst-mutable.rs +0 -2
- data/rust-vendor/zerocopy/tests/ui-stable/transmute-ref-dst-mutable.stderr +6 -6
- data/rust-vendor/zerocopy/tests/ui-stable/transmute-ref-dst-not-a-reference.rs +0 -2
- data/rust-vendor/zerocopy/tests/ui-stable/transmute-ref-dst-not-a-reference.stderr +6 -6
- data/rust-vendor/zerocopy/tests/ui-stable/transmute-ref-dst-not-frombytes.rs +1 -3
- data/rust-vendor/zerocopy/tests/ui-stable/transmute-ref-dst-not-frombytes.stderr +16 -16
- data/rust-vendor/zerocopy/tests/ui-stable/transmute-ref-dst-not-nocell.rs +1 -3
- data/rust-vendor/zerocopy/tests/ui-stable/transmute-ref-dst-not-nocell.stderr +14 -14
- data/rust-vendor/zerocopy/tests/ui-stable/transmute-ref-dst-unsized.rs +0 -2
- data/rust-vendor/zerocopy/tests/ui-stable/transmute-ref-dst-unsized.stderr +2 -2
- data/rust-vendor/zerocopy/tests/ui-stable/transmute-ref-src-dst-not-references.rs +0 -2
- data/rust-vendor/zerocopy/tests/ui-stable/transmute-ref-src-dst-not-references.stderr +9 -9
- data/rust-vendor/zerocopy/tests/ui-stable/transmute-ref-src-not-a-reference.rs +0 -2
- data/rust-vendor/zerocopy/tests/ui-stable/transmute-ref-src-not-a-reference.stderr +3 -3
- data/rust-vendor/zerocopy/tests/ui-stable/transmute-ref-src-not-intobytes.rs +1 -3
- data/rust-vendor/zerocopy/tests/ui-stable/transmute-ref-src-not-intobytes.stderr +18 -18
- data/rust-vendor/zerocopy/tests/ui-stable/transmute-ref-src-not-nocell.rs +1 -3
- data/rust-vendor/zerocopy/tests/ui-stable/transmute-ref-src-not-nocell.stderr +28 -28
- data/rust-vendor/zerocopy/tests/ui-stable/transmute-ref-src-unsized.rs +0 -2
- data/rust-vendor/zerocopy/tests/ui-stable/transmute-ref-src-unsized.stderr +2 -2
- data/rust-vendor/zerocopy/tests/ui-stable/transmute-size-decrease.rs +1 -3
- data/rust-vendor/zerocopy/tests/ui-stable/transmute-size-decrease.stderr +4 -4
- data/rust-vendor/zerocopy/tests/ui-stable/transmute-size-increase-allow-shrink.rs +1 -3
- data/rust-vendor/zerocopy/tests/ui-stable/transmute-size-increase-allow-shrink.stderr +4 -4
- data/rust-vendor/zerocopy/tests/ui-stable/transmute-size-increase.rs +1 -3
- data/rust-vendor/zerocopy/tests/ui-stable/transmute-size-increase.stderr +4 -4
- data/rust-vendor/zerocopy/tests/ui-stable/transmute-src-not-intobytes.rs +1 -3
- data/rust-vendor/zerocopy/tests/ui-stable/transmute-src-not-intobytes.stderr +8 -8
- data/rust-vendor/zerocopy/tests/ui-stable/try_transmute-dst-not-tryfrombytes.rs +1 -3
- data/rust-vendor/zerocopy/tests/ui-stable/try_transmute-dst-not-tryfrombytes.stderr +42 -42
- data/rust-vendor/zerocopy/tests/ui-stable/try_transmute-size-decrease.rs +1 -3
- data/rust-vendor/zerocopy/tests/ui-stable/try_transmute-size-decrease.stderr +2 -2
- data/rust-vendor/zerocopy/tests/ui-stable/try_transmute-size-increase.rs +1 -3
- data/rust-vendor/zerocopy/tests/ui-stable/try_transmute-size-increase.stderr +2 -2
- data/rust-vendor/zerocopy/tests/ui-stable/try_transmute-src-not-intobytes.rs +1 -3
- data/rust-vendor/zerocopy/tests/ui-stable/try_transmute-src-not-intobytes.stderr +7 -7
- data/rust-vendor/zerocopy/tests/ui-stable/try_transmute_mut-alignment-increase.rs +1 -3
- data/rust-vendor/zerocopy/tests/ui-stable/try_transmute_mut-alignment-increase.stderr +2 -2
- data/rust-vendor/zerocopy/tests/ui-stable/try_transmute_mut-dst-not-tryfrombytes.rs +1 -3
- data/rust-vendor/zerocopy/tests/ui-stable/try_transmute_mut-dst-not-tryfrombytes.stderr +49 -49
- data/rust-vendor/zerocopy/tests/ui-stable/try_transmute_mut-size-decrease.rs +1 -3
- data/rust-vendor/zerocopy/tests/ui-stable/try_transmute_mut-size-decrease.stderr +2 -2
- data/rust-vendor/zerocopy/tests/ui-stable/try_transmute_mut-size-increase.rs +1 -3
- data/rust-vendor/zerocopy/tests/ui-stable/try_transmute_mut-size-increase.stderr +4 -4
- data/rust-vendor/zerocopy/tests/ui-stable/try_transmute_mut-src-not-frombytes.rs +0 -2
- data/rust-vendor/zerocopy/tests/ui-stable/try_transmute_mut-src-not-frombytes.stderr +26 -26
- data/rust-vendor/zerocopy/tests/ui-stable/try_transmute_mut-src-not-intobytes.rs +0 -2
- data/rust-vendor/zerocopy/tests/ui-stable/try_transmute_mut-src-not-intobytes.stderr +19 -19
- data/rust-vendor/zerocopy/tests/ui-stable/try_transmute_ref-alignment-increase.rs +1 -3
- data/rust-vendor/zerocopy/tests/ui-stable/try_transmute_ref-alignment-increase.stderr +2 -2
- data/rust-vendor/zerocopy/tests/ui-stable/try_transmute_ref-dst-mutable.rs +0 -2
- data/rust-vendor/zerocopy/tests/ui-stable/try_transmute_ref-dst-mutable.stderr +6 -6
- data/rust-vendor/zerocopy/tests/ui-stable/try_transmute_ref-dst-not-immutable-tryfrombytes.rs +1 -3
- data/rust-vendor/zerocopy/tests/ui-stable/try_transmute_ref-dst-not-immutable-tryfrombytes.stderr +54 -54
- data/rust-vendor/zerocopy/tests/ui-stable/try_transmute_ref-size-decrease.rs +1 -3
- data/rust-vendor/zerocopy/tests/ui-stable/try_transmute_ref-size-decrease.stderr +2 -2
- data/rust-vendor/zerocopy/tests/ui-stable/try_transmute_ref-size-increase.rs +1 -3
- data/rust-vendor/zerocopy/tests/ui-stable/try_transmute_ref-size-increase.stderr +2 -2
- data/rust-vendor/zerocopy/tests/ui-stable/try_transmute_ref-src-not-immutable-intobytes.rs +1 -3
- data/rust-vendor/zerocopy/tests/ui-stable/try_transmute_ref-src-not-immutable-intobytes.stderr +19 -19
- data/rust-vendor/zerocopy-derive/.cargo-checksum.json +1 -1
- data/rust-vendor/zerocopy-derive/.cargo_vcs_info.json +1 -1
- data/rust-vendor/zerocopy-derive/Cargo.lock +3 -11
- data/rust-vendor/zerocopy-derive/Cargo.toml +13 -11
- data/rust-vendor/zerocopy-derive/Cargo.toml.orig +7 -10
- data/rust-vendor/zerocopy-derive/src/derive/from_bytes.rs +188 -0
- data/rust-vendor/zerocopy-derive/src/derive/into_bytes.rs +158 -0
- data/rust-vendor/zerocopy-derive/src/derive/known_layout.rs +348 -0
- data/rust-vendor/zerocopy-derive/src/derive/mod.rs +130 -0
- data/rust-vendor/zerocopy-derive/src/derive/try_from_bytes.rs +729 -0
- data/rust-vendor/zerocopy-derive/src/derive/unaligned.rs +78 -0
- data/rust-vendor/zerocopy-derive/src/lib.rs +31 -1893
- data/rust-vendor/zerocopy-derive/src/output_tests/expected/eq.expected.rs +17 -0
- data/rust-vendor/zerocopy-derive/src/output_tests/expected/from_bytes_enum.expected.rs +64 -0
- data/rust-vendor/zerocopy-derive/src/output_tests/expected/from_bytes_struct.expected.rs +64 -0
- data/rust-vendor/zerocopy-derive/src/output_tests/expected/from_bytes_union.expected.rs +144 -0
- data/rust-vendor/zerocopy-derive/src/output_tests/expected/from_zeros.expected.rs +39 -0
- data/rust-vendor/zerocopy-derive/src/output_tests/expected/hash.expected.rs +24 -0
- data/rust-vendor/zerocopy-derive/src/output_tests/expected/immutable.expected.rs +17 -0
- data/rust-vendor/zerocopy-derive/src/output_tests/expected/into_bytes_enum.expected.rs +17 -0
- data/rust-vendor/zerocopy-derive/src/output_tests/expected/into_bytes_struct_basic.expected.rs +25 -0
- data/rust-vendor/zerocopy-derive/src/output_tests/expected/into_bytes_struct_empty.expected.rs +17 -0
- data/rust-vendor/zerocopy-derive/src/output_tests/expected/into_bytes_struct_trailing.expected.rs +25 -0
- data/rust-vendor/zerocopy-derive/src/output_tests/expected/into_bytes_struct_trailing_generic.expected.rs +21 -0
- data/rust-vendor/zerocopy-derive/src/output_tests/expected/known_layout_repr_c_struct.expected.rs +135 -0
- data/rust-vendor/zerocopy-derive/src/output_tests/expected/known_layout_struct.expected.rs +34 -0
- data/rust-vendor/zerocopy-derive/src/output_tests/expected/split_at_repr_c.expected.rs +22 -0
- data/rust-vendor/zerocopy-derive/src/output_tests/expected/split_at_repr_transparent.expected.rs +22 -0
- data/rust-vendor/zerocopy-derive/src/output_tests/expected/try_from_bytes.expected.rs +22 -0
- data/rust-vendor/zerocopy-derive/src/output_tests/expected/try_from_bytes_enum_1.expected.rs +2802 -0
- data/rust-vendor/zerocopy-derive/src/output_tests/expected/try_from_bytes_enum_2.expected.rs +2802 -0
- data/rust-vendor/zerocopy-derive/src/output_tests/expected/try_from_bytes_enum_3.expected.rs +2802 -0
- data/rust-vendor/zerocopy-derive/src/output_tests/expected/try_from_bytes_trivial_is_bit_valid_enum.expected.rs +22 -0
- data/rust-vendor/zerocopy-derive/src/output_tests/expected/unaligned.expected.rs +17 -0
- data/rust-vendor/zerocopy-derive/src/output_tests/mod.rs +960 -0
- data/rust-vendor/zerocopy-derive/src/util.rs +757 -0
- data/rust-vendor/zerocopy-derive/tests/deprecated.rs +6 -0
- data/rust-vendor/zerocopy-derive/tests/enum_from_zeros.rs +9 -0
- data/rust-vendor/zerocopy-derive/tests/enum_known_layout.rs +4 -0
- data/rust-vendor/zerocopy-derive/tests/enum_no_cell.rs +4 -0
- data/rust-vendor/zerocopy-derive/tests/enum_to_bytes.rs +14 -0
- data/rust-vendor/zerocopy-derive/tests/enum_try_from_bytes.rs +37 -15
- data/rust-vendor/zerocopy-derive/tests/enum_unaligned.rs +4 -0
- data/rust-vendor/zerocopy-derive/tests/eq.rs +1 -0
- data/rust-vendor/zerocopy-derive/tests/hash.rs +1 -0
- data/rust-vendor/zerocopy-derive/tests/hygiene.rs +3 -1
- data/rust-vendor/zerocopy-derive/tests/include.rs +26 -4
- data/rust-vendor/zerocopy-derive/tests/issue_2117.rs +1 -0
- data/rust-vendor/zerocopy-derive/tests/issue_2835.rs +2 -1
- data/rust-vendor/zerocopy-derive/tests/issue_2880.rs +292 -0
- data/rust-vendor/zerocopy-derive/tests/issue_2915.rs +78 -0
- data/rust-vendor/zerocopy-derive/tests/paths_and_modules.rs +3 -0
- data/rust-vendor/zerocopy-derive/tests/priv_in_pub.rs +2 -0
- data/rust-vendor/zerocopy-derive/tests/struct_from_bytes.rs +6 -0
- data/rust-vendor/zerocopy-derive/tests/struct_from_zeros.rs +6 -0
- data/rust-vendor/zerocopy-derive/tests/struct_known_layout.rs +9 -0
- data/rust-vendor/zerocopy-derive/tests/struct_no_cell.rs +8 -0
- data/rust-vendor/zerocopy-derive/tests/struct_to_bytes.rs +17 -0
- data/rust-vendor/zerocopy-derive/tests/struct_try_from_bytes.rs +29 -65
- data/rust-vendor/zerocopy-derive/tests/struct_unaligned.rs +7 -0
- data/rust-vendor/zerocopy-derive/tests/ui-msrv/derive_transparent.rs +3 -2
- data/rust-vendor/zerocopy-derive/tests/ui-msrv/derive_transparent.stderr +32 -32
- data/rust-vendor/zerocopy-derive/tests/ui-msrv/enum.rs +48 -1
- data/rust-vendor/zerocopy-derive/tests/ui-msrv/enum.stderr +129 -126
- data/rust-vendor/zerocopy-derive/tests/ui-msrv/enum_from_bytes_u8_too_few.rs +2 -1
- data/rust-vendor/zerocopy-derive/tests/ui-msrv/enum_from_bytes_u8_too_few.stderr +6 -6
- data/rust-vendor/zerocopy-derive/tests/ui-msrv/late_compile_pass.rs +9 -2
- data/rust-vendor/zerocopy-derive/tests/ui-msrv/late_compile_pass.stderr +37 -37
- data/rust-vendor/zerocopy-derive/tests/ui-msrv/mid_compile_pass.rs +6 -2
- data/rust-vendor/zerocopy-derive/tests/ui-msrv/mid_compile_pass.stderr +26 -26
- data/rust-vendor/zerocopy-derive/tests/ui-msrv/msrv_specific.rs +3 -2
- data/rust-vendor/zerocopy-derive/tests/ui-msrv/msrv_specific.stderr +7 -7
- data/rust-vendor/zerocopy-derive/tests/ui-msrv/privacy.rs +66 -29
- data/rust-vendor/zerocopy-derive/tests/ui-msrv/privacy.stderr +78 -78
- data/rust-vendor/zerocopy-derive/tests/ui-msrv/struct.rs +34 -2
- data/rust-vendor/zerocopy-derive/tests/ui-msrv/struct.stderr +79 -79
- data/rust-vendor/zerocopy-derive/tests/ui-msrv/union.rs +12 -1
- data/rust-vendor/zerocopy-derive/tests/ui-msrv/union.stderr +29 -29
- data/rust-vendor/zerocopy-derive/tests/ui-msrv/union_into_bytes_cfg/union_into_bytes_cfg.rs +3 -2
- data/rust-vendor/zerocopy-derive/tests/ui-nightly/absence_of_deprecated_warning.rs +3 -2
- data/rust-vendor/zerocopy-derive/tests/ui-nightly/absence_of_deprecated_warning.stderr +2 -2
- data/rust-vendor/zerocopy-derive/tests/ui-nightly/derive_transparent.rs +3 -2
- data/rust-vendor/zerocopy-derive/tests/ui-nightly/derive_transparent.stderr +57 -57
- data/rust-vendor/zerocopy-derive/tests/ui-nightly/enum.rs +48 -1
- data/rust-vendor/zerocopy-derive/tests/ui-nightly/enum.stderr +200 -192
- data/rust-vendor/zerocopy-derive/tests/ui-nightly/enum_from_bytes_u8_too_few.rs +2 -1
- data/rust-vendor/zerocopy-derive/tests/ui-nightly/enum_from_bytes_u8_too_few.stderr +6 -6
- data/rust-vendor/zerocopy-derive/tests/ui-nightly/late_compile_pass.rs +9 -2
- data/rust-vendor/zerocopy-derive/tests/ui-nightly/late_compile_pass.stderr +105 -105
- data/rust-vendor/zerocopy-derive/tests/ui-nightly/mid_compile_pass.rs +6 -2
- data/rust-vendor/zerocopy-derive/tests/ui-nightly/mid_compile_pass.stderr +29 -29
- data/rust-vendor/zerocopy-derive/tests/ui-nightly/privacy.rs +66 -29
- data/rust-vendor/zerocopy-derive/tests/ui-nightly/privacy.stderr +15 -15
- data/rust-vendor/zerocopy-derive/tests/ui-nightly/struct.rs +34 -2
- data/rust-vendor/zerocopy-derive/tests/ui-nightly/struct.stderr +130 -129
- data/rust-vendor/zerocopy-derive/tests/ui-nightly/union.rs +12 -1
- data/rust-vendor/zerocopy-derive/tests/ui-nightly/union.stderr +42 -42
- data/rust-vendor/zerocopy-derive/tests/ui-nightly/union_into_bytes_cfg/union_into_bytes_cfg.rs +3 -2
- data/rust-vendor/zerocopy-derive/tests/ui-stable/derive_transparent.rs +3 -2
- data/rust-vendor/zerocopy-derive/tests/ui-stable/derive_transparent.stderr +57 -57
- data/rust-vendor/zerocopy-derive/tests/ui-stable/enum.rs +48 -1
- data/rust-vendor/zerocopy-derive/tests/ui-stable/enum.stderr +201 -186
- data/rust-vendor/zerocopy-derive/tests/ui-stable/enum_from_bytes_u8_too_few.rs +2 -1
- data/rust-vendor/zerocopy-derive/tests/ui-stable/enum_from_bytes_u8_too_few.stderr +6 -6
- data/rust-vendor/zerocopy-derive/tests/ui-stable/late_compile_pass.rs +9 -2
- data/rust-vendor/zerocopy-derive/tests/ui-stable/late_compile_pass.stderr +105 -105
- data/rust-vendor/zerocopy-derive/tests/ui-stable/mid_compile_pass.rs +6 -2
- data/rust-vendor/zerocopy-derive/tests/ui-stable/mid_compile_pass.stderr +29 -29
- data/rust-vendor/zerocopy-derive/tests/ui-stable/privacy.rs +66 -29
- data/rust-vendor/zerocopy-derive/tests/ui-stable/privacy.stderr +15 -15
- data/rust-vendor/zerocopy-derive/tests/ui-stable/struct.rs +34 -2
- data/rust-vendor/zerocopy-derive/tests/ui-stable/struct.stderr +158 -129
- data/rust-vendor/zerocopy-derive/tests/ui-stable/union.rs +12 -1
- data/rust-vendor/zerocopy-derive/tests/ui-stable/union.stderr +48 -44
- data/rust-vendor/zerocopy-derive/tests/ui-stable/union_into_bytes_cfg/union_into_bytes_cfg.rs +3 -2
- data/rust-vendor/zerocopy-derive/tests/union_from_bytes.rs +15 -0
- data/rust-vendor/zerocopy-derive/tests/union_from_zeros.rs +14 -0
- data/rust-vendor/zerocopy-derive/tests/union_known_layout.rs +5 -0
- data/rust-vendor/zerocopy-derive/tests/union_no_cell.rs +5 -0
- data/rust-vendor/zerocopy-derive/tests/union_to_bytes.rs +5 -0
- data/rust-vendor/zerocopy-derive/tests/union_try_from_bytes.rs +34 -74
- data/rust-vendor/zerocopy-derive/tests/union_unaligned.rs +4 -1
- data/rust-vendor/zerocopy-derive/tests/unsafe_cell.rs +3 -0
- data/rust-vendor/zmij/.cargo-checksum.json +1 -1
- data/rust-vendor/zmij/.cargo_vcs_info.json +1 -1
- data/rust-vendor/zmij/Cargo.lock +10 -10
- data/rust-vendor/zmij/Cargo.toml +1 -1
- data/rust-vendor/zmij/Cargo.toml.orig +1 -1
- data/rust-vendor/zmij/README.md +1 -1
- data/rust-vendor/zmij/src/lib.rs +132 -158
- data/rust-vendor/zune-jpeg/.cargo-checksum.json +1 -1
- data/rust-vendor/zune-jpeg/.cargo_vcs_info.json +1 -1
- data/rust-vendor/zune-jpeg/Cargo.lock +1 -1
- data/rust-vendor/zune-jpeg/Cargo.toml +1 -1
- data/rust-vendor/zune-jpeg/Cargo.toml.orig +1 -1
- data/rust-vendor/zune-jpeg/src/bitstream.rs +1 -1
- data/rust-vendor/zune-jpeg/src/components.rs +2 -1
- data/rust-vendor/zune-jpeg/src/decoder.rs +3 -23
- data/rust-vendor/zune-jpeg/src/headers.rs +19 -1
- data/rust-vendor/zune-jpeg/src/lib.rs +1 -0
- data/rust-vendor/zune-jpeg/src/mcu.rs +6 -6
- data/rust-vendor/zune-jpeg/src/mcu_prog.rs +22 -34
- data/rust-vendor/zune-jpeg/src/upsampler/avx2.rs +3 -1
- data/rust-vendor/zune-jpeg/src/upsampler/neon.rs +13 -23
- data/rust-vendor/zune-jpeg/src/upsampler/portable_simd.rs +4 -1
- data/rust-vendor/zune-jpeg/src/upsampler/scalar.rs +4 -1
- metadata +41 -8
- data/rust-vendor/zerocopy/tests/ui-stable/transmute-mut-src-dst-unsized.stderr +0 -183
- data/rust-vendor/zerocopy/tests/ui-stable/transmute-ref-src-dst-unsized.stderr +0 -183
- data/rust-vendor/zerocopy-derive/src/enum.rs +0 -456
- data/rust-vendor/zerocopy-derive/src/ext.rs +0 -123
- data/rust-vendor/zerocopy-derive/src/output_tests.rs +0 -5608
- data/rust-vendor/zerocopy-derive/tests/crate_path.rs +0 -189
|
@@ -14,6 +14,7 @@ use core::{
|
|
|
14
14
|
};
|
|
15
15
|
|
|
16
16
|
use super::*;
|
|
17
|
+
use crate::pointer::cast::{CastSizedExact, CastUnsized};
|
|
17
18
|
|
|
18
19
|
// SAFETY: Per the reference [1], "the unit tuple (`()`) ... is guaranteed as a
|
|
19
20
|
// zero-sized type to have a size of 0 and an alignment of 1."
|
|
@@ -108,11 +109,10 @@ assert_unaligned!(bool);
|
|
|
108
109
|
// pattern 0x01.
|
|
109
110
|
const _: () = unsafe {
|
|
110
111
|
unsafe_impl!(=> TryFromBytes for bool; |byte| {
|
|
111
|
-
let byte = byte.
|
|
112
|
+
let byte = byte.transmute_with::<u8, invariant::Valid, CastSizedExact, BecauseImmutable>();
|
|
112
113
|
*byte.unaligned_as_ref() < 2
|
|
113
114
|
})
|
|
114
115
|
};
|
|
115
|
-
impl_size_eq!(bool, u8);
|
|
116
116
|
|
|
117
117
|
// SAFETY:
|
|
118
118
|
// - `Immutable`: `char` self-evidently does not contain any `UnsafeCell`s.
|
|
@@ -138,14 +138,12 @@ const _: () = unsafe { unsafe_impl!(char: Immutable, FromZeros, IntoBytes) };
|
|
|
138
138
|
// `char`.
|
|
139
139
|
const _: () = unsafe {
|
|
140
140
|
unsafe_impl!(=> TryFromBytes for char; |c| {
|
|
141
|
-
let c = c.
|
|
141
|
+
let c = c.transmute_with::<Unalign<u32>, invariant::Valid, CastSizedExact, BecauseImmutable>();
|
|
142
142
|
let c = c.read_unaligned().into_inner();
|
|
143
143
|
char::from_u32(c).is_some()
|
|
144
144
|
});
|
|
145
145
|
};
|
|
146
146
|
|
|
147
|
-
impl_size_eq!(char, Unalign<u32>);
|
|
148
|
-
|
|
149
147
|
// SAFETY: Per the Reference [1], `str` has the same layout as `[u8]`.
|
|
150
148
|
// - `Immutable`: `[u8]` does not contain any `UnsafeCell`s.
|
|
151
149
|
// - `FromZeros`, `IntoBytes`, `Unaligned`: `[u8]` is `FromZeros`, `IntoBytes`,
|
|
@@ -168,26 +166,22 @@ const _: () = unsafe { unsafe_impl!(str: Immutable, FromZeros, IntoBytes, Unalig
|
|
|
168
166
|
// `Maybe<str>` refers to a valid `str`. `str::from_utf8` guarantees that it
|
|
169
167
|
// returns `Err` if its input is not a valid `str` [1].
|
|
170
168
|
//
|
|
171
|
-
// [
|
|
169
|
+
// [1] Per https://doc.rust-lang.org/core/str/fn.from_utf8.html#errors:
|
|
172
170
|
//
|
|
173
171
|
// Returns `Err` if the slice is not UTF-8.
|
|
174
172
|
const _: () = unsafe {
|
|
175
173
|
unsafe_impl!(=> TryFromBytes for str; |c| {
|
|
176
|
-
let c = c.
|
|
174
|
+
let c = c.transmute_with::<[u8], invariant::Valid, CastUnsized, BecauseImmutable>();
|
|
177
175
|
let c = c.unaligned_as_ref();
|
|
178
176
|
core::str::from_utf8(c).is_ok()
|
|
179
177
|
})
|
|
180
178
|
};
|
|
181
179
|
|
|
182
|
-
impl_size_eq!(str, [u8]);
|
|
183
|
-
|
|
184
180
|
macro_rules! unsafe_impl_try_from_bytes_for_nonzero {
|
|
185
181
|
($($nonzero:ident[$prim:ty]),*) => {
|
|
186
182
|
$(
|
|
187
183
|
unsafe_impl!(=> TryFromBytes for $nonzero; |n| {
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
let n = n.transmute::<Unalign<$prim>, invariant::Valid, _>();
|
|
184
|
+
let n = n.transmute_with::<Unalign<$prim>, invariant::Valid, CastSizedExact, BecauseImmutable>();
|
|
191
185
|
$nonzero::new(n.read_unaligned().into_inner()).is_some()
|
|
192
186
|
});
|
|
193
187
|
)*
|
|
@@ -404,13 +398,13 @@ mod atomics {
|
|
|
404
398
|
use super::*;
|
|
405
399
|
|
|
406
400
|
macro_rules! impl_traits_for_atomics {
|
|
407
|
-
($($atomics:
|
|
401
|
+
($($atomics:tt [$primitives:ty]),* $(,)?) => {
|
|
408
402
|
$(
|
|
409
403
|
impl_known_layout!($atomics);
|
|
410
|
-
impl_for_transmute_from!(=>
|
|
411
|
-
impl_for_transmute_from!(=>
|
|
412
|
-
impl_for_transmute_from!(=>
|
|
413
|
-
impl_for_transmute_from!(=> IntoBytes for $atomics [
|
|
404
|
+
impl_for_transmute_from!(=> FromZeros for $atomics [$primitives]);
|
|
405
|
+
impl_for_transmute_from!(=> FromBytes for $atomics [$primitives]);
|
|
406
|
+
impl_for_transmute_from!(=> TryFromBytes for $atomics [$primitives]);
|
|
407
|
+
impl_for_transmute_from!(=> IntoBytes for $atomics [$primitives]);
|
|
414
408
|
)*
|
|
415
409
|
};
|
|
416
410
|
}
|
|
@@ -425,7 +419,6 @@ mod atomics {
|
|
|
425
419
|
($($($tyvar:ident)? => $atomic:ty [$prim:ty]),*) => {{
|
|
426
420
|
crate::util::macros::__unsafe();
|
|
427
421
|
|
|
428
|
-
use core::cell::UnsafeCell;
|
|
429
422
|
use crate::pointer::{SizeEq, TransmuteFrom, invariant::Valid};
|
|
430
423
|
|
|
431
424
|
$(
|
|
@@ -436,29 +429,8 @@ mod atomics {
|
|
|
436
429
|
// the same size and bit validity.
|
|
437
430
|
unsafe impl<$($tyvar)?> TransmuteFrom<$prim, Valid, Valid> for $atomic {}
|
|
438
431
|
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
unsafe impl<$($tyvar)?> SizeEq<$atomic> for $prim {
|
|
442
|
-
type CastFrom = $crate::pointer::cast::CastSized;
|
|
443
|
-
}
|
|
444
|
-
// SAFETY: See previous safety comment.
|
|
445
|
-
unsafe impl<$($tyvar)?> SizeEq<$prim> for $atomic {
|
|
446
|
-
type CastFrom = $crate::pointer::cast::CastSized;
|
|
447
|
-
}
|
|
448
|
-
// SAFETY: The caller promised that `$atomic` and `$prim` have
|
|
449
|
-
// the same size. `UnsafeCell<T>` has the same size as `T` [1].
|
|
450
|
-
//
|
|
451
|
-
// [1] Per https://doc.rust-lang.org/1.85.0/std/cell/struct.UnsafeCell.html#memory-layout:
|
|
452
|
-
//
|
|
453
|
-
// `UnsafeCell<T>` has the same in-memory representation as
|
|
454
|
-
// its inner type `T`. A consequence of this guarantee is that
|
|
455
|
-
// it is possible to convert between `T` and `UnsafeCell<T>`.
|
|
456
|
-
unsafe impl<$($tyvar)?> SizeEq<$atomic> for UnsafeCell<$prim> {
|
|
457
|
-
type CastFrom = $crate::pointer::cast::CastSized;
|
|
458
|
-
}
|
|
459
|
-
// SAFETY: See previous safety comment.
|
|
460
|
-
unsafe impl<$($tyvar)?> SizeEq<UnsafeCell<$prim>> for $atomic {
|
|
461
|
-
type CastFrom = $crate::pointer::cast::CastSized;
|
|
432
|
+
impl<$($tyvar)?> SizeEq<ReadOnly<$atomic>> for ReadOnly<$prim> {
|
|
433
|
+
type CastFrom = $crate::pointer::cast::CastSizedExact;
|
|
462
434
|
}
|
|
463
435
|
|
|
464
436
|
// SAFETY: The caller promised that `$atomic` and `$prim` have
|
|
@@ -487,10 +459,9 @@ mod atomics {
|
|
|
487
459
|
impl_traits_for_atomics!(AtomicU8[u8], AtomicI8[i8]);
|
|
488
460
|
|
|
489
461
|
impl_known_layout!(AtomicBool);
|
|
490
|
-
|
|
491
|
-
impl_for_transmute_from!(=> TryFromBytes for AtomicBool [
|
|
492
|
-
impl_for_transmute_from!(=>
|
|
493
|
-
impl_for_transmute_from!(=> IntoBytes for AtomicBool [UnsafeCell<bool>]);
|
|
462
|
+
impl_for_transmute_from!(=> FromZeros for AtomicBool [bool]);
|
|
463
|
+
impl_for_transmute_from!(=> TryFromBytes for AtomicBool [bool]);
|
|
464
|
+
impl_for_transmute_from!(=> IntoBytes for AtomicBool [bool]);
|
|
494
465
|
|
|
495
466
|
// SAFETY: Per [1], `AtomicBool`, `AtomicU8`, and `AtomicI8` have the
|
|
496
467
|
// same size as `bool`, `u8`, and `i8` respectively. Since a type's
|
|
@@ -634,12 +605,11 @@ mod atomics {
|
|
|
634
605
|
|
|
635
606
|
impl_traits_for_atomics!(AtomicUsize[usize], AtomicIsize[isize]);
|
|
636
607
|
|
|
637
|
-
impl_known_layout!(T => AtomicPtr<T>);
|
|
638
|
-
|
|
639
608
|
// FIXME(#170): Implement `FromBytes` and `IntoBytes` once we implement
|
|
640
609
|
// those traits for `*mut T`.
|
|
641
|
-
|
|
642
|
-
impl_for_transmute_from!(T =>
|
|
610
|
+
impl_known_layout!(T => AtomicPtr<T>);
|
|
611
|
+
impl_for_transmute_from!(T => TryFromBytes for AtomicPtr<T> [*mut T]);
|
|
612
|
+
impl_for_transmute_from!(T => FromZeros for AtomicPtr<T> [*mut T]);
|
|
643
613
|
|
|
644
614
|
// SAFETY: `AtomicUsize` and `AtomicIsize` have the same size and bit
|
|
645
615
|
// validity as `usize` and `isize` respectively [1][2].
|
|
@@ -688,10 +658,10 @@ const _: () = unsafe {
|
|
|
688
658
|
assert_unaligned!(PhantomData<()>, PhantomData<u8>, PhantomData<u64>);
|
|
689
659
|
};
|
|
690
660
|
|
|
691
|
-
impl_for_transmute_from!(T: TryFromBytes => TryFromBytes for Wrapping<T>[
|
|
692
|
-
impl_for_transmute_from!(T: FromZeros => FromZeros for Wrapping<T>[
|
|
693
|
-
impl_for_transmute_from!(T: FromBytes => FromBytes for Wrapping<T>[
|
|
694
|
-
impl_for_transmute_from!(T: IntoBytes => IntoBytes for Wrapping<T>[
|
|
661
|
+
impl_for_transmute_from!(T: TryFromBytes => TryFromBytes for Wrapping<T>[T]);
|
|
662
|
+
impl_for_transmute_from!(T: FromZeros => FromZeros for Wrapping<T>[T]);
|
|
663
|
+
impl_for_transmute_from!(T: FromBytes => FromBytes for Wrapping<T>[T]);
|
|
664
|
+
impl_for_transmute_from!(T: IntoBytes => IntoBytes for Wrapping<T>[T]);
|
|
695
665
|
assert_unaligned!(Wrapping<()>, Wrapping<u8>);
|
|
696
666
|
|
|
697
667
|
// SAFETY: Per [1], `Wrapping<T>` has the same layout as `T`. Since its single
|
|
@@ -762,10 +732,10 @@ assert_unaligned!(CoreMaybeUninit<()>, CoreMaybeUninit<u8>);
|
|
|
762
732
|
// [2] https://doc.rust-lang.org/1.85.0/std/mem/struct.ManuallyDrop.html#impl-Deref-for-ManuallyDrop%3CT%3E
|
|
763
733
|
const _: () = unsafe { unsafe_impl!(T: ?Sized + Immutable => Immutable for ManuallyDrop<T>) };
|
|
764
734
|
|
|
765
|
-
impl_for_transmute_from!(T: ?Sized + TryFromBytes => TryFromBytes for ManuallyDrop<T>[
|
|
766
|
-
impl_for_transmute_from!(T: ?Sized + FromZeros => FromZeros for ManuallyDrop<T>[
|
|
767
|
-
impl_for_transmute_from!(T: ?Sized + FromBytes => FromBytes for ManuallyDrop<T>[
|
|
768
|
-
impl_for_transmute_from!(T: ?Sized + IntoBytes => IntoBytes for ManuallyDrop<T>[
|
|
735
|
+
impl_for_transmute_from!(T: ?Sized + TryFromBytes => TryFromBytes for ManuallyDrop<T>[T]);
|
|
736
|
+
impl_for_transmute_from!(T: ?Sized + FromZeros => FromZeros for ManuallyDrop<T>[T]);
|
|
737
|
+
impl_for_transmute_from!(T: ?Sized + FromBytes => FromBytes for ManuallyDrop<T>[T]);
|
|
738
|
+
impl_for_transmute_from!(T: ?Sized + IntoBytes => IntoBytes for ManuallyDrop<T>[T]);
|
|
769
739
|
// SAFETY: `ManuallyDrop<T>` has the same layout as `T` [1], and thus has the
|
|
770
740
|
// same alignment as `T`.
|
|
771
741
|
//
|
|
@@ -785,6 +755,30 @@ const _: () = {
|
|
|
785
755
|
)]
|
|
786
756
|
pub enum value {}
|
|
787
757
|
|
|
758
|
+
// SAFETY: See safety comment on `ProjectToTag`.
|
|
759
|
+
unsafe impl<T: ?Sized> HasTag for ManuallyDrop<T> {
|
|
760
|
+
#[inline]
|
|
761
|
+
fn only_derive_is_allowed_to_implement_this_trait()
|
|
762
|
+
where
|
|
763
|
+
Self: Sized,
|
|
764
|
+
{
|
|
765
|
+
}
|
|
766
|
+
|
|
767
|
+
type Tag = ();
|
|
768
|
+
|
|
769
|
+
// SAFETY: It is trivially sound to project any pointer to a pointer to
|
|
770
|
+
// a type of size zero and alignment 1 (which `()` is [1]). Such a
|
|
771
|
+
// pointer will trivially satisfy its aliasing and validity requirements
|
|
772
|
+
// (since it has a zero-sized referent), and its alignment requirement
|
|
773
|
+
// (since it is aligned to 1).
|
|
774
|
+
//
|
|
775
|
+
// [1] Per https://doc.rust-lang.org/1.92.0/reference/type-layout.html#r-layout.tuple.unit:
|
|
776
|
+
//
|
|
777
|
+
// [T]he unit tuple (`()`)... is guaranteed as a zero-sized type to
|
|
778
|
+
// have a size of 0 and an alignment of 1.
|
|
779
|
+
type ProjectToTag = crate::pointer::cast::CastToUnit;
|
|
780
|
+
}
|
|
781
|
+
|
|
788
782
|
// SAFETY: `ManuallyDrop<T>` has a field of type `T` at offset `0` without
|
|
789
783
|
// any safety invariants beyond those of `T`. Its existence is not
|
|
790
784
|
// explicitly documented, but it can be inferred; per [1] `ManuallyDrop<T>`
|
|
@@ -804,8 +798,6 @@ const _: () = {
|
|
|
804
798
|
HasField<value, { crate::STRUCT_VARIANT_ID }, { crate::ident_id!(value) }>
|
|
805
799
|
for ManuallyDrop<T>
|
|
806
800
|
{
|
|
807
|
-
type Type = T;
|
|
808
|
-
|
|
809
801
|
#[inline]
|
|
810
802
|
fn only_derive_is_allowed_to_implement_this_trait()
|
|
811
803
|
where
|
|
@@ -813,6 +805,8 @@ const _: () = {
|
|
|
813
805
|
{
|
|
814
806
|
}
|
|
815
807
|
|
|
808
|
+
type Type = T;
|
|
809
|
+
|
|
816
810
|
#[inline(always)]
|
|
817
811
|
fn project(slf: PtrInner<'_, Self>) -> *mut T {
|
|
818
812
|
// SAFETY: `ManuallyDrop<T>` has the same layout and bit validity as
|
|
@@ -828,10 +822,10 @@ const _: () = {
|
|
|
828
822
|
}
|
|
829
823
|
};
|
|
830
824
|
|
|
831
|
-
impl_for_transmute_from!(T: ?Sized + TryFromBytes => TryFromBytes for Cell<T>[
|
|
832
|
-
impl_for_transmute_from!(T: ?Sized + FromZeros => FromZeros for Cell<T>[
|
|
833
|
-
impl_for_transmute_from!(T: ?Sized + FromBytes => FromBytes for Cell<T>[
|
|
834
|
-
impl_for_transmute_from!(T: ?Sized + IntoBytes => IntoBytes for Cell<T>[
|
|
825
|
+
impl_for_transmute_from!(T: ?Sized + TryFromBytes => TryFromBytes for Cell<T>[T]);
|
|
826
|
+
impl_for_transmute_from!(T: ?Sized + FromZeros => FromZeros for Cell<T>[T]);
|
|
827
|
+
impl_for_transmute_from!(T: ?Sized + FromBytes => FromBytes for Cell<T>[T]);
|
|
828
|
+
impl_for_transmute_from!(T: ?Sized + IntoBytes => IntoBytes for Cell<T>[T]);
|
|
835
829
|
// SAFETY: `Cell<T>` has the same in-memory representation as `T` [1], and thus
|
|
836
830
|
// has the same alignment as `T`.
|
|
837
831
|
//
|
|
@@ -840,9 +834,9 @@ impl_for_transmute_from!(T: ?Sized + IntoBytes => IntoBytes for Cell<T>[UnsafeCe
|
|
|
840
834
|
// `Cell<T>` has the same in-memory representation as its inner type `T`.
|
|
841
835
|
const _: () = unsafe { unsafe_impl!(T: ?Sized + Unaligned => Unaligned for Cell<T>) };
|
|
842
836
|
|
|
843
|
-
impl_for_transmute_from!(T: ?Sized + FromZeros => FromZeros for UnsafeCell<T>[
|
|
844
|
-
impl_for_transmute_from!(T: ?Sized + FromBytes => FromBytes for UnsafeCell<T>[
|
|
845
|
-
impl_for_transmute_from!(T: ?Sized + IntoBytes => IntoBytes for UnsafeCell<T>[
|
|
837
|
+
impl_for_transmute_from!(T: ?Sized + FromZeros => FromZeros for UnsafeCell<T>[T]);
|
|
838
|
+
impl_for_transmute_from!(T: ?Sized + FromBytes => FromBytes for UnsafeCell<T>[T]);
|
|
839
|
+
impl_for_transmute_from!(T: ?Sized + IntoBytes => IntoBytes for UnsafeCell<T>[T]);
|
|
846
840
|
// SAFETY: `UnsafeCell<T>` has the same in-memory representation as `T` [1], and
|
|
847
841
|
// thus has the same alignment as `T`.
|
|
848
842
|
//
|
|
@@ -863,29 +857,8 @@ unsafe impl<T: TryFromBytes + ?Sized> TryFromBytes for UnsafeCell<T> {
|
|
|
863
857
|
}
|
|
864
858
|
|
|
865
859
|
#[inline]
|
|
866
|
-
fn is_bit_valid
|
|
867
|
-
|
|
868
|
-
// pointer. `UnsafeCell`s cannot be read via shared-aliased pointers
|
|
869
|
-
// (other than by using `unsafe` code, which we can't use since we can't
|
|
870
|
-
// guarantee how our users are accessing or modifying the `UnsafeCell`).
|
|
871
|
-
//
|
|
872
|
-
// `is_bit_valid` is documented as panicking or failing to monomorphize
|
|
873
|
-
// if called with a shared-aliased pointer on a type containing an
|
|
874
|
-
// `UnsafeCell`. In practice, it will always be a monomorphization error.
|
|
875
|
-
// Since `is_bit_valid` is `#[doc(hidden)]` and only called directly
|
|
876
|
-
// from this crate, we only need to worry about our own code incorrectly
|
|
877
|
-
// calling `UnsafeCell::is_bit_valid`. The post-monomorphization error
|
|
878
|
-
// makes it easier to test that this is truly the case, and also means
|
|
879
|
-
// that if we make a mistake, it will cause downstream code to fail to
|
|
880
|
-
// compile, which will immediately surface the mistake and give us a
|
|
881
|
-
// chance to fix it quickly.
|
|
882
|
-
let c = candidate.into_exclusive_or_pme();
|
|
883
|
-
|
|
884
|
-
// SAFETY: Since `UnsafeCell<T>` and `T` have the same layout and bit
|
|
885
|
-
// validity, `UnsafeCell<T>` is bit-valid exactly when its wrapped `T`
|
|
886
|
-
// is. Thus, this is a sound implementation of
|
|
887
|
-
// `UnsafeCell::is_bit_valid`.
|
|
888
|
-
T::is_bit_valid(c.get_mut())
|
|
860
|
+
fn is_bit_valid(candidate: Maybe<'_, Self>) -> bool {
|
|
861
|
+
T::is_bit_valid(candidate.transmute::<_, _, BecauseImmutable>())
|
|
889
862
|
}
|
|
890
863
|
}
|
|
891
864
|
|
|
@@ -914,11 +887,15 @@ unsafe impl<T: TryFromBytes + ?Sized> TryFromBytes for UnsafeCell<T> {
|
|
|
914
887
|
const _: () = unsafe {
|
|
915
888
|
unsafe_impl!(const N: usize, T: Immutable => Immutable for [T; N]);
|
|
916
889
|
unsafe_impl!(const N: usize, T: TryFromBytes => TryFromBytes for [T; N]; |c| {
|
|
890
|
+
let c: Ptr<'_, [ReadOnly<T>; N], _> = c.cast::<_, crate::pointer::cast::CastSized, _>();
|
|
891
|
+
let c: Ptr<'_, [ReadOnly<T>], _> = c.as_slice();
|
|
892
|
+
let c: Ptr<'_, ReadOnly<[T]>, _> = c.cast::<_, crate::pointer::cast::CastUnsized, _>();
|
|
893
|
+
|
|
917
894
|
// Note that this call may panic, but it would still be sound even if it
|
|
918
895
|
// did. `is_bit_valid` does not promise that it will not panic (in fact,
|
|
919
896
|
// it explicitly warns that it's a possibility), and we have not
|
|
920
897
|
// violated any safety invariants that we must fix before returning.
|
|
921
|
-
<[T] as TryFromBytes>::is_bit_valid(c
|
|
898
|
+
<[T] as TryFromBytes>::is_bit_valid(c)
|
|
922
899
|
});
|
|
923
900
|
unsafe_impl!(const N: usize, T: FromZeros => FromZeros for [T; N]);
|
|
924
901
|
unsafe_impl!(const N: usize, T: FromBytes => FromBytes for [T; N]);
|
|
@@ -927,6 +904,8 @@ const _: () = unsafe {
|
|
|
927
904
|
assert_unaligned!([(); 0], [(); 1], [u8; 0], [u8; 1]);
|
|
928
905
|
unsafe_impl!(T: Immutable => Immutable for [T]);
|
|
929
906
|
unsafe_impl!(T: TryFromBytes => TryFromBytes for [T]; |c| {
|
|
907
|
+
let c: Ptr<'_, [ReadOnly<T>], _> = c.cast::<_, crate::pointer::cast::CastUnsized, _>();
|
|
908
|
+
|
|
930
909
|
// SAFETY: Per the reference [1]:
|
|
931
910
|
//
|
|
932
911
|
// An array of `[T; N]` has a size of `size_of::<T>() * N` and the
|
|
@@ -1005,6 +984,238 @@ const _: () = unsafe {
|
|
|
1005
984
|
// [1] https://doc.rust-lang.org/core/option/enum.Option.html
|
|
1006
985
|
const _: () = unsafe { unsafe_impl!(T: Immutable => Immutable for Option<T>) };
|
|
1007
986
|
|
|
987
|
+
mod tuples {
|
|
988
|
+
use super::*;
|
|
989
|
+
|
|
990
|
+
/// Generates various trait implementations for tuples.
|
|
991
|
+
///
|
|
992
|
+
/// # Safety
|
|
993
|
+
///
|
|
994
|
+
/// `impl_tuple!` should be provided name-number pairs, where each number is
|
|
995
|
+
/// the ordinal of the preceding type name.
|
|
996
|
+
macro_rules! impl_tuple {
|
|
997
|
+
// Entry point.
|
|
998
|
+
($($T:ident $I:tt),+ $(,)?) => {
|
|
999
|
+
crate::util::macros::__unsafe();
|
|
1000
|
+
impl_tuple!(@all [] [$($T $I)+]);
|
|
1001
|
+
};
|
|
1002
|
+
|
|
1003
|
+
// Build up the set of tuple types (i.e., `(A,)`, `(A, B)`, `(A, B, C)`,
|
|
1004
|
+
// etc.) Trait implementations that do not depend on field index may be
|
|
1005
|
+
// added to this branch.
|
|
1006
|
+
(@all [$($head_T:ident $head_I:tt)*] [$next_T:ident $next_I:tt $($tail:tt)*]) => {
|
|
1007
|
+
// SAFETY: If all fields of the tuple `Self` are `Immutable`, so too is `Self`.
|
|
1008
|
+
unsafe_impl!($($head_T: Immutable,)* $next_T: Immutable => Immutable for ($($head_T,)* $next_T,));
|
|
1009
|
+
|
|
1010
|
+
// SAFETY: If all fields in `c` are `is_bit_valid`, so too is `c`.
|
|
1011
|
+
unsafe_impl!($($head_T: TryFromBytes,)* $next_T: TryFromBytes => TryFromBytes for ($($head_T,)* $next_T,); |c| {
|
|
1012
|
+
let mut c = c;
|
|
1013
|
+
$(TryFromBytes::is_bit_valid(into_inner!(c.reborrow().project::<_, { crate::STRUCT_VARIANT_ID }, { crate::ident_id!($head_I) }>())) &&)*
|
|
1014
|
+
TryFromBytes::is_bit_valid(into_inner!(c.reborrow().project::<_, { crate::STRUCT_VARIANT_ID }, { crate::ident_id!($next_I) }>()))
|
|
1015
|
+
});
|
|
1016
|
+
|
|
1017
|
+
// SAFETY: If all fields in `Self` are `FromZeros`, so too is `Self`.
|
|
1018
|
+
unsafe_impl!($($head_T: FromZeros,)* $next_T: FromZeros => FromZeros for ($($head_T,)* $next_T,));
|
|
1019
|
+
|
|
1020
|
+
// SAFETY: If all fields in `Self` are `FromBytes`, so too is `Self`.
|
|
1021
|
+
unsafe_impl!($($head_T: FromBytes,)* $next_T: FromBytes => FromBytes for ($($head_T,)* $next_T,));
|
|
1022
|
+
|
|
1023
|
+
// SAFETY: See safety comment on `ProjectToTag`.
|
|
1024
|
+
unsafe impl<$($head_T,)* $next_T> crate::HasTag for ($($head_T,)* $next_T,) {
|
|
1025
|
+
#[inline]
|
|
1026
|
+
fn only_derive_is_allowed_to_implement_this_trait()
|
|
1027
|
+
where
|
|
1028
|
+
Self: Sized
|
|
1029
|
+
{}
|
|
1030
|
+
|
|
1031
|
+
type Tag = ();
|
|
1032
|
+
|
|
1033
|
+
// SAFETY: It is trivially sound to project any pointer to a
|
|
1034
|
+
// pointer to a type of size zero and alignment 1 (which `()` is
|
|
1035
|
+
// [1]). Such a pointer will trivially satisfy its aliasing and
|
|
1036
|
+
// validity requirements (since it has a zero-sized referent),
|
|
1037
|
+
// and its alignment requirement (since it is aligned to 1).
|
|
1038
|
+
//
|
|
1039
|
+
// [1] Per https://doc.rust-lang.org/1.92.0/reference/type-layout.html#r-layout.tuple.unit:
|
|
1040
|
+
//
|
|
1041
|
+
// [T]he unit tuple (`()`)... is guaranteed as a zero-sized
|
|
1042
|
+
// type to have a size of 0 and an alignment of 1.
|
|
1043
|
+
type ProjectToTag = crate::pointer::cast::CastToUnit;
|
|
1044
|
+
}
|
|
1045
|
+
|
|
1046
|
+
// Generate impls that depend on tuple index.
|
|
1047
|
+
impl_tuple!(@variants
|
|
1048
|
+
[$($head_T $head_I)* $next_T $next_I]
|
|
1049
|
+
[]
|
|
1050
|
+
[$($head_T $head_I)* $next_T $next_I]
|
|
1051
|
+
);
|
|
1052
|
+
|
|
1053
|
+
// Recurse to next tuple size
|
|
1054
|
+
impl_tuple!(@all [$($head_T $head_I)* $next_T $next_I] [$($tail)*]);
|
|
1055
|
+
};
|
|
1056
|
+
(@all [$($head_T:ident $head_I:tt)*] []) => {};
|
|
1057
|
+
|
|
1058
|
+
// Emit trait implementations that depend on field index.
|
|
1059
|
+
(@variants
|
|
1060
|
+
// The full tuple definition in type–index pairs.
|
|
1061
|
+
[$($AllT:ident $AllI:tt)+]
|
|
1062
|
+
// Types before the current index.
|
|
1063
|
+
[$($BeforeT:ident)*]
|
|
1064
|
+
// The types and indices at and after the current index.
|
|
1065
|
+
[$CurrT:ident $CurrI:tt $($AfterT:ident $AfterI:tt)*]
|
|
1066
|
+
) => {
|
|
1067
|
+
// SAFETY:
|
|
1068
|
+
// - `Self` is a struct (albeit anonymous), so `VARIANT_ID` is
|
|
1069
|
+
// `STRUCT_VARIANT_ID`.
|
|
1070
|
+
// - `$CurrI` is the field at index `$CurrI`, so `FIELD_ID` is
|
|
1071
|
+
// `zerocopy::ident_id!($CurrI)`
|
|
1072
|
+
// - `()` has the same visibility as the `.$CurrI` field (ie, `.0`,
|
|
1073
|
+
// `.1`, etc)
|
|
1074
|
+
// - `Type` has the same type as `$CurrI`; i.e., `$CurrT`.
|
|
1075
|
+
unsafe impl<$($AllT),+> crate::HasField<
|
|
1076
|
+
(),
|
|
1077
|
+
{ crate::STRUCT_VARIANT_ID },
|
|
1078
|
+
{ crate::ident_id!($CurrI)}
|
|
1079
|
+
> for ($($AllT,)+) {
|
|
1080
|
+
#[inline]
|
|
1081
|
+
fn only_derive_is_allowed_to_implement_this_trait()
|
|
1082
|
+
where
|
|
1083
|
+
Self: Sized
|
|
1084
|
+
{}
|
|
1085
|
+
|
|
1086
|
+
type Type = $CurrT;
|
|
1087
|
+
|
|
1088
|
+
#[inline(always)]
|
|
1089
|
+
fn project(slf: crate::PtrInner<'_, Self>) -> *mut Self::Type {
|
|
1090
|
+
let slf = slf.as_non_null().as_ptr();
|
|
1091
|
+
// SAFETY: `PtrInner` promises it references either a zero-sized
|
|
1092
|
+
// byte range, or else will reference a byte range that is
|
|
1093
|
+
// entirely contained within an allocated object. In either
|
|
1094
|
+
// case, this guarantees that `(*slf).$CurrI` is in-bounds of
|
|
1095
|
+
// `slf`.
|
|
1096
|
+
unsafe { core::ptr::addr_of_mut!((*slf).$CurrI) }
|
|
1097
|
+
}
|
|
1098
|
+
}
|
|
1099
|
+
|
|
1100
|
+
// SAFETY: See comments on items.
|
|
1101
|
+
unsafe impl<Aliasing, Alignment, $($AllT),+> crate::ProjectField<
|
|
1102
|
+
(),
|
|
1103
|
+
(Aliasing, Alignment, crate::invariant::Uninit),
|
|
1104
|
+
{ crate::STRUCT_VARIANT_ID },
|
|
1105
|
+
{ crate::ident_id!($CurrI)}
|
|
1106
|
+
> for ($($AllT,)+)
|
|
1107
|
+
where
|
|
1108
|
+
Aliasing: crate::invariant::Aliasing,
|
|
1109
|
+
Alignment: crate::invariant::Alignment,
|
|
1110
|
+
{
|
|
1111
|
+
#[inline]
|
|
1112
|
+
fn only_derive_is_allowed_to_implement_this_trait()
|
|
1113
|
+
where
|
|
1114
|
+
Self: Sized
|
|
1115
|
+
{}
|
|
1116
|
+
|
|
1117
|
+
// SAFETY: Tuples are product types whose fields are
|
|
1118
|
+
// well-aligned, so projection preserves both the alignment and
|
|
1119
|
+
// validity invariants of the outer pointer.
|
|
1120
|
+
type Invariants = (Aliasing, Alignment, crate::invariant::Uninit);
|
|
1121
|
+
|
|
1122
|
+
// SAFETY: Tuples are product types and so projection is infallible;
|
|
1123
|
+
type Error = core::convert::Infallible;
|
|
1124
|
+
}
|
|
1125
|
+
|
|
1126
|
+
// SAFETY: See comments on items.
|
|
1127
|
+
unsafe impl<Aliasing, Alignment, $($AllT),+> crate::ProjectField<
|
|
1128
|
+
(),
|
|
1129
|
+
(Aliasing, Alignment, crate::invariant::Initialized),
|
|
1130
|
+
{ crate::STRUCT_VARIANT_ID },
|
|
1131
|
+
{ crate::ident_id!($CurrI)}
|
|
1132
|
+
> for ($($AllT,)+)
|
|
1133
|
+
where
|
|
1134
|
+
Aliasing: crate::invariant::Aliasing,
|
|
1135
|
+
Alignment: crate::invariant::Alignment,
|
|
1136
|
+
{
|
|
1137
|
+
#[inline]
|
|
1138
|
+
fn only_derive_is_allowed_to_implement_this_trait()
|
|
1139
|
+
where
|
|
1140
|
+
Self: Sized
|
|
1141
|
+
{}
|
|
1142
|
+
|
|
1143
|
+
// SAFETY: Tuples are product types whose fields are
|
|
1144
|
+
// well-aligned, so projection preserves both the alignment and
|
|
1145
|
+
// validity invariants of the outer pointer.
|
|
1146
|
+
type Invariants = (Aliasing, Alignment, crate::invariant::Initialized);
|
|
1147
|
+
|
|
1148
|
+
// SAFETY: Tuples are product types and so projection is infallible;
|
|
1149
|
+
type Error = core::convert::Infallible;
|
|
1150
|
+
}
|
|
1151
|
+
|
|
1152
|
+
// SAFETY: See comments on items.
|
|
1153
|
+
unsafe impl<Aliasing, Alignment, $($AllT),+> crate::ProjectField<
|
|
1154
|
+
(),
|
|
1155
|
+
(Aliasing, Alignment, crate::invariant::Valid),
|
|
1156
|
+
{ crate::STRUCT_VARIANT_ID },
|
|
1157
|
+
{ crate::ident_id!($CurrI)}
|
|
1158
|
+
> for ($($AllT,)+)
|
|
1159
|
+
where
|
|
1160
|
+
Aliasing: crate::invariant::Aliasing,
|
|
1161
|
+
Alignment: crate::invariant::Alignment,
|
|
1162
|
+
{
|
|
1163
|
+
#[inline]
|
|
1164
|
+
fn only_derive_is_allowed_to_implement_this_trait()
|
|
1165
|
+
where
|
|
1166
|
+
Self: Sized
|
|
1167
|
+
{}
|
|
1168
|
+
|
|
1169
|
+
// SAFETY: Tuples are product types whose fields are
|
|
1170
|
+
// well-aligned, so projection preserves both the alignment and
|
|
1171
|
+
// validity invariants of the outer pointer.
|
|
1172
|
+
type Invariants = (Aliasing, Alignment, crate::invariant::Valid);
|
|
1173
|
+
|
|
1174
|
+
// SAFETY: Tuples are product types and so projection is infallible;
|
|
1175
|
+
type Error = core::convert::Infallible;
|
|
1176
|
+
}
|
|
1177
|
+
|
|
1178
|
+
// Recurse to the next index.
|
|
1179
|
+
impl_tuple!(@variants [$($AllT $AllI)+] [$($BeforeT)* $CurrT] [$($AfterT $AfterI)*]);
|
|
1180
|
+
};
|
|
1181
|
+
(@variants [$($AllT:ident $AllI:tt)+] [$($BeforeT:ident)*] []) => {};
|
|
1182
|
+
}
|
|
1183
|
+
|
|
1184
|
+
// SAFETY: `impl_tuple` is provided name-number pairs, where number is the
|
|
1185
|
+
// ordinal of the name.
|
|
1186
|
+
#[allow(clippy::multiple_unsafe_ops_per_block)]
|
|
1187
|
+
const _: () = unsafe {
|
|
1188
|
+
impl_tuple! {
|
|
1189
|
+
A 0,
|
|
1190
|
+
B 1,
|
|
1191
|
+
C 2,
|
|
1192
|
+
D 3,
|
|
1193
|
+
E 4,
|
|
1194
|
+
F 5,
|
|
1195
|
+
G 6,
|
|
1196
|
+
H 7,
|
|
1197
|
+
I 8,
|
|
1198
|
+
J 9,
|
|
1199
|
+
K 10,
|
|
1200
|
+
L 11,
|
|
1201
|
+
M 12,
|
|
1202
|
+
N 13,
|
|
1203
|
+
O 14,
|
|
1204
|
+
P 15,
|
|
1205
|
+
Q 16,
|
|
1206
|
+
R 17,
|
|
1207
|
+
S 18,
|
|
1208
|
+
T 19,
|
|
1209
|
+
U 20,
|
|
1210
|
+
V 21,
|
|
1211
|
+
W 22,
|
|
1212
|
+
X 23,
|
|
1213
|
+
Y 24,
|
|
1214
|
+
Z 25,
|
|
1215
|
+
};
|
|
1216
|
+
};
|
|
1217
|
+
}
|
|
1218
|
+
|
|
1008
1219
|
// SIMD support
|
|
1009
1220
|
//
|
|
1010
1221
|
// Per the Unsafe Code Guidelines Reference [1]:
|
|
@@ -1156,7 +1367,6 @@ mod simd {
|
|
|
1156
1367
|
#[cfg(test)]
|
|
1157
1368
|
mod tests {
|
|
1158
1369
|
use super::*;
|
|
1159
|
-
use crate::pointer::invariant;
|
|
1160
1370
|
|
|
1161
1371
|
#[test]
|
|
1162
1372
|
fn test_impls() {
|
|
@@ -1169,18 +1379,18 @@ mod tests {
|
|
|
1169
1379
|
// types must implement `TryFromBytesTestable` directly (ie using
|
|
1170
1380
|
// `impl_try_from_bytes_testable!`).
|
|
1171
1381
|
trait TryFromBytesTestable {
|
|
1172
|
-
fn with_passing_test_cases<F: Fn(Box<Self
|
|
1382
|
+
fn with_passing_test_cases<F: Fn(Box<ReadOnly<Self>>)>(f: F);
|
|
1173
1383
|
fn with_failing_test_cases<F: Fn(&mut [u8])>(f: F);
|
|
1174
1384
|
}
|
|
1175
1385
|
|
|
1176
1386
|
impl<T: FromBytes> TryFromBytesTestable for T {
|
|
1177
|
-
fn with_passing_test_cases<F: Fn(Box<Self
|
|
1387
|
+
fn with_passing_test_cases<F: Fn(Box<ReadOnly<Self>>)>(f: F) {
|
|
1178
1388
|
// Test with a zeroed value.
|
|
1179
|
-
f(Self
|
|
1389
|
+
f(ReadOnly::<Self>::new_box_zeroed().unwrap());
|
|
1180
1390
|
|
|
1181
1391
|
let ffs = {
|
|
1182
|
-
let mut t = Self::new_zeroed();
|
|
1183
|
-
let ptr: *mut T = &mut t;
|
|
1392
|
+
let mut t = ReadOnly::new(Self::new_zeroed());
|
|
1393
|
+
let ptr: *mut T = ReadOnly::as_mut(&mut t);
|
|
1184
1394
|
// SAFETY: `T: FromBytes`
|
|
1185
1395
|
unsafe { ptr::write_bytes(ptr.cast::<u8>(), 0xFF, mem::size_of::<T>()) };
|
|
1186
1396
|
t
|
|
@@ -1197,9 +1407,9 @@ mod tests {
|
|
|
1197
1407
|
($($tys:ty),*) => {
|
|
1198
1408
|
$(
|
|
1199
1409
|
impl TryFromBytesTestable for Option<$tys> {
|
|
1200
|
-
fn with_passing_test_cases<F: Fn(Box<Self
|
|
1410
|
+
fn with_passing_test_cases<F: Fn(Box<ReadOnly<Self>>)>(f: F) {
|
|
1201
1411
|
// Test with a zeroed value.
|
|
1202
|
-
f(Box::new(None));
|
|
1412
|
+
f(Box::new(ReadOnly::new(None)));
|
|
1203
1413
|
}
|
|
1204
1414
|
|
|
1205
1415
|
fn with_failing_test_cases<F: Fn(&mut [u8])>(f: F) {
|
|
@@ -1237,9 +1447,17 @@ mod tests {
|
|
|
1237
1447
|
// Implements only the methods; caller must invoke this from inside
|
|
1238
1448
|
// an impl block.
|
|
1239
1449
|
(@methods @success $($success_case:expr),* $(, @failure $($failure_case:expr),*)?) => {
|
|
1240
|
-
fn with_passing_test_cases<F: Fn(Box<Self
|
|
1450
|
+
fn with_passing_test_cases<F: Fn(Box<ReadOnly<Self>>)>(_f: F) {
|
|
1241
1451
|
$(
|
|
1242
|
-
|
|
1452
|
+
let bx = Box::<Self>::from($success_case);
|
|
1453
|
+
let ro: Box<ReadOnly<_>> = {
|
|
1454
|
+
let raw = Box::into_raw(bx);
|
|
1455
|
+
// SAFETY: `ReadOnly<T>` has the same layout and bit
|
|
1456
|
+
// validity as `T`.
|
|
1457
|
+
#[allow(clippy::as_conversions)]
|
|
1458
|
+
unsafe { Box::from_raw(raw as *mut _) }
|
|
1459
|
+
};
|
|
1460
|
+
_f(ro);
|
|
1243
1461
|
)*
|
|
1244
1462
|
}
|
|
1245
1463
|
|
|
@@ -1339,17 +1557,15 @@ mod tests {
|
|
|
1339
1557
|
|
|
1340
1558
|
pub(super) trait TestIsBitValidShared<T: ?Sized> {
|
|
1341
1559
|
#[allow(clippy::needless_lifetimes)]
|
|
1342
|
-
fn test_is_bit_valid_shared<'ptr,
|
|
1343
|
-
|
|
1344
|
-
candidate: Maybe<'ptr, T, A>,
|
|
1345
|
-
) -> Option<bool>;
|
|
1560
|
+
fn test_is_bit_valid_shared<'ptr>(&self, candidate: Maybe<'ptr, T>)
|
|
1561
|
+
-> Option<bool>;
|
|
1346
1562
|
}
|
|
1347
1563
|
|
|
1348
1564
|
impl<T: TryFromBytes + Immutable + ?Sized> TestIsBitValidShared<T> for AutorefWrapper<T> {
|
|
1349
1565
|
#[allow(clippy::needless_lifetimes)]
|
|
1350
|
-
fn test_is_bit_valid_shared<'ptr
|
|
1566
|
+
fn test_is_bit_valid_shared<'ptr>(
|
|
1351
1567
|
&self,
|
|
1352
|
-
candidate: Maybe<'ptr, T
|
|
1568
|
+
candidate: Maybe<'ptr, T>,
|
|
1353
1569
|
) -> Option<bool> {
|
|
1354
1570
|
Some(T::is_bit_valid(candidate))
|
|
1355
1571
|
}
|
|
@@ -1403,12 +1619,12 @@ mod tests {
|
|
|
1403
1619
|
|
|
1404
1620
|
pub(super) trait TestAsBytes<T: ?Sized> {
|
|
1405
1621
|
#[allow(clippy::needless_lifetimes)]
|
|
1406
|
-
fn test_as_bytes<'slf, 't>(&'slf self, t: &'t T) -> Option<&'t [u8]>;
|
|
1622
|
+
fn test_as_bytes<'slf, 't>(&'slf self, t: &'t ReadOnly<T>) -> Option<&'t [u8]>;
|
|
1407
1623
|
}
|
|
1408
1624
|
|
|
1409
1625
|
impl<T: IntoBytes + Immutable + ?Sized> TestAsBytes<T> for AutorefWrapper<T> {
|
|
1410
1626
|
#[allow(clippy::needless_lifetimes)]
|
|
1411
|
-
fn test_as_bytes<'slf, 't>(&'slf self, t: &'t T) -> Option<&'t [u8]> {
|
|
1627
|
+
fn test_as_bytes<'slf, 't>(&'slf self, t: &'t ReadOnly<T>) -> Option<&'t [u8]> {
|
|
1412
1628
|
Some(t.as_bytes())
|
|
1413
1629
|
}
|
|
1414
1630
|
}
|
|
@@ -1455,9 +1671,9 @@ mod tests {
|
|
|
1455
1671
|
#[allow(unused, non_local_definitions)]
|
|
1456
1672
|
impl AutorefWrapper<$ty> {
|
|
1457
1673
|
#[allow(clippy::needless_lifetimes)]
|
|
1458
|
-
fn test_is_bit_valid_shared<'ptr
|
|
1674
|
+
fn test_is_bit_valid_shared<'ptr>(
|
|
1459
1675
|
&mut self,
|
|
1460
|
-
candidate: Maybe<'ptr, $ty
|
|
1676
|
+
candidate: Maybe<'ptr, $ty>,
|
|
1461
1677
|
) -> Option<bool> {
|
|
1462
1678
|
assert_on_allowlist!(
|
|
1463
1679
|
test_is_bit_valid_shared($ty):
|
|
@@ -1515,7 +1731,7 @@ mod tests {
|
|
|
1515
1731
|
None
|
|
1516
1732
|
}
|
|
1517
1733
|
|
|
1518
|
-
fn test_as_bytes(&mut self, _t:
|
|
1734
|
+
fn test_as_bytes(&mut self, _t: &ReadOnly<$ty>) -> Option<&[u8]> {
|
|
1519
1735
|
assert_on_allowlist!(
|
|
1520
1736
|
test_as_bytes($ty):
|
|
1521
1737
|
Option<&'static UnsafeCell<NotZerocopy>>,
|
|
@@ -1566,7 +1782,7 @@ mod tests {
|
|
|
1566
1782
|
let c = unsafe { c.assume_initialized() };
|
|
1567
1783
|
let res = w.test_is_bit_valid_shared(c);
|
|
1568
1784
|
if let Some(res) = res {
|
|
1569
|
-
assert!(res, "{}::is_bit_valid
|
|
1785
|
+
assert!(res, "{}::is_bit_valid (shared `Ptr`): got false, expected true", stringify!($ty));
|
|
1570
1786
|
}
|
|
1571
1787
|
|
|
1572
1788
|
let c = Ptr::from_mut(&mut *val);
|
|
@@ -1574,9 +1790,9 @@ mod tests {
|
|
|
1574
1790
|
// SAFETY: FIXME(#899): This is unsound. `$ty` is not
|
|
1575
1791
|
// necessarily `IntoBytes`, but that's the corner we've
|
|
1576
1792
|
// backed ourselves into by using `Ptr::from_ref`.
|
|
1577
|
-
let c = unsafe { c.assume_initialized() };
|
|
1578
|
-
let res = <$ty as TryFromBytes>::is_bit_valid(c);
|
|
1579
|
-
assert!(res, "{}::is_bit_valid
|
|
1793
|
+
let mut c = unsafe { c.assume_initialized() };
|
|
1794
|
+
let res = <$ty as TryFromBytes>::is_bit_valid(c.reborrow_shared());
|
|
1795
|
+
assert!(res, "{}::is_bit_valid (exclusive `Ptr`): got false, expected true", stringify!($ty));
|
|
1580
1796
|
|
|
1581
1797
|
// `bytes` is `Some(val.as_bytes())` if `$ty: IntoBytes +
|
|
1582
1798
|
// Immutable` and `None` otherwise.
|
|
@@ -1587,7 +1803,7 @@ mod tests {
|
|
|
1587
1803
|
// Immutable` and `None` otherwise.
|
|
1588
1804
|
let res = bytes.and_then(|bytes| ww.test_try_from_ref(bytes));
|
|
1589
1805
|
if let Some(res) = res {
|
|
1590
|
-
assert!(res.is_some(), "{}::try_ref_from_bytes
|
|
1806
|
+
assert!(res.is_some(), "{}::try_ref_from_bytes: got `None`, expected `Some`", stringify!($ty));
|
|
1591
1807
|
}
|
|
1592
1808
|
|
|
1593
1809
|
if let Some(bytes) = bytes {
|
|
@@ -1611,13 +1827,13 @@ mod tests {
|
|
|
1611
1827
|
|
|
1612
1828
|
let res = ww.test_try_from_mut(bytes_mut);
|
|
1613
1829
|
if let Some(res) = res {
|
|
1614
|
-
assert!(res.is_some(), "{}::try_mut_from_bytes
|
|
1830
|
+
assert!(res.is_some(), "{}::try_mut_from_bytes: got `None`, expected `Some`", stringify!($ty));
|
|
1615
1831
|
}
|
|
1616
1832
|
}
|
|
1617
1833
|
|
|
1618
1834
|
let res = bytes.and_then(|bytes| ww.test_try_read_from(bytes));
|
|
1619
1835
|
if let Some(res) = res {
|
|
1620
|
-
assert!(res.is_some(), "{}::try_read_from_bytes
|
|
1836
|
+
assert!(res.is_some(), "{}::try_read_from_bytes: got `None`, expected `Some`", stringify!($ty));
|
|
1621
1837
|
}
|
|
1622
1838
|
});
|
|
1623
1839
|
#[allow(clippy::as_conversions)]
|