This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +63
-0
lines changed
tests/ui/rust-2024/unsafe-extern-blocks Expand file tree Collapse file tree 3 files changed +63
-0
lines changed Original file line number Diff line number Diff line change 1+ //@ run-rustfix
2+
3+ #![feature(unsafe_extern_blocks)]
4+ #![deny(missing_unsafe_on_extern)]
5+ #![allow(unused)]
6+
7+ unsafe extern "C" {
8+ //~^ ERROR extern blocks should be unsafe [missing_unsafe_on_extern]
9+ //~| WARN this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2024!
10+ static TEST1: i32;
11+ fn test1(i: i32);
12+ }
13+
14+ unsafe extern "C" {
15+ static TEST2: i32;
16+ fn test2(i: i32);
17+ }
18+
19+ fn main() {}
Original file line number Diff line number Diff line change 1+ //@ run-rustfix
2+
3+ #![ feature( unsafe_extern_blocks) ]
4+ #![ deny( missing_unsafe_on_extern) ]
5+ #![ allow( unused) ]
6+
7+ extern "C" {
8+ //~^ ERROR extern blocks should be unsafe [missing_unsafe_on_extern]
9+ //~| WARN this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2024!
10+ static TEST1 : i32 ;
11+ fn test1 ( i : i32 ) ;
12+ }
13+
14+ unsafe extern "C" {
15+ static TEST2 : i32 ;
16+ fn test2 ( i : i32 ) ;
17+ }
18+
19+ fn main ( ) { }
Original file line number Diff line number Diff line change 1+ error: extern blocks should be unsafe
2+ --> $DIR/unsafe-extern-suggestion.rs:7:1
3+ |
4+ LL | extern "C" {
5+ | ^
6+ | |
7+ | _help: needs `unsafe` before the extern keyword: `unsafe`
8+ | |
9+ LL | |
10+ LL | |
11+ LL | | static TEST1: i32;
12+ LL | | fn test1(i: i32);
13+ LL | | }
14+ | |_^
15+ |
16+ = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2024!
17+ = note: for more information, see issue #123743 <https://github.com/rust-lang/rust/issues/123743>
18+ note: the lint level is defined here
19+ --> $DIR/unsafe-extern-suggestion.rs:4:9
20+ |
21+ LL | #![deny(missing_unsafe_on_extern)]
22+ | ^^^^^^^^^^^^^^^^^^^^^^^^
23+
24+ error: aborting due to 1 previous error
25+
You can’t perform that action at this time.
0 commit comments