Skip to content

Commit

Permalink
Disable re-exporting renamed traits in dev and CI
Browse files Browse the repository at this point in the history
See #960 for an explanation of why we do this.

Closes #960
  • Loading branch information
joshlf committed Feb 27, 2024
1 parent 978b400 commit 48692a4
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 31 deletions.
2 changes: 2 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1667,6 +1667,7 @@ pub unsafe trait FromZeros {
/// Deprecated: prefer [`FromZeros`] instead.
#[deprecated(since = "0.8.0", note = "`FromZeroes` was renamed to `FromZeros`")]
#[doc(hidden)]
#[cfg(not(__INTERNAL_USE_ONLY_DISABLE_DEPRECATED_TRAIT_ALIASES))] // See #960 for why we do this.
pub use FromZeros as FromZeroes;

/// Analyzes whether a type is [`FromBytes`].
Expand Down Expand Up @@ -3042,6 +3043,7 @@ pub unsafe trait IntoBytes {
/// Deprecated: prefer [`IntoBytes`] instead.
#[deprecated(since = "0.8.0", note = "`AsBytes` was renamed to `IntoBytes`")]
#[doc(hidden)]
#[cfg(not(__INTERNAL_USE_ONLY_DISABLE_DEPRECATED_TRAIT_ALIASES))] // See #960 for why we do this.
pub use IntoBytes as AsBytes;

/// Types with no alignment requirement.
Expand Down
12 changes: 6 additions & 6 deletions tests/ui-msrv/invalid-impls/invalid-impls.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,18 @@ help: consider restricting type parameter `T`
26 | impl_or_verify!(T: zerocopy::TryFromBytes => TryFromBytes for Foo<T>);
| ++++++++++++++++++++++++

error[E0277]: the trait bound `T: FromZeroes` is not satisfied
error[E0277]: the trait bound `T: zerocopy::FromZeros` is not satisfied
--> tests/ui-msrv/invalid-impls/../../../src/macros.rs
|
| impl<$($tyvar $(: $(? $optbound +)* $($bound +)*)?),*> Subtrait for $ty {}
| ^^^^^^^^ the trait `FromZeroes` is not implemented for `T`
| ^^^^^^^^ the trait `zerocopy::FromZeros` is not implemented for `T`
|
::: tests/ui-msrv/invalid-impls/invalid-impls.rs:27:1
|
27 | impl_or_verify!(T => FromZeros for Foo<T>);
| ------------------------------------------- in this macro invocation
|
note: required because of the requirements on the impl of `FromZeroes` for `Foo<T>`
note: required because of the requirements on the impl of `zerocopy::FromZeros` for `Foo<T>`
--> tests/ui-msrv/invalid-impls/invalid-impls.rs:22:10
|
22 | #[derive(FromBytes, IntoBytes, Unaligned)]
Expand Down Expand Up @@ -94,18 +94,18 @@ help: consider restricting type parameter `T`
28 | impl_or_verify!(T: zerocopy::FromBytes => FromBytes for Foo<T>);
| +++++++++++++++++++++

error[E0277]: the trait bound `T: AsBytes` is not satisfied
error[E0277]: the trait bound `T: zerocopy::IntoBytes` is not satisfied
--> tests/ui-msrv/invalid-impls/../../../src/macros.rs
|
| impl<$($tyvar $(: $(? $optbound +)* $($bound +)*)?),*> Subtrait for $ty {}
| ^^^^^^^^ the trait `AsBytes` is not implemented for `T`
| ^^^^^^^^ the trait `zerocopy::IntoBytes` is not implemented for `T`
|
::: tests/ui-msrv/invalid-impls/invalid-impls.rs:29:1
|
29 | impl_or_verify!(T => IntoBytes for Foo<T>);
| ------------------------------------------- in this macro invocation
|
note: required because of the requirements on the impl of `AsBytes` for `Foo<T>`
note: required because of the requirements on the impl of `zerocopy::IntoBytes` for `Foo<T>`
--> tests/ui-msrv/invalid-impls/invalid-impls.rs:22:21
|
22 | #[derive(FromBytes, IntoBytes, Unaligned)]
Expand Down
8 changes: 4 additions & 4 deletions tests/ui-msrv/transmute-ptr-to-usize.stderr
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
error[E0277]: the trait bound `*const usize: AsBytes` is not satisfied
error[E0277]: the trait bound `*const usize: IntoBytes` is not satisfied
--> tests/ui-msrv/transmute-ptr-to-usize.rs:20:30
|
20 | const POINTER_VALUE: usize = transmute!(&0usize as *const usize);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `AsBytes` is not implemented for `*const usize`
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `IntoBytes` is not implemented for `*const usize`
|
note: required by `AssertIsIntoBytes`
--> tests/ui-msrv/transmute-ptr-to-usize.rs:20:30
Expand All @@ -11,11 +11,11 @@ note: required by `AssertIsIntoBytes`
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: this error originates in the macro `transmute` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0277]: the trait bound `*const usize: AsBytes` is not satisfied
error[E0277]: the trait bound `*const usize: IntoBytes` is not satisfied
--> tests/ui-msrv/transmute-ptr-to-usize.rs:20:30
|
20 | const POINTER_VALUE: usize = transmute!(&0usize as *const usize);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `AsBytes` is not implemented for `*const usize`
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `IntoBytes` is not implemented for `*const usize`
|
note: required by a bound in `AssertIsIntoBytes`
--> tests/ui-msrv/transmute-ptr-to-usize.rs:20:30
Expand Down
8 changes: 4 additions & 4 deletions tests/ui-msrv/transmute-ref-src-not-intobytes.stderr
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
error[E0277]: the trait bound `Src: AsBytes` is not satisfied
error[E0277]: the trait bound `Src: zerocopy::IntoBytes` is not satisfied
--> tests/ui-msrv/transmute-ref-src-not-intobytes.rs:23:33
|
23 | const SRC_NOT_AS_BYTES: &AU16 = transmute_ref!(&Src(AU16(0)));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `AsBytes` is not implemented for `Src`
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `zerocopy::IntoBytes` is not implemented for `Src`
|
note: required by `AssertSrcIsIntoBytes`
--> tests/ui-msrv/transmute-ref-src-not-intobytes.rs:23:33
Expand All @@ -11,11 +11,11 @@ note: required by `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 `Src: AsBytes` is not satisfied
error[E0277]: the trait bound `Src: zerocopy::IntoBytes` is not satisfied
--> tests/ui-msrv/transmute-ref-src-not-intobytes.rs:23:33
|
23 | const SRC_NOT_AS_BYTES: &AU16 = transmute_ref!(&Src(AU16(0)));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `AsBytes` is not implemented for `Src`
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `zerocopy::IntoBytes` is not implemented for `Src`
|
note: required by a bound in `AssertSrcIsIntoBytes`
--> tests/ui-msrv/transmute-ref-src-not-intobytes.rs:23:33
Expand Down
8 changes: 4 additions & 4 deletions tests/ui-msrv/transmute-src-not-intobytes.stderr
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
error[E0277]: the trait bound `NotZerocopy<AU16>: AsBytes` is not satisfied
error[E0277]: the trait bound `NotZerocopy<AU16>: zerocopy::IntoBytes` is not satisfied
--> tests/ui-msrv/transmute-src-not-intobytes.rs:19:32
|
19 | const SRC_NOT_AS_BYTES: AU16 = transmute!(NotZerocopy(AU16(0)));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `AsBytes` is not implemented for `NotZerocopy<AU16>`
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `zerocopy::IntoBytes` is not implemented for `NotZerocopy<AU16>`
|
note: required by `AssertIsIntoBytes`
--> tests/ui-msrv/transmute-src-not-intobytes.rs:19:32
Expand All @@ -11,11 +11,11 @@ note: required by `AssertIsIntoBytes`
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= 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>: AsBytes` is not satisfied
error[E0277]: the trait bound `NotZerocopy<AU16>: zerocopy::IntoBytes` is not satisfied
--> tests/ui-msrv/transmute-src-not-intobytes.rs:19:32
|
19 | const SRC_NOT_AS_BYTES: AU16 = transmute!(NotZerocopy(AU16(0)));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `AsBytes` is not implemented for `NotZerocopy<AU16>`
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `zerocopy::IntoBytes` is not implemented for `NotZerocopy<AU16>`
|
note: required by a bound in `AssertIsIntoBytes`
--> tests/ui-msrv/transmute-src-not-intobytes.rs:19:32
Expand Down
6 changes: 4 additions & 2 deletions tools/cargo-zerocopy/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,10 +201,12 @@ fn install_toolchain_or_exit(versions: &Versions, name: &str) -> Result<(), Erro
}

