Merge pull request #3280 from d-dorazio/fix-new_without_default-should-not-fire-unsafe-new

new_without_default should not warn about unsafe new
This commit is contained in:
Philipp Hansch 2018-10-07 13:09:37 +01:00 committed by GitHub
commit 63ceabf0cf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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() {}