Add tests
This commit is contained in:
parent
aa5af2a003
commit
f03c2aef47
6 changed files with 80 additions and 0 deletions
11
src/test/ui/inline-const/expr-unsafe-err.mir.stderr
Normal file
11
src/test/ui/inline-const/expr-unsafe-err.mir.stderr
Normal 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`.
|
11
src/test/ui/inline-const/expr-unsafe-err.rs
Normal file
11
src/test/ui/inline-const/expr-unsafe-err.rs
Normal 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]
|
||||
}
|
||||
}
|
11
src/test/ui/inline-const/expr-unsafe-err.thir.stderr
Normal file
11
src/test/ui/inline-const/expr-unsafe-err.thir.stderr
Normal 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`.
|
14
src/test/ui/inline-const/expr-unsafe.mir.stderr
Normal file
14
src/test/ui/inline-const/expr-unsafe.mir.stderr
Normal 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
|
||||
|
16
src/test/ui/inline-const/expr-unsafe.rs
Normal file
16
src/test/ui/inline-const/expr-unsafe.rs
Normal 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
|
||||
}
|
||||
}
|
||||
}
|
17
src/test/ui/inline-const/expr-unsafe.thir.stderr
Normal file
17
src/test/ui/inline-const/expr-unsafe.thir.stderr
Normal 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
|
||||
|
Loading…
Add table
Reference in a new issue