mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-28 20:16:58 +03:00
Fix new_without_default FP on private type with trait impl (#15782)
Closes rust-lang/rust-clippy#15778 changelog: [`new_without_default`] fix FP on private type with trait impl
This commit is contained in:
@@ -94,7 +94,7 @@ fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx hir::Item<'_>) {
|
||||
return;
|
||||
}
|
||||
if sig.decl.inputs.is_empty()
|
||||
&& cx.effective_visibilities.is_reachable(impl_item.owner_id.def_id)
|
||||
&& cx.effective_visibilities.is_exported(impl_item.owner_id.def_id)
|
||||
&& let self_ty = cx.tcx.type_of(item.owner_id).instantiate_identity()
|
||||
&& self_ty == return_ty(cx, impl_item.owner_id)
|
||||
&& let Some(default_trait_id) = cx.tcx.get_diagnostic_item(sym::Default)
|
||||
|
||||
@@ -322,3 +322,23 @@ where
|
||||
Self { _kv: None }
|
||||
}
|
||||
}
|
||||
|
||||
mod issue15778 {
|
||||
pub struct Foo(Vec<i32>);
|
||||
|
||||
impl Foo {
|
||||
pub fn new() -> Self {
|
||||
Self(Vec::new())
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> IntoIterator for &'a Foo {
|
||||
type Item = &'a i32;
|
||||
|
||||
type IntoIter = std::slice::Iter<'a, i32>;
|
||||
|
||||
fn into_iter(self) -> Self::IntoIter {
|
||||
self.0.as_slice().iter()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -265,3 +265,23 @@ pub fn new() -> Self {
|
||||
Self { _kv: None }
|
||||
}
|
||||
}
|
||||
|
||||
mod issue15778 {
|
||||
pub struct Foo(Vec<i32>);
|
||||
|
||||
impl Foo {
|
||||
pub fn new() -> Self {
|
||||
Self(Vec::new())
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> IntoIterator for &'a Foo {
|
||||
type Item = &'a i32;
|
||||
|
||||
type IntoIter = std::slice::Iter<'a, i32>;
|
||||
|
||||
fn into_iter(self) -> Self::IntoIter {
|
||||
self.0.as_slice().iter()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user