Skip to content

Commit 8a2e5a2

Browse files
Squashed 'golang.org/x/tools/' changes from ead62e94e..776604a9e
776604a9e gopls/internal/analysis/modernize: sortslice: fix crash df7baa073 gopls/internal/analysis/simplifyrange: more precise fix ad5dd9875 gopls: fix a few bugs related to the new modcache imports source 4b3fdfd83 go/analysis/passes/printf: suppress diagnostic for Println("...%XX...") fe883a85d gopls/internal/analysis/unusedvariable: refine bug.Report golang/go#71812 d115b345e gopls/internal/analysis: simplify type-error analyzers with Cursor c18bffa1b all: delete redundant //go:debug gotypesalias=1 directives [generated] 94db71079 all: upgrade go directive to at least 1.23.0 [generated] git-subtree-dir: golang.org/x/tools git-subtree-split: 776604a9ed881ee1274724fb3a5f058f3ebdf0eb
1 parent 59f29fd commit 8a2e5a2

File tree

95 files changed

+324
-680
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

95 files changed

+324
-680
lines changed

cmd/bundle/gotypesalias.go

Lines changed: 0 additions & 12 deletions
This file was deleted.

cmd/callgraph/gotypesalias.go

Lines changed: 0 additions & 12 deletions
This file was deleted.

cmd/callgraph/main_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
// No testdata on Android.
66

77
//go:build !android && go1.11
8-
// +build !android,go1.11
98

109
package main
1110

cmd/deadcode/gotypesalias.go

Lines changed: 0 additions & 12 deletions
This file was deleted.

cmd/eg/gotypesalias.go

Lines changed: 0 additions & 12 deletions
This file was deleted.

cmd/fiximports/main_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
// No testdata on Android.
66

77
//go:build !android
8-
// +build !android
98

109
package main
1110

cmd/godex/gotypesalias.go

Lines changed: 0 additions & 12 deletions
This file was deleted.

cmd/godex/isAlias18.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
// license that can be found in the LICENSE file.
44

55
//go:build !go1.9
6-
// +build !go1.9
76

87
package main
98

cmd/godex/isAlias19.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
// license that can be found in the LICENSE file.
44

55
//go:build go1.9
6-
// +build go1.9
76

87
package main
98

cmd/godoc/gotypesalias.go

Lines changed: 0 additions & 12 deletions
This file was deleted.

cmd/goimports/goimports_gc.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
// license that can be found in the LICENSE file.
44

55
//go:build gc
6-
// +build gc
76

87
package main
98

cmd/goimports/goimports_not_gc.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
// license that can be found in the LICENSE file.
44

55
//go:build !gc
6-
// +build !gc
76

87
package main
98

cmd/goimports/gotypesalias.go

Lines changed: 0 additions & 12 deletions
This file was deleted.

cmd/gomvpkg/gotypesalias.go

Lines changed: 0 additions & 12 deletions
This file was deleted.

cmd/gotype/gotypesalias.go

Lines changed: 0 additions & 12 deletions
This file was deleted.

cmd/gotype/sizesFor18.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
// license that can be found in the LICENSE file.
44

55
//go:build !go1.9
6-
// +build !go1.9
76

87
// This file contains a copy of the implementation of types.SizesFor
98
// since this function is not available in go/types before Go 1.9.

cmd/gotype/sizesFor19.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
// license that can be found in the LICENSE file.
44

55
//go:build go1.9
6-
// +build go1.9
76

87
package main
98

cmd/splitdwarf/splitdwarf.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
// license that can be found in the LICENSE file.
44

55
//go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd
6-
// +build aix darwin dragonfly freebsd linux netbsd openbsd
76

