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

Commit b3d401e

Browse files
committed
Add unsafe markers to accomodate edition 2024 rules
- Add `unsafe` blocks inside `unsafe fn` using unsafe constructs - Add `unsafe` qualifier to `extern` blocks - Add `unsafe` qualifier to `no_mangle` attributes
1 parent d19c651 commit b3d401e

Some content is hidden

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

52 files changed

+640
-557
lines changed

tests/ui-toml/strict_non_send_fields_in_send_ty/test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ unsafe impl<T> Send for MyOption<T> {}
2929
//~^ non_send_fields_in_send_ty
3030

3131
// All fields are disallowed when raw pointer heuristic is off
32-
extern "C" {
32+
unsafe extern "C" {
3333
type NonSend;
3434
}
3535

tests/ui/asm_syntax_not_x86.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@ mod dont_warn {
88
use std::arch::{asm, global_asm};
99

1010
pub(super) unsafe fn use_asm() {
11-
asm!("");
12-
asm!("", options());
13-
asm!("", options(nostack));
11+
unsafe {
12+
asm!("");
13+
asm!("", options());
14+
asm!("", options(nostack));
15+
}
1416
}
1517

1618
global_asm!("");

tests/ui/asm_syntax_x86.rs

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,19 @@ mod warn_intel {
55
use std::arch::{asm, global_asm};
66

77
pub(super) unsafe fn use_asm() {
8-
asm!("");
9-
//~^ inline_asm_x86_intel_syntax
8+
unsafe {
9+
asm!("");
10+
//~^ inline_asm_x86_intel_syntax
1011

11-
asm!("", options());
12-
//~^ inline_asm_x86_intel_syntax
12+
asm!("", options());
13+
//~^ inline_asm_x86_intel_syntax
1314

14-
asm!("", options(nostack));
15-
//~^ inline_asm_x86_intel_syntax
15+
asm!("", options(nostack));
16+
//~^ inline_asm_x86_intel_syntax
1617

17-
asm!("", options(att_syntax));
18-
asm!("", options(nostack, att_syntax));
18+
asm!("", options(att_syntax));
19+
asm!("", options(nostack, att_syntax));
20+
}
1921
}
2022

2123
global_asm!("");
@@ -32,14 +34,16 @@ mod warn_att {
3234
use std::arch::{asm, global_asm};
3335

3436
pub(super) unsafe fn use_asm() {
35-
asm!("");
36-
asm!("", options());
37-
asm!("", options(nostack));
38-
asm!("", options(att_syntax));
39-
//~^ inline_asm_x86_att_syntax
40-
41-
asm!("", options(nostack, att_syntax));
42-
//~^ inline_asm_x86_att_syntax
37+
unsafe {
38+
asm!("");
39+
asm!("", options());
40+
asm!("", options(nostack));
41+
asm!("", options(att_syntax));
42+
//~^ inline_asm_x86_att_syntax
43+
44+
asm!("", options(nostack, att_syntax));
45+
//~^ inline_asm_x86_att_syntax
46+
}
4347
}
4448

4549
global_asm!("");

tests/ui/asm_syntax_x86.stderr

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,65 @@
11
error: Intel x86 assembly syntax used
2-
--> tests/ui/asm_syntax_x86.rs:8:9
2+
--> tests/ui/asm_syntax_x86.rs:9:13
33
|
4-
LL | asm!("");
5-
| ^^^^^^^^
4+
LL | asm!("");
5+
| ^^^^^^^^
66
|
77
= help: use AT&T x86 assembly syntax
88
= note: `-D clippy::inline-asm-x86-intel-syntax` implied by `-D warnings`
99
= help: to override `-D warnings` add `#[allow(clippy::inline_asm_x86_intel_syntax)]`
1010

1111
error: Intel x86 assembly syntax used
12-
--> tests/ui/asm_syntax_x86.rs:11:9
12+
--> tests/ui/asm_syntax_x86.rs:12:13
1313
|
14-
LL | asm!("", options());
15-
| ^^^^^^^^^^^^^^^^^^^
14+
LL | asm!("", options());
15+
| ^^^^^^^^^^^^^^^^^^^
1616
|
1717
= help: use AT&T x86 assembly syntax
1818

1919
error: Intel x86 assembly syntax used
20-
--> tests/ui/asm_syntax_x86.rs:14:9
20+
--> tests/ui/asm_syntax_x86.rs:15:13
2121
|
22-
LL | asm!("", options(nostack));
23-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
22+
LL | asm!("", options(nostack));
23+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
2424
|
2525
= help: use AT&T x86 assembly syntax
2626

2727
error: Intel x86 assembly syntax used
28-
--> tests/ui/asm_syntax_x86.rs:21:5
28+
--> tests/ui/asm_syntax_x86.rs:23:5
2929
|
3030
LL | global_asm!("");
3131
| ^^^^^^^^^^^^^^^
3232
|
3333
= help: use AT&T x86 assembly syntax
3434

3535
error: Intel x86 assembly syntax used
36-
--> tests/ui/asm_syntax_x86.rs:24:5
36+
--> tests/ui/asm_syntax_x86.rs:26:5
3737
|
3838
LL | global_asm!("", options());
3939
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
4040
|
4141
= help: use AT&T x86 assembly syntax
4242

4343
error: AT&T x86 assembly syntax used
44-
--> tests/ui/asm_syntax_x86.rs:38:9
44+
--> tests/ui/asm_syntax_x86.rs:41:13
4545
|
46-
LL | asm!("", options(att_syntax));
47-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
46+
LL | asm!("", options(att_syntax));
47+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
4848
|
4949
= help: use Intel x86 assembly syntax
5050
= note: `-D clippy::inline-asm-x86-att-syntax` implied by `-D warnings`
5151
= help: to override `-D warnings` add `#[allow(clippy::inline_asm_x86_att_syntax)]`
5252

5353
error: AT&T x86 assembly syntax used
54-
--> tests/ui/asm_syntax_x86.rs:41:9
54+
--> tests/ui/asm_syntax_x86.rs:44:13
5555
|
56-
LL | asm!("", options(nostack, att_syntax));
57-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
56+
LL | asm!("", options(nostack, att_syntax));
57+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
5858
|
5959
= help: use Intel x86 assembly syntax
6060

6161
error: AT&T x86 assembly syntax used
62-
--> tests/ui/asm_syntax_x86.rs:47:5
62+
--> tests/ui/asm_syntax_x86.rs:51:5
6363
|
6464
LL | global_asm!("", options(att_syntax));
6565
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

tests/ui/crashes/ice-7423.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ pub trait Trait {
66

77
impl Trait for usize {
88
fn f() {
9-
extern "C" {
9+
unsafe extern "C" {
1010
fn g() -> usize;
1111
}
1212
}

tests/ui/def_id_nocore.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#![allow(clippy::missing_safety_doc)]
66

77
#[link(name = "c")]
8-
extern "C" {}
8+
unsafe extern "C" {}
99

1010
#[lang = "sized"]
1111
pub trait Sized {}

tests/ui/doc/doc-fixable.fixed

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
//! This file tests for the `DOC_MARKDOWN` lint.
32

43
#![allow(dead_code, incomplete_features)]
@@ -272,7 +271,7 @@ fn parenthesized_word() {}
272271
/// UXes
273272
fn plural_acronym_test() {}
274273

275-
extern "C" {
274+
unsafe extern "C" {
276275
/// `foo()`
277276
//~^ doc_markdown
278277
fn in_extern();

tests/ui/doc/doc-fixable.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
//! This file tests for the `DOC_MARKDOWN` lint.
32
43
#![allow(dead_code, incomplete_features)]
@@ -272,7 +271,7 @@ fn parenthesized_word() {}
272271
/// UXes
273272
fn plural_acronym_test() {}
274273

275-
extern "C" {
274+
unsafe extern "C" {
276275
/// foo()
277276
//~^ doc_markdown
278277
fn in_extern();

0 commit comments

Comments
 (0)