diff options
| author | jyn <jyn.nelson@redjack.com> | 2023-04-02 19:30:32 -0400 |
|---|---|---|
| committer | jyn <jyn.nelson@redjack.com> | 2023-04-02 19:42:30 -0400 |
| commit | 01b75e20f2f92e3086bc004cd2f4430bf41ccdc0 (patch) | |
| tree | 757e8c283825445ecae6a3ccc0c32500bb7aca14 /tests/ui/unsafe | |
| parent | eb3e9c1f45981b47160543cfd882ca00e69bbfab (diff) | |
| download | rust-01b75e20f2f92e3086bc004cd2f4430bf41ccdc0.tar.gz rust-01b75e20f2f92e3086bc004cd2f4430bf41ccdc0.zip | |
Move some UI tests into subdirectories
to avoid going over the existing limit now that the ui-fulldeps tests have been moved to ui.
Diffstat (limited to 'tests/ui/unsafe')
| -rw-r--r-- | tests/ui/unsafe/foreign-unsafe-fn-called.mir.stderr | 11 | ||||
| -rw-r--r-- | tests/ui/unsafe/foreign-unsafe-fn-called.rs | 14 | ||||
| -rw-r--r-- | tests/ui/unsafe/foreign-unsafe-fn-called.thir.stderr | 11 | ||||
| -rw-r--r-- | tests/ui/unsafe/new-unsafe-pointers.rs | 7 | ||||
| -rw-r--r-- | tests/ui/unsafe/unsafe-fn-called-from-unsafe-blk.rs | 18 | ||||
| -rw-r--r-- | tests/ui/unsafe/unsafe-fn-called-from-unsafe-fn.rs | 17 | ||||
| -rw-r--r-- | tests/ui/unsafe/unsafe-pointer-assignability.rs | 11 |
7 files changed, 89 insertions, 0 deletions
diff --git a/tests/ui/unsafe/foreign-unsafe-fn-called.mir.stderr b/tests/ui/unsafe/foreign-unsafe-fn-called.mir.stderr new file mode 100644 index 00000000000..d3cf5d84fdd --- /dev/null +++ b/tests/ui/unsafe/foreign-unsafe-fn-called.mir.stderr @@ -0,0 +1,11 @@ +error[E0133]: call to unsafe function is unsafe and requires unsafe function or block + --> $DIR/foreign-unsafe-fn-called.rs:11:5 + | +LL | test::free(); + | ^^^^^^^^^^^^ call to unsafe function + | + = note: consult the function's documentation for information on how to avoid undefined behavior + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0133`. diff --git a/tests/ui/unsafe/foreign-unsafe-fn-called.rs b/tests/ui/unsafe/foreign-unsafe-fn-called.rs new file mode 100644 index 00000000000..67302ea1bcd --- /dev/null +++ b/tests/ui/unsafe/foreign-unsafe-fn-called.rs @@ -0,0 +1,14 @@ +// revisions: mir thir +// [thir]compile-flags: -Z thir-unsafeck + +mod test { + extern "C" { + pub fn free(); + } +} + +fn main() { + test::free(); + //[mir]~^ ERROR call to unsafe function is unsafe + //[thir]~^^ ERROR call to unsafe function `test::free` is unsafe +} diff --git a/tests/ui/unsafe/foreign-unsafe-fn-called.thir.stderr b/tests/ui/unsafe/foreign-unsafe-fn-called.thir.stderr new file mode 100644 index 00000000000..00ba0f7a6a3 --- /dev/null +++ b/tests/ui/unsafe/foreign-unsafe-fn-called.thir.stderr @@ -0,0 +1,11 @@ +error[E0133]: call to unsafe function `test::free` is unsafe and requires unsafe function or block + --> $DIR/foreign-unsafe-fn-called.rs:11:5 + | +LL | test::free(); + | ^^^^^^^^^^^^ call to unsafe function + | + = note: consult the function's documentation for information on how to avoid undefined behavior + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0133`. diff --git a/tests/ui/unsafe/new-unsafe-pointers.rs b/tests/ui/unsafe/new-unsafe-pointers.rs new file mode 100644 index 00000000000..d99eb4cbd1c --- /dev/null +++ b/tests/ui/unsafe/new-unsafe-pointers.rs @@ -0,0 +1,7 @@ +// run-pass +// pretty-expanded FIXME #23616 + +fn main() { + let _a: *const isize = 3 as *const isize; + let _a: *mut isize = 3 as *mut isize; +} diff --git a/tests/ui/unsafe/unsafe-fn-called-from-unsafe-blk.rs b/tests/ui/unsafe/unsafe-fn-called-from-unsafe-blk.rs new file mode 100644 index 00000000000..3713a7065f5 --- /dev/null +++ b/tests/ui/unsafe/unsafe-fn-called-from-unsafe-blk.rs @@ -0,0 +1,18 @@ +// run-pass + +#![allow(dead_code)] +// +// See also: ui/unsafe/unsafe-fn-called-from-safe.rs + +// pretty-expanded FIXME #23616 + +unsafe fn f() { return; } + +fn g() { + unsafe { + f(); + } +} + +pub fn main() { +} diff --git a/tests/ui/unsafe/unsafe-fn-called-from-unsafe-fn.rs b/tests/ui/unsafe/unsafe-fn-called-from-unsafe-fn.rs new file mode 100644 index 00000000000..5e953107686 --- /dev/null +++ b/tests/ui/unsafe/unsafe-fn-called-from-unsafe-fn.rs @@ -0,0 +1,17 @@ +// run-pass + +#![allow(dead_code)] +// +// See also: ui/unsafe/unsafe-fn-called-from-safe.rs + +// pretty-expanded FIXME #23616 + +unsafe fn f() { return; } + +unsafe fn g() { + f(); +} + +pub fn main() { + return; +} diff --git a/tests/ui/unsafe/unsafe-pointer-assignability.rs b/tests/ui/unsafe/unsafe-pointer-assignability.rs new file mode 100644 index 00000000000..db822bb6a02 --- /dev/null +++ b/tests/ui/unsafe/unsafe-pointer-assignability.rs @@ -0,0 +1,11 @@ +// run-pass + +fn f(x: *const isize) { + unsafe { + assert_eq!(*x, 3); + } +} + +pub fn main() { + f(&3); +} |
