Skip to content

Commit 92c0188

Browse files
authored
Merge branch 'main' into trivial-bounds
2 parents 7d166bc + 14416a5 commit 92c0188

File tree

6 files changed

+94
-29
lines changed

6 files changed

+94
-29
lines changed

.github/workflows/ci.yml

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ jobs:
7171
name: Build & Test (crate:${{ matrix.crate }}, toolchain:${{ matrix.toolchain }}, target:${{ matrix.target }}, features:${{ matrix.features }})
7272

7373
steps:
74-
- uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
74+
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
7575

7676
- uses: actions/cache@v3
7777
with:
@@ -171,6 +171,9 @@ jobs:
171171

172172
- name: Run tests under Miri
173173
run: |
174+
# Work around https://github.com/rust-lang/miri/issues/3125
175+
[ "${{ matrix.target }}" == "aarch64-unknown-linux-gnu" ] && cargo clean
176+
174177
# Run under both the stacked borrows model (default) and under the tree
175178
# borrows model to ensure we're compliant with both.
176179
for EXTRA_FLAGS in "" "-Zmiri-tree-borrows"; do
@@ -236,7 +239,7 @@ jobs:
236239
runs-on: ubuntu-latest
237240
name: 'Run tests under Kani'
238241
steps:
239-
- uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
242+
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
240243
- uses: model-checking/[email protected]
241244
with:
242245
args: "--package zerocopy --all-features --output-format=terse --randomize-layout --memory-safety-checks --overflow-checks --undefined-function-checks --unwinding-checks"
@@ -245,7 +248,7 @@ jobs:
245248
runs-on: ubuntu-latest
246249
name: Check Rust formatting
247250
steps:
248-
- uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
251+
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
249252
- name: Check Rust formatting
250253
run: |
251254
set -eo pipefail
@@ -260,7 +263,7 @@ jobs:
260263
runs-on: ubuntu-latest
261264
name: Check README.md
262265
steps:
263-
- uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
266+
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
264267

265268
- uses: actions/cache@v3
266269
with:
@@ -285,7 +288,7 @@ jobs:
285288
runs-on: ubuntu-latest
286289
name: Check MSRVs match
287290
steps:
288-
- uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
291+
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
289292

290293
- uses: actions/cache@v3
291294
with:
@@ -328,7 +331,7 @@ jobs:
328331
runs-on: ubuntu-latest
329332
name: Check crate versions match
330333
steps:
331-
- uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
334+
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
332335

333336
- uses: actions/cache@v3
334337
with:
@@ -403,7 +406,7 @@ jobs:
403406
runs-on: ubuntu-latest
404407
name: Generate cache
405408
steps:
406-
- uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
409+
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
407410

408411
- uses: actions/cache@v3
409412
with:

.github/workflows/dependency-review.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,6 @@ jobs:
2222
egress-policy: audit
2323

2424
- name: 'Checkout Repository'
25-
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
25+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
2626
- name: 'Dependency Review'
2727
uses: actions/dependency-review-action@6c5ccdad469c9f8a2996bfecaec55a631a347034 # v3.1.0

.github/workflows/roll-pinned-toolchain-versions.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
name: Roll pinned toolchain ${{ matrix.toolchain }} version
2525
steps:
2626
- name: Checkout code
27-
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
27+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
2828
with:
2929
ref: main
3030
persist-credentials: false

.github/workflows/scorecard.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929

3030
steps:
3131
- name: "Checkout code"
32-
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
32+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
3333
with:
3434
persist-credentials: false
3535

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ all-features = true
2626
[package.metadata.ci]
2727
# The versions of the stable and nightly compiler toolchains to use in CI.
2828
pinned-stable = "1.73.0"
29-
pinned-nightly = "nightly-2023-10-16"
29+
pinned-nightly = "nightly-2023-10-17"
3030

3131
[features]
3232
default = ["byteorder"]

src/lib.rs

