]> Cypherpunks.ru repositories - gostls13.git/log
gostls13.git
2 years ago[dev.boringcrypto] all: merge master into dev.boringcrypto
Chressie Himpel [Tue, 8 Feb 2022 09:31:51 +0000 (10:31 +0100)]
[dev.boringcrypto] all: merge master into dev.boringcrypto

Change-Id: If6b68df0c90464566e68de6807d15f4b8bec6219

2 years agocrypto/elliptic: use go:embed for the precomputed p256 table
Daniel Martí [Mon, 24 Jan 2022 15:26:33 +0000 (15:26 +0000)]
crypto/elliptic: use go:embed for the precomputed p256 table

go.dev/cl/339591 changed the code generation to use a constant string,
so that the ~88KiB table can be marked read-only.

The compiled code became a lot better, but unfortunately,
the generated Go source became significantly more inefficient.
The numbers below compare "gofmt -l" and "go tool compile" of said file,
where "old" is the file as of Go 1.17, and "new" as of master in 2022/01/19:

name           old time/op         new time/op         delta
Gofmt                 22.8ms ± 6%        898.5ms ± 3%  +3837.32%  (p=0.000 n=8+8)
GoToolCompile         26.9ms ± 2%        371.1ms ± 2%  +1278.36%  (p=0.000 n=7+8)

name           old user-time/op    new user-time/op    delta
Gofmt                 25.7ms ±65%        897.1ms ± 3%  +3383.86%  (p=0.000 n=8+8)
GoToolCompile         35.1ms ±26%        367.2ms ± 3%   +945.80%  (p=0.000 n=8+8)

name           old sys-time/op     new sys-time/op     delta
Gofmt                6.42ms ±276%         7.23ms ±38%       ~     (p=0.412 n=8+6)
GoToolCompile        9.20ms ±100%        13.90ms ±53%       ~     (p=0.105 n=8+8)

name           old peak-RSS-bytes  new peak-RSS-bytes  delta
Gofmt                 9.11MB ± 7%        22.79MB ± 1%   +150.23%  (p=0.000 n=8+8)
GoToolCompile         25.1MB ± 2%         68.6MB ± 2%   +173.57%  (p=0.000 n=8+8)

"+" operators are binary expressions at the syntax tree level,
which are represented by packages like go/ast as roughly:

struct {
X  Expr
Op Token
Y  Expr
}

Since each node is a pointer, chains of "+" operators act like linked lists.
The generated code has about 14k lines, and 8 "+" operators per line,
meaning that we end up with a linked list with over 11k elements.

This explains the slow-down in gofmt; the printer must walk said list,
and it does so more than once to work out how to format it.
It seems like the compiler is similarly affected by the huge length.

To remedy the effect of the linked list, use go:embed instead.
This results in the same string variable with the binary table,
but it greatly reduces the amount of syntax and its cost above.
We still keep the generator around, but modified so it produces the
binary file to be embedded rather than a large Go file.

Finally, we update go/build/deps_test.go to allow crypto/elliptic to
depend on embed; it's a tiny package and crypto/elliptic was already
manually embedding assets via code generation.
The change to deps_test.go was briefly discussed in the issue below.

Fixes #50995.

Change-Id: I0c8b432710e971a296a2e9c99147cc2cad9662aa
Reviewed-on: https://go-review.googlesource.com/c/go/+/380475
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
Trust: Daniel Martí <mvdan@mvdan.cc>
Trust: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
2 years agodoc/go1.18: mention linker improvements
Josh Bleecher Snyder [Mon, 7 Feb 2022 23:23:22 +0000 (15:23 -0800)]
doc/go1.18: mention linker improvements

Change-Id: I12cad608448ddd17a5da2b1d1209007102d892a7
Reviewed-on: https://go-review.googlesource.com/c/go/+/383914
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2 years agogo/parser: fix incorrect resolution of receiver type parameters
Robert Findley [Tue, 1 Feb 2022 22:13:53 +0000 (17:13 -0500)]
go/parser: fix incorrect resolution of receiver type parameters

Declare receiver type parameters in the function scope, but don't
resolve them (for now), as ast.Object.Decl is not documented to hold
*ast.Idents. This avoids incorrect resolution of identifiers to names
outside the function scope.

Also make tracing and error reporting more consistent.

For golang/go#50956

Change-Id: I8cd61dd25f4c0f6b974221599b00e23d8da206a1
Reviewed-on: https://go-review.googlesource.com/c/go/+/382247
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agogo/types, types2: ensure we have an interface before checking constraints
Robert Griesemer [Mon, 7 Feb 2022 19:28:14 +0000 (11:28 -0800)]
go/types, types2: ensure we have an interface before checking constraints

Due to delayed computation of constraint type sets it is possible that
a type argument is checked against a constraint before that constraint
has been wrapped into an implicit interface (if needed).

When the type checker is about to check whether a type argument
implements a constraint, it's always safe to force wrapping of
a constraint in an implicit interface (if necessary) before doing
the implements check.

Also, use a better position for tracing output related to constraint
type set computation.

Fixes #51048.

Change-Id: I52fecbf57814f09b62762452d7e17c2a230fdd59
Reviewed-on: https://go-review.googlesource.com/c/go/+/383834
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2 years agogo/types, types2: record correct argument type for cap, len
Robert Griesemer [Sat, 5 Feb 2022 00:57:43 +0000 (16:57 -0800)]
go/types, types2: record correct argument type for cap, len

Record the actual argument type for a cap/len call, not the
underlying type.

Fixes #51055.

Change-Id: Ia0e746a462377f030424ccaec0babf72b78da420
Reviewed-on: https://go-review.googlesource.com/c/go/+/383474
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2 years agoruntime: don't assume that 0.25 * 100 is representable as int
Ian Lance Taylor [Mon, 7 Feb 2022 03:33:03 +0000 (19:33 -0800)]
runtime: don't assume that 0.25 * 100 is representable as int

For the gofrontend, it's not; there are some trailing one bits,
which is permitted by the spec.

Change-Id: I58f5a5347068bb488306ec8e73da7c59376f1ae1
Reviewed-on: https://go-review.googlesource.com/c/go/+/383635
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2 years agodoc/go1.18: mention new x/exp generic packages
Ian Lance Taylor [Mon, 7 Feb 2022 18:02:30 +0000 (10:02 -0800)]
doc/go1.18: mention new x/exp generic packages

Change-Id: I119cfb1a0da9af89ced78935b8fcdfdb8d9b4ab6
Reviewed-on: https://go-review.googlesource.com/c/go/+/383794
Trust: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2 years agomisc/cgo: fix aliasing bugs in parallel tests that append to shared slices
Bryan C. Mills [Mon, 7 Feb 2022 16:33:30 +0000 (11:33 -0500)]
misc/cgo: fix aliasing bugs in parallel tests that append to shared slices

These tests use a slice to represent the base C compiler command (with
flags). Appending to that slice can cause subtle aliasing bugs, such
as commands that silently corrupt the arguments of other concurrent
commands in parallel tests.

In this change, we explicitly reduce the capacity of the command slice
to force appends to it to always allocate unique new slices.

Fixes #49693

Change-Id: Ide466bf65f12cb6cead3dcba69f513cccb60a160
Reviewed-on: https://go-review.googlesource.com/c/go/+/383754
Trust: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agotest: apply GO_TEST_TIMEOUT_SCALE scaling to test timeouts
Than McIntosh [Wed, 2 Feb 2022 19:09:26 +0000 (14:09 -0500)]
test: apply GO_TEST_TIMEOUT_SCALE scaling to test timeouts

Change run.go to apply the GO_TEST_TIMEOUT_SCALE scaling factor to
test timeouts (mentioned in "-t" clause in test header).

Also with this patch, bump up the timeout for fixedbugs/issue46234.go
from 30 to 45 seconds, to avoid flakes on very slow builders.

Updates #50973.

Change-Id: Icbafa482860e24cc1e72fee53511bcc764d06bf1
Reviewed-on: https://go-review.googlesource.com/c/go/+/382774
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Than McIntosh <thanm@google.com>
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agoos: don't repeat dir argument in CreateTemp error
Ian Lance Taylor [Mon, 7 Feb 2022 03:34:32 +0000 (19:34 -0800)]
os: don't repeat dir argument in CreateTemp error

