1
0
mirror of https://github.com/golang/go synced 2024-11-06 07:26:10 -07:00
Commit Graph

48492 Commits

Author SHA1 Message Date
Bryan C. Mills
f753d7223e doc/go1.17: resolve TODO for cmd/cover
Updates #32211

Change-Id: Ie38e831fcf557534023afd552d9394fe9e055caa
Reviewed-on: https://go-review.googlesource.com/c/go/+/325909
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
2021-06-08 19:41:01 +00:00
Cherry Mui
5b350505da [dev.typeparams] cmd/compile: remove variadic defer calls
Now that defer wrapping is used, deferred function is always
argumentless. Remove the code handling arguments.

This CL is mostly removing the fallback code path. There are more
cleanups to be done, in later CLs.

Change-Id: If6c729d3055c7a507cb1f1a000f5bbd3ad7ff235
Reviewed-on: https://go-review.googlesource.com/c/go/+/325914
Trust: Cherry Mui <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
2021-06-08 19:34:52 +00:00
Bryan C. Mills
9498b0155d cmd/go: in Go 1.17+ modules, add indirect go.mod dependencies separately from direct ones
Fixes #45965

Change-Id: If5c0d7b29e9f81be0763f3fa68051d4ef5419990
Reviewed-on: https://go-review.googlesource.com/c/go/+/325922
Trust: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
2021-06-08 19:32:28 +00:00
Filippo Valsorda
949f00cebe doc/go1.17: add release notes for crypto packages
For #44513

Change-Id: I459b3a4f9936eaa2c09888177f91176140d04280
Reviewed-on: https://go-review.googlesource.com/c/go/+/325649
Trust: Filippo Valsorda <filippo@golang.org>
Trust: Katie Hockman <katie@golang.org>
Reviewed-by: Roland Shoemaker <roland@golang.org>
Reviewed-by: Katie Hockman <katie@golang.org>
2021-06-08 18:05:45 +00:00
Bryan C. Mills
0fb3e2c184 doc/go1.17: add a release note for the '-compat' flag to 'go mod tidy'
Updates #46141

Change-Id: I7a6a84f816e3db19bb492f862366a29dc46ed2ee
Reviewed-on: https://go-review.googlesource.com/c/go/+/325910
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
2021-06-08 17:24:39 +00:00
Cherry Mui
a9de78ac88 [dev.typeparams] cmd/compile, runtime: always enable defer/go wrapping
Hardwire regabidefers to true. Remove it from GOEXPERIMENTs.

Fallback paths are not cleaned up in this CL. That will be done
in later CLs.

Change-Id: Iec1112a1e55d5f6ef70232a5ff6e702f649071c4
Reviewed-on: https://go-review.googlesource.com/c/go/+/325913
Trust: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
2021-06-08 17:03:39 +00:00
Cherry Mui
e58bddde70 [dev.typeparams] internal/goexperiment: regenerate generated files
Rerun the generator. exp_regabi_{on,off}.go are gone, as "regabi"
itself is not a goexperiment that we test at run time (the
sub-experiments are).

Change-Id: Ic1f31b4ef2769a143f768e1b3dc7221041aafca9
Reviewed-on: https://go-review.googlesource.com/c/go/+/325912
Trust: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2021-06-08 16:51:44 +00:00
Cuong Manh Le
2169deb352 cmd/compile: use t.AllMethods when sorting typesByString
For interface types, t.Methods contains only unexpanded method set, i.e
exclusive of interface embedding. Thus, we can't use it to detect an
interface contains embedding empty interface, like in:

	type EI interface{}

	func f() interface{ EI } {
		return nil
	}

At the time we generate runtime types, we want to check against the full
method set of interface instead.

Fixes #46386

Change-Id: Idff53ad39276be6632eb5932b76e855c15cbdd2e
Reviewed-on: https://go-review.googlesource.com/c/go/+/323649
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2021-06-08 12:17:50 +00:00
Matthew Dempsky
c20bcb6488 runtime: remove out-of-date comments about frame skipping
skipPleaseUseCallersFrames was removed in CL 152537.

