mirror of
https://github.com/golang/go
synced 2024-09-29 00:24:30 -06:00
cmd: go get golang.org/x/tools/analysis@49064d23 && go mod vendor
This brings in CLs 312829, 317431, 319211. Fixes #40356. Fixes #46129. Change-Id: I2ee1f858b2a41ffa60d88b0c17511ccad57f1816 Reviewed-on: https://go-review.googlesource.com/c/go/+/321389 Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org> Trust: Tim King <taking@google.com> Run-TryBot: Tim King <taking@google.com> TryBot-Result: Go Bot <gobot@golang.org>
This commit is contained in:
parent
7c692cc7ea
commit
baa934d26d
@ -10,6 +10,6 @@ require (
|
|||||||
golang.org/x/mod v0.4.3-0.20210512182355-6088ed88cecd
|
golang.org/x/mod v0.4.3-0.20210512182355-6088ed88cecd
|
||||||
golang.org/x/sys v0.0.0-20210511113859-b0526f3d8744 // indirect
|
golang.org/x/sys v0.0.0-20210511113859-b0526f3d8744 // indirect
|
||||||
golang.org/x/term v0.0.0-20210503060354-a79de5458b56
|
golang.org/x/term v0.0.0-20210503060354-a79de5458b56
|
||||||
golang.org/x/tools v0.1.1-0.20210505014545-7cab0ef2e9a5
|
golang.org/x/tools v0.1.2-0.20210519160823-49064d2332f9
|
||||||
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
|
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
|
||||||
)
|
)
|
||||||
|
@ -16,7 +16,7 @@ golang.org/x/sys v0.0.0-20210511113859-b0526f3d8744 h1:yhBbb4IRs2HS9PPlAg6DMC6mU
|
|||||||
golang.org/x/sys v0.0.0-20210511113859-b0526f3d8744/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20210511113859-b0526f3d8744/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/term v0.0.0-20210503060354-a79de5458b56 h1:b8jxX3zqjpqb2LklXPzKSGJhzyxCOZSz8ncv8Nv+y7w=
|
golang.org/x/term v0.0.0-20210503060354-a79de5458b56 h1:b8jxX3zqjpqb2LklXPzKSGJhzyxCOZSz8ncv8Nv+y7w=
|
||||||
golang.org/x/term v0.0.0-20210503060354-a79de5458b56/go.mod h1:tfny5GFUkzUvx4ps4ajbZsCe5lw1metzhBm9T3x7oIY=
|
golang.org/x/term v0.0.0-20210503060354-a79de5458b56/go.mod h1:tfny5GFUkzUvx4ps4ajbZsCe5lw1metzhBm9T3x7oIY=
|
||||||
golang.org/x/tools v0.1.1-0.20210505014545-7cab0ef2e9a5 h1:ImcI7RFHWLu2QWpFDXaReu0j+sQAHIy65vUFZImXiqY=
|
golang.org/x/tools v0.1.2-0.20210519160823-49064d2332f9 h1:2XlR/j4I4xz5GQZI7zBjqTfezYyRIE2jD5IMousB2rg=
|
||||||
golang.org/x/tools v0.1.1-0.20210505014545-7cab0ef2e9a5/go.mod h1:sH/Eidr0EddymY8HZSakBo32zU3fG5ovDq874hJLjVg=
|
golang.org/x/tools v0.1.2-0.20210519160823-49064d2332f9/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
|
||||||
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
|
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
|
||||||
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
|
2
src/cmd/vendor/golang.org/x/tools/go/analysis/passes/printf/printf.go
generated
vendored
2
src/cmd/vendor/golang.org/x/tools/go/analysis/passes/printf/printf.go
generated
vendored
@ -590,7 +590,7 @@ func checkPrintf(pass *analysis.Pass, kind Kind, call *ast.CallExpr, fn *types.F
|
|||||||
}
|
}
|
||||||
if state.verb == 'w' {
|
if state.verb == 'w' {
|
||||||
if kind != KindErrorf {
|
if kind != KindErrorf {
|
||||||
pass.Reportf(call.Pos(), "%s call has error-wrapping directive %%w", state.name)
|
pass.Reportf(call.Pos(), "%s call has error-wrapping directive %%w, which is only supported by Errorf", state.name)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if anyW {
|
if anyW {
|
||||||
|
11
src/cmd/vendor/golang.org/x/tools/go/analysis/passes/sigchanyzer/sigchanyzer.go
generated
vendored
11
src/cmd/vendor/golang.org/x/tools/go/analysis/passes/sigchanyzer/sigchanyzer.go
generated
vendored
@ -59,12 +59,19 @@ func run(pass *analysis.Pass) (interface{}, error) {
|
|||||||
if chanDecl == nil || len(chanDecl.Args) != 1 {
|
if chanDecl == nil || len(chanDecl.Args) != 1 {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
chanDecl.Args = append(chanDecl.Args, &ast.BasicLit{
|
|
||||||
|
// Make a copy of the channel's declaration to avoid
|
||||||
|
// mutating the AST. See https://golang.org/issue/46129.
|
||||||
|
chanDeclCopy := &ast.CallExpr{}
|
||||||
|
*chanDeclCopy = *chanDecl
|
||||||
|
chanDeclCopy.Args = append([]ast.Expr(nil), chanDecl.Args...)
|
||||||
|
chanDeclCopy.Args = append(chanDeclCopy.Args, &ast.BasicLit{
|
||||||
Kind: token.INT,
|
Kind: token.INT,
|
||||||
Value: "1",
|
Value: "1",
|
||||||
})
|
})
|
||||||
|
|
||||||
var buf bytes.Buffer
|
var buf bytes.Buffer
|
||||||
if err := format.Node(&buf, token.NewFileSet(), chanDecl); err != nil {
|
if err := format.Node(&buf, token.NewFileSet(), chanDeclCopy); err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
pass.Report(analysis.Diagnostic{
|
pass.Report(analysis.Diagnostic{
|
||||||
|
17
src/cmd/vendor/golang.org/x/tools/go/analysis/passes/stdmethods/stdmethods.go
generated
vendored
17
src/cmd/vendor/golang.org/x/tools/go/analysis/passes/stdmethods/stdmethods.go
generated
vendored
@ -61,10 +61,12 @@ var Analyzer = &analysis.Analyzer{
|
|||||||
// we let it go. But if it does have a fmt.ScanState, then the
|
// we let it go. But if it does have a fmt.ScanState, then the
|
||||||
// rest has to match.
|
// rest has to match.
|
||||||
var canonicalMethods = map[string]struct{ args, results []string }{
|
var canonicalMethods = map[string]struct{ args, results []string }{
|
||||||
|
"As": {[]string{"interface{}"}, []string{"bool"}}, // errors.As
|
||||||
// "Flush": {{}, {"error"}}, // http.Flusher and jpeg.writer conflict
|
// "Flush": {{}, {"error"}}, // http.Flusher and jpeg.writer conflict
|
||||||
"Format": {[]string{"=fmt.State", "rune"}, []string{}}, // fmt.Formatter
|
"Format": {[]string{"=fmt.State", "rune"}, []string{}}, // fmt.Formatter
|
||||||
"GobDecode": {[]string{"[]byte"}, []string{"error"}}, // gob.GobDecoder
|
"GobDecode": {[]string{"[]byte"}, []string{"error"}}, // gob.GobDecoder
|
||||||
"GobEncode": {[]string{}, []string{"[]byte", "error"}}, // gob.GobEncoder
|
"GobEncode": {[]string{}, []string{"[]byte", "error"}}, // gob.GobEncoder
|
||||||
|
"Is": {[]string{"error"}, []string{"bool"}}, // errors.Is
|
||||||
"MarshalJSON": {[]string{}, []string{"[]byte", "error"}}, // json.Marshaler
|
"MarshalJSON": {[]string{}, []string{"[]byte", "error"}}, // json.Marshaler
|
||||||
"MarshalXML": {[]string{"*xml.Encoder", "xml.StartElement"}, []string{"error"}}, // xml.Marshaler
|
"MarshalXML": {[]string{"*xml.Encoder", "xml.StartElement"}, []string{"error"}}, // xml.Marshaler
|
||||||
"ReadByte": {[]string{}, []string{"byte", "error"}}, // io.ByteReader
|
"ReadByte": {[]string{}, []string{"byte", "error"}}, // io.ByteReader
|
||||||
@ -76,6 +78,7 @@ var canonicalMethods = map[string]struct{ args, results []string }{
|
|||||||
"UnmarshalXML": {[]string{"*xml.Decoder", "xml.StartElement"}, []string{"error"}}, // xml.Unmarshaler
|
"UnmarshalXML": {[]string{"*xml.Decoder", "xml.StartElement"}, []string{"error"}}, // xml.Unmarshaler
|
||||||
"UnreadByte": {[]string{}, []string{"error"}},
|
"UnreadByte": {[]string{}, []string{"error"}},
|
||||||
"UnreadRune": {[]string{}, []string{"error"}},
|
"UnreadRune": {[]string{}, []string{"error"}},
|
||||||
|
"Unwrap": {[]string{}, []string{"error"}}, // errors.Unwrap
|
||||||
"WriteByte": {[]string{"byte"}, []string{"error"}}, // jpeg.writer (matching bufio.Writer)
|
"WriteByte": {[]string{"byte"}, []string{"error"}}, // jpeg.writer (matching bufio.Writer)
|
||||||
"WriteTo": {[]string{"=io.Writer"}, []string{"int64", "error"}}, // io.WriterTo
|
"WriteTo": {[]string{"=io.Writer"}, []string{"int64", "error"}}, // io.WriterTo
|
||||||
}
|
}
|
||||||
@ -123,6 +126,14 @@ func canonicalMethod(pass *analysis.Pass, id *ast.Ident) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Special case: Is, As and Unwrap only apply when type
|
||||||
|
// implements error.
|
||||||
|
if id.Name == "Is" || id.Name == "As" || id.Name == "Unwrap" {
|
||||||
|
if recv := sign.Recv(); recv == nil || !implementsError(recv.Type()) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Do the =s (if any) all match?
|
// Do the =s (if any) all match?
|
||||||
if !matchParams(pass, expect.args, args, "=") || !matchParams(pass, expect.results, results, "=") {
|
if !matchParams(pass, expect.args, args, "=") || !matchParams(pass, expect.results, results, "=") {
|
||||||
return
|
return
|
||||||
@ -185,3 +196,9 @@ func matchParamType(expect string, actual types.Type) bool {
|
|||||||
// Overkill but easy.
|
// Overkill but easy.
|
||||||
return typeString(actual) == expect
|
return typeString(actual) == expect
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var errorType = types.Universe.Lookup("error").Type().Underlying().(*types.Interface)
|
||||||
|
|
||||||
|
func implementsError(actual types.Type) bool {
|
||||||
|
return types.Implements(actual, errorType)
|
||||||
|
}
|
||||||
|
2
src/cmd/vendor/modules.txt
vendored
2
src/cmd/vendor/modules.txt
vendored
@ -48,7 +48,7 @@ golang.org/x/sys/windows
|
|||||||
# golang.org/x/term v0.0.0-20210503060354-a79de5458b56
|
# golang.org/x/term v0.0.0-20210503060354-a79de5458b56
|
||||||
## explicit; go 1.17
|
## explicit; go 1.17
|
||||||
golang.org/x/term
|
golang.org/x/term
|
||||||
# golang.org/x/tools v0.1.1-0.20210505014545-7cab0ef2e9a5
|
# golang.org/x/tools v0.1.2-0.20210519160823-49064d2332f9
|
||||||
## explicit; go 1.17
|
## explicit; go 1.17
|
||||||
golang.org/x/tools/cover
|
golang.org/x/tools/cover
|
||||||
golang.org/x/tools/go/analysis
|
golang.org/x/tools/go/analysis
|
||||||
|
Loading…
Reference in New Issue
Block a user