Skip to content

Commit d1f0e9f

Browse files
Test THIR unsafeck for unsafe ops in closures
1 parent 6c4f40d commit d1f0e9f

17 files changed

+143
-15
lines changed

src/test/ui/async-await/async-await.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
// run-pass
22

3-
// revisions: default nomiropt
3+
// revisions: default nomiropt thirunsafeck
44
//[nomiropt]compile-flags: -Z mir-opt-level=0
5+
//[thirunsafeck]compile-flags: -Zthir-unsafeck
56

67
#![allow(unused)]
78

src/test/ui/command/command-pre-exec.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
// run-pass
2+
// revisions: mir thir
3+
// [thir]compile-flags: -Zthir-unsafeck
24

35
#![allow(stable_features)]
46
// ignore-windows - this is a unix-specific test

src/test/ui/generator/static-mut-reference-across-yield.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
// build-pass
2+
// revisions: mir thir
3+
// [thir]compile-flags: -Zthir-unsafeck
4+
25
#![feature(generators)]
36

47
static mut A: [i32; 5] = [1, 2, 3, 4, 5];

src/test/ui/intrinsics/panic-uninitialized-zeroed.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// run-pass
22
// ignore-wasm32-bare compiled with panic=abort by default
3+
// revisions: mir thir
4+
// [thir]compile-flags: -Zthir-unsafeck
35

46
// This test checks panic emitted from `mem::{uninitialized,zeroed}`.
57

src/test/ui/issues/issue-11740.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
// check-pass
2+
// revisions: mir thir
3+
// [thir]compile-flags: -Zthir-unsafeck
24

35
struct Attr {
46
name: String,

src/test/ui/issues/issue-39367.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
// run-pass
2+
// revisions: mir thir
3+
// [thir]compile-flags: -Zthir-unsafeck
4+
25
use std::ops::Deref;
36

47
struct ArenaSet<U: Deref, V=<U as Deref>::Target>(U, &'static V)

src/test/ui/issues/issue-45107-unnecessary-unsafe-in-closure.stderr renamed to src/test/ui/issues/issue-45107-unnecessary-unsafe-in-closure.mir.stderr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: unnecessary `unsafe` block
2-
--> $DIR/issue-45107-unnecessary-unsafe-in-closure.rs:7:13
2+
--> $DIR/issue-45107-unnecessary-unsafe-in-closure.rs:10:13
33
|
44
LL | unsafe {
55
| ------ because it's nested under this `unsafe` block
@@ -8,13 +8,13 @@ LL | unsafe {
88
| ^^^^^^ unnecessary `unsafe` block
99
|
1010
note: the lint level is defined here
11-
--> $DIR/issue-45107-unnecessary-unsafe-in-closure.rs:1:8
11+
--> $DIR/issue-45107-unnecessary-unsafe-in-closure.rs:4:8
1212
|
1313
LL | #[deny(unused_unsafe)]
1414
| ^^^^^^^^^^^^^
1515

1616
error: unnecessary `unsafe` block
17-
--> $DIR/issue-45107-unnecessary-unsafe-in-closure.rs:9:38
17+
--> $DIR/issue-45107-unnecessary-unsafe-in-closure.rs:12:38
1818
|
1919
LL | unsafe {
2020
| ------ because it's nested under this `unsafe` block
@@ -23,7 +23,7 @@ LL | |w: &mut Vec<u32>| { unsafe {
2323
| ^^^^^^ unnecessary `unsafe` block
2424

2525
error: unnecessary `unsafe` block
26-
--> $DIR/issue-45107-unnecessary-unsafe-in-closure.rs:13:34
26+
--> $DIR/issue-45107-unnecessary-unsafe-in-closure.rs:16:34
2727
|
2828
LL | unsafe {
2929
| ------ because it's nested under this `unsafe` block

src/test/ui/issues/issue-45107-unnecessary-unsafe-in-closure.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// revisions: mir thir
2+
// [thir]compile-flags: -Zthir-unsafeck
3+
14
#[deny(unused_unsafe)]
25
fn main() {
36
let mut v = Vec::<i32>::with_capacity(24);
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
error: unnecessary `unsafe` block
2+
--> $DIR/issue-45107-unnecessary-unsafe-in-closure.rs:10:13
3+
|
4+
LL | unsafe {
5+
| ------ because it's nested under this `unsafe` block
6+
LL | let f = |v: &mut Vec<_>| {
7+
LL | unsafe {
8+
| ^^^^^^ unnecessary `unsafe` block
9+
|
10+
note: the lint level is defined here
11+
--> $DIR/issue-45107-unnecessary-unsafe-in-closure.rs:4:8
12+
|
13+
LL | #[deny(unused_unsafe)]
14+
| ^^^^^^^^^^^^^
15+
16+
error: unnecessary `unsafe` block
17+
--> $DIR/issue-45107-unnecessary-unsafe-in-closure.rs:12:38
18+
|
19+
LL | unsafe {
20+
| ------ because it's nested under this `unsafe` block
21+
...
22+
LL | |w: &mut Vec<u32>| { unsafe {
23+
| ^^^^^^ unnecessary `unsafe` block
24+
25+
error: unnecessary `unsafe` block
26+
--> $DIR/issue-45107-unnecessary-unsafe-in-closure.rs:16:34
27+
|
28+
LL | unsafe {
29+
| ------ because it's nested under this `unsafe` block
30+
...
31+
LL | |x: &mut Vec<u32>| { unsafe {
32+
| ^^^^^^ unnecessary `unsafe` block
33+
34+
error: aborting due to 3 previous errors
35+

src/test/ui/lto-still-runs-thread-dtors.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
// compile-flags: -C lto
33
// no-prefer-dynamic
44
// ignore-emscripten no threads support
5+
// revisions: mir thir
6+
// [thir]compile-flags: -Zthir-unsafeck
57

68
use std::thread;
79

0 commit comments

Comments
 (0)