mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-23 21:23:56 +00:00
new_without_default should not warn about unsafe new
This commit is contained in:
parent
4511f4edf4
commit
59c4ff77f1
2 changed files with 10 additions and 0 deletions
|
@ -116,6 +116,10 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NewWithoutDefault {
|
|||
// can't be implemented by default
|
||||
return;
|
||||
}
|
||||
if sig.header.unsafety == hir::Unsafety::Unsafe {
|
||||
// can't be implemented for unsafe new
|
||||
return;
|
||||
}
|
||||
if impl_item.generics.params.iter().any(|gen| match gen.kind {
|
||||
hir::GenericParamKind::Type { .. } => true,
|
||||
_ => false
|
||||
|
|
|
@ -101,4 +101,10 @@ pub trait TraitWithNew: Sized {
|
|||
}
|
||||
}
|
||||
|
||||
pub struct IgnoreUnsafeNew;
|
||||
|
||||
impl IgnoreUnsafeNew {
|
||||
pub unsafe fn new() -> Self { IgnoreUnsafeNew }
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
Loading…
Reference in a new issue