The dir argument is already in prefix, we shouldn't add it again.

Change-Id: I42a158bec3a43950fce24f57b808da3ad8c5ef5b
Reviewed-on: https://go-review.googlesource.com/c/go/+/383636
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2 years agocmd/dist: skip internal linking tests on arm64
Benny Siegert [Sat, 5 Feb 2022 16:23:26 +0000 (17:23 +0100)]
cmd/dist: skip internal linking tests on arm64

The previous workaround for issue #39466 only disabled this test for
Linux. However, the issue manifests for all arm64 systems with gcc 9.4
and above. The new netbsd-arm64 builder uses NetBSD-current with gcc
10.3, so it fails in the same way.

Updates #39466

Change-Id: I276a99a5e60914e5c22f74a680e461bea17cfe92
Reviewed-on: https://go-review.googlesource.com/c/go/+/383554
Trust: Benny Siegert <bsiegert@gmail.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2 years agoruntime: change sys.PtrSize to goarch.PtrSize in comments
Ian Lance Taylor [Sat, 5 Feb 2022 05:14:13 +0000 (21:14 -0800)]
runtime: change sys.PtrSize to goarch.PtrSize in comments

The code was updated, the comments were not.

Change-Id: If387779f3abd5e8a1b487fe34c33dcf9ce5fa7ff
Reviewed-on: https://go-review.googlesource.com/c/go/+/383495
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agogo/types, types2: use identical missingMethod in both type checkers
Robert Griesemer [Fri, 4 Feb 2022 01:34:43 +0000 (17:34 -0800)]
go/types, types2: use identical missingMethod in both type checkers

Further simplify and regularize Checker.missingMethod and use the
same code in both type checkers.

This enables case-folding lookup for go/types.

Adjusted test case that looks for alternative methods.

Change-Id: I5b8cc598c295c329ff93b1c65787cc6140f0900e
Reviewed-on: https://go-review.googlesource.com/c/go/+/382858
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2 years agogo/types, types2: always use missingMethodReason in checker.Implements
Robert Griesemer [Fri, 4 Feb 2022 00:07:28 +0000 (16:07 -0800)]
go/types, types2: always use missingMethodReason in checker.Implements

Remove special case where we don't have a *Checker and always use
Checker.missingMethodReason in Checker.implements.

Look for zero methods rather than empty interface to exit early
from Checker.missingMethod, and remove the extra test in
Checker.implements.

With this change we get consistent and more detailed error messages
from all places where we do a form of the "implements" test.

To make this possible, allow for the receiver to be nil in
- Checker.sprintf
- Checker.missingMethodReason
- Checker.interfacePtrError
- Checker.funcString

Allowing Checker.sprintf with nil Checker permits further simplifying
in a couple of places.

Change-Id: I0ea7178c9efbcd4a25ded2a66e2b058db52dc4d4
Reviewed-on: https://go-review.googlesource.com/c/go/+/383054
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2 years agogo/types, types2: simplify Checker.typeAssertion, use same code in both type checkers
Robert Griesemer [Thu, 3 Feb 2022 23:03:02 +0000 (15:03 -0800)]
go/types, types2: simplify Checker.typeAssertion, use same code in both type checkers

- Remove the xtyp argument from the Checker.typeAssertion parameter
  list; it was confusing and not needed. Adjusted call sites.

- Simplify logic in Checker.typeAssertion.

- Use the same code in both types2 and go/types, specifically
  use the same error positions.

- Adjust error messages as needed.

This removes another subtle discrepancy between types2 and go/types.
The go/types error messages don't have the have/want appendix for
the affected error messages yet because we don't use case folding
in lookups yet.

Change-Id: Id39f5c473da36c9baad60082f85cf1f34dc26c50
Reviewed-on: https://go-review.googlesource.com/c/go/+/383014
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2 years agogo/types, types2: simplify missingMethodReason
Robert Griesemer [Thu, 3 Feb 2022 05:36:50 +0000 (21:36 -0800)]
go/types, types2: simplify missingMethodReason

Added a funcString helper so we don't need to rewrite strings
with strings.Replace.

Use compiler format for error message about wrong method type;
this removes another unnecessary variation.

Simplify conditions for pointer-to-interface related error:
if one of the involved types is an interface pointer, it can't
have any methods.

Rewrite logic so we don't need all the else-if branches.

Adjusted a test case for types2 accordingly. The go/types version
of this test case has a different error because the implementation
of Checker.typeAssertion is different in the two type checkers
(the types2 version gives errors closer to the 1.17 compiler).

Change-Id: I19e604d7063c3e31e8290bd78384a9f38bb0d740
Reviewed-on: https://go-review.googlesource.com/c/go/+/382694
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2 years agogo/types, types2: fix bug in types2.MissingMethod
Robert Griesemer [Thu, 3 Feb 2022 00:31:26 +0000 (16:31 -0800)]
go/types, types2: fix bug in types2.MissingMethod

Because Checker.missingMethod also looks up methods matching
matching case-folded names, when Checker.missingMethod returns
an alternative method, that method does not automatically have
the wrong type. It may be a method with a different name.

Adjust types2.MissingMethod to check the alternative method
name before reporting a wrong type.

Add API test that verifies (now correct) behavior for this
case.

Ported the code also to go/types, though it was not a bug
there yet because looking up with case-folding is not yet
enabled.

Change-Id: Iaa48808535c9265a9879338ea666c6c021e93a2b
Reviewed-on: https://go-review.googlesource.com/c/go/+/382634
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2 years agogo/types, types2: remove superflous type parameter length checks
Robert Griesemer [Wed, 2 Feb 2022 23:04:58 +0000 (15:04 -0800)]
go/types, types2: remove superflous type parameter length checks

There is no need to check for length equality of type parameter
lists in Checker.missingMethod: the Identical predicate does
this check. Furthermore, we don't have methods with their own
type parameters. Remove the unnecessary (duplicate) code.

Also, update doc string on missingMethod and rename the 2nd
result parameter for clarity, and clarify internal comments.

For go/types, include the same case-folding code as for types2
but leave it disabled or now. Adjust any other differences in
the missingMethod implementation.

With this change, the types2 and go/types code of missingMethod
is identical again except for the disabled case-folding lookup.

No functionality changes.

Preparation for fixing some of the outstanding error reporting issues.

Change-Id: I4778d006c17f4e084ecc2cac7386c68e86aa49eb
Reviewed-on: https://go-review.googlesource.com/c/go/+/382614
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2 years agogo/types, types2: use same method lookup code in both type checkers
Robert Griesemer [Wed, 2 Feb 2022 21:18:56 +0000 (13:18 -0800)]
go/types, types2: use same method lookup code in both type checkers

types2 has some code to handle case-folding when doing method lookups
which was missing in go/types. This change is a first step to match
the implementations. Specifically:

In types2:
- remove the lookupMethodFold names in favor of just lookupMethod,
  but with the foldCase flag (e.g., instead if lookupMethodFold,
  we just use lookupMethod)
- rename checkFold to foldCase everywhere
- add foldCase parameter where it was missing
- moved foldCase paremeter to the end in lookupFieldOrMethod
- no functionality changes

In go/types:
- match function signatures with types2 use
- always provide false as argument for foldCase for now
- no functionality changes

Preparation for fixing some of the outstanding error reporting issues.

Change-Id: If129a5feb89ddf96a3596e8d73b23afa591875a0
Reviewed-on: https://go-review.googlesource.com/c/go/+/382461
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2 years agogo/types, types2: better error messages for expression switches
Robert Griesemer [Wed, 2 Feb 2022 05:43:00 +0000 (21:43 -0800)]
go/types, types2: better error messages for expression switches

Fixes #50965.

Change-Id: I61a74bdb46cf5e72ab94dbe8bd114704282b6211
Reviewed-on: https://go-review.googlesource.com/c/go/+/382354
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2 years agogo/types, types2: better error messages for comparisons
Robert Griesemer [Tue, 1 Feb 2022 05:25:14 +0000 (21:25 -0800)]
go/types, types2: better error messages for comparisons

Refactor Checker.comparison such that its logic is easier to reason
about and so that special cases can be handled more directly.

Use the appropriate operand (of 1st or 2nd operand) for error
reporting (position and type), rather than always using the
first operand.

Use an extra parameter to indicate a switch case
comparison; in this case the error is always reported at
the position of the first operand. (The error messages are
not yet adjusted for switches; see next CL.)