Lines changed: 80 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4196,7 +4196,8 @@ mod tests {
41964196
let mut buf = Align::<[u8; 8], AU64>::default();
41974197
// `buf.t` should be aligned to 8, so this should always succeed.
41984198
test_new_helper(Ref::<_, AU64>::new(&mut buf.t[..]).unwrap());
4199-
buf.t = [0xFFu8; 8];
4199+
let ascending: [u8; 8] = (0..8).collect::<Vec<_>>().try_into().unwrap();
4200+
buf.t = ascending;
42004201
test_new_helper(Ref::<_, AU64>::new_zeroed(&mut buf.t[..]).unwrap());
42014202
{
42024203
// In a block so that `r` and `suffix` don't live too long.
@@ -4206,7 +4207,7 @@ mod tests {
42064207
test_new_helper(r);
42074208
}
42084209
{
4209-
buf.t = [0xFFu8; 8];
4210+
buf.t = ascending;
42104211
let (r, suffix) = Ref::<_, AU64>::new_from_prefix_zeroed(&mut buf.t[..]).unwrap();
42114212
assert!(suffix.is_empty());
42124213
test_new_helper(r);
@@ -4218,46 +4219,54 @@ mod tests {
42184219
test_new_helper(r);
42194220
}
42204221
{
4221-
buf.t = [0xFFu8; 8];
4222+
buf.t = ascending;
42224223
let (prefix, r) = Ref::<_, AU64>::new_from_suffix_zeroed(&mut buf.t[..]).unwrap();
42234224
assert!(prefix.is_empty());
42244225
test_new_helper(r);
42254226
}
42264227

4227-
// A buffer with alignment 8 and length 16.
4228-
let mut buf = Align::<[u8; 16], AU64>::default();
4228+
// A buffer with alignment 8 and length 24. We choose this length very
4229+
// intentionally: if we instead used length 16, then the prefix and
4230+
// suffix lengths would be identical. In the past, we used length 16,
4231+
// which resulted in this test failing to discover the bug uncovered in
4232+
// #506.
4233+
let mut buf = Align::<[u8; 24], AU64>::default();
42294234
// `buf.t` should be aligned to 8 and have a length which is a multiple
42304235
// of `size_of::<AU64>()`, so this should always succeed.
4231-
test_new_helper_slice(Ref::<_, [AU64]>::new_slice(&mut buf.t[..]).unwrap(), 2);
4232-
buf.t = [0xFFu8; 16];
4233-
test_new_helper_slice(Ref::<_, [AU64]>::new_slice_zeroed(&mut buf.t[..]).unwrap(), 2);
4236+
test_new_helper_slice(Ref::<_, [AU64]>::new_slice(&mut buf.t[..]).unwrap(), 3);
4237+
let ascending: [u8; 24] = (0..24).collect::<Vec<_>>().try_into().unwrap();
4238+
// 16 ascending bytes followed by 8 zeros.
4239+
let mut ascending_prefix = ascending;
4240+
ascending_prefix[16..].copy_from_slice(&[0, 0, 0, 0, 0, 0, 0, 0]);
4241+
// 8 zeros followed by 16 ascending bytes.
4242+
let mut ascending_suffix = ascending;
4243+
ascending_suffix[..8].copy_from_slice(&[0, 0, 0, 0, 0, 0, 0, 0]);
4244+
test_new_helper_slice(Ref::<_, [AU64]>::new_slice_zeroed(&mut buf.t[..]).unwrap(), 3);
42344245

42354246
{
4236-
buf.set_default();
4237-
buf.t[8..].fill(0xFF);
4247+
buf.t = ascending_suffix;
42384248
let (r, suffix) = Ref::<_, [AU64]>::new_slice_from_prefix(&mut buf.t[..], 1).unwrap();
4239-
assert_eq!(suffix, [0xFF; 8]);
4249+
assert_eq!(suffix, &ascending[8..]);
42404250
test_new_helper_slice(r, 1);
42414251
}
42424252
{
4243-
buf.t = [0xFFu8; 16];
4253+
buf.t = ascending_suffix;
42444254
let (r, suffix) =
42454255
Ref::<_, [AU64]>::new_slice_from_prefix_zeroed(&mut buf.t[..], 1).unwrap();
4246-
assert_eq!(suffix, [0xFF; 8]);
4256+
assert_eq!(suffix, &ascending[8..]);
42474257
test_new_helper_slice(r, 1);
42484258
}
42494259
{
4250-
buf.set_default();
4251-
buf.t[..8].fill(0xFF);
4260+
buf.t = ascending_prefix;
42524261
let (prefix, r) = Ref::<_, [AU64]>::new_slice_from_suffix(&mut buf.t[..], 1).unwrap();
4253-
assert_eq!(prefix, [0xFF; 8]);
4262+
assert_eq!(prefix, &ascending[..16]);
42544263
test_new_helper_slice(r, 1);
42554264
}
42564265
{
4257-
buf.t = [0xFFu8; 16];
4266+
buf.t = ascending_prefix;
42584267
let (prefix, r) =
42594268
Ref::<_, [AU64]>::new_slice_from_suffix_zeroed(&mut buf.t[..], 1).unwrap();
4260-
assert_eq!(prefix, [0xFF; 8]);
4269+
assert_eq!(prefix, &ascending[..16]);
42614270
test_new_helper_slice(r, 1);
42624271
}
42634272
}
@@ -4835,5 +4844,58 @@ mod tests {
48354844
assert_impls!([NotZerocopy; 0]: !FromZeroes, !FromBytes, !AsBytes, !Unaligned);
48364845
assert_impls!([u8; 1]: FromZeroes, FromBytes, AsBytes, Unaligned);
48374846
assert_impls!([NotZerocopy; 1]: !FromZeroes, !FromBytes, !AsBytes, !Unaligned);
4847+
4848+
#[cfg(feature = "simd")]
4849+
{
4850+
macro_rules! test_simd_arch_mod {
4851+
($arch:ident, $($typ:ident),*) => {
4852+
{
4853+
use core::arch::$arch::{$($typ),*};
4854+
use crate::*;
4855+
$( assert_impls!($typ: KnownLayout, FromZeroes, FromBytes, AsBytes, !Unaligned); )*
4856+
}
4857+
};
4858+
}
4859+
#[cfg(target_arch = "x86")]
4860+
test_simd_arch_mod!(x86, __m128, __m128d, __m128i, __m256, __m256d, __m256i);
4861+
4862+
#[cfg(target_arch = "x86_64")]
4863+
test_simd_arch_mod!(x86_64, __m128, __m128d, __m128i, __m256, __m256d, __m256i);
4864+
4865+
#[cfg(target_arch = "wasm32")]
4866+
test_simd_arch_mod!(wasm32, v128);
4867+
4868+
#[cfg(all(feature = "simd-nightly", target_arch = "powerpc"))]
4869+
test_simd_arch_mod!(
4870+
powerpc,
4871+
vector_bool_long,
4872+
vector_double,
4873+
vector_signed_long,
4874+
vector_unsigned_long
4875+
);
4876+
4877+
#[cfg(all(feature = "simd-nightly", target_arch = "powerpc64"))]
4878+
test_simd_arch_mod!(
4879+
powerpc64,
4880+
vector_bool_long,
4881+
vector_double,
4882+
vector_signed_long,
4883+
vector_unsigned_long
4884+
);
4885+
#[cfg(target_arch = "aarch64")]
4886+
#[rustfmt::skip]
4887+
test_simd_arch_mod!(
4888+
aarch64, float32x2_t, float32x4_t, float64x1_t, float64x2_t, int8x8_t, int8x8x2_t,
4889+
int8x8x3_t, int8x8x4_t, int8x16_t, int8x16x2_t, int8x16x3_t, int8x16x4_t, int16x4_t,
4890+
int16x8_t, int32x2_t, int32x4_t, int64x1_t, int64x2_t, poly8x8_t, poly8x8x2_t, poly8x8x3_t,
4891+
poly8x8x4_t, poly8x16_t, poly8x16x2_t, poly8x16x3_t, poly8x16x4_t, poly16x4_t, poly16x8_t,
4892+
poly64x1_t, poly64x2_t, uint8x8_t, uint8x8x2_t, uint8x8x3_t, uint8x8x4_t, uint8x16_t,
4893+
uint8x16x2_t, uint8x16x3_t, uint8x16x4_t, uint16x4_t, uint16x8_t, uint32x2_t, uint32x4_t,
4894+
uint64x1_t, uint64x2_t
4895+
);
4896+
#[cfg(all(feature = "simd-nightly", target_arch = "arm"))]
4897+
#[rustfmt::skip]
4898+
test_simd_arch_mod!(arm, int8x4_t, uint8x4_t);
4899+
}
48384900
}
48394901
}

0 commit comments

Comments
 (0)