Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 8fa8f40

Browse files
Structurally resolve before adjust_for_branches
1 parent da0380b commit 8fa8f40

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

‎compiler/rustc_hir_typeck/src/_match.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
5757
// type in that case)
5858
let mut all_arms_diverge = Diverges::WarnedAlways;
5959

60-
let expected = orig_expected.adjust_for_branches(self);
60+
let expected = orig_expected.adjust_for_branches(self, expr.span);
6161
debug!(?expected);
6262

6363
let mut coercion = {

‎compiler/rustc_hir_typeck/src/expectation.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,14 @@ impl<'a, 'tcx> Expectation<'tcx> {
3939
// an expected type. Otherwise, we might write parts of the type
4040
// when checking the 'then' block which are incompatible with the
4141
// 'else' branch.
42-
pub(super) fn adjust_for_branches(&self, fcx: &FnCtxt<'a, 'tcx>) -> Expectation<'tcx> {
42+
pub(super) fn adjust_for_branches(
43+
&self,
44+
fcx: &FnCtxt<'a, 'tcx>,
45+
span: Span,
46+
) -> Expectation<'tcx> {
4347
match *self {
4448
ExpectHasType(ety) => {
45-
let ety = fcx.shallow_resolve(ety);
49+
let ety = fcx.try_structurally_resolve_type(span,ety);
4650
if !ety.is_ty_var() { ExpectHasType(ety) } else { NoExpectation }
4751
}
4852
ExpectRvalueLikeUnsized(ety) => ExpectRvalueLikeUnsized(ety),

‎compiler/rustc_hir_typeck/src/expr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1294,7 +1294,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
12941294
let cond_diverges = self.diverges.get();
12951295
self.diverges.set(Diverges::Maybe);
12961296

1297-
let expected = orig_expected.adjust_for_branches(self);
1297+
let expected = orig_expected.adjust_for_branches(self, sp);
12981298
let then_ty = self.check_expr_with_expectation(then_expr, expected);
12991299
let then_diverges = self.diverges.get();
13001300
self.diverges.set(Diverges::Maybe);

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /