only lint new_without_default for public items

This fixes #953.
This commit is contained in:
Andre Bogus 2016-06-01 23:35:14 +02:00
parent efeba8eec3
commit 49982036fc
2 changed files with 22 additions and 15 deletions

View file

@ -96,7 +96,8 @@ impl LateLintPass for NewWithoutDefault {
}
if let FnKind::Method(name, _, _, _) = kind {
if decl.inputs.is_empty() && name.as_str() == "new" {
if decl.inputs.is_empty() && name.as_str() == "new" &&
cx.access_levels.is_reachable(id) {
let self_ty = cx.tcx.lookup_item_type(cx.tcx.map.local_def_id(
cx.tcx.map.get_parent(id))).ty;
if_let_chain!{[