Skip to content

Commit 0cc35f5

Browse files
committed
Don't check self type twice
1 parent bc5f4c4 commit 0cc35f5

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

compiler/rustc_trait_selection/src/traits/coherence.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,6 @@ where
7070
// Before doing expensive operations like entering an inference context, do
7171
// a quick check via fast_reject to tell if the impl headers could possibly
7272
// unify.
73-
let impl1_self = tcx.type_of(impl1_def_id);
74-
let impl2_self = tcx.type_of(impl2_def_id);
7573
let impl1_ref = tcx.impl_trait_ref(impl1_def_id);
7674
let impl2_ref = tcx.impl_trait_ref(impl2_def_id);
7775

@@ -80,14 +78,13 @@ where
8078
.iter()
8179
.flat_map(|tref| tref.substs.types())
8280
.zip(impl2_ref.iter().flat_map(|tref| tref.substs.types()))
83-
.chain(iter::once((impl1_self, impl2_self)))
8481
.any(|(ty1, ty2)| {
8582
let t1 = fast_reject::simplify_type(tcx, ty1, false);
8683
let t2 = fast_reject::simplify_type(tcx, ty2, false);
8784
if let (Some(t1), Some(t2)) = (t1, t2) {
8885
// Simplified successfully
8986
// Types cannot unify if they differ in their reference mutability or simplify to different types
90-
t1 != t2 || ty1.ref_mutability() != ty2.ref_mutability()
87+
t1 != t2 || ty1.ref_mutability() != ty2.ref_mutability()
9188
} else {
9289
// Types might unify
9390
false

0 commit comments

Comments
 (0)