Skip to content

Commit

Permalink
use can_coerce instead of same_type_modulo_infer
Browse files Browse the repository at this point in the history
  • Loading branch information
TaKO8Ki committed Mar 28, 2022
1 parent 9e4d019 commit c26cfd1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
3 changes: 1 addition & 2 deletions compiler/rustc_typeck/src/check/pat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ use rustc_hir::def::{CtorKind, DefKind, Res};
use rustc_hir::pat_util::EnumerateAndAdjustIterator;
use rustc_hir::{HirId, Pat, PatKind};
use rustc_infer::infer;
use rustc_infer::infer::error_reporting::same_type_modulo_infer;
use rustc_infer::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
use rustc_middle::middle::stability::EvalResult;
use rustc_middle::ty::{self, Adt, BindingMode, Ty, TypeFoldable};
Expand Down Expand Up @@ -1518,7 +1517,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
} else if inexistent_fields.len() == 1 {
match pat_field.pat.kind {
PatKind::Lit(expr)
if !same_type_modulo_infer(
if !self.can_coerce(
self.typeck_results.borrow().expr_ty(expr),
self.field_ty(
unmentioned_fields[0].1.span,
Expand Down
5 changes: 4 additions & 1 deletion src/test/ui/issues/issue-51102.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ error[E0026]: struct `SimpleStruct` does not have a field named `state`
--> $DIR/issue-51102.rs:13:17
|
LL | state: 0,
| ^^^^^ struct `SimpleStruct` does not have this field
| ^^^^^
| |
| struct `SimpleStruct` does not have this field
| help: `SimpleStruct` has a field named `no_state_here`

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

0 comments on commit c26cfd1

Please sign in to comment.