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)]
|
2022-03-27 07:41:09 -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)]
|
2022-03-27 07:41:09 -05:00
|
|
|
pub struct B;
|
2020-04-19 16:11:30 -05:00
|
|
|
impl B {
|
|
|
|
pub unsafe fn unsafe_method(&self) {}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Deserialize)]
|
2022-03-27 07:41:09 -05:00
|
|
|
pub struct C;
|
2020-04-19 16:11:30 -05:00
|
|
|
impl C {
|
|
|
|
pub fn unsafe_block(&self) {
|
|
|
|
unsafe {}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Deserialize)]
|
2022-03-27 07:41:09 -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-03-27 07:41:09 -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-03-27 07:41:09 -05:00
|
|
|
pub struct F;
|
2020-04-19 16:11:30 -05:00
|
|
|
|
2020-08-05 17:40:11 -05:00
|
|
|
// Check that we honor the `allow` attribute on the ADT
|
|
|
|
#[allow(clippy::unsafe_derive_deserialize)]
|
|
|
|
#[derive(Deserialize)]
|
2022-03-27 07:41:09 -05:00
|
|
|
pub struct G;
|
2020-08-05 17:40:11 -05:00
|
|
|
impl G {
|
|
|
|
pub fn unsafe_block(&self) {
|
|
|
|
unsafe {}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-19 16:11:30 -05:00
|
|
|
fn main() {}
|