Change-Id: Ide47feec85a33a6fb6882e16baf9e21492521640
Reviewed-on: https://go-review.googlesource.com/c/go/+/325949
Trust: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2021-06-08 05:02:19 +00:00
Robert Griesemer
0c40cb4a07 [dev.typeparams] cmd/compile/internal/types2: provide valid signature in errors involving method expressions
This is an adjusted port of a similar fix in https://golang.org/cl/324733.

Fixes #46583.

Change-Id: Ica1410e4de561e64e58b753e3da04b32156cbaf6
Reviewed-on: https://go-review.googlesource.com/c/go/+/325369
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2021-06-08 01:17:12 +00:00
Matthew Dempsky
39c39ae52f doc: document Go 1.17 language changes
Fixes #46020.

Change-Id: Iadf9a0ac4a8863e17155d6ba1af2cc497634a634
Reviewed-on: https://go-review.googlesource.com/c/go/+/325870
Trust: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
2021-06-07 23:44:22 +00:00
Dan Scales
74d46381b2 [dev.typeparams] cmd/compile: do extra markObjects during iexport to deal with generics
markInlBody/markObject/markType don't fully work as they stand for
generic functions/methods, since markInlBody can't understand method
calls on generic types. Those method calls will be resolved to concrete
methods in a full instantiation, but markInlBody on a generic
function/method can't understand those method calls. So, we won't
necessarily cause export of the appropriate extra method/function bodies
needed for inlining in an instantiated function.

One way to do this is just to make sure that we call markType
on all generic types that are exported (whether explicitly exported via
a capitalized name or unexported types that are referenced by a generic
function body). That way, we will call markInlBody on all possible
generic methods that might be called.

Fixes the current problem for i386-softfloat builds on dev.typeparams.

Change-Id: I2d3625d26042296731bd3c44ba1938aa194d527e
Reviewed-on: https://go-review.googlesource.com/c/go/+/325329
Run-TryBot: Dan Scales <danscales@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Trust: Dan Scales <danscales@google.com>
2021-06-07 22:44:30 +00:00
Ian Lance Taylor
dc8b558951 cmd/dist: pass -Wno-lto-type-mismatch in swig_callback_lto
Fixes #46557

Change-Id: I95200ddd60e2879db15dd7353c2152b515c89020
Reviewed-on: https://go-review.googlesource.com/c/go/+/324909
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
2021-06-07 21:18:03 +00:00
Ian Lance Taylor
909dd5e010 strconv: ParseFloat: always return ErrSyntax for bad syntax
Previously we would sometimes return ErrRange if the parseable part of
the floating point number was out of range.

Fixes #46628

Change-Id: I15bbbb1e2a56fa27c19fe25ab5554d988cbfd9d2
Reviewed-on: https://go-review.googlesource.com/c/go/+/325750
Trust: Ian Lance Taylor <iant@golang.org>
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2021-06-07 21:12:46 +00:00
Keith Randall
ccfb0ce8df [dev.typeparams] cmd/compile: convert generic values to interface type using dictionary
When converting a variable of generic type to an interface, use the
entry in the dictionary for the type field instead of using the
compile-time type (which we only have when fully stenciling).

Note: this isn't all the conversions. Conversions often get processed
in the ir.OCALL case. Those aren't handled yet.

Change-Id: I9a6a4c572e3c54a8e8efad98365184dbb94c4487
Reviewed-on: https://go-review.googlesource.com/c/go/+/325330
Trust: Keith Randall <khr@golang.org>
Trust: Dan Scales <danscales@google.com>
Reviewed-by: Dan Scales <danscales@google.com>
2021-06-07 21:12:23 +00:00
Keith Randall
cf4b6dc48e [dev.typeparams] cmd/compile: allow conversions from type parameter to interface
When converting from a type param to an interface, allow it if
the type bound implements that interface.

Query: some conversions go through this path, some use another path?
The test does

   var i interface{foo()int} = x

but

   i := (interface{foo()int})(x)

