new_without_default should not warn about unsafe new

This commit is contained in:
Daniele D'Orazio 2018-10-07 12:39:54 +02:00
parent 4511f4edf4
commit 59c4ff77f1
2 changed files with 10 additions and 0 deletions

View file

@ -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

View file

@ -101,4 +101,10 @@ pub trait TraitWithNew: Sized {
}
}
pub struct IgnoreUnsafeNew;
impl IgnoreUnsafeNew {
pub unsafe fn new() -> Self { IgnoreUnsafeNew }
}
fn main() {}