Skip to content

Commit f9b22e7

Browse files
committed
[new_without_default]: make the suggestion machine-applicable
Now that generics and lifetimes are output as expected, the lint should be applicable.
1 parent 621e76d commit f9b22e7

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

clippy_lints/src/new_without_default.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ impl<'tcx> LateLintPass<'tcx> for NewWithoutDefault {
155155
&generics_sugg,
156156
&where_clause_sugg
157157
),
158-
Applicability::MaybeIncorrect,
158+
Applicability::MachineApplicable,
159159
);
160160
},
161161
);

tests/ui/new_without_default.fixed

+27-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,6 @@ impl<'c> LtKo<'c> {
102102
pub fn new() -> LtKo<'c> {
103103
unimplemented!()
104104
}
105-
// FIXME: that suggestion is missing lifetimes
106105
}
107106

108107
struct Private;
@@ -273,3 +272,30 @@ impl IgnoreLifetimeNew {
273272
Self
274273
}
275274
}
275+
276+
// From issue #11267
277+
278+
pub struct MyStruct<K, V>
279+
where
280+
K: std::hash::Hash + Eq + PartialEq,
281+
{
282+
_kv: Option<(K, V)>,
283+
}
284+
285+
impl<K, V> Default for MyStruct<K, V>
286+
where
287+
K: std::hash::Hash + Eq + PartialEq,
288+
{
289+
fn default() -> Self {
290+
Self::new()
291+
}
292+
}
293+
294+
impl<K, V> MyStruct<K, V>
295+
where
296+
K: std::hash::Hash + Eq + PartialEq,
297+
{
298+
pub fn new() -> Self {
299+
Self { _kv: None }
300+
}
301+
}

0 commit comments

Comments
 (0)