aboutsummaryrefslogtreecommitdiff
path: root/test/escape_closure.go
diff options
context:
space:
mode:
authorMatthew Dempsky <mdempsky@google.com>2019-09-12 10:18:03 -0700
committerMatthew Dempsky <mdempsky@google.com>2019-09-16 15:30:51 +0000
commit606019cb4b1c8fb57e5a83747ee0aff1054291d8 (patch)
tree04ff2c4bbf57c97d339663d2d46999702983121d /test/escape_closure.go
parent4ae25ff1405f9d6b25f40141f42196e8f142f207 (diff)
downloadgo-606019cb4b1c8fb57e5a83747ee0aff1054291d8.tar.gz
go-606019cb4b1c8fb57e5a83747ee0aff1054291d8.zip
cmd/compile: trim function name prefix from escape diagnostics
This information is redundant with the position information already provided. Also, no other -m diagnostics print out function name. While here, report parameter leak diagnostics against the parameter declaration position rather than the function, and use Warnl for "moved to heap" messages. Test cases updated programmatically by removing the first word from every "no match for" error emitted by run.go: go run run.go |& \ sed -E -n 's/^(.*):(.*): no match for `([^ ]* (.*))` in:$/\1!\2!\3!\4/p' | \ while IFS='!' read -r fn line before after; do before=$(echo "$before" | sed 's/[.[\*^$()+?{|]/\\&/g') after=$(echo "$after" | sed -E 's/(\&|\\)/\\&/g') fn=$(find . -name "${fn}" | head -1) sed -i -E -e "${line}s/\"${before}\"/\"${after}\"/" "${fn}" done Passes toolstash-check. Change-Id: I6e02486b1409e4a8dbb2b9b816d22095835426b5 Reviewed-on: https://go-review.googlesource.com/c/go/+/195040 Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com>
Diffstat (limited to 'test/escape_closure.go')
-rw-r--r--test/escape_closure.go14
1 files changed, 7 insertions, 7 deletions
diff --git a/test/escape_closure.go b/test/escape_closure.go
index f9f3c0fbd4..3b14027fa4 100644
--- a/test/escape_closure.go
+++ b/test/escape_closure.go
@@ -139,28 +139,28 @@ func ClosureCallArgs15() {
}(&p)
}
-func ClosureLeak1(s string) string { // ERROR "ClosureLeak1 s does not escape"
+func ClosureLeak1(s string) string { // ERROR "s does not escape"
t := s + "YYYY" // ERROR "escapes to heap"
- return ClosureLeak1a(t) // ERROR "ClosureLeak1 ... argument does not escape"
+ return ClosureLeak1a(t) // ERROR "... argument does not escape"
}
// See #14409 -- returning part of captured var leaks it.
func ClosureLeak1a(a ...string) string { // ERROR "leaking param: a to result ~r1 level=1$"
- return func() string { // ERROR "ClosureLeak1a func literal does not escape"
+ return func() string { // ERROR "func literal does not escape"
return a[0]
}()
}
-func ClosureLeak2(s string) string { // ERROR "ClosureLeak2 s does not escape"
+func ClosureLeak2(s string) string { // ERROR "s does not escape"
t := s + "YYYY" // ERROR "escapes to heap"
- c := ClosureLeak2a(t) // ERROR "ClosureLeak2 ... argument does not escape"
+ c := ClosureLeak2a(t) // ERROR "... argument does not escape"
return c
}
func ClosureLeak2a(a ...string) string { // ERROR "leaking param content: a"
- return ClosureLeak2b(func() string { // ERROR "ClosureLeak2a func literal does not escape"
+ return ClosureLeak2b(func() string { // ERROR "func literal does not escape"
return a[0]
})
}
-func ClosureLeak2b(f func() string) string { // ERROR "ClosureLeak2b f does not escape"
+func ClosureLeak2b(f func() string) string { // ERROR "f does not escape"
return f()
}