Introduce a new kindString function which is used to print simplified
types in error messages (related to comparisons only): instead of
printing the details of a struct type, we just print "struct" where
the details are not relevant. This matches the 1.17 compiler behavior.

Added a "reportf" parameter to the internal comparable function so we
can report an error cause in addition to the boolean result. Rather
than passing a *string for cause, we pass a function to record the
cause so that we can use the *Checker context for printing (needed
for proper type qualification). This mechanism reports the same
details now as the 1.17 compiler.

Adjusted various tests as needed added new test files.

Fixes #50918.

Change-Id: I1f0e7af22f09db4d31679c667c71a9038a8dc9d2
Reviewed-on: https://go-review.googlesource.com/c/go/+/381964
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2 years agointernal/fuzz: change meaning of "total" in output
Katie Hockman [Fri, 4 Feb 2022 22:02:49 +0000 (17:02 -0500)]
internal/fuzz: change meaning of "total" in output

Fixes #51023

Change-Id: I7dd9f7c696e15ba9c6c887d4c4e0f4d281a82b17
Reviewed-on: https://go-review.googlesource.com/c/go/+/383414
Trust: Katie Hockman <katie@golang.org>
Reviewed-by: Roland Shoemaker <roland@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agotesting: remove TODO and link to fuzz docs
Katie Hockman [Fri, 4 Feb 2022 22:11:18 +0000 (17:11 -0500)]
testing: remove TODO and link to fuzz docs

Change-Id: I3f5ee9629b0b0f3f29a021a656dbf3bca27e582d
Reviewed-on: https://go-review.googlesource.com/c/go/+/383415
Trust: Katie Hockman <katie@golang.org>
Run-TryBot: Katie Hockman <katie@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agocmd/go: preserve LIBRARY_PATH and C_INCLUDE_PATH for script tests
Brandon Bennett [Fri, 4 Feb 2022 19:45:18 +0000 (12:45 -0700)]
cmd/go: preserve LIBRARY_PATH and C_INCLUDE_PATH  for script tests

In bespoke build environments default libraries may be specificied with
LIBRARY_PATH, C_INCLUDE_PATH enviroment variables to overide the system
(i.e glibc). Allow them though to allow cgo testing of these enviroments.

Fixes #50985

Change-Id: I7497a7715d9b635a6ae97efaab94a7ff01cdf8e2
Reviewed-on: https://go-review.googlesource.com/c/go/+/383334
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
Trust: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agocmd/go: accept "-F dir" in compiler flags
Ian Lance Taylor [Fri, 4 Feb 2022 20:22:19 +0000 (12:22 -0800)]
cmd/go: accept "-F dir" in compiler flags

Fixes #51008

Change-Id: I5e47c7be59d4aae1d5059d99231422212cffa23a
Reviewed-on: https://go-review.googlesource.com/c/go/+/383217
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
2 years agointernal/nettrace: fix spelling error
Kevin Burke [Fri, 4 Feb 2022 19:27:17 +0000 (11:27 -0800)]
internal/nettrace: fix spelling error

Change-Id: Ibf51c0687197c0d791916b21cba7f8408aa5300a
Reviewed-on: https://go-review.googlesource.com/c/go/+/383216
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Trust: Kevin Burke <kevin@burke.dev>

2 years agogo/parser, go/types: don't parse type parameters on methods
Robert Findley [Wed, 2 Feb 2022 23:40:27 +0000 (18:40 -0500)]
go/parser, go/types: don't parse type parameters on methods

The go/parser package is updated to report an error on method type
parameters, and to not store them in the AST. Tests are updated
accordingly, and error messages are normalized accross go/parser and the
compiler syntax package.

Before this CL, go/parser would parse type parameters on method
declarations and interface methods, leaving it to go/types to complain.
There are several problems with this:

- Interface Methods and Method declarations do not have type parameters
  in the spec. We try to align the parser with the productions in the
  spec.
- Parsing method type parameters means that downstream libraries
  (go/doc, go/format, etc.) theoretically need to handle them, even
  though they are not part of the language.
- Relatedly, go/types has inconsistent handling of method type
  parameters due to support being removed, leading to the crasher in
  #50427.

It is more consistent and safer to disallow type parameters on methods
in the parser.

Fixes #50427

Change-Id: I555766da0c76c4cf1cfe0baa9416863088088b4e
Reviewed-on: https://go-review.googlesource.com/c/go/+/382538
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agocmd/compile: restrict generics test to -G=3
Keith Randall [Thu, 3 Feb 2022 23:17:00 +0000 (15:17 -0800)]
cmd/compile: restrict generics test to -G=3

Change-Id: Ifdb4f4f4fab8d45847ca525198b3960f87799f0c
Reviewed-on: https://go-review.googlesource.com/c/go/+/383034
Trust: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dan Scales <danscales@google.com>
Trust: Dan Scales <danscales@google.com>

2 years agomisc/cgo/test: disable unhelpful GCC warning
Ian Lance Taylor [Thu, 3 Feb 2022 20:43:48 +0000 (12:43 -0800)]
misc/cgo/test: disable unhelpful GCC warning

GCC 9 warns about a change in the ABI of passing structs with bitfields,
but we don't care.

Fixes #50987

Change-Id: Ica658d04172a42a7be788f94d31a714bb8c4766f
Reviewed-on: https://go-review.googlesource.com/c/go/+/382956
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Benny Siegert <bsiegert@gmail.com>
Trust: Benny Siegert <bsiegert@gmail.com>

2 years agocrypto/x509: support NumericString in DN components
Roland Shoemaker [Fri, 3 Sep 2021 16:56:23 +0000 (09:56 -0700)]
crypto/x509: support NumericString in DN components

Fixes #48171

Change-Id: Ia2e1920c0938a1f8659935a4f725a7e5090ef2c0
Reviewed-on: https://go-review.googlesource.com/c/go/+/347034
Trust: Roland Shoemaker <roland@golang.org>
Run-TryBot: Roland Shoemaker <roland@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
2 years ago[dev.boringcrypto] all: merge master into dev.boringcrypto
Chressie Himpel [Thu, 3 Feb 2022 18:10:54 +0000 (19:10 +0100)]
[dev.boringcrypto] all: merge master into dev.boringcrypto

Change-Id: I18dbf4f9fa7e2334fccedd862a523126cf38164e

2 years agocmd/compile: ensure size is computed for shape types
Keith Randall [Thu, 3 Feb 2022 17:44:21 +0000 (09:44 -0800)]
cmd/compile: ensure size is computed for shape types

Fixes #50993

Change-Id: I5f1bf5a8375c3da3203083b11de26962523ccb36
Reviewed-on: https://go-review.googlesource.com/c/go/+/382874
Trust: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dan Scales <danscales@google.com>
Trust: Dan Scales <danscales@google.com>

2 years agocrypto/elliptic: make IsOnCurve return false for invalid field elements
Filippo Valsorda [Wed, 2 Feb 2022 17:13:17 +0000 (09:13 -0800)]
crypto/elliptic: make IsOnCurve return false for invalid field elements

Thanks to Guido Vranken for reporting this issue.

Fixes #50974
Fixes CVE-2022-23806

Change-Id: I0201c2c88f13dd82910985a495973f1683af9259
Reviewed-on: https://go-review.googlesource.com/c/go/+/382455
Run-TryBot: Filippo Valsorda <filippo@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Trust: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Roland Shoemaker <roland@golang.org>
Reviewed-by: Katie Hockman <katie@golang.org>
Trust: Katie Hockman <katie@golang.org>

2 years agodoc/go1.18: add crypto/x509 verifier notes
Roland Shoemaker [Fri, 19 Nov 2021 22:32:49 +0000 (14:32 -0800)]
doc/go1.18: add crypto/x509 verifier notes

Change-Id: If3e835e868ae695ba232b57096c135ce2e73305b
Reviewed-on: https://go-review.googlesource.com/c/go/+/365835
Trust: Roland Shoemaker <roland@golang.org>
Trust: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Katie Hockman <katie@golang.org>
2 years agoruntime: regression test for issue 50936
Michael Pratt [Mon, 31 Jan 2022 21:37:40 +0000 (16:37 -0500)]
runtime: regression test for issue 50936

