aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_ty/src/tests
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir_ty/src/tests')
-rw-r--r--crates/ra_hir_ty/src/tests/coercion.rs31
1 files changed, 31 insertions, 0 deletions
diff --git a/crates/ra_hir_ty/src/tests/coercion.rs b/crates/ra_hir_ty/src/tests/coercion.rs
index 60ad6e9be..1e303f5ce 100644
--- a/crates/ra_hir_ty/src/tests/coercion.rs
+++ b/crates/ra_hir_ty/src/tests/coercion.rs
@@ -458,6 +458,37 @@ fn test() {
458} 458}
459 459
460#[test] 460#[test]
461fn coerce_autoderef_block() {
462 assert_snapshot!(
463 infer_with_mismatches(r#"
464struct String {}
465#[lang = "deref"]
466trait Deref { type Target; }
467impl Deref for String { type Target = str; }
468fn takes_ref_str(x: &str) {}
469fn returns_string() -> String { loop {} }
470fn test() {
471 takes_ref_str(&{ returns_string() });
472}
473"#, true),
474 @r###"
475 [127; 128) 'x': &str
476 [136; 138) '{}': ()
477 [169; 180) '{ loop {} }': String
478 [171; 178) 'loop {}': !
479 [176; 178) '{}': ()
480 [191; 236) '{ ... }); }': ()
481 [197; 210) 'takes_ref_str': fn takes_ref_str(&str) -> ()
482 [197; 233) 'takes_...g() })': ()
483 [211; 232) '&{ ret...ng() }': &String
484 [212; 232) '{ retu...ng() }': String
485 [214; 228) 'returns_string': fn returns_string() -> String
486 [214; 230) 'return...ring()': String
487 "###
488 );
489}
490
491#[test]
461fn closure_return_coerce() { 492fn closure_return_coerce() {
462 assert_snapshot!( 493 assert_snapshot!(
463 infer_with_mismatches(r#" 494 infer_with_mismatches(r#"