works at tip.

Change-Id: I84d497e5228c0e1d1c9d76ffebaedce09dc45e8e
Reviewed-on: https://go-review.googlesource.com/c/go/+/325409
Trust: Keith Randall <khr@golang.org>
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Dan Scales <danscales@google.com>
2021-06-07 19:53:38 +00:00
Keith Randall
bcb3927cb5 [dev.typeparams] cmd/compile: introduce IsTypeParam() helper
better than Kind() == types.TTYPEPARAM

Change-Id: I4f35a177cd0cda3be615a92b7b2af1b5a60a3bbc
Reviewed-on: https://go-review.googlesource.com/c/go/+/325410
Trust: Keith Randall <khr@golang.org>
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Dan Scales <danscales@google.com>
2021-06-07 19:51:26 +00:00
Gerrit Code Review
f0c97219a3 Merge "[dev.typeparams] all: merge master (8212707) into dev.typeparams" into dev.typeparams 2021-06-07 19:48:09 +00:00
Dan Scales
201d55e637 [dev.typeparams] cmd/compile: create .dict Param in the package of the instantiated function
The instantiated functions are created in the source package of the
generic function, so all lookups of symbols should be relative to that
package, so all symbols are consistently in the source package.

Fixes #46575

Change-Id: Iba67b2ba8014a630c5d4e032c0f2f2fbaaedce65
Reviewed-on: https://go-review.googlesource.com/c/go/+/325529
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2021-06-07 19:34:39 +00:00
Matthew Dempsky
0e39cdc0e9 [dev.typeparams] all: merge master (8212707) into dev.typeparams
Conflicts:

- src/go/internal/gcimporter/iimport.go

  CL 325429 and CL 319931 made unrelated changes to adjacent lines

Merge List:

+ 2021-06-07 8212707871 crypto/elliptic: update P-521 docs to say it's constant-time
+ 2021-06-07 7406180012 fmt: split package documentation into more sections
+ 2021-06-07 e3176bbc3e crypto/tls: fix typo in Config.NextProtos docs
+ 2021-06-05 e1fa26026d spec: improve wording consistency by eliminating "specifier"
+ 2021-06-05 f490134126 spec: improve wording by choosing an official term "keyword"
+ 2021-06-05 e3cb381704 go/internal/gcimporter: don't waste CPU copying bytes in `io.ReadAll`
+ 2021-06-05 9d669ed47a misc/cgo/errors: use expected column numbers
+ 2021-06-04 95939e8de7 cmd/compile/internal/abi: fix typo in comment
+ 2021-06-04 831f9376d8 net/http: fix ResponseWriter.ReadFrom with short reads
+ 2021-06-04 3a9d906edc os: avoid finalizer race in windows process object
+ 2021-06-04 105c5b50e0 os: terminate windows processes via handle directly
+ 2021-06-04 79cd407f88 syscall: regenerate zsyscall_windows.go
+ 2021-06-04 c6b6211229 doc/go1.17: document testing changes for Go 1.17
+ 2021-06-04 0214440075 syscall: do not pass console handles to PROC_THREAD_ATTRIBUTE_HANDLE_LIST on Windows 7
+ 2021-06-04 962d5c997a cmd/compile,go/types: restrict use of unsafe.{Add,Slice} to go1.17 or newer
+ 2021-06-04 b29b123e07 cmd/compile: remove spurious ir.Dump
+ 2021-06-03 6d98301114 cmd/link: use correct alignment in PE DWARF sections
+ 2021-06-03 e0d029f758 runtime: avoid gp.lockedm race in exitsyscall0
+ 2021-06-02 dd7ba3ba2c net: don't rely on system hosts in TestCVE202133195
+ 2021-06-02 4f572d7076 io/fs: minor corrections to Sub docs
+ 2021-06-02 e11d14225c doc/go1.17: remove runtime section
+ 2021-06-02 6e189afd3e doc/go1.17: mention SYS_WAIT6/WEXITED on NetBSD
+ 2021-06-02 ff9f5fb859 cmd/link: recognize clang linker error in testCGOLTO
+ 2021-06-02 1c6a2ea2ea doc/go1.17: document time changes for Go1.17
+ 2021-06-02 d743e67e06 doc/go1.17: document flag changes for Go 1.17
+ 2021-06-02 dc8f87b749 runtime/internal/sys: generate //go:build lines in gengoos.go
+ 2021-06-02 84c0e5d47f cmd/link: move issue 43830 tests out of TestScript
+ 2021-06-02 cae68700cc runtime: fix formatting
+ 2021-06-01 567ee865f6 cmd/go: add declaration to cgo_lto_issue43830 test
+ 2021-06-01 24e9707cbf cmd/link, cmd/cgo: support -flto in CFLAGS

