This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +82
-0
lines changed Expand file tree Collapse file tree 4 files changed +82
-0
lines changed Original file line number Diff line number Diff line change 1+ #![ deny( unused_unsafe) ]
2+
3+ unsafe fn unsf ( ) { }
4+
5+ unsafe fn foo ( ) {
6+ unsafe { //~ ERROR unnecessary `unsafe` block
7+ unsf ( )
8+ }
9+ }
10+
11+ fn main ( ) { }
Original file line number Diff line number Diff line change 1+ error: unnecessary `unsafe` block
2+ --> $DIR/feature-gate-unsafe_block_in_unsafe_fn.rs:6:5
3+ |
4+ LL | unsafe fn foo() {
5+ | --------------- because it's nested under this `unsafe` fn
6+ LL | unsafe {
7+ | ^^^^^^ unnecessary `unsafe` block
8+ |
9+ note: the lint level is defined here
10+ --> $DIR/feature-gate-unsafe_block_in_unsafe_fn.rs:1:9
11+ |
12+ LL | #![deny(unused_unsafe)]
13+ | ^^^^^^^^^^^^^
14+
15+ error: aborting due to previous error
16+
Original file line number Diff line number Diff line change 1+ #![ feature( unsafe_block_in_unsafe_fn) ]
2+ #![ warn( unsafe_op_in_unsafe_fn) ]
3+ #![ deny( unused_unsafe) ]
4+
5+ unsafe fn unsf ( ) { }
6+
7+ unsafe fn foo ( ) {
8+ unsf ( ) ;
9+ //~^ WARNING call to unsafe function is unsafe and requires unsafe block
10+ }
11+
12+ unsafe fn bar ( ) {
13+ unsafe { unsf ( ) } // no error
14+ }
15+
16+ unsafe fn baz ( ) {
17+ unsafe { unsafe { unsf ( ) } }
18+ //~^ ERROR unnecessary `unsafe` block
19+ }
20+
21+ #[ allow( unsafe_op_in_unsafe_fn) ]
22+ unsafe fn qux ( ) {
23+ unsf ( ) ; // no error
24+ }
25+
26+ fn main ( ) { }
Original file line number Diff line number Diff line change 1+ warning: call to unsafe function is unsafe and requires unsafe block (error E0133)
2+ --> $DIR/rfc-2585-unsafe_op_in_unsafe_fn.rs:8:5
3+ |
4+ LL | unsf();
5+ | ^^^^^^ call to unsafe function
6+ |
7+ note: the lint level is defined here
8+ --> $DIR/rfc-2585-unsafe_op_in_unsafe_fn.rs:2:9
9+ |
10+ LL | #![warn(unsafe_op_in_unsafe_fn)]
11+ | ^^^^^^^^^^^^^^^^^^^^^^
12+ = note: consult the function's documentation for information on how to avoid undefined behavior
13+
14+ error: unnecessary `unsafe` block
15+ --> $DIR/rfc-2585-unsafe_op_in_unsafe_fn.rs:17:14
16+ |
17+ LL | unsafe { unsafe { unsf() } }
18+ | ------ ^^^^^^ unnecessary `unsafe` block
19+ | |
20+ | because it's nested under this `unsafe` block
21+ |
22+ note: the lint level is defined here
23+ --> $DIR/rfc-2585-unsafe_op_in_unsafe_fn.rs:3:9
24+ |
25+ LL | #![deny(unused_unsafe)]
26+ | ^^^^^^^^^^^^^
27+
28+ error: aborting due to previous error; 1 warning emitted
29+
You can’t perform that action at this time.
0 commit comments