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.
This commit is contained in:
Jakob Schwarz 2024-05-15 18:21:20 +02:00
parent fc2f7035c6
commit 1b6c91628e
No known key found for this signature in database
GPG key ID: 5E5CCB0709EF8B92
2 changed files with 15 additions and 4 deletions

View file

@ -1,3 +1,4 @@
#![feature(lint_reasons)]
#![warn(clippy::unsafe_derive_deserialize)]
#![allow(unused, clippy::missing_safety_doc)]
@ -71,4 +72,14 @@ impl G {
}
}
// Check that we honor the `expect` attribute on the ADT
#[expect(clippy::unsafe_derive_deserialize)]
#[derive(Deserialize)]
pub struct H;
impl H {
pub fn unsafe_block(&self) {
unsafe {}
}
}
fn main() {}

View file

@ -1,5 +1,5 @@
error: you are deriving `serde::Deserialize` on a type that has methods using `unsafe`
--> tests/ui/unsafe_derive_deserialize.rs:8:10
--> tests/ui/unsafe_derive_deserialize.rs:9:10
|
LL | #[derive(Deserialize)]
| ^^^^^^^^^^^
@ -10,7 +10,7 @@ LL | #[derive(Deserialize)]
= note: this error originates in the derive macro `Deserialize` (in Nightly builds, run with -Z macro-backtrace for more info)
error: you are deriving `serde::Deserialize` on a type that has methods using `unsafe`
--> tests/ui/unsafe_derive_deserialize.rs:17:10
--> tests/ui/unsafe_derive_deserialize.rs:18:10
|
LL | #[derive(Deserialize)]
| ^^^^^^^^^^^
@ -19,7 +19,7 @@ LL | #[derive(Deserialize)]
= note: this error originates in the derive macro `Deserialize` (in Nightly builds, run with -Z macro-backtrace for more info)
error: you are deriving `serde::Deserialize` on a type that has methods using `unsafe`
--> tests/ui/unsafe_derive_deserialize.rs:24:10
--> tests/ui/unsafe_derive_deserialize.rs:25:10
|
LL | #[derive(Deserialize)]
| ^^^^^^^^^^^
@ -28,7 +28,7 @@ LL | #[derive(Deserialize)]
= note: this error originates in the derive macro `Deserialize` (in Nightly builds, run with -Z macro-backtrace for more info)
error: you are deriving `serde::Deserialize` on a type that has methods using `unsafe`
--> tests/ui/unsafe_derive_deserialize.rs:33:10
--> tests/ui/unsafe_derive_deserialize.rs:34:10
|
LL | #[derive(Deserialize)]
| ^^^^^^^^^^^