Skip to content

Commit

Permalink
Omit warning only for first parameter named self, to scope impact
Browse files Browse the repository at this point in the history
  • Loading branch information
wrwg committed Aug 21, 2024
1 parent dedd6f2 commit 63fbb86
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 7 additions & 0 deletions third_party/move/move-compiler/src/hlir/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,13 @@ impl FunctionSignature {
.iter()
.any(|(parameter_name, _)| parameter_name == v)
}

pub fn is_first_parameter(&self, v: &Var) -> bool {
self.parameters
.first()
.map(|(parameter_name, _)| parameter_name == v)
.unwrap_or(false)
}
}

impl Command_ {
Expand Down
2 changes: 1 addition & 1 deletion third_party/move/move-compiler/src/hlir/translate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1972,7 +1972,7 @@ fn check_unused_locals(
DisplayVar::Tmp => panic!("ICE unused tmp"),
DisplayVar::Orig(vstr) => vstr,
};
if signature.is_parameter(&v) && vstr == "self" {
if signature.is_first_parameter(&v) && vstr == "self" {
// Special treatment for `self` Move 2 parameter: do not warn if unused
// for the case v1 compiles v2 code
continue;
Expand Down

0 comments on commit 63fbb86

Please sign in to comment.