Skip to content

Commit 03ebc2c

Browse files
committed
[gopls-release-branch.0.6] all: merge master into gopls-release-branch.0.6
42984c4 internal/lsp/regtest: run one quick fix at a time in TestUnknownRevision 19b1717 go.mod: upgrade to Go 1.17 a1fbb68 all: upgrade go.mod files to Go 1.16 062bf4e internal/lsp: make ShowDocument RPC available to gopls 3e17c62 internal/lsp: warn users who have built gopls with go-diff v1.2.0 def0263 gopls: clarify policy with respect to support for older Go versions 7a6108e internal/lsp: don't use ast.NewPackage to build builtin edbe9be internal/lsp/completion: indicate completion candidates that are deprecated 9b9633e internal/lsp/regtest: force GOPACKAGESDRIVER=off 291330a gopls/internal/regtest/modfile: set an explicit go version in the TestUnknownRevision modules aec1372 gopls/internal/regtest: unskip tests for golang/go#37098 28c1392 internal/lsp: don't call PackagesForFile on builtin.go 800adbe go/packages: enable TestIssue37098 for Go 1.17 and later 16b25d2 internal/lsp: print comments that would be lost during extract func 7c72a84 go/analysis/passes/fieldalignment: clarify reported diagnostics in docs 9ff8648 internal/lsp: add support for extracting non-nested returns d0768c9 internal/lsp/source/completion: suggest only valid package names 6397a11 internal/lsp/debug: splice in updated servers rather than overwrite 7b9993c internal/lsp/cmd: add a command-line command to start daemon debugging fe1c548 gopls/test: it is safe to ignore json unmarshalling errors 735ed62 gopls: tidy module e3dc99f cmd/guru: update referrers-json testdata to reflect new line numbering 3f1e724 cmd/guru: remove test assertions involving unsafe to fix the build cf354b6 internal/lsp/cache: improve snapshot clone perfomance 7657be6 gopls/doc: fix broken link 7c93484 internal/lsp: add a command to start the debug server 716a04c lsp/completion: fix postfix completions preceding assignments f74a6698 internal/lsp/cache: preallocate internal maps when cloning snapshots e435455 internal/lsp: introduce MemoryMode f7e8e24 internal/lsp: support Check For Upgrades in vendor mode a8e7c0c internal/lsp: move gopls/internal/regtest -> internal/lsp/regtest f946a15 passes/sigchanyzer: allow valid inlined unbuffered signal channel 4934781 lsp/completion: offer candidates converting arrays to slices b3e5b99 internal/lsp: update unsafe completion test for upcoming spec changes e74674a internal/lsp/protocol: latest version of LSP dbc8747 internal/lsp/semantic: avoid doing semantic tokens for large files a13dbf1 lsp/completion: omit deep completions into unimported package names 10909d8 internal/lsp/cache: remove type info trimming 1dce19d internal/lsp/cache: don't trim types.Info with staticcheck enabled 07295ca internal/lsp/cache: prune types.Info entries in slice literals 1a0c608 internal/lsp/protocol/typescript: update documentation and generated code fe50371 internal/lsp/source: fix Deref function for cyclic types cb5dc85 internal/lsp/cache: add a scheme for types error code links 799b682 gopls/internal/hooks: respect the default checks of the staticcheck tool d1362d7 internal/lsp/source: fix an infinite loop in Deref function 59a2b45 internal/lsp/source: update process of hover signature creation for type declarations 2140cce fix the argument of the goimports example ec686a2 all: upgrade all dependencies except for go-diff 0243799 gopls/internal/coverage: apply gofmt to the build tag syntax be791d0 internal/lsp/source: small fixes to directory filters Change-Id: If0eb9499020d2baab77f05523197adb95044705f
2 parents 3f06512 + 42984c4 commit 03ebc2c

File tree

130 files changed

+2396
-722
lines changed

Some content is hidden

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

130 files changed

+2396
-722
lines changed

cmd/guru/testdata/src/describe/main.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@ import (
1010
"lib"
1111
"nosuchpkg" // @describe badimport1 "nosuchpkg"
1212
nosuchpkg2 "nosuchpkg" // @describe badimport2 "nosuchpkg2"
13-
_ "unsafe" // @describe unsafe "unsafe"
13+
// The unsafe package changed in Go 1.17 with the addition of
14+
// unsafe.Add and unsafe.Slice. While we still support older versions
15+
// of Go, the test case below cannot be enabled.
16+
// _ "unsafe" // @describe unsafe "unsafe"
1417
)
1518