fn get_rustflags(name: &str) -> &'static str {
// See #960 for an explanation of why we emit --cfg
// __INTERNAL_USE_ONLY_DISABLE_DEPRECATED_TRAIT_ALIASES.
if name == "nightly" {
"--cfg __INTERNAL_USE_ONLY_NIGHTLY_FEATURES_IN_TESTS "
"--cfg __INTERNAL_USE_ONLY_NIGHTLY_FEATURES_IN_TESTS --cfg __INTERNAL_USE_ONLY_DISABLE_DEPRECATED_TRAIT_ALIASES "
} else {
""
"--cfg __INTERNAL_USE_ONLY_DISABLE_DEPRECATED_TRAIT_ALIASES "
}
}

Expand Down
12 changes: 6 additions & 6 deletions zerocopy-derive/tests/enum_try_from_bytes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,11 @@ util_assert_impl_all!(Baz: imp::TryFromBytes);
#[test]
fn test_baz() {
imp::assert_eq!(
<Baz as imp::TryFromBytes>::try_read_from(imp::AsBytes::as_bytes(&1u32)),
<Baz as imp::TryFromBytes>::try_read_from(imp::IntoBytes::as_bytes(&1u32)),
imp::Some(Baz::A)
);
imp::assert_eq!(
<Baz as imp::TryFromBytes>::try_read_from(imp::AsBytes::as_bytes(&0u32)),
<Baz as imp::TryFromBytes>::try_read_from(imp::IntoBytes::as_bytes(&0u32)),
imp::Some(Baz::B)
);
imp::assert_eq!(<Baz as imp::TryFromBytes>::try_read_from(&[]), imp::None);
Expand Down Expand Up @@ -91,19 +91,19 @@ util_assert_impl_all!(Blah: imp::TryFromBytes);
#[test]
fn test_blah() {
imp::assert_eq!(
<Blah as imp::TryFromBytes>::try_read_from(imp::AsBytes::as_bytes(&1i8)),
<Blah as imp::TryFromBytes>::try_read_from(imp::IntoBytes::as_bytes(&1i8)),
imp::Some(Blah::A)
);
imp::assert_eq!(
<Blah as imp::TryFromBytes>::try_read_from(imp::AsBytes::as_bytes(&0i8)),
<Blah as imp::TryFromBytes>::try_read_from(imp::IntoBytes::as_bytes(&0i8)),
imp::Some(Blah::B)
);
imp::assert_eq!(
<Blah as imp::TryFromBytes>::try_read_from(imp::AsBytes::as_bytes(&3i8)),
<Blah as imp::TryFromBytes>::try_read_from(imp::IntoBytes::as_bytes(&3i8)),
imp::Some(Blah::C)
);
imp::assert_eq!(
<Blah as imp::TryFromBytes>::try_read_from(imp::AsBytes::as_bytes(&6i8)),
<Blah as imp::TryFromBytes>::try_read_from(imp::IntoBytes::as_bytes(&6i8)),
imp::Some(Blah::D)
);
imp::assert_eq!(<Blah as imp::TryFromBytes>::try_read_from(&[]), imp::None);
Expand Down
6 changes: 3 additions & 3 deletions zerocopy-derive/tests/ui-msrv/derive_transparent.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@ note: required by a bound in `_::{closure#0}::_::{closure#0}::assert_impl_all`
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `_::{closure#0}::_::{closure#0}::assert_impl_all`
= note: this error originates in the macro `::static_assertions::assert_impl_all` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0277]: the trait bound `NotZerocopy: AsBytes` is not satisfied
error[E0277]: the trait bound `NotZerocopy: zerocopy::IntoBytes` is not satisfied
--> tests/ui-msrv/derive_transparent.rs:37:1
|
37 | util_assert_impl_all!(TransparentStruct<NotZerocopy>: IntoBytes);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `AsBytes` is not implemented for `NotZerocopy`
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `zerocopy::IntoBytes` is not implemented for `NotZerocopy`
|
note: required because of the requirements on the impl of `AsBytes` for `TransparentStruct<NotZerocopy>`
note: required because of the requirements on the impl of `zerocopy::IntoBytes` for `TransparentStruct<NotZerocopy>`
--> tests/ui-msrv/derive_transparent.rs:24:10
|
24 | #[derive(IntoBytes, FromBytes, Unaligned)]
Expand Down
4 changes: 2 additions & 2 deletions zerocopy-derive/tests/ui-msrv/late_compile_pass.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,11 @@ error[E0277]: the trait bound `NotZerocopy: zerocopy::FromBytes` is not satisfie
= help: see issue #48214
= note: this error originates in the derive macro `FromBytes` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0277]: the trait bound `NotZerocopy: AsBytes` is not satisfied
error[E0277]: the trait bound `NotZerocopy: zerocopy::IntoBytes` is not satisfied
--> tests/ui-msrv/late_compile_pass.rs:55:10
|
55 | #[derive(IntoBytes)]
| ^^^^^^^^^ the trait `AsBytes` is not implemented for `NotZerocopy`
| ^^^^^^^^^ the trait `zerocopy::IntoBytes` is not implemented for `NotZerocopy`
|
= help: see issue #48214
= note: this error originates in the derive macro `IntoBytes` (in Nightly builds, run with -Z macro-backtrace for more info)
Expand Down

0 comments on commit 48692a4

Please sign in to comment.