[new_without_default]: make the suggestion machine-applicable

Now that generics and lifetimes are output as expected, the lint
should be applicable.
This commit is contained in:
Samuel Tardieu 2023-08-01 20:28:10 +02:00
parent 621e76d252
commit f9b22e7b84
2 changed files with 28 additions and 2 deletions

View File

@ -155,7 +155,7 @@ fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx hir::Item<'_>) {
&generics_sugg,
&where_clause_sugg
),
Applicability::MaybeIncorrect,
Applicability::MachineApplicable,
);
},
);

View File

@ -102,7 +102,6 @@ impl<'c> LtKo<'c> {
pub fn new() -> LtKo<'c> {
unimplemented!()
}
// FIXME: that suggestion is missing lifetimes
}
struct Private;
@ -273,3 +272,30 @@ impl IgnoreLifetimeNew {
Self
}
}
// From issue #11267
pub struct MyStruct<K, V>
where
K: std::hash::Hash + Eq + PartialEq,
{
_kv: Option<(K, V)>,
}
impl<K, V> Default for MyStruct<K, V>
where
K: std::hash::Hash + Eq + PartialEq,
{
fn default() -> Self {
Self::new()
}
}
impl<K, V> MyStruct<K, V>
where
K: std::hash::Hash + Eq + PartialEq,
{
pub fn new() -> Self {
Self { _kv: None }
}
}