diff options
Diffstat (limited to 'crates/ide_assists/src/handlers')
-rw-r--r-- | crates/ide_assists/src/handlers/extract_function.rs | 711 |
1 files changed, 409 insertions, 302 deletions
diff --git a/crates/ide_assists/src/handlers/extract_function.rs b/crates/ide_assists/src/handlers/extract_function.rs index 7085a0c48..43e83d683 100644 --- a/crates/ide_assists/src/handlers/extract_function.rs +++ b/crates/ide_assists/src/handlers/extract_function.rs | |||
@@ -831,6 +831,7 @@ fn path_element_of_reference( | |||
831 | })?; | 831 | })?; |
832 | stdx::always!( | 832 | stdx::always!( |
833 | matches!(path, ast::Expr::PathExpr(_) | ast::Expr::MacroCall(_)), | 833 | matches!(path, ast::Expr::PathExpr(_) | ast::Expr::MacroCall(_)), |
834 | |||
834 | "unexpected expression type for variable usage: {:?}", | 835 | "unexpected expression type for variable usage: {:?}", |
835 | path | 836 | path |
836 | ); | 837 | ); |
@@ -1501,7 +1502,8 @@ mod tests { | |||
1501 | r#" | 1502 | r#" |
1502 | fn foo() { | 1503 | fn foo() { |
1503 | foo($01 + 1$0); | 1504 | foo($01 + 1$0); |
1504 | }"#, | 1505 | } |
1506 | "#, | ||
1505 | r#" | 1507 | r#" |
1506 | fn foo() { | 1508 | fn foo() { |
1507 | foo(fun_name()); | 1509 | foo(fun_name()); |
@@ -1509,7 +1511,8 @@ fn foo() { | |||
1509 | 1511 | ||
1510 | fn $0fun_name() -> i32 { | 1512 | fn $0fun_name() -> i32 { |
1511 | 1 + 1 | 1513 | 1 + 1 |
1512 | }"#, | 1514 | } |
1515 | "#, | ||
1513 | ); | 1516 | ); |
1514 | } | 1517 | } |
1515 | 1518 | ||
@@ -1522,7 +1525,8 @@ mod bar { | |||
1522 | fn foo() { | 1525 | fn foo() { |
1523 | foo($01 + 1$0); | 1526 | foo($01 + 1$0); |
1524 | } | 1527 | } |
1525 | }"#, | 1528 | } |
1529 | "#, | ||
1526 | r#" | 1530 | r#" |
1527 | mod bar { | 1531 | mod bar { |
1528 | fn foo() { | 1532 | fn foo() { |
@@ -1532,7 +1536,8 @@ mod bar { | |||
1532 | fn $0fun_name() -> i32 { | 1536 | fn $0fun_name() -> i32 { |
1533 | 1 + 1 | 1537 | 1 + 1 |
1534 | } | 1538 | } |
1535 | }"#, | 1539 | } |
1540 | "#, | ||
1536 | ); | 1541 | ); |
1537 | } | 1542 | } |
1538 | 1543 | ||
@@ -1543,7 +1548,8 @@ mod bar { | |||
1543 | r#" | 1548 | r#" |
1544 | fn foo() { | 1549 | fn foo() { |
1545 | $0{ 1 + 1 }$0; | 1550 | $0{ 1 + 1 }$0; |
1546 | }"#, | 1551 | } |
1552 | "#, | ||
1547 | r#" | 1553 | r#" |
1548 | fn foo() { | 1554 | fn foo() { |
1549 | fun_name(); | 1555 | fun_name(); |
@@ -1551,7 +1557,8 @@ fn foo() { | |||
1551 | 1557 | ||
1552 | fn $0fun_name() -> i32 { | 1558 | fn $0fun_name() -> i32 { |
1553 | 1 + 1 | 1559 | 1 + 1 |
1554 | }"#, | 1560 | } |
1561 | "#, | ||
1555 | ); | 1562 | ); |
1556 | } | 1563 | } |
1557 | 1564 | ||
@@ -1564,7 +1571,8 @@ fn foo() -> i32 { | |||
1564 | let k = 1; | 1571 | let k = 1; |
1565 | $0let m = 1; | 1572 | $0let m = 1; |
1566 | m + 1$0 | 1573 | m + 1$0 |
1567 | }"#, | 1574 | } |
1575 | "#, | ||
1568 | r#" | 1576 | r#" |
1569 | fn foo() -> i32 { | 1577 | fn foo() -> i32 { |
1570 | let k = 1; | 1578 | let k = 1; |
@@ -1574,7 +1582,8 @@ fn foo() -> i32 { | |||
1574 | fn $0fun_name() -> i32 { | 1582 | fn $0fun_name() -> i32 { |
1575 | let m = 1; | 1583 | let m = 1; |
1576 | m + 1 | 1584 | m + 1 |
1577 | }"#, | 1585 | } |
1586 | "#, | ||
1578 | ); | 1587 | ); |
1579 | } | 1588 | } |
1580 | 1589 | ||
@@ -1588,7 +1597,8 @@ fn foo() { | |||
1588 | $0let m = 1; | 1597 | $0let m = 1; |
1589 | let n = m + 1;$0 | 1598 | let n = m + 1;$0 |
1590 | let g = 5; | 1599 | let g = 5; |
1591 | }"#, | 1600 | } |
1601 | "#, | ||
1592 | r#" | 1602 | r#" |
1593 | fn foo() { | 1603 | fn foo() { |
1594 | let k = 3; | 1604 | let k = 3; |
@@ -1599,7 +1609,8 @@ fn foo() { | |||
1599 | fn $0fun_name() { | 1609 | fn $0fun_name() { |
1600 | let m = 1; | 1610 | let m = 1; |
1601 | let n = m + 1; | 1611 | let n = m + 1; |
1602 | }"#, | 1612 | } |
1613 | "#, | ||
1603 | ); | 1614 | ); |
1604 | } | 1615 | } |
1605 | 1616 | ||
@@ -1610,7 +1621,8 @@ fn $0fun_name() { | |||
1610 | r#" | 1621 | r#" |
1611 | fn foo() { | 1622 | fn foo() { |
1612 | $0if true { }$0 | 1623 | $0if true { }$0 |
1613 | }"#, | 1624 | } |
1625 | "#, | ||
1614 | r#" | 1626 | r#" |
1615 | fn foo() { | 1627 | fn foo() { |
1616 | fun_name(); | 1628 | fun_name(); |
@@ -1618,7 +1630,8 @@ fn foo() { | |||
1618 | 1630 | ||
1619 | fn $0fun_name() { | 1631 | fn $0fun_name() { |
1620 | if true { } | 1632 | if true { } |
1621 | }"#, | 1633 | } |
1634 | "#, | ||
1622 | ); | 1635 | ); |
1623 | } | 1636 | } |
1624 | 1637 | ||
@@ -1629,7 +1642,8 @@ fn $0fun_name() { | |||
1629 | r#" | 1642 | r#" |
1630 | fn foo() -> i32 { | 1643 | fn foo() -> i32 { |
1631 | $0if true { 1 } else { 2 }$0 | 1644 | $0if true { 1 } else { 2 }$0 |
1632 | }"#, | 1645 | } |
1646 | "#, | ||
1633 | r#" | 1647 | r#" |
1634 | fn foo() -> i32 { | 1648 | fn foo() -> i32 { |
1635 | fun_name() | 1649 | fun_name() |
@@ -1637,7 +1651,8 @@ fn foo() -> i32 { | |||
1637 | 1651 | ||
1638 | fn $0fun_name() -> i32 { | 1652 | fn $0fun_name() -> i32 { |
1639 | if true { 1 } else { 2 } | 1653 | if true { 1 } else { 2 } |
1640 | }"#, | 1654 | } |
1655 | "#, | ||
1641 | ); | 1656 | ); |
1642 | } | 1657 | } |
1643 | 1658 | ||
@@ -1648,7 +1663,8 @@ fn $0fun_name() -> i32 { | |||
1648 | r#" | 1663 | r#" |
1649 | fn foo() -> i32 { | 1664 | fn foo() -> i32 { |
1650 | $0if let true = false { 1 } else { 2 }$0 | 1665 | $0if let true = false { 1 } else { 2 }$0 |
1651 | }"#, | 1666 | } |
1667 | "#, | ||
1652 | r#" | 1668 | r#" |
1653 | fn foo() -> i32 { | 1669 | fn foo() -> i32 { |
1654 | fun_name() | 1670 | fun_name() |
@@ -1656,7 +1672,8 @@ fn foo() -> i32 { | |||
1656 | 1672 | ||
1657 | fn $0fun_name() -> i32 { | 1673 | fn $0fun_name() -> i32 { |
1658 | if let true = false { 1 } else { 2 } | 1674 | if let true = false { 1 } else { 2 } |
1659 | }"#, | 1675 | } |
1676 | "#, | ||
1660 | ); | 1677 | ); |
1661 | } | 1678 | } |
1662 | 1679 | ||
@@ -1670,7 +1687,8 @@ fn foo() -> i32 { | |||
1670 | true => 1, | 1687 | true => 1, |
1671 | false => 2, | 1688 | false => 2, |
1672 | }$0 | 1689 | }$0 |
1673 | }"#, | 1690 | } |
1691 | "#, | ||
1674 | r#" | 1692 | r#" |
1675 | fn foo() -> i32 { | 1693 | fn foo() -> i32 { |
1676 | fun_name() | 1694 | fun_name() |
@@ -1681,7 +1699,8 @@ fn $0fun_name() -> i32 { | |||
1681 | true => 1, | 1699 | true => 1, |
1682 | false => 2, | 1700 | false => 2, |
1683 | } | 1701 | } |
1684 | }"#, | 1702 | } |
1703 | "#, | ||
1685 | ); | 1704 | ); |
1686 | } | 1705 | } |
1687 | 1706 | ||
@@ -1692,7 +1711,8 @@ fn $0fun_name() -> i32 { | |||
1692 | r#" | 1711 | r#" |
1693 | fn foo() { | 1712 | fn foo() { |
1694 | $0while true { }$0 | 1713 | $0while true { }$0 |
1695 | }"#, | 1714 | } |
1715 | "#, | ||
1696 | r#" | 1716 | r#" |
1697 | fn foo() { | 1717 | fn foo() { |
1698 | fun_name(); | 1718 | fun_name(); |
@@ -1700,7 +1720,8 @@ fn foo() { | |||
1700 | 1720 | ||
1701 | fn $0fun_name() { | 1721 | fn $0fun_name() { |
1702 | while true { } | 1722 | while true { } |
1703 | }"#, | 1723 | } |
1724 | "#, | ||
1704 | ); | 1725 | ); |
1705 | } | 1726 | } |
1706 | 1727 | ||
@@ -1711,7 +1732,8 @@ fn $0fun_name() { | |||
1711 | r#" | 1732 | r#" |
1712 | fn foo() { | 1733 | fn foo() { |
1713 | $0for v in &[0, 1] { }$0 | 1734 | $0for v in &[0, 1] { }$0 |
1714 | }"#, | 1735 | } |
1736 | "#, | ||
1715 | r#" | 1737 | r#" |
1716 | fn foo() { | 1738 | fn foo() { |
1717 | fun_name(); | 1739 | fun_name(); |
@@ -1719,7 +1741,8 @@ fn foo() { | |||
1719 | 1741 | ||
1720 | fn $0fun_name() { | 1742 | fn $0fun_name() { |
1721 | for v in &[0, 1] { } | 1743 | for v in &[0, 1] { } |
1722 | }"#, | 1744 | } |
1745 | "#, | ||
1723 | ); | 1746 | ); |
1724 | } | 1747 | } |
1725 | 1748 | ||
@@ -1732,7 +1755,8 @@ fn foo() { | |||
1732 | $0loop { | 1755 | $0loop { |
1733 | let m = 1; | 1756 | let m = 1; |
1734 | }$0 | 1757 | }$0 |
1735 | }"#, | 1758 | } |
1759 | "#, | ||
1736 | r#" | 1760 | r#" |
1737 | fn foo() { | 1761 | fn foo() { |
1738 | fun_name() | 1762 | fun_name() |
@@ -1742,7 +1766,8 @@ fn $0fun_name() -> ! { | |||
1742 | loop { | 1766 | loop { |
1743 | let m = 1; | 1767 | let m = 1; |
1744 | } | 1768 | } |
1745 | }"#, | 1769 | } |
1770 | "#, | ||
1746 | ); | 1771 | ); |
1747 | } | 1772 | } |
1748 | 1773 | ||
@@ -1756,7 +1781,8 @@ fn foo() { | |||
1756 | let m = 1; | 1781 | let m = 1; |
1757 | break m; | 1782 | break m; |
1758 | }$0; | 1783 | }$0; |
1759 | }"#, | 1784 | } |
1785 | "#, | ||
1760 | r#" | 1786 | r#" |
1761 | fn foo() { | 1787 | fn foo() { |
1762 | let v = fun_name(); | 1788 | let v = fun_name(); |
@@ -1767,7 +1793,8 @@ fn $0fun_name() -> i32 { | |||
1767 | let m = 1; | 1793 | let m = 1; |
1768 | break m; | 1794 | break m; |
1769 | } | 1795 | } |
1770 | }"#, | 1796 | } |
1797 | "#, | ||
1771 | ); | 1798 | ); |
1772 | } | 1799 | } |
1773 | 1800 | ||
@@ -1781,7 +1808,8 @@ fn foo() { | |||
1781 | Some(x) => x, | 1808 | Some(x) => x, |
1782 | None => 0, | 1809 | None => 0, |
1783 | }$0; | 1810 | }$0; |
1784 | }"#, | 1811 | } |
1812 | "#, | ||
1785 | r#" | 1813 | r#" |
1786 | fn foo() { | 1814 | fn foo() { |
1787 | let v: i32 = fun_name(); | 1815 | let v: i32 = fun_name(); |
@@ -1792,7 +1820,8 @@ fn $0fun_name() -> i32 { | |||
1792 | Some(x) => x, | 1820 | Some(x) => x, |
1793 | None => 0, | 1821 | None => 0, |
1794 | } | 1822 | } |
1795 | }"#, | 1823 | } |
1824 | "#, | ||
1796 | ); | 1825 | ); |
1797 | } | 1826 | } |
1798 | 1827 | ||
@@ -1805,7 +1834,8 @@ fn foo() { | |||
1805 | let n = 1; | 1834 | let n = 1; |
1806 | let mut v = $0n * n;$0 | 1835 | let mut v = $0n * n;$0 |
1807 | v += 1; | 1836 | v += 1; |
1808 | }"#, | 1837 | } |
1838 | "#, | ||
1809 | r#" | 1839 | r#" |
1810 | fn foo() { | 1840 | fn foo() { |
1811 | let n = 1; | 1841 | let n = 1; |
@@ -1816,7 +1846,8 @@ fn foo() { | |||
1816 | fn $0fun_name(n: i32) -> i32 { | 1846 | fn $0fun_name(n: i32) -> i32 { |
1817 | let mut v = n * n; | 1847 | let mut v = n * n; |
1818 | v | 1848 | v |
1819 | }"#, | 1849 | } |
1850 | "#, | ||
1820 | ); | 1851 | ); |
1821 | } | 1852 | } |
1822 | 1853 | ||
@@ -1832,7 +1863,8 @@ fn foo() { | |||
1832 | let mut w = 3;$0 | 1863 | let mut w = 3;$0 |
1833 | v += 1; | 1864 | v += 1; |
1834 | w += 1; | 1865 | w += 1; |
1835 | }"#, | 1866 | } |
1867 | "#, | ||
1836 | r#" | 1868 | r#" |
1837 | fn foo() { | 1869 | fn foo() { |
1838 | let m = 2; | 1870 | let m = 2; |
@@ -1846,7 +1878,8 @@ fn $0fun_name(m: i32, n: i32) -> (i32, i32) { | |||
1846 | let mut v = m * n; | 1878 | let mut v = m * n; |
1847 | let mut w = 3; | 1879 | let mut w = 3; |
1848 | (v, w) | 1880 | (v, w) |
1849 | }"#, | 1881 | } |
1882 | "#, | ||
1850 | ); | 1883 | ); |
1851 | } | 1884 | } |
1852 | 1885 | ||
@@ -1854,12 +1887,13 @@ fn $0fun_name(m: i32, n: i32) -> (i32, i32) { | |||
1854 | fn argument_form_expr() { | 1887 | fn argument_form_expr() { |
1855 | check_assist( | 1888 | check_assist( |
1856 | extract_function, | 1889 | extract_function, |
1857 | r" | 1890 | r#" |
1858 | fn foo() -> u32 { | 1891 | fn foo() -> u32 { |
1859 | let n = 2; | 1892 | let n = 2; |
1860 | $0n+2$0 | 1893 | $0n+2$0 |
1861 | }", | 1894 | } |
1862 | r" | 1895 | "#, |
1896 | r#" | ||
1863 | fn foo() -> u32 { | 1897 | fn foo() -> u32 { |
1864 | let n = 2; | 1898 | let n = 2; |
1865 | fun_name(n) | 1899 | fun_name(n) |
@@ -1867,7 +1901,8 @@ fn foo() -> u32 { | |||
1867 | 1901 | ||
1868 | fn $0fun_name(n: u32) -> u32 { | 1902 | fn $0fun_name(n: u32) -> u32 { |
1869 | n+2 | 1903 | n+2 |
1870 | }", | 1904 | } |
1905 | "#, | ||
1871 | ) | 1906 | ) |
1872 | } | 1907 | } |
1873 | 1908 | ||
@@ -1875,12 +1910,13 @@ fn $0fun_name(n: u32) -> u32 { | |||
1875 | fn argument_used_twice_form_expr() { | 1910 | fn argument_used_twice_form_expr() { |
1876 | check_assist( | 1911 | check_assist( |
1877 | extract_function, | 1912 | extract_function, |
1878 | r" | 1913 | r#" |
1879 | fn foo() -> u32 { | 1914 | fn foo() -> u32 { |
1880 | let n = 2; | 1915 | let n = 2; |
1881 | $0n+n$0 | 1916 | $0n+n$0 |
1882 | }", | 1917 | } |
1883 | r" | 1918 | "#, |
1919 | r#" | ||
1884 | fn foo() -> u32 { | 1920 | fn foo() -> u32 { |
1885 | let n = 2; | 1921 | let n = 2; |
1886 | fun_name(n) | 1922 | fun_name(n) |
@@ -1888,7 +1924,8 @@ fn foo() -> u32 { | |||
1888 | 1924 | ||
1889 | fn $0fun_name(n: u32) -> u32 { | 1925 | fn $0fun_name(n: u32) -> u32 { |
1890 | n+n | 1926 | n+n |
1891 | }", | 1927 | } |
1928 | "#, | ||
1892 | ) | 1929 | ) |
1893 | } | 1930 | } |
1894 | 1931 | ||
@@ -1896,13 +1933,14 @@ fn $0fun_name(n: u32) -> u32 { | |||
1896 | fn two_arguments_form_expr() { | 1933 | fn two_arguments_form_expr() { |
1897 | check_assist( | 1934 | check_assist( |
1898 | extract_function, | 1935 | extract_function, |
1899 | r" | 1936 | r#" |
1900 | fn foo() -> u32 { | 1937 | fn foo() -> u32 { |
1901 | let n = 2; | 1938 | let n = 2; |
1902 | let m = 3; | 1939 | let m = 3; |
1903 | $0n+n*m$0 | 1940 | $0n+n*m$0 |
1904 | }", | 1941 | } |
1905 | r" | 1942 | "#, |
1943 | r#" | ||
1906 | fn foo() -> u32 { | 1944 | fn foo() -> u32 { |
1907 | let n = 2; | 1945 | let n = 2; |
1908 | let m = 3; | 1946 | let m = 3; |
@@ -1911,7 +1949,8 @@ fn foo() -> u32 { | |||
1911 | 1949 | ||
1912 | fn $0fun_name(n: u32, m: u32) -> u32 { | 1950 | fn $0fun_name(n: u32, m: u32) -> u32 { |
1913 | n+n*m | 1951 | n+n*m |
1914 | }", | 1952 | } |
1953 | "#, | ||
1915 | ) | 1954 | ) |
1916 | } | 1955 | } |
1917 | 1956 | ||
@@ -1919,13 +1958,14 @@ fn $0fun_name(n: u32, m: u32) -> u32 { | |||
1919 | fn argument_and_locals() { | 1958 | fn argument_and_locals() { |
1920 | check_assist( | 1959 | check_assist( |
1921 | extract_function, | 1960 | extract_function, |
1922 | r" | 1961 | r#" |
1923 | fn foo() -> u32 { | 1962 | fn foo() -> u32 { |
1924 | let n = 2; | 1963 | let n = 2; |
1925 | $0let m = 1; | 1964 | $0let m = 1; |
1926 | n + m$0 | 1965 | n + m$0 |
1927 | }", | 1966 | } |
1928 | r" | 1967 | "#, |
1968 | r#" | ||
1929 | fn foo() -> u32 { | 1969 | fn foo() -> u32 { |
1930 | let n = 2; | 1970 | let n = 2; |
1931 | fun_name(n) | 1971 | fun_name(n) |
@@ -1934,7 +1974,8 @@ fn foo() -> u32 { | |||
1934 | fn $0fun_name(n: u32) -> u32 { | 1974 | fn $0fun_name(n: u32) -> u32 { |
1935 | let m = 1; | 1975 | let m = 1; |
1936 | n + m | 1976 | n + m |
1937 | }", | 1977 | } |
1978 | "#, | ||
1938 | ) | 1979 | ) |
1939 | } | 1980 | } |
1940 | 1981 | ||
@@ -1948,18 +1989,20 @@ fn $0fun_name(n: u32) -> u32 { | |||
1948 | fn part_of_expr_stmt() { | 1989 | fn part_of_expr_stmt() { |
1949 | check_assist( | 1990 | check_assist( |
1950 | extract_function, | 1991 | extract_function, |
1951 | " | 1992 | r#" |
1952 | fn foo() { | 1993 | fn foo() { |
1953 | $01$0 + 1; | 1994 | $01$0 + 1; |
1954 | }", | 1995 | } |
1955 | " | 1996 | "#, |
1997 | r#" | ||
1956 | fn foo() { | 1998 | fn foo() { |
1957 | fun_name() + 1; | 1999 | fun_name() + 1; |
1958 | } | 2000 | } |
1959 | 2001 | ||
1960 | fn $0fun_name() -> i32 { | 2002 | fn $0fun_name() -> i32 { |
1961 | 1 | 2003 | 1 |
1962 | }", | 2004 | } |
2005 | "#, | ||
1963 | ); | 2006 | ); |
1964 | } | 2007 | } |
1965 | 2008 | ||
@@ -1970,7 +2013,8 @@ fn $0fun_name() -> i32 { | |||
1970 | r#" | 2013 | r#" |
1971 | fn foo() { | 2014 | fn foo() { |
1972 | $0bar(1 + 1)$0 | 2015 | $0bar(1 + 1)$0 |
1973 | }"#, | 2016 | } |
2017 | "#, | ||
1974 | r#" | 2018 | r#" |
1975 | fn foo() { | 2019 | fn foo() { |
1976 | fun_name(); | 2020 | fun_name(); |
@@ -1978,7 +2022,8 @@ fn foo() { | |||
1978 | 2022 | ||
1979 | fn $0fun_name() { | 2023 | fn $0fun_name() { |
1980 | bar(1 + 1) | 2024 | bar(1 + 1) |
1981 | }"#, | 2025 | } |
2026 | "#, | ||
1982 | ) | 2027 | ) |
1983 | } | 2028 | } |
1984 | 2029 | ||
@@ -1986,15 +2031,16 @@ fn $0fun_name() { | |||
1986 | fn extract_from_nested() { | 2031 | fn extract_from_nested() { |
1987 | check_assist( | 2032 | check_assist( |
1988 | extract_function, | 2033 | extract_function, |
1989 | r" | 2034 | r#" |
1990 | fn main() { | 2035 | fn main() { |
1991 | let x = true; | 2036 | let x = true; |
1992 | let tuple = match x { | 2037 | let tuple = match x { |
1993 | true => ($02 + 2$0, true) | 2038 | true => ($02 + 2$0, true) |
1994 | _ => (0, false) | 2039 | _ => (0, false) |
1995 | }; | 2040 | }; |
1996 | }", | 2041 | } |
1997 | r" | 2042 | "#, |
2043 | r#" | ||
1998 | fn main() { | 2044 | fn main() { |
1999 | let x = true; | 2045 | let x = true; |
2000 | let tuple = match x { | 2046 | let tuple = match x { |
@@ -2005,7 +2051,8 @@ fn main() { | |||
2005 | 2051 | ||
2006 | fn $0fun_name() -> i32 { | 2052 | fn $0fun_name() -> i32 { |
2007 | 2 + 2 | 2053 | 2 + 2 |
2008 | }", | 2054 | } |
2055 | "#, | ||
2009 | ); | 2056 | ); |
2010 | } | 2057 | } |
2011 | 2058 | ||
@@ -2013,18 +2060,20 @@ fn $0fun_name() -> i32 { | |||
2013 | fn param_from_closure() { | 2060 | fn param_from_closure() { |
2014 | check_assist( | 2061 | check_assist( |
2015 | extract_function, | 2062 | extract_function, |
2016 | r" | 2063 | r#" |
2017 | fn main() { | 2064 | fn main() { |
2018 | let lambda = |x: u32| $0x * 2$0; | 2065 | let lambda = |x: u32| $0x * 2$0; |
2019 | }", | 2066 | } |
2020 | r" | 2067 | "#, |
2068 | r#" | ||
2021 | fn main() { | 2069 | fn main() { |
2022 | let lambda = |x: u32| fun_name(x); | 2070 | let lambda = |x: u32| fun_name(x); |
2023 | } | 2071 | } |
2024 | 2072 | ||
2025 | fn $0fun_name(x: u32) -> u32 { | 2073 | fn $0fun_name(x: u32) -> u32 { |
2026 | x * 2 | 2074 | x * 2 |
2027 | }", | 2075 | } |
2076 | "#, | ||
2028 | ); | 2077 | ); |
2029 | } | 2078 | } |
2030 | 2079 | ||
@@ -2032,18 +2081,20 @@ fn $0fun_name(x: u32) -> u32 { | |||
2032 | fn extract_return_stmt() { | 2081 | fn extract_return_stmt() { |
2033 | check_assist( | 2082 | check_assist( |
2034 | extract_function, | 2083 | extract_function, |
2035 | r" | 2084 | r#" |
2036 | fn foo() -> u32 { | 2085 | fn foo() -> u32 { |
2037 | $0return 2 + 2$0; | 2086 | $0return 2 + 2$0; |
2038 | }", | 2087 | } |
2039 | r" | 2088 | "#, |
2089 | r#" | ||
2040 | fn foo() -> u32 { | 2090 | fn foo() -> u32 { |
2041 | return fun_name(); | 2091 | return fun_name(); |
2042 | } | 2092 | } |
2043 | 2093 | ||
2044 | fn $0fun_name() -> u32 { | 2094 | fn $0fun_name() -> u32 { |
2045 | 2 + 2 | 2095 | 2 + 2 |
2046 | }", | 2096 | } |
2097 | "#, | ||
2047 | ); | 2098 | ); |
2048 | } | 2099 | } |
2049 | 2100 | ||
@@ -2051,13 +2102,14 @@ fn $0fun_name() -> u32 { | |||
2051 | fn does_not_add_extra_whitespace() { | 2102 | fn does_not_add_extra_whitespace() { |
2052 | check_assist( | 2103 | check_assist( |
2053 | extract_function, | 2104 | extract_function, |
2054 | r" | 2105 | r#" |
2055 | fn foo() -> u32 { | 2106 | fn foo() -> u32 { |
2056 | 2107 | ||
2057 | 2108 | ||
2058 | $0return 2 + 2$0; | 2109 | $0return 2 + 2$0; |
2059 | }", | 2110 | } |
2060 | r" | 2111 | "#, |
2112 | r#" | ||
2061 | fn foo() -> u32 { | 2113 | fn foo() -> u32 { |
2062 | 2114 | ||
2063 | 2115 | ||
@@ -2066,7 +2118,8 @@ fn foo() -> u32 { | |||
2066 | 2118 | ||
2067 | fn $0fun_name() -> u32 { | 2119 | fn $0fun_name() -> u32 { |
2068 | 2 + 2 | 2120 | 2 + 2 |
2069 | }", | 2121 | } |
2122 | "#, | ||
2070 | ); | 2123 | ); |
2071 | } | 2124 | } |
2072 | 2125 | ||
@@ -2074,13 +2127,14 @@ fn $0fun_name() -> u32 { | |||
2074 | fn break_stmt() { | 2127 | fn break_stmt() { |
2075 | check_assist( | 2128 | check_assist( |
2076 | extract_function, | 2129 | extract_function, |
2077 | r" | 2130 | r#" |
2078 | fn main() { | 2131 | fn main() { |
2079 | let result = loop { | 2132 | let result = loop { |
2080 | $0break 2 + 2$0; | 2133 | $0break 2 + 2$0; |
2081 | }; | 2134 | }; |
2082 | }", | 2135 | } |
2083 | r" | 2136 | "#, |
2137 | r#" | ||
2084 | fn main() { | 2138 | fn main() { |
2085 | let result = loop { | 2139 | let result = loop { |
2086 | break fun_name(); | 2140 | break fun_name(); |
@@ -2089,7 +2143,8 @@ fn main() { | |||
2089 | 2143 | ||
2090 | fn $0fun_name() -> i32 { | 2144 | fn $0fun_name() -> i32 { |
2091 | 2 + 2 | 2145 | 2 + 2 |
2092 | }", | 2146 | } |
2147 | "#, | ||
2093 | ); | 2148 | ); |
2094 | } | 2149 | } |
2095 | 2150 | ||
@@ -2097,18 +2152,20 @@ fn $0fun_name() -> i32 { | |||
2097 | fn extract_cast() { | 2152 | fn extract_cast() { |
2098 | check_assist( | 2153 | check_assist( |
2099 | extract_function, | 2154 | extract_function, |
2100 | r" | 2155 | r#" |
2101 | fn main() { | 2156 | fn main() { |
2102 | let v = $00f32 as u32$0; | 2157 | let v = $00f32 as u32$0; |
2103 | }", | 2158 | } |
2104 | r" | 2159 | "#, |
2160 | r#" | ||
2105 | fn main() { | 2161 | fn main() { |
2106 | let v = fun_name(); | 2162 | let v = fun_name(); |
2107 | } | 2163 | } |
2108 | 2164 | ||
2109 | fn $0fun_name() -> u32 { | 2165 | fn $0fun_name() -> u32 { |
2110 | 0f32 as u32 | 2166 | 0f32 as u32 |
2111 | }", | 2167 | } |
2168 | "#, | ||
2112 | ); | 2169 | ); |
2113 | } | 2170 | } |
2114 | 2171 | ||
@@ -2121,15 +2178,16 @@ fn $0fun_name() -> u32 { | |||
2121 | fn method_to_freestanding() { | 2178 | fn method_to_freestanding() { |
2122 | check_assist( | 2179 | check_assist( |
2123 | extract_function, | 2180 | extract_function, |
2124 | r" | 2181 | r#" |
2125 | struct S; | 2182 | struct S; |
2126 | 2183 | ||
2127 | impl S { | 2184 | impl S { |
2128 | fn foo(&self) -> i32 { | 2185 | fn foo(&self) -> i32 { |
2129 | $01+1$0 | 2186 | $01+1$0 |
2130 | } | 2187 | } |
2131 | }", | 2188 | } |
2132 | r" | 2189 | "#, |
2190 | r#" | ||
2133 | struct S; | 2191 | struct S; |
2134 | 2192 | ||
2135 | impl S { | 2193 | impl S { |
@@ -2140,7 +2198,8 @@ impl S { | |||
2140 | 2198 | ||
2141 | fn $0fun_name() -> i32 { | 2199 | fn $0fun_name() -> i32 { |
2142 | 1+1 | 2200 | 1+1 |
2143 | }", | 2201 | } |
2202 | "#, | ||
2144 | ); | 2203 | ); |
2145 | } | 2204 | } |
2146 | 2205 | ||
@@ -2148,15 +2207,16 @@ fn $0fun_name() -> i32 { | |||
2148 | fn method_with_reference() { | 2207 | fn method_with_reference() { |
2149 | check_assist( | 2208 | check_assist( |
2150 | extract_function, | 2209 | extract_function, |
2151 | r" | 2210 | r#" |
2152 | struct S { f: i32 }; | 2211 | struct S { f: i32 }; |
2153 | 2212 | ||
2154 | impl S { | 2213 | impl S { |
2155 | fn foo(&self) -> i32 { | 2214 | fn foo(&self) -> i32 { |
2156 | $01+self.f$0 | 2215 | $01+self.f$0 |
2157 | } | 2216 | } |
2158 | }", | 2217 | } |
2159 | r" | 2218 | "#, |
2219 | r#" | ||
2160 | struct S { f: i32 }; | 2220 | struct S { f: i32 }; |
2161 | 2221 | ||
2162 | impl S { | 2222 | impl S { |
@@ -2167,7 +2227,8 @@ impl S { | |||
2167 | fn $0fun_name(&self) -> i32 { | 2227 | fn $0fun_name(&self) -> i32 { |
2168 | 1+self.f | 2228 | 1+self.f |
2169 | } | 2229 | } |
2170 | }", | 2230 | } |
2231 | "#, | ||
2171 | ); | 2232 | ); |
2172 | } | 2233 | } |
2173 | 2234 | ||
@@ -2175,15 +2236,16 @@ impl S { | |||
2175 | fn method_with_mut() { | 2236 | fn method_with_mut() { |
2176 | check_assist( | 2237 | check_assist( |
2177 | extract_function, | 2238 | extract_function, |
2178 | r" | 2239 | r#" |
2179 | struct S { f: i32 }; | 2240 | struct S { f: i32 }; |
2180 | 2241 | ||
2181 | impl S { | 2242 | impl S { |
2182 | fn foo(&mut self) { | 2243 | fn foo(&mut self) { |
2183 | $0self.f += 1;$0 | 2244 | $0self.f += 1;$0 |
2184 | } | 2245 | } |
2185 | }", | 2246 | } |
2186 | r" | 2247 | "#, |
2248 | r#" | ||
2187 | struct S { f: i32 }; | 2249 | struct S { f: i32 }; |
2188 | 2250 | ||
2189 | impl S { | 2251 | impl S { |
@@ -2194,7 +2256,8 @@ impl S { | |||
2194 | fn $0fun_name(&mut self) { | 2256 | fn $0fun_name(&mut self) { |
2195 | self.f += 1; | 2257 | self.f += 1; |
2196 | } | 2258 | } |
2197 | }", | 2259 | } |
2260 | "#, | ||
2198 | ); | 2261 | ); |
2199 | } | 2262 | } |
2200 | 2263 | ||
@@ -2202,13 +2265,14 @@ impl S { | |||
2202 | fn variable_defined_inside_and_used_after_no_ret() { | 2265 | fn variable_defined_inside_and_used_after_no_ret() { |
2203 | check_assist( | 2266 | check_assist( |
2204 | extract_function, | 2267 | extract_function, |
2205 | r" | 2268 | r#" |
2206 | fn foo() { | 2269 | fn foo() { |
2207 | let n = 1; | 2270 | let n = 1; |
2208 | $0let k = n * n;$0 | 2271 | $0let k = n * n;$0 |
2209 | let m = k + 1; | 2272 | let m = k + 1; |
2210 | }", | 2273 | } |
2211 | r" | 2274 | "#, |
2275 | r#" | ||
2212 | fn foo() { | 2276 | fn foo() { |
2213 | let n = 1; | 2277 | let n = 1; |
2214 | let k = fun_name(n); | 2278 | let k = fun_name(n); |
@@ -2218,7 +2282,8 @@ fn foo() { | |||
2218 | fn $0fun_name(n: i32) -> i32 { | 2282 | fn $0fun_name(n: i32) -> i32 { |
2219 | let k = n * n; | 2283 | let k = n * n; |
2220 | k | 2284 | k |
2221 | }", | 2285 | } |
2286 | "#, | ||
2222 | ); | 2287 | ); |
2223 | } | 2288 | } |
2224 | 2289 | ||
@@ -2226,13 +2291,14 @@ fn $0fun_name(n: i32) -> i32 { | |||
2226 | fn variable_defined_inside_and_used_after_mutably_no_ret() { | 2291 | fn variable_defined_inside_and_used_after_mutably_no_ret() { |
2227 | check_assist( | 2292 | check_assist( |
2228 | extract_function, | 2293 | extract_function, |
2229 | r" | 2294 | r#" |
2230 | fn foo() { | 2295 | fn foo() { |
2231 | let n = 1; | 2296 | let n = 1; |
2232 | $0let mut k = n * n;$0 | 2297 | $0let mut k = n * n;$0 |
2233 | k += 1; | 2298 | k += 1; |
2234 | }", | 2299 | } |
2235 | r" | 2300 | "#, |
2301 | r#" | ||
2236 | fn foo() { | 2302 | fn foo() { |
2237 | let n = 1; | 2303 | let n = 1; |
2238 | let mut k = fun_name(n); | 2304 | let mut k = fun_name(n); |
@@ -2242,7 +2308,8 @@ fn foo() { | |||
2242 | fn $0fun_name(n: i32) -> i32 { | 2308 | fn $0fun_name(n: i32) -> i32 { |
2243 | let mut k = n * n; | 2309 | let mut k = n * n; |
2244 | k | 2310 | k |
2245 | }", | 2311 | } |
2312 | "#, | ||
2246 | ); | 2313 | ); |
2247 | } | 2314 | } |
2248 | 2315 | ||
@@ -2250,14 +2317,15 @@ fn $0fun_name(n: i32) -> i32 { | |||
2250 | fn two_variables_defined_inside_and_used_after_no_ret() { | 2317 | fn two_variables_defined_inside_and_used_after_no_ret() { |
2251 | check_assist( | 2318 | check_assist( |
2252 | extract_function, | 2319 | extract_function, |
2253 | r" | 2320 | r#" |
2254 | fn foo() { | 2321 | fn foo() { |
2255 | let n = 1; | 2322 | let n = 1; |
2256 | $0let k = n * n; | 2323 | $0let k = n * n; |
2257 | let m = k + 2;$0 | 2324 | let m = k + 2;$0 |
2258 | let h = k + m; | 2325 | let h = k + m; |
2259 | }", | 2326 | } |
2260 | r" | 2327 | "#, |
2328 | r#" | ||
2261 | fn foo() { | 2329 | fn foo() { |
2262 | let n = 1; | 2330 | let n = 1; |
2263 | let (k, m) = fun_name(n); | 2331 | let (k, m) = fun_name(n); |
@@ -2268,7 +2336,8 @@ fn $0fun_name(n: i32) -> (i32, i32) { | |||
2268 | let k = n * n; | 2336 | let k = n * n; |
2269 | let m = k + 2; | 2337 | let m = k + 2; |
2270 | (k, m) | 2338 | (k, m) |
2271 | }", | 2339 | } |
2340 | "#, | ||
2272 | ); | 2341 | ); |
2273 | } | 2342 | } |
2274 | 2343 | ||
@@ -2276,7 +2345,7 @@ fn $0fun_name(n: i32) -> (i32, i32) { | |||
2276 | fn multi_variables_defined_inside_and_used_after_mutably_no_ret() { | 2345 | fn multi_variables_defined_inside_and_used_after_mutably_no_ret() { |
2277 | check_assist( | 2346 | check_assist( |
2278 | extract_function, | 2347 | extract_function, |
2279 | r" | 2348 | r#" |
2280 | fn foo() { | 2349 | fn foo() { |
2281 | let n = 1; | 2350 | let n = 1; |
2282 | $0let mut k = n * n; | 2351 | $0let mut k = n * n; |
@@ -2285,8 +2354,9 @@ fn foo() { | |||
2285 | o += 1;$0 | 2354 | o += 1;$0 |
2286 | k += o; | 2355 | k += o; |
2287 | m = 1; | 2356 | m = 1; |
2288 | }", | 2357 | } |
2289 | r" | 2358 | "#, |
2359 | r#" | ||
2290 | fn foo() { | 2360 | fn foo() { |
2291 | let n = 1; | 2361 | let n = 1; |
2292 | let (mut k, mut m, o) = fun_name(n); | 2362 | let (mut k, mut m, o) = fun_name(n); |
@@ -2300,7 +2370,8 @@ fn $0fun_name(n: i32) -> (i32, i32, i32) { | |||
2300 | let mut o = m + 3; | 2370 | let mut o = m + 3; |
2301 | o += 1; | 2371 | o += 1; |
2302 | (k, m, o) | 2372 | (k, m, o) |
2303 | }", | 2373 | } |
2374 | "#, | ||
2304 | ); | 2375 | ); |
2305 | } | 2376 | } |
2306 | 2377 | ||
@@ -2308,13 +2379,14 @@ fn $0fun_name(n: i32) -> (i32, i32, i32) { | |||
2308 | fn nontrivial_patterns_define_variables() { | 2379 | fn nontrivial_patterns_define_variables() { |
2309 | check_assist( | 2380 | check_assist( |
2310 | extract_function, | 2381 | extract_function, |
2311 | r" | 2382 | r#" |
2312 | struct Counter(i32); | 2383 | struct Counter(i32); |
2313 | fn foo() { | 2384 | fn foo() { |
2314 | $0let Counter(n) = Counter(0);$0 | 2385 | $0let Counter(n) = Counter(0);$0 |
2315 | let m = n; | 2386 | let m = n; |
2316 | }", | 2387 | } |
2317 | r" | 2388 | "#, |
2389 | r#" | ||
2318 | struct Counter(i32); | 2390 | struct Counter(i32); |
2319 | fn foo() { | 2391 | fn foo() { |
2320 | let n = fun_name(); | 2392 | let n = fun_name(); |
@@ -2324,7 +2396,8 @@ fn foo() { | |||
2324 | fn $0fun_name() -> i32 { | 2396 | fn $0fun_name() -> i32 { |
2325 | let Counter(n) = Counter(0); | 2397 | let Counter(n) = Counter(0); |
2326 | n | 2398 | n |
2327 | }", | 2399 | } |
2400 | "#, | ||
2328 | ); | 2401 | ); |
2329 | } | 2402 | } |
2330 | 2403 | ||
@@ -2332,13 +2405,14 @@ fn $0fun_name() -> i32 { | |||
2332 | fn struct_with_two_fields_pattern_define_variables() { | 2405 | fn struct_with_two_fields_pattern_define_variables() { |
2333 | check_assist( | 2406 | check_assist( |
2334 | extract_function, | 2407 | extract_function, |
2335 | r" | 2408 | r#" |
2336 | struct Counter { n: i32, m: i32 }; | 2409 | struct Counter { n: i32, m: i32 }; |
2337 | fn foo() { | 2410 | fn foo() { |
2338 | $0let Counter { n, m: k } = Counter { n: 1, m: 2 };$0 | 2411 | $0let Counter { n, m: k } = Counter { n: 1, m: 2 };$0 |
2339 | let h = n + k; | 2412 | let h = n + k; |
2340 | }", | 2413 | } |
2341 | r" | 2414 | "#, |
2415 | r#" | ||
2342 | struct Counter { n: i32, m: i32 }; | 2416 | struct Counter { n: i32, m: i32 }; |
2343 | fn foo() { | 2417 | fn foo() { |
2344 | let (n, k) = fun_name(); | 2418 | let (n, k) = fun_name(); |
@@ -2348,7 +2422,8 @@ fn foo() { | |||
2348 | fn $0fun_name() -> (i32, i32) { | 2422 | fn $0fun_name() -> (i32, i32) { |
2349 | let Counter { n, m: k } = Counter { n: 1, m: 2 }; | 2423 | let Counter { n, m: k } = Counter { n: 1, m: 2 }; |
2350 | (n, k) | 2424 | (n, k) |
2351 | }", | 2425 | } |
2426 | "#, | ||
2352 | ); | 2427 | ); |
2353 | } | 2428 | } |
2354 | 2429 | ||
@@ -2356,13 +2431,14 @@ fn $0fun_name() -> (i32, i32) { | |||
2356 | fn mut_var_from_outer_scope() { | 2431 | fn mut_var_from_outer_scope() { |
2357 | check_assist( | 2432 | check_assist( |
2358 | extract_function, | 2433 | extract_function, |
2359 | r" | 2434 | r#" |
2360 | fn foo() { | 2435 | fn foo() { |
2361 | let mut n = 1; | 2436 | let mut n = 1; |
2362 | $0n += 1;$0 | 2437 | $0n += 1;$0 |
2363 | let m = n + 1; | 2438 | let m = n + 1; |
2364 | }", | 2439 | } |
2365 | r" | 2440 | "#, |
2441 | r#" | ||
2366 | fn foo() { | 2442 | fn foo() { |
2367 | let mut n = 1; | 2443 | let mut n = 1; |
2368 | fun_name(&mut n); | 2444 | fun_name(&mut n); |
@@ -2371,7 +2447,8 @@ fn foo() { | |||
2371 | 2447 | ||
2372 | fn $0fun_name(n: &mut i32) { | 2448 | fn $0fun_name(n: &mut i32) { |
2373 | *n += 1; | 2449 | *n += 1; |
2374 | }", | 2450 | } |
2451 | "#, | ||
2375 | ); | 2452 | ); |
2376 | } | 2453 | } |
2377 | 2454 | ||
@@ -2379,14 +2456,15 @@ fn $0fun_name(n: &mut i32) { | |||
2379 | fn mut_field_from_outer_scope() { | 2456 | fn mut_field_from_outer_scope() { |
2380 | check_assist( | 2457 | check_assist( |
2381 | extract_function, | 2458 | extract_function, |
2382 | r" | 2459 | r#" |
2383 | struct C { n: i32 } | 2460 | struct C { n: i32 } |
2384 | fn foo() { | 2461 | fn foo() { |
2385 | let mut c = C { n: 0 }; | 2462 | let mut c = C { n: 0 }; |
2386 | $0c.n += 1;$0 | 2463 | $0c.n += 1;$0 |
2387 | let m = c.n + 1; | 2464 | let m = c.n + 1; |
2388 | }", | 2465 | } |
2389 | r" | 2466 | "#, |
2467 | r#" | ||
2390 | struct C { n: i32 } | 2468 | struct C { n: i32 } |
2391 | fn foo() { | 2469 | fn foo() { |
2392 | let mut c = C { n: 0 }; | 2470 | let mut c = C { n: 0 }; |
@@ -2396,7 +2474,8 @@ fn foo() { | |||
2396 | 2474 | ||
2397 | fn $0fun_name(c: &mut C) { | 2475 | fn $0fun_name(c: &mut C) { |
2398 | c.n += 1; | 2476 | c.n += 1; |
2399 | }", | 2477 | } |
2478 | "#, | ||
2400 | ); | 2479 | ); |
2401 | } | 2480 | } |
2402 | 2481 | ||
@@ -2404,7 +2483,7 @@ fn $0fun_name(c: &mut C) { | |||
2404 | fn mut_nested_field_from_outer_scope() { | 2483 | fn mut_nested_field_from_outer_scope() { |
2405 | check_assist( | 2484 | check_assist( |
2406 | extract_function, | 2485 | extract_function, |
2407 | r" | 2486 | r#" |
2408 | struct P { n: i32} | 2487 | struct P { n: i32} |
2409 | struct C { p: P } | 2488 | struct C { p: P } |
2410 | fn foo() { | 2489 | fn foo() { |
@@ -2414,8 +2493,9 @@ fn foo() { | |||
2414 | $0c.p.n += u.p.n; | 2493 | $0c.p.n += u.p.n; |
2415 | let r = &mut v.p.n;$0 | 2494 | let r = &mut v.p.n;$0 |
2416 | let m = c.p.n + v.p.n + u.p.n; | 2495 | let m = c.p.n + v.p.n + u.p.n; |
2417 | }", | 2496 | } |
2418 | r" | 2497 | "#, |
2498 | r#" | ||
2419 | struct P { n: i32} | 2499 | struct P { n: i32} |
2420 | struct C { p: P } | 2500 | struct C { p: P } |
2421 | fn foo() { | 2501 | fn foo() { |
@@ -2429,7 +2509,8 @@ fn foo() { | |||
2429 | fn $0fun_name(c: &mut C, u: &C, v: &mut C) { | 2509 | fn $0fun_name(c: &mut C, u: &C, v: &mut C) { |
2430 | c.p.n += u.p.n; | 2510 | c.p.n += u.p.n; |
2431 | let r = &mut v.p.n; | 2511 | let r = &mut v.p.n; |
2432 | }", | 2512 | } |
2513 | "#, | ||
2433 | ); | 2514 | ); |
2434 | } | 2515 | } |
2435 | 2516 | ||
@@ -2437,7 +2518,7 @@ fn $0fun_name(c: &mut C, u: &C, v: &mut C) { | |||
2437 | fn mut_param_many_usages_stmt() { | 2518 | fn mut_param_many_usages_stmt() { |
2438 | check_assist( | 2519 | check_assist( |
2439 | extract_function, | 2520 | extract_function, |
2440 | r" | 2521 | r#" |
2441 | fn bar(k: i32) {} | 2522 | fn bar(k: i32) {} |
2442 | trait I: Copy { | 2523 | trait I: Copy { |
2443 | fn succ(&self) -> Self; | 2524 | fn succ(&self) -> Self; |
@@ -2458,8 +2539,9 @@ fn foo() { | |||
2458 | *v = v.succ(); | 2539 | *v = v.succ(); |
2459 | n.succ();$0 | 2540 | n.succ();$0 |
2460 | let m = n + 1; | 2541 | let m = n + 1; |
2461 | }", | 2542 | } |
2462 | r" | 2543 | "#, |
2544 | r#" | ||
2463 | fn bar(k: i32) {} | 2545 | fn bar(k: i32) {} |
2464 | trait I: Copy { | 2546 | trait I: Copy { |
2465 | fn succ(&self) -> Self; | 2547 | fn succ(&self) -> Self; |
@@ -2484,7 +2566,8 @@ fn $0fun_name(n: &mut i32) { | |||
2484 | let v = n; | 2566 | let v = n; |
2485 | *v = v.succ(); | 2567 | *v = v.succ(); |
2486 | n.succ(); | 2568 | n.succ(); |
2487 | }", | 2569 | } |
2570 | "#, | ||
2488 | ); | 2571 | ); |
2489 | } | 2572 | } |
2490 | 2573 | ||
@@ -2492,7 +2575,7 @@ fn $0fun_name(n: &mut i32) { | |||
2492 | fn mut_param_many_usages_expr() { | 2575 | fn mut_param_many_usages_expr() { |
2493 | check_assist( | 2576 | check_assist( |
2494 | extract_function, | 2577 | extract_function, |
2495 | r" | 2578 | r#" |
2496 | fn bar(k: i32) {} | 2579 | fn bar(k: i32) {} |
2497 | trait I: Copy { | 2580 | trait I: Copy { |
2498 | fn succ(&self) -> Self; | 2581 | fn succ(&self) -> Self; |
@@ -2515,8 +2598,9 @@ fn foo() { | |||
2515 | n.succ(); | 2598 | n.succ(); |
2516 | }$0 | 2599 | }$0 |
2517 | let m = n + 1; | 2600 | let m = n + 1; |
2518 | }", | 2601 | } |
2519 | r" | 2602 | "#, |
2603 | r#" | ||
2520 | fn bar(k: i32) {} | 2604 | fn bar(k: i32) {} |
2521 | trait I: Copy { | 2605 | trait I: Copy { |
2522 | fn succ(&self) -> Self; | 2606 | fn succ(&self) -> Self; |
@@ -2541,7 +2625,8 @@ fn $0fun_name(n: &mut i32) { | |||
2541 | let v = n; | 2625 | let v = n; |
2542 | *v = v.succ(); | 2626 | *v = v.succ(); |
2543 | n.succ(); | 2627 | n.succ(); |
2544 | }", | 2628 | } |
2629 | "#, | ||
2545 | ); | 2630 | ); |
2546 | } | 2631 | } |
2547 | 2632 | ||
@@ -2549,11 +2634,12 @@ fn $0fun_name(n: &mut i32) { | |||
2549 | fn mut_param_by_value() { | 2634 | fn mut_param_by_value() { |
2550 | check_assist( | 2635 | check_assist( |
2551 | extract_function, | 2636 | extract_function, |
2552 | r" | 2637 | r#" |
2553 | fn foo() { | 2638 | fn foo() { |
2554 | let mut n = 1; | 2639 | let mut n = 1; |
2555 | $0n += 1;$0 | 2640 | $0n += 1;$0 |
2556 | }", | 2641 | } |
2642 | "#, | ||
2557 | r" | 2643 | r" |
2558 | fn foo() { | 2644 | fn foo() { |
2559 | let mut n = 1; | 2645 | let mut n = 1; |
@@ -2562,7 +2648,8 @@ fn foo() { | |||
2562 | 2648 | ||
2563 | fn $0fun_name(mut n: i32) { | 2649 | fn $0fun_name(mut n: i32) { |
2564 | n += 1; | 2650 | n += 1; |
2565 | }", | 2651 | } |
2652 | ", | ||
2566 | ); | 2653 | ); |
2567 | } | 2654 | } |
2568 | 2655 | ||
@@ -2570,14 +2657,15 @@ fn $0fun_name(mut n: i32) { | |||
2570 | fn mut_param_because_of_mut_ref() { | 2657 | fn mut_param_because_of_mut_ref() { |
2571 | check_assist( | 2658 | check_assist( |
2572 | extract_function, | 2659 | extract_function, |
2573 | r" | 2660 | r#" |
2574 | fn foo() { | 2661 | fn foo() { |
2575 | let mut n = 1; | 2662 | let mut n = 1; |
2576 | $0let v = &mut n; | 2663 | $0let v = &mut n; |
2577 | *v += 1;$0 | 2664 | *v += 1;$0 |
2578 | let k = n; | 2665 | let k = n; |
2579 | }", | 2666 | } |
2580 | r" | 2667 | "#, |
2668 | r#" | ||
2581 | fn foo() { | 2669 | fn foo() { |
2582 | let mut n = 1; | 2670 | let mut n = 1; |
2583 | fun_name(&mut n); | 2671 | fun_name(&mut n); |
@@ -2587,7 +2675,8 @@ fn foo() { | |||
2587 | fn $0fun_name(n: &mut i32) { | 2675 | fn $0fun_name(n: &mut i32) { |
2588 | let v = n; | 2676 | let v = n; |
2589 | *v += 1; | 2677 | *v += 1; |
2590 | }", | 2678 | } |
2679 | "#, | ||
2591 | ); | 2680 | ); |
2592 | } | 2681 | } |
2593 | 2682 | ||
@@ -2600,8 +2689,9 @@ fn foo() { | |||
2600 | let mut n = 1; | 2689 | let mut n = 1; |
2601 | $0let v = &mut n; | 2690 | $0let v = &mut n; |
2602 | *v += 1;$0 | 2691 | *v += 1;$0 |
2603 | }", | 2692 | } |
2604 | r" | 2693 | ", |
2694 | r#" | ||
2605 | fn foo() { | 2695 | fn foo() { |
2606 | let mut n = 1; | 2696 | let mut n = 1; |
2607 | fun_name(n); | 2697 | fun_name(n); |
@@ -2610,7 +2700,8 @@ fn foo() { | |||
2610 | fn $0fun_name(mut n: i32) { | 2700 | fn $0fun_name(mut n: i32) { |
2611 | let v = &mut n; | 2701 | let v = &mut n; |
2612 | *v += 1; | 2702 | *v += 1; |
2613 | }", | 2703 | } |
2704 | "#, | ||
2614 | ); | 2705 | ); |
2615 | } | 2706 | } |
2616 | 2707 | ||
@@ -2618,7 +2709,7 @@ fn $0fun_name(mut n: i32) { | |||
2618 | fn mut_method_call() { | 2709 | fn mut_method_call() { |
2619 | check_assist( | 2710 | check_assist( |
2620 | extract_function, | 2711 | extract_function, |
2621 | r" | 2712 | r#" |
2622 | trait I { | 2713 | trait I { |
2623 | fn inc(&mut self); | 2714 | fn inc(&mut self); |
2624 | } | 2715 | } |
@@ -2628,8 +2719,9 @@ impl I for i32 { | |||
2628 | fn foo() { | 2719 | fn foo() { |
2629 | let mut n = 1; | 2720 | let mut n = 1; |
2630 | $0n.inc();$0 | 2721 | $0n.inc();$0 |
2631 | }", | 2722 | } |
2632 | r" | 2723 | "#, |
2724 | r#" | ||
2633 | trait I { | 2725 | trait I { |
2634 | fn inc(&mut self); | 2726 | fn inc(&mut self); |
2635 | } | 2727 | } |
@@ -2643,7 +2735,8 @@ fn foo() { | |||
2643 | 2735 | ||
2644 | fn $0fun_name(mut n: i32) { | 2736 | fn $0fun_name(mut n: i32) { |
2645 | n.inc(); | 2737 | n.inc(); |
2646 | }", | 2738 | } |
2739 | "#, | ||
2647 | ); | 2740 | ); |
2648 | } | 2741 | } |
2649 | 2742 | ||
@@ -2651,7 +2744,7 @@ fn $0fun_name(mut n: i32) { | |||
2651 | fn shared_method_call() { | 2744 | fn shared_method_call() { |
2652 | check_assist( | 2745 | check_assist( |
2653 | extract_function, | 2746 | extract_function, |
2654 | r" | 2747 | r#" |
2655 | trait I { | 2748 | trait I { |
2656 | fn succ(&self); | 2749 | fn succ(&self); |
2657 | } | 2750 | } |
@@ -2661,7 +2754,8 @@ impl I for i32 { | |||
2661 | fn foo() { | 2754 | fn foo() { |
2662 | let mut n = 1; | 2755 | let mut n = 1; |
2663 | $0n.succ();$0 | 2756 | $0n.succ();$0 |
2664 | }", | 2757 | } |
2758 | "#, | ||
2665 | r" | 2759 | r" |
2666 | trait I { | 2760 | trait I { |
2667 | fn succ(&self); | 2761 | fn succ(&self); |
@@ -2676,7 +2770,8 @@ fn foo() { | |||
2676 | 2770 | ||
2677 | fn $0fun_name(n: i32) { | 2771 | fn $0fun_name(n: i32) { |
2678 | n.succ(); | 2772 | n.succ(); |
2679 | }", | 2773 | } |
2774 | ", | ||
2680 | ); | 2775 | ); |
2681 | } | 2776 | } |
2682 | 2777 | ||
@@ -2684,7 +2779,7 @@ fn $0fun_name(n: i32) { | |||
2684 | fn mut_method_call_with_other_receiver() { | 2779 | fn mut_method_call_with_other_receiver() { |
2685 | check_assist( | 2780 | check_assist( |
2686 | extract_function, | 2781 | extract_function, |
2687 | r" | 2782 | r#" |
2688 | trait I { | 2783 | trait I { |
2689 | fn inc(&mut self, n: i32); | 2784 | fn inc(&mut self, n: i32); |
2690 | } | 2785 | } |
@@ -2695,7 +2790,8 @@ fn foo() { | |||
2695 | let mut n = 1; | 2790 | let mut n = 1; |
2696 | $0let mut m = 2; | 2791 | $0let mut m = 2; |
2697 | m.inc(n);$0 | 2792 | m.inc(n);$0 |
2698 | }", | 2793 | } |
2794 | "#, | ||
2699 | r" | 2795 | r" |
2700 | trait I { | 2796 | trait I { |
2701 | fn inc(&mut self, n: i32); | 2797 | fn inc(&mut self, n: i32); |
@@ -2711,7 +2807,8 @@ fn foo() { | |||
2711 | fn $0fun_name(n: i32) { | 2807 | fn $0fun_name(n: i32) { |
2712 | let mut m = 2; | 2808 | let mut m = 2; |
2713 | m.inc(n); | 2809 | m.inc(n); |
2714 | }", | 2810 | } |
2811 | ", | ||
2715 | ); | 2812 | ); |
2716 | } | 2813 | } |
2717 | 2814 | ||
@@ -2719,12 +2816,13 @@ fn $0fun_name(n: i32) { | |||
2719 | fn non_copy_without_usages_after() { | 2816 | fn non_copy_without_usages_after() { |
2720 | check_assist( | 2817 | check_assist( |
2721 | extract_function, | 2818 | extract_function, |
2722 | r" | 2819 | r#" |
2723 | struct Counter(i32); | 2820 | struct Counter(i32); |
2724 | fn foo() { | 2821 | fn foo() { |
2725 | let c = Counter(0); | 2822 | let c = Counter(0); |
2726 | $0let n = c.0;$0 | 2823 | $0let n = c.0;$0 |
2727 | }", | 2824 | } |
2825 | "#, | ||
2728 | r" | 2826 | r" |
2729 | struct Counter(i32); | 2827 | struct Counter(i32); |
2730 | fn foo() { | 2828 | fn foo() { |
@@ -2734,7 +2832,8 @@ fn foo() { | |||
2734 | 2832 | ||
2735 | fn $0fun_name(c: Counter) { | 2833 | fn $0fun_name(c: Counter) { |
2736 | let n = c.0; | 2834 | let n = c.0; |
2737 | }", | 2835 | } |
2836 | ", | ||
2738 | ); | 2837 | ); |
2739 | } | 2838 | } |
2740 | 2839 | ||
@@ -2748,8 +2847,9 @@ fn foo() { | |||
2748 | let c = Counter(0); | 2847 | let c = Counter(0); |
2749 | $0let n = c.0;$0 | 2848 | $0let n = c.0;$0 |
2750 | let m = c.0; | 2849 | let m = c.0; |
2751 | }", | 2850 | } |
2752 | r" | 2851 | ", |
2852 | r#" | ||
2753 | struct Counter(i32); | 2853 | struct Counter(i32); |
2754 | fn foo() { | 2854 | fn foo() { |
2755 | let c = Counter(0); | 2855 | let c = Counter(0); |
@@ -2759,7 +2859,8 @@ fn foo() { | |||
2759 | 2859 | ||
2760 | fn $0fun_name(c: &Counter) { | 2860 | fn $0fun_name(c: &Counter) { |
2761 | let n = c.0; | 2861 | let n = c.0; |
2762 | }", | 2862 | } |
2863 | "#, | ||
2763 | ); | 2864 | ); |
2764 | } | 2865 | } |
2765 | 2866 | ||
@@ -2767,19 +2868,15 @@ fn $0fun_name(c: &Counter) { | |||
2767 | fn copy_used_after() { | 2868 | fn copy_used_after() { |
2768 | check_assist( | 2869 | check_assist( |
2769 | extract_function, | 2870 | extract_function, |
2770 | r##" | 2871 | r#" |
2771 | #[lang = "copy"] | 2872 | //- minicore: copy |
2772 | pub trait Copy {} | ||
2773 | impl Copy for i32 {} | ||
2774 | fn foo() { | 2873 | fn foo() { |
2775 | let n = 0; | 2874 | let n = 0; |
2776 | $0let m = n;$0 | 2875 | $0let m = n;$0 |
2777 | let k = n; | 2876 | let k = n; |
2778 | }"##, | 2877 | } |
2779 | r##" | 2878 | "#, |
2780 | #[lang = "copy"] | 2879 | r#" |
2781 | pub trait Copy {} | ||
2782 | impl Copy for i32 {} | ||
2783 | fn foo() { | 2880 | fn foo() { |
2784 | let n = 0; | 2881 | let n = 0; |
2785 | fun_name(n); | 2882 | fun_name(n); |
@@ -2788,7 +2885,8 @@ fn foo() { | |||
2788 | 2885 | ||
2789 | fn $0fun_name(n: i32) { | 2886 | fn $0fun_name(n: i32) { |
2790 | let m = n; | 2887 | let m = n; |
2791 | }"##, | 2888 | } |
2889 | "#, | ||
2792 | ) | 2890 | ) |
2793 | } | 2891 | } |
2794 | 2892 | ||
@@ -2796,21 +2894,19 @@ fn $0fun_name(n: i32) { | |||
2796 | fn copy_custom_used_after() { | 2894 | fn copy_custom_used_after() { |
2797 | check_assist( | 2895 | check_assist( |
2798 | extract_function, | 2896 | extract_function, |
2799 | r##" | 2897 | r#" |
2800 | #[lang = "copy"] | 2898 | //- minicore: copy, derive |
2801 | pub trait Copy {} | 2899 | #[derive(Clone, Copy)] |
2802 | struct Counter(i32); | 2900 | struct Counter(i32); |
2803 | impl Copy for Counter {} | ||
2804 | fn foo() { | 2901 | fn foo() { |
2805 | let c = Counter(0); | 2902 | let c = Counter(0); |
2806 | $0let n = c.0;$0 | 2903 | $0let n = c.0;$0 |
2807 | let m = c.0; | 2904 | let m = c.0; |
2808 | }"##, | 2905 | } |
2809 | r##" | 2906 | "#, |
2810 | #[lang = "copy"] | 2907 | r#" |
2811 | pub trait Copy {} | 2908 | #[derive(Clone, Copy)] |
2812 | struct Counter(i32); | 2909 | struct Counter(i32); |
2813 | impl Copy for Counter {} | ||
2814 | fn foo() { | 2910 | fn foo() { |
2815 | let c = Counter(0); | 2911 | let c = Counter(0); |
2816 | fun_name(c); | 2912 | fun_name(c); |
@@ -2819,7 +2915,8 @@ fn foo() { | |||
2819 | 2915 | ||
2820 | fn $0fun_name(c: Counter) { | 2916 | fn $0fun_name(c: Counter) { |
2821 | let n = c.0; | 2917 | let n = c.0; |
2822 | }"##, | 2918 | } |
2919 | "#, | ||
2823 | ); | 2920 | ); |
2824 | } | 2921 | } |
2825 | 2922 | ||
@@ -2827,7 +2924,7 @@ fn $0fun_name(c: Counter) { | |||
2827 | fn indented_stmts() { | 2924 | fn indented_stmts() { |
2828 | check_assist( | 2925 | check_assist( |
2829 | extract_function, | 2926 | extract_function, |
2830 | r" | 2927 | r#" |
2831 | fn foo() { | 2928 | fn foo() { |
2832 | if true { | 2929 | if true { |
2833 | loop { | 2930 | loop { |
@@ -2835,8 +2932,9 @@ fn foo() { | |||
2835 | let m = 2;$0 | 2932 | let m = 2;$0 |
2836 | } | 2933 | } |
2837 | } | 2934 | } |
2838 | }", | 2935 | } |
2839 | r" | 2936 | "#, |
2937 | r#" | ||
2840 | fn foo() { | 2938 | fn foo() { |
2841 | if true { | 2939 | if true { |
2842 | loop { | 2940 | loop { |
@@ -2848,7 +2946,8 @@ fn foo() { | |||
2848 | fn $0fun_name() { | 2946 | fn $0fun_name() { |
2849 | let n = 1; | 2947 | let n = 1; |
2850 | let m = 2; | 2948 | let m = 2; |
2851 | }", | 2949 | } |
2950 | "#, | ||
2852 | ); | 2951 | ); |
2853 | } | 2952 | } |
2854 | 2953 | ||
@@ -2856,7 +2955,7 @@ fn $0fun_name() { | |||
2856 | fn indented_stmts_inside_mod() { | 2955 | fn indented_stmts_inside_mod() { |
2857 | check_assist( | 2956 | check_assist( |
2858 | extract_function, | 2957 | extract_function, |
2859 | r" | 2958 | r#" |
2860 | mod bar { | 2959 | mod bar { |
2861 | fn foo() { | 2960 | fn foo() { |
2862 | if true { | 2961 | if true { |
@@ -2866,8 +2965,9 @@ mod bar { | |||
2866 | } | 2965 | } |
2867 | } | 2966 | } |
2868 | } | 2967 | } |
2869 | }", | 2968 | } |
2870 | r" | 2969 | "#, |
2970 | r#" | ||
2871 | mod bar { | 2971 | mod bar { |
2872 | fn foo() { | 2972 | fn foo() { |
2873 | if true { | 2973 | if true { |
@@ -2881,7 +2981,8 @@ mod bar { | |||
2881 | let n = 1; | 2981 | let n = 1; |
2882 | let m = 2; | 2982 | let m = 2; |
2883 | } | 2983 | } |
2884 | }", | 2984 | } |
2985 | "#, | ||
2885 | ); | 2986 | ); |
2886 | } | 2987 | } |
2887 | 2988 | ||
@@ -2889,7 +2990,7 @@ mod bar { | |||
2889 | fn break_loop() { | 2990 | fn break_loop() { |
2890 | check_assist( | 2991 | check_assist( |
2891 | extract_function, | 2992 | extract_function, |
2892 | r##" | 2993 | r#" |
2893 | enum Option<T> { | 2994 | enum Option<T> { |
2894 | #[lang = "None"] None, | 2995 | #[lang = "None"] None, |
2895 | #[lang = "Some"] Some(T), | 2996 | #[lang = "Some"] Some(T), |
@@ -2903,8 +3004,9 @@ fn foo() { | |||
2903 | let k = 2;$0 | 3004 | let k = 2;$0 |
2904 | let h = 1 + k; | 3005 | let h = 1 + k; |
2905 | } | 3006 | } |
2906 | }"##, | 3007 | } |
2907 | r##" | 3008 | "#, |
3009 | r#" | ||
2908 | enum Option<T> { | 3010 | enum Option<T> { |
2909 | #[lang = "None"] None, | 3011 | #[lang = "None"] None, |
2910 | #[lang = "Some"] Some(T), | 3012 | #[lang = "Some"] Some(T), |
@@ -2926,7 +3028,8 @@ fn $0fun_name(n: i32) -> Option<i32> { | |||
2926 | return None; | 3028 | return None; |
2927 | let k = 2; | 3029 | let k = 2; |
2928 | Some(k) | 3030 | Some(k) |
2929 | }"##, | 3031 | } |
3032 | "#, | ||
2930 | ); | 3033 | ); |
2931 | } | 3034 | } |
2932 | 3035 | ||
@@ -2934,31 +3037,17 @@ fn $0fun_name(n: i32) -> Option<i32> { | |||
2934 | fn return_to_parent() { | 3037 | fn return_to_parent() { |
2935 | check_assist( | 3038 | check_assist( |
2936 | extract_function, | 3039 | extract_function, |
2937 | r##" | 3040 | r#" |
2938 | #[lang = "copy"] | 3041 | //- minicore: copy, result |
2939 | pub trait Copy {} | ||
2940 | impl Copy for i32 {} | ||
2941 | enum Result<T, E> { | ||
2942 | #[lang = "Ok"] Ok(T), | ||
2943 | #[lang = "Err"] Err(E), | ||
2944 | } | ||
2945 | use Result::*; | ||
2946 | fn foo() -> i64 { | 3042 | fn foo() -> i64 { |
2947 | let n = 1; | 3043 | let n = 1; |
2948 | $0let m = n + 1; | 3044 | $0let m = n + 1; |
2949 | return 1; | 3045 | return 1; |
2950 | let k = 2;$0 | 3046 | let k = 2;$0 |
2951 | (n + k) as i64 | 3047 | (n + k) as i64 |
2952 | }"##, | 3048 | } |
2953 | r##" | 3049 | "#, |
2954 | #[lang = "copy"] | 3050 | r#" |
2955 | pub trait Copy {} | ||
2956 | impl Copy for i32 {} | ||
2957 | enum Result<T, E> { | ||
2958 | #[lang = "Ok"] Ok(T), | ||
2959 | #[lang = "Err"] Err(E), | ||
2960 | } | ||
2961 | use Result::*; | ||
2962 | fn foo() -> i64 { | 3051 | fn foo() -> i64 { |
2963 | let n = 1; | 3052 | let n = 1; |
2964 | let k = match fun_name(n) { | 3053 | let k = match fun_name(n) { |
@@ -2973,7 +3062,8 @@ fn $0fun_name(n: i32) -> Result<i32, i64> { | |||
2973 | return Err(1); | 3062 | return Err(1); |
2974 | let k = 2; | 3063 | let k = 2; |
2975 | Ok(k) | 3064 | Ok(k) |
2976 | }"##, | 3065 | } |
3066 | "#, | ||
2977 | ); | 3067 | ); |
2978 | } | 3068 | } |
2979 | 3069 | ||
@@ -2982,7 +3072,7 @@ fn $0fun_name(n: i32) -> Result<i32, i64> { | |||
2982 | cov_mark::check!(external_control_flow_break_and_continue); | 3072 | cov_mark::check!(external_control_flow_break_and_continue); |
2983 | check_assist_not_applicable( | 3073 | check_assist_not_applicable( |
2984 | extract_function, | 3074 | extract_function, |
2985 | r##" | 3075 | r#" |
2986 | fn foo() { | 3076 | fn foo() { |
2987 | loop { | 3077 | loop { |
2988 | let n = 1; | 3078 | let n = 1; |
@@ -2993,7 +3083,8 @@ fn foo() { | |||
2993 | let k = k + 1;$0 | 3083 | let k = k + 1;$0 |
2994 | let r = n + k; | 3084 | let r = n + k; |
2995 | } | 3085 | } |
2996 | }"##, | 3086 | } |
3087 | "#, | ||
2997 | ); | 3088 | ); |
2998 | } | 3089 | } |
2999 | 3090 | ||
@@ -3002,7 +3093,7 @@ fn foo() { | |||
3002 | cov_mark::check!(external_control_flow_return_and_bc); | 3093 | cov_mark::check!(external_control_flow_return_and_bc); |
3003 | check_assist_not_applicable( | 3094 | check_assist_not_applicable( |
3004 | extract_function, | 3095 | extract_function, |
3005 | r##" | 3096 | r#" |
3006 | fn foo() { | 3097 | fn foo() { |
3007 | loop { | 3098 | loop { |
3008 | let n = 1; | 3099 | let n = 1; |
@@ -3013,7 +3104,8 @@ fn foo() { | |||
3013 | let k = k + 1;$0 | 3104 | let k = k + 1;$0 |
3014 | let r = n + k; | 3105 | let r = n + k; |
3015 | } | 3106 | } |
3016 | }"##, | 3107 | } |
3108 | "#, | ||
3017 | ); | 3109 | ); |
3018 | } | 3110 | } |
3019 | 3111 | ||
@@ -3021,7 +3113,7 @@ fn foo() { | |||
3021 | fn break_loop_with_if() { | 3113 | fn break_loop_with_if() { |
3022 | check_assist( | 3114 | check_assist( |
3023 | extract_function, | 3115 | extract_function, |
3024 | r##" | 3116 | r#" |
3025 | fn foo() { | 3117 | fn foo() { |
3026 | loop { | 3118 | loop { |
3027 | let mut n = 1; | 3119 | let mut n = 1; |
@@ -3030,8 +3122,9 @@ fn foo() { | |||
3030 | n += m;$0 | 3122 | n += m;$0 |
3031 | let h = 1 + n; | 3123 | let h = 1 + n; |
3032 | } | 3124 | } |
3033 | }"##, | 3125 | } |
3034 | r##" | 3126 | "#, |
3127 | r#" | ||
3035 | fn foo() { | 3128 | fn foo() { |
3036 | loop { | 3129 | loop { |
3037 | let mut n = 1; | 3130 | let mut n = 1; |
@@ -3047,7 +3140,8 @@ fn $0fun_name(n: &mut i32) -> bool { | |||
3047 | return true; | 3140 | return true; |
3048 | *n += m; | 3141 | *n += m; |
3049 | false | 3142 | false |
3050 | }"##, | 3143 | } |
3144 | "#, | ||
3051 | ); | 3145 | ); |
3052 | } | 3146 | } |
3053 | 3147 | ||
@@ -3055,7 +3149,7 @@ fn $0fun_name(n: &mut i32) -> bool { | |||
3055 | fn break_loop_nested() { | 3149 | fn break_loop_nested() { |
3056 | check_assist( | 3150 | check_assist( |
3057 | extract_function, | 3151 | extract_function, |
3058 | r##" | 3152 | r#" |
3059 | fn foo() { | 3153 | fn foo() { |
3060 | loop { | 3154 | loop { |
3061 | let mut n = 1; | 3155 | let mut n = 1; |
@@ -3065,8 +3159,9 @@ fn foo() { | |||
3065 | }$0 | 3159 | }$0 |
3066 | let h = 1; | 3160 | let h = 1; |
3067 | } | 3161 | } |
3068 | }"##, | 3162 | } |
3069 | r##" | 3163 | "#, |
3164 | r#" | ||
3070 | fn foo() { | 3165 | fn foo() { |
3071 | loop { | 3166 | loop { |
3072 | let mut n = 1; | 3167 | let mut n = 1; |
@@ -3083,7 +3178,8 @@ fn $0fun_name(n: i32) -> bool { | |||
3083 | return true; | 3178 | return true; |
3084 | } | 3179 | } |
3085 | false | 3180 | false |
3086 | }"##, | 3181 | } |
3182 | "#, | ||
3087 | ); | 3183 | ); |
3088 | } | 3184 | } |
3089 | 3185 | ||
@@ -3091,7 +3187,7 @@ fn $0fun_name(n: i32) -> bool { | |||
3091 | fn return_from_nested_loop() { | 3187 | fn return_from_nested_loop() { |
3092 | check_assist( | 3188 | check_assist( |
3093 | extract_function, | 3189 | extract_function, |
3094 | r##" | 3190 | r#" |
3095 | fn foo() { | 3191 | fn foo() { |
3096 | loop { | 3192 | loop { |
3097 | let n = 1; | 3193 | let n = 1; |
@@ -3103,8 +3199,9 @@ fn foo() { | |||
3103 | let m = k + 1;$0 | 3199 | let m = k + 1;$0 |
3104 | let h = 1 + m; | 3200 | let h = 1 + m; |
3105 | } | 3201 | } |
3106 | }"##, | 3202 | } |
3107 | r##" | 3203 | "#, |
3204 | r#" | ||
3108 | fn foo() { | 3205 | fn foo() { |
3109 | loop { | 3206 | loop { |
3110 | let n = 1; | 3207 | let n = 1; |
@@ -3123,7 +3220,8 @@ fn $0fun_name() -> Option<i32> { | |||
3123 | } | 3220 | } |
3124 | let m = k + 1; | 3221 | let m = k + 1; |
3125 | Some(m) | 3222 | Some(m) |
3126 | }"##, | 3223 | } |
3224 | "#, | ||
3127 | ); | 3225 | ); |
3128 | } | 3226 | } |
3129 | 3227 | ||
@@ -3131,7 +3229,7 @@ fn $0fun_name() -> Option<i32> { | |||
3131 | fn break_from_nested_loop() { | 3229 | fn break_from_nested_loop() { |
3132 | check_assist( | 3230 | check_assist( |
3133 | extract_function, | 3231 | extract_function, |
3134 | r##" | 3232 | r#" |
3135 | fn foo() { | 3233 | fn foo() { |
3136 | loop { | 3234 | loop { |
3137 | let n = 1; | 3235 | let n = 1; |
@@ -3142,8 +3240,9 @@ fn foo() { | |||
3142 | let m = k + 1;$0 | 3240 | let m = k + 1;$0 |
3143 | let h = 1 + m; | 3241 | let h = 1 + m; |
3144 | } | 3242 | } |
3145 | }"##, | 3243 | } |
3146 | r##" | 3244 | "#, |
3245 | r#" | ||
3147 | fn foo() { | 3246 | fn foo() { |
3148 | loop { | 3247 | loop { |
3149 | let n = 1; | 3248 | let n = 1; |
@@ -3159,7 +3258,8 @@ fn $0fun_name() -> i32 { | |||
3159 | } | 3258 | } |
3160 | let m = k + 1; | 3259 | let m = k + 1; |
3161 | m | 3260 | m |
3162 | }"##, | 3261 | } |
3262 | "#, | ||
3163 | ); | 3263 | ); |
3164 | } | 3264 | } |
3165 | 3265 | ||
@@ -3167,7 +3267,7 @@ fn $0fun_name() -> i32 { | |||
3167 | fn break_from_nested_and_outer_loops() { | 3267 | fn break_from_nested_and_outer_loops() { |
3168 | check_assist( | 3268 | check_assist( |
3169 | extract_function, | 3269 | extract_function, |
3170 | r##" | 3270 | r#" |
3171 | fn foo() { | 3271 | fn foo() { |
3172 | loop { | 3272 | loop { |
3173 | let n = 1; | 3273 | let n = 1; |
@@ -3181,8 +3281,9 @@ fn foo() { | |||
3181 | let m = k + 1;$0 | 3281 | let m = k + 1;$0 |
3182 | let h = 1 + m; | 3282 | let h = 1 + m; |
3183 | } | 3283 | } |
3184 | }"##, | 3284 | } |
3185 | r##" | 3285 | "#, |
3286 | r#" | ||
3186 | fn foo() { | 3287 | fn foo() { |
3187 | loop { | 3288 | loop { |
3188 | let n = 1; | 3289 | let n = 1; |
@@ -3204,7 +3305,8 @@ fn $0fun_name() -> Option<i32> { | |||
3204 | } | 3305 | } |
3205 | let m = k + 1; | 3306 | let m = k + 1; |
3206 | Some(m) | 3307 | Some(m) |
3207 | }"##, | 3308 | } |
3309 | "#, | ||
3208 | ); | 3310 | ); |
3209 | } | 3311 | } |
3210 | 3312 | ||
@@ -3212,7 +3314,7 @@ fn $0fun_name() -> Option<i32> { | |||
3212 | fn return_from_nested_fn() { | 3314 | fn return_from_nested_fn() { |
3213 | check_assist( | 3315 | check_assist( |
3214 | extract_function, | 3316 | extract_function, |
3215 | r##" | 3317 | r#" |
3216 | fn foo() { | 3318 | fn foo() { |
3217 | loop { | 3319 | loop { |
3218 | let n = 1; | 3320 | let n = 1; |
@@ -3223,8 +3325,9 @@ fn foo() { | |||
3223 | let m = k + 1;$0 | 3325 | let m = k + 1;$0 |
3224 | let h = 1 + m; | 3326 | let h = 1 + m; |
3225 | } | 3327 | } |
3226 | }"##, | 3328 | } |
3227 | r##" | 3329 | "#, |
3330 | r#" | ||
3228 | fn foo() { | 3331 | fn foo() { |
3229 | loop { | 3332 | loop { |
3230 | let n = 1; | 3333 | let n = 1; |
@@ -3240,7 +3343,8 @@ fn $0fun_name() -> i32 { | |||
3240 | } | 3343 | } |
3241 | let m = k + 1; | 3344 | let m = k + 1; |
3242 | m | 3345 | m |
3243 | }"##, | 3346 | } |
3347 | "#, | ||
3244 | ); | 3348 | ); |
3245 | } | 3349 | } |
3246 | 3350 | ||
@@ -3248,7 +3352,7 @@ fn $0fun_name() -> i32 { | |||
3248 | fn break_with_value() { | 3352 | fn break_with_value() { |
3249 | check_assist( | 3353 | check_assist( |
3250 | extract_function, | 3354 | extract_function, |
3251 | r##" | 3355 | r#" |
3252 | fn foo() -> i32 { | 3356 | fn foo() -> i32 { |
3253 | loop { | 3357 | loop { |
3254 | let n = 1; | 3358 | let n = 1; |
@@ -3259,8 +3363,9 @@ fn foo() -> i32 { | |||
3259 | let m = k + 1;$0 | 3363 | let m = k + 1;$0 |
3260 | let h = 1; | 3364 | let h = 1; |
3261 | } | 3365 | } |
3262 | }"##, | 3366 | } |
3263 | r##" | 3367 | "#, |
3368 | r#" | ||
3264 | fn foo() -> i32 { | 3369 | fn foo() -> i32 { |
3265 | loop { | 3370 | loop { |
3266 | let n = 1; | 3371 | let n = 1; |
@@ -3278,7 +3383,8 @@ fn $0fun_name() -> Option<i32> { | |||
3278 | } | 3383 | } |
3279 | let m = k + 1; | 3384 | let m = k + 1; |
3280 | None | 3385 | None |
3281 | }"##, | 3386 | } |
3387 | "#, | ||
3282 | ); | 3388 | ); |
3283 | } | 3389 | } |
3284 | 3390 | ||
@@ -3286,7 +3392,7 @@ fn $0fun_name() -> Option<i32> { | |||
3286 | fn break_with_value_and_return() { | 3392 | fn break_with_value_and_return() { |
3287 | check_assist( | 3393 | check_assist( |
3288 | extract_function, | 3394 | extract_function, |
3289 | r##" | 3395 | r#" |
3290 | fn foo() -> i64 { | 3396 | fn foo() -> i64 { |
3291 | loop { | 3397 | loop { |
3292 | let n = 1; | 3398 | let n = 1; |
@@ -3298,8 +3404,9 @@ fn foo() -> i64 { | |||
3298 | let m = k + 1;$0 | 3404 | let m = k + 1;$0 |
3299 | let h = 1 + m; | 3405 | let h = 1 + m; |
3300 | } | 3406 | } |
3301 | }"##, | 3407 | } |
3302 | r##" | 3408 | "#, |
3409 | r#" | ||
3303 | fn foo() -> i64 { | 3410 | fn foo() -> i64 { |
3304 | loop { | 3411 | loop { |
3305 | let n = 1; | 3412 | let n = 1; |
@@ -3318,7 +3425,8 @@ fn $0fun_name() -> Result<i32, i64> { | |||
3318 | } | 3425 | } |
3319 | let m = k + 1; | 3426 | let m = k + 1; |
3320 | Ok(m) | 3427 | Ok(m) |
3321 | }"##, | 3428 | } |
3429 | "#, | ||
3322 | ); | 3430 | ); |
3323 | } | 3431 | } |
3324 | 3432 | ||
@@ -3326,9 +3434,8 @@ fn $0fun_name() -> Result<i32, i64> { | |||
3326 | fn try_option() { | 3434 | fn try_option() { |
3327 | check_assist( | 3435 | check_assist( |
3328 | extract_function, | 3436 | extract_function, |
3329 | r##" | 3437 | r#" |
3330 | enum Option<T> { None, Some(T), } | 3438 | //- minicore: option |
3331 | use Option::*; | ||
3332 | fn bar() -> Option<i32> { None } | 3439 | fn bar() -> Option<i32> { None } |
3333 | fn foo() -> Option<()> { | 3440 | fn foo() -> Option<()> { |
3334 | let n = bar()?; | 3441 | let n = bar()?; |
@@ -3336,10 +3443,9 @@ fn foo() -> Option<()> { | |||
3336 | let m = k + 1;$0 | 3443 | let m = k + 1;$0 |
3337 | let h = 1 + m; | 3444 | let h = 1 + m; |
3338 | Some(()) | 3445 | Some(()) |
3339 | }"##, | 3446 | } |
3340 | r##" | 3447 | "#, |
3341 | enum Option<T> { None, Some(T), } | 3448 | r#" |
3342 | use Option::*; | ||
3343 | fn bar() -> Option<i32> { None } | 3449 | fn bar() -> Option<i32> { None } |
3344 | fn foo() -> Option<()> { | 3450 | fn foo() -> Option<()> { |
3345 | let n = bar()?; | 3451 | let n = bar()?; |
@@ -3352,7 +3458,8 @@ fn $0fun_name() -> Option<i32> { | |||
3352 | let k = foo()?; | 3458 | let k = foo()?; |
3353 | let m = k + 1; | 3459 | let m = k + 1; |
3354 | Some(m) | 3460 | Some(m) |
3355 | }"##, | 3461 | } |
3462 | "#, | ||
3356 | ); | 3463 | ); |
3357 | } | 3464 | } |
3358 | 3465 | ||
@@ -3360,19 +3467,17 @@ fn $0fun_name() -> Option<i32> { | |||
3360 | fn try_option_unit() { | 3467 | fn try_option_unit() { |
3361 | check_assist( | 3468 | check_assist( |
3362 | extract_function, | 3469 | extract_function, |
3363 | r##" | 3470 | r#" |
3364 | enum Option<T> { None, Some(T), } | 3471 | //- minicore: option |
3365 | use Option::*; | ||
3366 | fn foo() -> Option<()> { | 3472 | fn foo() -> Option<()> { |
3367 | let n = 1; | 3473 | let n = 1; |
3368 | $0let k = foo()?; | 3474 | $0let k = foo()?; |
3369 | let m = k + 1;$0 | 3475 | let m = k + 1;$0 |
3370 | let h = 1 + n; | 3476 | let h = 1 + n; |
3371 | Some(()) | 3477 | Some(()) |
3372 | }"##, | 3478 | } |
3373 | r##" | 3479 | "#, |
3374 | enum Option<T> { None, Some(T), } | 3480 | r#" |
3375 | use Option::*; | ||
3376 | fn foo() -> Option<()> { | 3481 | fn foo() -> Option<()> { |
3377 | let n = 1; | 3482 | let n = 1; |
3378 | fun_name()?; | 3483 | fun_name()?; |
@@ -3384,7 +3489,8 @@ fn $0fun_name() -> Option<()> { | |||
3384 | let k = foo()?; | 3489 | let k = foo()?; |
3385 | let m = k + 1; | 3490 | let m = k + 1; |
3386 | Some(()) | 3491 | Some(()) |
3387 | }"##, | 3492 | } |
3493 | "#, | ||
3388 | ); | 3494 | ); |
3389 | } | 3495 | } |
3390 | 3496 | ||
@@ -3392,19 +3498,17 @@ fn $0fun_name() -> Option<()> { | |||
3392 | fn try_result() { | 3498 | fn try_result() { |
3393 | check_assist( | 3499 | check_assist( |
3394 | extract_function, | 3500 | extract_function, |
3395 | r##" | 3501 | r#" |
3396 | enum Result<T, E> { Ok(T), Err(E), } | 3502 | //- minicore: result |
3397 | use Result::*; | ||
3398 | fn foo() -> Result<(), i64> { | 3503 | fn foo() -> Result<(), i64> { |
3399 | let n = 1; | 3504 | let n = 1; |
3400 | $0let k = foo()?; | 3505 | $0let k = foo()?; |
3401 | let m = k + 1;$0 | 3506 | let m = k + 1;$0 |
3402 | let h = 1 + m; | 3507 | let h = 1 + m; |
3403 | Ok(()) | 3508 | Ok(()) |
3404 | }"##, | 3509 | } |
3405 | r##" | 3510 | "#, |
3406 | enum Result<T, E> { Ok(T), Err(E), } | 3511 | r#" |
3407 | use Result::*; | ||
3408 | fn foo() -> Result<(), i64> { | 3512 | fn foo() -> Result<(), i64> { |
3409 | let n = 1; | 3513 | let n = 1; |
3410 | let m = fun_name()?; | 3514 | let m = fun_name()?; |
@@ -3416,7 +3520,8 @@ fn $0fun_name() -> Result<i32, i64> { | |||
3416 | let k = foo()?; | 3520 | let k = foo()?; |
3417 | let m = k + 1; | 3521 | let m = k + 1; |
3418 | Ok(m) | 3522 | Ok(m) |
3419 | }"##, | 3523 | } |
3524 | "#, | ||
3420 | ); | 3525 | ); |
3421 | } | 3526 | } |
3422 | 3527 | ||
@@ -3424,9 +3529,8 @@ fn $0fun_name() -> Result<i32, i64> { | |||
3424 | fn try_option_with_return() { | 3529 | fn try_option_with_return() { |
3425 | check_assist( | 3530 | check_assist( |
3426 | extract_function, | 3531 | extract_function, |
3427 | r##" | 3532 | r#" |
3428 | enum Option<T> { None, Some(T) } | 3533 | //- minicore: option |
3429 | use Option::*; | ||
3430 | fn foo() -> Option<()> { | 3534 | fn foo() -> Option<()> { |
3431 | let n = 1; | 3535 | let n = 1; |
3432 | $0let k = foo()?; | 3536 | $0let k = foo()?; |
@@ -3436,10 +3540,9 @@ fn foo() -> Option<()> { | |||
3436 | let m = k + 1;$0 | 3540 | let m = k + 1;$0 |
3437 | let h = 1 + m; | 3541 | let h = 1 + m; |
3438 | Some(()) | 3542 | Some(()) |
3439 | }"##, | 3543 | } |
3440 | r##" | 3544 | "#, |
3441 | enum Option<T> { None, Some(T) } | 3545 | r#" |
3442 | use Option::*; | ||
3443 | fn foo() -> Option<()> { | 3546 | fn foo() -> Option<()> { |
3444 | let n = 1; | 3547 | let n = 1; |
3445 | let m = fun_name()?; | 3548 | let m = fun_name()?; |
@@ -3454,7 +3557,8 @@ fn $0fun_name() -> Option<i32> { | |||
3454 | } | 3557 | } |
3455 | let m = k + 1; | 3558 | let m = k + 1; |
3456 | Some(m) | 3559 | Some(m) |
3457 | }"##, | 3560 | } |
3561 | "#, | ||
3458 | ); | 3562 | ); |
3459 | } | 3563 | } |
3460 | 3564 | ||
@@ -3462,9 +3566,8 @@ fn $0fun_name() -> Option<i32> { | |||
3462 | fn try_result_with_return() { | 3566 | fn try_result_with_return() { |
3463 | check_assist( | 3567 | check_assist( |
3464 | extract_function, | 3568 | extract_function, |
3465 | r##" | 3569 | r#" |
3466 | enum Result<T, E> { Ok(T), Err(E), } | 3570 | //- minicore: result |
3467 | use Result::*; | ||
3468 | fn foo() -> Result<(), i64> { | 3571 | fn foo() -> Result<(), i64> { |
3469 | let n = 1; | 3572 | let n = 1; |
3470 | $0let k = foo()?; | 3573 | $0let k = foo()?; |
@@ -3474,10 +3577,9 @@ fn foo() -> Result<(), i64> { | |||
3474 | let m = k + 1;$0 | 3577 | let m = k + 1;$0 |
3475 | let h = 1 + m; | 3578 | let h = 1 + m; |
3476 | Ok(()) | 3579 | Ok(()) |
3477 | }"##, | 3580 | } |
3478 | r##" | 3581 | "#, |
3479 | enum Result<T, E> { Ok(T), Err(E), } | 3582 | r#" |
3480 | use Result::*; | ||
3481 | fn foo() -> Result<(), i64> { | 3583 | fn foo() -> Result<(), i64> { |
3482 | let n = 1; | 3584 | let n = 1; |
3483 | let m = fun_name()?; | 3585 | let m = fun_name()?; |
@@ -3492,7 +3594,8 @@ fn $0fun_name() -> Result<i32, i64> { | |||
3492 | } | 3594 | } |
3493 | let m = k + 1; | 3595 | let m = k + 1; |
3494 | Ok(m) | 3596 | Ok(m) |
3495 | }"##, | 3597 | } |
3598 | "#, | ||
3496 | ); | 3599 | ); |
3497 | } | 3600 | } |
3498 | 3601 | ||
@@ -3501,9 +3604,8 @@ fn $0fun_name() -> Result<i32, i64> { | |||
3501 | cov_mark::check!(external_control_flow_try_and_bc); | 3604 | cov_mark::check!(external_control_flow_try_and_bc); |
3502 | check_assist_not_applicable( | 3605 | check_assist_not_applicable( |
3503 | extract_function, | 3606 | extract_function, |
3504 | r##" | 3607 | r#" |
3505 | enum Option<T> { None, Some(T) } | 3608 | //- minicore: option |
3506 | use Option::*; | ||
3507 | fn foo() -> Option<()> { | 3609 | fn foo() -> Option<()> { |
3508 | loop { | 3610 | loop { |
3509 | let n = Some(1); | 3611 | let n = Some(1); |
@@ -3514,7 +3616,8 @@ fn foo() -> Option<()> { | |||
3514 | let r = n + k; | 3616 | let r = n + k; |
3515 | } | 3617 | } |
3516 | Some(()) | 3618 | Some(()) |
3517 | }"##, | 3619 | } |
3620 | "#, | ||
3518 | ); | 3621 | ); |
3519 | } | 3622 | } |
3520 | 3623 | ||
@@ -3523,9 +3626,8 @@ fn foo() -> Option<()> { | |||
3523 | cov_mark::check!(external_control_flow_try_and_return_non_err); | 3626 | cov_mark::check!(external_control_flow_try_and_return_non_err); |
3524 | check_assist_not_applicable( | 3627 | check_assist_not_applicable( |
3525 | extract_function, | 3628 | extract_function, |
3526 | r##" | 3629 | r#" |
3527 | enum Result<T, E> { Ok(T), Err(E), } | 3630 | //- minicore: result |
3528 | use Result::*; | ||
3529 | fn foo() -> Result<(), i64> { | 3631 | fn foo() -> Result<(), i64> { |
3530 | let n = 1; | 3632 | let n = 1; |
3531 | $0let k = foo()?; | 3633 | $0let k = foo()?; |
@@ -3535,7 +3637,8 @@ fn foo() -> Result<(), i64> { | |||
3535 | let m = k + 1;$0 | 3637 | let m = k + 1;$0 |
3536 | let h = 1 + m; | 3638 | let h = 1 + m; |
3537 | Ok(()) | 3639 | Ok(()) |
3538 | }"##, | 3640 | } |
3641 | "#, | ||
3539 | ); | 3642 | ); |
3540 | } | 3643 | } |
3541 | 3644 | ||
@@ -3543,7 +3646,7 @@ fn foo() -> Result<(), i64> { | |||
3543 | fn param_usage_in_macro() { | 3646 | fn param_usage_in_macro() { |
3544 | check_assist( | 3647 | check_assist( |
3545 | extract_function, | 3648 | extract_function, |
3546 | r" | 3649 | r#" |
3547 | macro_rules! m { | 3650 | macro_rules! m { |
3548 | ($val:expr) => { $val }; | 3651 | ($val:expr) => { $val }; |
3549 | } | 3652 | } |
@@ -3552,8 +3655,9 @@ fn foo() { | |||
3552 | let n = 1; | 3655 | let n = 1; |
3553 | $0let k = n * m!(n);$0 | 3656 | $0let k = n * m!(n);$0 |
3554 | let m = k + 1; | 3657 | let m = k + 1; |
3555 | }", | 3658 | } |
3556 | r" | 3659 | "#, |
3660 | r#" | ||
3557 | macro_rules! m { | 3661 | macro_rules! m { |
3558 | ($val:expr) => { $val }; | 3662 | ($val:expr) => { $val }; |
3559 | } | 3663 | } |
@@ -3567,7 +3671,8 @@ fn foo() { | |||
3567 | fn $0fun_name(n: i32) -> i32 { | 3671 | fn $0fun_name(n: i32) -> i32 { |
3568 | let k = n * m!(n); | 3672 | let k = n * m!(n); |
3569 | k | 3673 | k |
3570 | }", | 3674 | } |
3675 | "#, | ||
3571 | ); | 3676 | ); |
3572 | } | 3677 | } |
3573 | 3678 | ||
@@ -3575,7 +3680,8 @@ fn $0fun_name(n: i32) -> i32 { | |||
3575 | fn extract_with_await() { | 3680 | fn extract_with_await() { |
3576 | check_assist( | 3681 | check_assist( |
3577 | extract_function, | 3682 | extract_function, |
3578 | r#"fn main() { | 3683 | r#" |
3684 | fn main() { | ||
3579 | $0some_function().await;$0 | 3685 | $0some_function().await;$0 |
3580 | } | 3686 | } |
3581 | 3687 | ||
@@ -3603,7 +3709,8 @@ async fn some_function() { | |||
3603 | fn extract_with_await_in_args() { | 3709 | fn extract_with_await_in_args() { |
3604 | check_assist( | 3710 | check_assist( |
3605 | extract_function, | 3711 | extract_function, |
3606 | r#"fn main() { | 3712 | r#" |
3713 | fn main() { | ||
3607 | $0function_call("a", some_function().await);$0 | 3714 | $0function_call("a", some_function().await);$0 |
3608 | } | 3715 | } |
3609 | 3716 | ||