aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_ty/src/tests
diff options
context:
space:
mode:
authorFlorian Diebold <[email protected]>2020-04-17 18:41:37 +0100
committerFlorian Diebold <[email protected]>2020-04-17 18:42:36 +0100
commit6a7fc76b89dca4d1b4e3e50047183535aee98627 (patch)
tree54d7d20ef4dc585bf85d176173f6d59273699681 /crates/ra_hir_ty/src/tests
parentf11236e511ec8470276180fa728f4e00c17ee3fb (diff)
Fix type equality for dyn Trait
Fixes a lot of false type mismatches. (And as always when touching the unification code, I have to say I'm looking forward to replacing it by Chalk's...)
Diffstat (limited to 'crates/ra_hir_ty/src/tests')
-rw-r--r--crates/ra_hir_ty/src/tests/traits.rs24
1 files changed, 24 insertions, 0 deletions
diff --git a/crates/ra_hir_ty/src/tests/traits.rs b/crates/ra_hir_ty/src/tests/traits.rs
index dc517fc4a..f6e3e07cd 100644
--- a/crates/ra_hir_ty/src/tests/traits.rs
+++ b/crates/ra_hir_ty/src/tests/traits.rs
@@ -2378,3 +2378,27 @@ fn main() {
2378 ); 2378 );
2379 assert_eq!(t, "Foo"); 2379 assert_eq!(t, "Foo");
2380} 2380}
2381
2382#[test]
2383fn trait_object_no_coercion() {
2384 assert_snapshot!(
2385 infer_with_mismatches(r#"
2386trait Foo {}
2387
2388fn foo(x: &dyn Foo) {}
2389
2390fn test(x: &dyn Foo) {
2391 foo(x);
2392}
2393"#, true),
2394 @r###"
2395 [22; 23) 'x': &dyn Foo
2396 [35; 37) '{}': ()
2397 [47; 48) 'x': &dyn Foo
2398 [60; 75) '{ foo(x); }': ()
2399 [66; 69) 'foo': fn foo(&dyn Foo)
2400 [66; 72) 'foo(x)': ()
2401 [70; 71) 'x': &dyn Foo
2402 "###
2403 );
2404}