[release-branch.go1.19] sync/atomic: disallow type conversions of atomic.Pointer[T]

For #56603.
Fixes #56638.

Change-Id: I6af9d80201025ae4028bfaa4a62e5de9ac0c501d
GitHub-Last-Rev: e6ed5e1451
GitHub-Pull-Request: golang/go#56604
Reviewed-on: https://go-review.googlesource.com/c/go/+/448275
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
(cherry picked from commit 6bead8f77a)
Reviewed-on: https://go-review.googlesource.com/c/go/+/448518
Run-TryBot: Michael Knyszek <mknyszek@google.com>
This commit is contained in:
Mateusz Poliwczak 2022-11-07 14:54:52 +00:00 committed by Michael Knyszek
parent ec6510887c
commit 0dfdf3262d
1 changed files with 4 additions and 0 deletions

View File

@ -37,6 +37,10 @@ func b32(b bool) uint32 {
// A Pointer is an atomic pointer of type *T. The zero value is a nil *T.
type Pointer[T any] struct {
// Mention T in a field to disallow conversion between Pointer types.
// See go.dev/issue/56603 for more details.
_ [0]T
_ noCopy
v unsafe.Pointer
}