Change-Id: I9ef88e7de0f8b1841ed9604b613b41672df67e71
2021-06-07 12:27:36 -07:00
Rob Findley
7c8a5be2d6 [dev.typeparams] go/types: factor out constraint satisfaction check
This is a port of CL 322070 to go/types, adjusted for the different
error reporting API.

Change-Id: I75eafe015b5b00554116527ea021e7a5f9e0343b
Reviewed-on: https://go-review.googlesource.com/c/go/+/324759
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2021-06-07 17:29:52 +00:00
Rob Findley
7497e57a39 [dev.typeparams] go/types: simplify Interface accessors
This is a straightforward port of CL 321850 to go/types.

Change-Id: I719c19b8839390fdfa961255c6f1e79561cda6e6
Reviewed-on: https://go-review.googlesource.com/c/go/+/324757
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2021-06-07 17:07:23 +00:00
Rob Findley
2f26adc232 [dev.typeparams] go/types: re-use existing code for Interface.Complete
This is a port of CL 321751 to go/types, adjusted to use token.Pos, and
to exclude a missing position from a panic message (an unresolved
comment on the original CL).

Change-Id: I5814067aecb67aca9d73f2093fb6004b769924f3
Reviewed-on: https://go-review.googlesource.com/c/go/+/324756
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2021-06-07 17:07:10 +00:00
Rob Findley
1395952075 [dev.typeparams] go/types: add Named.SetTParams and Named.Orig methods
This is a port of CL 309832 to go/types, adjusted to not export the new
API and to amend TestSizeof.

Change-Id: I67efd3ba9b921c8431528eba1cd88ec1f41898bb
Reviewed-on: https://go-review.googlesource.com/c/go/+/324755
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2021-06-07 17:06:56 +00:00
Rob Findley
991dca0112 [dev.typeparams] go/types: move signature checking into separate file
This is a port of CL 321590 to go/types. Specifically, the same checker
methods were moved.

Change-Id: If4522d316f29c6b6f887580aa037e6b6dedbb6ac
Reviewed-on: https://go-review.googlesource.com/c/go/+/324754
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2021-06-07 17:06:42 +00:00
Filippo Valsorda
8212707871 crypto/elliptic: update P-521 docs to say it's constant-time
This is true since CL 315274.

Also adjust the P-256 note, since Add, Double, and IsOnCurve use the
generic, non-constant-time implementation.

Change-Id: I4b3b340f65bce91dcca30bcf86456cc8ce4dd4bb
Reviewed-on: https://go-review.googlesource.com/c/go/+/325650
Trust: Filippo Valsorda <filippo@golang.org>
Trust: Katie Hockman <katie@golang.org>
Run-TryBot: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Katie Hockman <katie@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
2021-06-07 15:19:57 +00:00
Branden J Brown
7406180012 fmt: split package documentation into more sections
The package-level documentation on fmt previously had only two formal
sections, for printing and scanning. Because of this, the section on
printing was very long, including some pseudo-sections describing
particular features. This feature makes those pseudo-sections into
proper sections, both to improve readability and so that those sections
have hyperlinks on documentation sites.

Fixes #46522