Add a regression test for issue 50936 which coerces the runtime into
frequent execution of the cgocall dropg/execute curg assignment race by
making many concurrent cgo calls eligible for P retake by sysmon. This
results in no P during exitsyscall, at which point they will update curg
and will crash if SIGPROF arrives in between updating mp.curg and
mp.curg.m.

This test is conceptually similar to the basic cgo callback test in
aprof.go but with additional concurrency and a sleep in C.

On my machine this test fails ~5% of the time prior to CL 382079.

For #50936.

Change-Id: I21b6c7f2594f9a615a64580ef70a88b692505678
Reviewed-on: https://go-review.googlesource.com/c/go/+/382244
Trust: Michael Pratt <mpratt@google.com>
Run-TryBot: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2 years agoruntime: skip TestSegv failures with "morestack on g0" on darwin/amd64
Bryan C. Mills [Wed, 2 Feb 2022 15:19:30 +0000 (10:19 -0500)]
runtime: skip TestSegv failures with "morestack on g0" on darwin/amd64

This failure mode has been present since at least 2020-06-08. We have
enough information to diagnose it, and further failures don't seem to
be adding any new information at this point: they can only add noise,
both on the Go project's builders and in users' own modules (for
example, when run as part of 'go test all').

For #39457

Change-Id: I2379631da0c8af69598fa61c0cc5ac0ea6ba8267
Reviewed-on: https://go-review.googlesource.com/c/go/+/382395
Trust: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2 years agocmd/go/internal/modfetch: do not short-circuit canonical versions
Bryan C. Mills [Thu, 13 Jan 2022 20:38:14 +0000 (15:38 -0500)]
cmd/go/internal/modfetch: do not short-circuit canonical versions

Since at least CL 121857, the conversion logic in
(*modfetch).codeRepo.Stat has had a short-circuit to use the version
requested by the caller if it successfully resolves and is already
canonical.

However, we should not use that version if it refers to a branch
instead of a tag, because branches (unlike tags) usually do not refer
to a single, stable release: a branch named "v1.0.0" may be for the
development of the v1.0.0 release, or for the development of patches
based on v1.0.0, but only one commit (perhaps at the end of that
branch — but possibly not even written yet!) can be that specific
version.

We already have some logic to prefer tags that are semver-equivalent
to the version requested by the caller. That more general case
suffices for exact equality too — so we can eliminate the
special-case, fixing the bug and (happily!) also somewhat simplifying
the code.

Fixes #35671
Updates #41512

Change-Id: I2fd290190b8a99a580deec7e26d15659b58a50b0
Reviewed-on: https://go-review.googlesource.com/c/go/+/378400
Trust: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agogo/types, types2: shorter list for 2nd phase of function type inference
Robert Griesemer [Fri, 28 Jan 2022 02:55:29 +0000 (18:55 -0800)]
go/types, types2: shorter list for 2nd phase of function type inference

In the 2nd phase of function argument type inference we only
consider parameters with types that are single type parameters.
Thus there is no need to collect anything else in the first
phase.

This matches the algorithm description in the forthcoming spec
more closely.

Change-Id: Ie5c29f30ff43b1e37d719ecbe1688b50ed2177f3
Reviewed-on: https://go-review.googlesource.com/c/go/+/381554
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2 years agonet: remove an arbitrary timeout in TestUDPReadSizeError
Bryan C. Mills [Wed, 2 Feb 2022 22:09:28 +0000 (17:09 -0500)]
net: remove an arbitrary timeout in TestUDPReadSizeError

Looking at the condition actually exercised by the test it seems
unnecessary: assuming that the Write succeeds (checked earlier in the
test), the Read must have a nonzero number of bytes available to read
immediately. (That is not the case in TestUDPZeroByteBuffer, from
which this test appears to have been derived.)

Fixes #50870

Change-Id: Ia6040a2d5dc320f0b86ec9d6f6b91dc72e8f3b84
Reviewed-on: https://go-review.googlesource.com/c/go/+/382537
Trust: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2 years agocmd/go: fail 'go work' subcommands with a more helpful error if no go.work file exists
Bryan C. Mills [Tue, 1 Feb 2022 21:59:41 +0000 (16:59 -0500)]
cmd/go: fail 'go work' subcommands with a more helpful error if no go.work file exists

Otherwise, the failure mode for these subcommands refers to an empty file path:
go: open : no such file or directory

Fixes #50964

Change-Id: I8776431a294d2b2246d7d147b6059054f31bc255
Reviewed-on: https://go-review.googlesource.com/c/go/+/382246
Trust: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
2 years agocmd/go/internal/modload: skip deleted entries in UpdateWorkFile
Bryan C. Mills [Tue, 1 Feb 2022 21:35:02 +0000 (16:35 -0500)]
cmd/go/internal/modload: skip deleted entries in UpdateWorkFile

Fixes #50958

Change-Id: I25b4f34bea7705525217296471ce97e6a2ab99f6
Reviewed-on: https://go-review.googlesource.com/c/go/+/382245
Trust: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
2 years agonet/netip: correct ipv6 address in ParsePrefix comment
Ian Lance Taylor [Tue, 1 Feb 2022 21:27:36 +0000 (13:27 -0800)]
net/netip: correct ipv6 address in ParsePrefix comment

Fixes #50950

Change-Id: Iea94dba6e57d7e7985d4ae06a9b59ad126568599
Reviewed-on: https://go-review.googlesource.com/c/go/+/382294
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2 years agoconstraints: remove package
Ian Lance Taylor [Wed, 2 Feb 2022 21:22:18 +0000 (13:22 -0800)]
constraints: remove package

It has moved to golang.org/x/exp/constraints. Perhaps it will move
back to the standard library in a future release.

For golang/go#45458
Fixes golang/go#50792

Change-Id: I93aa251a7afe7b329a3d3faadc0c5d6388b1f0e9
Reviewed-on: https://go-review.googlesource.com/c/go/+/382460
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agocrypto/ecdsa,crypto/elliptic: update docs and spec references
Filippo Valsorda [Sat, 30 Oct 2021 04:27:51 +0000 (00:27 -0400)]
crypto/ecdsa,crypto/elliptic: update docs and spec references

crypto/ecdsa was long overdue a cleanup. Bump the FIPS 186 version, and
make sure we consistently reference that and SEC 1, not the paywalled
ANSI standard.

Change-Id: Idd90bd6c14b334941fdcd829d89b796a60a8b174
Reviewed-on: https://go-review.googlesource.com/c/go/+/352529
Run-TryBot: Filippo Valsorda <filippo@golang.org>
Trust: Filippo Valsorda <filippo@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Roland Shoemaker <roland@golang.org>
2 years agodoc/go1.18: add crypto/tls, crypto/x509, and crypto/elliptic release notes
Filippo Valsorda [Tue, 1 Feb 2022 20:24:51 +0000 (21:24 +0100)]
doc/go1.18: add crypto/tls, crypto/x509, and crypto/elliptic release notes

Updates #45428
Updates #41682

Change-Id: I811bc4f8ec8de6b6db6a2917e265a72134a05e78
Reviewed-on: https://go-review.googlesource.com/c/go/+/382454
Trust: Filippo Valsorda <filippo@golang.org>
Trust: Katie Hockman <katie@golang.org>
Reviewed-by: Katie Hockman <katie@golang.org>
2 years agoruntime: update _defer comment to not mention freedefer
Ian Lance Taylor [Wed, 2 Feb 2022 03:32:08 +0000 (19:32 -0800)]
runtime: update _defer comment to not mention freedefer

CL 339669 changed freedefer to not mention every field of _defer,
so no need to call it out in the _defer comment.

Change-Id: Id8b67ba2298685f609bf901b5948fd30666bd6e3
Reviewed-on: https://go-review.googlesource.com/c/go/+/382251
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
2 years agogo/types, types2: add a const to control recursion panics in unification
Robert Findley [Wed, 2 Feb 2022 18:47:31 +0000 (13:47 -0500)]
go/types, types2: add a const to control recursion panics in unification

Add a panicAtUnificationDepthLimit const to replace the use of the debug
const to control whether to panic when the unification recursion depth
is reached. Our tests should pass when debug==true.

Change-Id: I58847f49d66010bd4ca01c0408ec10acac95cba6
Reviewed-on: https://go-review.googlesource.com/c/go/+/382534
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agocmd/compile: edit README
pierwill [Wed, 2 Feb 2022 18:21:04 +0000 (18:21 +0000)]
cmd/compile: edit README

