Add tests

This commit is contained in:
Gary Guo 2022-12-01 19:13:18 +00:00
parent aa5af2a003
commit f03c2aef47
6 changed files with 80 additions and 0 deletions

View File

@ -0,0 +1,11 @@
error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
--> $DIR/expr-unsafe-err.rs:8:9
|
LL | require_unsafe();
| ^^^^^^^^^^^^^^^^ 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`.

View File

@ -0,0 +1,11 @@
// revisions: mir thir
// [thir]compile-flags: -Z thir-unsafeck
#![feature(inline_const)]
const unsafe fn require_unsafe() -> usize { 1 }
fn main() {
const {
require_unsafe();
//~^ ERROR [E0133]
}
}

View File

@ -0,0 +1,11 @@
error[E0133]: call to unsafe function `require_unsafe` is unsafe and requires unsafe function or block
--> $DIR/expr-unsafe-err.rs:8:9
|
LL | require_unsafe();
| ^^^^^^^^^^^^^^^^ 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`.

View File

@ -0,0 +1,14 @@
warning: unnecessary `unsafe` block
--> $DIR/expr-unsafe.rs:12:13
|
LL | unsafe {}
| ^^^^^^ unnecessary `unsafe` block
|
note: the lint level is defined here
--> $DIR/expr-unsafe.rs:4:9
|
LL | #![warn(unused_unsafe)]
| ^^^^^^^^^^^^^
warning: 1 warning emitted

View File

@ -0,0 +1,16 @@
// check-pass
// revisions: mir thir
// [thir]compile-flags: -Z thir-unsafeck
#![warn(unused_unsafe)]
#![feature(inline_const)]
const unsafe fn require_unsafe() -> usize { 1 }
fn main() {
unsafe {
const {
require_unsafe();
unsafe {}
//~^ WARNING unnecessary `unsafe` block
}
}
}

View File

@ -0,0 +1,17 @@
warning: unnecessary `unsafe` block
--> $DIR/expr-unsafe.rs:12:13
|
LL | unsafe {
| ------ because it's nested under this `unsafe` block
...
LL | unsafe {}
| ^^^^^^ unnecessary `unsafe` block
|
note: the lint level is defined here
--> $DIR/expr-unsafe.rs:4:9
|
LL | #![warn(unused_unsafe)]
| ^^^^^^^^^^^^^
warning: 1 warning emitted