Change-Id: I38b7bc3447610faca446051da235edcbbd063f61
Reviewed-on: https://go-review.googlesource.com/c/go/+/324349
Reviewed-by: Rob Pike <r@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Tobias Klauser <tobias.klauser@gmail.com>
2021-06-07 15:17:48 +00:00
Filippo Valsorda
e3176bbc3e crypto/tls: fix typo in Config.NextProtos docs
Change-Id: I916df584859595067e5e86c35607869397dbbd8c
Reviewed-on: https://go-review.googlesource.com/c/go/+/325651
Trust: Filippo Valsorda <filippo@golang.org>
Run-TryBot: Filippo Valsorda <filippo@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
2021-06-07 15:16:23 +00:00
Robert Griesemer
c23294d6b3 [dev.typeparams] cmd/compile/internal/types2: return Universe for ((*Package)(nil)).Scope()
For #46594.

Change-Id: I53776cbdc1b8f6da511abe2c6659a7313d7a163a
Reviewed-on: https://go-review.googlesource.com/c/go/+/325469
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2021-06-06 17:31:50 +00:00
Matthew Dempsky
a5be3eaee2 [dev.typeparams] cmd/compile: refactor export writing
This CL reorganizes export writing in preparation for unified IR:

1. It moves dumpexport into noder as noder.WriteExports so that it can
be extended to include unified IR's export data.

2. Adds an "extensions" flag to typecheck.WriteExports to control
whether the compiler-only extension data (e.g., function bodies and
linker symbol info) is included in the exports.

3. It moves the gc.exporter type into typecheck and renames it to
"crawler". The type originated as the implementation of
the (pre-iexport) binary exporter, but since the removal of bexport
it's been relegated to simply crawling the exported functions/bodies
graph to identify which inline bodies need to be included.

4. It changes inline.Inline_Flood into the method crawler.markInlBody.
Inline_Flood doesn't actually have anything to do with the rest of
inlining; its current name and location are just historical quirks.

Passes toolstash -cmp.

Change-Id: I6445e2de9d3ce500a3aded5a8e20b09f46d23dbc
Reviewed-on: https://go-review.googlesource.com/c/go/+/325212
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Trust: Matthew Dempsky <mdempsky@google.com>
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2021-06-05 23:29:09 +00:00
Matthew Dempsky
4c072c94dc [dev.typeparams] cmd/compile: refactor import reading
This CL restructures the gcimports importer to mmap the export data
into memory as a string, and then pass that same string to both the
typecheck and types2 importers.

This is primarily motivated by preparation for unified IR; but it
should also improve performance (fewer string copies) and reduces
divergance between the two importers.

Passes toolstash -cmp.

Change-Id: I397f720693e9e6360bfcb5acb12609ab339d251f
Reviewed-on: https://go-review.googlesource.com/c/go/+/325210
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Trust: Matthew Dempsky <mdempsky@google.com>
Trust: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2021-06-05 23:28:52 +00:00
DQNEO
e1fa26026d spec: improve wording consistency by eliminating "specifier"
The word "specifier" is used once only here and technically not defined.

Change-Id: Ifc9f0582f4eb3c3011ba60d8008234de511d4be6
Reviewed-on: https://go-review.googlesource.com/c/go/+/323730
Reviewed-by: Robert Griesemer <gri@golang.org>
Trust: Ian Lance Taylor <iant@golang.org>
Trust: Robert Griesemer <gri@golang.org>
2021-06-05 19:52:26 +00:00
DQNEO
f490134126 spec: improve wording by choosing an official term "keyword"
Replace "reserved word" by "keyword" as the latter is the official term.

Change-Id: I9f269759b872026034a9f47e4a761cff2d348ca0
Reviewed-on: https://go-review.googlesource.com/c/go/+/323729
Reviewed-by: Robert Griesemer <gri@golang.org>
Trust: Ian Lance Taylor <iant@golang.org>
Trust: Robert Griesemer <gri@golang.org>
2021-06-05 19:51:45 +00:00
Sergey Zagursky
e3cb381704 go/internal/gcimporter: don't waste CPU copying bytes in io.ReadAll
`io.ReadAll` dynamically reallocates byte slice because it doesn't know
its size in advance. We don't need to read an entire file into memory
and therefore may use `bufio.Reader` to read its contents.

