From 59bbbe78e2ddf6f5c823372890b928fe19e41ac3 Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Fri, 13 May 2022 09:30:09 +0000 Subject: [PATCH] Avoid invoking the full `eq` infrastructure when all we want is to check a discriminant --- compiler/rustc_middle/src/traits/mod.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/compiler/rustc_middle/src/traits/mod.rs b/compiler/rustc_middle/src/traits/mod.rs index 8072dd16ae8..dcd457957a8 100644 --- a/compiler/rustc_middle/src/traits/mod.rs +++ b/compiler/rustc_middle/src/traits/mod.rs @@ -206,7 +206,9 @@ pub struct InternedObligationCauseCode<'tcx> { impl<'tcx> From> for InternedObligationCauseCode<'tcx> { #[inline(always)] fn from(code: ObligationCauseCode<'tcx>) -> Self { - Self { code: if code == MISC_OBLIGATION_CAUSE_CODE { None } else { Some(Lrc::new(code)) } } + Self { + code: if let MISC_OBLIGATION_CAUSE_CODE = code { None } else { Some(Lrc::new(code)) }, + } } }