This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +41
-2
lines changed
src/tools/rust-analyzer/crates/ide-assists/src/handlers Expand file tree Collapse file tree 1 file changed +41
-2
lines changed Original file line number Diff line number Diff line change @@ -282,8 +282,11 @@ fn generate_impl(
282282 ai. assoc_items ( )
283283 . filter ( |item| matches ! ( item, AssocItem :: MacroCall ( _) ) . not ( ) )
284284 . 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+ ) ;
287290 if let Some ( assoc) = assoc {
288291 delegate_assoc_items. add_item ( assoc) ;
289292 }
@@ -1797,4 +1800,40 @@ impl T for B {
17971800"# ,
17981801 ) ;
17991802 }
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+ }
18001839}
You can’t perform that action at this time.
0 commit comments