aboutsummaryrefslogtreecommitdiff
path: root/test/escape_map.go
diff options
context:
space:
mode:
authorCuong Manh Le <cuong.manhle.vn@gmail.com>2020-09-09 11:09:01 +0700
committerCuong Manh Le <cuong.manhle.vn@gmail.com>2020-09-12 08:31:49 +0000
commit2c95e3a6a8377ca9c72608c25b4cf2506baf782f (patch)
treee8696bf16d352c026cf84e0cab63c53369f67fe8 /test/escape_map.go
parentd7384f36121d52191097af50d6dc12c0eb08fd75 (diff)
downloadgo-2c95e3a6a8377ca9c72608c25b4cf2506baf782f.tar.gz
go-2c95e3a6a8377ca9c72608c25b4cf2506baf782f.zip
cmd/compile: use clearer error message for stuct literal
This CL changes "T literal.M" error message to "T{...}.M". It's clearer expression and focusing user on actual issue. Updates #38745 Change-Id: I84b455a86742f37e0bde5bf390aa02984eecc3c9 Reviewed-on: https://go-review.googlesource.com/c/go/+/253677 Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Diffstat (limited to 'test/escape_map.go')
-rw-r--r--test/escape_map.go26
1 files changed, 13 insertions, 13 deletions
diff --git a/test/escape_map.go b/test/escape_map.go
index 0e9896a9fc..23abaa1e0c 100644
--- a/test/escape_map.go
+++ b/test/escape_map.go
@@ -15,7 +15,7 @@ func map0() {
// BAD: i should not escape
i := 0 // ERROR "moved to heap: i"
// BAD: j should not escape
- j := 0 // ERROR "moved to heap: j"
+ j := 0 // ERROR "moved to heap: j"
m[&i] = &j
_ = m
}
@@ -23,8 +23,8 @@ func map0() {
func map1() *int {
m := make(map[*int]*int) // ERROR "make\(map\[\*int\]\*int\) does not escape"
// BAD: i should not escape
- i := 0 // ERROR "moved to heap: i"
- j := 0 // ERROR "moved to heap: j"
+ i := 0 // ERROR "moved to heap: i"
+ j := 0 // ERROR "moved to heap: j"
m[&i] = &j
return m[&i]
}
@@ -41,7 +41,7 @@ func map3() []*int {
m := make(map[*int]*int) // ERROR "make\(map\[\*int\]\*int\) does not escape"
i := 0 // ERROR "moved to heap: i"
// BAD: j should not escape
- j := 0 // ERROR "moved to heap: j"
+ j := 0 // ERROR "moved to heap: j"
m[&i] = &j
var r []*int
for k := range m {
@@ -53,8 +53,8 @@ func map3() []*int {
func map4() []*int {
m := make(map[*int]*int) // ERROR "make\(map\[\*int\]\*int\) does not escape"
// BAD: i should not escape
- i := 0 // ERROR "moved to heap: i"
- j := 0 // ERROR "moved to heap: j"
+ i := 0 // ERROR "moved to heap: i"
+ j := 0 // ERROR "moved to heap: j"
m[&i] = &j
var r []*int
for k, v := range m {
@@ -68,8 +68,8 @@ func map4() []*int {
}
func map5(m map[*int]*int) { // ERROR "m does not escape"
- i := 0 // ERROR "moved to heap: i"
- j := 0 // ERROR "moved to heap: j"
+ i := 0 // ERROR "moved to heap: i"
+ j := 0 // ERROR "moved to heap: j"
m[&i] = &j
}
@@ -77,8 +77,8 @@ func map6(m map[*int]*int) { // ERROR "m does not escape"
if m != nil {
m = make(map[*int]*int) // ERROR "make\(map\[\*int\]\*int\) does not escape"
}
- i := 0 // ERROR "moved to heap: i"
- j := 0 // ERROR "moved to heap: j"
+ i := 0 // ERROR "moved to heap: i"
+ j := 0 // ERROR "moved to heap: j"
m[&i] = &j
}
@@ -87,14 +87,14 @@ func map7() {
i := 0 // ERROR "moved to heap: i"
// BAD: j should not escape
j := 0 // ERROR "moved to heap: j"
- m := map[*int]*int{&i: &j} // ERROR "literal does not escape"
+ m := map[*int]*int{&i: &j} // ERROR "map\[\*int\]\*int{...} does not escape"
_ = m
}
func map8() {
i := 0 // ERROR "moved to heap: i"
j := 0 // ERROR "moved to heap: j"
- m := map[*int]*int{&i: &j} // ERROR "literal escapes to heap"
+ m := map[*int]*int{&i: &j} // ERROR "map\[\*int\]\*int{...} escapes to heap"
sink = m
}
@@ -102,6 +102,6 @@ func map9() *int {
// BAD: i should not escape
i := 0 // ERROR "moved to heap: i"
j := 0 // ERROR "moved to heap: j"
- m := map[*int]*int{&i: &j} // ERROR "literal does not escape"
+ m := map[*int]*int{&i: &j} // ERROR "map\[\*int\]\*int{...} does not escape"
return m[nil]
}