Source file test/typeparam/issue54765.go
1 // errorcheck 2 3 // Copyright 2022 The Go Authors. All rights reserved. 4 // Use of this source code is governed by a BSD-style 5 // license that can be found in the LICENSE file. 6 7 // Test that not-in-heap types cannot be used as type 8 // arguments. (pointer-to-nih types are okay though.) 9 10 //go:build cgo 11 // +build cgo 12 13 package p 14 15 import ( 16 "runtime/cgo" 17 "sync/atomic" 18 ) 19 20 var _ atomic.Pointer[cgo.Incomplete] // ERROR "cannot use incomplete \(or unallocatable\) type as a type argument: runtime/cgo\.Incomplete" 21 var _ atomic.Pointer[*cgo.Incomplete] // ok 22 23 func implicit(ptr *cgo.Incomplete) { 24 g(ptr) // ERROR "cannot use incomplete \(or unallocatable\) type as a type argument: runtime/cgo\.Incomplete" 25 g(&ptr) // ok 26 } 27 28 func g[T any](_ *T) {} 29