1619
var _ nosuchpkg.T

cmd/guru/testdata/src/describe/main.golden

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,6 @@ import of package "nosuchpkg"
2020
-------- @describe badimport2 --------
2121
reference to package "nosuchpkg"
2222

23-
-------- @describe unsafe --------
24-
import of package "unsafe"
25-
builtin Alignof
26-
builtin Offsetof
27-
type Pointer unsafe.Pointer
28-
builtin Sizeof
29-
3023
-------- @describe type-ref-builtin --------
3124
reference to built-in type float64
3225

cmd/guru/testdata/src/referrers-json/main.golden

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
"package": "describe",
4444
"refs": [
4545
{
46-
"pos": "testdata/src/describe/main.go:92:8",
46+
"pos": "testdata/src/describe/main.go:95:8",
4747
"text": "\tvar _ lib.Outer // @describe lib-outer \"Outer\""
4848
}
4949
]

go.mod

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

3-
go 1.12
3+
go 1.17
44

55
require (
6-
github.com/yuin/goldmark v1.2.1
7-
golang.org/x/mod v0.4.1
8-
golang.org/x/net v0.0.0-20201021035429-f5854403a974
9-
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9
10-
golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c
6+
github.com/yuin/goldmark v1.3.3
7+
golang.org/x/mod v0.4.2
8+
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4
9+
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c
10+
golang.org/x/sys v0.0.0-20210403161142-5e06dd20ab57
1111
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1
1212
)

go.sum

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,23 @@
1-
github.com/yuin/goldmark v1.2.1 h1:ruQGxdhGHe7FWOJPT0mKs5+pD2Xs1Bm/kdGlHO04FmM=
2-
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
1+
github.com/yuin/goldmark v1.3.3 h1:37BdQwPx8VOSic8eDSWee6QL9mRpZRm9VJp/QugNrW0=
2+
github.com/yuin/goldmark v1.3.3/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
33
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
44
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
5-
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
6-
golang.org/x/mod v0.4.1 h1:Kvvh58BN8Y9/lBi7hTekvtMpm07eUZ0ck5pRHpsMWrY=
7-
golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
5+
golang.org/x/mod v0.4.2 h1:Gz96sIWK3OalVv/I/qNygP42zyoKp3xptRVCWRFEBvo=
6+
golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
87
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
98
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
10-
golang.org/x/net v0.0.0-20201021035429-f5854403a974 h1:IX6qOQeG5uLjB/hjjwjedwfjND0hgjPMMyO1RoIXQNI=
11-
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
9+
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4 h1:4nGaVu0QrbjT/AK2PRLuQfQuh6DJve+pELhqTdAj3x0=
10+
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
1211
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
13-
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9 h1:SQFwaSi55rU7vdNs9Yr0Z324VNlrF+0wMqRXT4St8ck=
14-
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
12+
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c h1:5KslGYwFpkhGh+Q16bwMP3cOontH8FOep7tGV86Y7SQ=
13+
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
1514
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
1615
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
17-
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
18-
golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c h1:VwygUrnw9jn88c4u8GD3rZQbqrP/tgas88tPUbBxQrk=
19-
golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
16+
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
17+
golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
18+
golang.org/x/sys v0.0.0-20210403161142-5e06dd20ab57 h1:F5Gozwx4I1xtr/sr/8CFbb57iKi3297KFs0QDbGN60A=
19+
golang.org/x/sys v0.0.0-20210403161142-5e06dd20ab57/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
20+
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
2021
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
2122
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
2223
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=

go/analysis/passes/fieldalignment/fieldalignment.go

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Use of this source code is governed by a BSD-style
33
// license that can be found in the LICENSE file.
44

5-
// Package fieldalignment defines an Analyzer that detects structs that would take less
5+
// Package fieldalignment defines an Analyzer that detects structs that would use less
66
// memory if their fields were sorted.
77
package fieldalignment
88

@@ -20,10 +20,27 @@ import (
2020
"golang.org/x/tools/go/ast/inspector"
2121
)
2222

