Skip to content

Commit

Permalink
Avoid code duplication
Browse files Browse the repository at this point in the history
  • Loading branch information
veera-sivarajan committed Feb 29, 2024
1 parent 4996194 commit 3ba50b3
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions compiler/rustc_middle/src/ty/generics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 3ba50b3

Please sign in to comment.