Skip to content

Commit 188b785

Browse files
committed
all: merge master (9c97539) into gopls-release-branch.0.12
Also put back the x/tools replace directive in gopls/go.mod. For golang/go#59818 Merge List: + 2023-05-24 9c97539 gopls/internal/lsp/cache: remove nested module warning + 2023-05-24 d44a094 gopls/internal/lsp/cmd: add a stats -anon flag to show anonymous data + 2023-05-24 e106694 gopls/internal/lsp: bundle certain quick-fixes with their diagnostic + 2023-05-24 5dc3f74 gopls/internal/lsp/filecache: reenable memory cache layer + 2023-05-24 7e146a6 gopls/internal/lsp/cmd: simplify connection type + 2023-05-24 1e60668 gopls/internal/regtest/workspace: unskip duplicate modules test + 2023-05-23 5ce721d gopls/doc: Fix broken links + 2023-05-23 7a03feb gopls/internal/lsp/cmd: remove vestiges of debugging golang/go#59475 + 2023-05-22 a70f2bc gopls/internal/regtest/misc: update and unskip TestHoverIntLiteral + 2023-05-22 6997d19 gopls/internal/regtest/misc: unskip TestMajorOptionsChange + 2023-05-22 ec543c5 gopls/internal/lsp/cache: fix crash in Session.updateViewLocked + 2023-05-22 a12ee94 gopls/internal/regtest/misc: update some unilaterally skipped tests + 2023-05-22 5ff5cbb gopls: deprecate support for Go 1.16 and 1.17, update warnings + 2023-05-22 e6fd7f4 gopls/internal/lsp/cache: limit module scan to 100K files + 2023-05-22 9ca66ba gopls/internal/lsp/regtest: delete TestWatchReplaceTargets + 2023-05-22 edbfdbe gopls/internal/lsp/source/completion: (unimported) add placeholders + 2023-05-22 3a5dbf3 gopls: add a new "subdirWatchPatterns" setting + 2023-05-22 3c02551 internal/typesinternal: remove NewObjectpathFunc + 2023-05-20 0729362 present: reformat doc comment for lack of inline code + 2023-05-20 d4e66bd go/ssa: TestStdlib: disable check that function names are distinct + 2023-05-20 738ea2b go/ssa: use core type for field accesses + 2023-05-19 2ec4299 gopls/internal/lsp: split file-watching glob patterns + 2023-05-19 43b02ea gopls/internal/lsp/cache: only delete the most relevant mod tidy handle + 2023-05-19 5919673 internal/lsp/filecache: eliminate 'kind' directories + 2023-05-19 a5ef6c3 gopls/internal/lsp: keep track of overlays on the files map + 2023-05-19 d7f4359 gopls/internal/lsp/mod: optimizations for mod tidy diagnostics + 2023-05-19 2eb726b gopls/internal/lsp/filecache: touch only files older than 1h + 2023-05-19 b742cb9 gopls/internal/regtest/bench: add a benchmark for diagnosing saves + 2023-05-19 4d66324 gopls/internal/lsp/cache: tweak error message + 2023-05-19 e46df40 gopls/internal/lsp/filecache: delayed tweaks from code review + 2023-05-19 3df69b8 gopls/internal/lsp/debug: remove memory monitoring + 2023-05-19 a069704 gopls/internal/lsp/filecache: avoid flock + 2023-05-18 3d53c2d gopls/internal/lsp/cache: fix race in adhoc reloading + 2023-05-17 8b4b27b go/analysis/passes/slog: fix Group kv offset + 2023-05-17 242e5ed cover: eliminate an unnecessary fsync in TestParseProfiles + 2023-05-17 651d951 go/ssa: fix typo in package docs Change-Id: Ie57d55ba8f3ae9bcf868db08088f68955b5e4856
2 parents 12762ec + 9c97539 commit 188b785

Some content is hidden

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

80 files changed

+1336
-2360
lines changed

cover/profile_test.go

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ package cover
66

