chore: checkpoint before Python removal

This commit is contained in:
2026-03-26 22:33:59 +00:00
parent 683cec9307
commit e568ddf82a
29972 changed files with 11269302 additions and 2 deletions

View File

@@ -0,0 +1,99 @@
error[E0277]: the trait bound `NotZerocopy: FromBytes` is not satisfied
--> $DIR/diagnostic-not-implemented.rs:16:24
|
16 | takes_from_bytes::<NotZerocopy>();
| ^^^^^^^^^^^ the trait `FromBytes` is not implemented for `NotZerocopy`
|
note: required by a bound in `takes_from_bytes`
--> $DIR/diagnostic-not-implemented.rs:77:24
|
77 | fn takes_from_bytes<T: FromBytes>() {}
| ^^^^^^^^^ required by this bound in `takes_from_bytes`
error[E0277]: the trait bound `NotZerocopy: FromZeros` is not satisfied
--> $DIR/diagnostic-not-implemented.rs:18:24
|
18 | takes_from_zeros::<NotZerocopy>();
| ^^^^^^^^^^^ the trait `FromZeros` is not implemented for `NotZerocopy`
|
note: required by a bound in `takes_from_zeros`
--> $DIR/diagnostic-not-implemented.rs:78:24
|
78 | fn takes_from_zeros<T: FromZeros>() {}
| ^^^^^^^^^ required by this bound in `takes_from_zeros`
error[E0277]: the trait bound `NotZerocopy: Immutable` is not satisfied
--> $DIR/diagnostic-not-implemented.rs:20:23
|
20 | takes_immutable::<NotZerocopy>();
| ^^^^^^^^^^^ the trait `Immutable` is not implemented for `NotZerocopy`
|
note: required by a bound in `takes_immutable`
--> $DIR/diagnostic-not-implemented.rs:79:23
|
79 | fn takes_immutable<T: Immutable>() {}
| ^^^^^^^^^ required by this bound in `takes_immutable`
error[E0277]: the trait bound `NotZerocopy: IntoBytes` is not satisfied
--> $DIR/diagnostic-not-implemented.rs:22:24
|
22 | takes_into_bytes::<NotZerocopy>();
| ^^^^^^^^^^^ the trait `IntoBytes` is not implemented for `NotZerocopy`
|
note: required by a bound in `takes_into_bytes`
--> $DIR/diagnostic-not-implemented.rs:80:24
|
80 | fn takes_into_bytes<T: IntoBytes>() {}
| ^^^^^^^^^ required by this bound in `takes_into_bytes`
error[E0277]: the trait bound `NotZerocopy: KnownLayout` is not satisfied
--> $DIR/diagnostic-not-implemented.rs:24:26
|
24 | takes_known_layout::<NotZerocopy>();
| ^^^^^^^^^^^ the trait `KnownLayout` is not implemented for `NotZerocopy`
|
note: required by a bound in `takes_known_layout`
--> $DIR/diagnostic-not-implemented.rs:81:26
|
81 | fn takes_known_layout<T: KnownLayout>() {}
| ^^^^^^^^^^^ required by this bound in `takes_known_layout`
error[E0277]: the trait bound `NotZerocopy: TryFromBytes` is not satisfied
--> $DIR/diagnostic-not-implemented.rs:26:28
|
26 | takes_try_from_bytes::<NotZerocopy>();
| ^^^^^^^^^^^ the trait `TryFromBytes` is not implemented for `NotZerocopy`
|
note: required by a bound in `takes_try_from_bytes`
--> $DIR/diagnostic-not-implemented.rs:82:28
|
82 | fn takes_try_from_bytes<T: TryFromBytes>() {}
| ^^^^^^^^^^^^ required by this bound in `takes_try_from_bytes`
error[E0277]: the trait bound `NotZerocopy: zerocopy::Unaligned` is not satisfied
--> $DIR/diagnostic-not-implemented.rs:28:23
|
28 | takes_unaligned::<NotZerocopy>();
| ^^^^^^^^^^^ the trait `zerocopy::Unaligned` is not implemented for `NotZerocopy`
|
note: required by a bound in `takes_unaligned`
--> $DIR/diagnostic-not-implemented.rs:83:23
|
83 | fn takes_unaligned<T: Unaligned>() {}
| ^^^^^^^^^ required by this bound in `takes_unaligned`
error[E0277]: the trait bound `NotZerocopy: Immutable` is not satisfied
--> $DIR/diagnostic-not-implemented.rs:66:19
|
66 | Foo.write_obj(NotZerocopy(()));
| ^^^^^^^^^^^^^^^ the trait `Immutable` is not implemented for `NotZerocopy`
error[E0277]: the trait bound `NotZerocopy: IntoBytes` is not satisfied
--> $DIR/diagnostic-not-implemented.rs:66:19
|
66 | Foo.write_obj(NotZerocopy(()));
| ^^^^^^^^^^^^^^^ the trait `IntoBytes` is not implemented for `NotZerocopy`
error: aborting due to 9 previous errors
For more information about this error, try `rustc --explain E0277`.

View File

@@ -0,0 +1,249 @@
error[E0277]: the trait bound `NotZerocopy: FromBytes` is not satisfied
--> $DIR/diagnostic-not-implemented.rs:16:24
|
16 | takes_from_bytes::<NotZerocopy>();
| ^^^^^^^^^^^ unsatisfied trait bound
|
help: the trait `FromBytes` is not implemented for `NotZerocopy`
--> $DIR/../include.rs:15:5
|
15 | pub struct NotZerocopy<T = ()>(pub T);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: Consider adding `#[derive(FromBytes)]` to `NotZerocopy`
= help: the following other types implement trait `FromBytes`:
()
(A, B)
(A, B, C)
(A, B, C, D)
(A, B, C, D, E)
(A, B, C, D, E, F)
(A, B, C, D, E, F, G)
(A, B, C, D, E, F, G, H)
and 79 others
note: required by a bound in `takes_from_bytes`
--> $DIR/diagnostic-not-implemented.rs:77:24
|
77 | fn takes_from_bytes<T: FromBytes>() {}
| ^^^^^^^^^ required by this bound in `takes_from_bytes`
error[E0277]: the trait bound `NotZerocopy: FromZeros` is not satisfied
--> $DIR/diagnostic-not-implemented.rs:18:24
|
18 | takes_from_zeros::<NotZerocopy>();
| ^^^^^^^^^^^ unsatisfied trait bound
|
help: the trait `FromZeros` is not implemented for `NotZerocopy`
--> $DIR/../include.rs:15:5
|
15 | pub struct NotZerocopy<T = ()>(pub T);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: Consider adding `#[derive(FromZeros)]` to `NotZerocopy`
= help: the following other types implement trait `FromZeros`:
()
(A, B)
(A, B, C)
(A, B, C, D)
(A, B, C, D, E)
(A, B, C, D, E, F)
(A, B, C, D, E, F, G)
(A, B, C, D, E, F, G, H)
and 141 others
note: required by a bound in `takes_from_zeros`
--> $DIR/diagnostic-not-implemented.rs:78:24
|
78 | fn takes_from_zeros<T: FromZeros>() {}
| ^^^^^^^^^ required by this bound in `takes_from_zeros`
error[E0277]: the trait bound `NotZerocopy: Immutable` is not satisfied
--> $DIR/diagnostic-not-implemented.rs:20:23
|
20 | takes_immutable::<NotZerocopy>();
| ^^^^^^^^^^^ unsatisfied trait bound
|
help: the trait `Immutable` is not implemented for `NotZerocopy`
--> $DIR/../include.rs:15:5
|
15 | pub struct NotZerocopy<T = ()>(pub T);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: Consider adding `#[derive(Immutable)]` to `NotZerocopy`
= help: the following other types implement trait `Immutable`:
&T
&mut T
()
(A, B)
(A, B, C)
(A, B, C, D)
(A, B, C, D, E)
(A, B, C, D, E, F)
and 128 others
note: required by a bound in `takes_immutable`
--> $DIR/diagnostic-not-implemented.rs:79:23
|
79 | fn takes_immutable<T: Immutable>() {}
| ^^^^^^^^^ required by this bound in `takes_immutable`
error[E0277]: the trait bound `NotZerocopy: IntoBytes` is not satisfied
--> $DIR/diagnostic-not-implemented.rs:22:24
|
22 | takes_into_bytes::<NotZerocopy>();
| ^^^^^^^^^^^ unsatisfied trait bound
|
help: the trait `IntoBytes` is not implemented for `NotZerocopy`
--> $DIR/../include.rs:15:5
|
15 | pub struct NotZerocopy<T = ()>(pub T);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: Consider adding `#[derive(IntoBytes)]` to `NotZerocopy`
= help: the following other types implement trait `IntoBytes`:
()
AU16
AtomicBool
AtomicI16
AtomicI32
AtomicI64
AtomicI8
AtomicIsize
and 68 others
note: required by a bound in `takes_into_bytes`
--> $DIR/diagnostic-not-implemented.rs:80:24
|
80 | fn takes_into_bytes<T: IntoBytes>() {}
| ^^^^^^^^^ required by this bound in `takes_into_bytes`
error[E0277]: the trait bound `NotZerocopy: KnownLayout` is not satisfied
--> $DIR/diagnostic-not-implemented.rs:24:26
|
24 | takes_known_layout::<NotZerocopy>();
| ^^^^^^^^^^^ unsatisfied trait bound
|
help: the trait `KnownLayout` is not implemented for `NotZerocopy`
--> $DIR/../include.rs:15:5
|
15 | pub struct NotZerocopy<T = ()>(pub T);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: Consider adding `#[derive(KnownLayout)]` to `NotZerocopy`
= help: the following other types implement trait `KnownLayout`:
&T
&mut T
()
*const T
*mut T
AU16
AtomicBool
AtomicI16
and 65 others
note: required by a bound in `takes_known_layout`
--> $DIR/diagnostic-not-implemented.rs:81:26
|
81 | fn takes_known_layout<T: KnownLayout>() {}
| ^^^^^^^^^^^ required by this bound in `takes_known_layout`
error[E0277]: the trait bound `NotZerocopy: TryFromBytes` is not satisfied
--> $DIR/diagnostic-not-implemented.rs:26:28
|
26 | takes_try_from_bytes::<NotZerocopy>();
| ^^^^^^^^^^^ unsatisfied trait bound
|
help: the trait `TryFromBytes` is not implemented for `NotZerocopy`
--> $DIR/../include.rs:15:5
|
15 | pub struct NotZerocopy<T = ()>(pub T);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: Consider adding `#[derive(TryFromBytes)]` to `NotZerocopy`
= help: the following other types implement trait `TryFromBytes`:
()
(A, B)
(A, B, C)
(A, B, C, D)
(A, B, C, D, E)
(A, B, C, D, E, F)
(A, B, C, D, E, F, G)
(A, B, C, D, E, F, G, H)
and 153 others
note: required by a bound in `takes_try_from_bytes`
--> $DIR/diagnostic-not-implemented.rs:82:28
|
82 | fn takes_try_from_bytes<T: TryFromBytes>() {}
| ^^^^^^^^^^^^ required by this bound in `takes_try_from_bytes`
error[E0277]: the trait bound `NotZerocopy: zerocopy::Unaligned` is not satisfied
--> $DIR/diagnostic-not-implemented.rs:28:23
|
28 | takes_unaligned::<NotZerocopy>();
| ^^^^^^^^^^^ unsatisfied trait bound
|
help: the trait `zerocopy::Unaligned` is not implemented for `NotZerocopy`
--> $DIR/../include.rs:15:5
|
15 | pub struct NotZerocopy<T = ()>(pub T);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: Consider adding `#[derive(Unaligned)]` to `NotZerocopy`
= help: the following other types implement trait `zerocopy::Unaligned`:
()
AtomicBool
AtomicI8
AtomicU8
Cell<T>
F32<O>
F64<O>
I128<O>
and 26 others
note: required by a bound in `takes_unaligned`
--> $DIR/diagnostic-not-implemented.rs:83:23
|
83 | fn takes_unaligned<T: Unaligned>() {}
| ^^^^^^^^^ required by this bound in `takes_unaligned`
error[E0277]: the trait bound `NotZerocopy: Immutable` is not satisfied
--> $DIR/diagnostic-not-implemented.rs:66:19
|
66 | Foo.write_obj(NotZerocopy(()));
| --------- ^^^^^^^^^^^^^^^ the trait `Immutable` is not implemented for `NotZerocopy`
| |
| required by a bound introduced by this call
|
note: required by a bound in `Foo::write_obj`
--> $DIR/diagnostic-not-implemented.rs:73:25
|
73 | fn write_obj<T: Immutable + IntoBytes>(&mut self, _val: T) {}
| ^^^^^^^^^ required by this bound in `Foo::write_obj`
help: consider borrowing here
|
66 | Foo.write_obj(&NotZerocopy(()));
| +
66 | Foo.write_obj(&mut NotZerocopy(()));
| ++++
error[E0277]: the trait bound `NotZerocopy: IntoBytes` is not satisfied
--> $DIR/diagnostic-not-implemented.rs:66:19
|
66 | Foo.write_obj(NotZerocopy(()));
| --------- ^^^^^^^^^^^^^^^ unsatisfied trait bound
| |
| required by a bound introduced by this call
|
help: the trait `IntoBytes` is not implemented for `NotZerocopy`
--> $DIR/../include.rs:15:5
|
15 | pub struct NotZerocopy<T = ()>(pub T);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: Consider adding `#[derive(IntoBytes)]` to `NotZerocopy`
= help: the following other types implement trait `IntoBytes`:
()
AU16
AtomicBool
AtomicI16
AtomicI32
AtomicI64
AtomicI8
AtomicIsize
and 68 others
note: required by a bound in `Foo::write_obj`
--> $DIR/diagnostic-not-implemented.rs:73:37
|
73 | fn write_obj<T: Immutable + IntoBytes>(&mut self, _val: T) {}
| ^^^^^^^^^ required by this bound in `Foo::write_obj`
error: aborting due to 9 previous errors
For more information about this error, try `rustc --explain E0277`.

View File

@@ -0,0 +1,83 @@
// Copyright 2022 The Fuchsia Authors
//
// Licensed under a BSD-style license <LICENSE-BSD>, Apache License, Version 2.0
// <LICENSE-APACHE or https://www.apache.org/licenses/LICENSE-2.0>, or the MIT
// license <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your option.
// This file may not be copied, modified, or distributed except according to
// those terms.
include!("../include.rs");
use util::NotZerocopy;
use zerocopy::{FromBytes, FromZeros, Immutable, IntoBytes, KnownLayout, TryFromBytes, Unaligned};
fn main() {
// We expect the proper diagnostic to be emitted on Rust 1.78.0 and later.
takes_from_bytes::<NotZerocopy>();
//~[msrv, stable, nightly]^ ERROR: the trait bound `NotZerocopy: FromBytes` is not satisfied
takes_from_zeros::<NotZerocopy>();
//~[msrv, stable, nightly]^ ERROR: the trait bound `NotZerocopy: FromZeros` is not satisfied
takes_immutable::<NotZerocopy>();
//~[msrv, stable, nightly]^ ERROR: the trait bound `NotZerocopy: Immutable` is not satisfied
takes_into_bytes::<NotZerocopy>();
//~[msrv, stable, nightly]^ ERROR: the trait bound `NotZerocopy: IntoBytes` is not satisfied
takes_known_layout::<NotZerocopy>();
//~[msrv, stable, nightly]^ ERROR: the trait bound `NotZerocopy: KnownLayout` is not satisfied
takes_try_from_bytes::<NotZerocopy>();
//~[msrv, stable, nightly]^ ERROR: the trait bound `NotZerocopy: TryFromBytes` is not satisfied
takes_unaligned::<NotZerocopy>();
//~[msrv, stable, nightly]^ ERROR: the trait bound `NotZerocopy: zerocopy::Unaligned` is not satisfied
// This is adapted from #1296, which includes the following text:
//
// The compiler errors when a type is missing Immutable are somewhat
// misleading, although I'm not sure there's much zerocopy can do about
// this. An example where the compiler recommends adding a reference
// rather than implementing Immutable (some were even more confusing than
// this):
//
// error[E0277]: the trait bound `virtio::wl::CtrlVfdNewDmabuf: zerocopy::Immutable` is not satisfied
// --> devices/src/virtio/wl.rs:317:20
// |
// 317 | .write_obj(ctrl_vfd_new_dmabuf)
// | --------- ^^^^^^^^^^^^^^^^^^^ the trait `zerocopy::Immutable` is not implemented for `virtio::wl::CtrlVfdNewDmabuf`
// | |
// | required by a bound introduced by this call
// |
// note: required by a bound in `virtio::descriptor_utils::Writer::write_obj`
// --> devices/src/virtio/descriptor_utils.rs:536:25
// |
// 536 | pub fn write_obj<T: Immutable + IntoBytes>(&mut self, val: T) -> io::Result<()> {
// | ^^^^^^^^^ required by this bound in `Writer::write_obj`
// help: consider borrowing here
// |
// 317 | .write_obj(&ctrl_vfd_new_dmabuf)
// | +
// 317 | .write_obj(&mut ctrl_vfd_new_dmabuf)
// | ++++
//
// Taking the compiler's suggestion results in a different error with a
// recommendation to remove the reference (back to the original code).
//
// As of this writing, the described problem is still happening thanks to
// https://github.com/rust-lang/rust/issues/130563. We include this test so
// that we can capture the current behavior, but we will update it once that
// Rust issue is fixed.
Foo.write_obj(NotZerocopy(()));
//~[msrv, stable, nightly]^ ERROR: the trait bound `NotZerocopy: Immutable` is not satisfied
//~[msrv, stable, nightly]^^ ERROR: the trait bound `NotZerocopy: IntoBytes` is not satisfied
struct Foo;
impl Foo {
fn write_obj<T: Immutable + IntoBytes>(&mut self, _val: T) {}
}
}
fn takes_from_bytes<T: FromBytes>() {}
fn takes_from_zeros<T: FromZeros>() {}
fn takes_immutable<T: Immutable>() {}
fn takes_into_bytes<T: IntoBytes>() {}
fn takes_known_layout<T: KnownLayout>() {}
fn takes_try_from_bytes<T: TryFromBytes>() {}
fn takes_unaligned<T: Unaligned>() {}

View File

@@ -0,0 +1,249 @@
error[E0277]: the trait bound `NotZerocopy: FromBytes` is not satisfied
--> $DIR/diagnostic-not-implemented.rs:16:24
|
16 | takes_from_bytes::<NotZerocopy>();
| ^^^^^^^^^^^ unsatisfied trait bound
|
help: the trait `FromBytes` is not implemented for `NotZerocopy`
--> $DIR/../include.rs:15:5
|
15 | pub struct NotZerocopy<T = ()>(pub T);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: Consider adding `#[derive(FromBytes)]` to `NotZerocopy`
= help: the following other types implement trait `FromBytes`:
()
(A, B)
(A, B, C)
(A, B, C, D)
(A, B, C, D, E)
(A, B, C, D, E, F)
(A, B, C, D, E, F, G)
(A, B, C, D, E, F, G, H)
and 79 others
note: required by a bound in `takes_from_bytes`
--> $DIR/diagnostic-not-implemented.rs:77:24
|
77 | fn takes_from_bytes<T: FromBytes>() {}
| ^^^^^^^^^ required by this bound in `takes_from_bytes`
error[E0277]: the trait bound `NotZerocopy: FromZeros` is not satisfied
--> $DIR/diagnostic-not-implemented.rs:18:24
|
18 | takes_from_zeros::<NotZerocopy>();
| ^^^^^^^^^^^ unsatisfied trait bound
|
help: the trait `FromZeros` is not implemented for `NotZerocopy`
--> $DIR/../include.rs:15:5
|
15 | pub struct NotZerocopy<T = ()>(pub T);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: Consider adding `#[derive(FromZeros)]` to `NotZerocopy`
= help: the following other types implement trait `FromZeros`:
()
(A, B)
(A, B, C)
(A, B, C, D)
(A, B, C, D, E)
(A, B, C, D, E, F)
(A, B, C, D, E, F, G)
(A, B, C, D, E, F, G, H)
and 141 others
note: required by a bound in `takes_from_zeros`
--> $DIR/diagnostic-not-implemented.rs:78:24
|
78 | fn takes_from_zeros<T: FromZeros>() {}
| ^^^^^^^^^ required by this bound in `takes_from_zeros`
error[E0277]: the trait bound `NotZerocopy: Immutable` is not satisfied
--> $DIR/diagnostic-not-implemented.rs:20:23
|
20 | takes_immutable::<NotZerocopy>();
| ^^^^^^^^^^^ unsatisfied trait bound
|
help: the trait `Immutable` is not implemented for `NotZerocopy`
--> $DIR/../include.rs:15:5
|
15 | pub struct NotZerocopy<T = ()>(pub T);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: Consider adding `#[derive(Immutable)]` to `NotZerocopy`
= help: the following other types implement trait `Immutable`:
&T
&mut T
()
(A, B)
(A, B, C)
(A, B, C, D)
(A, B, C, D, E)
(A, B, C, D, E, F)
and 128 others
note: required by a bound in `takes_immutable`
--> $DIR/diagnostic-not-implemented.rs:79:23
|
79 | fn takes_immutable<T: Immutable>() {}
| ^^^^^^^^^ required by this bound in `takes_immutable`
error[E0277]: the trait bound `NotZerocopy: IntoBytes` is not satisfied
--> $DIR/diagnostic-not-implemented.rs:22:24
|
22 | takes_into_bytes::<NotZerocopy>();
| ^^^^^^^^^^^ unsatisfied trait bound
|
help: the trait `IntoBytes` is not implemented for `NotZerocopy`
--> $DIR/../include.rs:15:5
|
15 | pub struct NotZerocopy<T = ()>(pub T);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: Consider adding `#[derive(IntoBytes)]` to `NotZerocopy`
= help: the following other types implement trait `IntoBytes`:
()
AU16
AtomicBool
AtomicI16
AtomicI32
AtomicI64
AtomicI8
AtomicIsize
and 68 others
note: required by a bound in `takes_into_bytes`
--> $DIR/diagnostic-not-implemented.rs:80:24
|
80 | fn takes_into_bytes<T: IntoBytes>() {}
| ^^^^^^^^^ required by this bound in `takes_into_bytes`
error[E0277]: the trait bound `NotZerocopy: KnownLayout` is not satisfied
--> $DIR/diagnostic-not-implemented.rs:24:26
|
24 | takes_known_layout::<NotZerocopy>();
| ^^^^^^^^^^^ unsatisfied trait bound
|
help: the trait `KnownLayout` is not implemented for `NotZerocopy`
--> $DIR/../include.rs:15:5
|
15 | pub struct NotZerocopy<T = ()>(pub T);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: Consider adding `#[derive(KnownLayout)]` to `NotZerocopy`
= help: the following other types implement trait `KnownLayout`:
&T
&mut T
()
*const T
*mut T
AU16
AtomicBool
AtomicI16
and 65 others
note: required by a bound in `takes_known_layout`
--> $DIR/diagnostic-not-implemented.rs:81:26
|
81 | fn takes_known_layout<T: KnownLayout>() {}
| ^^^^^^^^^^^ required by this bound in `takes_known_layout`
error[E0277]: the trait bound `NotZerocopy: TryFromBytes` is not satisfied
--> $DIR/diagnostic-not-implemented.rs:26:28
|
26 | takes_try_from_bytes::<NotZerocopy>();
| ^^^^^^^^^^^ unsatisfied trait bound
|
help: the trait `TryFromBytes` is not implemented for `NotZerocopy`
--> $DIR/../include.rs:15:5
|
15 | pub struct NotZerocopy<T = ()>(pub T);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: Consider adding `#[derive(TryFromBytes)]` to `NotZerocopy`
= help: the following other types implement trait `TryFromBytes`:
()
(A, B)
(A, B, C)
(A, B, C, D)
(A, B, C, D, E)
(A, B, C, D, E, F)
(A, B, C, D, E, F, G)
(A, B, C, D, E, F, G, H)
and 153 others
note: required by a bound in `takes_try_from_bytes`
--> $DIR/diagnostic-not-implemented.rs:82:28
|
82 | fn takes_try_from_bytes<T: TryFromBytes>() {}
| ^^^^^^^^^^^^ required by this bound in `takes_try_from_bytes`
error[E0277]: the trait bound `NotZerocopy: zerocopy::Unaligned` is not satisfied
--> $DIR/diagnostic-not-implemented.rs:28:23
|
28 | takes_unaligned::<NotZerocopy>();
| ^^^^^^^^^^^ unsatisfied trait bound
|
help: the trait `zerocopy::Unaligned` is not implemented for `NotZerocopy`
--> $DIR/../include.rs:15:5
|
15 | pub struct NotZerocopy<T = ()>(pub T);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: Consider adding `#[derive(Unaligned)]` to `NotZerocopy`
= help: the following other types implement trait `zerocopy::Unaligned`:
()
AtomicBool
AtomicI8
AtomicU8
Cell<T>
F32<O>
F64<O>
I128<O>
and 26 others
note: required by a bound in `takes_unaligned`
--> $DIR/diagnostic-not-implemented.rs:83:23
|
83 | fn takes_unaligned<T: Unaligned>() {}
| ^^^^^^^^^ required by this bound in `takes_unaligned`
error[E0277]: the trait bound `NotZerocopy: Immutable` is not satisfied
--> $DIR/diagnostic-not-implemented.rs:66:19
|
66 | Foo.write_obj(NotZerocopy(()));
| --------- ^^^^^^^^^^^^^^^ the trait `Immutable` is not implemented for `NotZerocopy`
| |
| required by a bound introduced by this call
|
note: required by a bound in `Foo::write_obj`
--> $DIR/diagnostic-not-implemented.rs:73:25
|
73 | fn write_obj<T: Immutable + IntoBytes>(&mut self, _val: T) {}
| ^^^^^^^^^ required by this bound in `Foo::write_obj`
help: consider borrowing here
|
66 | Foo.write_obj(&NotZerocopy(()));
| +
66 | Foo.write_obj(&mut NotZerocopy(()));
| ++++
error[E0277]: the trait bound `NotZerocopy: IntoBytes` is not satisfied
--> $DIR/diagnostic-not-implemented.rs:66:19
|
66 | Foo.write_obj(NotZerocopy(()));
| --------- ^^^^^^^^^^^^^^^ unsatisfied trait bound
| |
| required by a bound introduced by this call
|
help: the trait `IntoBytes` is not implemented for `NotZerocopy`
--> $DIR/../include.rs:15:5
|
15 | pub struct NotZerocopy<T = ()>(pub T);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: Consider adding `#[derive(IntoBytes)]` to `NotZerocopy`
= help: the following other types implement trait `IntoBytes`:
()
AU16
AtomicBool
AtomicI16
AtomicI32
AtomicI64
AtomicI8
AtomicIsize
and 68 others
note: required by a bound in `Foo::write_obj`
--> $DIR/diagnostic-not-implemented.rs:73:37
|
73 | fn write_obj<T: Immutable + IntoBytes>(&mut self, _val: T) {}
| ^^^^^^^^^ required by this bound in `Foo::write_obj`
error: aborting due to 9 previous errors
For more information about this error, try `rustc --explain E0277`.

