diff --git a/src/lib.rs b/src/lib.rs index 329f5300b70..22aa39e6162 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -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`]. @@ -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. diff --git a/tests/ui-msrv/invalid-impls/invalid-impls.stderr b/tests/ui-msrv/invalid-impls/invalid-impls.stderr index 89f135c3b3b..fcca270d8ec 100644 --- a/tests/ui-msrv/invalid-impls/invalid-impls.stderr +++ b/tests/ui-msrv/invalid-impls/invalid-impls.stderr @@ -30,18 +30,18 @@ help: consider restricting type parameter `T` 26 | impl_or_verify!(T: zerocopy::TryFromBytes => TryFromBytes for Foo); | ++++++++++++++++++++++++ -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); | ------------------------------------------- in this macro invocation | -note: required because of the requirements on the impl of `FromZeroes` for `Foo` +note: required because of the requirements on the impl of `zerocopy::FromZeros` for `Foo` --> tests/ui-msrv/invalid-impls/invalid-impls.rs:22:10 | 22 | #[derive(FromBytes, IntoBytes, Unaligned)] @@ -94,18 +94,18 @@ help: consider restricting type parameter `T` 28 | impl_or_verify!(T: zerocopy::FromBytes => FromBytes for Foo); | +++++++++++++++++++++ -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); | ------------------------------------------- in this macro invocation | -note: required because of the requirements on the impl of `AsBytes` for `Foo` +note: required because of the requirements on the impl of `zerocopy::IntoBytes` for `Foo` --> tests/ui-msrv/invalid-impls/invalid-impls.rs:22:21 | 22 | #[derive(FromBytes, IntoBytes, Unaligned)] diff --git a/tests/ui-msrv/transmute-ptr-to-usize.stderr b/tests/ui-msrv/transmute-ptr-to-usize.stderr index fab734f39f9..81d60c71a1d 100644 --- a/tests/ui-msrv/transmute-ptr-to-usize.stderr +++ b/tests/ui-msrv/transmute-ptr-to-usize.stderr @@ -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 @@ -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 diff --git a/tests/ui-msrv/transmute-ref-src-not-intobytes.stderr b/tests/ui-msrv/transmute-ref-src-not-intobytes.stderr index e1a2f6a7696..84036b70ba3 100644 --- a/tests/ui-msrv/transmute-ref-src-not-intobytes.stderr +++ b/tests/ui-msrv/transmute-ref-src-not-intobytes.stderr @@ -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 @@ -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 diff --git a/tests/ui-msrv/transmute-src-not-intobytes.stderr b/tests/ui-msrv/transmute-src-not-intobytes.stderr index f5aecafc3aa..6382be909c8 100644 --- a/tests/ui-msrv/transmute-src-not-intobytes.stderr +++ b/tests/ui-msrv/transmute-src-not-intobytes.stderr @@ -1,8 +1,8 @@ -error[E0277]: the trait bound `NotZerocopy: AsBytes` is not satisfied +error[E0277]: the trait bound `NotZerocopy: 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` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `zerocopy::IntoBytes` is not implemented for `NotZerocopy` | note: required by `AssertIsIntoBytes` --> tests/ui-msrv/transmute-src-not-intobytes.rs:19:32 @@ -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: AsBytes` is not satisfied +error[E0277]: the trait bound `NotZerocopy: 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` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `zerocopy::IntoBytes` is not implemented for `NotZerocopy` | note: required by a bound in `AssertIsIntoBytes` --> tests/ui-msrv/transmute-src-not-intobytes.rs:19:32 diff --git a/tools/cargo-zerocopy/src/main.rs b/tools/cargo-zerocopy/src/main.rs index a2386eaa31d..04e6b5e95f3 100644 --- a/tools/cargo-zerocopy/src/main.rs +++ b/tools/cargo-zerocopy/src/main.rs @@ -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 " } } diff --git a/zerocopy-derive/tests/enum_try_from_bytes.rs b/zerocopy-derive/tests/enum_try_from_bytes.rs index 03581c6801d..65fdfa0fb27 100644 --- a/zerocopy-derive/tests/enum_try_from_bytes.rs +++ b/zerocopy-derive/tests/enum_try_from_bytes.rs @@ -57,11 +57,11 @@ util_assert_impl_all!(Baz: imp::TryFromBytes); #[test] fn test_baz() { imp::assert_eq!( - ::try_read_from(imp::AsBytes::as_bytes(&1u32)), + ::try_read_from(imp::IntoBytes::as_bytes(&1u32)), imp::Some(Baz::A) ); imp::assert_eq!( - ::try_read_from(imp::AsBytes::as_bytes(&0u32)), + ::try_read_from(imp::IntoBytes::as_bytes(&0u32)), imp::Some(Baz::B) ); imp::assert_eq!(::try_read_from(&[]), imp::None); @@ -91,19 +91,19 @@ util_assert_impl_all!(Blah: imp::TryFromBytes); #[test] fn test_blah() { imp::assert_eq!( - ::try_read_from(imp::AsBytes::as_bytes(&1i8)), + ::try_read_from(imp::IntoBytes::as_bytes(&1i8)), imp::Some(Blah::A) ); imp::assert_eq!( - ::try_read_from(imp::AsBytes::as_bytes(&0i8)), + ::try_read_from(imp::IntoBytes::as_bytes(&0i8)), imp::Some(Blah::B) ); imp::assert_eq!( - ::try_read_from(imp::AsBytes::as_bytes(&3i8)), + ::try_read_from(imp::IntoBytes::as_bytes(&3i8)), imp::Some(Blah::C) ); imp::assert_eq!( - ::try_read_from(imp::AsBytes::as_bytes(&6i8)), + ::try_read_from(imp::IntoBytes::as_bytes(&6i8)), imp::Some(Blah::D) ); imp::assert_eq!(::try_read_from(&[]), imp::None); diff --git a/zerocopy-derive/tests/ui-msrv/derive_transparent.stderr b/zerocopy-derive/tests/ui-msrv/derive_transparent.stderr index 05378d16623..e6e01d51003 100644 --- a/zerocopy-derive/tests/ui-msrv/derive_transparent.stderr +++ b/zerocopy-derive/tests/ui-msrv/derive_transparent.stderr @@ -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: 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` +note: required because of the requirements on the impl of `zerocopy::IntoBytes` for `TransparentStruct` --> tests/ui-msrv/derive_transparent.rs:24:10 | 24 | #[derive(IntoBytes, FromBytes, Unaligned)] diff --git a/zerocopy-derive/tests/ui-msrv/late_compile_pass.stderr b/zerocopy-derive/tests/ui-msrv/late_compile_pass.stderr index 814f48d5d56..0c3d09567e1 100644 --- a/zerocopy-derive/tests/ui-msrv/late_compile_pass.stderr +++ b/zerocopy-derive/tests/ui-msrv/late_compile_pass.stderr @@ -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)