aboutsummaryrefslogtreecommitdiff
path: root/test/escape_hash_maphash.go
diff options
context:
space:
mode:
authorKeith Randall <khr@golang.org>2019-11-16 07:12:53 -0800
committerKeith Randall <khr@golang.org>2019-11-16 20:31:45 +0000
commit6ba0be16391697bdaab7d8f836b66921977d5474 (patch)
tree07c3ef892dbce409c21fd4b60652a4d93f9f813d /test/escape_hash_maphash.go
parentc20b71eb37889e7257453be152a994319c76d451 (diff)
downloadgo-6ba0be16391697bdaab7d8f836b66921977d5474.tar.gz
go-6ba0be16391697bdaab7d8f836b66921977d5474.zip
hash/maphash: mark call into runtime hash function as not escaping
This allows maphash.Hash to be allocated on the stack for typical uses. Fixes #35636 Change-Id: I8366507d26ea717f47a9fb46d3bd69ba799845ac Reviewed-on: https://go-review.googlesource.com/c/go/+/207444 Run-TryBot: Keith Randall <khr@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Diffstat (limited to 'test/escape_hash_maphash.go')
-rw-r--r--test/escape_hash_maphash.go19
1 files changed, 19 insertions, 0 deletions
diff --git a/test/escape_hash_maphash.go b/test/escape_hash_maphash.go
new file mode 100644
index 0000000000..f8dcc5450d
--- /dev/null
+++ b/test/escape_hash_maphash.go
@@ -0,0 +1,19 @@
+// errorcheck -0 -m -l
+
+// Copyright 2019 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Test escape analysis for hash/maphash.
+
+package escape
+
+import (
+ "hash/maphash"
+)
+
+func f() {
+ var x maphash.Hash // should be stack allocatable
+ x.WriteString("foo")
+ x.Sum64()
+}