diff options
| author | Michael Goulet <michael@errs.io> | 2024-08-20 11:35:05 -0400 |
|---|---|---|
| committer | Michael Goulet <michael@errs.io> | 2024-08-31 16:07:41 -0400 |
| commit | c3f9c4f4d4bbc83c7de79a09c7ec0e7fda8efc5e (patch) | |
| tree | 4d2554d3650f5a89052155cd911547fb2e73a7e8 /compiler | |
| parent | d571ae851d93541bef826c3c48c1e9ad99da77d6 (diff) | |
| download | rust-c3f9c4f4d4bbc83c7de79a09c7ec0e7fda8efc5e.tar.gz rust-c3f9c4f4d4bbc83c7de79a09c7ec0e7fda8efc5e.zip | |
Use equality when relating formal and expected type in arg checking
Diffstat (limited to 'compiler')
| -rw-r--r-- | compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs index eebb0217990..16d65726128 100644 --- a/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs +++ b/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs @@ -292,21 +292,20 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let coerce_error = self.coerce(provided_arg, checked_ty, coerced_ty, AllowTwoPhase::Yes, None).err(); - if coerce_error.is_some() { return Compatibility::Incompatible(coerce_error); } - // 3. Check if the formal type is a supertype of the checked one - // and register any such obligations for future type checks - let supertype_error = self.at(&self.misc(provided_arg.span), self.param_env).sup( + // 3. Check if the formal type is actually equal to the checked one + // and register any such obligations for future type checks. + let formal_ty_error = self.at(&self.misc(provided_arg.span), self.param_env).eq( DefineOpaqueTypes::Yes, formal_input_ty, coerced_ty, ); // If neither check failed, the types are compatible - match supertype_error { + match formal_ty_error { Ok(InferOk { obligations, value: () }) => { self.register_predicates(obligations); Compatibility::Compatible |
