Skip to content

Commit

Permalink
Avoid an intermediate Option and just create the resulting enum directly
Browse files Browse the repository at this point in the history
  • Loading branch information
oli-obk committed Apr 12, 2024
1 parent 241fc13 commit 0c60779
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -301,18 +301,14 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
formal_input_ty,
coerced_ty,
);
let subtyping_error = match supertype_error {

// If neither check failed, the types are compatible
match supertype_error {
Ok(InferOk { obligations, value: () }) => {
self.register_predicates(obligations);
None
Compatibility::Compatible
}
Err(err) => Some(err),
};

// If neither check failed, the types are compatible
match subtyping_error {
None => Compatibility::Compatible,
Some(_) => Compatibility::Incompatible(subtyping_error),
Err(err) => Compatibility::Incompatible(Some(err)),
}
};

Expand Down

0 comments on commit 0c60779

Please sign in to comment.