mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-03 07:04:49 +00:00
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...)
This commit is contained in:
parent
f11236e511
commit
6a7fc76b89
3 changed files with 65 additions and 5 deletions
|
@ -2378,3 +2378,27 @@ fn main() {
|
|||
);
|
||||
assert_eq!(t, "Foo");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn trait_object_no_coercion() {
|
||||
assert_snapshot!(
|
||||
infer_with_mismatches(r#"
|
||||
trait Foo {}
|
||||
|
||||
fn foo(x: &dyn Foo) {}
|
||||
|
||||
fn test(x: &dyn Foo) {
|
||||
foo(x);
|
||||
}
|
||||
"#, true),
|
||||
@r###"
|
||||
[22; 23) 'x': &dyn Foo
|
||||
[35; 37) '{}': ()
|
||||
[47; 48) 'x': &dyn Foo
|
||||
[60; 75) '{ foo(x); }': ()
|
||||
[66; 69) 'foo': fn foo(&dyn Foo)
|
||||
[66; 72) 'foo(x)': ()
|
||||
[70; 71) 'x': &dyn Foo
|
||||
"###
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue