cmd/fix: pull in CL 787020 Generated with updatestd, though it's equivalent to manually running: cd src/cmd go get golang.org/x/tools@internal-branch.go1.27-vendor # v0.45.1-0.20260604184323-2111063761b3 go mod tidy go mod vendor Fixes #77965. [git-generate] updatestd -goroot=$(pwd) -branch=internal-branch.go1.27-vendor Change-Id: I2800970c281d3a0b8ef7eb076cd8a71179df5d6f Reviewed-on: https://go-review.googlesource.com/c/go/+/788883 LUCI-TryBot-Result: golang-scoped@luci-project-accounts.iam.gserviceaccount.com <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Auto-Submit: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com>
diff --git a/src/cmd/go.mod b/src/cmd/go.mod index 82ceadb..326553a 100644 --- a/src/cmd/go.mod +++ b/src/cmd/go.mod
@@ -11,7 +11,7 @@ golang.org/x/sys v0.45.0 golang.org/x/telemetry v0.0.0-20260519152614-eab6ae52b5e2 golang.org/x/term v0.43.0 - golang.org/x/tools v0.45.1-0.20260526150332-c7a66a92adc3 + golang.org/x/tools v0.45.1-0.20260604184323-2111063761b3 ) require (
diff --git a/src/cmd/go.sum b/src/cmd/go.sum index d9e3e39..3b88ef7 100644 --- a/src/cmd/go.sum +++ b/src/cmd/go.sum
@@ -22,7 +22,7 @@ golang.org/x/term v0.43.0/go.mod h1:lrhlHNdQJHO+1qVYiHfFKVuVioJIheAc3fBSMFYEIsk= golang.org/x/text v0.37.0 h1:Cqjiwd9eSg8e0QAkyCaQTNHFIIzWtidPahFWR83rTrc= golang.org/x/text v0.37.0/go.mod h1:a5sjxXGs9hsn/AJVwuElvCAo9v8QYLzvavO5z2PiM38= -golang.org/x/tools v0.45.1-0.20260526150332-c7a66a92adc3 h1:o+mbfNMbZ8U/0e+0iqqjrGiSsrFCYvSwI30zQkf0fpA= -golang.org/x/tools v0.45.1-0.20260526150332-c7a66a92adc3/go.mod h1:LuUGqqaXcXMEFEruIVJVm5mgDD8vww/z/SR1gQ4uE/0= +golang.org/x/tools v0.45.1-0.20260604184323-2111063761b3 h1:67WIfVS+BxW2WEfdADNUnCzQ/wcK7oSOaevonJ70wTw= +golang.org/x/tools v0.45.1-0.20260604184323-2111063761b3/go.mod h1:LuUGqqaXcXMEFEruIVJVm5mgDD8vww/z/SR1gQ4uE/0= rsc.io/markdown v0.0.0-20240306144322-0bf8f97ee8ef h1:mqLYrXCXYEZOop9/Dbo6RPX11539nwiCNBb1icVPmw8= rsc.io/markdown v0.0.0-20240306144322-0bf8f97ee8ef/go.mod h1:8xcPgWmwlZONN1D9bjxtHEjrUtSEa3fakVF8iaewYKQ=
diff --git a/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/modernize/embedlit.go b/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/modernize/embedlit.go index 7d0b7e3..da883d6 100644 --- a/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/modernize/embedlit.go +++ b/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/modernize/embedlit.go
@@ -80,7 +80,7 @@ // be promoted, and calculates the corresponding edits. var checkLit func(lit *ast.CompositeLit) checkLit = func(lit *ast.CompositeLit) { - for _, elt := range lit.Elts { + for i, elt := range lit.Elts { // Can't promote an unkeyed field; would result in a syntax error. if kv, ok := elt.(*ast.KeyValueExpr); ok { if innerLit := isEmbeddedFieldLit(info, compLitType, kv); innerLit != nil { @@ -102,13 +102,57 @@ !moreiters.Empty(astutil.Comments(file, closingPos, innerLit.Rbrace+1)) { continue } + // Delete starting from the key to the character right after the + // opening brace of the inner literal: + // T{U: U{f: v, ...}} + // ----- + startPos := kv.Pos() + endPos := innerLit.Lbrace + 1 + + // Delete the entire line if the key and its opening brace are + // together on their own line. This prevents leaving behind unneeded + // blank lines inside struct literals that `gofmt` will not remove. + // T{ + // U: U{ <- delete entire line + // f: v, + // } + // } + // + tokFile := pass.Fset.File(kv.Pos()) + lineOf := func(pos token.Pos) int { + return tokFile.PositionFor(pos, false).Line + } + curLine := lineOf(kv.Pos()) + var prevLine int + if i == 0 { + // First element, so the previous line is the parent lbrace. + prevLine = lineOf(lit.Lbrace) + } else { + prevLine = lineOf(lit.Elts[i-1].End()) + } + + // We can safely delete the entire line if the key value expression is + // on a different line than the previous element, and the closing + // brace of the inner literal is on a different line than its opening + // brace. + if prevLine < curLine && curLine < tokFile.LineCount() && // (1-based) + lineOf(innerLit.Lbrace) < lineOf(innerLit.Rbrace) { + lineStart := tokFile.LineStart(curLine) + nextLineStart := tokFile.LineStart(curLine + 1) + // Check that there are no comments on the line we are going to delete. + if moreiters.Empty(astutil.Comments(file, lineStart, nextLineStart)) { + startPos = tokFile.LineStart(curLine) + endPos = nextLineStart + } + } + edits = append(edits, []analysis.TextEdit{ // T{U: U{f: v, ...}} // ----- - { // Delete the key and the opening brace of the inner struct literal. - Pos: kv.Pos(), - End: innerLit.Lbrace + 1, + Pos: startPos, + End: endPos, }, { // Delete the corresponding closing brace, including preceding
diff --git a/src/cmd/vendor/modules.txt b/src/cmd/vendor/modules.txt index 4774f1a..7df86f0 100644 --- a/src/cmd/vendor/modules.txt +++ b/src/cmd/vendor/modules.txt
@@ -73,7 +73,7 @@ golang.org/x/text/language golang.org/x/text/transform golang.org/x/text/unicode/norm -# golang.org/x/tools v0.45.1-0.20260526150332-c7a66a92adc3 +# golang.org/x/tools v0.45.1-0.20260604184323-2111063761b3 ## explicit; go 1.25.0 golang.org/x/tools/cmd/bisect golang.org/x/tools/cover