diff options
author | Robert Griesemer <gri@golang.org> | 2021-01-08 10:29:11 -0800 |
---|---|---|
committer | Robert Griesemer <gri@golang.org> | 2021-01-08 22:00:23 +0000 |
commit | 822aeacd9ed0630f84552d3120a12ddaa65b23cc (patch) | |
tree | 59c9f533e65a9f6ef3189fb72736e6d7b4308ff3 /src/cmd/compile/internal/syntax | |
parent | d017a1b64951d43b009c18454443025cbc9373e1 (diff) | |
download | go-822aeacd9ed0630f84552d3120a12ddaa65b23cc.tar.gz go-822aeacd9ed0630f84552d3120a12ddaa65b23cc.zip |
[dev.typeparams] cmd/compile/internal/syntax: remove ShortString, use String instead
Follow-up on feedback by mdempsky@ in https://golang.org/cl/282552 .
Change-Id: I1e5bb2d67cc8ae29fed100b87d18a33b3e2069eb
Reviewed-on: https://go-review.googlesource.com/c/go/+/282672
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Diffstat (limited to 'src/cmd/compile/internal/syntax')
-rw-r--r-- | src/cmd/compile/internal/syntax/printer.go | 11 | ||||
-rw-r--r-- | src/cmd/compile/internal/syntax/printer_test.go | 2 |
2 files changed, 5 insertions, 8 deletions
diff --git a/src/cmd/compile/internal/syntax/printer.go b/src/cmd/compile/internal/syntax/printer.go index 0a60e1753d..161eb0d092 100644 --- a/src/cmd/compile/internal/syntax/printer.go +++ b/src/cmd/compile/internal/syntax/printer.go @@ -44,20 +44,17 @@ func Fprint(w io.Writer, x Node, form Form) (n int, err error) { return } -func asString(n Node, form Form) string { +// String is a convenience functions that prints n in ShortForm +// and returns the printed string. +func String(n Node) string { var buf bytes.Buffer - _, err := Fprint(&buf, n, form) + _, err := Fprint(&buf, n, ShortForm) if err != nil { fmt.Fprintf(&buf, "<<< ERROR: %s", err) } return buf.String() } -// String and ShortString are convenience functions that print n in -// LineForm or ShortForm respectively, and return the printed string. -func String(n Node) string { return asString(n, LineForm) } -func ShortString(n Node) string { return asString(n, ShortForm) } - type ctrlSymbol int const ( diff --git a/src/cmd/compile/internal/syntax/printer_test.go b/src/cmd/compile/internal/syntax/printer_test.go index e83e9c1b2c..bcae815a46 100644 --- a/src/cmd/compile/internal/syntax/printer_test.go +++ b/src/cmd/compile/internal/syntax/printer_test.go @@ -178,7 +178,7 @@ func TestShortString(t *testing.T) { continue } x := ast.DeclList[0].(*VarDecl).Values - if got := ShortString(x); got != test[1] { + if got := String(x); got != test[1] { t.Errorf("%s: got %s, want %s", test[0], got, test[1]) } } |