diff options
author | Cuong Manh Le <cuong.manhle.vn@gmail.com> | 2020-09-09 11:09:01 +0700 |
---|---|---|
committer | Cuong Manh Le <cuong.manhle.vn@gmail.com> | 2020-09-12 08:31:49 +0000 |
commit | 2c95e3a6a8377ca9c72608c25b4cf2506baf782f (patch) | |
tree | e8696bf16d352c026cf84e0cab63c53369f67fe8 /test/escape_iface.go | |
parent | d7384f36121d52191097af50d6dc12c0eb08fd75 (diff) | |
download | go-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_iface.go')
-rw-r--r-- | test/escape_iface.go | 50 |
1 files changed, 25 insertions, 25 deletions
diff --git a/test/escape_iface.go b/test/escape_iface.go index 118ed3c56f..7b0914cadb 100644 --- a/test/escape_iface.go +++ b/test/escape_iface.go @@ -37,7 +37,7 @@ func efaceEscape0() { _ = x } { - i := 0 // ERROR "moved to heap: i" + i := 0 // ERROR "moved to heap: i" v := M0{&i} var x M = v sink = x @@ -50,7 +50,7 @@ func efaceEscape0() { _ = v1 } { - i := 0 // ERROR "moved to heap: i" + i := 0 // ERROR "moved to heap: i" v := M0{&i} // BAD: v does not escape to heap here var x M = v @@ -58,14 +58,14 @@ func efaceEscape0() { sink = v1 } { - i := 0 // ERROR "moved to heap: i" + i := 0 // ERROR "moved to heap: i" v := M0{&i} // BAD: v does not escape to heap here var x M = v x.M() } { - i := 0 // ERROR "moved to heap: i" + i := 0 // ERROR "moved to heap: i" v := M0{&i} var x M = v mescapes(x) @@ -91,46 +91,46 @@ func efaceEscape1() { { i := 0 v := M1{&i, 0} - var x M = v // ERROR "v does not escape" + var x M = v // ERROR "v does not escape" _ = x } { - i := 0 // ERROR "moved to heap: i" + i := 0 // ERROR "moved to heap: i" v := M1{&i, 0} - var x M = v // ERROR "v escapes to heap" + var x M = v // ERROR "v escapes to heap" sink = x } { i := 0 v := M1{&i, 0} - var x M = v // ERROR "v does not escape" + var x M = v // ERROR "v does not escape" v1 := x.(M1) _ = v1 } { - i := 0 // ERROR "moved to heap: i" + i := 0 // ERROR "moved to heap: i" v := M1{&i, 0} var x M = v // ERROR "v does not escape" v1 := x.(M1) sink = v1 // ERROR "v1 escapes to heap" } { - i := 0 // ERROR "moved to heap: i" + i := 0 // ERROR "moved to heap: i" v := M1{&i, 0} // BAD: v does not escape to heap here var x M = v // ERROR "v escapes to heap" x.M() } { - i := 0 // ERROR "moved to heap: i" + i := 0 // ERROR "moved to heap: i" v := M1{&i, 0} - var x M = v // ERROR "v escapes to heap" + var x M = v // ERROR "v escapes to heap" mescapes(x) } { i := 0 v := M1{&i, 0} - var x M = v // ERROR "v does not escape" + var x M = v // ERROR "v does not escape" mdoesnotescape(x) } } @@ -146,26 +146,26 @@ func (*M2) M() { func efaceEscape2() { { i := 0 - v := &M2{&i} // ERROR "&M2 literal does not escape" + v := &M2{&i} // ERROR "&M2{...} does not escape" var x M = v _ = x } { i := 0 // ERROR "moved to heap: i" - v := &M2{&i} // ERROR "&M2 literal escapes to heap" + v := &M2{&i} // ERROR "&M2{...} escapes to heap" var x M = v sink = x } { i := 0 - v := &M2{&i} // ERROR "&M2 literal does not escape" + v := &M2{&i} // ERROR "&M2{...} does not escape" var x M = v v1 := x.(*M2) _ = v1 } { i := 0 // ERROR "moved to heap: i" - v := &M2{&i} // ERROR "&M2 literal escapes to heap" + v := &M2{&i} // ERROR "&M2{...} escapes to heap" // BAD: v does not escape to heap here var x M = v v1 := x.(*M2) @@ -173,7 +173,7 @@ func efaceEscape2() { } { i := 0 // ERROR "moved to heap: i" - v := &M2{&i} // ERROR "&M2 literal does not escape" + v := &M2{&i} // ERROR "&M2{...} does not escape" // BAD: v does not escape to heap here var x M = v v1 := x.(*M2) @@ -181,7 +181,7 @@ func efaceEscape2() { } { i := 0 // ERROR "moved to heap: i" - v := &M2{&i} // ERROR "&M2 literal does not escape" + v := &M2{&i} // ERROR "&M2{...} does not escape" // BAD: v does not escape to heap here var x M = v v1, ok := x.(*M2) @@ -190,20 +190,20 @@ func efaceEscape2() { } { i := 0 // ERROR "moved to heap: i" - v := &M2{&i} // ERROR "&M2 literal escapes to heap" + v := &M2{&i} // ERROR "&M2{...} escapes to heap" // BAD: v does not escape to heap here var x M = v x.M() } { i := 0 // ERROR "moved to heap: i" - v := &M2{&i} // ERROR "&M2 literal escapes to heap" + v := &M2{&i} // ERROR "&M2{...} escapes to heap" var x M = v mescapes(x) } { i := 0 - v := &M2{&i} // ERROR "&M2 literal does not escape" + v := &M2{&i} // ERROR "&M2{...} does not escape" var x M = v mdoesnotescape(x) } @@ -219,8 +219,8 @@ type T2 struct { func dotTypeEscape() *T2 { // #11931 var x interface{} - x = &T1{p: new(int)} // ERROR "new\(int\) escapes to heap" "&T1 literal does not escape" - return &T2{ // ERROR "&T2 literal escapes to heap" + x = &T1{p: new(int)} // ERROR "new\(int\) escapes to heap" "&T1{...} does not escape" + return &T2{ // ERROR "&T2{...} escapes to heap" T1: *(x.(*T1)), } } @@ -244,7 +244,7 @@ func dotTypeEscape2() { // #13805, #15796 var x interface{} = i // ERROR "i does not escape" var y interface{} = j // ERROR "j does not escape" - sink = x.(int) // ERROR "x.\(int\) escapes to heap" + sink = x.(int) // ERROR "x.\(int\) escapes to heap" sink, *(&ok) = y.(int) } { |