Commit 29d11ef4 authored by Manish Goregaokar's avatar Manish Goregaokar Committed by Rob Pike

cmd/vet: add test that copylock catches copying a sync.Map

fixes #21635

Change-Id: I78716d47b6a930074e5394f7171d5f545dfba0bc
Reviewed-on: https://go-review.googlesource.com/59690Reviewed-by: default avatarBryan Mills <bcmills@google.com>
Reviewed-by: default avatarRob Pike <r@golang.org>
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
parent ce54a0c1
...@@ -11,12 +11,14 @@ import "sync" ...@@ -11,12 +11,14 @@ import "sync"
func OkFunc(*sync.Mutex) {} func OkFunc(*sync.Mutex) {}
func BadFunc(sync.Mutex) {} // ERROR "BadFunc passes lock by value: sync.Mutex" func BadFunc(sync.Mutex) {} // ERROR "BadFunc passes lock by value: sync.Mutex"
func BadFunc2(sync.Map) {} // ERROR "BadFunc2 passes lock by value: sync.Map contains sync.Mutex"
func OkRet() *sync.Mutex {} func OkRet() *sync.Mutex {}
func BadRet() sync.Mutex {} // Don't warn about results func BadRet() sync.Mutex {} // Don't warn about results
var ( var (
OkClosure = func(*sync.Mutex) {} OkClosure = func(*sync.Mutex) {}
BadClosure = func(sync.Mutex) {} // ERROR "func passes lock by value: sync.Mutex" BadClosure = func(sync.Mutex) {} // ERROR "func passes lock by value: sync.Mutex"
BadClosure2 = func(sync.Map) {} // ERROR "func passes lock by value: sync.Map contains sync.Mutex"
) )
type EmbeddedRWMutex struct { type EmbeddedRWMutex struct {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment