@@ -54,6 +54,8 @@ pub(crate) fn generate_default_from_new(acc: &mut Assists, ctx: &AssistContext)
54
54
55
55
let impl_ = fn_node. syntax ( ) . ancestors ( ) . into_iter ( ) . find_map ( ast:: Impl :: cast) ?;
56
56
if is_default_implemented ( ctx, & impl_) {
57
+ mark:: hit!( default_block_is_already_present) ;
58
+ mark:: hit!( struct_in_module_with_default) ;
57
59
return None ;
58
60
}
59
61
@@ -86,20 +88,18 @@ impl Default for {} {{
86
88
fn is_default_implemented ( ctx : & AssistContext , impl_ : & Impl ) -> bool {
87
89
let db = ctx. sema . db ;
88
90
let impl_ = ctx. sema . to_def ( impl_) ;
89
- let impl_def;
90
- match impl_ {
91
- Some ( value) => impl_def = value,
91
+ let impl_def = match impl_ {
92
+ Some ( value) => value,
92
93
None => return false ,
93
- }
94
+ } ;
94
95
95
96
let ty = impl_def. target_ty ( db) ;
96
97
let krate = impl_def. module ( db) . krate ( ) ;
97
98
let default = FamousDefs ( & ctx. sema , Some ( krate) ) . core_default_Default ( ) ;
98
- let default_trait;
99
- match default {
100
- Some ( value) => default_trait = value,
99
+ let default_trait = match default {
100
+ Some ( value) => value,
101
101
None => return false ,
102
- }
102
+ } ;
103
103
104
104
ty. impls_trait ( db, default_trait, & [ ] )
105
105
}
@@ -199,7 +199,7 @@ impl Example {
199
199
r#"
200
200
struct Example { _inner: () }
201
201
202
- impl Exmaple {
202
+ impl Example {
203
203
pub fn a$0dd() -> Self {
204
204
Self { _inner: () }
205
205
}
@@ -211,6 +211,7 @@ impl Exmaple {
211
211
212
212
#[ test]
213
213
fn default_block_is_already_present ( ) {
214
+ mark:: check!( default_block_is_already_present) ;
214
215
check_not_applicable (
215
216
r#"
216
217
struct Example { _inner: () }
@@ -339,6 +340,7 @@ impl Default for Example {
339
340
340
341
#[ test]
341
342
fn struct_in_module_with_default ( ) {
343
+ mark:: check!( struct_in_module_with_default) ;
342
344
check_not_applicable (
343
345
r#"
344
346
mod test {
0 commit comments