Skip to content

Commit 8568f44

Browse files
suggest deref/unboxing before wrapping variant
1 parent 40f33a7 commit 8568f44

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

compiler/rustc_typeck/src/check/demand.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
3131
error: TypeError<'tcx>,
3232
) {
3333
self.annotate_expected_due_to_let_ty(err, expr, error);
34-
self.suggest_compatible_variants(err, expr, expected, expr_ty);
3534
self.suggest_deref_ref_or_into(err, expr, expected, expr_ty, expected_ty_expr);
35+
self.suggest_compatible_variants(err, expr, expected, expr_ty);
3636
if self.suggest_calling_boxed_future_when_appropriate(err, expr, expected, expr_ty) {
3737
return;
3838
}

src/test/ui/suggestions/boxed-variant-field.stderr

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ LL | Ty::List(elem) => foo(elem),
66
|
77
= note: expected enum `Ty`
88
found struct `Box<Ty>`
9-
help: try wrapping the expression in `Ty::List`
10-
|
11-
LL | Ty::List(elem) => foo(Ty::List(elem)),
12-
| +++++++++ +
139
help: consider unboxing the value
1410
|
1511
LL | Ty::List(elem) => foo(*elem),
1612
| +
13+
help: try wrapping the expression in `Ty::List`
14+
|
15+
LL | Ty::List(elem) => foo(Ty::List(elem)),
16+
| +++++++++ +
1717

1818
error: aborting due to previous error
1919

0 commit comments

Comments
 (0)