View File

@@ -0,0 +1,19 @@
error[E0277]: the trait bound `NotZerocopy<u32>: FromBytes` is not satisfied
--> $DIR/include_value.rs:17:5
|
17 | zerocopy::include_value!("../../testdata/include_value/data");
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `FromBytes` is not implemented for `NotZerocopy<u32>`
|
note: required by a bound in `NOT_FROM_BYTES::transmute`
--> $DIR/include_value.rs:17:5
|
17 | zerocopy::include_value!("../../testdata/include_value/data");
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
| required by a bound in this
| required by this bound in `NOT_FROM_BYTES::transmute`
= note: this error originates in the macro `$crate::transmute` (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to previous error
For more information about this error, try `rustc --explain E0277`.

View File

@@ -0,0 +1,35 @@
error[E0277]: the trait bound `NotZerocopy<u32>: FromBytes` is not satisfied
--> $DIR/include_value.rs:17:5
|
17 | zerocopy::include_value!("../../testdata/include_value/data");
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unsatisfied trait bound
|
help: the trait `FromBytes` is not implemented for `NotZerocopy<u32>`
--> $DIR/../include.rs:15:5
|
15 | pub struct NotZerocopy<T = ()>(pub T);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: Consider adding `#[derive(FromBytes)]` to `NotZerocopy<u32>`
= help: the following other types implement trait `FromBytes`:
()
(A, B)
(A, B, C)
(A, B, C, D)
(A, B, C, D, E)
(A, B, C, D, E, F)
(A, B, C, D, E, F, G)
(A, B, C, D, E, F, G, H)
and 79 others
note: required by a bound in `NOT_FROM_BYTES::transmute`
--> $DIR/include_value.rs:17:5
|
17 | zerocopy::include_value!("../../testdata/include_value/data");
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
| required by a bound in this function
| required by this bound in `transmute`
= note: this error originates in the macro `$crate::transmute` which comes from the expansion of the macro `zerocopy::include_value` (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0277`.

View File

@@ -0,0 +1,18 @@
// Copyright 2023 The Fuchsia Authors
//
// Licensed under a BSD-style license <LICENSE-BSD>, Apache License, Version 2.0
// <LICENSE-APACHE or https://www.apache.org/licenses/LICENSE-2.0>, or the MIT
// license <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your option.
// This file may not be copied, modified, or distributed except according to
// those terms.
include!("../include.rs");
use util::NotZerocopy;
fn main() {}
// Should fail because `NotZerocopy<u32>: !FromBytes`.
const NOT_FROM_BYTES: NotZerocopy<u32> =
zerocopy::include_value!("../../testdata/include_value/data");
//~[msrv, stable, nightly]^ ERROR: the trait bound `NotZerocopy<u32>: FromBytes` is not satisfied

View File

@@ -0,0 +1,35 @@
error[E0277]: the trait bound `NotZerocopy<u32>: FromBytes` is not satisfied
--> $DIR/include_value.rs:17:5
|
17 | zerocopy::include_value!("../../testdata/include_value/data");
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unsatisfied trait bound
|
help: the trait `FromBytes` is not implemented for `NotZerocopy<u32>`
--> $DIR/../include.rs:15:5
|
15 | pub struct NotZerocopy<T = ()>(pub T);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: Consider adding `#[derive(FromBytes)]` to `NotZerocopy<u32>`
= help: the following other types implement trait `FromBytes`:
()
(A, B)
(A, B, C)
(A, B, C, D)
(A, B, C, D, E)
(A, B, C, D, E, F)
(A, B, C, D, E, F, G)
(A, B, C, D, E, F, G, H)
and 79 others
note: required by a bound in `NOT_FROM_BYTES::transmute`
--> $DIR/include_value.rs:17:5
|
17 | zerocopy::include_value!("../../testdata/include_value/data");
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
| required by a bound in this function
| required by this bound in `transmute`
= note: this error originates in the macro `$crate::transmute` which comes from the expansion of the macro `zerocopy::include_value` (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0277`.

View File

@@ -0,0 +1,135 @@
error[E0512]: cannot transmute between types of different sizes, or dependently-sized types
--> $DIR/late-compile-pass.rs:20:37
|
20 | const TRANSMUTE_DECREASE_SIZE: u8 = transmute!(AU16(0));
| ^^^^^^^^^^^^^^^^^^^
|
= note: source type: `AU16` (16 bits)
= note: target type: `u8` (8 bits)
= note: this error originates in the macro `transmute` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0512]: cannot transmute between types of different sizes, or dependently-sized types
--> $DIR/late-compile-pass.rs:26:39
|
26 | const TRANSMUTE_INCREASE_SIZE: AU16 = transmute!(0u8);
| ^^^^^^^^^^^^^^^
|
= note: source type: `u8` (8 bits)
= note: target type: `AU16` (16 bits)
= note: this error originates in the macro `transmute` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0512]: cannot transmute between types of different sizes, or dependently-sized types
--> $DIR/late-compile-pass.rs:32:52
|
32 | const TRANSMUTE_INCREASE_SIZE_ALLOW_SHRINK: AU16 = transmute!(#![allow(shrink)] 0u8);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: source type: `u8` (8 bits)
= note: target type: `Transmute<u8, AU16>` (16 bits)
= note: this error originates in the macro `transmute` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0512]: cannot transmute between types of different sizes, or dependently-sized types
--> $DIR/late-compile-pass.rs:50:39
|
50 | const INCLUDE_VALUE_WRONG_SIZE: u64 = zerocopy::include_value!("../../testdata/include_value/data");
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: source type: `[u8; 4]` (32 bits)
= note: target type: `u64` (64 bits)
= note: this error originates in the macro `$crate::transmute` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0512]: cannot transmute between types of different sizes, or dependently-sized types
--> $DIR/late-compile-pass.rs:58:41
|
58 | let _decrease_size: Result<u8, _> = try_transmute!(AU16(0));
| ^^^^^^^^^^^^^^^^^^^^^^^
|
= note: source type: `AU16` (16 bits)
= note: target type: `u8` (8 bits)
= note: this error originates in the macro `try_transmute` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0512]: cannot transmute between types of different sizes, or dependently-sized types
--> $DIR/late-compile-pass.rs:63:43
|
63 | let _increase_size: Result<AU16, _> = try_transmute!(0u8);
| ^^^^^^^^^^^^^^^^^^^
|
= note: source type: `u8` (8 bits)
= note: target type: `AU16` (16 bits)
= note: this error originates in the macro `try_transmute` (in Nightly builds, run with -Z macro-backtrace for more info)
warning: taking a mutable reference to a `const` item
--> $DIR/late-compile-pass.rs:39:66
|
39 | const TRANSMUTE_MUT_CONST_CONTEXT: &mut [u8; 2] = transmute_mut!(&mut ARRAY_OF_U8S);
| ^^^^^^^^^^^^^^^^^
|
= note: `#[warn(const_item_mutation)]` on by default
= note: each usage of a `const` item creates a new temporary
= note: the mutable reference will refer to this temporary, not the original `const` item
note: `const` item defined here
--> $DIR/late-compile-pass.rs:36:1
|
36 | const ARRAY_OF_U8S: [u8; 2] = [0u8; 2];
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0658]: mutable references are not allowed in constants
--> $DIR/late-compile-pass.rs:39:66
|
39 | const TRANSMUTE_MUT_CONST_CONTEXT: &mut [u8; 2] = transmute_mut!(&mut ARRAY_OF_U8S);
| ^^^^^^^^^^^^^^^^^
|
= note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information
error[E0015]: calls in constants are limited to constant functions, tuple structs and tuple variants
--> $DIR/late-compile-pass.rs:39:51
|
39 | const TRANSMUTE_MUT_CONST_CONTEXT: &mut [u8; 2] = transmute_mut!(&mut ARRAY_OF_U8S);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: this error originates in the macro `transmute_mut` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0015]: calls in constants are limited to constant functions, tuple structs and tuple variants
--> $DIR/late-compile-pass.rs:39:51
|
39 | const TRANSMUTE_MUT_CONST_CONTEXT: &mut [u8; 2] = transmute_mut!(&mut ARRAY_OF_U8S);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: this error originates in the macro `transmute_mut` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0716]: temporary value dropped while borrowed
--> $DIR/late-compile-pass.rs:39:71
|
39 | const TRANSMUTE_MUT_CONST_CONTEXT: &mut [u8; 2] = transmute_mut!(&mut ARRAY_OF_U8S);
| --------------------^^^^^^^^^^^^-
| | |
| | creates a temporary which is freed while still in use
| temporary value is freed at the end of this statement
| using this value as a constant requires that borrow lasts for `'static`
error[E0597]: `x` does not live long enough
--> $DIR/late-compile-pass.rs:69:60
|
69 | let _: &'static mut u64 = zerocopy::transmute_mut!(&mut x);
| ---------------- ^^^^^^ borrowed value does not live long enough
| |
| type annotation requires that `x` is borrowed for `'static`
70 |
71 | }
| - `x` dropped here while still borrowed
error[E0597]: `x` does not live long enough
--> $DIR/late-compile-pass.rs:76:56
|
76 | let _: &'static u64 = zerocopy::transmute_ref!(&x);
| ------------ ^^ borrowed value does not live long enough
| |
| type annotation requires that `x` is borrowed for `'static`
77 |
78 | }
| - `x` dropped here while still borrowed
error: aborting due to 12 previous errors; 1 warning emitted
Some errors have detailed explanations: E0015, E0512, E0597, E0658, E0716.
For more information about an error, try `rustc --explain E0015`.

View File

@@ -0,0 +1,157 @@
error[E0080]: transmuting from 2-byte type to 1-byte type: `AU16` -> `u8`
--> $DIR/late-compile-pass.rs:20:37
|
20 | const TRANSMUTE_DECREASE_SIZE: u8 = transmute!(AU16(0));
| ^^^^^^^^^^^^^^^^^^^ evaluation of `TRANSMUTE_DECREASE_SIZE` failed here
|
= note: this error originates in the macro `transmute` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0080]: transmuting from 1-byte type to 2-byte type: `u8` -> `AU16`
--> $DIR/late-compile-pass.rs:26:39
|
26 | const TRANSMUTE_INCREASE_SIZE: AU16 = transmute!(0u8);
| ^^^^^^^^^^^^^^^ evaluation of `TRANSMUTE_INCREASE_SIZE` failed here
|
= note: this error originates in the macro `transmute` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0080]: transmuting from 1-byte type to 2-byte type: `u8` -> `Transmute<u8, AU16>`
--> $DIR/late-compile-pass.rs:32:52
|
32 | const TRANSMUTE_INCREASE_SIZE_ALLOW_SHRINK: AU16 = transmute!(#![allow(shrink)] 0u8);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `TRANSMUTE_INCREASE_SIZE_ALLOW_SHRINK` failed here
|
= note: this error originates in the macro `transmute` (in Nightly builds, run with -Z macro-backtrace for more info)
warning: taking a mutable reference to a `const` item
--> $DIR/late-compile-pass.rs:39:66
|
39 | const TRANSMUTE_MUT_CONST_CONTEXT: &mut [u8; 2] = transmute_mut!(&mut ARRAY_OF_U8S);
| ^^^^^^^^^^^^^^^^^
|
= note: each usage of a `const` item creates a new temporary
= note: the mutable reference will refer to this temporary, not the original `const` item
note: `const` item defined here
--> $DIR/late-compile-pass.rs:36:1
|
36 | const ARRAY_OF_U8S: [u8; 2] = [0u8; 2];
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: `#[warn(const_item_mutation)]` on by default
error[E0015]: cannot call non-const method `zerocopy::util::macro_util::Wrap::<&mut [u8; 2], &mut [u8; 2]>::transmute_mut_inference_helper` in constants
--> $DIR/late-compile-pass.rs:39:51
|
39 | const TRANSMUTE_MUT_CONST_CONTEXT: &mut [u8; 2] = transmute_mut!(&mut ARRAY_OF_U8S);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: calls in constants are limited to constant functions, tuple structs and tuple variants
= note: this error originates in the macro `transmute_mut` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0015]: cannot call non-const method `zerocopy::util::macro_util::Wrap::<&mut [u8; 2], &mut [u8; 2]>::transmute_mut` in constants
--> $DIR/late-compile-pass.rs:39:51
|
39 | const TRANSMUTE_MUT_CONST_CONTEXT: &mut [u8; 2] = transmute_mut!(&mut ARRAY_OF_U8S);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: calls in constants are limited to constant functions, tuple structs and tuple variants
= note: this error originates in the macro `transmute_mut` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0080]: transmuting from 4-byte type to 8-byte type: `[u8; 4]` -> `u64`
--> $DIR/late-compile-pass.rs:50:39
|
50 | const INCLUDE_VALUE_WRONG_SIZE: u64 = zerocopy::include_value!("../../testdata/include_value/data");
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `INCLUDE_VALUE_WRONG_SIZE` failed here
|
= note: this error originates in the macro `$crate::transmute` which comes from the expansion of the macro `zerocopy::include_value` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0512]: cannot transmute between types of different sizes, or dependently-sized types
--> $DIR/late-compile-pass.rs:20:37
|
20 | const TRANSMUTE_DECREASE_SIZE: u8 = transmute!(AU16(0));
| ^^^^^^^^^^^^^^^^^^^
|
= note: source type: `AU16` (16 bits)
= note: target type: `u8` (8 bits)
= note: this error originates in the macro `transmute` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0512]: cannot transmute between types of different sizes, or dependently-sized types
--> $DIR/late-compile-pass.rs:26:39
|
26 | const TRANSMUTE_INCREASE_SIZE: AU16 = transmute!(0u8);
| ^^^^^^^^^^^^^^^
|
= note: source type: `u8` (8 bits)
= note: target type: `AU16` (16 bits)
= note: this error originates in the macro `transmute` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0512]: cannot transmute between types of different sizes, or dependently-sized types
--> $DIR/late-compile-pass.rs:32:52
|
32 | const TRANSMUTE_INCREASE_SIZE_ALLOW_SHRINK: AU16 = transmute!(#![allow(shrink)] 0u8);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: source type: `u8` (8 bits)
= note: target type: `Transmute<u8, AU16>` (16 bits)
= note: this error originates in the macro `transmute` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0512]: cannot transmute between types of different sizes, or dependently-sized types
--> $DIR/late-compile-pass.rs:50:39
|
50 | const INCLUDE_VALUE_WRONG_SIZE: u64 = zerocopy::include_value!("../../testdata/include_value/data");
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: source type: `[u8; 4]` (32 bits)
= note: target type: `u64` (64 bits)
= note: this error originates in the macro `$crate::transmute` which comes from the expansion of the macro `zerocopy::include_value` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0512]: cannot transmute between types of different sizes, or dependently-sized types
--> $DIR/late-compile-pass.rs:58:41
|
58 | let _decrease_size: Result<u8, _> = try_transmute!(AU16(0));
| ^^^^^^^^^^^^^^^^^^^^^^^
|
= note: source type: `AU16` (16 bits)
= note: target type: `u8` (8 bits)
= note: this error originates in the macro `try_transmute` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0512]: cannot transmute between types of different sizes, or dependently-sized types
--> $DIR/late-compile-pass.rs:63:43
|
63 | let _increase_size: Result<AU16, _> = try_transmute!(0u8);
| ^^^^^^^^^^^^^^^^^^^
|
= note: source type: `u8` (8 bits)
= note: target type: `AU16` (16 bits)
= note: this error originates in the macro `try_transmute` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0597]: `x` does not live long enough
--> $DIR/late-compile-pass.rs:69:60
|
67 | let mut x = 0u64;
| ----- binding `x` declared here
68 | // It is illegal to increase the lifetime scope.
69 | let _: &'static mut u64 = zerocopy::transmute_mut!(&mut x);
| ---------------- ^^^^^^ borrowed value does not live long enough
| |
| type annotation requires that `x` is borrowed for `'static`
70 |
71 | }
| - `x` dropped here while still borrowed
error[E0597]: `x` does not live long enough
--> $DIR/late-compile-pass.rs:76:56
|
74 | let x = 0u64;
| - binding `x` declared here
75 | // It is illegal to increase the lifetime scope.
76 | let _: &'static u64 = zerocopy::transmute_ref!(&x);
| ------------ ^^ borrowed value does not live long enough
| |
| type annotation requires that `x` is borrowed for `'static`
77 |
78 | }
| - `x` dropped here while still borrowed
error: aborting due to 14 previous errors; 1 warning emitted
Some errors have detailed explanations: E0015, E0080, E0512, E0597.
For more information about an error, try `rustc --explain E0015`.

View File

@@ -0,0 +1,79 @@
// Copyright 2026 The Fuchsia Authors
//
// Licensed under a BSD-style license <LICENSE-BSD>, Apache License, Version 2.0
// <LICENSE-APACHE or https://www.apache.org/licenses/LICENSE-2.0>, or the MIT
// license <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your option.
// This file may not be copied, modified, or distributed except according to
// those terms.
// These tests cause errors which are generated by a later compilation pass than
// the other errors we generate, and so if they're compiled in the same file,
// the compiler will never get to that pass, and so we won't get the errors.
include!("../include.rs");
use util::AU16;
use zerocopy::{transmute, transmute_mut, try_transmute};
// Although this is not a soundness requirement, we currently require that the
// size of the destination type is not smaller than the size of the source type.
const TRANSMUTE_DECREASE_SIZE: u8 = transmute!(AU16(0));
//~[msrv, stable, nightly]^ ERROR: cannot transmute between types of different sizes, or dependently-sized types
//~[stable, nightly]^^ ERROR: transmuting from 2-byte type to 1-byte type: `AU16` -> `u8`
// `transmute!` does not support transmuting from a smaller type to a larger
// one.
const TRANSMUTE_INCREASE_SIZE: AU16 = transmute!(0u8);
//~[msrv, stable, nightly]^ ERROR: cannot transmute between types of different sizes, or dependently-sized types
//~[stable, nightly]^^ ERROR: transmuting from 1-byte type to 2-byte type: `u8` -> `AU16`
// `transmute!` does not support transmuting from a smaller type to a larger
// one.
const TRANSMUTE_INCREASE_SIZE_ALLOW_SHRINK: AU16 = transmute!(#![allow(shrink)] 0u8);
//~[msrv, stable, nightly]^ ERROR: cannot transmute between types of different sizes, or dependently-sized types
//~[stable, nightly]^^ ERROR: transmuting from 1-byte type to 2-byte type: `u8` -> `Transmute<u8, AU16>`
const ARRAY_OF_U8S: [u8; 2] = [0u8; 2];
// `transmute_mut!` cannot, generally speaking, be used in const contexts.
const TRANSMUTE_MUT_CONST_CONTEXT: &mut [u8; 2] = transmute_mut!(&mut ARRAY_OF_U8S);
//~[msrv]^ ERROR: mutable references are not allowed in constants
//~[msrv]^^ ERROR: calls in constants are limited to constant functions, tuple structs and tuple variants
//~[msrv]^^^ ERROR: calls in constants are limited to constant functions, tuple structs and tuple variants
//~[msrv]^^^^ ERROR: temporary value dropped while borrowed
//~[stable]^^^^^ ERROR: cannot call non-const method `Wrap::<&mut [u8; 2], &mut [u8; 2]>::transmute_mut_inference_helper` in constants
//~[stable]^^^^^^ ERROR: cannot call non-const method `Wrap::<&mut [u8; 2], &mut [u8; 2]>::transmute_mut` in constants
//~[nightly]^^^^^^^ ERROR: cannot call non-const method `zerocopy::util::macro_util::Wrap::<&mut [u8; 2], &mut [u8; 2]>::transmute_mut_inference_helper` in constants
//~[nightly]^^^^^^^^ ERROR: cannot call non-const method `zerocopy::util::macro_util::Wrap::<&mut [u8; 2], &mut [u8; 2]>::transmute_mut` in constants
// Should fail because the file is 4 bytes long, not 8.
const INCLUDE_VALUE_WRONG_SIZE: u64 = zerocopy::include_value!("../../testdata/include_value/data");
//~[msrv, stable, nightly]^ ERROR: cannot transmute between types of different sizes, or dependently-sized types
//~[stable, nightly]^^ ERROR: transmuting from 4-byte type to 8-byte type: `[u8; 4]` -> `u64`
fn main() {
// Although this is not a soundness requirement, we currently require that
// the size of the destination type is not smaller than the size of the
// source type.
let _decrease_size: Result<u8, _> = try_transmute!(AU16(0));
//~[msrv, stable, nightly]^ ERROR: cannot transmute between types of different sizes, or dependently-sized types
// `try_transmute!` does not support transmuting from a smaller type to a larger
// one.
let _increase_size: Result<AU16, _> = try_transmute!(0u8);
//~[msrv, stable, nightly]^ ERROR: cannot transmute between types of different sizes, or dependently-sized types
fn _transmute_mut_increase_lifetime() {
let mut x = 0u64;
// It is illegal to increase the lifetime scope.
let _: &'static mut u64 = zerocopy::transmute_mut!(&mut x);
//~[msrv, stable, nightly]^ ERROR: `x` does not live long enough
}
fn _transmute_ref_increase_lifetime() {
let x = 0u64;
// It is illegal to increase the lifetime scope.
let _: &'static u64 = zerocopy::transmute_ref!(&x);
//~[msrv, stable, nightly]^ ERROR: `x` does not live long enough
}
}

View File

@@ -0,0 +1,157 @@
error[E0080]: transmuting from 2-byte type to 1-byte type: `AU16` -> `u8`
--> $DIR/late-compile-pass.rs:20:37
|
20 | const TRANSMUTE_DECREASE_SIZE: u8 = transmute!(AU16(0));
| ^^^^^^^^^^^^^^^^^^^ evaluation of `TRANSMUTE_DECREASE_SIZE` failed here
|
= note: this error originates in the macro `transmute` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0080]: transmuting from 1-byte type to 2-byte type: `u8` -> `AU16`
--> $DIR/late-compile-pass.rs:26:39
|
26 | const TRANSMUTE_INCREASE_SIZE: AU16 = transmute!(0u8);
| ^^^^^^^^^^^^^^^ evaluation of `TRANSMUTE_INCREASE_SIZE` failed here
|
= note: this error originates in the macro `transmute` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0080]: transmuting from 1-byte type to 2-byte type: `u8` -> `Transmute<u8, AU16>`
--> $DIR/late-compile-pass.rs:32:52
|
32 | const TRANSMUTE_INCREASE_SIZE_ALLOW_SHRINK: AU16 = transmute!(#![allow(shrink)] 0u8);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `TRANSMUTE_INCREASE_SIZE_ALLOW_SHRINK` failed here
|
= note: this error originates in the macro `transmute` (in Nightly builds, run with -Z macro-backtrace for more info)
warning: taking a mutable reference to a `const` item
--> $DIR/late-compile-pass.rs:39:66
|
39 | const TRANSMUTE_MUT_CONST_CONTEXT: &mut [u8; 2] = transmute_mut!(&mut ARRAY_OF_U8S);
| ^^^^^^^^^^^^^^^^^
|
= note: each usage of a `const` item creates a new temporary
= note: the mutable reference will refer to this temporary, not the original `const` item
note: `const` item defined here
--> $DIR/late-compile-pass.rs:36:1
|
36 | const ARRAY_OF_U8S: [u8; 2] = [0u8; 2];
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: `#[warn(const_item_mutation)]` on by default
error[E0015]: cannot call non-const method `Wrap::<&mut [u8; 2], &mut [u8; 2]>::transmute_mut_inference_helper` in constants
--> $DIR/late-compile-pass.rs:39:51
|
39 | const TRANSMUTE_MUT_CONST_CONTEXT: &mut [u8; 2] = transmute_mut!(&mut ARRAY_OF_U8S);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: calls in constants are limited to constant functions, tuple structs and tuple variants
= note: this error originates in the macro `transmute_mut` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0015]: cannot call non-const method `Wrap::<&mut [u8; 2], &mut [u8; 2]>::transmute_mut` in constants
--> $DIR/late-compile-pass.rs:39:51
|
39 | const TRANSMUTE_MUT_CONST_CONTEXT: &mut [u8; 2] = transmute_mut!(&mut ARRAY_OF_U8S);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: calls in constants are limited to constant functions, tuple structs and tuple variants
= note: this error originates in the macro `transmute_mut` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0080]: transmuting from 4-byte type to 8-byte type: `[u8; 4]` -> `u64`
--> $DIR/late-compile-pass.rs:50:39
|
50 | const INCLUDE_VALUE_WRONG_SIZE: u64 = zerocopy::include_value!("../../testdata/include_value/data");
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `INCLUDE_VALUE_WRONG_SIZE` failed here
|
= note: this error originates in the macro `$crate::transmute` which comes from the expansion of the macro `zerocopy::include_value` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0512]: cannot transmute between types of different sizes, or dependently-sized types
--> $DIR/late-compile-pass.rs:20:37
|
20 | const TRANSMUTE_DECREASE_SIZE: u8 = transmute!(AU16(0));
| ^^^^^^^^^^^^^^^^^^^
|
= note: source type: `AU16` (16 bits)
= note: target type: `u8` (8 bits)
= note: this error originates in the macro `transmute` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0512]: cannot transmute between types of different sizes, or dependently-sized types
--> $DIR/late-compile-pass.rs:26:39
|
26 | const TRANSMUTE_INCREASE_SIZE: AU16 = transmute!(0u8);
| ^^^^^^^^^^^^^^^
|
= note: source type: `u8` (8 bits)
= note: target type: `AU16` (16 bits)
= note: this error originates in the macro `transmute` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0512]: cannot transmute between types of different sizes, or dependently-sized types
--> $DIR/late-compile-pass.rs:32:52
|
32 | const TRANSMUTE_INCREASE_SIZE_ALLOW_SHRINK: AU16 = transmute!(#![allow(shrink)] 0u8);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: source type: `u8` (8 bits)
= note: target type: `Transmute<u8, AU16>` (16 bits)
= note: this error originates in the macro `transmute` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0512]: cannot transmute between types of different sizes, or dependently-sized types
--> $DIR/late-compile-pass.rs:50:39
|
50 | const INCLUDE_VALUE_WRONG_SIZE: u64 = zerocopy::include_value!("../../testdata/include_value/data");
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: source type: `[u8; 4]` (32 bits)
= note: target type: `u64` (64 bits)
= note: this error originates in the macro `$crate::transmute` which comes from the expansion of the macro `zerocopy::include_value` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0512]: cannot transmute between types of different sizes, or dependently-sized types
--> $DIR/late-compile-pass.rs:58:41
|
58 | let _decrease_size: Result<u8, _> = try_transmute!(AU16(0));
| ^^^^^^^^^^^^^^^^^^^^^^^
|
= note: source type: `AU16` (16 bits)
= note: target type: `u8` (8 bits)
= note: this error originates in the macro `try_transmute` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0512]: cannot transmute between types of different sizes, or dependently-sized types
--> $DIR/late-compile-pass.rs:63:43
|
63 | let _increase_size: Result<AU16, _> = try_transmute!(0u8);
| ^^^^^^^^^^^^^^^^^^^
|
= note: source type: `u8` (8 bits)
= note: target type: `AU16` (16 bits)
= note: this error originates in the macro `try_transmute` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0597]: `x` does not live long enough
--> $DIR/late-compile-pass.rs:69:60
|
67 | let mut x = 0u64;
| ----- binding `x` declared here
68 | // It is illegal to increase the lifetime scope.
69 | let _: &'static mut u64 = zerocopy::transmute_mut!(&mut x);
| ---------------- ^^^^^^ borrowed value does not live long enough
| |
| type annotation requires that `x` is borrowed for `'static`
70 |
71 | }
| - `x` dropped here while still borrowed
error[E0597]: `x` does not live long enough
--> $DIR/late-compile-pass.rs:76:56
|
74 | let x = 0u64;
| - binding `x` declared here
75 | // It is illegal to increase the lifetime scope.
76 | let _: &'static u64 = zerocopy::transmute_ref!(&x);
| ------------ ^^ borrowed value does not live long enough
| |
| type annotation requires that `x` is borrowed for `'static`
77 |
78 | }
| - `x` dropped here while still borrowed
error: aborting due to 14 previous errors; 1 warning emitted
Some errors have detailed explanations: E0015, E0080, E0512, E0597.
For more information about an error, try `rustc --explain E0015`.

