diff options
| author | Yuki Okushi <huyuumi.dev@gmail.com> | 2020-04-16 15:50:32 +0900 |
|---|---|---|
| committer | Yuki Okushi <huyuumi.dev@gmail.com> | 2020-05-06 14:02:55 +0900 |
| commit | e69748ba4f48efdc9a1dfcf8c16bc9aba39a86e3 (patch) | |
| tree | 33fc77d7a08037da5deeb878068f5af0284aa732 /src/test/ui/array-slice-vec | |
| parent | 43271a39adc26d29350d4830b594c6435472815e (diff) | |
| download | rust-e69748ba4f48efdc9a1dfcf8c16bc9aba39a86e3.tar.gz rust-e69748ba4f48efdc9a1dfcf8c16bc9aba39a86e3.zip | |
Move tests from `test/run-fail` to UI
Diffstat (limited to 'src/test/ui/array-slice-vec')
| -rw-r--r-- | src/test/ui/array-slice-vec/bounds-check-no-overflow.rs | 10 | ||||
| -rw-r--r-- | src/test/ui/array-slice-vec/dst-raw-slice.rs | 11 |
2 files changed, 21 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..70cbb067254 --- /dev/null +++ b/src/test/ui/array-slice-vec/bounds-check-no-overflow.rs @@ -0,0 +1,10 @@ +// run-fail +// error-pattern:index out of bounds + +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..33db126944d --- /dev/null +++ b/src/test/ui/array-slice-vec/dst-raw-slice.rs @@ -0,0 +1,11 @@ +// Test bounds checking for DST raw slices + +// run-fail +// error-pattern:index out of bounds +#[allow(unconditional_panic)] +fn main() { + let a: *const [_] = &[1, 2, 3]; + unsafe { + let _b = (*a)[3]; + } +} |
