From 9e29dd42df18141506dcfc2513e8a653564fdbf1 Mon Sep 17 00:00:00 2001 From: Robert Findley Date: Tue, 7 Dec 2021 14:29:21 -0500 Subject: [PATCH] doc: document cmd/vet changes for generics in 1.18 Fixes #50011 Updates #47694 Change-Id: Id3d43f2f72de61b360b79c2b375ca1372d5f4692 Reviewed-on: https://go-review.googlesource.com/c/go/+/369979 Trust: Robert Findley Run-TryBot: Robert Findley TryBot-Result: Gopher Robot Reviewed-by: Tim King --- doc/go1.18.html | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/doc/go1.18.html b/doc/go1.18.html index a3c2da059b..2813ddc12c 100644 --- a/doc/go1.18.html +++ b/doc/go1.18.html @@ -266,6 +266,28 @@ Do not send CLs removing the interior tags from such phrases. multiple CPUs, gofmt should now be significantly faster.

+

vet

+ +

Updates for Generics

+ +

+ The vet tool is updated to support generic code. In most cases, + it reports an error in generic code whenever it would report an error in the + equivalent non-generic code after substituting for type parameters with a + type from their + type set. + + For example, vet reports a format error in +

func Print[T ~int|~string](t T) {
+	fmt.Printf("%d", t)
+}
+ because it would report a format error in the non-generic equivalent of + Print[string]: +
func PrintString(x string) {
+	fmt.Printf("%d", x)
+}
+

+

Runtime