Make some small edits for clarification of important concepts.

Change-Id: I1f78f2a59489ac71e3948dc924641540508613ce
GitHub-Last-Rev: 1819140ee607edf8be3ed35f846848178065391a
GitHub-Pull-Request: golang/go#50980
Reviewed-on: https://go-review.googlesource.com/c/go/+/382458
Reviewed-by: Robert Griesemer <gri@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2 years agointernal/fuzz: small cleanups
Katie Hockman [Tue, 1 Feb 2022 17:30:36 +0000 (12:30 -0500)]
internal/fuzz: small cleanups

Change-Id: I9fc12f352d57db776d176990277e104f64f9908d
Reviewed-on: https://go-review.googlesource.com/c/go/+/382238
Reviewed-by: Julie Qiu <julie@golang.org>
Reviewed-by: Roland Shoemaker <roland@golang.org>
Trust: Katie Hockman <katie@golang.org>
Run-TryBot: Katie Hockman <katie@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agocmd/go: document that GOENV=off disables the default config file
Ian Lance Taylor [Fri, 28 Jan 2022 23:48:32 +0000 (15:48 -0800)]
cmd/go: document that GOENV=off disables the default config file

Fixes #46840

Change-Id: Icc5475e312003e316dc039413a35089485163ba6
Reviewed-on: https://go-review.googlesource.com/c/go/+/381894
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Trust: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agocmd/go: add detail to test failures
Bryan C. Mills [Fri, 28 Jan 2022 21:18:22 +0000 (16:18 -0500)]
cmd/go: add detail to test failures

For #50892

Change-Id: I14ff1c43b39687a0ba5e668ee962cecfb49e4beb
Reviewed-on: https://go-review.googlesource.com/c/go/+/381836
Trust: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agocmd/go: fix relative-path normalization in go.work files
Bryan C. Mills [Tue, 1 Feb 2022 16:25:13 +0000 (11:25 -0500)]
cmd/go: fix relative-path normalization in go.work files

We had been statting 'dir' instead of 'absDir', which statted the
wrong directory if 'dir' was made relative to the location of the
go.work file and that location was different from the current working
directory.

While we're here, I also noticed some other dir-vs.-absDir
discrepancies. The haveDirs map had assumed relative, slash-separated
filesystem paths, but absolute paths on Windows are not
slash-separated and we do retain those. Moreover, if users hand-edit
the go.work file they may introduce non-canonical paths.
I have changed the haveDirs logic to retain absolute paths in their
platform-specific forms, and to call DropUse with the original path
from the go.work file instead of the newly-resolved path.

Fixes #50931
Updates #48257

Change-Id: Ib0a46179aa20c99f045aac5c7c02dbb55da455c8
Reviewed-on: https://go-review.googlesource.com/c/go/+/382240
Trust: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agocmd/go: add missing newlines in TestScript '? cmp' output
Bryan C. Mills [Tue, 1 Feb 2022 15:16:48 +0000 (10:16 -0500)]
cmd/go: add missing newlines in TestScript '? cmp' output

Change-Id: I0314c2e9073b162119060a23c5eee9a78ca08ebf
Reviewed-on: https://go-review.googlesource.com/c/go/+/382239
Trust: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2 years agodoc/go1.18: explain changes to compiler error messages
Robert Griesemer [Tue, 1 Feb 2022 17:07:49 +0000 (09:07 -0800)]
doc/go1.18: explain changes to compiler error messages

For #47694.
For #50954.

Change-Id: I3789e145d64025fe2bf787fa5d01a21832903586
Reviewed-on: https://go-review.googlesource.com/c/go/+/381968
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2 years agodoc/go1.18: document restrictions for real, imag, complex
Robert Griesemer [Tue, 1 Feb 2022 16:37:05 +0000 (08:37 -0800)]
doc/go1.18: document restrictions for real, imag, complex

For #47694.
For #50912.
For #50937.

Change-Id: I3fae6c8dbbd61a45e669b8fb0c18ac76f2183963
Reviewed-on: https://go-review.googlesource.com/c/go/+/381967
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2 years agogo/types, types2: tweak missingMethodReason logic to improve message
Dan Scales [Wed, 26 Jan 2022 18:09:39 +0000 (10:09 -0800)]
go/types, types2: tweak missingMethodReason logic to improve message

This makes the error case pointed out in the issue like the current
message in Go 1.17 or -G=0 mode. The priority is to point out the
similar but wrong method name, rather than a difference in type.

Made changes to both cmd/compile/internal/types2 and go/types.
Added in a missing tab in an error message in go/types.

At the same time, removed the extra "at info" on the have lines (and
pointer receiver lines) of error messages, as requested in #50907.

Fixes #50816
Fixes #50907

Change-Id: I04f8151955bdb6192246cbcb59adc1c4b8a2c4e5
Reviewed-on: https://go-review.googlesource.com/c/go/+/381774
Reviewed-by: Robert Griesemer <gri@golang.org>
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Dan Scales <danscales@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agointernal/fuzz: properly handle duplicates during cache loading
Roland Shoemaker [Sun, 30 Jan 2022 19:21:28 +0000 (11:21 -0800)]
internal/fuzz: properly handle duplicates during cache loading

When loading the corpus, if the cache contained an entry which was a
duplicate of an entry added using f.Add, coordinator.addCorpusEntries
would return early, ignoring everything after this entry in the cache.

Instead, skip duplicates as intended, and continue to load the rest of
the cache.

Fixes #50913

Change-Id: I3a64b93cbb217c5c364a9f8d0005752e9e9d10ff
Reviewed-on: https://go-review.googlesource.com/c/go/+/381960
Trust: Katie Hockman <katie@golang.org>
Reviewed-by: Katie Hockman <katie@golang.org>
Trust: Roland Shoemaker <roland@golang.org>
Run-TryBot: Roland Shoemaker <roland@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agocmd/go/internal/workcmd: fix typo in help string
Bryan C. Mills [Tue, 1 Feb 2022 14:56:41 +0000 (09:56 -0500)]
cmd/go/internal/workcmd: fix typo in help string

Fixes #50945

Change-Id: Ib6251a5be09f4c6ba428ef4c97fe23ebffca3506
Reviewed-on: https://go-review.googlesource.com/c/go/+/382118
Trust: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2 years agospec: add section on comparable constraint
Robert Griesemer [Fri, 28 Jan 2022 23:34:40 +0000 (15:34 -0800)]
spec: add section on comparable constraint

For #50646.
Fixes #50791.

Change-Id: I8fec25ae3f0280c5b5a778011d23842b886ba79e
Reviewed-on: https://go-review.googlesource.com/c/go/+/381896
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2 years agogo/types, types2: disallow real, imag, complex on type parameters
Robert Griesemer [Mon, 31 Jan 2022 23:12:53 +0000 (15:12 -0800)]
go/types, types2: disallow real, imag, complex on type parameters

We can type-check these fine but the API implications are unclear.

Fixes #50912.
For #50937.

Change-Id: If29bbb4a257ff6a85e3bfcd4755fd8f90c80fb87
Reviewed-on: https://go-review.googlesource.com/c/go/+/382116
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agogo/types, types2: fix unification code for defined types
Robert Griesemer [Mon, 31 Jan 2022 20:51:45 +0000 (12:51 -0800)]
go/types, types2: fix unification code for defined types

Fixes #50929.

Change-Id: I65b8eaf5e4b423839bc53c7b1db3679961498c8a
Reviewed-on: https://go-review.googlesource.com/c/go/+/382076
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2 years agocmd/go: update go work edit -json types to final version
Ian Lance Taylor [Fri, 28 Jan 2022 23:17:46 +0000 (15:17 -0800)]
cmd/go: update go work edit -json types to final version

For #45713

Change-Id: Ia55a96702b99cccaf5d96c2125ee513700658444
Reviewed-on: https://go-review.googlesource.com/c/go/+/381874
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
Trust: Michael Matloob <matloob@golang.org>

2 years agoRevert "runtime: normalize sigprof traceback flags"
Michael Pratt [Mon, 31 Jan 2022 22:10:58 +0000 (17:10 -0500)]
Revert "runtime: normalize sigprof traceback flags"

