Skip to content

Commit c26cfd1

Browse files
committed
use can_coerce instead of same_type_modulo_infer
1 parent 9e4d019 commit c26cfd1

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

compiler/rustc_typeck/src/check/pat.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ use rustc_hir::def::{CtorKind, DefKind, Res};
1010
use rustc_hir::pat_util::EnumerateAndAdjustIterator;
1111
use rustc_hir::{HirId, Pat, PatKind};
1212
use rustc_infer::infer;
13-
use rustc_infer::infer::error_reporting::same_type_modulo_infer;
1413
use rustc_infer::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
1514
use rustc_middle::middle::stability::EvalResult;
1615
use rustc_middle::ty::{self, Adt, BindingMode, Ty, TypeFoldable};
@@ -1518,7 +1517,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
15181517
} else if inexistent_fields.len() == 1 {
15191518
match pat_field.pat.kind {
15201519
PatKind::Lit(expr)
1521-
if !same_type_modulo_infer(
1520+
if !self.can_coerce(
15221521
self.typeck_results.borrow().expr_ty(expr),
15231522
self.field_ty(
15241523
unmentioned_fields[0].1.span,

src/test/ui/issues/issue-51102.stderr

+4-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@ error[E0026]: struct `SimpleStruct` does not have a field named `state`
22
--> $DIR/issue-51102.rs:13:17
33
|
44
LL | state: 0,
5-
| ^^^^^ struct `SimpleStruct` does not have this field
5+
| ^^^^^
6+
| |
7+
| struct `SimpleStruct` does not have this field
8+
| help: `SimpleStruct` has a field named `no_state_here`
69

710
error[E0025]: field `no_state_here` bound multiple times in the pattern
811
--> $DIR/issue-51102.rs:24:17

0 commit comments

Comments
 (0)