]> Cypherpunks repositories - gostls13.git/commitdiff
doc/go1.22: document changes to vet loopclosure analyzer
authorTim King <taking@google.com>
Tue, 19 Dec 2023 18:08:00 +0000 (10:08 -0800)
committerTim King <taking@google.com>
Wed, 20 Dec 2023 18:38:20 +0000 (18:38 +0000)
cmd/vet no longer reports loopclosure bugs within files built at
GoVersion>=1.22.

For #61422.

Change-Id: I6f29373bb236822ece4e7ae35914859538b8d57b
Reviewed-on: https://go-review.googlesource.com/c/go/+/551376
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
Run-TryBot: Tim King <taking@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

doc/go1.22.html

index 951a8e316001d43d118887e8041378dbdf008dd9..5aa0a3f54dc952fe9e0a1dc14a023dcf03a5bd3e 100644 (file)
@@ -136,9 +136,20 @@ packages that do not have their own test files. Prior to Go 1.22 a
 
 <h3 id="vet">Vet</h3>
 
-<!-- <p><\!-- CL 539016 -\-> -->
-<!--   TODO: <a href="https://go.dev/cl/539016">https://go.dev/cl/539016</a>: go/analysis/passes/loopclosure: disable checker after go1.22.; loopclosure was modified to only not report in files with GoVersion after 1.22. -->
-<!-- </p> -->
+<h4 id="vet-loopclosure">References to loop variables</h4>
+
+<p><!-- CL 539016, https://go.dev/issue/63888: cmd/vet: do not report variable capture for loop variables with the new lifetime rules -->
+  The behavior of the <code>vet</code> tool has changed to match
+  the new semantics (see above) of loop variables in Go 1.22.
+  When analyzing a file that requires Go 1.22 or newer
+  (due to its go.mod file or a per-file build constraint),
+  <code>vet</code>code> no longer reports references to
+  loop variables from within a function literal that
+  might outlive the iteration of the loop.
+  In Go 1.22, loop variables are created anew for each iteration,
+  so such references are no longer at risk of using a variable
+  after it has been updated by the loop.
+</p>
 
 <h4 id="vet-appends">New warnings for missing values after append</h4>