Skip to content

Commit f86bdd1

Browse files
authored
Update MSRV to 1.65.0 (#156)
Also update the versions of the stable and nightly compiler toolchains that are pinned in CI.
1 parent d05b7be commit f86bdd1

File tree

15 files changed

+183
-97
lines changed

15 files changed

+183
-97
lines changed

Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ authors = ["Joshua Liebow-Feeser <joshlf@google.com>"]
1616
description = "Utilities for zero-copy parsing and serialization"
1717
license = "BSD-2-Clause"
1818
repository = "https://github.com/google/zerocopy"
19-
rust-version = "1.61.0"
19+
rust-version = "1.65.0"
2020

2121
exclude = [".*"]
2222

@@ -25,8 +25,8 @@ all-features = true
2525

2626
[package.metadata.ci]
2727
# The versions of the stable and nightly compiler toolchains to use in CI.
28-
pinned-stable = "1.64.0"
29-
pinned-nightly = "nightly-2022-10-17"
28+
pinned-stable = "1.65.0"
29+
pinned-nightly = "nightly-2022-11-04"
3030

3131
[features]
3232
alloc = []

src/lib.rs

Lines changed: 2 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2738,6 +2738,8 @@ mod alloc_support {
27382738

27392739
#[cfg(test)]
27402740
mod tests {
2741+
use core::convert::TryFrom as _;
2742+
27412743
use super::*;
27422744

27432745
#[test]
@@ -2920,38 +2922,9 @@ mod alloc_support {
29202922
let _ = u16::new_box_slice_zeroed(usize::MAX);
29212923
}
29222924

2923-
// This test fails on stable <= 1.64.0, but succeeds on 1.65.0-beta.2
2924-
// (2022-09-13). In particular, on stable <= 1.64.0,
2925-
// `new_box_slice_zeroed` attempts to perform the allocation (which of
2926-
// course fails). `Layout::from_size_align` should be returning an error
2927-
// due to `isize` overflow, but it doesn't. I (joshlf) haven't
2928-
// investigated enough to confirm, but my guess is that this was a bug
2929-
// that was fixed recently.
2930-
//
2931-
// Triggering the bug requires calling
2932-
// `FromZeroes::new_box_slice_zeroed` with an allocation which overflows
2933-
// `isize`, and all that happens is that the program panics due to a
2934-
// failed allocation. Even on 32-bit platforms, this requires a 2GB
2935-
// allocation. On 64-bit platforms, this requires a 2^63-byte
2936-
// allocation. In both cases, even a slightly smaller allocation that
2937-
// didn't trigger this bug would likely (absolutely certainly in the
2938-
// case of 64-bit platforms) fail to allocate in exactly the same way
2939-
// regardless.
2940-
//
2941-
// Given how minor the impact is, and given that the bug seems fixed in
2942-
// 1.65.0, I've chosen to just release the code as-is and disable the
2943-
// test on buggy toolchains. Once our MSRV is at or above 1.65.0, we can
2944-
// remove this conditional compilation (and this comment) entirely.
2945-
#[rustversion::since(1.65.0)]
29462925
#[test]
29472926
#[should_panic(expected = "total allocation size overflows `isize`: LayoutError")]
29482927
fn test_new_box_slice_zeroed_panics_isize_overflow() {
2949-
// TODO: Move this to the top of the module once this test is
2950-
// compiled unconditionally. Right now, it causes an unused import
2951-
// warning (which in CI becomes an error) on versions prior to
2952-
// 1.65.0.
2953-
use core::convert::TryFrom as _;
2954-
29552928
let max = usize::try_from(isize::MAX).unwrap();
29562929
let _ = u16::new_box_slice_zeroed((max / mem::size_of::<u16>()) + 1);
29572930
}

tests/trybuild.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717

1818
#[rustversion::any(nightly, beta)]
1919
const SOURCE_FILES_GLOB: &str = "tests/ui/*.rs";
20-
#[rustversion::all(stable, not(stable(1.61.0)))]
20+
#[rustversion::all(stable, not(stable(1.65.0)))]
2121
const SOURCE_FILES_GLOB: &str = "tests/ui-stable/*.rs";
22-
#[rustversion::stable(1.61.0)]
22+
#[rustversion::stable(1.65.0)]
2323
const SOURCE_FILES_GLOB: &str = "tests/ui-msrv/*.rs";
2424

2525
#[test]

tests/ui-msrv/transmute-illegal.stderr

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,20 @@ error[E0277]: the trait bound `*const usize: AsBytes` is not satisfied
22
--> tests/ui-msrv/transmute-illegal.rs:10:30
33
|
44
10 | const POINTER_VALUE: usize = zerocopy::transmute!(&0usize as *const usize);
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `AsBytes` is not implemented for `*const usize`
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6+
| |
7+
| the trait `AsBytes` is not implemented for `*const usize`
8+
| required by a bound introduced by this call
69
|
7-
= help: the following implementations were found:
8-
<usize as AsBytes>
9-
<f32 as AsBytes>
10-
<f64 as AsBytes>
11-
<i128 as AsBytes>
10+
= help: the following other types implement trait `AsBytes`:
11+
f32
12+
f64
13+
i128
14+
i16
15+
i32
16+
i64
17+
i8
18+
isize
1219
and $N others
1320
note: required by a bound in `POINTER_VALUE::transmute`
1421
--> tests/ui-msrv/transmute-illegal.rs:10:30

tests/ui-stable/transmute-illegal.stderr

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,12 @@ error[E0277]: the trait bound `*const usize: AsBytes` is not satisfied
22
--> tests/ui-stable/transmute-illegal.rs:10:30
33
|
44
10 | const POINTER_VALUE: usize = zerocopy::transmute!(&0usize as *const usize);
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `AsBytes` is not implemented for `*const usize`
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6+
| |
7+
| the trait `AsBytes` is not implemented for `*const usize`
8+
| required by a bound introduced by this call
69
|
7-
= help: the following other types implement trait `AsBytes`:
8-
f32
9-
f64
10-
i128
11-
i16
12-
i32
13-
i64
14-
i8
15-
isize
16-
and $N others
10+
= help: the trait `AsBytes` is implemented for `usize`
1711
note: required by a bound in `POINTER_VALUE::transmute`
1812
--> tests/ui-stable/transmute-illegal.rs:10:30
1913
|

zerocopy-derive/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ authors = ["Joshua Liebow-Feeser <joshlf@google.com>"]
1010
description = "Custom derive for traits from the zerocopy crate"
1111
license-file = "../LICENSE"
1212
repository = "https://github.com/google/zerocopy"
13-
rust-version = "1.61.0"
13+
rust-version = "1.65.0"
1414

1515
exclude = [".*"]
1616

zerocopy-derive/src/repr.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ impl Repr {
189189
let ident = path
190190
.get_ident()
191191
.ok_or_else(|| Error::new_spanned(meta, "unrecognized representation hint"))?;
192-
match format!("{}", ident).as_str() {
192+
match format!("{ident}").as_str() {
193193
"u8" => return Ok(Repr::U8),
194194
"u16" => return Ok(Repr::U16),
195195
"u32" => return Ok(Repr::U32),
@@ -223,7 +223,7 @@ impl Repr {
223223
impl Display for Repr {
224224
fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), fmt::Error> {
225225
if let Repr::Align(n) = self {
226-
return write!(f, "repr(align({}))", n);
226+
return write!(f, "repr(align({n}))");
227227
}
228228
write!(
229229
f,

zerocopy-derive/tests/trybuild.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717

1818
#[rustversion::any(nightly, beta)]
1919
const SOURCE_FILES_GLOB: &str = "tests/ui/*.rs";
20-
#[rustversion::all(stable, not(stable(1.61.0)))]
20+
#[rustversion::all(stable, not(stable(1.65.0)))]
2121
const SOURCE_FILES_GLOB: &str = "tests/ui-stable/*.rs";
22-
#[rustversion::stable(1.61.0)]
22+
#[rustversion::stable(1.65.0)]
2323
const SOURCE_FILES_GLOB: &str = "tests/ui-msrv/*.rs";
2424

2525
#[test]
Lines changed: 60 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,20 @@
11
error[E0277]: the trait bound `NotZerocopy: FromZeroes` is not satisfied
2-
--> tests/ui-msrv/derive_transparent.rs:33:1
2+
--> tests/ui-msrv/derive_transparent.rs:33:18
33
|
44
33 | assert_impl_all!(TransparentStruct<NotZerocopy>: FromZeroes);
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `FromZeroes` is not implemented for `NotZerocopy`
6-
|
7-
note: required because of the requirements on the impl of `FromZeroes` for `TransparentStruct<NotZerocopy>`
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `FromZeroes` is not implemented for `NotZerocopy`
6+
|
7+
= help: the following other types implement trait `FromZeroes`:
8+
()
9+
AU16
10+
F32<O>
11+
F64<O>
12+
I128<O>
13+
I16<O>
14+
I32<O>
15+
I64<O>
16+
and $N others
17+
note: required for `TransparentStruct<NotZerocopy>` to implement `FromZeroes`
818
--> tests/ui-msrv/derive_transparent.rs:23:19
919
|
1020
23 | #[derive(AsBytes, FromZeroes, FromBytes, Unaligned)]
@@ -14,15 +24,25 @@ note: required by a bound in `_::{closure#0}::assert_impl_all`
1424
|
1525
33 | assert_impl_all!(TransparentStruct<NotZerocopy>: FromZeroes);
1626
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `_::{closure#0}::assert_impl_all`
17-
= note: this error originates in the macro `assert_impl_all` (in Nightly builds, run with -Z macro-backtrace for more info)
27+
= note: this error originates in the derive macro `FromZeroes` which comes from the expansion of the macro `assert_impl_all` (in Nightly builds, run with -Z macro-backtrace for more info)
1828

1929
error[E0277]: the trait bound `NotZerocopy: FromBytes` is not satisfied
20-
--> tests/ui-msrv/derive_transparent.rs:34:1
30+
--> tests/ui-msrv/derive_transparent.rs:34:18
2131
|
2232
34 | assert_impl_all!(TransparentStruct<NotZerocopy>: FromBytes);
23-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `FromBytes` is not implemented for `NotZerocopy`
24-
|
25-
note: required because of the requirements on the impl of `FromBytes` for `TransparentStruct<NotZerocopy>`
33+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `FromBytes` is not implemented for `NotZerocopy`
34+
|
35+
= help: the following other types implement trait `FromBytes`:
36+
()
37+
AU16
38+
F32<O>
39+
F64<O>
40+
I128<O>
41+
I16<O>
42+
I32<O>
43+
I64<O>
44+
and $N others
45+
note: required for `TransparentStruct<NotZerocopy>` to implement `FromBytes`
2646
--> tests/ui-msrv/derive_transparent.rs:23:31
2747
|
2848
23 | #[derive(AsBytes, FromZeroes, FromBytes, Unaligned)]
@@ -32,15 +52,25 @@ note: required by a bound in `_::{closure#0}::assert_impl_all`
3252
|
3353
34 | assert_impl_all!(TransparentStruct<NotZerocopy>: FromBytes);
3454
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `_::{closure#0}::assert_impl_all`
35-
= note: this error originates in the macro `assert_impl_all` (in Nightly builds, run with -Z macro-backtrace for more info)
55+
= note: this error originates in the derive macro `FromBytes` which comes from the expansion of the macro `assert_impl_all` (in Nightly builds, run with -Z macro-backtrace for more info)
3656

3757
error[E0277]: the trait bound `NotZerocopy: AsBytes` is not satisfied
38-
--> tests/ui-msrv/derive_transparent.rs:35:1
58+
--> tests/ui-msrv/derive_transparent.rs:35:18
3959
|
4060
35 | assert_impl_all!(TransparentStruct<NotZerocopy>: AsBytes);
41-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `AsBytes` is not implemented for `NotZerocopy`
42-
|
43-
note: required because of the requirements on the impl of `AsBytes` for `TransparentStruct<NotZerocopy>`
61+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `AsBytes` is not implemented for `NotZerocopy`
62+
|
63+
= help: the following other types implement trait `AsBytes`:
64+
()
65+
AU16
66+
F32<O>
67+
F64<O>
68+
I128<O>
69+
I16<O>
70+
I32<O>
71+
I64<O>
72+
and $N others
73+
note: required for `TransparentStruct<NotZerocopy>` to implement `AsBytes`
4474
--> tests/ui-msrv/derive_transparent.rs:23:10
4575
|
4676
23 | #[derive(AsBytes, FromZeroes, FromBytes, Unaligned)]
@@ -50,15 +80,25 @@ note: required by a bound in `_::{closure#0}::assert_impl_all`
5080
|
5181
35 | assert_impl_all!(TransparentStruct<NotZerocopy>: AsBytes);
5282
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `_::{closure#0}::assert_impl_all`
53-
= note: this error originates in the macro `assert_impl_all` (in Nightly builds, run with -Z macro-backtrace for more info)
83+
= note: this error originates in the derive macro `AsBytes` which comes from the expansion of the macro `assert_impl_all` (in Nightly builds, run with -Z macro-backtrace for more info)
5484

5585
error[E0277]: the trait bound `NotZerocopy: Unaligned` is not satisfied
56-
--> tests/ui-msrv/derive_transparent.rs:36:1
86+
--> tests/ui-msrv/derive_transparent.rs:36:18
5787
|
5888
36 | assert_impl_all!(TransparentStruct<NotZerocopy>: Unaligned);
59-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Unaligned` is not implemented for `NotZerocopy`
60-
|
61-
note: required because of the requirements on the impl of `Unaligned` for `TransparentStruct<NotZerocopy>`
89+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Unaligned` is not implemented for `NotZerocopy`
90+
|
91+
= help: the following other types implement trait `Unaligned`:
92+
()
93+
F32<O>
94+
F64<O>
95+
I128<O>
96+
I16<O>
97+
I32<O>
98+
I64<O>
99+
ManuallyDrop<T>
100+
and $N others
101+
note: required for `TransparentStruct<NotZerocopy>` to implement `Unaligned`
62102
--> tests/ui-msrv/derive_transparent.rs:23:42
63103
|
64104
23 | #[derive(AsBytes, FromZeroes, FromBytes, Unaligned)]
@@ -68,4 +108,4 @@ note: required by a bound in `_::{closure#0}::assert_impl_all`
68108
|
69109
36 | assert_impl_all!(TransparentStruct<NotZerocopy>: Unaligned);
70110
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `_::{closure#0}::assert_impl_all`
71-
= note: this error originates in the macro `assert_impl_all` (in Nightly builds, run with -Z macro-backtrace for more info)
111+
= note: this error originates in the derive macro `Unaligned` which comes from the expansion of the macro `assert_impl_all` (in Nightly builds, run with -Z macro-backtrace for more info)

zerocopy-derive/tests/ui-msrv/enum.stderr

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,8 @@ error[E0552]: unrecognized representation hint
187187
|
188188
21 | #[repr(foo)]
189189
| ^^^
190+
|
191+
= help: valid reprs are `C`, `align`, `packed`, `transparent`, `simd`, `i8`, `u8`, `i16`, `u16`, `i32`, `u32`, `i64`, `u64`, `i128`, `u128`, `isize`, `usize`
190192

191193
error[E0566]: conflicting representation hints
192194
--> tests/ui-msrv/enum.rs:33:8

0 commit comments

Comments
 (0)