]> git.lizzy.rs Git - rust.git/commitdiff
use `can_coerce` instead of `same_type_modulo_infer`
authorTakayuki Maeda <takoyaki0316@gmail.com>
Mon, 28 Mar 2022 04:43:33 +0000 (13:43 +0900)
committerTakayuki Maeda <takoyaki0316@gmail.com>
Mon, 28 Mar 2022 04:43:33 +0000 (13:43 +0900)
compiler/rustc_typeck/src/check/pat.rs
src/test/ui/issues/issue-51102.stderr

index 67124f2d23836d72b9e3fd7522030f0b3d4f4390..d66230acb8bda7bf45d5a392b6d1d8c700b02526 100644 (file)
@@ -10,7 +10,6 @@
 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 @@ fn error_inexistent_fields(
                 } 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,
index eb9eb680200672da966418f7491ce6a5b9a64422..09c52292dccaff9ba05d44d83dd16faf69881588 100644 (file)
@@ -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