@@ -415,7 +415,24 @@ fn inline(
415415        let  expr:  & ast:: Expr  = expr; 
416416
417417        let  mut  insert_let_stmt = || { 
418-             let  ty = sema. type_of_expr ( expr) . filter ( TypeInfo :: has_adjustment) . and ( param_ty. clone ( ) ) ; 
418+             let  param_ty = match  param_ty { 
419+                 None  => None , 
420+                 Some ( param_ty)  => { 
421+                     if  sema. hir_file_for ( param_ty. syntax ( ) ) . is_macro ( )  { 
422+                         if  let  Some ( param_ty)  =
423+                             ast:: Type :: cast ( insert_ws_into ( param_ty. syntax ( ) . clone ( ) ) ) 
424+                         { 
425+                             Some ( param_ty) 
426+                         }  else  { 
427+                             Some ( param_ty. clone_for_update ( ) ) 
428+                         } 
429+                     }  else  { 
430+                         Some ( param_ty. clone_for_update ( ) ) 
431+                     } 
432+                 } 
433+             } ; 
434+             let  ty:  Option < syntax:: ast:: Type >  =
435+                 sema. type_of_expr ( expr) . filter ( TypeInfo :: has_adjustment) . and ( param_ty) ; 
419436
420437            let  is_self = param
421438                . name ( sema. db ) 
@@ -1732,6 +1749,135 @@ pub fn main() {
17321749        this.0 += 1; 
17331750    }; 
17341751} 
1752+ "# , 
1753+         ) 
1754+     } 
1755+ 
1756+     #[ test]  
1757+     fn  inline_call_with_reference_in_macros ( )  { 
1758+         check_assist ( 
1759+             inline_call, 
1760+             r#" 
1761+ fn _write_u64(s: &mut u64, x: u64) { 
1762+     *s += x; 
1763+ } 
1764+ macro_rules! impl_write { 
1765+     ($(($ty:ident, $meth:ident),)*) => {$( 
1766+         fn _hash(inner_self_: &u64, state: &mut u64) { 
1767+             $meth(state, *inner_self_) 
1768+         } 
1769+     )*} 
1770+ } 
1771+ impl_write! { (u64, _write_u64), } 
1772+ fn _hash2(self_: &u64, state: &mut u64) { 
1773+     $0_hash(&self_, state); 
1774+ } 
1775+ "# , 
1776+             r#" 
1777+ fn _write_u64(s: &mut u64, x: u64) { 
1778+     *s += x; 
1779+ } 
1780+ macro_rules! impl_write { 
1781+     ($(($ty:ident, $meth:ident),)*) => {$( 
1782+         fn _hash(inner_self_: &u64, state: &mut u64) { 
1783+             $meth(state, *inner_self_) 
1784+         } 
1785+     )*} 
1786+ } 
1787+ impl_write! { (u64, _write_u64), } 
1788+ fn _hash2(self_: &u64, state: &mut u64) { 
1789+     { 
1790+         let inner_self_: &u64 = &self_; 
1791+         let state: &mut u64 = state; 
1792+       _write_u64(state, *inner_self_) 
1793+     }; 
1794+ } 
1795+ "# , 
1796+         ) 
1797+     } 
1798+ 
1799+     #[ test]  
1800+     fn  inline_call_with_reference_in_macro_generated_trait_impl ( )  { 
1801+         check_assist ( 
1802+             inline_call, 
1803+             r#" 
1804+ trait Hash2 { 
1805+     fn hash2<H: Hasher2>(&self, state: &mut H); 
1806+ } 
1807+ 
1808+ trait Hasher2 { 
1809+     fn write2_u64(&mut self, x: u64); 
1810+ } 
1811+ impl Hasher2 for u64 { 
1812+     fn write2_u64(&mut self, x: u64) { 
1813+         *self += x; 
1814+     } 
1815+ } 
1816+ 
1817+ macro_rules! impl_write { 
1818+     ($(($ty:ident, $meth:ident),)*) => {$( 
1819+         impl Hash2 for $ty { 
1820+             #[inline] 
1821+             fn hash2<H: Hasher2>(&self, state: &mut H) { 
1822+                 state.$meth(*self) 
1823+             } 
1824+         } 
1825+     )*} 
1826+ } 
1827+ 
1828+ impl_write! { (u64, write2_u64), } 
1829+ 
1830+ pub struct MyStruct { 
1831+     value: u64, 
1832+ } 
1833+ 
1834+ impl Hash2 for MyStruct { 
1835+     fn hash2<H: Hasher2>(&self, state: &mut H) { 
1836+         self.value.$0hash2(state) 
1837+     } 
1838+ } 
1839+ "# , 
1840+             // 
1841+             r#" 
1842+ trait Hash2 { 
1843+     fn hash2<H: Hasher2>(&self, state: &mut H); 
1844+ } 
1845+ 
1846+ trait Hasher2 { 
1847+     fn write2_u64(&mut self, x: u64); 
1848+ } 
1849+ impl Hasher2 for u64 { 
1850+     fn write2_u64(&mut self, x: u64) { 
1851+         *self += x; 
1852+     } 
1853+ } 
1854+ 
1855+ macro_rules! impl_write { 
1856+     ($(($ty:ident, $meth:ident),)*) => {$( 
1857+         impl Hash2 for $ty { 
1858+             #[inline] 
1859+             fn hash2<H: Hasher2>(&self, state: &mut H) { 
1860+                 state.$meth(*self) 
1861+             } 
1862+         } 
1863+     )*} 
1864+ } 
1865+ 
1866+ impl_write! { (u64, write2_u64), } 
1867+ 
1868+ pub struct MyStruct { 
1869+     value: u64, 
1870+ } 
1871+ 
1872+ impl Hash2 for MyStruct { 
1873+     fn hash2<H: Hasher2>(&self, state: &mut H) { 
1874+         { 
1875+             let this = &self.value; 
1876+             let state: &mut H = state; 
1877+           state.write2_u64(*this) 
1878+         } 
1879+     } 
1880+ } 
17351881"# , 
17361882        ) 
17371883    } 
0 commit comments