Skip to content

Commit f20a37d

Browse files
Avoid code duplication
1 parent ffc9e83 commit f20a37d

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

compiler/rustc_middle/src/ty/generics.rs

+6-11
Original file line numberDiff line numberDiff line change
@@ -372,17 +372,12 @@ 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])
378-
{
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;
375+
if let Some(inst) = param.default_value(tcx).map(|default| default.instantiate(tcx, args)) {
376+
if inst == args[param.index as usize] {
377+
default_param_seen = true;
378+
} else if default_param_seen {
379+
return true;
380+
}
386381
}
387382
}
388383
false

0 commit comments

Comments
 (0)