aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_ty/src/tests
diff options
context:
space:
mode:
authorFlorian Diebold <[email protected]>2020-02-07 17:27:54 +0000
committerFlorian Diebold <[email protected]>2020-02-07 17:28:11 +0000
commiteefe02ce6e1750b771cf99125429358e87485745 (patch)
treed51fc01b2e85b0a85b22e49e830c541c827badca /crates/ra_hir_ty/src/tests
parent9d6061f3bb935c914a6d58df803dd42770f2f7e2 (diff)
Add two more tests
Diffstat (limited to 'crates/ra_hir_ty/src/tests')
-rw-r--r--crates/ra_hir_ty/src/tests/traits.rs51
1 files changed, 51 insertions, 0 deletions
diff --git a/crates/ra_hir_ty/src/tests/traits.rs b/crates/ra_hir_ty/src/tests/traits.rs
index c6851fb69..17611ddbf 100644
--- a/crates/ra_hir_ty/src/tests/traits.rs
+++ b/crates/ra_hir_ty/src/tests/traits.rs
@@ -1014,6 +1014,31 @@ fn test() {
1014} 1014}
1015 1015
1016#[test] 1016#[test]
1017fn argument_impl_trait_to_fn_pointer() {
1018 assert_snapshot!(
1019 infer_with_mismatches(r#"
1020trait Trait {}
1021fn foo(x: impl Trait) { loop {} }
1022struct S;
1023impl Trait for S {}
1024
1025fn test() {
1026 let f: fn(S) -> () = foo;
1027}
1028"#, true),
1029 @r###"
1030 [23; 24) 'x': impl Trait
1031 [38; 49) '{ loop {} }': ()
1032 [40; 47) 'loop {}': !
1033 [45; 47) '{}': ()
1034 [91; 124) '{ ...foo; }': ()
1035 [101; 102) 'f': fn(S) -> ()
1036 [118; 121) 'foo': fn foo(S) -> ()
1037 "###
1038 );
1039}
1040
1041#[test]
1017#[ignore] 1042#[ignore]
1018fn impl_trait() { 1043fn impl_trait() {
1019 assert_snapshot!( 1044 assert_snapshot!(
@@ -1377,6 +1402,32 @@ fn test<T: Trait1, U: Trait2>(x: T, y: U) {
1377} 1402}
1378 1403
1379#[test] 1404#[test]
1405fn super_trait_impl_trait_method_resolution() {
1406 assert_snapshot!(
1407 infer(r#"
1408mod foo {
1409 trait SuperTrait {
1410 fn foo(&self) -> u32 {}
1411 }
1412}
1413trait Trait1: foo::SuperTrait {}
1414
1415fn test(x: &impl Trait1) {
1416 x.foo();
1417}
1418"#),
1419 @r###"
1420 [50; 54) 'self': &Self
1421 [63; 65) '{}': ()
1422 [116; 117) 'x': &impl Trait1
1423 [133; 149) '{ ...o(); }': ()
1424 [139; 140) 'x': &impl Trait1
1425 [139; 146) 'x.foo()': u32
1426 "###
1427 );
1428}
1429
1430#[test]
1380fn super_trait_cycle() { 1431fn super_trait_cycle() {
1381 // This just needs to not crash 1432 // This just needs to not crash
1382 assert_snapshot!( 1433 assert_snapshot!(