aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_ty/src/tests
diff options
context:
space:
mode:
authorFlorian Diebold <[email protected]>2020-02-22 12:14:39 +0000
committerFlorian Diebold <[email protected]>2020-02-22 12:14:39 +0000
commit3e106c77ff76c39be49444165eac805d32666e41 (patch)
tree7f136356bb7edb610233a2821be0b755725ed03a /crates/ra_hir_ty/src/tests
parentc2000257941956cd4c4365d6eb6cdbc1b16e929c (diff)
Rework find_super_trait_path to protect against cycles
Diffstat (limited to 'crates/ra_hir_ty/src/tests')
-rw-r--r--crates/ra_hir_ty/src/tests/coercion.rs38
1 files changed, 38 insertions, 0 deletions
diff --git a/crates/ra_hir_ty/src/tests/coercion.rs b/crates/ra_hir_ty/src/tests/coercion.rs
index 5594ed394..60ad6e9be 100644
--- a/crates/ra_hir_ty/src/tests/coercion.rs
+++ b/crates/ra_hir_ty/src/tests/coercion.rs
@@ -622,6 +622,44 @@ fn test() {
622 ); 622 );
623} 623}
624 624
625#[test]
626fn coerce_unsize_super_trait_cycle() {
627 assert_snapshot!(
628 infer_with_mismatches(r#"
629#[lang = "unsize"]
630pub trait Unsize<T> {}
631#[lang = "coerce_unsized"]
632pub trait CoerceUnsized<T> {}
633
634impl<T: Unsize<U>, U> CoerceUnsized<&U> for &T {}
635
636trait A {}
637trait B: C + A {}
638trait C: B {}
639trait D: C
640
641struct S;
642impl A for S {}
643impl B for S {}
644impl C for S {}
645impl D for S {}
646
647fn test() {
648 let obj: &dyn D = &S;
649 let obj: &dyn A = obj;
650}
651"#, true),
652 @r###"
653 [292; 348) '{ ...obj; }': ()
654 [302; 305) 'obj': &dyn D
655 [316; 318) '&S': &S
656 [317; 318) 'S': S
657 [328; 331) 'obj': &dyn A
658 [342; 345) 'obj': &dyn D
659 "###
660 );
661}
662
625#[ignore] 663#[ignore]
626#[test] 664#[test]
627fn coerce_unsize_generic() { 665fn coerce_unsize_generic() {