This reverts commit CL 358900.

Adding _TraceJumpStack to cgo traceback exposed a crashing condition.
This CL was primarily a cleanup, so we revert it entirely for now
and follow-up with the VDSO and libcall parts later.

Fixes #50936.

Change-Id: Ie45c9caaa8e2ef5bc9498ba65c36c887ca821bf7
Reviewed-on: https://go-review.googlesource.com/c/go/+/382079
Reviewed-by: Cherry Mui <cherryyz@google.com>
Trust: Michael Pratt <mpratt@google.com>
Run-TryBot: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agoruntime: mgcmark.go typo fix: gorountine -> goroutine.
doujiang24 [Sun, 30 Jan 2022 06:16:03 +0000 (06:16 +0000)]
runtime: mgcmark.go typo fix: gorountine -> goroutine.

Change-Id: I5cd980a7c825619cc782a3bca2a1c9c7971fdca2
GitHub-Last-Rev: 6833eedf2dab77f7263f9803839a64b79f57e43e
GitHub-Pull-Request: golang/go#50910
Reviewed-on: https://go-review.googlesource.com/c/go/+/381959
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
2 years agogo/types, types2: fix implements and identical predicates
Robert Griesemer [Thu, 27 Jan 2022 06:48:44 +0000 (22:48 -0800)]
go/types, types2: fix implements and identical predicates

- Use the correct predicate in Checker.implements: for interfaces
  we cannot use the API Comparable because it always returns true
  for all non-type parameter interface types: Comparable simply
  answers if == and != is permitted, and it's always been permitted
  for interfaces. Instead we must use Interface.IsComparable which
  looks at the type set of an interface.

- When comparing interfaces for identity, we must also consider the
  whether the type sets have the comparable bit set.

With this change, `any` doesn't implement `comparable` anymore. This
only matters for generic functions and types, and the API functions.
It does mean that for now (until we allow type-constrained interfaces
for general non-constraint use, at some point in the future) a type
parameter that needs to be comparable cannot be instantiated with an
interface anymore.

For #50646.

Change-Id: I7e7f711bdcf94461f330c90509211ec0c2cf3633
Reviewed-on: https://go-review.googlesource.com/c/go/+/381254
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2 years agocmd/go: rewrite TestScript/cgo_stale_precompiled to be agnostic to staleness go1.18beta2
Bryan C. Mills [Fri, 28 Jan 2022 22:22:32 +0000 (17:22 -0500)]
cmd/go: rewrite TestScript/cgo_stale_precompiled to be agnostic to staleness

