Skip to content

Commit 97e00a7

Browse files
Avoid code duplication
1 parent ffc9e83 commit 97e00a7

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

compiler/rustc_middle/src/ty/generics.rs

+7-10
Original file line numberDiff line numberDiff line change
@@ -372,17 +372,14 @@ impl<'tcx> Generics {
372372
) -> bool {
373373
let mut default_param_seen = false;
374374
for param in self.params.iter() {
375-
if param
376-
.default_value(tcx)
377-
.is_some_and(|default| default.instantiate(tcx, args) == args[param.index as usize])
375+
if let Some(inst) =
376+
param.default_value(tcx).map(|default| default.instantiate(tcx, args))
378377
{
379-
default_param_seen = true;
380-
} else if default_param_seen
381-
&& param.default_value(tcx).is_some_and(|default| {
382-
default.instantiate(tcx, args) != args[param.index as usize]
383-
})
384-
{
385-
return true;
378+
if inst == args[param.index as usize] {
379+
default_param_seen = true;
380+
} else if default_param_seen {
381+
return true;
382+
}
386383
}
387384
}
388385
false

0 commit comments

Comments
 (0)