Fixes #46564

Change-Id: Id504b1512662b6dea4775d523455896fa4162ab3
Reviewed-on: https://go-review.googlesource.com/c/go/+/325429
Reviewed-by: Dominik Honnef <dominik@honnef.co>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Trust: Matthew Dempsky <mdempsky@google.com>
Trust: Dominik Honnef <dominik@honnef.co>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-06-05 09:28:43 +00:00
Ian Lance Taylor
9d669ed47a misc/cgo/errors: use expected column numbers
The test was using the wrong column numbers, and was erroneously
passing because there happened to be line numbers that matched those
column numbers. Change the test harness to require the expected line
number for the ERROR HERE regexp case, so that this doesn't happen again.

Also rename a couple of variables in the test to avoid useless
redeclaration errors.

Fixes #46534

Change-Id: I2fcbf5e379c346de5346035c73d174a3980c0927
Reviewed-on: https://go-review.googlesource.com/c/go/+/324970
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2021-06-05 04:40:03 +00:00
Matthew Dempsky
4e001a8d9e [dev.typeparams] runtime/race: make test compatible with types2
types2 correctly distinguishes variable assignment from use even
within function literals. Whatever the outcome of #3059, the test
cases in runtime/race need to be fixed to accomodate that.

Change-Id: Ibe3547f07b681ff41225caabaf050872a48c98d1
Reviewed-on: https://go-review.googlesource.com/c/go/+/325030
Trust: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2021-06-05 02:01:10 +00:00
Robert Griesemer
246a5570be [dev.typeparams] cmd/compile: rename (types2.Inferred.)Targs to TArgs
This is consistent with Named.TArgs.

This is a straight-forward port of https://golang.org/cl/321289
plus the necessary compiler noder changes.

Change-Id: I50791e5abe0d7f294293bed65cebc8dde8bf8c06
Reviewed-on: https://go-review.googlesource.com/c/go/+/325010
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2021-06-05 01:52:30 +00:00
Robert Griesemer
692399fbaa [dev.typeparams] cmd/compile/internal/syntax: not all index expressions can be instantiated types
An index expression followed by an opening "{" may indicate
a composite literal but only if the index expression can be
a type. Exclude cases where the index expression cannot be
a type (e.g. s[0], a[i+j], etc.).

This leads to a better error message in code that is erroneous.

Fixes #46558.

Change-Id: Ida9291ca30683c211812dfb95abe4969f44c474f
Reviewed-on: https://go-review.googlesource.com/c/go/+/325009
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2021-06-05 01:52:24 +00:00
Matthew Dempsky
a94e4f5a85 [dev.typeparams] cmd/compile: point StructKeyExpr at the types.Field
When constructing struct literals, importers need a way to specify
precisely which field to initialize without worrying about visibility
or those fields being blank. (A blank field doesn't actually need to
be initialized, but the expression needs to be evaluated still, and
with the right order-of-operations.)

This CL changes StructKeyExpr's Field field to point directly to the
corresponding types.Field, rather than merely holding a copy of its
Sym and Offset. This is akin to past changes to add
SelectorExpr.Selection.

Change-Id: I95b72b1788f73206fcebc22b456cf6b1186db6a7
Reviewed-on: https://go-review.googlesource.com/c/go/+/325031
Trust: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-06-04 21:07:19 +00:00
sryoya
95939e8de7 cmd/compile/internal/abi: fix typo in comment
Change-Id: I196045314b2b0e908d7b31ac0cea5b25404f3ee0
Reviewed-on: https://go-review.googlesource.com/c/go/+/325249
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Trust: Keith Randall <khr@golang.org>
2021-06-04 20:51:27 +00:00
Keith Randall
bad388744b [dev.typeparams] cmd/compile: handle dictionaries for top-level instantiations
There's no outer function in these cases, so we won't be reading
the dictionary as a subdictionary from the outer scope's dictionary.
It will always be a compile-time constant.