View File

@@ -0,0 +1,9 @@
error[E0589]: invalid `repr(align)` attribute: larger than 2^29
--> $DIR/max-align.rs:98:11
|
98 | #[repr(C, align(1073741824))]
| ^^^^^^^^^^^^^^^^^
error: aborting due to previous error
For more information about this error, try `rustc --explain E0589`.

View File

@@ -0,0 +1,9 @@
error[E0589]: invalid `repr(align)` attribute: larger than 2^29
--> $DIR/max-align.rs:98:17
|
98 | #[repr(C, align(1073741824))]
| ^^^^^^^^^^
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0589`.

102
vendor/zerocopy/tests/ui/max-align.rs vendored Normal file
View File

@@ -0,0 +1,102 @@
// Copyright 2023 The Fuchsia Authors
//
// Licensed under a BSD-style license <LICENSE-BSD>, Apache License, Version 2.0
// <LICENSE-APACHE or https://www.apache.org/licenses/LICENSE-2.0>, or the MIT
// license <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your option.
// This file may not be copied, modified, or distributed except according to
// those terms.
include!("../include.rs");
#[repr(C, align(1))]
struct Align1;
#[repr(C, align(2))]
struct Align2;
#[repr(C, align(4))]
struct Align4;
#[repr(C, align(8))]
struct Align8;
#[repr(C, align(16))]
struct Align16;
#[repr(C, align(32))]
struct Align32;
#[repr(C, align(64))]
struct Align64;
#[repr(C, align(128))]
struct Align128;
#[repr(C, align(256))]
struct Align256;
#[repr(C, align(512))]
struct Align512;
#[repr(C, align(1024))]
struct Align1024;
#[repr(C, align(2048))]
struct Align2048;
#[repr(C, align(4096))]
struct Align4096;
#[repr(C, align(8192))]
struct Align8192;
#[repr(C, align(16384))]
struct Align16384;
#[repr(C, align(32768))]
struct Align32768;
#[repr(C, align(65536))]
struct Align65536;
#[repr(C, align(131072))]
struct Align131072;
#[repr(C, align(262144))]
struct Align262144;
#[repr(C, align(524288))]
struct Align524288;
#[repr(C, align(1048576))]
struct Align1048576;
#[repr(C, align(2097152))]
struct Align2097152;
#[repr(C, align(4194304))]
struct Align4194304;
#[repr(C, align(8388608))]
struct Align8388608;
#[repr(C, align(16777216))]
struct Align16777216;
#[repr(C, align(33554432))]
struct Align33554432;
#[repr(C, align(67108864))]
struct Align67108864;
#[repr(C, align(134217728))]
struct Align13421772;
#[repr(C, align(268435456))]
struct Align26843545;
#[repr(C, align(1073741824))]
//~[msrv, stable, nightly]^ ERROR: invalid `repr(align)` attribute: larger than 2^29
struct Align1073741824;
fn main() {}

View File

@@ -0,0 +1,9 @@
error[E0589]: invalid `repr(align)` attribute: larger than 2^29
--> $DIR/max-align.rs:98:17
|
98 | #[repr(C, align(1073741824))]
| ^^^^^^^^^^
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0589`.

View File

@@ -0,0 +1,21 @@
error[E0623]: lifetime mismatch
--> $DIR/ptr-is-invariant-over-v.rs:21:14
|
18 | big: Ptr<'small, &'big u32, (Exclusive, Aligned, Valid)>,
| --------------------------------------------------- these two types are declared with different lifetimes...
...
21 | _small = big;
| ^^^ ...but data from `big` flows into `big` here
error[E0623]: lifetime mismatch
--> $DIR/ptr-is-invariant-over-v.rs:30:14
|
27 | big: Ptr<'small, &'big u32, (Shared, Aligned, Valid)>,
| ------------------------------------------------ these two types are declared with different lifetimes...
...
30 | _small = big;
| ^^^ ...but data from `big` flows into `big` here
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0623`.

View File

@@ -0,0 +1,34 @@
error: lifetime may not live long enough
--> $DIR/ptr-is-invariant-over-v.rs:21:5
|
17 | fn _when_exclusive<'big: 'small, 'small>(
| ---- ------ lifetime `'small` defined here
| |
| lifetime `'big` defined here
...
21 | _small = big;
| ^^^^^^^^^^^^ assignment requires that `'small` must outlive `'big`
|
= help: consider adding the following bound: `'small: 'big`
= note: requirement occurs because of the type `Ptr<'_, &u32, (zerocopy::invariant::Exclusive, zerocopy::invariant::Aligned, zerocopy::invariant::Valid)>`, which makes the generic argument `&u32` invariant
= note: the struct `Ptr<'a, T, I>` is invariant over the parameter `T`
= help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance
error: lifetime may not live long enough
--> $DIR/ptr-is-invariant-over-v.rs:30:5
|
26 | fn _when_shared<'big: 'small, 'small>(
| ---- ------ lifetime `'small` defined here
| |
| lifetime `'big` defined here
...
30 | _small = big;
| ^^^^^^^^^^^^ assignment requires that `'small` must outlive `'big`
|
= help: consider adding the following bound: `'small: 'big`
= note: requirement occurs because of the type `Ptr<'_, &u32, (zerocopy::invariant::Shared, zerocopy::invariant::Aligned, zerocopy::invariant::Valid)>`, which makes the generic argument `&u32` invariant
= note: the struct `Ptr<'a, T, I>` is invariant over the parameter `T`
= help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance
error: aborting due to 2 previous errors

View File

@@ -0,0 +1,35 @@
// Copyright 2025 The Fuchsia Authors
//
// Licensed under the 2-Clause BSD License <LICENSE-BSD or
// https://opensource.org/license/bsd-2-clause>, Apache License, Version 2.0
// <LICENSE-APACHE or https://www.apache.org/licenses/LICENSE-2.0>, or the MIT
// license <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your option.
// This file may not be copied, modified, or distributed except according to
// those terms.
include!("../include.rs");
use zerocopy::pointer::{
invariant::{Aligned, Exclusive, Shared, Valid},
Ptr,
};
fn _when_exclusive<'big: 'small, 'small>(
big: Ptr<'small, &'big u32, (Exclusive, Aligned, Valid)>,
mut _small: Ptr<'small, &'small u32, (Exclusive, Aligned, Valid)>,
) {
_small = big;
//~[msrv]^ ERROR: lifetime mismatch
//~[stable, nightly]^^ ERROR: lifetime may not live long enough
}
fn _when_shared<'big: 'small, 'small>(
big: Ptr<'small, &'big u32, (Shared, Aligned, Valid)>,
mut _small: Ptr<'small, &'small u32, (Shared, Aligned, Valid)>,
) {
_small = big;
//~[msrv]^ ERROR: lifetime mismatch
//~[stable, nightly]^^ ERROR: lifetime may not live long enough
}
fn main() {}

View File

@@ -0,0 +1,34 @@
error: lifetime may not live long enough
--> $DIR/ptr-is-invariant-over-v.rs:21:5
|
17 | fn _when_exclusive<'big: 'small, 'small>(
| ---- ------ lifetime `'small` defined here
| |
| lifetime `'big` defined here
...
21 | _small = big;
| ^^^^^^^^^^^^ assignment requires that `'small` must outlive `'big`
|
= help: consider adding the following bound: `'small: 'big`
= note: requirement occurs because of the type `Ptr<'_, &u32, (zerocopy::invariant::Exclusive, Aligned, zerocopy::invariant::Valid)>`, which makes the generic argument `&u32` invariant
= note: the struct `Ptr<'a, T, I>` is invariant over the parameter `T`
= help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance
error: lifetime may not live long enough
--> $DIR/ptr-is-invariant-over-v.rs:30:5
|
26 | fn _when_shared<'big: 'small, 'small>(
| ---- ------ lifetime `'small` defined here
| |
| lifetime `'big` defined here
...
30 | _small = big;
| ^^^^^^^^^^^^ assignment requires that `'small` must outlive `'big`
|
= help: consider adding the following bound: `'small: 'big`
= note: requirement occurs because of the type `Ptr<'_, &u32, (Shared, Aligned, zerocopy::invariant::Valid)>`, which makes the generic argument `&u32` invariant
= note: the struct `Ptr<'a, T, I>` is invariant over the parameter `T`
= help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance
error: aborting due to 2 previous errors

View File

