Skip to content

Commit adec22b

Browse files
committed
doc/go1.22: document changes to vet loopclosure analyzer
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 <[email protected]> Reviewed-by: Alan Donovan <[email protected]> Run-TryBot: Tim King <[email protected]> TryBot-Result: Gopher Robot <[email protected]>
1 parent a2a2c5b commit adec22b

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

doc/go1.22.html

+14-3
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,20 @@ <h3 id="trace">Trace</h3>
136136

137137
<h3 id="vet">Vet</h3>
138138

139-
<!-- <p><\!-- CL 539016 -\-> -->
140-
<!-- 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. -->
141-
<!-- </p> -->
139+
<h4 id="vet-loopclosure">References to loop variables</h4>
140+
141+
<p><!-- CL 539016, https://go.dev/issue/63888: cmd/vet: do not report variable capture for loop variables with the new lifetime rules -->
142+
The behavior of the <code>vet</code> tool has changed to match
143+
the new semantics (see above) of loop variables in Go 1.22.
144+
When analyzing a file that requires Go 1.22 or newer
145+
(due to its go.mod file or a per-file build constraint),
146+
<code>vet</code>code> no longer reports references to
147+
loop variables from within a function literal that
148+
might outlive the iteration of the loop.
149+
In Go 1.22, loop variables are created anew for each iteration,
150+
so such references are no longer at risk of using a variable
151+
after it has been updated by the loop.
152+
</p>
142153

143154
<h4 id="vet-appends">New warnings for missing values after append</h4>
144155

0 commit comments

Comments
 (0)