Change-Id: I754b126652a6ffb62255734d53fcec29d77cfa9e
Reviewed-on: https://go-review.googlesource.com/c/go/+/324949
Trust: Keith Randall <khr@golang.org>
Trust: Dan Scales <danscales@google.com>
Reviewed-by: Dan Scales <danscales@google.com>
2021-06-04 18:11:39 +00:00
Dan Scales
de61465156 [dev.typeparams] cmd/compile: allow inlining in instantiated functions
Change markType to scan generic types and methods, so that inlineable
functions inside generic functions/methods will be properly marked for
export, which means inlining inside instantiated functions will work
correctly.

Also, fix handling of closures for instantiated functions. Some code
needs to be adjusted, since instantiated functions/methods are compiled
as if in the package of the source generic function/type, rather than in
the local package. When we create the closure struct, we want to make
sure that the .F field has the same package as the other fields for the
closure variables. Also, we need to disable a check in tcCompLit() when
being done for an instantiated function, since fields of the closure
struct will be from the source package, not the local package.

Re-enabled part of the orderedmapsimp test that was disabled because of
these issues.

Change-Id: Ic4dba8917da0a36b17c0bdb69d6d6edfdf14104a
Reviewed-on: https://go-review.googlesource.com/c/go/+/324331
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Dan Scales <danscales@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
2021-06-04 17:48:10 +00:00
Damien Neil
831f9376d8 net/http: fix ResponseWriter.ReadFrom with short reads
CL 249238 changes ResponseWriter.ReadFrom to probe the source with
a single read of sniffLen bytes before writing the response header.
If the source returns less than sniffLen bytes without reaching
EOF, this can cause Content-Type and Content-Length detection to
fail.

Fix ResponseWrite.ReadFrom to copy a full sniffLen bytes from
the source as a probe.

Drop the explicit call to w.WriteHeader; writing the probe will
trigger a WriteHeader call.

Consistently use io.CopyBuffer; ReadFrom has already acquired a
copy buffer, so it may as well use it.

Fixes #44953.

Change-Id: Ic49305fb827a2bd7da4764b68d64b797b5157dc0
Reviewed-on: https://go-review.googlesource.com/c/go/+/301449
Trust: Damien Neil <dneil@google.com>
Run-TryBot: Damien Neil <dneil@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2021-06-04 17:33:24 +00:00
Jason A. Donenfeld
3a9d906edc os: avoid finalizer race in windows process object
If proc.Release is called concurrently, a handle will be double-freed.

Change-Id: I0c0c32e312e07bc8615e0bf9e9b691214444d8d5
Reviewed-on: https://go-review.googlesource.com/c/go/+/322510
Trust: Jason A. Donenfeld <Jason@zx2c4.com>
Run-TryBot: Jason A. Donenfeld <Jason@zx2c4.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-06-04 17:21:49 +00:00
Jason A. Donenfeld
105c5b50e0 os: terminate windows processes via handle directly
We already have a handle to the process, so use that for termination,
rather than doing a new lookup based on the PID.

Change-Id: I2958c1817f12f3dd783412baacbf629049f6956a
Reviewed-on: https://go-review.googlesource.com/c/go/+/322509
Trust: Jason A. Donenfeld <Jason@zx2c4.com>
Run-TryBot: Jason A. Donenfeld <Jason@zx2c4.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-06-04 17:21:40 +00:00
Cherry Mui
4cf7f5f694 [dev.typeparams] test: test regabidefers in live.go
Previously, live.go is conditioned on not using regabidefers. Now
we have regabidefers enabled by default everywhere, and we may
remove the fallback path in the near future, test that
configuration instead.

Change-Id: Idf910aee323bdd6478bc7a2062b2052d82ce003f
Reviewed-on: https://go-review.googlesource.com/c/go/+/325111
Trust: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
2021-06-04 17:00:48 +00:00
Cherry Mui
3298c749ac [dev.typeparams] runtime: undo go'd closure argument workaround
In CL 298669 we added defer/go wrapping, and, as it is not
allowed for closures to escape when compiling runtime, we worked
around it by rewriting go'd closures to argumentless
non-capturing closures, so it is not a real closure and so not
needed to escape.

