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 23, 2024
1 parent ffc9e83 commit f20a37d
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions compiler/rustc_middle/src/ty/generics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -372,17 +372,12 @@ 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])
{
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 let Some(inst) = param.default_value(tcx).map(|default| default.instantiate(tcx, args)) {
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 f20a37d

Please sign in to comment.