2020-04-19 16:11:30 -05:00
|
|
|
#![warn(clippy::unsafe_derive_deserialize)]
|
|
|
|
#![allow(unused, clippy::missing_safety_doc)]
|
|
|
|
|
|
|
|
extern crate serde;
|
|
|
|
|
|
|
|
use serde::Deserialize;
|
|
|
|
|
|
|
|
#[derive(Deserialize)]
|
2023-08-24 14:32:12 -05:00
|
|
|
//~^ ERROR: you are deriving `serde::Deserialize` on a type that has methods using `unsafe
|
2022-04-07 12:39:59 -05:00
|
|
|
pub struct A;
|
2020-04-19 16:11:30 -05:00
|
|
|
impl A {
|
|
|
|
pub unsafe fn new(_a: i32, _b: i32) -> Self {
|
|
|
|
Self {}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Deserialize)]
|
2023-08-24 14:32:12 -05:00
|
|
|
//~^ ERROR: you are deriving `serde::Deserialize` on a type that has methods using `unsafe
|
2022-04-07 12:39:59 -05:00
|
|
|
pub struct B;
|
2020-04-19 16:11:30 -05:00
|
|
|
impl B {
|
|
|
|
pub unsafe fn unsafe_method(&self) {}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Deserialize)]
|
2023-08-24 14:32:12 -05:00
|
|
|
//~^ ERROR: you are deriving `serde::Deserialize` on a type that has methods using `unsafe
|
2022-04-07 12:39:59 -05:00
|
|
|
pub struct C;
|
2020-04-19 16:11:30 -05:00
|
|
|
impl C {
|
|
|
|
pub fn unsafe_block(&self) {
|
|
|
|
unsafe {}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Deserialize)]
|
2023-08-24 14:32:12 -05:00
|
|
|
//~^ ERROR: you are deriving `serde::Deserialize` on a type that has methods using `unsafe
|
2022-04-07 12:39:59 -05:00
|
|
|
pub struct D;
|
2020-04-19 16:11:30 -05:00
|
|
|
impl D {
|
|
|
|
pub fn inner_unsafe_fn(&self) {
|
|
|
|
unsafe fn inner() {}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Does not derive `Deserialize`, should be ignored
|
2022-04-07 12:39:59 -05:00
|
|
|
pub struct E;
|
2020-04-19 16:11:30 -05:00
|
|
|
impl E {
|
|
|
|
pub unsafe fn new(_a: i32, _b: i32) -> Self {
|
|
|
|
Self {}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub unsafe fn unsafe_method(&self) {}
|
|
|
|
|
|
|
|
pub fn unsafe_block(&self) {
|
|
|
|
unsafe {}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn inner_unsafe_fn(&self) {
|
|
|
|
unsafe fn inner() {}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Does not have methods using `unsafe`, should be ignored
|
|
|
|
#[derive(Deserialize)]
|
2022-04-07 12:39:59 -05:00
|
|
|
pub struct F;
|
2020-04-19 16:11:30 -05:00
|
|
|
|
2020-08-11 08:43:21 -05:00
|
|
|
// Check that we honor the `allow` attribute on the ADT
|
|
|
|
#[allow(clippy::unsafe_derive_deserialize)]
|
|
|
|
#[derive(Deserialize)]
|
2022-04-07 12:39:59 -05:00
|
|
|
pub struct G;
|
2020-08-11 08:43:21 -05:00
|
|
|
impl G {
|
|
|
|
pub fn unsafe_block(&self) {
|
|
|
|
unsafe {}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-19 16:11:30 -05:00
|
|
|
fn main() {}
|