Previous CL removes the restriction. Now we can undo the
workaround.

Updates #40724.

Change-Id: Ic7bf129da4aee7b7fdb7157414eca943a6a27264
Reviewed-on: https://go-review.googlesource.com/c/go/+/325110
Trust: Cherry Mui <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
2021-06-04 17:00:32 +00:00
Cherry Mui
46beeed0ac [dev.typeparams] cmd/compile: allow go'd closure to escape when compiling runtime
When compiling runtime, we don't allow closures to escape,
because we don't want (implicit) allocations to occur when it is
not okay to allocate (e.g. in the allocator itself). However, for
go statement, it already allocates a new goroutine anyway. It is
okay to allocate the closure. Allow it.

Also include the closure's name when reporting error.

Updates #40724.

Change-Id: Id7574ed17cc27709609a059c4eaa67ba1c4436dc
Reviewed-on: https://go-review.googlesource.com/c/go/+/325109
Trust: Cherry Mui <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
2021-06-04 17:00:19 +00:00
Dan Scales
8e6dfe1b31 [dev.typeparams] cmd/compile: export/import of recursive generic types.
Deal with export/import of recursive generic types. This includes
typeparams which have bounds that reference the typeparam.

There are three main changes:

  - Change export/import of typeparams to have an implicit "declaration"
    (doDecl). We need to do a declaration of typeparams (via the
    typeparam's package and unique name), because it may be referenced
    within its bound during its own definition.

  - We delay most of the processing of the Instantiate call until we
    finish the creation of the top-most type (similar to the way we
    delay CheckSize). This is because we can't do the full instantiation
    properly until the base type is fully defined (with methods). The
    functions delayDoInst() and resumeDoInst() delay and resume the
    processing of the instantiations.

  - To do the full needed type substitutions for type instantiations
    during import, I had to separate out the type subster in stencil.go
    and move it to subr.go in the typecheck package. The subster in
    stencil.go now does node substitution and makes use of the type
    subster to do type substitutions.

Notable other changes:
 - In types/builtins.go, put the newly defined typeparam for a union type
   (related to use of real/imag, etc.) in the current package, rather
   than the builtin package, so exports/imports work properly.

 - In types2, allowed NewTypeParam() to be called with a nil bound, and
   allow setting the bound later. (Needed to import a typeparam whose
   bound refers to the typeparam itself.)

 - During import of typeparams in types2 (importer/import.go), we need
   to keep an index of the typeparams by their package and unique name
   (with id). Use a new map typParamIndex[] for that. Again, this is
   needed to deal with typeparams whose bounds refer to the typeparam
   itself.

 - Added several new tests absdiffimp.go and orderedmapsimp.go. Some of
   the orderemapsimp tests are commented out for now, because there are
   some issues with closures inside instantiations (relating to unexported
   names of closure structs).

 - Renamed some typeparams in test value.go to make them all T (to make
   typeparam uniqueness is working fine).

Change-Id: Ib47ed9471c19ee8e9fbb34e8506907dad3021e5a
Reviewed-on: https://go-review.googlesource.com/c/go/+/323029
Trust: Dan Scales <danscales@google.com>
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2021-06-04 16:43:27 +00:00
Bryan C. Mills
79cd407f88 syscall: regenerate zsyscall_windows.go
The declaration order in CL 319310 does not match what the generator
produces from scratch. That currently causes
cmd/internal/moddeps.TestAllDependencies to fail, since it is
explicitly checking for that kind of skew.

Updates #45914

Change-Id: If2a9cabc3d54e21deba7cb438fa364df205f38ac
Reviewed-on: https://go-review.googlesource.com/c/go/+/325112
Trust: Bryan C. Mills <bcmills@google.com>
Trust: Jason A. Donenfeld <Jason@zx2c4.com>
Reviewed-by: Jason A. Donenfeld <Jason@zx2c4.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-06-04 15:53:06 +00:00