]> Cypherpunks repositories - gostls13.git/commitdiff
cmd: update x/tools@4df13e3
authorAlan Donovan <adonovan@google.com>
Thu, 25 Sep 2025 14:30:14 +0000 (10:30 -0400)
committerGopher Robot <gobot@golang.org>
Thu, 25 Sep 2025 15:01:03 +0000 (08:01 -0700)
This includes only a couple of minor cmd/vet fixes for new(expr).

    export GOWORK=off
    cd src/cmd
    go get golang.org/x/tools@4df13e3
    go mod tidy
    go mod vendor

For #45624

Change-Id: Iafba4350d321d6cd1fcc91a062e2c150e3f4d553
Reviewed-on: https://go-review.googlesource.com/c/go/+/706735
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Auto-Submit: Alan Donovan <adonovan@google.com>

src/cmd/go.mod
src/cmd/go.sum
src/cmd/vendor/golang.org/x/tools/go/analysis/passes/copylock/copylock.go
src/cmd/vendor/golang.org/x/tools/internal/analysisinternal/analysis.go
src/cmd/vendor/modules.txt

index c72a250aeabf276633476e444205b1dbb58a5d5a..017883a7870cd236caacc50a822a2d16ff64c720 100644 (file)
@@ -11,7 +11,7 @@ require (
        golang.org/x/sys v0.36.0
        golang.org/x/telemetry v0.0.0-20250908211612-aef8a434d053
        golang.org/x/term v0.34.0
-       golang.org/x/tools v0.37.1-0.20250915202913-9fccddc465ef
+       golang.org/x/tools v0.37.1-0.20250924232827-4df13e317ce4
 )
 
 require (
index a4801f1843054fefeb327b1423a79facc2a704b4..0906ffcc605854a620f3e5e9b247091d9b6e6031 100644 (file)
@@ -22,7 +22,7 @@ golang.org/x/term v0.34.0 h1:O/2T7POpk0ZZ7MAzMeWFSg6S5IpWd/RXDlM9hgM3DR4=
 golang.org/x/term v0.34.0/go.mod h1:5jC53AEywhIVebHgPVeg0mj8OD3VO9OzclacVrqpaAw=
 golang.org/x/text v0.29.0 h1:1neNs90w9YzJ9BocxfsQNHKuAT4pkghyXc4nhZ6sJvk=
 golang.org/x/text v0.29.0/go.mod h1:7MhJOA9CD2qZyOKYazxdYMF85OwPdEr9jTtBpO7ydH4=
-golang.org/x/tools v0.37.1-0.20250915202913-9fccddc465ef h1:ISPkUgvOYIt0oS7oVnwAPktCKBvgWkDlWWGMgX0veZM=
-golang.org/x/tools v0.37.1-0.20250915202913-9fccddc465ef/go.mod h1:MBN5QPQtLMHVdvsbtarmTNukZDdgwdwlO5qGacAzF0w=
+golang.org/x/tools v0.37.1-0.20250924232827-4df13e317ce4 h1:IcXDtHggZZo+GzNzvVRPyNFLnOc2/Z1gg3ZVIWF2uCU=
+golang.org/x/tools v0.37.1-0.20250924232827-4df13e317ce4/go.mod h1:MBN5QPQtLMHVdvsbtarmTNukZDdgwdwlO5qGacAzF0w=
 rsc.io/markdown v0.0.0-20240306144322-0bf8f97ee8ef h1:mqLYrXCXYEZOop9/Dbo6RPX11539nwiCNBb1icVPmw8=
 rsc.io/markdown v0.0.0-20240306144322-0bf8f97ee8ef/go.mod h1:8xcPgWmwlZONN1D9bjxtHEjrUtSEa3fakVF8iaewYKQ=
index a4e455d9b30bf5c8f32bf9e8ebee11fa0bac508c..d35b85f03a721b1b42fa84bebc04e6f70e15378b 100644 (file)
@@ -157,7 +157,10 @@ func checkCopyLocksCallExpr(pass *analysis.Pass, ce *ast.CallExpr) {
        }
        if fun, ok := pass.TypesInfo.Uses[id].(*types.Builtin); ok {
                switch fun.Name() {
-               case "new", "len", "cap", "Sizeof", "Offsetof", "Alignof":
+               case "len", "cap", "Sizeof", "Offsetof", "Alignof":
+                       // The argument of this operation is used only
+                       // for its type (e.g. len(array)), or the operation
+                       // does not copy a lock (e.g. len(slice)).
                        return
                }
        }
index bc7f9984e90396c1ddf1f703b5910d485e805468..cea89d34dac45bae4f404600156997d83e6d0ee1 100644 (file)
@@ -193,18 +193,23 @@ func CheckReadable(pass *analysis.Pass, filename string) error {
        return fmt.Errorf("Pass.ReadFile: %s is not among OtherFiles, IgnoredFiles, or names of Files", filename)
 }
 
-// AddImport checks whether this file already imports pkgpath and
-// that import is in scope at pos. If so, it returns the name under
-// which it was imported and a zero edit. Otherwise, it adds a new
-// import of pkgpath, using a name derived from the preferred name,
-// and returns the chosen name, a prefix to be concatenated with member
-// to form a qualified name, and the edit for the new import.
+// AddImport checks whether this file already imports pkgpath and that
+// the import is in scope at pos. If so, it returns the name under
+// which it was imported and no edits. Otherwise, it adds a new import
+// of pkgpath, using a name derived from the preferred name, and
+// returns the chosen name, a prefix to be concatenated with member to
+// form a qualified name, and the edit for the new import.
 //
-// In the special case that pkgpath is dot-imported then member, the
-// identifier for which the import is being added, is consulted. If
-// member is not shadowed at pos, AddImport returns (".", "", nil).
-// (AddImport accepts the caller's implicit claim that the imported
-// package declares member.)
+// The member argument indicates the name of the desired symbol within
+// the imported package. This is needed in the case when the existing
+// import is a dot import, because then it is possible that the
+// desired symbol is shadowed by other declarations in the current
+// package. If member is not shadowed at pos, AddImport returns (".",
+// "", nil). (AddImport accepts the caller's implicit claim that the
+// imported package declares member.)
+//
+// Use a preferredName of "_" to request a blank import;
+// member is ignored in this case.
 //
 // It does not mutate its arguments.
 func AddImport(info *types.Info, file *ast.File, preferredName, pkgpath, member string, pos token.Pos) (name, prefix string, newImport []analysis.TextEdit) {
@@ -220,6 +225,10 @@ func AddImport(info *types.Info, file *ast.File, preferredName, pkgpath, member
                pkgname := info.PkgNameOf(spec)
                if pkgname != nil && pkgname.Imported().Path() == pkgpath {
                        name = pkgname.Name()
+                       if preferredName == "_" {
+                               // Request for blank import; any existing import will do.
+                               return name, "", nil
+                       }
                        if name == "." {
                                // The scope of ident must be the file scope.
                                if s, _ := scope.LookupParent(member, pos); s == info.Scopes[file] {
@@ -232,8 +241,12 @@ func AddImport(info *types.Info, file *ast.File, preferredName, pkgpath, member
        }
 
        // We must add a new import.
+
        // Ensure we have a fresh name.
-       newName := FreshName(scope, pos, preferredName)
+       newName := preferredName
+       if preferredName != "_" {
+               newName = FreshName(scope, pos, preferredName)
+       }
 
        // Create a new import declaration either before the first existing
        // declaration (which must exist), including its comments; or
@@ -246,6 +259,7 @@ func AddImport(info *types.Info, file *ast.File, preferredName, pkgpath, member
        if newName != preferredName || newName != pathpkg.Base(pkgpath) {
                newText = fmt.Sprintf("%s %q", newName, pkgpath)
        }
+
        decl0 := file.Decls[0]
        var before ast.Node = decl0
        switch decl0 := decl0.(type) {
index f166b77ea201272731a63de0cb04ce74e982f708..133271355f2cafc4257075ea8eed6d8cada4f0ad 100644 (file)
@@ -73,7 +73,7 @@ golang.org/x/text/internal/tag
 golang.org/x/text/language
 golang.org/x/text/transform
 golang.org/x/text/unicode/norm
-# golang.org/x/tools v0.37.1-0.20250915202913-9fccddc465ef
+# golang.org/x/tools v0.37.1-0.20250924232827-4df13e317ce4
 ## explicit; go 1.24.0
 golang.org/x/tools/cmd/bisect
 golang.org/x/tools/cover