The configuration set by x/build/cmd/releasebot causes runtime/cgo to
be stale in the darwin/amd64 release (see #36025, #35459).
That staleness is mostly benign because we can reasonably assume that
users on macOS will either disable CGO entirely or have a C compiler
installed to rebuild (and cache) the stale packages if needed.

Fixes #50892
Fixes #50893
Updates #46347

Change-Id: Ib9ce6b5014de436264238f680f7ca4ae02c9a220
Reviewed-on: https://go-review.googlesource.com/c/go/+/381854
Trust: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2 years agocmd/go: fix error message when missing import
zhouguangyuan [Tue, 2 Nov 2021 12:23:34 +0000 (20:23 +0800)]
cmd/go: fix error message when missing import

Fixes #48907

Change-Id: I504f846fc2ea655ba00aedb30f90847f938c347c
Reviewed-on: https://go-review.googlesource.com/c/go/+/360615
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Emmanuel Odeke <emmanuel@orijtech.com>

2 years agodoc/go1.18: mention new debug/dwarf DataBitOffset fields
Ian Lance Taylor [Fri, 28 Jan 2022 21:15:16 +0000 (13:15 -0800)]
doc/go1.18: mention new debug/dwarf DataBitOffset fields

For #46784
For #47694
For #50685

Change-Id: I5351b56722d036a520d1a598ef7af95c5eb44c35
Reviewed-on: https://go-review.googlesource.com/c/go/+/381778
Trust: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
2 years agocmd/go: correct -trimpath docs for the standard library
Mark Pulford [Sat, 22 Jan 2022 06:13:53 +0000 (16:43 +1030)]
cmd/go: correct -trimpath docs for the standard library

Fixes #50402

Change-Id: Ic539afc1aef3906ef591b403eba0fde20a5ccef2
Reviewed-on: https://go-review.googlesource.com/c/go/+/380078
Reviewed-by: Bryan Mills <bcmills@google.com>
Trust: Emmanuel Odeke <emmanuel@orijtech.com>
Run-TryBot: Emmanuel Odeke <emmanuel@orijtech.com>

2 years agodoc/go1.18: in workspace mode doc, link to "go work" docs
Ian Lance Taylor [Fri, 28 Jan 2022 22:32:56 +0000 (14:32 -0800)]
doc/go1.18: in workspace mode doc, link to "go work" docs

For #45713
For #47694

Change-Id: I6f615c07749fca49c19f2ae22f79971c29aa8183
Reviewed-on: https://go-review.googlesource.com/c/go/+/381779
Trust: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
2 years agogo/types, types2: delete TypeList.String
Robert Griesemer [Fri, 28 Jan 2022 05:26:27 +0000 (21:26 -0800)]
go/types, types2: delete TypeList.String

This method is unused and was not discussed in the API
proposals. Note that all error output goes through the
local sprintf which handles arguments specially.

Fixes #50760.

Change-Id: Iae66b0253cc0ece037d3d280951dc2d223c119fb
Reviewed-on: https://go-review.googlesource.com/c/go/+/381634
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2 years agogo/types, types2: remove Qualifier parameter from Checker.implements
Robert Griesemer [Thu, 27 Jan 2022 20:53:13 +0000 (12:53 -0800)]
go/types, types2: remove Qualifier parameter from Checker.implements

Where we provide it we take it from the Checker (which is already
passed in). Thus there's no need to pass it separately. Cleanup.

Change-Id: I63ae445ccac5643235d85e1867462ef5c01ad5fe
Reviewed-on: https://go-review.googlesource.com/c/go/+/381297
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2 years agogo/types, types2: use Checker.implements in operand.assignableTo
Robert Griesemer [Thu, 27 Jan 2022 18:52:22 +0000 (10:52 -0800)]
go/types, types2: use Checker.implements in operand.assignableTo

Now that we have the detailed error reporting in Checker.implements
we don't need it anymore in operand.assignableTo and can simply call
Checker.implements. This also more directly matches the spec.

For #50646.

Change-Id: Ic44ced999c75be6cc9edaab01177ee0495147ea1
Reviewed-on: https://go-review.googlesource.com/c/go/+/381435
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2 years agogo/types, types2: better error reporting for Checker.implements
Robert Griesemer [Thu, 27 Jan 2022 18:28:46 +0000 (10:28 -0800)]
go/types, types2: better error reporting for Checker.implements

This CL copies (and adjusts as needed) the logic for error reporting
from operand.assignableTo to Checker.implements in the case of a missing
method failure and assignment to an interface pointer.

Preparation for using Checker.implements in operand.assignableTo
rather than implementing the same logic twice.

This also leads to better errors from Checker.implements as it's
using the same logic we already use elsewhere.

For #50646.

Change-Id: I199a1e02cf328b222ae52c10131db871539863bf
Reviewed-on: https://go-review.googlesource.com/c/go/+/381434
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2 years agospec: add section on type inference
Robert Griesemer [Tue, 30 Nov 2021 17:29:45 +0000 (09:29 -0800)]
spec: add section on type inference

Change-Id: Ic338788d6410ed0d09ad129811377ee9ce5ed496
Reviewed-on: https://go-review.googlesource.com/c/go/+/367954
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2 years agodebug/dwarf: fix problems with handling of bit offsets for bitfields
Than McIntosh [Tue, 25 Jan 2022 14:34:35 +0000 (09:34 -0500)]
debug/dwarf: fix problems with handling of bit offsets for bitfields

This patch reworks the handling of the DWARF DW_AT_bit_offset and
DW_AT_data_bit_offset attributes to resolve problems arising from
a previous related change (CL 328709).

In CL 328709 the DWARF type reader was updated to look for and use
the DW_AT_data_bit_offset attribute for structure fields, handling
the value of the attribute in the same way as for DW_AT_bit_offset.
This caused problems for clients, since the two attributes have very
different semantics.

This CL effectively reverts CL 328709 and moves to a scheme in which
we detect and report the two attributes separately/independently.

This patch also corrects a problem in the DWARF type reader in the
code that detects and fixes up the type of struct fields corresponding
to zero-length arrays; the code in question was testing the
DW_AT_bit_offset attribute value but assuming DW_AT_data_bit_offset
semantics, meaning that it would fail to fix up cases such as

  typedef struct another_struct {
    unsigned short quix;
    int xyz[0];
    unsigned  x:1;
    long long array[40];
  } t;

The code in question has been changed to avoid using BitOffset and
instead consider only ByteOffset and BitSize.

Fixes #50685.
Updates #46784.

Change-Id: Ic15ce01c851af38ebd81af827973ec49badcab6f
Reviewed-on: https://go-review.googlesource.com/c/go/+/380714
Trust: Than McIntosh <thanm@google.com>
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2 years agogo/types, types2: delete _TypeSet.includes - not used (cleanup)
Robert Griesemer [Thu, 27 Jan 2022 23:00:57 +0000 (15:00 -0800)]
go/types, types2: delete _TypeSet.includes - not used (cleanup)

Change-Id: Ia324c6185e36efd4ea7dc92d7c2233fec8f5a55f
Reviewed-on: https://go-review.googlesource.com/c/go/+/381494
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2 years agomath/big: prevent overflow in (*Rat).SetString
Katie Hockman [Wed, 19 Jan 2022 21:54:41 +0000 (16:54 -0500)]
math/big: prevent overflow in (*Rat).SetString

Credit to rsc@ for the original patch.

Thanks to the OSS-Fuzz project for discovering this
issue and to Emmanuel Odeke (@odeke_et) for reporting it.

Fixes #50699
Fixes CVE-2022-23772

Change-Id: I590395a3d55689625390cf1e58f5f40623b26ee5
Reviewed-on: https://go-review.googlesource.com/c/go/+/379537
Trust: Katie Hockman <katie@golang.org>
Run-TryBot: Katie Hockman <katie@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
Reviewed-by: Roland Shoemaker <roland@golang.org>
Reviewed-by: Julie Qiu <julie@golang.org>
2 years agogo/types: update interface receivers after substituting
Robert Findley [Thu, 27 Jan 2022 01:50:51 +0000 (20:50 -0500)]
go/types: update interface receivers after substituting

Interface method receivers are synthetic: they record either the
interface type or the the defined type for which they are the RHS of the
type declaration. When instantiating, we need to update these receivers
accordingly.

Fixes #50839

Change-Id: Icd8e1a2817b0135059d25d034b01b0ff5207641f
Reviewed-on: https://go-review.googlesource.com/c/go/+/381174
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agogo/types, cmd/compile: fix composite literal structural typing
Matthew Dempsky [Wed, 26 Jan 2022 21:46:45 +0000 (13:46 -0800)]
go/types, cmd/compile: fix composite literal structural typing

For a composite literal expression like []T{{f: 1}}, we allow T to be
a pointer to struct type, so it's consistent to allow T to also be a
type parameter whose structural type is a pointer to struct type.

Fixes #50833.

Change-Id: Ib0781ec4a4f327c875ea25b97740ff2c0c86b916
Reviewed-on: https://go-review.googlesource.com/c/go/+/381075
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
Trust: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agocmd/compile: remove incorrect arm,arm64 CMP->CMN transformations
David Chase [Thu, 27 Jan 2022 16:26:59 +0000 (11:26 -0500)]
cmd/compile: remove incorrect arm,arm64 CMP->CMN transformations

These can go wrong when one of the operands is the minimum integer value.

Fixes #50854.

Change-Id: I238fe284f60c7ee5aeb9dc9a18e8b1578cdb77d0
Reviewed-on: https://go-review.googlesource.com/c/go/+/381318
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Trust: David Chase <drchase@google.com>
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agointernal/fuzz: centralize corpus entry addition
Roland Shoemaker [Mon, 1 Nov 2021 17:03:36 +0000 (10:03 -0700)]
internal/fuzz: centralize corpus entry addition

Adds an addCorpusEntry method to coordinator which manages checking for
duplicate entries, writing entries to the cache directory, and adding
entries to the corpus. Also moves readCache to be a method on the
coordinator.

Fixes #50606

Change-Id: Id6721384a2ad1cfb4c5471cf0cd0a7510d250a6c
Reviewed-on: https://go-review.googlesource.com/c/go/+/360394
Trust: Katie Hockman <katie@golang.org>
Reviewed-by: Katie Hockman <katie@golang.org>
Trust: Roland Shoemaker <roland@golang.org>
Run-TryBot: Roland Shoemaker <roland@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agocmd/compile: add missing shape check in (*Tsubster).tinter
Dan Scales [Thu, 27 Jan 2022 01:58:08 +0000 (17:58 -0800)]
cmd/compile: add missing shape check in (*Tsubster).tinter

Add a missing shape check in (*Tsubster).tinter when substituting on a
generic type which is an empty interface, analogous to same check in
(*Tsubster).tstruct. Empty structs/interfaces that have rparams (i.e.
are a generic type or a shape type) need to get a new type of their
rparams - they will be different even though they don't have any
fields/methods. Without this shape check, we were not correctly
completing the Token[int] type during substitution in the example in the
issue. This issue only happens for a generic type which is an empty
interface (i.e. doesn't actually use the type param, hence quite unusual).

Added the test case already created by Keith.

Fixes #50841

Change-Id: Ia985b9f52c0e87ed0647b46373e44c51cb748ba4
Reviewed-on: https://go-review.googlesource.com/c/go/+/381175
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Dan Scales <danscales@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2 years agocmd/compile: support structural typing in unified IR
Matthew Dempsky [Wed, 26 Jan 2022 21:26:45 +0000 (13:26 -0800)]
cmd/compile: support structural typing in unified IR

This CL updates unified IR to look at the structural type of a
composite literal type, rather than merely the underlying type, to
determine if it's a structure. This fixes a number of currently
failing regress test cases.

Updates #50833.

Change-Id: I11c040c77ec86c23e8ffefcf1ce1aed548687dc5
Reviewed-on: https://go-review.googlesource.com/c/go/+/381074
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Trust: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
2 years agoRevert "spec: document the underlying type of comparable"
Robert Griesemer [Wed, 26 Jan 2022 22:01:52 +0000 (14:01 -0800)]
Revert "spec: document the underlying type of comparable"

This reverts CL 380854.

Per the conluding discussions on #50791. A follow-up will
document `comparable` more thoroughly.

For #50791.

Change-Id: I15db9051784a012f713e28d725c3b8bbfeb40569
Reviewed-on: https://go-review.googlesource.com/c/go/+/381076
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2 years agogo/types, types2: clean up the set up of error, comparable
Robert Griesemer [Wed, 26 Jan 2022 21:44:45 +0000 (13:44 -0800)]
go/types, types2: clean up the set up of error, comparable

Follow-up on CL 380754.

For #50791.

Change-Id: Ia2f8f9785c2f02647525e7ee4168991fd4066dd3
Reviewed-on: https://go-review.googlesource.com/c/go/+/381094
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2 years agogo/types, types2: print underlying type of comparable as "interface{comparable}"
Robert Griesemer [Tue, 25 Jan 2022 17:21:39 +0000 (09:21 -0800)]
go/types, types2: print underlying type of comparable as "interface{comparable}"

For #50791.

Change-Id: Ib12009d2895146e55ec3a51aa8ceafe58dfd82a5
Reviewed-on: https://go-review.googlesource.com/c/go/+/380754
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2 years agodoc/go1.18: note short-circuit and/or in html/template
Russ Cox [Thu, 20 Jan 2022 13:54:59 +0000 (08:54 -0500)]
doc/go1.18: note short-circuit and/or in html/template

It was already noted in text/template; copied from there.

Change-Id: Ie749d04004af60f2333073ddf556ff7e16c81c45
Reviewed-on: https://go-review.googlesource.com/c/go/+/379794
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2 years agocmd/compile/internal/types2: remove (*Signature).SetRecvTypeParams
Matthew Dempsky [Wed, 26 Jan 2022 00:49:59 +0000 (16:49 -0800)]
cmd/compile/internal/types2: remove (*Signature).SetRecvTypeParams

This method isn't available in go/types, and its use by unified IR is
non-essential. This CL refactors reader2.go to avoid using it and then
removes the method.

Change-Id: I813c93a062c43292bb6760686ef91df5219534a6
Reviewed-on: https://go-review.googlesource.com/c/go/+/380834
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Trust: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
2 years agocmd/api: reduce parallel 'go list' invocations to a constant
Bryan C. Mills [Wed, 26 Jan 2022 17:45:12 +0000 (12:45 -0500)]
cmd/api: reduce parallel 'go list' invocations to a constant

'go list' has its own internal parallelism, so invoking in in parallel
can produce up to quadratic peak memory usage.

Running 'go list' is also very I/O-intensive, so the higher
parallelism does substantially improve latency; unfortunately, we lack
a good way to balance latency against memory footprint, so we need to
sacrifice some latency for reliability.

Fixes #49957.

Change-Id: Ib53990b46acf4cc67a9141644d97282964d6442d
Reviewed-on: https://go-review.googlesource.com/c/go/+/380994
Trust: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
2 years agospec: document the underlying type of comparable
Robert Griesemer [Wed, 26 Jan 2022 03:12:35 +0000 (19:12 -0800)]
spec: document the underlying type of comparable

For #50791.

Change-Id: I7f135bb6626128a3cee9fd71c57535c1fc83ac7f
Reviewed-on: https://go-review.googlesource.com/c/go/+/380854
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2 years agocmd/go: fix retrieving Mercurial commit timestamp under Windows
Mark Pulford [Sat, 22 Jan 2022 05:33:28 +0000 (16:03 +1030)]
cmd/go: fix retrieving Mercurial commit timestamp under Windows

Use "hgdate" since the strftime filter is unsupported by Mercurial under
Windows.

Fixes #49841

Change-Id: I300898e51e324147aaf1bfe12ed17dea4bdd183d
Reviewed-on: https://go-review.googlesource.com/c/go/+/380077
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Trust: Jeremy Faller <jeremy@golang.org>
Trust: Michael Knyszek <mknyszek@google.com>

2 years agocmd/go: avoid recording GOROOT_FINAL in precompiled C archives
Bryan C. Mills [Wed, 26 Jan 2022 14:18:14 +0000 (09:18 -0500)]
cmd/go: avoid recording GOROOT_FINAL in precompiled C archives

C archives for packages in GOROOT are shipped along with binary
releases of the Go toolchain. Although we build the toolchain with
GOROOT_FINAL set, we don't know actually know where the release will
be installed: the user's real GOROOT can differ arbitrarily from our
GOROOT_FINAL.

(In the specific case of toolchains installed through golang.org/dl
wrappers, the release's GOROOT_FINAL is /usr/local/go but the actual
GOROOT to which the release is installed is
$HOME/sdk/$(go env GOVERSION).)

Fixes #50183
Updates #48319

Change-Id: If10a42f90c725300bbcb89c3b5b01a2d93ab6ef7
Reviewed-on: https://go-review.googlesource.com/c/go/+/380915
Trust: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agocmd/go: refactor TestScript/build_issue48319 to check a more general property
Bryan C. Mills [Wed, 26 Jan 2022 14:24:25 +0000 (09:24 -0500)]
cmd/go: refactor TestScript/build_issue48319 to check a more general property

The test previously checked that the DWARF DW_AT_comp_dir attribute
matched GOROOT_FINAL. However, on further consideration, we believe
that DW_AT_comp_dir should not actually match GOROOT_FINAL: the DWARF
spec says that DW_AT_comp_dir records “the current working directory
of the compilation command that produced this compilation unit”, but
the actual working directory of the compilation command proper is a
throwaway directory in the build cache — it is neither stable nor
meaningful.

However, the test was getting at a real issue that we do care about:
namely, that the binary produced by a 'go build' command with cgo
enabled should not reuse a dependency that embeds a stale
GOROOT_FINAL.

This change refactors the test to verify the latter property instead
of checking DW_AT_comp_dir specifically.

For #50183
Updates #48319

Change-Id: I0b1151d9ba3d0ff903f72e27850306406e5cb518
Reviewed-on: https://go-review.googlesource.com/c/go/+/380914
Trust: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agocmd/go: remove mercurial from bitbucket vcs options
Ethan Anderson [Tue, 14 Dec 2021 16:59:06 +0000 (10:59 -0600)]
cmd/go: remove mercurial from bitbucket vcs options

Mercurial was deprecated as of July 1, 2020 as per https://bitbucket.org/blog/sunsetting-mercurial-support-in-bitbucket

Fixes #50810.

Change-Id: I0d40f84aaa393905cae7c4bed8919b15de9a5f6d
Reviewed-on: https://go-review.googlesource.com/c/go/+/371720
Trust: Russ Cox <rsc@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Trust: Bryan Mills <bcmills@google.com>

2 years agocmd/go: add mv and support "! cmp" in script tests
Bryan C. Mills [Wed, 26 Jan 2022 14:50:41 +0000 (09:50 -0500)]
cmd/go: add mv and support "! cmp" in script tests

For #50183

Change-Id: Ie384333fb7a69d0d2cfaba0cfc4eb7afba2fd745
Reviewed-on: https://go-review.googlesource.com/c/go/+/380916
Trust: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2 years agoall: update vendored golang.org/x/tools
Robert Findley [Tue, 25 Jan 2022 22:31:52 +0000 (17:31 -0500)]
all: update vendored golang.org/x/tools

Update the vendored x/tools to pick up CL 380014, which updates the
ifaceassert vet analyzer to remove spurious errors for assertions
involving interfaces with type parameters.

This also picks up some superficial changes related to refactoring of
the x/tools/internal/typeparams API.

The following commands were used:

  go get -d golang.org/x/tools@master
  go mod tidy
  go mod vendor

Fixes #50658

Change-Id: I2f612fd186a1a260cab21860b192c9f6dc3f560f
Reviewed-on: https://go-review.googlesource.com/c/go/+/380777
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Tim King <taking@google.com>
2 years agogo/types, types2: all interfaces implement comparable (add tests)
Robert Griesemer [Tue, 25 Jan 2022 01:49:11 +0000 (17:49 -0800)]
go/types, types2: all interfaces implement comparable (add tests)

For #50646.

Change-Id: I7420545556e0df2659836364a62ce2c32ad7a8b1
Reviewed-on: https://go-review.googlesource.com/c/go/+/380654
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2 years agogo/types, types2: make each method instantiation independently lazy
Robert Findley [Mon, 24 Jan 2022 15:37:59 +0000 (10:37 -0500)]
go/types, types2: make each method instantiation independently lazy

Method signatures can introduce a significant number of edges into the
type graph. One can imagine a generic type with many methods, each of
which may use other instantiated types, etc. For performance, when type
checking generic code, we should avoid unnecessary instantiation of
methods wherever possible.

This CL achieves this by making method instantiation lazy at the
individual method level. It abstracts method access into a methodList
type, which may be either eager or lazy. In the lazy case, methods are
only instantiated when they are accessed via the Named.Method,
MethodSet, or LookupFieldOrMethod APIs. Factoring out a methodList type
makes it easier to verify that we're not leaking the methods slice
anywhere, and as a side benefit reduces the size of *Named types in the
case where there are no methods. The effective memory footprint of Named
types with methods increases by a pointer (to hold the slice of guards),
and the footprint of instantiated named types increases additionally by
a sync.Once per method. We estimate that this memory increase is more
than offset by the reduction in the number of instantiated methods.

This also simplifies the code. Previously we had to work around the fact
that named type expansion could occur before all signatures were set-up,
by stashing the instantiated receiver into a partially filled-out *Func.
With fully lazy methods, we can rely on the invariant that any use of
methods in valid code can only occur after all signatures can be type
checked. This means that we can fully instantiate the *Func, and don't
need to deal with partially instantiated stubs.

Finally, this CL fixes a bug (issue #50619), where traversing
Method->Receiver Type->Method did not get us back where we started. This
is fixed by not instantiating a new method if t is already the receiver
base of the original method.

A test is added to explicitly verify the invariant above, and more test
cases are added for the behavior of Info with respect to generic code.

Fixes #50619

Change-Id: I5b6d2bdc4404c9f5dcb583a29cb64e8af9794c54
Reviewed-on: https://go-review.googlesource.com/c/go/+/380499
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>