diff options
| author | Pankaj Chaudhary <pankajchaudhary172@gmail.com> | 2020-07-13 14:14:37 +0530 |
|---|---|---|
| committer | PankajChaudhary5 <pankajchaudhary172@gmail.com> | 2020-07-13 14:57:22 +0530 |
| commit | bc2b37aad7f9cbd1c97e416e6b16325b607422b8 (patch) | |
| tree | 867a6176bcf763bba6e5de12bc08f034a320ac56 /src/test/ui/array-slice-vec | |
| parent | e3ae4c7345cfd06b06c6996536d7c158ce6970db (diff) | |
| parent | 9d09331e00b02f81c714b0c41ce3a38380dd36a2 (diff) | |
| download | rust-bc2b37aad7f9cbd1c97e416e6b16325b607422b8.tar.gz rust-bc2b37aad7f9cbd1c97e416e6b16325b607422b8.zip | |
Merge branch 'master' into E0688
Diffstat (limited to 'src/test/ui/array-slice-vec')
5 files changed, 31 insertions, 5 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]; + } +} diff --git a/src/test/ui/array-slice-vec/match_arr_unknown_len.rs b/src/test/ui/array-slice-vec/match_arr_unknown_len.rs index 7f3da75ddcb..45b2889f1ca 100644 --- a/src/test/ui/array-slice-vec/match_arr_unknown_len.rs +++ b/src/test/ui/array-slice-vec/match_arr_unknown_len.rs @@ -1,5 +1,5 @@ #![feature(const_generics)] -//~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash +//~^ WARN the feature `const_generics` is incomplete fn is_123<const N: usize>(x: [u32; N]) -> bool { match x { diff --git a/src/test/ui/array-slice-vec/match_arr_unknown_len.stderr b/src/test/ui/array-slice-vec/match_arr_unknown_len.stderr index 09f65f6acd0..0ad05b3adeb 100644 --- a/src/test/ui/array-slice-vec/match_arr_unknown_len.stderr +++ b/src/test/ui/array-slice-vec/match_arr_unknown_len.stderr @@ -1,19 +1,20 @@ -warning: the feature `const_generics` is incomplete and may cause the compiler to crash +warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes --> $DIR/match_arr_unknown_len.rs:1:12 | LL | #![feature(const_generics)] | ^^^^^^^^^^^^^^ | = note: `#[warn(incomplete_features)]` on by default + = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information error[E0308]: mismatched types --> $DIR/match_arr_unknown_len.rs:6:9 | LL | [1, 2] => true, - | ^^^^^^ expected `2usize`, found `N` + | ^^^^^^ expected `2_usize`, found `N` | = note: expected array `[u32; 2]` - found array `[u32; _]` + found array `[u32; N]` error: aborting due to previous error; 1 warning emitted diff --git a/src/test/ui/array-slice-vec/subslice-patterns-const-eval-match.rs b/src/test/ui/array-slice-vec/subslice-patterns-const-eval-match.rs index 69c33921868..d8a9ae6ca20 100644 --- a/src/test/ui/array-slice-vec/subslice-patterns-const-eval-match.rs +++ b/src/test/ui/array-slice-vec/subslice-patterns-const-eval-match.rs @@ -2,7 +2,8 @@ // run-pass -#![feature(const_fn, const_if_match)] +#![feature(const_fn)] + #[derive(PartialEq, Debug, Clone)] struct N(u8); |
