File tree 1 file changed +41
-2
lines changed
crates/ide-assists/src/handlers
1 file changed +41
-2
lines changed Original file line number Diff line number Diff line change @@ -282,8 +282,11 @@ fn generate_impl(
282
282
ai. assoc_items ( )
283
283
. filter ( |item| matches ! ( item, AssocItem :: MacroCall ( _) ) . not ( ) )
284
284
. for_each ( |item| {
285
- let assoc =
286
- process_assoc_item ( item, qualified_path_type. clone ( ) , field_name) ;
285
+ let assoc = process_assoc_item (
286
+ item. clone_for_update ( ) ,
287
+ qualified_path_type. clone ( ) ,
288
+ field_name,
289
+ ) ;
287
290
if let Some ( assoc) = assoc {
288
291
delegate_assoc_items. add_item ( assoc) ;
289
292
}
@@ -1797,4 +1800,40 @@ impl T for B {
1797
1800
"# ,
1798
1801
) ;
1799
1802
}
1803
+
1804
+ #[ test]
1805
+ fn assoc_items_attributes_mutably_cloned ( ) {
1806
+ check_assist (
1807
+ generate_delegate_trait,
1808
+ r#"
1809
+ pub struct A;
1810
+ pub trait C<D> {
1811
+ #[allow(clippy::dead_code)]
1812
+ fn a_funk(&self) -> &D;
1813
+ }
1814
+
1815
+ pub struct B<T: C<A>> {
1816
+ has_dr$0ain: T,
1817
+ }
1818
+ "# ,
1819
+ r#"
1820
+ pub struct A;
1821
+ pub trait C<D> {
1822
+ #[allow(clippy::dead_code)]
1823
+ fn a_funk(&self) -> &D;
1824
+ }
1825
+
1826
+ pub struct B<T: C<A>> {
1827
+ has_drain: T,
1828
+ }
1829
+
1830
+ impl<D, T: C<A>> C<D> for B<T> {
1831
+ #[allow(clippy::dead_code)]
1832
+ fn a_funk(&self) -> &D {
1833
+ <T as C<D>>::a_funk(&self.has_drain)
1834
+ }
1835
+ }
1836
+ "# ,
1837
+ )
1838
+ }
1800
1839
}
You can’t perform that action at this time.
0 commit comments