diff options
| author | Dmitri Shuralyov <dmitshur@golang.org> | 2022-05-16 17:53:36 -0400 |
|---|---|---|
| committer | Dmitri Shuralyov <dmitshur@golang.org> | 2022-05-16 22:26:23 +0000 |
| commit | d81dd1290665aea2de8d4d5284be26ea0bfe4cd2 (patch) | |
| tree | 0a5efd16d8e1bd23f221d36a392fc5b6b351e058 /src/cmd | |
| parent | 420a1fb223da8830ca8b30e503fd9bfa7d99be3b (diff) | |
| download | go-d81dd1290665aea2de8d4d5284be26ea0bfe4cd2.tar.xz | |
all: update vendored golang.org/x dependencies for Go 1.19 release
The Go 1.19 code freeze has recently started. This is a time to update
all golang.org/x/... module versions that contribute packages to the
std and cmd modules in the standard library to latest master versions.
This CL updates the rest of the modules with x/build/cmd/updatestd.
For #36905.
Change-Id: I4751ca477365b036a8e5ad6a9256293b44ddcd2f
Reviewed-on: https://go-review.googlesource.com/c/go/+/406356
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
Diffstat (limited to 'src/cmd')
| -rw-r--r-- | src/cmd/go.mod | 6 | ||||
| -rw-r--r-- | src/cmd/go.sum | 12 | ||||
| -rw-r--r-- | src/cmd/vendor/golang.org/x/tools/go/analysis/passes/httpresponse/httpresponse.go | 41 | ||||
| -rw-r--r-- | src/cmd/vendor/golang.org/x/tools/go/types/objectpath/objectpath.go | 100 | ||||
| -rw-r--r-- | src/cmd/vendor/golang.org/x/tools/internal/typeparams/termlist.go | 9 | ||||
| -rw-r--r-- | src/cmd/vendor/golang.org/x/tools/internal/typeparams/typeterm.go | 9 | ||||
| -rw-r--r-- | src/cmd/vendor/modules.txt | 6 |
7 files changed, 130 insertions, 53 deletions
diff --git a/src/cmd/go.mod b/src/cmd/go.mod index d6ca56f135..c720cde802 100644 --- a/src/cmd/go.mod +++ b/src/cmd/go.mod @@ -6,13 +6,13 @@ require ( github.com/google/pprof v0.0.0-20220314021825-5bba342933ea golang.org/x/arch v0.0.0-20220412001346-fc48f9fe4c15 golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 - golang.org/x/sync v0.0.0-20210220032951-036812b2e83c + golang.org/x/sync v0.0.0-20220513210516-0976fa681c29 golang.org/x/sys v0.0.0-20220513210249-45d2b4557a2a golang.org/x/term v0.0.0-20220411215600-e5f449aeb171 - golang.org/x/tools v0.1.11-0.20220510125844-bc0e26ea1275 + golang.org/x/tools v0.1.11-0.20220516163903-1e55371df567 ) require ( github.com/ianlancetaylor/demangle v0.0.0-20210905161508-09a460cdf81d // indirect - golang.org/x/crypto v0.0.0-20220315160706-3147a52a75dd // indirect + golang.org/x/crypto v0.0.0-20220516162934-403b01795ae8 // indirect ) diff --git a/src/cmd/go.sum b/src/cmd/go.sum index 39227186fd..e768e1ee6c 100644 --- a/src/cmd/go.sum +++ b/src/cmd/go.sum @@ -7,16 +7,16 @@ github.com/ianlancetaylor/demangle v0.0.0-20210905161508-09a460cdf81d h1:uGg2frl github.com/ianlancetaylor/demangle v0.0.0-20210905161508-09a460cdf81d/go.mod h1:aYm2/VgdVmcIU8iMfdMvDMsRAQjcfZSKFby6HOFvi/w= golang.org/x/arch v0.0.0-20220412001346-fc48f9fe4c15 h1:GVfVkciLYxn5mY5EncwAe0SXUn9Rm81rRkZ0TTmn/cU= golang.org/x/arch v0.0.0-20220412001346-fc48f9fe4c15/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8= -golang.org/x/crypto v0.0.0-20220315160706-3147a52a75dd h1:XcWmESyNjXJMLahc3mqVQJcgSTDxFxhETVlfk9uGc38= -golang.org/x/crypto v0.0.0-20220315160706-3147a52a75dd/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= +golang.org/x/crypto v0.0.0-20220516162934-403b01795ae8 h1:y+mHpWoQJNAHt26Nhh6JP7hvM71IRZureyvZhoVALIs= +golang.org/x/crypto v0.0.0-20220516162934-403b01795ae8/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 h1:6zppjxzCulZykYSLyVDYbneBfbaBIQPYMevg0bEwv2s= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= -golang.org/x/sync v0.0.0-20210220032951-036812b2e83c h1:5KslGYwFpkhGh+Q16bwMP3cOontH8FOep7tGV86Y7SQ= -golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20220513210516-0976fa681c29 h1:w8s32wxx3sY+OjLlv9qltkLU5yvJzxjjgiHWLjdIcw4= +golang.org/x/sync v0.0.0-20220513210516-0976fa681c29/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220513210249-45d2b4557a2a h1:N2T1jUrTQE9Re6TFF5PhvEHXHCguynGhKjWVsIUt5cY= golang.org/x/sys v0.0.0-20220513210249-45d2b4557a2a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20220411215600-e5f449aeb171 h1:EH1Deb8WZJ0xc0WK//leUHXcX9aLE5SymusoTmMZye8= golang.org/x/term v0.0.0-20220411215600-e5f449aeb171/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/tools v0.1.11-0.20220510125844-bc0e26ea1275 h1:ismY4QcvigOCsXTuUEtx/f/vntz7reNAQnMGPI0Z4KE= -golang.org/x/tools v0.1.11-0.20220510125844-bc0e26ea1275/go.mod h1:SgwaegtQh8clINPpECJMqnxLv9I09HLqnW3RMqW0CA4= +golang.org/x/tools v0.1.11-0.20220516163903-1e55371df567 h1:MksUZ/zlU+pMbsq1Sw16gK6E1aWzD0rLE+eS2SxF24Y= +golang.org/x/tools v0.1.11-0.20220516163903-1e55371df567/go.mod h1:SgwaegtQh8clINPpECJMqnxLv9I09HLqnW3RMqW0CA4= diff --git a/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/httpresponse/httpresponse.go b/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/httpresponse/httpresponse.go index 092ac75cca..3b9168c6c3 100644 --- a/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/httpresponse/httpresponse.go +++ b/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/httpresponse/httpresponse.go @@ -62,15 +62,16 @@ func run(pass *analysis.Pass) (interface{}, error) { // Find the innermost containing block, and get the list // of statements starting with the one containing call. - stmts, withinAnotherCall := restOfBlock(stack) - if withinAnotherCall { - // We skip cases when the results of a call to http member - // are passed directly to another call, as that later call - // could check err != nil and create false positives (#52661). + stmts, ncalls := restOfBlock(stack) + if len(stmts) < 2 { + // The call to the http function is the last statement of the block. return true } - if len(stmts) < 2 { - return true // the call to the http function is the last statement of the block. + + // Skip cases in which the call is wrapped by another (#52661). + // Example: resp, err := checkError(http.Get(url)) + if ncalls > 1 { + return true } asg, ok := stmts[0].(*ast.AssignStmt) @@ -136,34 +137,26 @@ func isHTTPFuncOrMethodOnClient(info *types.Info, expr *ast.CallExpr) bool { return ok && isNamedType(ptr.Elem(), "net/http", "Client") // method on *http.Client. } -// restOfBlock, given a traversal stack, checks if the current node -// (the last element of stack) appears as an argument to another call. -// If not, it finds the innermost containing block and returns the -// suffix of its statements starting with the current node. Otherwise, -// returns an empty slice. -func restOfBlock(stack []ast.Node) ([]ast.Stmt, bool) { +// restOfBlock, given a traversal stack, finds the innermost containing +// block and returns the suffix of its statements starting with the current +// node, along with the number of call expressions encountered. +func restOfBlock(stack []ast.Node) ([]ast.Stmt, int) { + var ncalls int for i := len(stack) - 1; i >= 0; i-- { - // If the current node appears within another call, then - // this has to happen within the same block. We can thus - // immediately return on whichever we see first, a block - // statement or a call statement. - if b, ok := stack[i].(*ast.BlockStmt); ok { for j, v := range b.List { if v == stack[i+1] { - return b.List[j:], false + return b.List[j:], ncalls } } break } - // The call to an http member currently analyzed is at len(stack)-1. - if _, ok := stack[i].(*ast.CallExpr); ok && i != len(stack)-1 { - return nil, true // e.g. "resp, err := wrap(http.Get(...))" + if _, ok := stack[i].(*ast.CallExpr); ok { + ncalls++ } - } - return nil, false + return nil, 0 } // rootIdent finds the root identifier x in a chain of selections x.y.z, or nil if not found. diff --git a/src/cmd/vendor/golang.org/x/tools/go/types/objectpath/objectpath.go b/src/cmd/vendor/golang.org/x/tools/go/types/objectpath/objectpath.go index f27d871295..c160acb686 100644 --- a/src/cmd/vendor/golang.org/x/tools/go/types/objectpath/objectpath.go +++ b/src/cmd/vendor/golang.org/x/tools/go/types/objectpath/objectpath.go @@ -224,10 +224,11 @@ func For(obj types.Object) (Path, error) { if recv := obj.Type().(*types.Signature).Recv(); recv == nil { return "", fmt.Errorf("func is not a method: %v", obj) } - // TODO(adonovan): opt: if the method is concrete, - // do a specialized version of the rest of this function so - // that it's O(1) not O(|scope|). Basically 'find' is needed - // only for struct fields and interface methods. + + if path, ok := concreteMethod(obj); ok { + // Fast path for concrete methods that avoids looping over scope. + return path, nil + } default: panic(obj) @@ -316,6 +317,97 @@ func appendOpArg(path []byte, op byte, arg int) []byte { return path } +// concreteMethod returns the path for meth, which must have a non-nil receiver. +// The second return value indicates success and may be false if the method is +// an interface method or if it is an instantiated method. +// +// This function is just an optimization that avoids the general scope walking +// approach. You are expected to fall back to the general approach if this +// function fails. +func concreteMethod(meth *types.Func) (Path, bool) { + // Concrete methods can only be declared on package-scoped named types. For + // that reason we can skip the expensive walk over the package scope: the + // path will always be package -> named type -> method. We can trivially get + // the type name from the receiver, and only have to look over the type's + // methods to find the method index. + // + // Methods on generic types require special consideration, however. Consider + // the following package: + // + // L1: type S[T any] struct{} + // L2: func (recv S[A]) Foo() { recv.Bar() } + // L3: func (recv S[B]) Bar() { } + // L4: type Alias = S[int] + // L5: func _[T any]() { var s S[int]; s.Foo() } + // + // The receivers of methods on generic types are instantiations. L2 and L3 + // instantiate S with the type-parameters A and B, which are scoped to the + // respective methods. L4 and L5 each instantiate S with int. Each of these + // instantiations has its own method set, full of methods (and thus objects) + // with receivers whose types are the respective instantiations. In other + // words, we have + // + // S[A].Foo, S[A].Bar + // S[B].Foo, S[B].Bar + // S[int].Foo, S[int].Bar + // + // We may thus be trying to produce object paths for any of these objects. + // + // S[A].Foo and S[B].Bar are the origin methods, and their paths are S.Foo + // and S.Bar, which are the paths that this function naturally produces. + // + // S[A].Bar, S[B].Foo, and both methods on S[int] are instantiations that + // don't correspond to the origin methods. For S[int], this is significant. + // The most precise object path for S[int].Foo, for example, is Alias.Foo, + // not S.Foo. Our function, however, would produce S.Foo, which would + // resolve to a different object. + // + // For S[A].Bar and S[B].Foo it could be argued that S.Bar and S.Foo are + // still the correct paths, since only the origin methods have meaningful + // paths. But this is likely only true for trivial cases and has edge cases. + // Since this function is only an optimization, we err on the side of giving + // up, deferring to the slower but definitely correct algorithm. Most users + // of objectpath will only be giving us origin methods, anyway, as referring + // to instantiated methods is usually not useful. + + if typeparams.OriginMethod(meth) != meth { + return "", false + } + + recvT := meth.Type().(*types.Signature).Recv().Type() + if ptr, ok := recvT.(*types.Pointer); ok { + recvT = ptr.Elem() + } + + named, ok := recvT.(*types.Named) + if !ok { + return "", false + } + + if types.IsInterface(named) { + // Named interfaces don't have to be package-scoped + // + // TODO(dominikh): opt: if scope.Lookup(name) == named, then we can apply this optimization to interface + // methods, too, I think. + return "", false + } + + // Preallocate space for the name, opType, opMethod, and some digits. + name := named.Obj().Name() + path := make([]byte, 0, len(name)+8) + path = append(path, name...) + path = append(path, opType) + canonical := canonicalize(named) + for i, m := range canonical { + if m == meth { + path = appendOpArg(path, opMethod, i) + return Path(path), true + } + } + + panic(fmt.Sprintf("couldn't find method %s on type %s", meth, named)) +} + // find finds obj within type T, returning the path to it, or nil if not found. // // The seen map is used to short circuit cycles through type parameters. If diff --git a/src/cmd/vendor/golang.org/x/tools/internal/typeparams/termlist.go b/src/cmd/vendor/golang.org/x/tools/internal/typeparams/termlist.go index 10857d504c..933106a23d 100644 --- a/src/cmd/vendor/golang.org/x/tools/internal/typeparams/termlist.go +++ b/src/cmd/vendor/golang.org/x/tools/internal/typeparams/termlist.go @@ -97,15 +97,6 @@ func (xl termlist) norm() termlist { return rl } -// If the type set represented by xl is specified by a single (non-𝓤) term, -// structuralType returns that type. Otherwise it returns nil. -func (xl termlist) structuralType() types.Type { - if nl := xl.norm(); len(nl) == 1 { - return nl[0].typ // if nl.isAll() then typ is nil, which is ok - } - return nil -} - // union returns the union xl ∪ yl. func (xl termlist) union(yl termlist) termlist { return append(xl, yl...).norm() diff --git a/src/cmd/vendor/golang.org/x/tools/internal/typeparams/typeterm.go b/src/cmd/vendor/golang.org/x/tools/internal/typeparams/typeterm.go index 7350bb702a..7ddee28d98 100644 --- a/src/cmd/vendor/golang.org/x/tools/internal/typeparams/typeterm.go +++ b/src/cmd/vendor/golang.org/x/tools/internal/typeparams/typeterm.go @@ -10,10 +10,11 @@ import "go/types" // A term describes elementary type sets: // -// ∅: (*term)(nil) == ∅ // set of no types (empty set) -// 𝓤: &term{} == 𝓤 // set of all types (𝓤niverse) -// T: &term{false, T} == {T} // set of type T -// ~t: &term{true, t} == {t' | under(t') == t} // set of types with underlying type t +// ∅: (*term)(nil) == ∅ // set of no types (empty set) +// 𝓤: &term{} == 𝓤 // set of all types (𝓤niverse) +// T: &term{false, T} == {T} // set of type T +// ~t: &term{true, t} == {t' | under(t') == t} // set of types with underlying type t +// type term struct { tilde bool // valid if typ != nil typ types.Type diff --git a/src/cmd/vendor/modules.txt b/src/cmd/vendor/modules.txt index ede312d358..62da0c76bb 100644 --- a/src/cmd/vendor/modules.txt +++ b/src/cmd/vendor/modules.txt @@ -23,7 +23,7 @@ golang.org/x/arch/arm/armasm golang.org/x/arch/arm64/arm64asm golang.org/x/arch/ppc64/ppc64asm golang.org/x/arch/x86/x86asm -# golang.org/x/crypto v0.0.0-20220315160706-3147a52a75dd +# golang.org/x/crypto v0.0.0-20220516162934-403b01795ae8 ## explicit; go 1.17 golang.org/x/crypto/ed25519 # golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 @@ -37,7 +37,7 @@ golang.org/x/mod/sumdb/dirhash golang.org/x/mod/sumdb/note golang.org/x/mod/sumdb/tlog golang.org/x/mod/zip -# golang.org/x/sync v0.0.0-20210220032951-036812b2e83c +# golang.org/x/sync v0.0.0-20220513210516-0976fa681c29 ## explicit golang.org/x/sync/semaphore # golang.org/x/sys v0.0.0-20220513210249-45d2b4557a2a @@ -49,7 +49,7 @@ golang.org/x/sys/windows # golang.org/x/term v0.0.0-20220411215600-e5f449aeb171 ## explicit; go 1.17 golang.org/x/term -# golang.org/x/tools v0.1.11-0.20220510125844-bc0e26ea1275 +# golang.org/x/tools v0.1.11-0.20220516163903-1e55371df567 ## explicit; go 1.17 golang.org/x/tools/cover golang.org/x/tools/go/analysis |
