From 97e00a7e28ba85202dac8fa12ee163f802058ee3 Mon Sep 17 00:00:00 2001 From: Veera Date: Thu, 22 Feb 2024 21:37:11 -0500 Subject: [PATCH] Avoid code duplication --- compiler/rustc_middle/src/ty/generics.rs | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/compiler/rustc_middle/src/ty/generics.rs b/compiler/rustc_middle/src/ty/generics.rs index 4f75b7b42fb23..2630b96869bae 100644 --- a/compiler/rustc_middle/src/ty/generics.rs +++ b/compiler/rustc_middle/src/ty/generics.rs @@ -372,17 +372,14 @@ impl<'tcx> Generics { ) -> bool { let mut default_param_seen = false; for param in self.params.iter() { - if param - .default_value(tcx) - .is_some_and(|default| default.instantiate(tcx, args) == args[param.index as usize]) + if let Some(inst) = + param.default_value(tcx).map(|default| default.instantiate(tcx, args)) { - default_param_seen = true; - } else if default_param_seen - && param.default_value(tcx).is_some_and(|default| { - default.instantiate(tcx, args) != args[param.index as usize] - }) - { - return true; + if inst == args[param.index as usize] { + default_param_seen = true; + } else if default_param_seen { + return true; + } } } false