Skip to content

Commit f03c2ae

Browse files
committed
Add tests
1 parent aa5af2a commit f03c2ae

File tree

6 files changed

+80
-0
lines changed

6 files changed

+80
-0
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
2+
--> $DIR/expr-unsafe-err.rs:8:9
3+
|
4+
LL | require_unsafe();
5+
| ^^^^^^^^^^^^^^^^ call to unsafe function
6+
|
7+
= note: consult the function's documentation for information on how to avoid undefined behavior
8+
9+
error: aborting due to previous error
10+
11+
For more information about this error, try `rustc --explain E0133`.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// revisions: mir thir
2+
// [thir]compile-flags: -Z thir-unsafeck
3+
#![feature(inline_const)]
4+
const unsafe fn require_unsafe() -> usize { 1 }
5+
6+
fn main() {
7+
const {
8+
require_unsafe();
9+
//~^ ERROR [E0133]
10+
}
11+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
error[E0133]: call to unsafe function `require_unsafe` is unsafe and requires unsafe function or block
2+
--> $DIR/expr-unsafe-err.rs:8:9
3+
|
4+
LL | require_unsafe();
5+
| ^^^^^^^^^^^^^^^^ call to unsafe function
6+
|
7+
= note: consult the function's documentation for information on how to avoid undefined behavior
8+
9+
error: aborting due to previous error
10+
11+
For more information about this error, try `rustc --explain E0133`.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
warning: unnecessary `unsafe` block
2+
--> $DIR/expr-unsafe.rs:12:13
3+
|
4+
LL | unsafe {}
5+
| ^^^^^^ unnecessary `unsafe` block
6+
|
7+
note: the lint level is defined here
8+
--> $DIR/expr-unsafe.rs:4:9
9+
|
10+
LL | #![warn(unused_unsafe)]
11+
| ^^^^^^^^^^^^^
12+
13+
warning: 1 warning emitted
14+
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// check-pass
2+
// revisions: mir thir
3+
// [thir]compile-flags: -Z thir-unsafeck
4+
#![warn(unused_unsafe)]
5+
#![feature(inline_const)]
6+
const unsafe fn require_unsafe() -> usize { 1 }
7+
8+
fn main() {
9+
unsafe {
10+
const {
11+
require_unsafe();
12+
unsafe {}
13+
//~^ WARNING unnecessary `unsafe` block
14+
}
15+
}
16+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
warning: unnecessary `unsafe` block
2+
--> $DIR/expr-unsafe.rs:12:13
3+
|
4+
LL | unsafe {
5+
| ------ because it's nested under this `unsafe` block
6+
...
7+
LL | unsafe {}
8+
| ^^^^^^ unnecessary `unsafe` block
9+
|
10+
note: the lint level is defined here
11+
--> $DIR/expr-unsafe.rs:4:9
12+
|
13+
LL | #![warn(unused_unsafe)]
14+
| ^^^^^^^^^^^^^
15+
16+
warning: 1 warning emitted
17+

0 commit comments

Comments
 (0)