]> git.lizzy.rs Git - rust.git/blobdiff - crates/hir_ty/src/tests/simple.rs
Add more tests, refactor array lengths/consteval work
[rust.git] / crates / hir_ty / src / tests / simple.rs
index 8b09f2e4a0f7e948616f95d9ff8b42fec07b9cc8..a9cd42186ed01af5c1eb42c99777ea520f329021 100644 (file)
@@ -488,23 +488,34 @@ fn test() {
                 mod foo {}
             "#;
             br#"yolo"#;
+            let a = b"a\x20b\
+            c";
+            let b = br"g\
+h";
+            let c = br#"x"\"yb"#;
         }
         "##,
         expect![[r##"
-            10..216 '{     ...o"#; }': ()
-            16..20 '5i32': i32
-            26..30 '5f32': f32
-            36..40 '5f64': f64
-            46..53 '"hello"': &str
-            59..67 'b"bytes"': &[u8; _]
-            73..76 ''c'': char
-            82..86 'b'b'': u8
-            92..96 '3.14': f64
-            102..106 '5000': i32
-            112..117 'false': bool
-            123..127 'true': bool
-            133..197 'r#"   ...    "#': &str
-            203..213 'br#"yolo"#': &[u8; _]
+            18..478 '{     ...     }': ()
+            32..36 '5i32': i32
+            50..54 '5f32': f32
+            68..72 '5f64': f64
+            86..93 '"hello"': &str
+            107..115 'b"bytes"': &[u8; 5]
+            129..132 ''c'': char
+            146..150 'b'b'': u8
+            164..168 '3.14': f64
+            182..186 '5000': i32
+            200..205 'false': bool
+            219..223 'true': bool
+            237..333 'r#"   ...    "#': &str
+            347..357 'br#"yolo"#': &[u8; 4]
+            375..376 'a': &[u8; 4]
+            379..403 'b"a\x2...    c"': &[u8; 4]
+            421..422 'b': &[u8; 4]
+            425..433 'br"g\ h"': &[u8; 4]
+            451..452 'c': &[u8; 6]
+            455..467 'br#"x"\"yb"#': &[u8; 6]
         "##]],
     );
 }
@@ -1260,12 +1271,14 @@ fn test(x: &str, y: isize) {
 
             let b = [a, ["b"]];
             let x: [u8; 0] = [];
+            // FIXME: requires const evaluation/taking type from rhs somehow
+            let y: [u8; 2+2] = [1,2,3,4];
         }
         "#,
         expect![[r#"
             8..9 'x': &str
             17..18 'y': isize
-            27..292 '{     ... []; }': ()
+            27..395 '{     ...,4]; }': ()
             37..38 'a': [&str; 1]
             41..44 '[x]': [&str; 1]
             42..43 'x': &str
@@ -1313,8 +1326,14 @@ fn test(x: &str, y: isize) {
             255..256 'a': [&str; 1]
             258..263 '["b"]': [&str; 1]
             259..262 '"b"': &str
-            274..275 'x': [u8; _]
+            274..275 'x': [u8; 0]
             287..289 '[]': [u8; 0]
+            368..369 'y': [u8; _]
+            383..392 '[1,2,3,4]': [u8; 4]
+            384..385 '1': u8
+            386..387 '2': u8
+            388..389 '3': u8
+            390..391 '4': u8
         "#]],
     );
 }
@@ -2409,38 +2428,38 @@ fn test() {
             320..422 '{     ...     }': V2
             334..335 'x': f32
             338..342 'self': V2
-            338..344 'self.0': [f32; _]
+            338..344 'self.0': [f32; 2]
             338..347 'self.0[0]': {unknown}
             338..358 'self.0...s.0[0]': f32
             345..346 '0': i32
             350..353 'rhs': V2
-            350..355 'rhs.0': [f32; _]
+            350..355 'rhs.0': [f32; 2]
             350..358 'rhs.0[0]': {unknown}
             356..357 '0': i32
             372..373 'y': f32
             376..380 'self': V2
-            376..382 'self.0': [f32; _]
+            376..382 'self.0': [f32; 2]
             376..385 'self.0[1]': {unknown}
             376..396 'self.0...s.0[1]': f32
             383..384 '1': i32
             388..391 'rhs': V2
-            388..393 'rhs.0': [f32; _]
+            388..393 'rhs.0': [f32; 2]
             388..396 'rhs.0[1]': {unknown}
             394..395 '1': i32
-            406..408 'V2': V2([f32; _]) -> V2
+            406..408 'V2': V2([f32; 2]) -> V2
             406..416 'V2([x, y])': V2
             409..415 '[x, y]': [f32; 2]
             410..411 'x': f32
             413..414 'y': f32
             436..519 '{     ... vb; }': ()
             446..448 'va': V2
-            451..453 'V2': V2([f32; _]) -> V2
+            451..453 'V2': V2([f32; 2]) -> V2
             451..465 'V2([0.0, 1.0])': V2
             454..464 '[0.0, 1.0]': [f32; 2]
             455..458 '0.0': f32
             460..463 '1.0': f32
             475..477 'vb': V2
-            480..482 'V2': V2([f32; _]) -> V2
+            480..482 'V2': V2([f32; 2]) -> V2
             480..494 'V2([0.0, 1.0])': V2
             483..493 '[0.0, 1.0]': [f32; 2]
             484..487 '0.0': f32