87
/*
98
Splitdwarf uncompresses and copies the DWARF segment of a Mach-O

cmd/ssadump/gotypesalias.go

Lines changed: 0 additions & 12 deletions
This file was deleted.

cmd/stress/stress.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
// license that can be found in the LICENSE file.
44

55
//go:build unix || aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris || windows
6-
// +build unix aix darwin dragonfly freebsd linux netbsd openbsd solaris windows
76

87
// The stress utility is intended for catching sporadic failures.
98
// It runs a given process in parallel in a loop and collects any failures.

cmd/stringer/gotypesalias.go

Lines changed: 0 additions & 12 deletions
This file was deleted.

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module golang.org/x/tools
22

3-
go 1.22.0 // => default GODEBUG has gotypesalias=0
3+
go 1.23.0
44

55
require (
66
github.com/google/go-cmp v0.6.0

go/analysis/multichecker/multichecker_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
// license that can be found in the LICENSE file.
44

55
//go:build go1.12
6-
// +build go1.12
76

87
package multichecker_test
98

go/analysis/passes/defers/cmd/defers/gotypesalias.go

Lines changed: 0 additions & 12 deletions
This file was deleted.

go/analysis/passes/errorsas/errorsas_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
// license that can be found in the LICENSE file.
44

55
//go:build go1.13
6-
// +build go1.13
76

87
package errorsas_test
98

go/analysis/passes/fieldalignment/cmd/fieldalignment/gotypesalias.go

Lines changed: 0 additions & 12 deletions
This file was deleted.

go/analysis/passes/findcall/cmd/findcall/gotypesalias.go

Lines changed: 0 additions & 12 deletions
This file was deleted.

go/analysis/passes/httpmux/cmd/httpmux/gotypesalias.go

Lines changed: 0 additions & 12 deletions
This file was deleted.

go/analysis/passes/ifaceassert/cmd/ifaceassert/gotypesalias.go

Lines changed: 0 additions & 12 deletions
This file was deleted.

go/analysis/passes/lostcancel/cmd/lostcancel/gotypesalias.go

Lines changed: 0 additions & 12 deletions
This file was deleted.

go/analysis/passes/nilness/cmd/nilness/gotypesalias.go

Lines changed: 0 additions & 12 deletions
This file was deleted.

go/analysis/passes/printf/printf.go

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -924,9 +924,14 @@ func checkPrint(pass *analysis.Pass, call *ast.CallExpr, name string) {
924924
// The % in "abc 0.0%" couldn't be a formatting directive.
925925
s = strings.TrimSuffix(s, "%")
926926
if strings.Contains(s, "%") {
927-
m := printFormatRE.FindStringSubmatch(s)
928-
if m != nil {
929-
pass.ReportRangef(call, "%s call has possible Printf formatting directive %s", name, m[0])
927+
for _, m := range printFormatRE.FindAllString(s, -1) {
928+
// Allow %XX where XX are hex digits,
929+
// as this is common in URLs.
930+
if len(m) >= 3 && isHex(m[1]) && isHex(m[2]) {
931+
continue
932+
}
933+
pass.ReportRangef(call, "%s call has possible Printf formatting directive %s", name, m)
934+
break // report only the first one
930935
}
931936
}
932937
}
@@ -992,3 +997,10 @@ func (ss stringSet) Set(flag string) error {
992997
//
993998
// Remove this after the 1.24 release.
994999
var suppressNonconstants bool
1000+
1001+
// isHex reports whether b is a hex digit.
1002+
func isHex(b byte) bool {
1003+
return '0' <= b && b <= '9' ||
1004+
'A' <= b && b <= 'F' ||
1005+
'a' <= b && b <= 'f'
1006+
}

go/analysis/passes/printf/testdata/src/a/a.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,8 @@ func PrintfTests() {
154154
fmt.Println("%v", "hi") // want "fmt.Println call has possible Printf formatting directive %v"
155155
fmt.Println("%T", "hi") // want "fmt.Println call has possible Printf formatting directive %T"
156156
fmt.Println("%s"+" there", "hi") // want "fmt.Println call has possible Printf formatting directive %s"
157+
fmt.Println("http://foo.com?q%2Fabc") // no diagnostic: %XX is excepted
158+
fmt.Println("http://foo.com?q%2Fabc-%s") // want"fmt.Println call has possible Printf formatting directive %s"
157159
fmt.Println("0.0%") // correct (trailing % couldn't be a formatting directive)
158160
fmt.Printf("%s", "hi", 3) // want "fmt.Printf call needs 1 arg but has 2 args"
159161
_ = fmt.Sprintf("%"+("s"), "hi", 3) // want "fmt.Sprintf call needs 1 arg but has 2 args"

go/analysis/passes/shadow/cmd/shadow/gotypesalias.go

Lines changed: 0 additions & 12 deletions
This file was deleted.

go/analysis/passes/stdversion/main.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
// license that can be found in the LICENSE file.
44

55
//go:build ignore
6-
// +build ignore
76

87
package main
98

0 commit comments

Comments
 (0)