Skip to content

Commit f3c7a96

Browse files
stroxlerfacebook-github-bot
authored andcommitted
Tweak the style update logic in definitions.rs
Summary: When `style` stopped implementing `copy`, we introduced a `let style =` binding and added a clone, but this isn't necessary, we can just clone. This is important because the existing code is shadowing the function argument `style` with the let binding, which means that on a skim it looks like we're just overwriting the style, which would lead to completely different semantics. I got confused by this - when we skim code, we don't skim line-by-line so the shadowing really is confusing. If we just directly clone, then it's immediately obvious what the semantics actually are. Reviewed By: rchen152 Differential Revision: D82325999 fbshipit-source-id: 2bdab6362fa2df8c9a44655384bd9a69b53eead1
1 parent 0c2db36 commit f3c7a96

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

pyrefly/lib/export/definitions.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -260,8 +260,7 @@ impl<'a> DefinitionsBuilder<'a> {
260260
) {
261261
match self.inner.definitions.entry(x.clone()) {
262262
Entry::Occupied(mut e) => {
263-
let style = cmp::min(&e.get().style, &style);
264-
e.get_mut().style = style.clone();
263+
e.get_mut().style = cmp::min(&e.get().style, &style).clone();
265264
if e.get().annot.is_none() {
266265
e.get_mut().annot = annot;
267266
}

0 commit comments

Comments
 (0)