Fix duplicate type mismatches with blocks

E.g. when there's a type mismatch on the return value of a function. To
fix this, we have to return the expected type as the type of the block
when there's a mismatch. That meant some IDE code that expected
otherwise had to be adapted, in particular the "add return type" assist.
For the "wrap in Ok/Some" quickfix, this sadly means it usually can't be applied
in all branches of an if expression at the same time anymore, because
there's a type mismatch for each branch that has the wrong type.
This commit is contained in:
Florian Diebold 2022-03-29 17:51:11 +02:00
parent 89d495eb30
commit 0c4bdd2f32
12 changed files with 212 additions and 83 deletions

View file

@ -54,13 +54,13 @@ fn check_nth_fix(nth: usize, ra_fixture_before: &str, ra_fixture_after: &str) {
actual
};
assert_eq_text!(&after, &actual);
assert!(
fix.target.contains_inclusive(file_position.offset),
"diagnostic fix range {:?} does not touch cursor position {:?}",
fix.target,
file_position.offset
);
assert_eq_text!(&after, &actual);
}
/// Checks that there's a diagnostic *without* fix at `$0`.