Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit a95b342

Browse files
Test -Zthir-unsafeck for unsafe function calls
1 parent 29780f4 commit a95b342

File tree

46 files changed

+422
-45
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+422
-45
lines changed

src/test/ui/async-await/async-unsafe-fn-call-in-safe.stderr renamed to src/test/ui/async-await/async-unsafe-fn-call-in-safe.mir.stderr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
11
error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
2-
--> $DIR/async-unsafe-fn-call-in-safe.rs:12:5
2+
--> $DIR/async-unsafe-fn-call-in-safe.rs:14:5
33
|
44
LL | S::f();
55
| ^^^^^^ call to unsafe function
66
|
77
= note: consult the function's documentation for information on how to avoid undefined behavior
88

99
error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
10-
--> $DIR/async-unsafe-fn-call-in-safe.rs:13:5
10+
--> $DIR/async-unsafe-fn-call-in-safe.rs:15:5
1111
|
1212
LL | f();
1313
| ^^^ call to unsafe function
1414
|
1515
= note: consult the function's documentation for information on how to avoid undefined behavior
1616

1717
error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
18-
--> $DIR/async-unsafe-fn-call-in-safe.rs:17:5
18+
--> $DIR/async-unsafe-fn-call-in-safe.rs:19:5
1919
|
2020
LL | S::f();
2121
| ^^^^^^ call to unsafe function
2222
|
2323
= note: consult the function's documentation for information on how to avoid undefined behavior
2424

2525
error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
26-
--> $DIR/async-unsafe-fn-call-in-safe.rs:18:5
26+
--> $DIR/async-unsafe-fn-call-in-safe.rs:20:5
2727
|
2828
LL | f();
2929
| ^^^ call to unsafe function

src/test/ui/async-await/async-unsafe-fn-call-in-safe.rs

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

35
struct S;
46

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
2+
--> $DIR/async-unsafe-fn-call-in-safe.rs:14:5
3+
|
4+
LL | S::f();
5+
| ^^^^^^ call to unsafe function
6+
|
7+
= note: consult the function's documentation for information on how to avoid undefined behavior
8+
9+
error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
10+
--> $DIR/async-unsafe-fn-call-in-safe.rs:15:5
11+
|
12+
LL | f();
13+
| ^^^ call to unsafe function
14+
|
15+
= note: consult the function's documentation for information on how to avoid undefined behavior
16+
17+
error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
18+
--> $DIR/async-unsafe-fn-call-in-safe.rs:19:5
19+
|
20+
LL | S::f();
21+
| ^^^^^^ call to unsafe function
22+
|
23+
= note: consult the function's documentation for information on how to avoid undefined behavior
24+
25+
error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
26+
--> $DIR/async-unsafe-fn-call-in-safe.rs:20:5
27+
|
28+
LL | f();
29+
| ^^^ call to unsafe function
30+
|
31+
= note: consult the function's documentation for information on how to avoid undefined behavior
32+
33+
error: aborting due to 4 previous errors
34+
35+
For more information about this error, try `rustc --explain E0133`.

src/test/ui/closures/closure_no_cap_coerce_many_unsafe_0.stderr renamed to src/test/ui/closures/closure_no_cap_coerce_many_unsafe_0.mir.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
2-
--> $DIR/closure_no_cap_coerce_many_unsafe_0.rs:12:23
2+
--> $DIR/closure_no_cap_coerce_many_unsafe_0.rs:15:23
33
|
44
LL | let result: i32 = foo(5, 5);
55
| ^^^^^^^^^ call to unsafe function
66
|
77
= note: consult the function's documentation for information on how to avoid undefined behavior
88

99
error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
10-
--> $DIR/closure_no_cap_coerce_many_unsafe_0.rs:21:23
10+
--> $DIR/closure_no_cap_coerce_many_unsafe_0.rs:24:23
1111
|
1212
LL | let result: i32 = foo(5, 5);
1313
| ^^^^^^^^^ call to unsafe function

src/test/ui/closures/closure_no_cap_coerce_many_unsafe_0.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: -Z thir-unsafeck
3+
14
// Ensure we get unsafe function after coercion
25
unsafe fn add(a: i32, b: i32) -> i32 {
36
a + b
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
2+
--> $DIR/closure_no_cap_coerce_many_unsafe_0.rs:15:23
3+
|
4+
LL | let result: i32 = foo(5, 5);
5+
| ^^^^^^^^^ call to unsafe function
6+
|
7+
= note: consult the function's documentation for information on how to avoid undefined behavior
8+
9+
error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
10+
--> $DIR/closure_no_cap_coerce_many_unsafe_0.rs:24:23
11+
|
12+
LL | let result: i32 = foo(5, 5);
13+
| ^^^^^^^^^ call to unsafe function
14+
|
15+
= note: consult the function's documentation for information on how to avoid undefined behavior
16+
17+
error: aborting due to 2 previous errors
18+
19+
For more information about this error, try `rustc --explain E0133`.

src/test/ui/closures/coerce-unsafe-closure-to-unsafe-fn-ptr.stderr renamed to src/test/ui/closures/coerce-unsafe-closure-to-unsafe-fn-ptr.mir.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
2-
--> $DIR/coerce-unsafe-closure-to-unsafe-fn-ptr.rs:2:31
2+
--> $DIR/coerce-unsafe-closure-to-unsafe-fn-ptr.rs:5:31
33
|
44
LL | let _: unsafe fn() = || { ::std::pin::Pin::new_unchecked(&0_u8); };
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function

src/test/ui/closures/coerce-unsafe-closure-to-unsafe-fn-ptr.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: -Z thir-unsafeck
3+
14
fn main() {
25
let _: unsafe fn() = || { ::std::pin::Pin::new_unchecked(&0_u8); };
36
//~^ ERROR E0133
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/coerce-unsafe-closure-to-unsafe-fn-ptr.rs:5:31
3+
|
4+
LL | let _: unsafe fn() = || { ::std::pin::Pin::new_unchecked(&0_u8); };
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`.

src/test/ui/consts/const-extern-fn/const-extern-fn-requires-unsafe.stderr renamed to src/test/ui/consts/const-extern-fn/const-extern-fn-requires-unsafe.mir.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
2-
--> $DIR/const-extern-fn-requires-unsafe.rs:8:5
2+
--> $DIR/const-extern-fn-requires-unsafe.rs:11:5
33
|
44
LL | foo();
55
| ^^^^^ call to unsafe function
66
|
77
= note: consult the function's documentation for information on how to avoid undefined behavior
88

99
error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
10-
--> $DIR/const-extern-fn-requires-unsafe.rs:6:17
10+
--> $DIR/const-extern-fn-requires-unsafe.rs:9:17
1111
|
1212
LL | let a: [u8; foo()];
1313
| ^^^^^ call to unsafe function

0 commit comments

Comments
 (0)