about summary refs log tree commit diff
diff options
context:
space:
mode:
authorTakayuki Maeda <takoyaki0316@gmail.com>2022-03-28 13:43:33 +0900
committerTakayuki Maeda <takoyaki0316@gmail.com>2022-03-28 13:43:33 +0900
commitc26cfd1c5347091eb72c545b71c682f972cec1f1 (patch)
tree8a7eb84e74d3a2247e2dcb1934ba5991b844d4d6
parent9e4d019fee6f8f0b452c99f883c501c341d36dba (diff)
downloadrust-c26cfd1c5347091eb72c545b71c682f972cec1f1.tar.gz
rust-c26cfd1c5347091eb72c545b71c682f972cec1f1.zip
use `can_coerce` instead of `same_type_modulo_infer`
-rw-r--r--compiler/rustc_typeck/src/check/pat.rs3
-rw-r--r--src/test/ui/issues/issue-51102.stderr5
2 files changed, 5 insertions, 3 deletions
diff --git a/compiler/rustc_typeck/src/check/pat.rs b/compiler/rustc_typeck/src/check/pat.rs
index 67124f2d238..d66230acb8b 100644
--- a/compiler/rustc_typeck/src/check/pat.rs
+++ b/compiler/rustc_typeck/src/check/pat.rs
@@ -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};
@@ -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,
diff --git a/src/test/ui/issues/issue-51102.stderr b/src/test/ui/issues/issue-51102.stderr
index eb9eb680200..09c52292dcc 100644
--- a/src/test/ui/issues/issue-51102.stderr
+++ b/src/test/ui/issues/issue-51102.stderr
@@ -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