[tools] go/analysis/passes/modernize: require go1.21 to remove user-defined min/max

0 views
Skip to first unread message

Gopher Robot (Gerrit)

unread,
3:41 PM (4 hours ago) 3:41 PM
to Madeline Kalil, goph...@pubsubhelper.golang.org, golang-...@googlegroups.com, Go LUCI, Alan Donovan, golang-co...@googlegroups.com

Gopher Robot submitted the change with unreviewed changes

Unreviewed changes

1 is the latest approved patch-set.
The change was submitted with unreviewed changes in the following files:

```
The name of the file: go/analysis/passes/modernize/minmax.go
Insertions: 2, Deletions: 1.

@@ -308,7 +308,8 @@
decl := def.Parent().Node().(*ast.FuncDecl)
// Check if this function matches the built-in min/max signature
// and behavior, and verify that we have go1.21.
- if canUseBuiltinMinMax(fn, decl.Body) && analyzerutil.FileUsesGoVersion(pass, astutil.EnclosingFile(def), versions.Go1_21) {
+ if canUseBuiltinMinMax(fn, decl.Body) &&
+ analyzerutil.FileUsesGoVersion(pass, astutil.EnclosingFile(def), versions.Go1_21) {
// Expand to include leading doc comment
pos := decl.Pos()
if docs := astutil.DocComment(decl); docs != nil {
```

Change information

Commit message:
go/analysis/passes/modernize: require go1.21 to remove user-defined min/max

Adds check for go1.21 before removing user-defined min/max functions that are equivalent to the built-in functions.

Switch to checking FileUsesGoVersion later, just before pass.Report, since it is expensive and the number of files with 1.21 is high.

Fixes golang/go#78250
Change-Id: I57eb546f1218065f869c6dd5a6fabfa9062f3ced
Reviewed-by: Alan Donovan <adon...@google.com>
Auto-Submit: Madeline Kalil <mka...@google.com>
Files:
  • M go/analysis/passes/modernize/minmax.go
  • M go/analysis/passes/modernize/modernize_test.go
  • A go/analysis/passes/modernize/testdata/src/minmax/go120/minmax.go
  • A go/analysis/passes/modernize/testdata/src/minmax/go120/minmax_go120.go
  • A go/analysis/passes/modernize/testdata/src/minmax/go120/minmax_go120.go.golden
Change size: M
Delta: 5 files changed, 58 insertions(+), 27 deletions(-)
Branch: refs/heads/master
Submit Requirements:
  • requirement satisfiedCode-Review: +2 by Alan Donovan
  • requirement satisfiedTryBots-Pass: LUCI-TryBot-Result+1 by Go LUCI
Open in Gerrit
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: merged
Gerrit-Project: tools
Gerrit-Branch: master
Gerrit-Change-Id: I57eb546f1218065f869c6dd5a6fabfa9062f3ced
Gerrit-Change-Number: 757500
Gerrit-PatchSet: 3
Gerrit-Owner: Madeline Kalil <mka...@google.com>
Gerrit-Reviewer: Alan Donovan <adon...@google.com>
Gerrit-Reviewer: Gopher Robot <go...@golang.org>
Gerrit-Reviewer: Madeline Kalil <mka...@google.com>
open
diffy
satisfied_requirement
Reply all
Reply to author
Forward
0 new messages