@@ -0,0 +1,19 @@
error[E0277]: the trait bound `*const usize: IntoBytes` is not satisfied
--> $DIR/transmute-ptr-to-usize.rs:21:30
|
21 | const POINTER_VALUE: usize = transmute!(&0usize as *const usize);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `IntoBytes` is not implemented for `*const usize`
|
note: required by a bound in `POINTER_VALUE::transmute`
--> $DIR/transmute-ptr-to-usize.rs:21:30
|
21 | const POINTER_VALUE: usize = transmute!(&0usize as *const usize);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
| required by a bound in this
| required by this bound in `POINTER_VALUE::transmute`
= note: this error originates in the macro `transmute` (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to previous error
For more information about this error, try `rustc --explain E0277`.

View File

@@ -0,0 +1,33 @@
error[E0277]: the trait bound `*const usize: IntoBytes` is not satisfied
--> $DIR/transmute-ptr-to-usize.rs:21:30
|
21 | const POINTER_VALUE: usize = transmute!(&0usize as *const usize);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
| the trait `IntoBytes` is not implemented for `*const usize`
| required by a bound introduced by this call
|
= note: Consider adding `#[derive(IntoBytes)]` to `*const usize`
help: the trait `IntoBytes` is implemented for `usize`
--> src/util/macros.rs:29:9
|
29 | unsafe impl $trait for $ty {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
::: src/impls.rs:77:5
|
77 | unsafe_impl!(usize: Immutable, TryFromBytes, FromZeros, FromBytes, IntoBytes);
| ----------------------------------------------------------------------------- in this macro invocation
note: required by a bound in `POINTER_VALUE::transmute`
--> $DIR/transmute-ptr-to-usize.rs:21:30
|
21 | const POINTER_VALUE: usize = transmute!(&0usize as *const usize);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
| required by a bound in this function
| required by this bound in `transmute`
= note: this error originates in the macro `transmute` (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0277`.

View File

@@ -0,0 +1,22 @@
// Copyright 2022 The Fuchsia Authors
//
// Licensed under a BSD-style license <LICENSE-BSD>, Apache License, Version 2.0
// <LICENSE-APACHE or https://www.apache.org/licenses/LICENSE-2.0>, or the MIT
// license <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your option.
// This file may not be copied, modified, or distributed except according to
// those terms.
include!("../include.rs");
use zerocopy::transmute;
fn main() {}
// It is unclear whether we can or should support this transmutation, especially
// in a const context. This test ensures that even if such a transmutation
// becomes valid due to the requisite implementations of `FromBytes` being
// added, that we re-examine whether it should specifically be valid in a const
// context.
const POINTER_VALUE: usize = transmute!(&0usize as *const usize);
//~[msrv, stable, nightly]^ ERROR: the trait bound `*const usize: IntoBytes` is not satisfied

View File

@@ -0,0 +1,28 @@
error[E0277]: the trait bound `*const usize: IntoBytes` is not satisfied
--> $DIR/transmute-ptr-to-usize.rs:21:30
|
21 | const POINTER_VALUE: usize = transmute!(&0usize as *const usize);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
| the trait `IntoBytes` is not implemented for `*const usize`
| required by a bound introduced by this call
|
= note: Consider adding `#[derive(IntoBytes)]` to `*const usize`
help: the trait `IntoBytes` is implemented for `usize`
--> $WORKSPACE/src/impls.rs:77:5
|
77 | unsafe_impl!(usize: Immutable, TryFromBytes, FromZeros, FromBytes, IntoBytes);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: required by a bound in `POINTER_VALUE::transmute`
--> $DIR/transmute-ptr-to-usize.rs:21:30
|
21 | const POINTER_VALUE: usize = transmute!(&0usize as *const usize);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
| required by a bound in this function
| required by this bound in `transmute`
= note: this error originates in the macro `transmute` (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0277`.

View File

@@ -0,0 +1,35 @@
error[E0277]: the trait bound `NotZerocopy: FromBytes` is not satisfied
--> $DIR/transmute.rs:17:41
|
17 | const DST_NOT_FROM_BYTES: NotZerocopy = transmute!(AU16(0));
| ^^^^^^^^^^^^^^^^^^^ the trait `FromBytes` is not implemented for `NotZerocopy`
|
note: required by a bound in `DST_NOT_FROM_BYTES::transmute`
--> $DIR/transmute.rs:17:41
|
17 | const DST_NOT_FROM_BYTES: NotZerocopy = transmute!(AU16(0));
| ^^^^^^^^^^^^^^^^^^^
| |
| required by a bound in this
| required by this bound in `DST_NOT_FROM_BYTES::transmute`
= note: this error originates in the macro `transmute` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0277]: the trait bound `NotZerocopy<AU16>: IntoBytes` is not satisfied
--> $DIR/transmute.rs:21:32
|
21 | const SRC_NOT_AS_BYTES: AU16 = transmute!(NotZerocopy(AU16(0)));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `IntoBytes` is not implemented for `NotZerocopy<AU16>`
|
note: required by a bound in `SRC_NOT_AS_BYTES::transmute`
--> $DIR/transmute.rs:21:32
|
21 | const SRC_NOT_AS_BYTES: AU16 = transmute!(NotZerocopy(AU16(0)));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
| required by a bound in this
| required by this bound in `SRC_NOT_AS_BYTES::transmute`
= note: this error originates in the macro `transmute` (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0277`.

View File

@@ -0,0 +1,70 @@
error[E0277]: the trait bound `NotZerocopy: FromBytes` is not satisfied
--> $DIR/transmute.rs:17:41
|
17 | const DST_NOT_FROM_BYTES: NotZerocopy = transmute!(AU16(0));
| ^^^^^^^^^^^^^^^^^^^ unsatisfied trait bound
|
help: the trait `FromBytes` is not implemented for `NotZerocopy`
--> $DIR/../include.rs:15:5
|
15 | pub struct NotZerocopy<T = ()>(pub T);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: Consider adding `#[derive(FromBytes)]` to `NotZerocopy`
= help: the following other types implement trait `FromBytes`:
()
(A, B)
(A, B, C)
(A, B, C, D)
(A, B, C, D, E)
(A, B, C, D, E, F)
(A, B, C, D, E, F, G)
(A, B, C, D, E, F, G, H)
and 79 others
note: required by a bound in `DST_NOT_FROM_BYTES::transmute`
--> $DIR/transmute.rs:17:41
|
17 | const DST_NOT_FROM_BYTES: NotZerocopy = transmute!(AU16(0));
| ^^^^^^^^^^^^^^^^^^^
| |
| required by a bound in this function
| required by this bound in `transmute`
= note: this error originates in the macro `transmute` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0277]: the trait bound `NotZerocopy<AU16>: IntoBytes` is not satisfied
--> $DIR/transmute.rs:21:32
|
21 | const SRC_NOT_AS_BYTES: AU16 = transmute!(NotZerocopy(AU16(0)));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
| unsatisfied trait bound
| required by a bound introduced by this call
|
help: the trait `IntoBytes` is not implemented for `NotZerocopy<AU16>`
--> $DIR/../include.rs:15:5
|
15 | pub struct NotZerocopy<T = ()>(pub T);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: Consider adding `#[derive(IntoBytes)]` to `NotZerocopy<AU16>`
= help: the following other types implement trait `IntoBytes`:
()
AU16
AtomicBool
AtomicI16
AtomicI32
AtomicI64
AtomicI8
AtomicIsize
and 68 others
note: required by a bound in `SRC_NOT_AS_BYTES::transmute`
--> $DIR/transmute.rs:21:32
|
21 | const SRC_NOT_AS_BYTES: AU16 = transmute!(NotZerocopy(AU16(0)));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
| required by a bound in this function
| required by this bound in `transmute`
= note: this error originates in the macro `transmute` (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0277`.

22
vendor/zerocopy/tests/ui/transmute.rs vendored Normal file
View File

@@ -0,0 +1,22 @@
// Copyright 2022 The Fuchsia Authors
//
// Licensed under a BSD-style license <LICENSE-BSD>, Apache License, Version 2.0
// <LICENSE-APACHE or https://www.apache.org/licenses/LICENSE-2.0>, or the MIT
// license <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your option.
// This file may not be copied, modified, or distributed except according to
// those terms.
include!("../include.rs");
use util::{NotZerocopy, AU16};
use zerocopy::transmute;
fn main() {}
// `transmute` requires that the destination type implements `FromBytes`
const DST_NOT_FROM_BYTES: NotZerocopy = transmute!(AU16(0));
//~[msrv, stable, nightly]^ ERROR: the trait bound `NotZerocopy: FromBytes` is not satisfied
// `transmute` requires that the source type implements `IntoBytes`
const SRC_NOT_AS_BYTES: AU16 = transmute!(NotZerocopy(AU16(0)));
//~[msrv, stable, nightly]^ ERROR: the trait bound `NotZerocopy<AU16>: IntoBytes` is not satisfied

View File

@@ -0,0 +1,70 @@
error[E0277]: the trait bound `NotZerocopy: FromBytes` is not satisfied
--> $DIR/transmute.rs:17:41
|
17 | const DST_NOT_FROM_BYTES: NotZerocopy = transmute!(AU16(0));
| ^^^^^^^^^^^^^^^^^^^ unsatisfied trait bound
|
help: the trait `FromBytes` is not implemented for `NotZerocopy`
--> $DIR/../include.rs:15:5
|
15 | pub struct NotZerocopy<T = ()>(pub T);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: Consider adding `#[derive(FromBytes)]` to `NotZerocopy`
= help: the following other types implement trait `FromBytes`:
()
(A, B)
(A, B, C)
(A, B, C, D)
(A, B, C, D, E)
(A, B, C, D, E, F)
(A, B, C, D, E, F, G)
(A, B, C, D, E, F, G, H)
and 79 others
note: required by a bound in `DST_NOT_FROM_BYTES::transmute`
--> $DIR/transmute.rs:17:41
|
17 | const DST_NOT_FROM_BYTES: NotZerocopy = transmute!(AU16(0));
| ^^^^^^^^^^^^^^^^^^^
| |
| required by a bound in this function
| required by this bound in `transmute`
= note: this error originates in the macro `transmute` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0277]: the trait bound `NotZerocopy<AU16>: IntoBytes` is not satisfied
--> $DIR/transmute.rs:21:32
|
21 | const SRC_NOT_AS_BYTES: AU16 = transmute!(NotZerocopy(AU16(0)));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
| unsatisfied trait bound
| required by a bound introduced by this call
|
help: the trait `IntoBytes` is not implemented for `NotZerocopy<AU16>`
--> $DIR/../include.rs:15:5
|
15 | pub struct NotZerocopy<T = ()>(pub T);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: Consider adding `#[derive(IntoBytes)]` to `NotZerocopy<AU16>`
= help: the following other types implement trait `IntoBytes`:
()
AU16
AtomicBool
AtomicI16
AtomicI32
AtomicI64
AtomicI8
AtomicIsize
and 68 others
note: required by a bound in `SRC_NOT_AS_BYTES::transmute`
--> $DIR/transmute.rs:21:32
|
21 | const SRC_NOT_AS_BYTES: AU16 = transmute!(NotZerocopy(AU16(0)));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
| required by a bound in this function
| required by this bound in `transmute`
= note: this error originates in the macro `transmute` (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0277`.

View File

@@ -0,0 +1,111 @@
error[E0308]: mismatched types
--> $DIR/transmute_mut.rs:17:36
|
17 | const DST_NOT_A_REFERENCE: usize = transmute_mut!(&mut 0u8);
| ^^^^^^^^^^^^^^^^^^^^^^^^ expected `usize`, found `&mut _`
|
= note: expected type `usize`
found mutable reference `&mut _`
= note: this error originates in the macro `transmute_mut` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0308]: mismatched types
--> $DIR/transmute_mut.rs:17:36
|
17 | const DST_NOT_A_REFERENCE: usize = transmute_mut!(&mut 0u8);
| ^^^^^^^^^^^^^^^^^^^^^^^^ expected `usize`, found `&mut _`
|
= note: expected type `usize`
found mutable reference `&mut _`
= note: this error originates in the macro `transmute_mut` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0277]: the trait bound `DstA: FromBytes` is not satisfied
--> $DIR/transmute_mut.rs:30:39
|
30 | const DST_NOT_FROM_BYTES: &mut DstA = transmute_mut!(&mut SrcA);
| ^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `FromBytes` is not implemented for `DstA`
|
= note: this error originates in the macro `transmute_mut` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0277]: the trait bound `DstB: IntoBytes` is not satisfied
--> $DIR/transmute_mut.rs:42:37
|
42 | const DST_NOT_AS_BYTES: &mut DstB = transmute_mut!(&mut SrcB);
| ^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `IntoBytes` is not implemented for `DstB`
|
= note: this error originates in the macro `transmute_mut` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0308]: mismatched types
--> $DIR/transmute_mut.rs:47:59
|
47 | const SRC_DST_NOT_REFERENCES: &mut usize = transmute_mut!(0usize);
| ---------------^^^^^^-
| | |
| | expected `&mut _`, found `usize`
| | help: consider mutably borrowing here: `&mut 0usize`
| expected due to this
|
= note: expected mutable reference `&mut _`
found type `usize`
error[E0308]: mismatched types
--> $DIR/transmute_mut.rs:58:53
|
58 | const SRC_NOT_A_REFERENCE: &mut u8 = transmute_mut!(0usize);
| ---------------^^^^^^-
| | |
| | expected `&mut _`, found `usize`
| | help: consider mutably borrowing here: `&mut 0usize`
| expected due to this
|
= note: expected mutable reference `&mut _`
found type `usize`
error[E0277]: the trait bound `SrcC: FromBytes` is not satisfied
--> $DIR/transmute_mut.rs:70:39
|
70 | const SRC_NOT_FROM_BYTES: &mut DstC = transmute_mut!(&mut SrcC);
| ^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `FromBytes` is not implemented for `SrcC`
|
= note: this error originates in the macro `transmute_mut` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0277]: the trait bound `SrcD: IntoBytes` is not satisfied
--> $DIR/transmute_mut.rs:82:37
|
82 | const SRC_NOT_AS_BYTES: &mut DstD = transmute_mut!(&mut SrcD);
| ^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `IntoBytes` is not implemented for `SrcD`
|
= note: this error originates in the macro `transmute_mut` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0599]: the method `transmute_mut` exists for struct `Wrap<&mut [u8], &mut [u8; 1]>`, but its trait bounds were not satisfied
--> $DIR/transmute_mut.rs:87:35
|
87 | const SRC_UNSIZED: &mut [u8; 1] = transmute_mut!(&mut [0u8][..]);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ method cannot be called on `Wrap<&mut [u8], &mut [u8; 1]>` due to unsatisfied trait bounds
|
::: $WORKSPACE/src/util/macro_util.rs:692:1
|
692 | pub struct Wrap<Src, Dst>(pub Src, pub PhantomData<Dst>);
| --------------------------------------------------------- doesn't satisfy `Wrap<&mut [u8], &mut [u8; 1]>: TransmuteMutDst`
|
= note: the following trait bounds were not satisfied:
`[u8]: Sized`
`<[u8; 1] as KnownLayout>::PointerMetadata = usize`
which is required by `Wrap<&mut [u8], &mut [u8; 1]>: TransmuteMutDst`
= note: this error originates in the macro `transmute_mut` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0308]: mismatched types
--> $DIR/transmute_mut.rs:52:37
|
52 | let _: &mut u8 = transmute_mut!(&0u8);
| ---------------^^^^-
| | |
| | types differ in mutability
| expected due to this
|
= note: expected mutable reference `&mut _`
found reference `&u8`
error: aborting due to 10 previous errors
Some errors have detailed explanations: E0277, E0308, E0599.
For more information about an error, try `rustc --explain E0277`.

View File

@@ -0,0 +1,213 @@
error[E0308]: mismatched types
--> $DIR/transmute_mut.rs:17:36
|
17 | const DST_NOT_A_REFERENCE: usize = transmute_mut!(&mut 0u8);
| ^^^^^^^^^^^^^^^^^^^^^^^^ expected `usize`, found `&mut _`
|
= note: expected type `usize`
found mutable reference `&mut _`
= note: this error originates in the macro `transmute_mut` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0308]: mismatched types
--> $DIR/transmute_mut.rs:17:36
|
17 | const DST_NOT_A_REFERENCE: usize = transmute_mut!(&mut 0u8);
| ^^^^^^^^^^^^^^^^^^^^^^^^ expected `usize`, found `&mut _`
|
= note: expected type `usize`
found mutable reference `&mut _`
= note: this error originates in the macro `transmute_mut` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0277]: the trait bound `DstA: FromBytes` is not satisfied
--> $DIR/transmute_mut.rs:30:39
|
30 | const DST_NOT_FROM_BYTES: &mut DstA = transmute_mut!(&mut SrcA);
| ^^^^^^^^^^^^^^^^^^^^^^^^^ unsatisfied trait bound
|
help: the trait `FromBytes` is not implemented for `DstA`
--> $DIR/transmute_mut.rs:27:1
|
27 | struct DstA;
| ^^^^^^^^^^^
= note: Consider adding `#[derive(FromBytes)]` to `DstA`
= help: the following other types implement trait `FromBytes`:
()
(A, B)
(A, B, C)
(A, B, C, D)
(A, B, C, D, E)
(A, B, C, D, E, F)
(A, B, C, D, E, F, G)
(A, B, C, D, E, F, G, H)
and 85 others
note: required by a bound in `zerocopy::util::macro_util::Wrap::<&'a mut Src, &'a mut Dst>::transmute_mut`
--> src/util/macro_util.rs:806:14
|
803 | pub fn transmute_mut(self) -> &'a mut Dst
| ------------- required by a bound in this associated function
...
806 | Dst: FromBytes + IntoBytes,
| ^^^^^^^^^ required by this bound in `Wrap::<&mut Src, &mut Dst>::transmute_mut`
= note: this error originates in the macro `transmute_mut` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0277]: the trait bound `DstB: IntoBytes` is not satisfied
--> $DIR/transmute_mut.rs:42:37
|
42 | const DST_NOT_AS_BYTES: &mut DstB = transmute_mut!(&mut SrcB);
| ^^^^^^^^^^^^^^^^^^^^^^^^^ unsatisfied trait bound
|
help: the trait `IntoBytes` is not implemented for `DstB`
--> $DIR/transmute_mut.rs:39:1
|
39 | struct DstB;
| ^^^^^^^^^^^
= note: Consider adding `#[derive(IntoBytes)]` to `DstB`
= help: the following other types implement trait `IntoBytes`:
()
AU16
AtomicBool
AtomicI16
AtomicI32
AtomicI64
AtomicI8
AtomicIsize
and 74 others
note: required by a bound in `zerocopy::util::macro_util::Wrap::<&'a mut Src, &'a mut Dst>::transmute_mut`
--> src/util/macro_util.rs:806:26
|
803 | pub fn transmute_mut(self) -> &'a mut Dst
| ------------- required by a bound in this associated function
...
806 | Dst: FromBytes + IntoBytes,
| ^^^^^^^^^ required by this bound in `Wrap::<&mut Src, &mut Dst>::transmute_mut`
= note: this error originates in the macro `transmute_mut` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0308]: mismatched types
--> $DIR/transmute_mut.rs:47:59
|
47 | const SRC_DST_NOT_REFERENCES: &mut usize = transmute_mut!(0usize);
| ---------------^^^^^^-
| | |
| | expected `&mut _`, found `usize`
| expected due to this
|
= note: expected mutable reference `&mut _`
found type `usize`
help: consider mutably borrowing here
|
47 | const SRC_DST_NOT_REFERENCES: &mut usize = transmute_mut!(&mut 0usize);
| ++++
error[E0308]: mismatched types
--> $DIR/transmute_mut.rs:52:37
|
52 | let _: &mut u8 = transmute_mut!(&0u8);
| ---------------^^^^-
| | |
| | types differ in mutability
| expected due to this
|
= note: expected mutable reference `&mut _`
found reference `&u8`
error[E0308]: mismatched types
--> $DIR/transmute_mut.rs:58:53
|
58 | const SRC_NOT_A_REFERENCE: &mut u8 = transmute_mut!(0usize);
| ---------------^^^^^^-
| | |
| | expected `&mut _`, found `usize`
| expected due to this
|
= note: expected mutable reference `&mut _`
found type `usize`
help: consider mutably borrowing here
|
58 | const SRC_NOT_A_REFERENCE: &mut u8 = transmute_mut!(&mut 0usize);
| ++++
error[E0277]: the trait bound `SrcC: FromBytes` is not satisfied
--> $DIR/transmute_mut.rs:70:39
|
70 | const SRC_NOT_FROM_BYTES: &mut DstC = transmute_mut!(&mut SrcC);
| ^^^^^^^^^^^^^^^^^^^^^^^^^ unsatisfied trait bound
|
help: the trait `FromBytes` is not implemented for `SrcC`
--> $DIR/transmute_mut.rs:63:1
|
63 | struct SrcC;
| ^^^^^^^^^^^
= note: Consider adding `#[derive(FromBytes)]` to `SrcC`
= help: the following other types implement trait `FromBytes`:
()
(A, B)
(A, B, C)
(A, B, C, D)
(A, B, C, D, E)
(A, B, C, D, E, F)
(A, B, C, D, E, F, G)
(A, B, C, D, E, F, G, H)
and 85 others
note: required by a bound in `zerocopy::util::macro_util::Wrap::<&'a mut Src, &'a mut Dst>::transmute_mut`
--> src/util/macro_util.rs:805:14
|
803 | pub fn transmute_mut(self) -> &'a mut Dst
| ------------- required by a bound in this associated function
804 | where
805 | Src: FromBytes + IntoBytes,
| ^^^^^^^^^ required by this bound in `Wrap::<&mut Src, &mut Dst>::transmute_mut`
= note: this error originates in the macro `transmute_mut` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0277]: the trait bound `SrcD: IntoBytes` is not satisfied
--> $DIR/transmute_mut.rs:82:37
|
82 | const SRC_NOT_AS_BYTES: &mut DstD = transmute_mut!(&mut SrcD);
| ^^^^^^^^^^^^^^^^^^^^^^^^^ unsatisfied trait bound
|
help: the trait `IntoBytes` is not implemented for `SrcD`
--> $DIR/transmute_mut.rs:75:1
|
75 | struct SrcD;
| ^^^^^^^^^^^
= note: Consider adding `#[derive(IntoBytes)]` to `SrcD`
= help: the following other types implement trait `IntoBytes`:
()
AU16
AtomicBool
AtomicI16
AtomicI32
AtomicI64
AtomicI8
AtomicIsize
and 74 others
note: required by a bound in `zerocopy::util::macro_util::Wrap::<&'a mut Src, &'a mut Dst>::transmute_mut`
--> src/util/macro_util.rs:805:26
|
803 | pub fn transmute_mut(self) -> &'a mut Dst
| ------------- required by a bound in this associated function
804 | where
805 | Src: FromBytes + IntoBytes,
| ^^^^^^^^^ required by this bound in `Wrap::<&mut Src, &mut Dst>::transmute_mut`
= note: this error originates in the macro `transmute_mut` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0599]: the method `transmute_mut` exists for struct `zerocopy::util::macro_util::Wrap<&mut [u8], &mut [u8; 1]>`, but its trait bounds were not satisfied
--> $DIR/transmute_mut.rs:87:35
|
87 | const SRC_UNSIZED: &mut [u8; 1] = transmute_mut!(&mut [0u8][..]);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
::: src/util/macro_util.rs:692:1
|
692 | pub struct Wrap<Src, Dst>(pub Src, pub PhantomData<Dst>);
| ------------------------- doesn't satisfy `_: TransmuteMutDst<'_>`
|
= note: the following trait bounds were not satisfied:
`[u8]: Sized`
`<[u8; 1] as KnownLayout>::PointerMetadata = usize`
which is required by `zerocopy::util::macro_util::Wrap<&mut [u8], &mut [u8; 1]>: zerocopy::util::macro_util::TransmuteMutDst<'_>`
= note: this error originates in the macro `transmute_mut` (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to 10 previous errors
Some errors have detailed explanations: E0277, E0308, E0599.
For more information about an error, try `rustc --explain E0277`.

View File

@@ -0,0 +1,89 @@
// Copyright 2023 The Fuchsia Authors
//
// Licensed under a BSD-style license <LICENSE-BSD>, Apache License, Version 2.0
// <LICENSE-APACHE or https://www.apache.org/licenses/LICENSE-2.0>, or the MIT
// license <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your option.
// This file may not be copied, modified, or distributed except according to
// those terms.
include!("../include.rs");
use zerocopy::transmute_mut;
fn main() {}
// `transmute_mut!` does not support transmuting into a non-reference
// destination type.
const DST_NOT_A_REFERENCE: usize = transmute_mut!(&mut 0u8);
//~[msrv, stable, nightly]^ ERROR: mismatched types
//~[msrv, stable, nightly]^^ ERROR: mismatched types
#[derive(zerocopy::FromBytes, zerocopy::IntoBytes, zerocopy::Immutable)]
#[repr(C)]
struct SrcA;
#[derive(zerocopy::IntoBytes, zerocopy::Immutable)]
#[repr(C)]
struct DstA;
// `transmute_mut` requires that the destination type implements `FromBytes`
const DST_NOT_FROM_BYTES: &mut DstA = transmute_mut!(&mut SrcA);
//~[msrv, stable, nightly]^ ERROR: the trait bound `DstA: FromBytes` is not satisfied
#[derive(zerocopy::FromBytes, zerocopy::IntoBytes, zerocopy::Immutable)]
#[repr(C)]
struct SrcB;
#[derive(zerocopy::FromBytes, zerocopy::Immutable)]
#[repr(C)]
struct DstB;
// `transmute_mut` requires that the destination type implements `IntoBytes`
const DST_NOT_AS_BYTES: &mut DstB = transmute_mut!(&mut SrcB);
//~[msrv, stable, nightly]^ ERROR: the trait bound `DstB: IntoBytes` is not satisfied
// `transmute_mut!` does not support transmuting between non-reference source
// and destination types.
const SRC_DST_NOT_REFERENCES: &mut usize = transmute_mut!(0usize);
//~[msrv, stable, nightly]^ ERROR: mismatched types
fn ref_src_immutable() {
// `transmute_mut!` requires that its source type be a mutable reference.
let _: &mut u8 = transmute_mut!(&0u8);
//~[msrv, stable, nightly]^ ERROR: mismatched types
}
// `transmute_mut!` does not support transmuting from a non-reference source
// type.
const SRC_NOT_A_REFERENCE: &mut u8 = transmute_mut!(0usize);
//~[msrv, stable, nightly]^ ERROR: mismatched types
#[derive(zerocopy::IntoBytes, zerocopy::Immutable)]
#[repr(C)]
struct SrcC;
#[derive(zerocopy::FromBytes, zerocopy::IntoBytes, zerocopy::Immutable)]
#[repr(C)]
struct DstC;
// `transmute_mut` requires that the source type implements `FromBytes`
const SRC_NOT_FROM_BYTES: &mut DstC = transmute_mut!(&mut SrcC);
//~[msrv, stable, nightly]^ ERROR: the trait bound `SrcC: FromBytes` is not satisfied
#[derive(zerocopy::FromBytes, zerocopy::Immutable)]
#[repr(C)]
struct SrcD;
#[derive(zerocopy::FromBytes, zerocopy::IntoBytes, zerocopy::Immutable)]
#[repr(C)]
struct DstD;
// `transmute_mut` requires that the source type implements `IntoBytes`
const SRC_NOT_AS_BYTES: &mut DstD = transmute_mut!(&mut SrcD);
//~[msrv, stable, nightly]^ ERROR: the trait bound `SrcD: IntoBytes` is not satisfied
// `transmute_mut!` does not support transmuting from an unsized source type to
// a sized destination type.
const SRC_UNSIZED: &mut [u8; 1] = transmute_mut!(&mut [0u8][..]);
//~[msrv, stable]^ ERROR: the method `transmute_mut` exists for struct `Wrap<&mut [u8], &mut [u8; 1]>`, but its trait bounds were not satisfied
//~[nightly]^^ ERROR: transmute_mut` exists for struct `zerocopy::util::macro_util::Wrap<&mut [u8], &mut [u8; 1]>`, but its trait bounds were not satisfied

View File

@@ -0,0 +1,213 @@
error[E0308]: mismatched types
--> $DIR/transmute_mut.rs:17:36
|
17 | const DST_NOT_A_REFERENCE: usize = transmute_mut!(&mut 0u8);
| ^^^^^^^^^^^^^^^^^^^^^^^^ expected `usize`, found `&mut _`
|
= note: expected type `usize`
found mutable reference `&mut _`
= note: this error originates in the macro `transmute_mut` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0308]: mismatched types
--> $DIR/transmute_mut.rs:17:36
|
17 | const DST_NOT_A_REFERENCE: usize = transmute_mut!(&mut 0u8);
| ^^^^^^^^^^^^^^^^^^^^^^^^ expected `usize`, found `&mut _`
|
= note: expected type `usize`
found mutable reference `&mut _`
= note: this error originates in the macro `transmute_mut` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0277]: the trait bound `DstA: FromBytes` is not satisfied
--> $DIR/transmute_mut.rs:30:39
|
30 | const DST_NOT_FROM_BYTES: &mut DstA = transmute_mut!(&mut SrcA);
| ^^^^^^^^^^^^^^^^^^^^^^^^^ unsatisfied trait bound
|
help: the trait `FromBytes` is not implemented for `DstA`
--> $DIR/transmute_mut.rs:27:1
|
27 | struct DstA;
| ^^^^^^^^^^^
= note: Consider adding `#[derive(FromBytes)]` to `DstA`
= help: the following other types implement trait `FromBytes`:
()
(A, B)
(A, B, C)
(A, B, C, D)
(A, B, C, D, E)
(A, B, C, D, E, F)
(A, B, C, D, E, F, G)
(A, B, C, D, E, F, G, H)
and 85 others
note: required by a bound in `Wrap::<&'a mut Src, &'a mut Dst>::transmute_mut`
--> $WORKSPACE/src/util/macro_util.rs:806:14
|
803 | pub fn transmute_mut(self) -> &'a mut Dst
| ------------- required by a bound in this associated function
...
806 | Dst: FromBytes + IntoBytes,
| ^^^^^^^^^ required by this bound in `Wrap::<&mut Src, &mut Dst>::transmute_mut`
= note: this error originates in the macro `transmute_mut` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0277]: the trait bound `DstB: IntoBytes` is not satisfied
--> $DIR/transmute_mut.rs:42:37
|
42 | const DST_NOT_AS_BYTES: &mut DstB = transmute_mut!(&mut SrcB);
| ^^^^^^^^^^^^^^^^^^^^^^^^^ unsatisfied trait bound
|
help: the trait `IntoBytes` is not implemented for `DstB`
--> $DIR/transmute_mut.rs:39:1
|
39 | struct DstB;
| ^^^^^^^^^^^
= note: Consider adding `#[derive(IntoBytes)]` to `DstB`
= help: the following other types implement trait `IntoBytes`:
()
AU16
AtomicBool
AtomicI16
AtomicI32
AtomicI64
AtomicI8
AtomicIsize
and 74 others
note: required by a bound in `Wrap::<&'a mut Src, &'a mut Dst>::transmute_mut`
--> $WORKSPACE/src/util/macro_util.rs:806:26
|
803 | pub fn transmute_mut(self) -> &'a mut Dst
| ------------- required by a bound in this associated function
...
806 | Dst: FromBytes + IntoBytes,
| ^^^^^^^^^ required by this bound in `Wrap::<&mut Src, &mut Dst>::transmute_mut`
= note: this error originates in the macro `transmute_mut` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0308]: mismatched types
--> $DIR/transmute_mut.rs:47:59
|
47 | const SRC_DST_NOT_REFERENCES: &mut usize = transmute_mut!(0usize);
| ---------------^^^^^^-
| | |
| | expected `&mut _`, found `usize`
| expected due to this
|
= note: expected mutable reference `&mut _`
found type `usize`
help: consider mutably borrowing here
|
47 | const SRC_DST_NOT_REFERENCES: &mut usize = transmute_mut!(&mut 0usize);
| ++++
error[E0308]: mismatched types
--> $DIR/transmute_mut.rs:52:37
|
52 | let _: &mut u8 = transmute_mut!(&0u8);
| ---------------^^^^-
| | |
| | types differ in mutability
| expected due to this
|
= note: expected mutable reference `&mut _`
found reference `&u8`
error[E0308]: mismatched types
--> $DIR/transmute_mut.rs:58:53
|
58 | const SRC_NOT_A_REFERENCE: &mut u8 = transmute_mut!(0usize);
| ---------------^^^^^^-
| | |
| | expected `&mut _`, found `usize`
| expected due to this
|
= note: expected mutable reference `&mut _`
found type `usize`
help: consider mutably borrowing here
|
58 | const SRC_NOT_A_REFERENCE: &mut u8 = transmute_mut!(&mut 0usize);
| ++++
error[E0277]: the trait bound `SrcC: FromBytes` is not satisfied
--> $DIR/transmute_mut.rs:70:39
|
70 | const SRC_NOT_FROM_BYTES: &mut DstC = transmute_mut!(&mut SrcC);
| ^^^^^^^^^^^^^^^^^^^^^^^^^ unsatisfied trait bound
|
help: the trait `FromBytes` is not implemented for `SrcC`
--> $DIR/transmute_mut.rs:63:1
|
63 | struct SrcC;
| ^^^^^^^^^^^
= note: Consider adding `#[derive(FromBytes)]` to `SrcC`
= help: the following other types implement trait `FromBytes`:
()
(A, B)
(A, B, C)
(A, B, C, D)
(A, B, C, D, E)
(A, B, C, D, E, F)
(A, B, C, D, E, F, G)
(A, B, C, D, E, F, G, H)
and 85 others
note: required by a bound in `Wrap::<&'a mut Src, &'a mut Dst>::transmute_mut`
--> $WORKSPACE/src/util/macro_util.rs:805:14
|
803 | pub fn transmute_mut(self) -> &'a mut Dst
| ------------- required by a bound in this associated function
804 | where
805 | Src: FromBytes + IntoBytes,
| ^^^^^^^^^ required by this bound in `Wrap::<&mut Src, &mut Dst>::transmute_mut`
= note: this error originates in the macro `transmute_mut` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0277]: the trait bound `SrcD: IntoBytes` is not satisfied
--> $DIR/transmute_mut.rs:82:37
|
82 | const SRC_NOT_AS_BYTES: &mut DstD = transmute_mut!(&mut SrcD);
| ^^^^^^^^^^^^^^^^^^^^^^^^^ unsatisfied trait bound
|
help: the trait `IntoBytes` is not implemented for `SrcD`
--> $DIR/transmute_mut.rs:75:1
|
75 | struct SrcD;
| ^^^^^^^^^^^
= note: Consider adding `#[derive(IntoBytes)]` to `SrcD`
= help: the following other types implement trait `IntoBytes`:
()
AU16
AtomicBool
AtomicI16
AtomicI32
AtomicI64
AtomicI8
AtomicIsize
and 74 others
note: required by a bound in `Wrap::<&'a mut Src, &'a mut Dst>::transmute_mut`
--> $WORKSPACE/src/util/macro_util.rs:805:26
|
803 | pub fn transmute_mut(self) -> &'a mut Dst
| ------------- required by a bound in this associated function
804 | where
805 | Src: FromBytes + IntoBytes,
| ^^^^^^^^^ required by this bound in `Wrap::<&mut Src, &mut Dst>::transmute_mut`
= note: this error originates in the macro `transmute_mut` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0599]: the method `transmute_mut` exists for struct `Wrap<&mut [u8], &mut [u8; 1]>`, but its trait bounds were not satisfied
--> $DIR/transmute_mut.rs:87:35
|
87 | const SRC_UNSIZED: &mut [u8; 1] = transmute_mut!(&mut [0u8][..]);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
::: $WORKSPACE/src/util/macro_util.rs:692:1
|
692 | pub struct Wrap<Src, Dst>(pub Src, pub PhantomData<Dst>);
| ------------------------- doesn't satisfy `Wrap<&mut [u8], &mut [u8; 1]>: TransmuteMutDst<'_>`
|
= note: the following trait bounds were not satisfied:
`[u8]: Sized`
`<[u8; 1] as KnownLayout>::PointerMetadata = usize`
which is required by `Wrap<&mut [u8], &mut [u8; 1]>: TransmuteMutDst<'_>`
= note: this error originates in the macro `transmute_mut` (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to 10 previous errors
Some errors have detailed explanations: E0277, E0308, E0599.
For more information about an error, try `rustc --explain E0277`.

View File

@@ -0,0 +1,245 @@
error[E0308]: mismatched types
--> $DIR/transmute_ref.rs:29:36
|
29 | const DST_NOT_A_REFERENCE: usize = transmute_ref!(&0u8);
| ^^^^^^^^^^^^^^^^^^^^ expected `usize`, found reference
|
= note: expected type `usize`
found reference `&_`
= note: this error originates in the macro `transmute_ref` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0308]: mismatched types
--> $DIR/transmute_ref.rs:29:36
|
29 | const DST_NOT_A_REFERENCE: usize = transmute_ref!(&0u8);
| ^^^^^^^^^^^^^^^^^^^^ expected `usize`, found reference
|
= note: expected type `usize`
found reference `&_`
= note: this error originates in the macro `transmute_ref` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0308]: mismatched types
--> $DIR/transmute_ref.rs:29:36
|
29 | const DST_NOT_A_REFERENCE: usize = transmute_ref!(&0u8);
| ^^^^^^^^^^^^^^^^^^^^ expected `usize`, found reference
|
= note: expected type `usize`
found reference `&_`
= note: this error originates in the macro `transmute_ref` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0308]: mismatched types
--> $DIR/transmute_ref.rs:29:36
|
29 | const DST_NOT_A_REFERENCE: usize = transmute_ref!(&0u8);
| ^^^^^^^^^^^^^^^^^^^^ expected `usize`, found reference
|
= note: expected type `usize`
found reference `&_`
= note: this error originates in the macro `transmute_ref` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0277]: the trait bound `DstA: FromBytes` is not satisfied
--> $DIR/transmute_ref.rs:40:35
|
40 | const DST_NOT_FROM_BYTES: &DstA = transmute_ref!(&AU16(0));
| ^^^^^^^^^^^^^^^^^^^^^^^^ the trait `FromBytes` is not implemented for `DstA`
|
note: required by `DST_NOT_FROM_BYTES::AssertDstIsFromBytes`
--> $DIR/transmute_ref.rs:40:35
|
40 | const DST_NOT_FROM_BYTES: &DstA = transmute_ref!(&AU16(0));
| ^^^^^^^^^^^^^^^^^^^^^^^^
= note: this error originates in the macro `transmute_ref` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0277]: the trait bound `DstB: Immutable` is not satisfied
--> $DIR/transmute_ref.rs:48:34
|
48 | const DST_NOT_IMMUTABLE: &DstB = transmute_ref!(&AU16(0));
| ^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Immutable` is not implemented for `DstB`
|
note: required by `DST_NOT_IMMUTABLE::AssertDstIsImmutable`
--> $DIR/transmute_ref.rs:48:34
|
48 | const DST_NOT_IMMUTABLE: &DstB = transmute_ref!(&AU16(0));
| ^^^^^^^^^^^^^^^^^^^^^^^^
= note: this error originates in the macro `transmute_ref` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0308]: mismatched types
--> $DIR/transmute_ref.rs:53:54
|
53 | const SRC_DST_NOT_REFERENCES: usize = transmute_ref!(0usize);
| ---------------^^^^^^-
| | |
| | expected reference, found `usize`
| | help: consider borrowing here: `&0usize`
| expected due to this
|
= note: expected reference `&_`
found type `usize`
error[E0308]: mismatched types
--> $DIR/transmute_ref.rs:53:39
|
53 | const SRC_DST_NOT_REFERENCES: usize = transmute_ref!(0usize);
| ^^^^^^^^^^^^^^^^^^^^^^ expected `usize`, found reference
|
= note: expected type `usize`
found reference `&_`
= note: this error originates in the macro `transmute_ref` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0308]: mismatched types
--> $DIR/transmute_ref.rs:53:39
|
53 | const SRC_DST_NOT_REFERENCES: usize = transmute_ref!(0usize);
| ^^^^^^^^^^^^^^^^^^^^^^ expected `usize`, found reference
|
= note: expected type `usize`
found reference `&_`
= note: this error originates in the macro `transmute_ref` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0308]: mismatched types
--> $DIR/transmute_ref.rs:53:39
|
53 | const SRC_DST_NOT_REFERENCES: usize = transmute_ref!(0usize);
| ^^^^^^^^^^^^^^^^^^^^^^ expected `usize`, found reference
|
= note: expected type `usize`
found reference `&_`
= note: this error originates in the macro `transmute_ref` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0308]: mismatched types
--> $DIR/transmute_ref.rs:53:39
|
53 | const SRC_DST_NOT_REFERENCES: usize = transmute_ref!(0usize);
| ^^^^^^^^^^^^^^^^^^^^^^ expected `usize`, found reference
|
= note: expected type `usize`
found reference `&_`
= note: this error originates in the macro `transmute_ref` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0308]: mismatched types
--> $DIR/transmute_ref.rs:62:49
|
62 | const SRC_NOT_A_REFERENCE: &u8 = transmute_ref!(0usize);
| ---------------^^^^^^-
| | |
| | expected reference, found `usize`
| | help: consider borrowing here: `&0usize`
| expected due to this
|
= note: expected reference `&_`
found type `usize`
error[E0277]: the trait bound `SrcA: IntoBytes` is not satisfied
--> $DIR/transmute_ref.rs:70:33
|
70 | const SRC_NOT_AS_BYTES: &AU16 = transmute_ref!(&SrcA(AU16(0)));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `IntoBytes` is not implemented for `SrcA`
|
note: required by `SRC_NOT_AS_BYTES::AssertSrcIsIntoBytes`
--> $DIR/transmute_ref.rs:70:33
|
70 | const SRC_NOT_AS_BYTES: &AU16 = transmute_ref!(&SrcA(AU16(0)));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: this error originates in the macro `transmute_ref` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0277]: the trait bound `SrcA: IntoBytes` is not satisfied
--> $DIR/transmute_ref.rs:70:33
|
70 | const SRC_NOT_AS_BYTES: &AU16 = transmute_ref!(&SrcA(AU16(0)));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `IntoBytes` is not implemented for `SrcA`
|
note: required by a bound in `SRC_NOT_AS_BYTES::AssertSrcIsIntoBytes`
--> $DIR/transmute_ref.rs:70:33
|
70 | const SRC_NOT_AS_BYTES: &AU16 = transmute_ref!(&SrcA(AU16(0)));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `SRC_NOT_AS_BYTES::AssertSrcIsIntoBytes`
= note: this error originates in the macro `transmute_ref` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0277]: the trait bound `SrcB: Immutable` is not satisfied
--> $DIR/transmute_ref.rs:79:34
|
79 | const SRC_NOT_IMMUTABLE: &AU16 = transmute_ref!(&SrcB(AU16(0)));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected an implementor of trait `Immutable`
|
note: required by `SRC_NOT_IMMUTABLE::AssertSrcIsImmutable`
--> $DIR/transmute_ref.rs:79:34
|
79 | const SRC_NOT_IMMUTABLE: &AU16 = transmute_ref!(&SrcB(AU16(0)));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: this error originates in the macro `transmute_ref` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0277]: the trait bound `SrcB: Immutable` is not satisfied
--> $DIR/transmute_ref.rs:79:34
|
79 | const SRC_NOT_IMMUTABLE: &AU16 = transmute_ref!(&SrcB(AU16(0)));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Immutable` is not implemented for `SrcB`
|
note: required by a bound in `SRC_NOT_IMMUTABLE::AssertSrcIsImmutable`
--> $DIR/transmute_ref.rs:79:34
|
79 | const SRC_NOT_IMMUTABLE: &AU16 = transmute_ref!(&SrcB(AU16(0)));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `SRC_NOT_IMMUTABLE::AssertSrcIsImmutable`
= note: this error originates in the macro `transmute_ref` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0599]: the method `transmute_ref` exists for struct `Wrap<&[u8], &[u8; 1]>`, but its trait bounds were not satisfied
--> $DIR/transmute_ref.rs:84:31
|
84 | const SRC_UNSIZED: &[u8; 1] = transmute_ref!(&[0u8][..]);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ method cannot be called on `Wrap<&[u8], &[u8; 1]>` due to unsatisfied trait bounds
|
::: $WORKSPACE/src/util/macro_util.rs:692:1
|
692 | pub struct Wrap<Src, Dst>(pub Src, pub PhantomData<Dst>);
| --------------------------------------------------------- doesn't satisfy `Wrap<&[u8], &[u8; 1]>: TransmuteRefDst`
|
= note: the following trait bounds were not satisfied:
`[u8]: Sized`
`<[u8; 1] as KnownLayout>::PointerMetadata = usize`
which is required by `Wrap<&[u8], &[u8; 1]>: TransmuteRefDst`
= note: this error originates in the macro `transmute_ref` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0308]: mismatched types
--> $DIR/transmute_ref.rs:20:22
|
20 | let _: &mut u8 = transmute_ref!(&0u8);
| ^^^^^^^^^^^^^^^^^^^^ types differ in mutability
|
= note: expected mutable reference `&mut u8`
found reference `&_`
= note: this error originates in the macro `transmute_ref` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0308]: mismatched types
--> $DIR/transmute_ref.rs:20:22
|
20 | let _: &mut u8 = transmute_ref!(&0u8);
| ^^^^^^^^^^^^^^^^^^^^ types differ in mutability
|
= note: expected mutable reference `&mut u8`
found reference `&_`
= note: this error originates in the macro `transmute_ref` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0308]: mismatched types
--> $DIR/transmute_ref.rs:20:22
|
20 | let _: &mut u8 = transmute_ref!(&0u8);
| ^^^^^^^^^^^^^^^^^^^^ types differ in mutability
|
= note: expected mutable reference `&mut u8`
found reference `&_`
= note: this error originates in the macro `transmute_ref` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0308]: mismatched types
--> $DIR/transmute_ref.rs:20:22
|
20 | let _: &mut u8 = transmute_ref!(&0u8);
| ^^^^^^^^^^^^^^^^^^^^ types differ in mutability
|
= note: expected mutable reference `&mut u8`
found reference `&_`
= note: this error originates in the macro `transmute_ref` (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to 21 previous errors
Some errors have detailed explanations: E0277, E0308, E0599.
For more information about an error, try `rustc --explain E0277`.

View File

@@ -0,0 +1,359 @@
error[E0308]: mismatched types
--> $DIR/transmute_ref.rs:20:22
|
20 | let _: &mut u8 = transmute_ref!(&0u8);
| ^^^^^^^^^^^^^^^^^^^^ types differ in mutability
|
= note: expected mutable reference `&mut u8`
found reference `&_`
= note: this error originates in the macro `transmute_ref` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0308]: mismatched types
--> $DIR/transmute_ref.rs:20:22
|
20 | let _: &mut u8 = transmute_ref!(&0u8);
| ^^^^^^^^^^^^^^^^^^^^ types differ in mutability
|
= note: expected mutable reference `&mut u8`
found reference `&_`
= note: this error originates in the macro `transmute_ref` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0308]: mismatched types
--> $DIR/transmute_ref.rs:20:22
|
20 | let _: &mut u8 = transmute_ref!(&0u8);
| ^^^^^^^^^^^^^^^^^^^^ types differ in mutability
|
= note: expected mutable reference `&mut u8`
found reference `&_`
= note: this error originates in the macro `transmute_ref` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0308]: mismatched types
--> $DIR/transmute_ref.rs:20:22
|
20 | let _: &mut u8 = transmute_ref!(&0u8);
| ^^^^^^^^^^^^^^^^^^^^ types differ in mutability
|
= note: expected mutable reference `&mut u8`
found reference `&_`
= note: this error originates in the macro `transmute_ref` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0308]: mismatched types
--> $DIR/transmute_ref.rs:29:36
|
29 | const DST_NOT_A_REFERENCE: usize = transmute_ref!(&0u8);
| ^^^^^^^^^^^^^^^^^^^^ expected `usize`, found `&_`
|
= note: expected type `usize`
found reference `&_`
= note: this error originates in the macro `transmute_ref` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0308]: mismatched types
--> $DIR/transmute_ref.rs:29:36
|
29 | const DST_NOT_A_REFERENCE: usize = transmute_ref!(&0u8);
| ^^^^^^^^^^^^^^^^^^^^ expected `usize`, found `&_`
|
= note: expected type `usize`
found reference `&_`
= note: this error originates in the macro `transmute_ref` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0308]: mismatched types
--> $DIR/transmute_ref.rs:29:36
|
29 | const DST_NOT_A_REFERENCE: usize = transmute_ref!(&0u8);
| ^^^^^^^^^^^^^^^^^^^^ expected `usize`, found `&_`
|
= note: expected type `usize`
found reference `&_`
= note: this error originates in the macro `transmute_ref` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0308]: mismatched types
--> $DIR/transmute_ref.rs:29:36
|
29 | const DST_NOT_A_REFERENCE: usize = transmute_ref!(&0u8);
| ^^^^^^^^^^^^^^^^^^^^ expected `usize`, found `&_`
|
= note: expected type `usize`
found reference `&_`
= note: this error originates in the macro `transmute_ref` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0277]: the trait bound `DstA: FromBytes` is not satisfied
--> $DIR/transmute_ref.rs:40:35
|
40 | const DST_NOT_FROM_BYTES: &DstA = transmute_ref!(&AU16(0));
| ^^^^^^^^^^^^^^^^^^^^^^^^
| |
| unsatisfied trait bound
| required by a bound introduced by this call
|
help: the trait `FromBytes` is not implemented for `DstA`
--> $DIR/transmute_ref.rs:37:1
|
37 | struct DstA(AU16);
| ^^^^^^^^^^^
= note: Consider adding `#[derive(FromBytes)]` to `DstA`
= help: the following other types implement trait `FromBytes`:
()
(A, B)
(A, B, C)
(A, B, C, D)
(A, B, C, D, E)
(A, B, C, D, E, F)
(A, B, C, D, E, F, G)
(A, B, C, D, E, F, G, H)
and 80 others
note: required by a bound in `DST_NOT_FROM_BYTES::AssertDstIsFromBytes`
--> $DIR/transmute_ref.rs:40:35
|
40 | const DST_NOT_FROM_BYTES: &DstA = transmute_ref!(&AU16(0));
| ^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `AssertDstIsFromBytes`
= note: this error originates in the macro `transmute_ref` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0277]: the trait bound `DstB: Immutable` is not satisfied
--> $DIR/transmute_ref.rs:48:34
|
48 | const DST_NOT_IMMUTABLE: &DstB = transmute_ref!(&AU16(0));
| ^^^^^^^^^^^^^^^^^^^^^^^^
| |
| unsatisfied trait bound
| required by a bound introduced by this call
|
help: the trait `Immutable` is not implemented for `DstB`
--> $DIR/transmute_ref.rs:45:1
|
45 | struct DstB(AU16);
| ^^^^^^^^^^^
= note: Consider adding `#[derive(Immutable)]` to `DstB`
= help: the following other types implement trait `Immutable`:
&T
&mut T
()
(A, B)
(A, B, C)
(A, B, C, D)
(A, B, C, D, E)
(A, B, C, D, E, F)
and 130 others
note: required by a bound in `DST_NOT_IMMUTABLE::AssertDstIsImmutable`
--> $DIR/transmute_ref.rs:48:34
|
48 | const DST_NOT_IMMUTABLE: &DstB = transmute_ref!(&AU16(0));
| ^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `AssertDstIsImmutable`
= note: this error originates in the macro `transmute_ref` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0308]: mismatched types
--> $DIR/transmute_ref.rs:53:54
|
53 | const SRC_DST_NOT_REFERENCES: usize = transmute_ref!(0usize);
| ---------------^^^^^^-
| | |
| | expected `&_`, found `usize`
| expected due to this
|
= note: expected reference `&_`
found type `usize`
help: consider borrowing here
|
53 | const SRC_DST_NOT_REFERENCES: usize = transmute_ref!(&0usize);
| +
error[E0308]: mismatched types
--> $DIR/transmute_ref.rs:53:39
|
53 | const SRC_DST_NOT_REFERENCES: usize = transmute_ref!(0usize);
| ^^^^^^^^^^^^^^^^^^^^^^ expected `usize`, found `&_`
|
= note: expected type `usize`
found reference `&_`
= note: this error originates in the macro `transmute_ref` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0308]: mismatched types
--> $DIR/transmute_ref.rs:53:39
|
53 | const SRC_DST_NOT_REFERENCES: usize = transmute_ref!(0usize);
| ^^^^^^^^^^^^^^^^^^^^^^ expected `usize`, found `&_`
|
= note: expected type `usize`
found reference `&_`
= note: this error originates in the macro `transmute_ref` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0308]: mismatched types
--> $DIR/transmute_ref.rs:53:39
|
53 | const SRC_DST_NOT_REFERENCES: usize = transmute_ref!(0usize);
| ^^^^^^^^^^^^^^^^^^^^^^ expected `usize`, found `&_`
|
= note: expected type `usize`
found reference `&_`
= note: this error originates in the macro `transmute_ref` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0308]: mismatched types
--> $DIR/transmute_ref.rs:53:39
|
53 | const SRC_DST_NOT_REFERENCES: usize = transmute_ref!(0usize);
| ^^^^^^^^^^^^^^^^^^^^^^ expected `usize`, found `&_`
|
= note: expected type `usize`
found reference `&_`
= note: this error originates in the macro `transmute_ref` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0308]: mismatched types
--> $DIR/transmute_ref.rs:62:49
|
62 | const SRC_NOT_A_REFERENCE: &u8 = transmute_ref!(0usize);
| ---------------^^^^^^-
| | |
| | expected `&_`, found `usize`
| expected due to this
|
= note: expected reference `&_`
found type `usize`
help: consider borrowing here
|
62 | const SRC_NOT_A_REFERENCE: &u8 = transmute_ref!(&0usize);
| +
error[E0277]: the trait bound `SrcA: IntoBytes` is not satisfied
--> $DIR/transmute_ref.rs:70:33
|
70 | const SRC_NOT_AS_BYTES: &AU16 = transmute_ref!(&SrcA(AU16(0)));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
| unsatisfied trait bound
| required by a bound introduced by this call
|
help: the trait `IntoBytes` is not implemented for `SrcA`
--> $DIR/transmute_ref.rs:67:1
|
67 | struct SrcA(AU16);
| ^^^^^^^^^^^
= note: Consider adding `#[derive(IntoBytes)]` to `SrcA`
= help: the following other types implement trait `IntoBytes`:
()
AU16
AtomicBool
AtomicI16
AtomicI32
AtomicI64
AtomicI8
AtomicIsize
and 69 others
note: required by a bound in `SRC_NOT_AS_BYTES::AssertSrcIsIntoBytes`
--> $DIR/transmute_ref.rs:70:33
|
70 | const SRC_NOT_AS_BYTES: &AU16 = transmute_ref!(&SrcA(AU16(0)));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `AssertSrcIsIntoBytes`
= note: this error originates in the macro `transmute_ref` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0277]: the trait bound `SrcA: IntoBytes` is not satisfied
--> $DIR/transmute_ref.rs:70:33
|
70 | const SRC_NOT_AS_BYTES: &AU16 = transmute_ref!(&SrcA(AU16(0)));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unsatisfied trait bound
|
help: the trait `IntoBytes` is not implemented for `SrcA`
--> $DIR/transmute_ref.rs:67:1
|
67 | struct SrcA(AU16);
| ^^^^^^^^^^^
= note: Consider adding `#[derive(IntoBytes)]` to `SrcA`
= help: the following other types implement trait `IntoBytes`:
()
AU16
AtomicBool
AtomicI16
AtomicI32
AtomicI64
AtomicI8
AtomicIsize
and 69 others
note: required by a bound in `SRC_NOT_AS_BYTES::AssertSrcIsIntoBytes`
--> $DIR/transmute_ref.rs:70:33
|
70 | const SRC_NOT_AS_BYTES: &AU16 = transmute_ref!(&SrcA(AU16(0)));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `AssertSrcIsIntoBytes`
= note: this error originates in the macro `transmute_ref` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0277]: the trait bound `SrcB: Immutable` is not satisfied
--> $DIR/transmute_ref.rs:79:34
|
79 | const SRC_NOT_IMMUTABLE: &AU16 = transmute_ref!(&SrcB(AU16(0)));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
| unsatisfied trait bound
| required by a bound introduced by this call
|
help: the trait `Immutable` is not implemented for `SrcB`
--> $DIR/transmute_ref.rs:76:1
|
76 | struct SrcB(AU16);
| ^^^^^^^^^^^
= note: Consider adding `#[derive(Immutable)]` to `SrcB`
= help: the following other types implement trait `Immutable`:
&T
&mut T
()
(A, B)
(A, B, C)
(A, B, C, D)
(A, B, C, D, E)
(A, B, C, D, E, F)
and 130 others
note: required by a bound in `SRC_NOT_IMMUTABLE::AssertSrcIsImmutable`
--> $DIR/transmute_ref.rs:79:34
|
79 | const SRC_NOT_IMMUTABLE: &AU16 = transmute_ref!(&SrcB(AU16(0)));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `AssertSrcIsImmutable`
= note: this error originates in the macro `transmute_ref` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0277]: the trait bound `SrcB: Immutable` is not satisfied
--> $DIR/transmute_ref.rs:79:34
|
79 | const SRC_NOT_IMMUTABLE: &AU16 = transmute_ref!(&SrcB(AU16(0)));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unsatisfied trait bound
|
help: the trait `Immutable` is not implemented for `SrcB`
--> $DIR/transmute_ref.rs:76:1
|
76 | struct SrcB(AU16);
| ^^^^^^^^^^^
= note: Consider adding `#[derive(Immutable)]` to `SrcB`
= help: the following other types implement trait `Immutable`:
&T
&mut T
()
(A, B)
(A, B, C)
(A, B, C, D)
(A, B, C, D, E)
(A, B, C, D, E, F)
and 130 others
note: required by a bound in `SRC_NOT_IMMUTABLE::AssertSrcIsImmutable`
--> $DIR/transmute_ref.rs:79:34
|
79 | const SRC_NOT_IMMUTABLE: &AU16 = transmute_ref!(&SrcB(AU16(0)));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `AssertSrcIsImmutable`
= note: this error originates in the macro `transmute_ref` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0599]: the method `transmute_ref` exists for struct `zerocopy::util::macro_util::Wrap<&[u8], &[u8; 1]>`, but its trait bounds were not satisfied
--> $DIR/transmute_ref.rs:84:31
|
84 | const SRC_UNSIZED: &[u8; 1] = transmute_ref!(&[0u8][..]);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
::: src/util/macro_util.rs:692:1
|
692 | pub struct Wrap<Src, Dst>(pub Src, pub PhantomData<Dst>);
| ------------------------- doesn't satisfy `_: TransmuteRefDst<'_>`
|
= note: the following trait bounds were not satisfied:
`[u8]: Sized`
`<[u8; 1] as KnownLayout>::PointerMetadata = usize`
which is required by `zerocopy::util::macro_util::Wrap<&[u8], &[u8; 1]>: zerocopy::util::macro_util::TransmuteRefDst<'_>`
= note: this error originates in the macro `transmute_ref` (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to 21 previous errors
Some errors have detailed explanations: E0277, E0308, E0599.
For more information about an error, try `rustc --explain E0277`.

View File

@@ -0,0 +1,86 @@
// Copyright 2023 The Fuchsia Authors
//
// Licensed under a BSD-style license <LICENSE-BSD>, Apache License, Version 2.0
// <LICENSE-APACHE or https://www.apache.org/licenses/LICENSE-2.0>, or the MIT
// license <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your option.
// This file may not be copied, modified, or distributed except according to
// those terms.
include!("../include.rs");
use zerocopy::transmute_ref;
use crate::util::AU16;
fn main() {}
fn ref_dst_mutable() {
// `transmute_ref!` requires that its destination type be an immutable
// reference.
let _: &mut u8 = transmute_ref!(&0u8);
//~[msrv, stable, nightly]^ ERROR: mismatched types
//~[msrv, stable, nightly]^^ ERROR: mismatched types
//~[msrv, stable, nightly]^^^ ERROR: mismatched types
//~[msrv, stable, nightly]^^^^ ERROR: mismatched types
}
// `transmute_ref!` does not support transmuting into a non-reference
// destination type.
const DST_NOT_A_REFERENCE: usize = transmute_ref!(&0u8);
//~[msrv, stable, nightly]^ ERROR: mismatched types
//~[msrv, stable, nightly]^^ ERROR: mismatched types
//~[msrv, stable, nightly]^^^ ERROR: mismatched types
//~[msrv, stable, nightly]^^^^ ERROR: mismatched types
#[derive(zerocopy::Immutable)]
#[repr(transparent)]
struct DstA(AU16);
// `transmute_ref` requires that the destination type implements `FromBytes`
const DST_NOT_FROM_BYTES: &DstA = transmute_ref!(&AU16(0));
//~[msrv, stable, nightly]^ ERROR: the trait bound `DstA: FromBytes` is not satisfied
#[derive(zerocopy::FromBytes)]
#[repr(transparent)]
struct DstB(AU16);
// `transmute_ref` requires that the destination type implements `Immutable`
const DST_NOT_IMMUTABLE: &DstB = transmute_ref!(&AU16(0));
//~[msrv, stable, nightly]^ ERROR: the trait bound `DstB: Immutable` is not satisfied
// `transmute_ref!` does not support transmuting between non-reference source
// and destination types.
const SRC_DST_NOT_REFERENCES: usize = transmute_ref!(0usize);
//~[msrv, stable, nightly]^ ERROR: mismatched types
//~[msrv, stable, nightly]^^ ERROR: mismatched types
//~[msrv, stable, nightly]^^^ ERROR: mismatched types
//~[msrv, stable, nightly]^^^^ ERROR: mismatched types
//~[msrv, stable, nightly]^^^^^ ERROR: mismatched types
// `transmute_ref!` does not support transmuting from a non-reference source
// type.
const SRC_NOT_A_REFERENCE: &u8 = transmute_ref!(0usize);
//~[msrv, stable, nightly]^ ERROR: mismatched types
#[derive(zerocopy::Immutable)]
#[repr(transparent)]
struct SrcA(AU16);
// `transmute_ref` requires that the source type implements `IntoBytes`
const SRC_NOT_AS_BYTES: &AU16 = transmute_ref!(&SrcA(AU16(0)));
//~[msrv, stable, nightly]^ ERROR: the trait bound `SrcA: IntoBytes` is not satisfied
//~[msrv, stable, nightly]^^ ERROR: the trait bound `SrcA: IntoBytes` is not satisfied
#[derive(zerocopy::IntoBytes)]
#[repr(transparent)]
struct SrcB(AU16);
// `transmute_ref` requires that the source type implements `Immutable`
const SRC_NOT_IMMUTABLE: &AU16 = transmute_ref!(&SrcB(AU16(0)));
//~[msrv, stable, nightly]^ ERROR: the trait bound `SrcB: Immutable` is not satisfied
//~[msrv, stable, nightly]^^ ERROR: the trait bound `SrcB: Immutable` is not satisfied
// `transmute_ref!` does not support transmuting from an unsized source type.
const SRC_UNSIZED: &[u8; 1] = transmute_ref!(&[0u8][..]);
//~[msrv, stable]^ ERROR: the method `transmute_ref` exists for struct `Wrap<&[u8], &[u8; 1]>`, but its trait bounds were not satisfied
//~[nightly]^^ ERROR: the method `transmute_ref` exists for struct `zerocopy::util::macro_util::Wrap<&[u8], &[u8; 1]>`, but its trait bounds were not satisfied

View File

@@ -0,0 +1,359 @@
error[E0308]: mismatched types
--> $DIR/transmute_ref.rs:20:22
|
20 | let _: &mut u8 = transmute_ref!(&0u8);
| ^^^^^^^^^^^^^^^^^^^^ types differ in mutability
|
= note: expected mutable reference `&mut u8`
found reference `&_`
= note: this error originates in the macro `transmute_ref` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0308]: mismatched types
--> $DIR/transmute_ref.rs:20:22
|
20 | let _: &mut u8 = transmute_ref!(&0u8);
| ^^^^^^^^^^^^^^^^^^^^ types differ in mutability
|
= note: expected mutable reference `&mut u8`
found reference `&_`
= note: this error originates in the macro `transmute_ref` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0308]: mismatched types
--> $DIR/transmute_ref.rs:20:22
|
20 | let _: &mut u8 = transmute_ref!(&0u8);
| ^^^^^^^^^^^^^^^^^^^^ types differ in mutability
|
= note: expected mutable reference `&mut u8`
found reference `&_`
= note: this error originates in the macro `transmute_ref` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0308]: mismatched types
--> $DIR/transmute_ref.rs:20:22
|
20 | let _: &mut u8 = transmute_ref!(&0u8);
| ^^^^^^^^^^^^^^^^^^^^ types differ in mutability
|
= note: expected mutable reference `&mut u8`
found reference `&_`
= note: this error originates in the macro `transmute_ref` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0308]: mismatched types
--> $DIR/transmute_ref.rs:29:36
|
29 | const DST_NOT_A_REFERENCE: usize = transmute_ref!(&0u8);
| ^^^^^^^^^^^^^^^^^^^^ expected `usize`, found `&_`
|
= note: expected type `usize`
found reference `&_`
= note: this error originates in the macro `transmute_ref` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0308]: mismatched types
--> $DIR/transmute_ref.rs:29:36
|
29 | const DST_NOT_A_REFERENCE: usize = transmute_ref!(&0u8);
| ^^^^^^^^^^^^^^^^^^^^ expected `usize`, found `&_`
|
= note: expected type `usize`
found reference `&_`
= note: this error originates in the macro `transmute_ref` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0308]: mismatched types
--> $DIR/transmute_ref.rs:29:36
|
29 | const DST_NOT_A_REFERENCE: usize = transmute_ref!(&0u8);
| ^^^^^^^^^^^^^^^^^^^^ expected `usize`, found `&_`
|
= note: expected type `usize`
found reference `&_`
= note: this error originates in the macro `transmute_ref` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0308]: mismatched types
--> $DIR/transmute_ref.rs:29:36
|
29 | const DST_NOT_A_REFERENCE: usize = transmute_ref!(&0u8);
| ^^^^^^^^^^^^^^^^^^^^ expected `usize`, found `&_`
|
= note: expected type `usize`
found reference `&_`
= note: this error originates in the macro `transmute_ref` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0277]: the trait bound `DstA: FromBytes` is not satisfied
--> $DIR/transmute_ref.rs:40:35
|
40 | const DST_NOT_FROM_BYTES: &DstA = transmute_ref!(&AU16(0));
| ^^^^^^^^^^^^^^^^^^^^^^^^
| |
| unsatisfied trait bound
| required by a bound introduced by this call
|
help: the trait `FromBytes` is not implemented for `DstA`
--> $DIR/transmute_ref.rs:37:1
|
37 | struct DstA(AU16);
| ^^^^^^^^^^^
= note: Consider adding `#[derive(FromBytes)]` to `DstA`
= help: the following other types implement trait `FromBytes`:
()
(A, B)
(A, B, C)
(A, B, C, D)
(A, B, C, D, E)
(A, B, C, D, E, F)
(A, B, C, D, E, F, G)
(A, B, C, D, E, F, G, H)
and 80 others
note: required by a bound in `DST_NOT_FROM_BYTES::AssertDstIsFromBytes`
--> $DIR/transmute_ref.rs:40:35
|
40 | const DST_NOT_FROM_BYTES: &DstA = transmute_ref!(&AU16(0));
| ^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `AssertDstIsFromBytes`
= note: this error originates in the macro `transmute_ref` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0277]: the trait bound `DstB: Immutable` is not satisfied
--> $DIR/transmute_ref.rs:48:34
|
48 | const DST_NOT_IMMUTABLE: &DstB = transmute_ref!(&AU16(0));
| ^^^^^^^^^^^^^^^^^^^^^^^^
| |
| unsatisfied trait bound
| required by a bound introduced by this call
|
help: the trait `Immutable` is not implemented for `DstB`
--> $DIR/transmute_ref.rs:45:1
|
45 | struct DstB(AU16);
| ^^^^^^^^^^^
= note: Consider adding `#[derive(Immutable)]` to `DstB`
= help: the following other types implement trait `Immutable`:
&T
&mut T
()
(A, B)
(A, B, C)
(A, B, C, D)
(A, B, C, D, E)
(A, B, C, D, E, F)
and 130 others
note: required by a bound in `DST_NOT_IMMUTABLE::AssertDstIsImmutable`
--> $DIR/transmute_ref.rs:48:34
|
48 | const DST_NOT_IMMUTABLE: &DstB = transmute_ref!(&AU16(0));
| ^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `AssertDstIsImmutable`
= note: this error originates in the macro `transmute_ref` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0308]: mismatched types
--> $DIR/transmute_ref.rs:53:54
|
53 | const SRC_DST_NOT_REFERENCES: usize = transmute_ref!(0usize);
| ---------------^^^^^^-
| | |
| | expected `&_`, found `usize`
| expected due to this
|
= note: expected reference `&_`
found type `usize`
help: consider borrowing here
|
53 | const SRC_DST_NOT_REFERENCES: usize = transmute_ref!(&0usize);
| +
error[E0308]: mismatched types
--> $DIR/transmute_ref.rs:53:39
|
53 | const SRC_DST_NOT_REFERENCES: usize = transmute_ref!(0usize);
| ^^^^^^^^^^^^^^^^^^^^^^ expected `usize`, found `&_`
|
= note: expected type `usize`
found reference `&_`
= note: this error originates in the macro `transmute_ref` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0308]: mismatched types
--> $DIR/transmute_ref.rs:53:39
|
53 | const SRC_DST_NOT_REFERENCES: usize = transmute_ref!(0usize);
| ^^^^^^^^^^^^^^^^^^^^^^ expected `usize`, found `&_`
|
= note: expected type `usize`
found reference `&_`
= note: this error originates in the macro `transmute_ref` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0308]: mismatched types
--> $DIR/transmute_ref.rs:53:39
|
53 | const SRC_DST_NOT_REFERENCES: usize = transmute_ref!(0usize);
| ^^^^^^^^^^^^^^^^^^^^^^ expected `usize`, found `&_`
|
= note: expected type `usize`
found reference `&_`
= note: this error originates in the macro `transmute_ref` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0308]: mismatched types
--> $DIR/transmute_ref.rs:53:39
|
53 | const SRC_DST_NOT_REFERENCES: usize = transmute_ref!(0usize);
| ^^^^^^^^^^^^^^^^^^^^^^ expected `usize`, found `&_`
|
= note: expected type `usize`
found reference `&_`
= note: this error originates in the macro `transmute_ref` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0308]: mismatched types
--> $DIR/transmute_ref.rs:62:49
|
62 | const SRC_NOT_A_REFERENCE: &u8 = transmute_ref!(0usize);
| ---------------^^^^^^-
| | |
| | expected `&_`, found `usize`
| expected due to this
|
= note: expected reference `&_`
found type `usize`
help: consider borrowing here
|
62 | const SRC_NOT_A_REFERENCE: &u8 = transmute_ref!(&0usize);
| +
error[E0277]: the trait bound `SrcA: IntoBytes` is not satisfied
--> $DIR/transmute_ref.rs:70:33
|
70 | const SRC_NOT_AS_BYTES: &AU16 = transmute_ref!(&SrcA(AU16(0)));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
| unsatisfied trait bound
| required by a bound introduced by this call
|
help: the trait `IntoBytes` is not implemented for `SrcA`
--> $DIR/transmute_ref.rs:67:1
|
67 | struct SrcA(AU16);
| ^^^^^^^^^^^
= note: Consider adding `#[derive(IntoBytes)]` to `SrcA`
= help: the following other types implement trait `IntoBytes`:
()
AU16
AtomicBool
AtomicI16
AtomicI32
AtomicI64
AtomicI8
AtomicIsize
and 69 others
note: required by a bound in `SRC_NOT_AS_BYTES::AssertSrcIsIntoBytes`
--> $DIR/transmute_ref.rs:70:33
|
70 | const SRC_NOT_AS_BYTES: &AU16 = transmute_ref!(&SrcA(AU16(0)));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `AssertSrcIsIntoBytes`
= note: this error originates in the macro `transmute_ref` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0277]: the trait bound `SrcA: IntoBytes` is not satisfied
--> $DIR/transmute_ref.rs:70:33
|
70 | const SRC_NOT_AS_BYTES: &AU16 = transmute_ref!(&SrcA(AU16(0)));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unsatisfied trait bound
|
help: the trait `IntoBytes` is not implemented for `SrcA`
--> $DIR/transmute_ref.rs:67:1
|
67 | struct SrcA(AU16);
| ^^^^^^^^^^^
= note: Consider adding `#[derive(IntoBytes)]` to `SrcA`
= help: the following other types implement trait `IntoBytes`:
()
AU16
AtomicBool
AtomicI16
AtomicI32
AtomicI64
AtomicI8
AtomicIsize
and 69 others
note: required by a bound in `SRC_NOT_AS_BYTES::AssertSrcIsIntoBytes`
--> $DIR/transmute_ref.rs:70:33
|
70 | const SRC_NOT_AS_BYTES: &AU16 = transmute_ref!(&SrcA(AU16(0)));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `AssertSrcIsIntoBytes`
= note: this error originates in the macro `transmute_ref` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0277]: the trait bound `SrcB: Immutable` is not satisfied
--> $DIR/transmute_ref.rs:79:34
|
79 | const SRC_NOT_IMMUTABLE: &AU16 = transmute_ref!(&SrcB(AU16(0)));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
| unsatisfied trait bound
| required by a bound introduced by this call
|
help: the trait `Immutable` is not implemented for `SrcB`
--> $DIR/transmute_ref.rs:76:1
|
76 | struct SrcB(AU16);
| ^^^^^^^^^^^
= note: Consider adding `#[derive(Immutable)]` to `SrcB`
= help: the following other types implement trait `Immutable`:
&T
&mut T
()
(A, B)
(A, B, C)
(A, B, C, D)
(A, B, C, D, E)
(A, B, C, D, E, F)
and 130 others
note: required by a bound in `SRC_NOT_IMMUTABLE::AssertSrcIsImmutable`
--> $DIR/transmute_ref.rs:79:34
|
79 | const SRC_NOT_IMMUTABLE: &AU16 = transmute_ref!(&SrcB(AU16(0)));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `AssertSrcIsImmutable`
= note: this error originates in the macro `transmute_ref` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0277]: the trait bound `SrcB: Immutable` is not satisfied
--> $DIR/transmute_ref.rs:79:34
|
79 | const SRC_NOT_IMMUTABLE: &AU16 = transmute_ref!(&SrcB(AU16(0)));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unsatisfied trait bound
|
help: the trait `Immutable` is not implemented for `SrcB`
--> $DIR/transmute_ref.rs:76:1
|
76 | struct SrcB(AU16);
| ^^^^^^^^^^^
= note: Consider adding `#[derive(Immutable)]` to `SrcB`
= help: the following other types implement trait `Immutable`:
&T
&mut T
()
(A, B)
(A, B, C)
(A, B, C, D)
(A, B, C, D, E)
(A, B, C, D, E, F)
and 130 others
note: required by a bound in `SRC_NOT_IMMUTABLE::AssertSrcIsImmutable`
--> $DIR/transmute_ref.rs:79:34
|
79 | const SRC_NOT_IMMUTABLE: &AU16 = transmute_ref!(&SrcB(AU16(0)));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `AssertSrcIsImmutable`
= note: this error originates in the macro `transmute_ref` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0599]: the method `transmute_ref` exists for struct `Wrap<&[u8], &[u8; 1]>`, but its trait bounds were not satisfied
--> $DIR/transmute_ref.rs:84:31
|
84 | const SRC_UNSIZED: &[u8; 1] = transmute_ref!(&[0u8][..]);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
::: $WORKSPACE/src/util/macro_util.rs:692:1
|
692 | pub struct Wrap<Src, Dst>(pub Src, pub PhantomData<Dst>);
| ------------------------- doesn't satisfy `Wrap<&[u8], &[u8; 1]>: TransmuteRefDst<'_>`
|
= note: the following trait bounds were not satisfied:
`[u8]: Sized`
`<[u8; 1] as KnownLayout>::PointerMetadata = usize`
which is required by `Wrap<&[u8], &[u8; 1]>: TransmuteRefDst<'_>`
= note: this error originates in the macro `transmute_ref` (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to 21 previous errors
Some errors have detailed explanations: E0277, E0308, E0599.
For more information about an error, try `rustc --explain E0277`.

View File

@@ -0,0 +1,54 @@
error[E0277]: the trait bound `NotZerocopy: TryFromBytes` is not satisfied
--> $DIR/try_transmute.rs:15:58
|
15 | let dst_not_try_from_bytes: Result<NotZerocopy, _> = try_transmute!(AU16(0));
| ^^^^^^^^^^^^^^^^^^^^^^^ the trait `TryFromBytes` is not implemented for `NotZerocopy`
|
note: required by a bound in `try_transmute`
--> $WORKSPACE/src/util/macro_util.rs:526:10
|
526 | Dst: TryFromBytes,
| ^^^^^^^^^^^^ required by this bound in `try_transmute`
= note: this error originates in the macro `try_transmute` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0277]: the trait bound `NotZerocopy: TryFromBytes` is not satisfied
--> $DIR/try_transmute.rs:15:33
|
15 | let dst_not_try_from_bytes: Result<NotZerocopy, _> = try_transmute!(AU16(0));
| ^^^^^^^^^^^^^^^^^^^^^^ the trait `TryFromBytes` is not implemented for `NotZerocopy`
|
note: required by a bound in `ValidityError`
--> $WORKSPACE/src/error.rs:588:45
|
588 | pub struct ValidityError<Src, Dst: ?Sized + TryFromBytes> {
| ^^^^^^^^^^^^ required by this bound in `ValidityError`
error[E0277]: the trait bound `NotZerocopy: TryFromBytes` is not satisfied
--> $DIR/try_transmute.rs:15:58
|
15 | let dst_not_try_from_bytes: Result<NotZerocopy, _> = try_transmute!(AU16(0));
| ^^^^^^^^^^^^^^^^^^^^^^^ the trait `TryFromBytes` is not implemented for `NotZerocopy`
|
note: required by a bound in `ValidityError`
--> $WORKSPACE/src/error.rs:588:45
|
588 | pub struct ValidityError<Src, Dst: ?Sized + TryFromBytes> {
| ^^^^^^^^^^^^ required by this bound in `ValidityError`
= note: this error originates in the macro `try_transmute` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0277]: the trait bound `NotZerocopy<AU16>: IntoBytes` is not satisfied
--> $DIR/try_transmute.rs:21:47
|
21 | let src_not_into_bytes: Result<AU16, _> = try_transmute!(NotZerocopy(AU16(0)));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `IntoBytes` is not implemented for `NotZerocopy<AU16>`
|
note: required by a bound in `try_transmute`
--> $WORKSPACE/src/util/macro_util.rs:525:10
|
525 | Src: IntoBytes,
| ^^^^^^^^^ required by this bound in `try_transmute`
= note: this error originates in the macro `try_transmute` (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to 4 previous errors
For more information about this error, try `rustc --explain E0277`.

View File

@@ -0,0 +1,124 @@
error[E0277]: the trait bound `NotZerocopy: TryFromBytes` is not satisfied
--> $DIR/try_transmute.rs:15:33
|
15 | let dst_not_try_from_bytes: Result<NotZerocopy, _> = try_transmute!(AU16(0));
| ^^^^^^^^^^^^^^^^^^^^^^ unsatisfied trait bound
|
help: the trait `TryFromBytes` is not implemented for `NotZerocopy`
--> $DIR/../include.rs:15:5
|
15 | pub struct NotZerocopy<T = ()>(pub T);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: Consider adding `#[derive(TryFromBytes)]` to `NotZerocopy`
= help: the following other types implement trait `TryFromBytes`:
()
(A, B)
(A, B, C)
(A, B, C, D)
(A, B, C, D, E)
(A, B, C, D, E, F)
(A, B, C, D, E, F, G)
(A, B, C, D, E, F, G, H)
and 153 others
note: required by a bound in `ValidityError`
--> src/error.rs:588:45
|
588 | pub struct ValidityError<Src, Dst: ?Sized + TryFromBytes> {
| ^^^^^^^^^^^^ required by this bound in `ValidityError`
error[E0277]: the trait bound `NotZerocopy: TryFromBytes` is not satisfied
--> $DIR/try_transmute.rs:15:58
|
15 | let dst_not_try_from_bytes: Result<NotZerocopy, _> = try_transmute!(AU16(0));
| ^^^^^^^^^^^^^^^^^^^^^^^ unsatisfied trait bound
|
help: the trait `TryFromBytes` is not implemented for `NotZerocopy`
--> $DIR/../include.rs:15:5
|
15 | pub struct NotZerocopy<T = ()>(pub T);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: Consider adding `#[derive(TryFromBytes)]` to `NotZerocopy`
= help: the following other types implement trait `TryFromBytes`:
()
(A, B)
(A, B, C)
(A, B, C, D)
(A, B, C, D, E)
(A, B, C, D, E, F)
(A, B, C, D, E, F, G)
(A, B, C, D, E, F, G, H)
and 153 others
note: required by a bound in `zerocopy::util::macro_util::try_transmute`
--> src/util/macro_util.rs:526:10
|
523 | pub fn try_transmute<Src, Dst>(src: Src) -> Result<Dst, ValidityError<Src, Dst>>
| ------------- required by a bound in this function
...
526 | Dst: TryFromBytes,
| ^^^^^^^^^^^^ required by this bound in `try_transmute`
= note: this error originates in the macro `try_transmute` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0277]: the trait bound `NotZerocopy: TryFromBytes` is not satisfied
--> $DIR/try_transmute.rs:15:58
|
15 | let dst_not_try_from_bytes: Result<NotZerocopy, _> = try_transmute!(AU16(0));
| ^^^^^^^^^^^^^^^^^^^^^^^ unsatisfied trait bound
|
help: the trait `TryFromBytes` is not implemented for `NotZerocopy`
--> $DIR/../include.rs:15:5
|
15 | pub struct NotZerocopy<T = ()>(pub T);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: Consider adding `#[derive(TryFromBytes)]` to `NotZerocopy`
= help: the following other types implement trait `TryFromBytes`:
()
(A, B)
(A, B, C)
(A, B, C, D)
(A, B, C, D, E)
(A, B, C, D, E, F)
(A, B, C, D, E, F, G)
(A, B, C, D, E, F, G, H)
and 153 others
note: required by a bound in `ValidityError`
--> src/error.rs:588:45
|
588 | pub struct ValidityError<Src, Dst: ?Sized + TryFromBytes> {
| ^^^^^^^^^^^^ required by this bound in `ValidityError`
= note: this error originates in the macro `try_transmute` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0277]: the trait bound `NotZerocopy<AU16>: IntoBytes` is not satisfied
--> $DIR/try_transmute.rs:21:47
|
21 | let src_not_into_bytes: Result<AU16, _> = try_transmute!(NotZerocopy(AU16(0)));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unsatisfied trait bound
|
help: the trait `IntoBytes` is not implemented for `NotZerocopy<AU16>`
--> $DIR/../include.rs:15:5
|
15 | pub struct NotZerocopy<T = ()>(pub T);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: Consider adding `#[derive(IntoBytes)]` to `NotZerocopy<AU16>`
= help: the following other types implement trait `IntoBytes`:
()
AU16
AtomicBool
AtomicI16
AtomicI32
AtomicI64
AtomicI8
AtomicIsize
and 68 others
note: required by a bound in `zerocopy::util::macro_util::try_transmute`
--> src/util/macro_util.rs:525:10
|
523 | pub fn try_transmute<Src, Dst>(src: Src) -> Result<Dst, ValidityError<Src, Dst>>
| ------------- required by a bound in this function
524 | where
525 | Src: IntoBytes,
| ^^^^^^^^^ required by this bound in `try_transmute`
= note: this error originates in the macro `try_transmute` (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to 4 previous errors
For more information about this error, try `rustc --explain E0277`.

View File

@@ -0,0 +1,23 @@
// Copyright 2022 The Fuchsia Authors
//
// Licensed under a BSD-style license <LICENSE-BSD>, Apache License, Version 2.0
// <LICENSE-APACHE or https://www.apache.org/licenses/LICENSE-2.0>, or the MIT
// license <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your option.
// This file may not be copied, modified, or distributed except according to
// those terms.
include!("../include.rs");
use util::{NotZerocopy, AU16};
use zerocopy::try_transmute;
fn main() {
let dst_not_try_from_bytes: Result<NotZerocopy, _> = try_transmute!(AU16(0));
//~[msrv, stable, nightly]^ ERROR: the trait bound `NotZerocopy: TryFromBytes` is not satisfied
//~[msrv, stable, nightly]^^ ERROR: the trait bound `NotZerocopy: TryFromBytes` is not satisfied
//~[msrv, stable, nightly]^^^ ERROR: the trait bound `NotZerocopy: TryFromBytes` is not satisfied
// `try_transmute` requires that the source type implements `IntoBytes`
let src_not_into_bytes: Result<AU16, _> = try_transmute!(NotZerocopy(AU16(0)));
//~[msrv, stable, nightly]^ ERROR: the trait bound `NotZerocopy<AU16>: IntoBytes` is not satisfied
}

View File

@@ -0,0 +1,124 @@
error[E0277]: the trait bound `NotZerocopy: TryFromBytes` is not satisfied
--> $DIR/try_transmute.rs:15:33
|
15 | let dst_not_try_from_bytes: Result<NotZerocopy, _> = try_transmute!(AU16(0));
| ^^^^^^^^^^^^^^^^^^^^^^ unsatisfied trait bound
|
help: the trait `TryFromBytes` is not implemented for `NotZerocopy`
--> $DIR/../include.rs:15:5
|
15 | pub struct NotZerocopy<T = ()>(pub T);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: Consider adding `#[derive(TryFromBytes)]` to `NotZerocopy`
= help: the following other types implement trait `TryFromBytes`:
()
(A, B)
(A, B, C)
(A, B, C, D)
(A, B, C, D, E)
(A, B, C, D, E, F)
(A, B, C, D, E, F, G)
(A, B, C, D, E, F, G, H)
and 153 others
note: required by a bound in `ValidityError`
--> $WORKSPACE/src/error.rs:588:45
|
588 | pub struct ValidityError<Src, Dst: ?Sized + TryFromBytes> {
| ^^^^^^^^^^^^ required by this bound in `ValidityError`
error[E0277]: the trait bound `NotZerocopy: TryFromBytes` is not satisfied
--> $DIR/try_transmute.rs:15:58
|
15 | let dst_not_try_from_bytes: Result<NotZerocopy, _> = try_transmute!(AU16(0));
| ^^^^^^^^^^^^^^^^^^^^^^^ unsatisfied trait bound
|
help: the trait `TryFromBytes` is not implemented for `NotZerocopy`
--> $DIR/../include.rs:15:5
|
15 | pub struct NotZerocopy<T = ()>(pub T);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: Consider adding `#[derive(TryFromBytes)]` to `NotZerocopy`
= help: the following other types implement trait `TryFromBytes`:
()
(A, B)
(A, B, C)
(A, B, C, D)
(A, B, C, D, E)
(A, B, C, D, E, F)
(A, B, C, D, E, F, G)
(A, B, C, D, E, F, G, H)
and 153 others
note: required by a bound in `try_transmute`
--> $WORKSPACE/src/util/macro_util.rs:526:10
|
523 | pub fn try_transmute<Src, Dst>(src: Src) -> Result<Dst, ValidityError<Src, Dst>>
| ------------- required by a bound in this function
...
526 | Dst: TryFromBytes,
| ^^^^^^^^^^^^ required by this bound in `try_transmute`
= note: this error originates in the macro `try_transmute` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0277]: the trait bound `NotZerocopy: TryFromBytes` is not satisfied
--> $DIR/try_transmute.rs:15:58
|
15 | let dst_not_try_from_bytes: Result<NotZerocopy, _> = try_transmute!(AU16(0));
| ^^^^^^^^^^^^^^^^^^^^^^^ unsatisfied trait bound
|
help: the trait `TryFromBytes` is not implemented for `NotZerocopy`
--> $DIR/../include.rs:15:5
|
15 | pub struct NotZerocopy<T = ()>(pub T);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: Consider adding `#[derive(TryFromBytes)]` to `NotZerocopy`
= help: the following other types implement trait `TryFromBytes`:
()
(A, B)
(A, B, C)
(A, B, C, D)
(A, B, C, D, E)
(A, B, C, D, E, F)
(A, B, C, D, E, F, G)
(A, B, C, D, E, F, G, H)
and 153 others
note: required by a bound in `ValidityError`
--> $WORKSPACE/src/error.rs:588:45
|
588 | pub struct ValidityError<Src, Dst: ?Sized + TryFromBytes> {
| ^^^^^^^^^^^^ required by this bound in `ValidityError`
= note: this error originates in the macro `try_transmute` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0277]: the trait bound `NotZerocopy<AU16>: IntoBytes` is not satisfied
--> $DIR/try_transmute.rs:21:47
|
21 | let src_not_into_bytes: Result<AU16, _> = try_transmute!(NotZerocopy(AU16(0)));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unsatisfied trait bound
|
help: the trait `IntoBytes` is not implemented for `NotZerocopy<AU16>`
--> $DIR/../include.rs:15:5
|
15 | pub struct NotZerocopy<T = ()>(pub T);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: Consider adding `#[derive(IntoBytes)]` to `NotZerocopy<AU16>`
= help: the following other types implement trait `IntoBytes`:
()
AU16
AtomicBool
AtomicI16
AtomicI32
AtomicI64
AtomicI8
AtomicIsize
and 68 others
note: required by a bound in `try_transmute`
--> $WORKSPACE/src/util/macro_util.rs:525:10
|
523 | pub fn try_transmute<Src, Dst>(src: Src) -> Result<Dst, ValidityError<Src, Dst>>
| ------------- required by a bound in this function
524 | where
525 | Src: IntoBytes,
| ^^^^^^^^^ required by this bound in `try_transmute`
= note: this error originates in the macro `try_transmute` (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to 4 previous errors
For more information about this error, try `rustc --explain E0277`.

View File

@@ -0,0 +1,76 @@
error[E0277]: the trait bound `NotZerocopy: TryFromBytes` is not satisfied
--> $DIR/try_transmute_mut.rs:18:63
|
18 | let dst_not_try_from_bytes: Result<&mut NotZerocopy, _> = try_transmute_mut!(src);
| ^^^^^^^^^^^^^^^^^^^^^^^ the trait `TryFromBytes` is not implemented for `NotZerocopy`
|
= note: this error originates in the macro `try_transmute_mut` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0277]: the trait bound `NotZerocopy: IntoBytes` is not satisfied
--> $DIR/try_transmute_mut.rs:18:63
|
18 | let dst_not_try_from_bytes: Result<&mut NotZerocopy, _> = try_transmute_mut!(src);
| ^^^^^^^^^^^^^^^^^^^^^^^ the trait `IntoBytes` is not implemented for `NotZerocopy`
|
= note: this error originates in the macro `try_transmute_mut` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0277]: the trait bound `NotZerocopy: TryFromBytes` is not satisfied
--> $DIR/try_transmute_mut.rs:18:33
|
18 | let dst_not_try_from_bytes: Result<&mut NotZerocopy, _> = try_transmute_mut!(src);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `TryFromBytes` is not implemented for `NotZerocopy`
|
note: required by a bound in `ValidityError`
--> $WORKSPACE/src/error.rs:588:45
|
588 | pub struct ValidityError<Src, Dst: ?Sized + TryFromBytes> {
| ^^^^^^^^^^^^ required by this bound in `ValidityError`
error[E0277]: the trait bound `NotZerocopy: TryFromBytes` is not satisfied
--> $DIR/try_transmute_mut.rs:18:63
|
18 | let dst_not_try_from_bytes: Result<&mut NotZerocopy, _> = try_transmute_mut!(src);
| ^^^^^^^^^^^^^^^^^^^^^^^ the trait `TryFromBytes` is not implemented for `NotZerocopy`
|
note: required by a bound in `ValidityError`
--> $WORKSPACE/src/error.rs:588:45
|
588 | pub struct ValidityError<Src, Dst: ?Sized + TryFromBytes> {
| ^^^^^^^^^^^^ required by this bound in `ValidityError`
= note: this error originates in the macro `try_transmute_mut` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0277]: the trait bound `SrcA: FromBytes` is not satisfied
--> $DIR/try_transmute_mut.rs:33:41
|
33 | let src_not_from_bytes: &mut DstA = try_transmute_mut!(&mut SrcA).unwrap();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `FromBytes` is not implemented for `SrcA`
|
= note: this error originates in the macro `try_transmute_mut` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0277]: the trait bound `DstA: IntoBytes` is not satisfied
--> $DIR/try_transmute_mut.rs:33:41
|
33 | let src_not_from_bytes: &mut DstA = try_transmute_mut!(&mut SrcA).unwrap();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `IntoBytes` is not implemented for `DstA`
|
= note: this error originates in the macro `try_transmute_mut` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0277]: the trait bound `SrcB: IntoBytes` is not satisfied
--> $DIR/try_transmute_mut.rs:46:41
|
46 | let src_not_from_bytes: &mut DstB = try_transmute_mut!(&mut SrcB).unwrap();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `IntoBytes` is not implemented for `SrcB`
|
= note: this error originates in the macro `try_transmute_mut` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0277]: the trait bound `DstB: IntoBytes` is not satisfied
--> $DIR/try_transmute_mut.rs:46:41
|
46 | let src_not_from_bytes: &mut DstB = try_transmute_mut!(&mut SrcB).unwrap();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `IntoBytes` is not implemented for `DstB`
|
= note: this error originates in the macro `try_transmute_mut` (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to 8 previous errors
For more information about this error, try `rustc --explain E0277`.

View File

@@ -0,0 +1,252 @@
error[E0277]: the trait bound `NotZerocopy: TryFromBytes` is not satisfied
--> $DIR/try_transmute_mut.rs:18:63
|
18 | let dst_not_try_from_bytes: Result<&mut NotZerocopy, _> = try_transmute_mut!(src);
| ^^^^^^^^^^^^^^^^^^^^^^^ unsatisfied trait bound
|
help: the trait `TryFromBytes` is not implemented for `NotZerocopy`
--> $DIR/../include.rs:15:5
|
15 | pub struct NotZerocopy<T = ()>(pub T);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: Consider adding `#[derive(TryFromBytes)]` to `NotZerocopy`
= help: the following other types implement trait `TryFromBytes`:
()
(A, B)
(A, B, C)
(A, B, C, D)
(A, B, C, D, E)
(A, B, C, D, E, F)
(A, B, C, D, E, F, G)
(A, B, C, D, E, F, G, H)
and 156 others
note: required by a bound in `zerocopy::util::macro_util::Wrap::<&'a mut Src, &'a mut Dst>::try_transmute_mut`
--> src/util/macro_util.rs:829:14
|
826 | pub fn try_transmute_mut(self) -> Result<&'a mut Dst, ValidityError<&'a mut Src, Dst>>
| ----------------- required by a bound in this associated function
...
829 | Dst: TryFromBytes + IntoBytes,
| ^^^^^^^^^^^^ required by this bound in `Wrap::<&mut Src, &mut Dst>::try_transmute_mut`
= note: this error originates in the macro `try_transmute_mut` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0277]: the trait bound `NotZerocopy: IntoBytes` is not satisfied
--> $DIR/try_transmute_mut.rs:18:63
|
18 | let dst_not_try_from_bytes: Result<&mut NotZerocopy, _> = try_transmute_mut!(src);
| ^^^^^^^^^^^^^^^^^^^^^^^ unsatisfied trait bound
|
help: the trait `IntoBytes` is not implemented for `NotZerocopy`
--> $DIR/../include.rs:15:5
|
15 | pub struct NotZerocopy<T = ()>(pub T);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: Consider adding `#[derive(IntoBytes)]` to `NotZerocopy`
= help: the following other types implement trait `IntoBytes`:
()
AU16
AtomicBool
AtomicI16
AtomicI32
AtomicI64
AtomicI8
AtomicIsize
and 69 others
note: required by a bound in `zerocopy::util::macro_util::Wrap::<&'a mut Src, &'a mut Dst>::try_transmute_mut`
--> src/util/macro_util.rs:829:29
|
826 | pub fn try_transmute_mut(self) -> Result<&'a mut Dst, ValidityError<&'a mut Src, Dst>>
| ----------------- required by a bound in this associated function
...
829 | Dst: TryFromBytes + IntoBytes,
| ^^^^^^^^^ required by this bound in `Wrap::<&mut Src, &mut Dst>::try_transmute_mut`
= note: this error originates in the macro `try_transmute_mut` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0277]: the trait bound `NotZerocopy: TryFromBytes` is not satisfied
--> $DIR/try_transmute_mut.rs:18:33
|
18 | let dst_not_try_from_bytes: Result<&mut NotZerocopy, _> = try_transmute_mut!(src);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ unsatisfied trait bound
|
help: the trait `TryFromBytes` is not implemented for `NotZerocopy`
--> $DIR/../include.rs:15:5
|
15 | pub struct NotZerocopy<T = ()>(pub T);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: Consider adding `#[derive(TryFromBytes)]` to `NotZerocopy`
= help: the following other types implement trait `TryFromBytes`:
()
(A, B)
(A, B, C)
(A, B, C, D)
(A, B, C, D, E)
(A, B, C, D, E, F)
(A, B, C, D, E, F, G)
(A, B, C, D, E, F, G, H)
and 156 others
note: required by a bound in `ValidityError`
--> src/error.rs:588:45
|
588 | pub struct ValidityError<Src, Dst: ?Sized + TryFromBytes> {
| ^^^^^^^^^^^^ required by this bound in `ValidityError`
error[E0277]: the trait bound `NotZerocopy: TryFromBytes` is not satisfied
--> $DIR/try_transmute_mut.rs:18:63
|
18 | let dst_not_try_from_bytes: Result<&mut NotZerocopy, _> = try_transmute_mut!(src);
| ^^^^^^^^^^^^^^^^^^^^^^^ unsatisfied trait bound
|
help: the trait `TryFromBytes` is not implemented for `NotZerocopy`
--> $DIR/../include.rs:15:5
|
15 | pub struct NotZerocopy<T = ()>(pub T);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: Consider adding `#[derive(TryFromBytes)]` to `NotZerocopy`
= help: the following other types implement trait `TryFromBytes`:
()
(A, B)
(A, B, C)
(A, B, C, D)
(A, B, C, D, E)
(A, B, C, D, E, F)
(A, B, C, D, E, F, G)
(A, B, C, D, E, F, G, H)
and 156 others
note: required by a bound in `ValidityError`
--> src/error.rs:588:45
|
588 | pub struct ValidityError<Src, Dst: ?Sized + TryFromBytes> {
| ^^^^^^^^^^^^ required by this bound in `ValidityError`
= note: this error originates in the macro `try_transmute_mut` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0277]: the trait bound `SrcA: FromBytes` is not satisfied
--> $DIR/try_transmute_mut.rs:33:41
|
33 | let src_not_from_bytes: &mut DstA = try_transmute_mut!(&mut SrcA).unwrap();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unsatisfied trait bound
|
help: the trait `FromBytes` is not implemented for `SrcA`
--> $DIR/try_transmute_mut.rs:26:5
|
26 | struct SrcA;
| ^^^^^^^^^^^
= note: Consider adding `#[derive(FromBytes)]` to `SrcA`
= help: the following other types implement trait `FromBytes`:
()
(A, B)
(A, B, C)
(A, B, C, D)
(A, B, C, D, E)
(A, B, C, D, E, F)
(A, B, C, D, E, F, G)
(A, B, C, D, E, F, G, H)
and 80 others
note: required by a bound in `zerocopy::util::macro_util::Wrap::<&'a mut Src, &'a mut Dst>::try_transmute_mut`
--> src/util/macro_util.rs:828:14
|
826 | pub fn try_transmute_mut(self) -> Result<&'a mut Dst, ValidityError<&'a mut Src, Dst>>
| ----------------- required by a bound in this associated function
827 | where
828 | Src: FromBytes + IntoBytes,
| ^^^^^^^^^ required by this bound in `Wrap::<&mut Src, &mut Dst>::try_transmute_mut`
= note: this error originates in the macro `try_transmute_mut` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0277]: the trait bound `DstA: IntoBytes` is not satisfied
--> $DIR/try_transmute_mut.rs:33:41
|
33 | let src_not_from_bytes: &mut DstA = try_transmute_mut!(&mut SrcA).unwrap();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unsatisfied trait bound
|
help: the trait `IntoBytes` is not implemented for `DstA`
--> $DIR/try_transmute_mut.rs:30:5
|
30 | struct DstA;
| ^^^^^^^^^^^
= note: Consider adding `#[derive(IntoBytes)]` to `DstA`
= help: the following other types implement trait `IntoBytes`:
()
AU16
AtomicBool
AtomicI16
AtomicI32
AtomicI64
AtomicI8
AtomicIsize
and 69 others
note: required by a bound in `zerocopy::util::macro_util::Wrap::<&'a mut Src, &'a mut Dst>::try_transmute_mut`
--> src/util/macro_util.rs:829:29
|
826 | pub fn try_transmute_mut(self) -> Result<&'a mut Dst, ValidityError<&'a mut Src, Dst>>
| ----------------- required by a bound in this associated function
...
829 | Dst: TryFromBytes + IntoBytes,
| ^^^^^^^^^ required by this bound in `Wrap::<&mut Src, &mut Dst>::try_transmute_mut`
= note: this error originates in the macro `try_transmute_mut` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0277]: the trait bound `SrcB: IntoBytes` is not satisfied
--> $DIR/try_transmute_mut.rs:46:41
|
46 | let src_not_from_bytes: &mut DstB = try_transmute_mut!(&mut SrcB).unwrap();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unsatisfied trait bound
|
help: the trait `IntoBytes` is not implemented for `SrcB`
--> $DIR/try_transmute_mut.rs:39:5
|
39 | struct SrcB;
| ^^^^^^^^^^^
= note: Consider adding `#[derive(IntoBytes)]` to `SrcB`
= help: the following other types implement trait `IntoBytes`:
()
AU16
AtomicBool
AtomicI16
AtomicI32
AtomicI64
AtomicI8
AtomicIsize
and 69 others
note: required by a bound in `zerocopy::util::macro_util::Wrap::<&'a mut Src, &'a mut Dst>::try_transmute_mut`
--> src/util/macro_util.rs:828:26
|
826 | pub fn try_transmute_mut(self) -> Result<&'a mut Dst, ValidityError<&'a mut Src, Dst>>
| ----------------- required by a bound in this associated function
827 | where
828 | Src: FromBytes + IntoBytes,
| ^^^^^^^^^ required by this bound in `Wrap::<&mut Src, &mut Dst>::try_transmute_mut`
= note: this error originates in the macro `try_transmute_mut` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0277]: the trait bound `DstB: IntoBytes` is not satisfied
--> $DIR/try_transmute_mut.rs:46:41
|
46 | let src_not_from_bytes: &mut DstB = try_transmute_mut!(&mut SrcB).unwrap();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unsatisfied trait bound
|
help: the trait `IntoBytes` is not implemented for `DstB`
--> $DIR/try_transmute_mut.rs:43:5
|
43 | struct DstB;
| ^^^^^^^^^^^
= note: Consider adding `#[derive(IntoBytes)]` to `DstB`
= help: the following other types implement trait `IntoBytes`:
()
AU16
AtomicBool
AtomicI16
AtomicI32
AtomicI64
AtomicI8
AtomicIsize
and 69 others
note: required by a bound in `zerocopy::util::macro_util::Wrap::<&'a mut Src, &'a mut Dst>::try_transmute_mut`
--> src/util/macro_util.rs:829:29
|
826 | pub fn try_transmute_mut(self) -> Result<&'a mut Dst, ValidityError<&'a mut Src, Dst>>
| ----------------- required by a bound in this associated function
...
829 | Dst: TryFromBytes + IntoBytes,
| ^^^^^^^^^ required by this bound in `Wrap::<&mut Src, &mut Dst>::try_transmute_mut`
= note: this error originates in the macro `try_transmute_mut` (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to 8 previous errors
For more information about this error, try `rustc --explain E0277`.

View File

@@ -0,0 +1,49 @@
// Copyright 2024 The Fuchsia Authors
//
// Licensed under a BSD-style license <LICENSE-BSD>, Apache License, Version 2.0
// <LICENSE-APACHE or https://www.apache.org/licenses/LICENSE-2.0>, or the MIT
// license <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your option.
// This file may not be copied, modified, or distributed except according to
// those terms.
include!("../include.rs");
use util::{NotZerocopy, AU16};
use zerocopy::try_transmute_mut;
fn main() {
// `try_transmute_mut` requires that the destination type implements
// `IntoBytes`
let src = &mut AU16(0);
let dst_not_try_from_bytes: Result<&mut NotZerocopy, _> = try_transmute_mut!(src);
//~[msrv, stable, nightly]^ ERROR: the trait bound `NotZerocopy: TryFromBytes` is not satisfied
//~[msrv, stable, nightly]^^ ERROR: the trait bound `NotZerocopy: TryFromBytes` is not satisfied
//~[msrv, stable, nightly]^^^ ERROR: the trait bound `NotZerocopy: TryFromBytes` is not satisfied
//~[msrv, stable, nightly]^^^^ ERROR: the trait bound `NotZerocopy: IntoBytes` is not satisfied
#[derive(zerocopy::IntoBytes)]
#[repr(C)]
struct SrcA;
#[derive(zerocopy::TryFromBytes)]
#[repr(C)]
struct DstA;
// `try_transmute_mut` requires that the source type implements `FromBytes`
let src_not_from_bytes: &mut DstA = try_transmute_mut!(&mut SrcA).unwrap();
//~[msrv, stable, nightly]^ ERROR: the trait bound `SrcA: FromBytes` is not satisfied
//~[msrv, stable, nightly]^^ ERROR: the trait bound `DstA: IntoBytes` is not satisfied
#[derive(zerocopy::FromBytes)]
#[repr(C)]
struct SrcB;
#[derive(zerocopy::TryFromBytes)]
#[repr(C)]
struct DstB;
// `try_transmute_mut` requires that the source type implements `IntoBytes`
let src_not_from_bytes: &mut DstB = try_transmute_mut!(&mut SrcB).unwrap();
//~[msrv, stable, nightly]^ ERROR: the trait bound `SrcB: IntoBytes` is not satisfied
//~[msrv, stable, nightly]^^ ERROR: the trait bound `DstB: IntoBytes` is not satisfied
}

View File

@@ -0,0 +1,252 @@
error[E0277]: the trait bound `NotZerocopy: TryFromBytes` is not satisfied
--> $DIR/try_transmute_mut.rs:18:63
|
18 | let dst_not_try_from_bytes: Result<&mut NotZerocopy, _> = try_transmute_mut!(src);
| ^^^^^^^^^^^^^^^^^^^^^^^ unsatisfied trait bound
|
help: the trait `TryFromBytes` is not implemented for `NotZerocopy`
--> $DIR/../include.rs:15:5
|
15 | pub struct NotZerocopy<T = ()>(pub T);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: Consider adding `#[derive(TryFromBytes)]` to `NotZerocopy`
= help: the following other types implement trait `TryFromBytes`:
()
(A, B)
(A, B, C)
(A, B, C, D)
(A, B, C, D, E)
(A, B, C, D, E, F)
(A, B, C, D, E, F, G)
(A, B, C, D, E, F, G, H)
and 156 others
note: required by a bound in `Wrap::<&'a mut Src, &'a mut Dst>::try_transmute_mut`
--> $WORKSPACE/src/util/macro_util.rs:829:14
|
826 | pub fn try_transmute_mut(self) -> Result<&'a mut Dst, ValidityError<&'a mut Src, Dst>>
| ----------------- required by a bound in this associated function
...
829 | Dst: TryFromBytes + IntoBytes,
| ^^^^^^^^^^^^ required by this bound in `Wrap::<&mut Src, &mut Dst>::try_transmute_mut`
= note: this error originates in the macro `try_transmute_mut` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0277]: the trait bound `NotZerocopy: IntoBytes` is not satisfied
--> $DIR/try_transmute_mut.rs:18:63
|
18 | let dst_not_try_from_bytes: Result<&mut NotZerocopy, _> = try_transmute_mut!(src);
| ^^^^^^^^^^^^^^^^^^^^^^^ unsatisfied trait bound
|
help: the trait `IntoBytes` is not implemented for `NotZerocopy`
--> $DIR/../include.rs:15:5
|
15 | pub struct NotZerocopy<T = ()>(pub T);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: Consider adding `#[derive(IntoBytes)]` to `NotZerocopy`
= help: the following other types implement trait `IntoBytes`:
()
AU16
AtomicBool
AtomicI16
AtomicI32
AtomicI64
AtomicI8
AtomicIsize
and 69 others
note: required by a bound in `Wrap::<&'a mut Src, &'a mut Dst>::try_transmute_mut`
--> $WORKSPACE/src/util/macro_util.rs:829:29
|
826 | pub fn try_transmute_mut(self) -> Result<&'a mut Dst, ValidityError<&'a mut Src, Dst>>
| ----------------- required by a bound in this associated function
...
829 | Dst: TryFromBytes + IntoBytes,
| ^^^^^^^^^ required by this bound in `Wrap::<&mut Src, &mut Dst>::try_transmute_mut`
= note: this error originates in the macro `try_transmute_mut` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0277]: the trait bound `NotZerocopy: TryFromBytes` is not satisfied
--> $DIR/try_transmute_mut.rs:18:33
|
18 | let dst_not_try_from_bytes: Result<&mut NotZerocopy, _> = try_transmute_mut!(src);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ unsatisfied trait bound
|
help: the trait `TryFromBytes` is not implemented for `NotZerocopy`
--> $DIR/../include.rs:15:5
|
15 | pub struct NotZerocopy<T = ()>(pub T);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: Consider adding `#[derive(TryFromBytes)]` to `NotZerocopy`
= help: the following other types implement trait `TryFromBytes`:
()
(A, B)
(A, B, C)
(A, B, C, D)
(A, B, C, D, E)
(A, B, C, D, E, F)
(A, B, C, D, E, F, G)
(A, B, C, D, E, F, G, H)
and 156 others
note: required by a bound in `ValidityError`
--> $WORKSPACE/src/error.rs:588:45
|
588 | pub struct ValidityError<Src, Dst: ?Sized + TryFromBytes> {
| ^^^^^^^^^^^^ required by this bound in `ValidityError`
error[E0277]: the trait bound `NotZerocopy: TryFromBytes` is not satisfied
--> $DIR/try_transmute_mut.rs:18:63
|
18 | let dst_not_try_from_bytes: Result<&mut NotZerocopy, _> = try_transmute_mut!(src);
| ^^^^^^^^^^^^^^^^^^^^^^^ unsatisfied trait bound
|
help: the trait `TryFromBytes` is not implemented for `NotZerocopy`
--> $DIR/../include.rs:15:5
|
15 | pub struct NotZerocopy<T = ()>(pub T);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: Consider adding `#[derive(TryFromBytes)]` to `NotZerocopy`
= help: the following other types implement trait `TryFromBytes`:
()
(A, B)
(A, B, C)
(A, B, C, D)
(A, B, C, D, E)
(A, B, C, D, E, F)
(A, B, C, D, E, F, G)
(A, B, C, D, E, F, G, H)
and 156 others
note: required by a bound in `ValidityError`
--> $WORKSPACE/src/error.rs:588:45
|
588 | pub struct ValidityError<Src, Dst: ?Sized + TryFromBytes> {
| ^^^^^^^^^^^^ required by this bound in `ValidityError`
= note: this error originates in the macro `try_transmute_mut` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0277]: the trait bound `SrcA: FromBytes` is not satisfied
--> $DIR/try_transmute_mut.rs:33:41
|
33 | let src_not_from_bytes: &mut DstA = try_transmute_mut!(&mut SrcA).unwrap();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unsatisfied trait bound
|
help: the trait `FromBytes` is not implemented for `SrcA`
--> $DIR/try_transmute_mut.rs:26:5
|
26 | struct SrcA;
| ^^^^^^^^^^^
= note: Consider adding `#[derive(FromBytes)]` to `SrcA`
= help: the following other types implement trait `FromBytes`:
()
(A, B)
(A, B, C)
(A, B, C, D)
(A, B, C, D, E)
(A, B, C, D, E, F)
(A, B, C, D, E, F, G)
(A, B, C, D, E, F, G, H)
and 80 others
note: required by a bound in `Wrap::<&'a mut Src, &'a mut Dst>::try_transmute_mut`
--> $WORKSPACE/src/util/macro_util.rs:828:14
|
826 | pub fn try_transmute_mut(self) -> Result<&'a mut Dst, ValidityError<&'a mut Src, Dst>>
| ----------------- required by a bound in this associated function
827 | where
828 | Src: FromBytes + IntoBytes,
| ^^^^^^^^^ required by this bound in `Wrap::<&mut Src, &mut Dst>::try_transmute_mut`
= note: this error originates in the macro `try_transmute_mut` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0277]: the trait bound `DstA: IntoBytes` is not satisfied
--> $DIR/try_transmute_mut.rs:33:41
|
33 | let src_not_from_bytes: &mut DstA = try_transmute_mut!(&mut SrcA).unwrap();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unsatisfied trait bound
|
help: the trait `IntoBytes` is not implemented for `DstA`
--> $DIR/try_transmute_mut.rs:30:5
|
30 | struct DstA;
| ^^^^^^^^^^^
= note: Consider adding `#[derive(IntoBytes)]` to `DstA`
= help: the following other types implement trait `IntoBytes`:
()
AU16
AtomicBool
AtomicI16
AtomicI32
AtomicI64
AtomicI8
AtomicIsize
and 69 others
note: required by a bound in `Wrap::<&'a mut Src, &'a mut Dst>::try_transmute_mut`
--> $WORKSPACE/src/util/macro_util.rs:829:29
|
826 | pub fn try_transmute_mut(self) -> Result<&'a mut Dst, ValidityError<&'a mut Src, Dst>>
| ----------------- required by a bound in this associated function
...
829 | Dst: TryFromBytes + IntoBytes,
| ^^^^^^^^^ required by this bound in `Wrap::<&mut Src, &mut Dst>::try_transmute_mut`
= note: this error originates in the macro `try_transmute_mut` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0277]: the trait bound `SrcB: IntoBytes` is not satisfied
--> $DIR/try_transmute_mut.rs:46:41
|
46 | let src_not_from_bytes: &mut DstB = try_transmute_mut!(&mut SrcB).unwrap();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unsatisfied trait bound
|
help: the trait `IntoBytes` is not implemented for `SrcB`
--> $DIR/try_transmute_mut.rs:39:5
|
39 | struct SrcB;
| ^^^^^^^^^^^
= note: Consider adding `#[derive(IntoBytes)]` to `SrcB`
= help: the following other types implement trait `IntoBytes`:
()
AU16
AtomicBool
AtomicI16
AtomicI32
AtomicI64
AtomicI8
AtomicIsize
and 69 others
note: required by a bound in `Wrap::<&'a mut Src, &'a mut Dst>::try_transmute_mut`
--> $WORKSPACE/src/util/macro_util.rs:828:26
|
826 | pub fn try_transmute_mut(self) -> Result<&'a mut Dst, ValidityError<&'a mut Src, Dst>>
| ----------------- required by a bound in this associated function
827 | where
828 | Src: FromBytes + IntoBytes,
| ^^^^^^^^^ required by this bound in `Wrap::<&mut Src, &mut Dst>::try_transmute_mut`
= note: this error originates in the macro `try_transmute_mut` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0277]: the trait bound `DstB: IntoBytes` is not satisfied
--> $DIR/try_transmute_mut.rs:46:41
|
46 | let src_not_from_bytes: &mut DstB = try_transmute_mut!(&mut SrcB).unwrap();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unsatisfied trait bound
|
help: the trait `IntoBytes` is not implemented for `DstB`
--> $DIR/try_transmute_mut.rs:43:5
|
43 | struct DstB;
| ^^^^^^^^^^^
= note: Consider adding `#[derive(IntoBytes)]` to `DstB`
= help: the following other types implement trait `IntoBytes`:
()
AU16
AtomicBool
AtomicI16
AtomicI32
AtomicI64
AtomicI8
AtomicIsize
and 69 others
note: required by a bound in `Wrap::<&'a mut Src, &'a mut Dst>::try_transmute_mut`
--> $WORKSPACE/src/util/macro_util.rs:829:29
|
826 | pub fn try_transmute_mut(self) -> Result<&'a mut Dst, ValidityError<&'a mut Src, Dst>>
| ----------------- required by a bound in this associated function
...
829 | Dst: TryFromBytes + IntoBytes,
| ^^^^^^^^^ required by this bound in `Wrap::<&mut Src, &mut Dst>::try_transmute_mut`
= note: this error originates in the macro `try_transmute_mut` (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to 8 previous errors
For more information about this error, try `rustc --explain E0277`.

View File

@@ -0,0 +1,84 @@
error[E0308]: mismatched types
--> $DIR/try_transmute_ref.rs:19:33
|
19 | let _: Result<&mut u8, _> = try_transmute_ref!(&0u8);
| ^^^^^^^^^^^^^^^^^^^^^^^^ types differ in mutability
|
= note: expected mutable reference `&mut u8`
found reference `&_`
= note: this error originates in the macro `try_transmute_ref` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0308]: mismatched types
--> $DIR/try_transmute_ref.rs:19:33
|
19 | let _: Result<&mut u8, _> = try_transmute_ref!(&0u8);
| ^^^^^^^^^^^^^^^^^^^^^^^^
| |
| types differ in mutability
| help: try using a variant of the expected enum: `Err(t.try_transmute_ref())`
|
= note: expected enum `Result<&mut u8, _>`
found enum `Result<&_, ValidityError<&u8, _>>`
= note: this error originates in the macro `try_transmute_ref` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0277]: the trait bound `NotZerocopy: TryFromBytes` is not satisfied
--> $DIR/try_transmute_ref.rs:25:59
|
25 | let dst_not_try_from_bytes: Result<&NotZerocopy, _> = try_transmute_ref!(&AU16(0));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `TryFromBytes` is not implemented for `NotZerocopy`
|
= note: this error originates in the macro `try_transmute_ref` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0277]: the trait bound `NotZerocopy: Immutable` is not satisfied
--> $DIR/try_transmute_ref.rs:25:59
|
25 | let dst_not_try_from_bytes: Result<&NotZerocopy, _> = try_transmute_ref!(&AU16(0));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Immutable` is not implemented for `NotZerocopy`
|
= note: this error originates in the macro `try_transmute_ref` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0277]: the trait bound `NotZerocopy: TryFromBytes` is not satisfied
--> $DIR/try_transmute_ref.rs:25:33
|
25 | let dst_not_try_from_bytes: Result<&NotZerocopy, _> = try_transmute_ref!(&AU16(0));
| ^^^^^^^^^^^^^^^^^^^^^^^ the trait `TryFromBytes` is not implemented for `NotZerocopy`
|
note: required by a bound in `ValidityError`
--> $WORKSPACE/src/error.rs:588:45
|
588 | pub struct ValidityError<Src, Dst: ?Sized + TryFromBytes> {
| ^^^^^^^^^^^^ required by this bound in `ValidityError`
error[E0277]: the trait bound `NotZerocopy: TryFromBytes` is not satisfied
--> $DIR/try_transmute_ref.rs:25:59
|
25 | let dst_not_try_from_bytes: Result<&NotZerocopy, _> = try_transmute_ref!(&AU16(0));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `TryFromBytes` is not implemented for `NotZerocopy`
|
note: required by a bound in `ValidityError`
--> $WORKSPACE/src/error.rs:588:45
|
588 | pub struct ValidityError<Src, Dst: ?Sized + TryFromBytes> {
| ^^^^^^^^^^^^ required by this bound in `ValidityError`
= note: this error originates in the macro `try_transmute_ref` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0277]: the trait bound `NotZerocopy<AU16>: IntoBytes` is not satisfied
--> $DIR/try_transmute_ref.rs:33:48
|
33 | let src_not_into_bytes: Result<&AU16, _> = try_transmute_ref!(&NotZerocopy(AU16(0)));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `IntoBytes` is not implemented for `NotZerocopy<AU16>`
|
= note: this error originates in the macro `try_transmute_ref` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0277]: the trait bound `NotZerocopy<AU16>: Immutable` is not satisfied
--> $DIR/try_transmute_ref.rs:33:48
|
33 | let src_not_into_bytes: Result<&AU16, _> = try_transmute_ref!(&NotZerocopy(AU16(0)));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Immutable` is not implemented for `NotZerocopy<AU16>`
|
= note: this error originates in the macro `try_transmute_ref` (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to 8 previous errors
Some errors have detailed explanations: E0277, E0308.
For more information about an error, try `rustc --explain E0277`.

View File

@@ -0,0 +1,206 @@
error[E0308]: mismatched types
--> tests$RUSTUP_TOOLCHAIN/lib/rustlib/src/rust/library/core/src/result.rs:561:5
|
561 | Ok(#[stable(feature = "rust1", since = "1.0.0")] T),
| ^^
= note: this error originates in the macro `try_transmute_ref` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0308]: mismatched types
--> $DIR/try_transmute_ref.rs:19:33
|
19 | let _: Result<&mut u8, _> = try_transmute_ref!(&0u8);
| ^^^^^^^^^^^^^^^^^^^^^^^^ types differ in mutability
|
= note: expected enum `Result<&mut u8, _>`
found enum `Result<&_, ValidityError<&u8, _>>`
= note: this error originates in the macro `try_transmute_ref` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0277]: the trait bound `NotZerocopy: TryFromBytes` is not satisfied
--> $DIR/try_transmute_ref.rs:25:59
|
25 | let dst_not_try_from_bytes: Result<&NotZerocopy, _> = try_transmute_ref!(&AU16(0));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unsatisfied trait bound
|
help: the trait `TryFromBytes` is not implemented for `NotZerocopy`
--> $DIR/../include.rs:15:5
|
15 | pub struct NotZerocopy<T = ()>(pub T);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: Consider adding `#[derive(TryFromBytes)]` to `NotZerocopy`
= help: the following other types implement trait `TryFromBytes`:
()
(A, B)
(A, B, C)
(A, B, C, D)
(A, B, C, D, E)
(A, B, C, D, E, F)
(A, B, C, D, E, F, G)
(A, B, C, D, E, F, G, H)
and 153 others
note: required by a bound in `zerocopy::util::macro_util::Wrap::<&'a Src, &'a Dst>::try_transmute_ref`
--> src/util/macro_util.rs:755:14
|
752 | pub fn try_transmute_ref(self) -> Result<&'a Dst, ValidityError<&'a Src, Dst>>
| ----------------- required by a bound in this associated function
...
755 | Dst: TryFromBytes + Immutable,
| ^^^^^^^^^^^^ required by this bound in `Wrap::<&Src, &Dst>::try_transmute_ref`
= note: this error originates in the macro `try_transmute_ref` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0277]: the trait bound `NotZerocopy: Immutable` is not satisfied
--> $DIR/try_transmute_ref.rs:25:59
|
25 | let dst_not_try_from_bytes: Result<&NotZerocopy, _> = try_transmute_ref!(&AU16(0));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unsatisfied trait bound
|
help: the trait `Immutable` is not implemented for `NotZerocopy`
--> $DIR/../include.rs:15:5
|
15 | pub struct NotZerocopy<T = ()>(pub T);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: Consider adding `#[derive(Immutable)]` to `NotZerocopy`
= help: the following other types implement trait `Immutable`:
&T
&mut T
()
(A, B)
(A, B, C)
(A, B, C, D)
(A, B, C, D, E)
(A, B, C, D, E, F)
and 128 others
note: required by a bound in `zerocopy::util::macro_util::Wrap::<&'a Src, &'a Dst>::try_transmute_ref`
--> src/util/macro_util.rs:755:29
|
752 | pub fn try_transmute_ref(self) -> Result<&'a Dst, ValidityError<&'a Src, Dst>>
| ----------------- required by a bound in this associated function
...
755 | Dst: TryFromBytes + Immutable,
| ^^^^^^^^^ required by this bound in `Wrap::<&Src, &Dst>::try_transmute_ref`
= note: this error originates in the macro `try_transmute_ref` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0277]: the trait bound `NotZerocopy: TryFromBytes` is not satisfied
--> $DIR/try_transmute_ref.rs:25:33
|
25 | let dst_not_try_from_bytes: Result<&NotZerocopy, _> = try_transmute_ref!(&AU16(0));
| ^^^^^^^^^^^^^^^^^^^^^^^ unsatisfied trait bound
|
help: the trait `TryFromBytes` is not implemented for `NotZerocopy`
--> $DIR/../include.rs:15:5
|
15 | pub struct NotZerocopy<T = ()>(pub T);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: Consider adding `#[derive(TryFromBytes)]` to `NotZerocopy`
= help: the following other types implement trait `TryFromBytes`:
()
(A, B)
(A, B, C)
(A, B, C, D)
(A, B, C, D, E)
(A, B, C, D, E, F)
(A, B, C, D, E, F, G)
(A, B, C, D, E, F, G, H)
and 153 others
note: required by a bound in `ValidityError`
--> src/error.rs:588:45
|
588 | pub struct ValidityError<Src, Dst: ?Sized + TryFromBytes> {
| ^^^^^^^^^^^^ required by this bound in `ValidityError`
error[E0277]: the trait bound `NotZerocopy: TryFromBytes` is not satisfied
--> $DIR/try_transmute_ref.rs:25:59
|
25 | let dst_not_try_from_bytes: Result<&NotZerocopy, _> = try_transmute_ref!(&AU16(0));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unsatisfied trait bound
|
help: the trait `TryFromBytes` is not implemented for `NotZerocopy`
--> $DIR/../include.rs:15:5
|
15 | pub struct NotZerocopy<T = ()>(pub T);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: Consider adding `#[derive(TryFromBytes)]` to `NotZerocopy`
= help: the following other types implement trait `TryFromBytes`:
()
(A, B)
(A, B, C)
(A, B, C, D)
(A, B, C, D, E)
(A, B, C, D, E, F)
(A, B, C, D, E, F, G)
(A, B, C, D, E, F, G, H)
and 153 others
note: required by a bound in `ValidityError`
--> src/error.rs:588:45
|
588 | pub struct ValidityError<Src, Dst: ?Sized + TryFromBytes> {
| ^^^^^^^^^^^^ required by this bound in `ValidityError`
= note: this error originates in the macro `try_transmute_ref` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0277]: the trait bound `NotZerocopy<AU16>: IntoBytes` is not satisfied
--> $DIR/try_transmute_ref.rs:33:48
|
33 | let src_not_into_bytes: Result<&AU16, _> = try_transmute_ref!(&NotZerocopy(AU16(0)));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unsatisfied trait bound
|
help: the trait `IntoBytes` is not implemented for `NotZerocopy<AU16>`
--> $DIR/../include.rs:15:5
|
15 | pub struct NotZerocopy<T = ()>(pub T);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: Consider adding `#[derive(IntoBytes)]` to `NotZerocopy<AU16>`
= help: the following other types implement trait `IntoBytes`:
()
AU16
AtomicBool
AtomicI16
AtomicI32
AtomicI64
AtomicI8
AtomicIsize
and 68 others
note: required by a bound in `zerocopy::util::macro_util::Wrap::<&'a Src, &'a Dst>::try_transmute_ref`
--> src/util/macro_util.rs:754:14
|
752 | pub fn try_transmute_ref(self) -> Result<&'a Dst, ValidityError<&'a Src, Dst>>
| ----------------- required by a bound in this associated function
753 | where
754 | Src: IntoBytes + Immutable,
| ^^^^^^^^^ required by this bound in `Wrap::<&Src, &Dst>::try_transmute_ref`
= note: this error originates in the macro `try_transmute_ref` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0277]: the trait bound `NotZerocopy<AU16>: Immutable` is not satisfied
--> $DIR/try_transmute_ref.rs:33:48
|
33 | let src_not_into_bytes: Result<&AU16, _> = try_transmute_ref!(&NotZerocopy(AU16(0)));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unsatisfied trait bound
|
help: the trait `Immutable` is not implemented for `NotZerocopy<AU16>`
--> $DIR/../include.rs:15:5
|
15 | pub struct NotZerocopy<T = ()>(pub T);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: Consider adding `#[derive(Immutable)]` to `NotZerocopy<AU16>`
= help: the following other types implement trait `Immutable`:
&T
&mut T
()
(A, B)
(A, B, C)
(A, B, C, D)
(A, B, C, D, E)
(A, B, C, D, E, F)
and 128 others
note: required by a bound in `zerocopy::util::macro_util::Wrap::<&'a Src, &'a Dst>::try_transmute_ref`
--> src/util/macro_util.rs:754:26
|
752 | pub fn try_transmute_ref(self) -> Result<&'a Dst, ValidityError<&'a Src, Dst>>
| ----------------- required by a bound in this associated function
753 | where
754 | Src: IntoBytes + Immutable,
| ^^^^^^^^^ required by this bound in `Wrap::<&Src, &Dst>::try_transmute_ref`
= note: this error originates in the macro `try_transmute_ref` (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to 8 previous errors
Some errors have detailed explanations: E0277, E0308.
For more information about an error, try `rustc --explain E0277`.

View File

@@ -0,0 +1,36 @@
// Copyright 2024 The Fuchsia Authors
//
// Licensed under a BSD-style license <LICENSE-BSD>, Apache License, Version 2.0
// <LICENSE-APACHE or https://www.apache.org/licenses/LICENSE-2.0>, or the MIT
// license <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your option.
// This file may not be copied, modified, or distributed except according to
// those terms.
include!("../include.rs");
use util::{NotZerocopy, AU16};
use zerocopy::try_transmute_ref;
fn main() {}
fn ref_dst_mutable() {
// `try_transmute_ref!` requires that its destination type be an immutable
// reference.
let _: Result<&mut u8, _> = try_transmute_ref!(&0u8);
//~[msrv, stable, nightly]^ ERROR: mismatched types
//~[msrv, stable, nightly]^^ ERROR: mismatched types
// `try_transmute_ref` requires that the source type implements `Immutable`
// and `IntoBytes`
let dst_not_try_from_bytes: Result<&NotZerocopy, _> = try_transmute_ref!(&AU16(0));
//~[msrv, stable, nightly]^ ERROR: the trait bound `NotZerocopy: TryFromBytes` is not satisfied
//~[msrv, stable, nightly]^^ ERROR: the trait bound `NotZerocopy: TryFromBytes` is not satisfied
//~[msrv, stable, nightly]^^^ ERROR: the trait bound `NotZerocopy: TryFromBytes` is not satisfied
//~[msrv, stable, nightly]^^^^ ERROR: the trait bound `NotZerocopy: Immutable` is not satisfied
// `try_transmute_ref` requires that the source type implements `Immutable`
// and `IntoBytes`
let src_not_into_bytes: Result<&AU16, _> = try_transmute_ref!(&NotZerocopy(AU16(0)));
//~[msrv, stable, nightly]^ ERROR: the trait bound `NotZerocopy<AU16>: IntoBytes` is not satisfied
//~[msrv, stable, nightly]^^ ERROR: the trait bound `NotZerocopy<AU16>: Immutable` is not satisfied
}

View File

@@ -0,0 +1,206 @@
error[E0308]: mismatched types
--> tests$RUSTUP_TOOLCHAIN/lib/rustlib/src/rust/library/core/src/result.rs:561:5
|
561 | Ok(#[stable(feature = "rust1", since = "1.0.0")] T),
| ^^
= note: this error originates in the macro `try_transmute_ref` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0308]: mismatched types
--> $DIR/try_transmute_ref.rs:19:33
|
19 | let _: Result<&mut u8, _> = try_transmute_ref!(&0u8);
| ^^^^^^^^^^^^^^^^^^^^^^^^ types differ in mutability
|
= note: expected enum `Result<&mut u8, _>`
found enum `Result<&_, ValidityError<&u8, _>>`
= note: this error originates in the macro `try_transmute_ref` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0277]: the trait bound `NotZerocopy: TryFromBytes` is not satisfied
--> $DIR/try_transmute_ref.rs:25:59
|
25 | let dst_not_try_from_bytes: Result<&NotZerocopy, _> = try_transmute_ref!(&AU16(0));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unsatisfied trait bound
|
help: the trait `TryFromBytes` is not implemented for `NotZerocopy`
--> $DIR/../include.rs:15:5
|
15 | pub struct NotZerocopy<T = ()>(pub T);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: Consider adding `#[derive(TryFromBytes)]` to `NotZerocopy`
= help: the following other types implement trait `TryFromBytes`:
()
(A, B)
(A, B, C)
(A, B, C, D)
(A, B, C, D, E)
(A, B, C, D, E, F)
(A, B, C, D, E, F, G)
(A, B, C, D, E, F, G, H)
and 153 others
note: required by a bound in `Wrap::<&'a Src, &'a Dst>::try_transmute_ref`
--> $WORKSPACE/src/util/macro_util.rs:755:14
|
752 | pub fn try_transmute_ref(self) -> Result<&'a Dst, ValidityError<&'a Src, Dst>>
| ----------------- required by a bound in this associated function
...
755 | Dst: TryFromBytes + Immutable,
| ^^^^^^^^^^^^ required by this bound in `Wrap::<&Src, &Dst>::try_transmute_ref`
= note: this error originates in the macro `try_transmute_ref` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0277]: the trait bound `NotZerocopy: Immutable` is not satisfied
--> $DIR/try_transmute_ref.rs:25:59
|
25 | let dst_not_try_from_bytes: Result<&NotZerocopy, _> = try_transmute_ref!(&AU16(0));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unsatisfied trait bound
|
help: the trait `Immutable` is not implemented for `NotZerocopy`
--> $DIR/../include.rs:15:5
|
15 | pub struct NotZerocopy<T = ()>(pub T);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: Consider adding `#[derive(Immutable)]` to `NotZerocopy`
= help: the following other types implement trait `Immutable`:
&T
&mut T
()
(A, B)
(A, B, C)
(A, B, C, D)
(A, B, C, D, E)
(A, B, C, D, E, F)
and 128 others
note: required by a bound in `Wrap::<&'a Src, &'a Dst>::try_transmute_ref`
--> $WORKSPACE/src/util/macro_util.rs:755:29
|
752 | pub fn try_transmute_ref(self) -> Result<&'a Dst, ValidityError<&'a Src, Dst>>
| ----------------- required by a bound in this associated function
...
755 | Dst: TryFromBytes + Immutable,
| ^^^^^^^^^ required by this bound in `Wrap::<&Src, &Dst>::try_transmute_ref`
= note: this error originates in the macro `try_transmute_ref` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0277]: the trait bound `NotZerocopy: TryFromBytes` is not satisfied
--> $DIR/try_transmute_ref.rs:25:33
|
25 | let dst_not_try_from_bytes: Result<&NotZerocopy, _> = try_transmute_ref!(&AU16(0));
| ^^^^^^^^^^^^^^^^^^^^^^^ unsatisfied trait bound
|
help: the trait `TryFromBytes` is not implemented for `NotZerocopy`
--> $DIR/../include.rs:15:5
|
15 | pub struct NotZerocopy<T = ()>(pub T);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: Consider adding `#[derive(TryFromBytes)]` to `NotZerocopy`
= help: the following other types implement trait `TryFromBytes`:
()
(A, B)
(A, B, C)
(A, B, C, D)
(A, B, C, D, E)
(A, B, C, D, E, F)
(A, B, C, D, E, F, G)
(A, B, C, D, E, F, G, H)
and 153 others
note: required by a bound in `ValidityError`
--> $WORKSPACE/src/error.rs:588:45
|
588 | pub struct ValidityError<Src, Dst: ?Sized + TryFromBytes> {
| ^^^^^^^^^^^^ required by this bound in `ValidityError`
error[E0277]: the trait bound `NotZerocopy: TryFromBytes` is not satisfied
--> $DIR/try_transmute_ref.rs:25:59
|
25 | let dst_not_try_from_bytes: Result<&NotZerocopy, _> = try_transmute_ref!(&AU16(0));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unsatisfied trait bound
|
help: the trait `TryFromBytes` is not implemented for `NotZerocopy`
--> $DIR/../include.rs:15:5
|
15 | pub struct NotZerocopy<T = ()>(pub T);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: Consider adding `#[derive(TryFromBytes)]` to `NotZerocopy`
= help: the following other types implement trait `TryFromBytes`:
()
(A, B)
(A, B, C)
(A, B, C, D)
(A, B, C, D, E)
(A, B, C, D, E, F)
(A, B, C, D, E, F, G)
(A, B, C, D, E, F, G, H)
and 153 others
note: required by a bound in `ValidityError`
--> $WORKSPACE/src/error.rs:588:45
|
588 | pub struct ValidityError<Src, Dst: ?Sized + TryFromBytes> {
| ^^^^^^^^^^^^ required by this bound in `ValidityError`
= note: this error originates in the macro `try_transmute_ref` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0277]: the trait bound `NotZerocopy<AU16>: IntoBytes` is not satisfied
--> $DIR/try_transmute_ref.rs:33:48
|
33 | let src_not_into_bytes: Result<&AU16, _> = try_transmute_ref!(&NotZerocopy(AU16(0)));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unsatisfied trait bound
|
help: the trait `IntoBytes` is not implemented for `NotZerocopy<AU16>`
--> $DIR/../include.rs:15:5
|
15 | pub struct NotZerocopy<T = ()>(pub T);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: Consider adding `#[derive(IntoBytes)]` to `NotZerocopy<AU16>`
= help: the following other types implement trait `IntoBytes`:
()
AU16
AtomicBool
AtomicI16
AtomicI32
AtomicI64
AtomicI8
AtomicIsize
and 68 others
note: required by a bound in `Wrap::<&'a Src, &'a Dst>::try_transmute_ref`
--> $WORKSPACE/src/util/macro_util.rs:754:14
|
752 | pub fn try_transmute_ref(self) -> Result<&'a Dst, ValidityError<&'a Src, Dst>>
| ----------------- required by a bound in this associated function
753 | where
754 | Src: IntoBytes + Immutable,
| ^^^^^^^^^ required by this bound in `Wrap::<&Src, &Dst>::try_transmute_ref`
= note: this error originates in the macro `try_transmute_ref` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0277]: the trait bound `NotZerocopy<AU16>: Immutable` is not satisfied
--> $DIR/try_transmute_ref.rs:33:48
|
33 | let src_not_into_bytes: Result<&AU16, _> = try_transmute_ref!(&NotZerocopy(AU16(0)));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unsatisfied trait bound
|
help: the trait `Immutable` is not implemented for `NotZerocopy<AU16>`
--> $DIR/../include.rs:15:5
|
15 | pub struct NotZerocopy<T = ()>(pub T);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: Consider adding `#[derive(Immutable)]` to `NotZerocopy<AU16>`
= help: the following other types implement trait `Immutable`:
&T
&mut T
()
(A, B)
(A, B, C)
(A, B, C, D)
(A, B, C, D, E)
(A, B, C, D, E, F)
and 128 others
note: required by a bound in `Wrap::<&'a Src, &'a Dst>::try_transmute_ref`
--> $WORKSPACE/src/util/macro_util.rs:754:26
|
752 | pub fn try_transmute_ref(self) -> Result<&'a Dst, ValidityError<&'a Src, Dst>>
| ----------------- required by a bound in this associated function
753 | where
754 | Src: IntoBytes + Immutable,
| ^^^^^^^^^ required by this bound in `Wrap::<&Src, &Dst>::try_transmute_ref`
= note: this error originates in the macro `try_transmute_ref` (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to 8 previous errors
Some errors have detailed explanations: E0277, E0308.
For more information about an error, try `rustc --explain E0277`.