77
import (
88
"fmt"
9-
"io/ioutil"
109
"os"
10+
"path/filepath"
1111
"reflect"
1212
"testing"
1313
)
@@ -208,26 +208,12 @@ some/fancy/path:42.69,44.16 2 -1`,
208208

209209
for _, tc := range tests {
210210
t.Run(tc.name, func(t *testing.T) {
211-
f, err := ioutil.TempFile("", "")
212-
if err != nil {
213-
t.Fatalf("Failed to create a temp file: %v.", err)
214-
}
215-
defer func() {
216-
f.Close()
217-
os.Remove(f.Name())
218-
}()
219-
n, err := f.WriteString(tc.input)
220-
if err != nil {
221-
t.Fatalf("Failed to write to temp file: %v", err)
222-
}
223-
if n < len(tc.input) {
224-
t.Fatalf("Didn't write enough bytes to temp file (wrote %d, expected %d).", n, len(tc.input))
225-
}
226-
if err := f.Sync(); err != nil {
227-
t.Fatalf("Failed to sync temp file: %v", err)
211+
fname := filepath.Join(t.TempDir(), "test.cov")
212+
if err := os.WriteFile(fname, []byte(tc.input), 0644); err != nil {
213+
t.Fatal(err)
228214
}
229215

230-
result, err := ParseProfiles(f.Name())
216+
result, err := ParseProfiles(fname)
231217
if err != nil {
232218
if !tc.expectErr {
233219
t.Errorf("Unexpected error: %v", err)

go/analysis/passes/slog/slog.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ var kvFuncs = map[string]map[string]int{
204204
"WarnCtx": 2,
205205
"ErrorCtx": 2,
206206
"Log": 3,
207-
"Group": 0,
207+
"Group": 1,
208208
},
209209
"Logger": map[string]int{
210210
"Debug": 1,

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,8 @@ func All() {
143143

144144
r.Add(1, 2) // want `slog.Record.Add arg "1" should be a string or a slog.Attr`
145145

146-
_ = slog.Group("a", 1, 2, 3) // want `slog.Group arg "2" should be a string or a slog.Attr`
146+
_ = slog.Group("key", "a", 1, "b", 2)
147+
_ = slog.Group("key", "a", 1, 2, 3) // want `slog.Group arg "2" should be a string or a slog.Attr`
147148

148149
}
149150

go/ssa/builder_generic_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -685,7 +685,7 @@ func TestInstructionString(t *testing.T) {
685685
//@ instrs("f12", "*ssa.MakeMap", "make map[P]bool 1:int")
686686
func f12[T any, P *struct{f T}](x T) map[P]bool { return map[P]bool{{}: true} }
687687
688-
//@ instrs("f13", "&v[0:int]")
688+
//@ instrs("f13", "*ssa.IndexAddr", "&v[0:int]")
689689
//@ instrs("f13", "*ssa.Store", "*t0 = 7:int", "*v = *new(A):A")
690690
func f13[A [3]int, PA *A](v PA) {
691691
*v = A{7}

go/ssa/doc.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@
6666
// *FieldAddr ✔ ✔
6767
// *FreeVar ✔
6868
// *Function ✔ ✔ (func)
69-
// *GenericConvert ✔ ✔
7069
// *Global ✔ ✔ (var)
7170
// *Go ✔
7271
// *If ✔
@@ -80,6 +79,7 @@
8079
// *MakeMap ✔ ✔
8180
// *MakeSlice ✔ ✔
8281
// *MapUpdate ✔
82+
// *MultiConvert ✔ ✔
8383
// *NamedConst ✔ (const)
8484
// *Next ✔ ✔
8585
// *Panic ✔

go/ssa/emit.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,7 @@ func emitTailCall(f *Function, call *Call) {
476476
// value of a field.
477477
func emitImplicitSelections(f *Function, v Value, indices []int, pos token.Pos) Value {
478478
for _, index := range indices {
479-
if st, vptr := deptr(v.Type()); vptr {
479+
if st, vptr := deref(v.Type()); vptr {
480480
fld := fieldOf(st, index)
481481
instr := &FieldAddr{
482482
X: v,
@@ -486,7 +486,7 @@ func emitImplicitSelections(f *Function, v Value, indices []int, pos token.Pos)
486486
instr.setType(types.NewPointer(fld.Type()))
487487
v = f.emit(instr)
488488
// Load the field's value iff indirectly embedded.
489-
if _, fldptr := deptr(fld.Type()); fldptr {
489+
if _, fldptr := deref(fld.Type()); fldptr {
490490
v = emitLoad(f, v)
491491
}
492492
} else {
@@ -510,7 +510,7 @@ func emitImplicitSelections(f *Function, v Value, indices []int, pos token.Pos)
510510
// field's value.
511511
// Ident id is used for position and debug info.
512512
func emitFieldSelection(f *Function, v Value, index int, wantAddr bool, id *ast.Ident) Value {
513-
if st, vptr := deptr(v.Type()); vptr {
513+
if st, vptr := deref(v.Type()); vptr {
514514
fld := fieldOf(st, index)
515515
instr := &FieldAddr{
516516
X: v,

go/ssa/ssa.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -865,7 +865,7 @@ type Slice struct {
865865
type FieldAddr struct {
866866
register
867867
X Value // *struct
868-
Field int // field is typeparams.CoreType(X.Type().Underlying().(*types.Pointer).Elem()).(*types.Struct).Field(Field)
868+
Field int // index into CoreType(CoreType(X.Type()).(*types.Pointer).Elem()).(*types.Struct).Fields
869869
}
870870

871871
// The Field instruction yields the Field of struct X.
@@ -884,7 +884,7 @@ type FieldAddr struct {
884884
type Field struct {
885885
register
886886
X Value // struct
887-
Field int // index into typeparams.CoreType(X.Type()).(*types.Struct).Fields
887+
Field int // index into CoreType(X.Type()).(*types.Struct).Fields
888888
}
889889

890890
// The IndexAddr instruction yields the address of the element at

go/ssa/stdlib_test.go

Lines changed: 28 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ func bytesAllocated() uint64 {
3636

3737
func TestStdlib(t *testing.T) {
3838
if testing.Short() {
39-
t.Skip("skipping in short mode; too slow (https://golang.org/issue/14113)")
39+
t.Skip("skipping in short mode; too slow (https://golang.org/issue/14113)") // ~5s
4040
}
4141
testenv.NeedsTool(t, "go")
4242

@@ -81,20 +81,33 @@ func TestStdlib(t *testing.T) {
8181

8282
allFuncs := ssautil.AllFunctions(prog)
8383

84-
// Check that all non-synthetic functions have distinct names.
85-
// Synthetic wrappers for exported methods should be distinct too,
86-
// except for unexported ones (explained at (*Function).RelString).
87-
byName := make(map[string]*ssa.Function)
88-
for fn := range allFuncs {
89-
if fn.Synthetic == "" || ast.IsExported(fn.Name()) {
90-
str := fn.String()
91-
prev := byName[str]
92-
byName[str] = fn
93-
if prev != nil {
94-
t.Errorf("%s: duplicate function named %s",
95-
prog.Fset.Position(fn.Pos()), str)
96-
t.Errorf("%s: (previously defined here)",
97-
prog.Fset.Position(prev.Pos()))
84+
// The assertion below is not valid if the program contains
85+
// variants of the same package, such as the test variants
86+
// (e.g. package p as compiled for test executable x) obtained
87+
// when cfg.Tests=true. Profile-guided optimization may
88+
// lead to similar variation for non-test executables.
89+
//
90+
// Ideally, the test would assert that all functions within
91+
// each executable (more generally: within any singly rooted
92+
// transitively closed subgraph of the import graph) have
93+
// distinct names, but that isn't so easy to compute efficiently.
94+
// Disabling for now.
95+
if false {
96+
// Check that all non-synthetic functions have distinct names.
97+
// Synthetic wrappers for exported methods should be distinct too,
98+
// except for unexported ones (explained at (*Function).RelString).
99+
byName := make(map[string]*ssa.Function)
100+
for fn := range allFuncs {
101+
if fn.Synthetic == "" || ast.IsExported(fn.Name()) {
102+
str := fn.String()
103+
prev := byName[str]
104+
byName[str] = fn
105+
if prev != nil {
106+
t.Errorf("%s: duplicate function named %s",
107+
prog.Fset.Position(fn.Pos()), str)
108+
t.Errorf("%s: (previously defined here)",
109+
prog.Fset.Position(prev.Pos()))
110+
}
98111
}
99112
}
100113
}

gopls/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ version of gopls.
9393
| ----------- | --------------------------------------------------- |
9494
| Go 1.12 | [[email protected]](https://github.com/golang/tools/releases/tag/gopls%2Fv0.7.5) |
9595
| Go 1.15 | [[email protected]](https://github.com/golang/tools/releases/tag/gopls%2Fv0.9.5) |
96+
| Go 1.17 | [[email protected]](https://github.com/golang/tools/releases/tag/gopls%2Fv0.11.0) |
9697

9798
Our extended support is enforced via [continuous integration with older Go
9899
versions](doc/contributing.md#ci). This legacy Go CI may not block releases:

gopls/doc/commands.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,9 @@ Args:
267267
"URI": string,
268268
// The module path to remove.
269269
"ModulePath": string,
270+
// If the module is tidied apart from the one unused diagnostic, we can
271+
// run `go get module@none`, and then run `go mod tidy`. Otherwise, we
272+
// must make textual edits.
270273
"OnlyDiagnostic": bool,
271274
}
272275
```

0 commit comments

Comments
 (0)