diff options
| author | Ben Kimock <kimockb@gmail.com> | 2024-02-07 10:30:11 -0500 |
|---|---|---|
| committer | Ben Kimock <kimockb@gmail.com> | 2024-02-08 19:56:30 -0500 |
| commit | 9e1b2d909bec461d334b412bdbc0d0f8ba6c17ed (patch) | |
| tree | 7396383989bcd68593ecc7f406fda79599894f61 | |
| parent | 88d6e9f868d7bd21aa2b6c641f8743fe7e53e67b (diff) | |
| download | rust-9e1b2d909bec461d334b412bdbc0d0f8ba6c17ed.tar.gz rust-9e1b2d909bec461d334b412bdbc0d0f8ba6c17ed.zip | |
Add new ui tests
| -rw-r--r-- | src/tools/tidy/src/ui_tests.rs | 2 | ||||
| -rw-r--r-- | tests/ui/precondition-checks/misaligned-slice.rs | 11 | ||||
| -rw-r--r-- | tests/ui/precondition-checks/null-slice.rs | 11 | ||||
| -rw-r--r-- | tests/ui/precondition-checks/out-of-bounds-get-unchecked.rs | 12 |
4 files changed, 35 insertions, 1 deletions
diff --git a/src/tools/tidy/src/ui_tests.rs b/src/tools/tidy/src/ui_tests.rs index 4a44c40debd..d5df05bacd9 100644 --- a/src/tools/tidy/src/ui_tests.rs +++ b/src/tools/tidy/src/ui_tests.rs @@ -15,7 +15,7 @@ use std::path::{Path, PathBuf}; const ENTRY_LIMIT: usize = 900; // FIXME: The following limits should be reduced eventually. const ISSUES_ENTRY_LIMIT: usize = 1819; -const ROOT_ENTRY_LIMIT: usize = 871; +const ROOT_ENTRY_LIMIT: usize = 872; const EXPECTED_TEST_FILE_EXTENSIONS: &[&str] = &[ "rs", // test source files diff --git a/tests/ui/precondition-checks/misaligned-slice.rs b/tests/ui/precondition-checks/misaligned-slice.rs new file mode 100644 index 00000000000..c961c800352 --- /dev/null +++ b/tests/ui/precondition-checks/misaligned-slice.rs @@ -0,0 +1,11 @@ +// run-fail +// compile-flags: -Copt-level=3 -Cdebug-assertions=yes +// error-pattern: unsafe precondition(s) violated: slice::from_raw_parts +// ignore-debug +// ignore-wasm32-bare no panic messages + +fn main() { + unsafe { + let _s: &[u64] = std::slice::from_raw_parts(1usize as *const u64, 0); + } +} diff --git a/tests/ui/precondition-checks/null-slice.rs b/tests/ui/precondition-checks/null-slice.rs new file mode 100644 index 00000000000..1e67e7f5fb1 --- /dev/null +++ b/tests/ui/precondition-checks/null-slice.rs @@ -0,0 +1,11 @@ +// run-fail +// compile-flags: -Copt-level=3 -Cdebug-assertions=yes +// error-pattern: unsafe precondition(s) violated: slice::from_raw_parts +// ignore-debug +// ignore-wasm32-bare no panic messages + +fn main() { + unsafe { + let _s: &[u8] = std::slice::from_raw_parts(std::ptr::null(), 0); + } +} diff --git a/tests/ui/precondition-checks/out-of-bounds-get-unchecked.rs b/tests/ui/precondition-checks/out-of-bounds-get-unchecked.rs new file mode 100644 index 00000000000..1366ba28f1c --- /dev/null +++ b/tests/ui/precondition-checks/out-of-bounds-get-unchecked.rs @@ -0,0 +1,12 @@ +// run-fail +// compile-flags: -Copt-level=3 -Cdebug-assertions=yes +// error-pattern: unsafe precondition(s) violated: hint::assert_unchecked +// ignore-debug +// ignore-wasm32-bare no panic messages + +fn main() { + unsafe { + let sli: &[u8] = &[0]; + sli.get_unchecked(1); + } +} |
