@@ -104,7 +104,14 @@ pub(crate) fn generate_mut_trait_impl(acc: &mut Assists, ctx: &AssistContext<'_>
104
104
format ! ( "Generate `{trait_new}` impl from this `{trait_name}` trait" ) ,
105
105
target,
106
106
|edit| {
107
- edit. insert ( target. start ( ) , format ! ( "$0{impl_def}\n \n {indent}" ) ) ;
107
+ edit. insert (
108
+ target. start ( ) ,
109
+ if ctx. config . snippet_cap . is_some ( ) {
110
+ format ! ( "$0{impl_def}\n \n {indent}" )
111
+ } else {
112
+ format ! ( "{impl_def}\n \n {indent}" )
113
+ } ,
114
+ ) ;
108
115
} ,
109
116
)
110
117
}
@@ -161,7 +168,10 @@ fn process_ret_type(ref_ty: &ast::RetType) -> Option<ast::Type> {
161
168
162
169
#[ cfg( test) ]
163
170
mod tests {
164
- use crate :: tests:: { check_assist, check_assist_not_applicable} ;
171
+ use crate :: {
172
+ AssistConfig ,
173
+ tests:: { TEST_CONFIG , check_assist, check_assist_not_applicable, check_assist_with_config} ,
174
+ } ;
165
175
166
176
use super :: * ;
167
177
@@ -402,6 +412,43 @@ impl<T> Index$0<i32> for [T; 3] {}
402
412
pub trait AsRef<T: ?Sized> {}
403
413
404
414
impl AsRef$0<i32> for [T; 3] {}
415
+ "# ,
416
+ ) ;
417
+ }
418
+
419
+ #[ test]
420
+ fn no_snippets ( ) {
421
+ check_assist_with_config (
422
+ generate_mut_trait_impl,
423
+ AssistConfig { snippet_cap : None , ..TEST_CONFIG } ,
424
+ r#"
425
+ //- minicore: index
426
+ pub enum Axis { X = 0, Y = 1, Z = 2 }
427
+
428
+ impl<T> core::ops::Index$0<Axis> for [T; 3] {
429
+ type Output = T;
430
+
431
+ fn index(&self, index: Axis) -> &Self::Output {
432
+ &self[index as usize]
433
+ }
434
+ }
435
+ "# ,
436
+ r#"
437
+ pub enum Axis { X = 0, Y = 1, Z = 2 }
438
+
439
+ impl<T> core::ops::IndexMut<Axis> for [T; 3] {
440
+ fn index_mut(&mut self, index: Axis) -> &mut Self::Output {
441
+ &mut self[index as usize]
442
+ }
443
+ }
444
+
445
+ impl<T> core::ops::Index<Axis> for [T; 3] {
446
+ type Output = T;
447
+
448
+ fn index(&self, index: Axis) -> &Self::Output {
449
+ &self[index as usize]
450
+ }
451
+ }
405
452
"# ,
406
453
) ;
407
454
}
0 commit comments