Skip to content

Commit

Permalink
Prefer identity equality over equating types during coercion.
Browse files Browse the repository at this point in the history
These types are always generic only over their own generic parameters with no inference variables involved.
  • Loading branch information
oli-obk committed Apr 16, 2024
1 parent 1dea922 commit 24d9add
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions compiler/rustc_hir_analysis/src/coherence/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -433,14 +433,12 @@ pub fn coerce_unsized_info<'tcx>(
// something more accepting, but we use
// equality because we want to be able to
// perform this check without computing
// variance where possible. (This is because
// we may have to evaluate constraint
// variance or constraining opaque types' hidden types.
// (This is because we may have to evaluate constraint
// expressions in the course of execution.)
// See e.g., #41936.
if let Ok(ok) = infcx.at(&cause, param_env).eq(DefineOpaqueTypes::No, a, b) {
if ok.obligations.is_empty() {
return None;
}
if a == b {
return None;
}

// Collect up all fields that were significantly changed
Expand Down

0 comments on commit 24d9add

Please sign in to comment.