Reorder constraint introduction

This avoids an unnecessary clone if the conditional is false
This commit is contained in:
ayazhafiz 2021-12-23 14:30:47 -06:00
parent b4c9068676
commit 9a813b6c49

View file

@ -164,19 +164,19 @@ pub fn constrain_pattern(
}
Identifier(symbol) => {
if destruct_position {
state.constraints.push(Constraint::Present(
expected.get_type_ref().clone(),
PresenceConstraint::IsOpen,
));
}
state.headers.insert(
*symbol,
Loc {
region,
value: expected.get_type_ref().clone(),
value: expected.get_type(),
},
);
if destruct_position {
state.constraints.push(Constraint::Present(
expected.get_type(),
PresenceConstraint::IsOpen,
));
}
}
NumLiteral(var, _, _) => {