Skip to content

Commit 1b6c916

Browse files
committed
add test for #[expect]ing unsafe_derive_deserialize
Adding `#![feature(lint_reasons)]` to the top of the file also changed the line numbers in the expected error output.
1 parent fc2f703 commit 1b6c916

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

tests/ui/unsafe_derive_deserialize.rs

+11
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#![feature(lint_reasons)]
12
#![warn(clippy::unsafe_derive_deserialize)]
23
#![allow(unused, clippy::missing_safety_doc)]
34

@@ -71,4 +72,14 @@ impl G {
7172
}
7273
}
7374

75+
// Check that we honor the `expect` attribute on the ADT
76+
#[expect(clippy::unsafe_derive_deserialize)]
77+
#[derive(Deserialize)]
78+
pub struct H;
79+
impl H {
80+
pub fn unsafe_block(&self) {
81+
unsafe {}
82+
}
83+
}
84+
7485
fn main() {}

tests/ui/unsafe_derive_deserialize.stderr

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: you are deriving `serde::Deserialize` on a type that has methods using `unsafe`
2-
--> tests/ui/unsafe_derive_deserialize.rs:8:10
2+
--> tests/ui/unsafe_derive_deserialize.rs:9:10
33
|
44
LL | #[derive(Deserialize)]
55
| ^^^^^^^^^^^
@@ -10,7 +10,7 @@ LL | #[derive(Deserialize)]
1010
= note: this error originates in the derive macro `Deserialize` (in Nightly builds, run with -Z macro-backtrace for more info)
1111

1212
error: you are deriving `serde::Deserialize` on a type that has methods using `unsafe`
13-
--> tests/ui/unsafe_derive_deserialize.rs:17:10
13+
--> tests/ui/unsafe_derive_deserialize.rs:18:10
1414
|
1515
LL | #[derive(Deserialize)]
1616
| ^^^^^^^^^^^
@@ -19,7 +19,7 @@ LL | #[derive(Deserialize)]
1919
= note: this error originates in the derive macro `Deserialize` (in Nightly builds, run with -Z macro-backtrace for more info)
2020

2121
error: you are deriving `serde::Deserialize` on a type that has methods using `unsafe`
22-
--> tests/ui/unsafe_derive_deserialize.rs:24:10
22+
--> tests/ui/unsafe_derive_deserialize.rs:25:10
2323
|
2424
LL | #[derive(Deserialize)]
2525
| ^^^^^^^^^^^
@@ -28,7 +28,7 @@ LL | #[derive(Deserialize)]
2828
= note: this error originates in the derive macro `Deserialize` (in Nightly builds, run with -Z macro-backtrace for more info)
2929

3030
error: you are deriving `serde::Deserialize` on a type that has methods using `unsafe`
31-
--> tests/ui/unsafe_derive_deserialize.rs:33:10
31+
--> tests/ui/unsafe_derive_deserialize.rs:34:10
3232
|
3333
LL | #[derive(Deserialize)]
3434
| ^^^^^^^^^^^

0 commit comments

Comments
 (0)