diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-04-17 19:47:08 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2020-04-17 19:47:08 +0100 |
commit | 8a4cebafca257f6d3294744d0e9e3d461c954645 (patch) | |
tree | 54d7d20ef4dc585bf85d176173f6d59273699681 /crates/ra_hir_ty/src/tests | |
parent | f11236e511ec8470276180fa728f4e00c17ee3fb (diff) | |
parent | 6a7fc76b89dca4d1b4e3e50047183535aee98627 (diff) |
Merge #4021
4021: Fix type equality for dyn Trait r=matklad a=flodiebold
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...)
Co-authored-by: Florian Diebold <[email protected]>
Diffstat (limited to 'crates/ra_hir_ty/src/tests')
-rw-r--r-- | crates/ra_hir_ty/src/tests/traits.rs | 24 |
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] | ||
2383 | fn trait_object_no_coercion() { | ||
2384 | assert_snapshot!( | ||
2385 | infer_with_mismatches(r#" | ||
2386 | trait Foo {} | ||
2387 | |||
2388 | fn foo(x: &dyn Foo) {} | ||
2389 | |||
2390 | fn 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 | } | ||