aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/vendor
diff options
context:
space:
mode:
authorTim King <taking@google.com>2021-05-19 18:45:53 -0700
committerTim King <taking@google.com>2021-05-20 20:37:02 +0000
commitbaa934d26dd6e201dcda0962dd51b0e5f6f69c1b (patch)
tree99fc31e65e13610526247265217f6f8f54093aa2 /src/cmd/vendor
parent7c692cc7ea69ba4d8603fbada112289443a6f526 (diff)
downloadgo-baa934d26dd6e201dcda0962dd51b0e5f6f69c1b.tar.gz
go-baa934d26dd6e201dcda0962dd51b0e5f6f69c1b.zip
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>
Diffstat (limited to 'src/cmd/vendor')
-rw-r--r--src/cmd/vendor/golang.org/x/tools/go/analysis/passes/printf/printf.go2
-rw-r--r--src/cmd/vendor/golang.org/x/tools/go/analysis/passes/sigchanyzer/sigchanyzer.go11
-rw-r--r--src/cmd/vendor/golang.org/x/tools/go/analysis/passes/stdmethods/stdmethods.go17
-rw-r--r--src/cmd/vendor/modules.txt2
4 files changed, 28 insertions, 4 deletions
diff --git a/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/printf/printf.go b/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/printf/printf.go
index ddad4c796c..822820f06e 100644
--- a/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/printf/printf.go
+++ b/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/printf/printf.go
@@ -590,7 +590,7 @@ func checkPrintf(pass *analysis.Pass, kind Kind, call *ast.CallExpr, fn *types.F
}
if state.verb == 'w' {
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
}
if anyW {
diff --git a/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/sigchanyzer/sigchanyzer.go b/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/sigchanyzer/sigchanyzer.go
index b00aa7e144..0d6c8ebf16 100644
--- a/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/sigchanyzer/sigchanyzer.go
+++ b/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/sigchanyzer/sigchanyzer.go
@@ -59,12 +59,19 @@ func run(pass *analysis.Pass) (interface{}, error) {
if chanDecl == nil || len(chanDecl.Args) != 1 {
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,
Value: "1",
})
+
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
}
pass.Report(analysis.Diagnostic{
diff --git a/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/stdmethods/stdmethods.go b/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/stdmethods/stdmethods.go
index 856c6ae0d8..64a28ac0b9 100644
--- a/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/stdmethods/stdmethods.go
+++ b/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/stdmethods/stdmethods.go
@@ -61,10 +61,12 @@ var Analyzer = &analysis.Analyzer{
// we let it go. But if it does have a fmt.ScanState, then the
// rest has to match.
var canonicalMethods = map[string]struct{ args, results []string }{
+ "As": {[]string{"interface{}"}, []string{"bool"}}, // errors.As
// "Flush": {{}, {"error"}}, // http.Flusher and jpeg.writer conflict
"Format": {[]string{"=fmt.State", "rune"}, []string{}}, // fmt.Formatter
"GobDecode": {[]string{"[]byte"}, []string{"error"}}, // gob.GobDecoder
"GobEncode": {[]string{}, []string{"[]byte", "error"}}, // gob.GobEncoder
+ "Is": {[]string{"error"}, []string{"bool"}}, // errors.Is
"MarshalJSON": {[]string{}, []string{"[]byte", "error"}}, // json.Marshaler
"MarshalXML": {[]string{"*xml.Encoder", "xml.StartElement"}, []string{"error"}}, // xml.Marshaler
"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
"UnreadByte": {[]string{}, []string{"error"}},
"UnreadRune": {[]string{}, []string{"error"}},
+ "Unwrap": {[]string{}, []string{"error"}}, // errors.Unwrap
"WriteByte": {[]string{"byte"}, []string{"error"}}, // jpeg.writer (matching bufio.Writer)
"WriteTo": {[]string{"=io.Writer"}, []string{"int64", "error"}}, // io.WriterTo
}
@@ -123,6 +126,14 @@ func canonicalMethod(pass *analysis.Pass, id *ast.Ident) {
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?
if !matchParams(pass, expect.args, args, "=") || !matchParams(pass, expect.results, results, "=") {
return
@@ -185,3 +196,9 @@ func matchParamType(expect string, actual types.Type) bool {
// Overkill but easy.
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)
+}
diff --git a/src/cmd/vendor/modules.txt b/src/cmd/vendor/modules.txt
index 016ec011a9..9a1723d32c 100644
--- a/src/cmd/vendor/modules.txt
+++ b/src/cmd/vendor/modules.txt
@@ -48,7 +48,7 @@ golang.org/x/sys/windows
# golang.org/x/term v0.0.0-20210503060354-a79de5458b56
## explicit; go 1.17
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
golang.org/x/tools/cover
golang.org/x/tools/go/analysis