@@ -1693,16 +1693,16 @@ fn infer_type_param() {
1693
1693
fn infer_const ( ) {
1694
1694
check_infer (
1695
1695
r#"
1696
- struct Foo;
1697
- impl Foo { const ASSOC_CONST: u32 = 0; }
1698
- const GLOBAL_CONST: u32 = 101;
1699
- fn test() {
1700
- const LOCAL_CONST: u32 = 99;
1701
- let x = LOCAL_CONST;
1702
- let z = GLOBAL_CONST;
1703
- let id = Foo::ASSOC_CONST;
1704
- }
1705
- "#,
1696
+ struct Foo;
1697
+ impl Foo { const ASSOC_CONST: u32 = 0; }
1698
+ const GLOBAL_CONST: u32 = 101;
1699
+ fn test() {
1700
+ const LOCAL_CONST: u32 = 99;
1701
+ let x = LOCAL_CONST;
1702
+ let z = GLOBAL_CONST;
1703
+ let id = Foo::ASSOC_CONST;
1704
+ }
1705
+ "# ,
1706
1706
expect ! [ [ r#"
1707
1707
48..49 '0': u32
1708
1708
79..82 '101': u32
@@ -1722,17 +1722,17 @@ fn infer_const() {
1722
1722
fn infer_static ( ) {
1723
1723
check_infer (
1724
1724
r#"
1725
- static GLOBAL_STATIC: u32 = 101;
1726
- static mut GLOBAL_STATIC_MUT: u32 = 101;
1727
- fn test() {
1728
- static LOCAL_STATIC: u32 = 99;
1729
- static mut LOCAL_STATIC_MUT: u32 = 99;
1730
- let x = LOCAL_STATIC;
1731
- let y = LOCAL_STATIC_MUT;
1732
- let z = GLOBAL_STATIC;
1733
- let w = GLOBAL_STATIC_MUT;
1734
- }
1735
- "#,
1725
+ static GLOBAL_STATIC: u32 = 101;
1726
+ static mut GLOBAL_STATIC_MUT: u32 = 101;
1727
+ fn test() {
1728
+ static LOCAL_STATIC: u32 = 99;
1729
+ static mut LOCAL_STATIC_MUT: u32 = 99;
1730
+ let x = LOCAL_STATIC;
1731
+ let y = LOCAL_STATIC_MUT;
1732
+ let z = GLOBAL_STATIC;
1733
+ let w = GLOBAL_STATIC_MUT;
1734
+ }
1735
+ "# ,
1736
1736
expect ! [ [ r#"
1737
1737
28..31 '101': u32
1738
1738
69..72 '101': u32
@@ -1751,6 +1751,41 @@ fn infer_static() {
1751
1751
) ;
1752
1752
}
1753
1753
1754
+ #[ test]
1755
+ fn infer_enum_variant ( ) {
1756
+ check_infer (
1757
+ r#"
1758
+ enum Foo {
1759
+ A = 15,
1760
+ B = Foo::A as isize + 1
1761
+ }
1762
+ "# ,
1763
+ expect ! [ [ r#"
1764
+ 19..21 '15': isize
1765
+ 31..37 'Foo::A': Foo
1766
+ 31..46 'Foo::A as isize': isize
1767
+ 31..50 'Foo::A...ze + 1': isize
1768
+ 49..50 '1': isize
1769
+ "# ] ] ,
1770
+ ) ;
1771
+ check_infer (
1772
+ r#"
1773
+ #[repr(u32)]
1774
+ enum Foo {
1775
+ A = 15,
1776
+ B = Foo::A as u32 + 1
1777
+ }
1778
+ "# ,
1779
+ expect ! [ [ r#"
1780
+ 32..34 '15': u32
1781
+ 44..50 'Foo::A': Foo
1782
+ 44..57 'Foo::A as u32': u32
1783
+ 44..61 'Foo::A...32 + 1': u32
1784
+ 60..61 '1': u32
1785
+ "# ] ] ,
1786
+ ) ;
1787
+ }
1788
+
1754
1789
#[ test]
1755
1790
fn shadowing_primitive ( ) {
1756
1791
check_types (
0 commit comments