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]
"##]],
);
}
)
}
-#[test]
-fn infer_closure_unify() {
- check_infer(
- r#"
- fn foo(f: bool) {
- let a = |x| x;
- let b = |x| x;
- let id = if f { a } else { b };
- id(123);
- }
- "#,
- expect![[r#"
- 7..8 'f': bool
- 16..106 '{ ...23); }': ()
- 26..27 'a': |i32| -> i32
- 30..35 '|x| x': |i32| -> i32
- 31..32 'x': i32
- 34..35 'x': i32
- 45..46 'b': |i32| -> i32
- 49..54 '|x| x': |i32| -> i32
- 50..51 'x': i32
- 53..54 'x': i32
- 64..66 'id': |i32| -> i32
- 69..90 'if f {... { b }': |i32| -> i32
- 72..73 'f': bool
- 74..79 '{ a }': |i32| -> i32
- 76..77 'a': |i32| -> i32
- 85..90 '{ b }': |i32| -> i32
- 87..88 'b': |i32| -> i32
- 96..98 'id': |i32| -> i32
- 96..103 'id(123)': i32
- 99..102 '123': i32
- "#]],
- )
-}
-
#[test]
fn infer_if_match_with_return() {
check_infer(
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
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
"#]],
);
}
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