diff options
| author | Ralf Jung <post@ralfj.de> | 2020-05-09 13:36:30 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-05-09 13:36:30 +0200 |
| commit | 1704dca270e86f5d33c84e1952897c2c33ad5256 (patch) | |
| tree | af3dac1da622a4621581fcc542329f0f77e22acb /src/test/ui/array-slice-vec | |
| parent | 2420b42ac665ee2235b15847cacf26c7fc9633c7 (diff) | |
| parent | 9a164ff4c59e19afbbc13072676d06aa2f70942e (diff) | |
| download | rust-1704dca270e86f5d33c84e1952897c2c33ad5256.tar.gz rust-1704dca270e86f5d33c84e1952897c2c33ad5256.zip | |
Rollup merge of #71185 - JohnTitor:run-fail, r=petrochenkov
Move tests from `test/run-fail` to UI Fixes #65440 cc #65865 #65506 r? @nikomatsakis
Diffstat (limited to 'src/test/ui/array-slice-vec')
| -rw-r--r-- | src/test/ui/array-slice-vec/bounds-check-no-overflow.rs | 11 | ||||
| -rw-r--r-- | src/test/ui/array-slice-vec/dst-raw-slice.rs | 13 |
2 files changed, 24 insertions, 0 deletions
diff --git a/src/test/ui/array-slice-vec/bounds-check-no-overflow.rs b/src/test/ui/array-slice-vec/bounds-check-no-overflow.rs new file mode 100644 index 00000000000..3caf5f44995 --- /dev/null +++ b/src/test/ui/array-slice-vec/bounds-check-no-overflow.rs @@ -0,0 +1,11 @@ +// run-fail +// error-pattern:index out of bounds +// ignore-emscripten no processes + +use std::usize; +use std::mem::size_of; + +fn main() { + let xs = [1, 2, 3]; + xs[usize::MAX / size_of::<isize>() + 1]; +} diff --git a/src/test/ui/array-slice-vec/dst-raw-slice.rs b/src/test/ui/array-slice-vec/dst-raw-slice.rs new file mode 100644 index 00000000000..371d16f093a --- /dev/null +++ b/src/test/ui/array-slice-vec/dst-raw-slice.rs @@ -0,0 +1,13 @@ +// Test bounds checking for DST raw slices + +// run-fail +// error-pattern:index out of bounds +// ignore-emscripten no processes + +#[allow(unconditional_panic)] +fn main() { + let a: *const [_] = &[1, 2, 3]; + unsafe { + let _b = (*a)[3]; + } +} |