23-
const Doc = `find structs that would take less memory if their fields were sorted
23+
const Doc = `find structs that would use less memory if their fields were sorted
2424
25-
This analyzer find structs that can be rearranged to take less memory, and provides
25+
This analyzer find structs that can be rearranged to use less memory, and provides
2626
a suggested edit with the optimal order.
27+
28+
Note that there are two different diagnostics reported. One checks struct size,
29+
and the other reports "pointer bytes" used. Pointer bytes is how many bytes of the
30+
object that the garbage collector has to potentially scan for pointers, for example:
31+
32+
struct { uint32; string }
33+
34+
have 16 pointer bytes because the garbage collector has to scan up through the string's
35+
inner pointer.
36+
37+
struct { string; *uint32 }
38+
39+
has 24 pointer bytes because it has to scan further through the *uint32.
40+
41+
struct { string; uint32 }
42+
43+
has 8 because it can stop immediately after the string pointer.
2744
`
2845

2946
var Analyzer = &analysis.Analyzer{

go/analysis/passes/sigchanyzer/sigchanyzer.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@ func run(pass *analysis.Pass) (interface{}, error) {
4949
chanDecl = decl
5050
}
5151
case *ast.CallExpr:
52+
// Only signal.Notify(make(chan os.Signal), os.Interrupt) is safe,
53+
// conservatively treate others as not safe, see golang/go#45043
54+
if isBuiltinMake(pass.TypesInfo, arg) {
55+
return
56+
}
5257
chanDecl = arg
5358
}
5459
if chanDecl == nil || len(chanDecl.Args) != 1 {
@@ -127,3 +132,16 @@ func findDecl(arg *ast.Ident) ast.Node {
127132
}
128133
return nil
129134
}
135+
136+
func isBuiltinMake(info *types.Info, call *ast.CallExpr) bool {
137+
typVal := info.Types[call.Fun]
138+
if !typVal.IsBuiltin() {
139+
return false
140+
}
141+
switch fun := call.Fun.(type) {
142+
case *ast.Ident:
143+
return info.ObjectOf(fun).Name() == "make"
144+
default:
145+
return false
146+
}
147+
}

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,19 @@ func j() {
3636
f := signal.Notify
3737
f(c, os.Interrupt) // want "misuse of unbuffered os.Signal channel as argument to signal.Notify"
3838
}
39+
40+
func k() {
41+
signal.Notify(make(chan os.Signal), os.Interrupt) // ok
42+
}
43+
44+
func l() {
45+
signal.Notify(make(chan os.Signal, 1), os.Interrupt) // ok
46+
}
47+
48+
func m() {
49+
signal.Notify(make(chan ao.Signal, 1), os.Interrupt) // ok
50+
}
51+
52+
func n() {
53+
signal.Notify(make(chan ao.Signal), os.Interrupt) // ok
54+
}

go/analysis/passes/sigchanyzer/testdata/src/a/a.go.golden

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,19 @@ func j() {
3636
f := signal.Notify
3737
f(c, os.Interrupt) // want "misuse of unbuffered os.Signal channel as argument to signal.Notify"
3838
}
39+
40+
func k() {
41+
signal.Notify(make(chan os.Signal), os.Interrupt) // ok
42+
}
43+
44+
func l() {
45+
signal.Notify(make(chan os.Signal, 1), os.Interrupt) // ok
46+
}
47+
48+
func m() {
49+
signal.Notify(make(chan ao.Signal, 1), os.Interrupt) // ok
50+
}
51+
52+
func n() {
53+
signal.Notify(make(chan ao.Signal), os.Interrupt) // ok
54+
}

go/packages/packages_test.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2355,7 +2355,16 @@ func testIssue37098(t *testing.T, exporter packagestest.Exporter) {
23552355
// (*Package).CompiledGoFiles. This tests #37098, where using SWIG to
23562356
// causes C++ sources to be inadvertently included in
23572357
// (*Package).CompiledGoFiles.
2358-
t.Skip("Issue #37098: SWIG causes generated C++ sources in CompiledGoFiles")
2358+
2359+
// This is fixed in Go 1.17, but not earlier.
2360+
testenv.NeedsGo1Point(t, 17)
2361+
2362+
if _, err := exec.LookPath("swig"); err != nil {
2363+
t.Skip("skipping test: swig not available")
2364+
}
2365+
if _, err := exec.LookPath("g++"); err != nil {
2366+
t.Skip("skipping test: g++ not available")
2367+
}
23592368

23602369
// Create a fake package with an empty Go source, and a SWIG interface
23612370
// file.

0 commit comments

Comments
 (0)