diff options
author | Matthew Dempsky <mdempsky@google.com> | 2022-01-10 19:18:39 +0000 |
---|---|---|
committer | Matthew Dempsky <mdempsky@google.com> | 2022-01-10 20:53:01 +0000 |
commit | 55d10acb72c2dc5524aae69ade560f3cf308a864 (patch) | |
tree | cbcd9621cdbef4e78f2af5651cc1320807c56086 /src | |
parent | 7de2249a08aab44c512d0ea86f50481d76e135f1 (diff) | |
download | go-55d10acb72c2dc5524aae69ade560f3cf308a864.tar.gz go-55d10acb72c2dc5524aae69ade560f3cf308a864.zip |
Revert "cmd/compile: unique LinkString for renamed, embedded fields"
This reverts CL 372914.
Reason for revert: missing synchronization
Change-Id: I7ebb6de082cebb73741d803ff00e3465bbafab81
Reviewed-on: https://go-review.googlesource.com/c/go/+/377379
Trust: Dan Scales <danscales@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Dan Scales <danscales@google.com>
Trust: Matthew Dempsky <mdempsky@google.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/cmd/compile/internal/types/fmt.go | 37 |
1 files changed, 2 insertions, 35 deletions
diff --git a/src/cmd/compile/internal/types/fmt.go b/src/cmd/compile/internal/types/fmt.go index 1399483424..3198a1f53c 100644 --- a/src/cmd/compile/internal/types/fmt.go +++ b/src/cmd/compile/internal/types/fmt.go @@ -631,7 +631,6 @@ func fldconv(b *bytes.Buffer, f *Field, verb rune, mode fmtMode, visited map[*Ty } var name string - nameSep := " " if verb != 'S' { s := f.Sym @@ -640,41 +639,9 @@ func fldconv(b *bytes.Buffer, f *Field, verb rune, mode fmtMode, visited map[*Ty s = OrigSym(s) } - if s != nil { + if s != nil && f.Embedded == 0 { if funarg != FunargNone { name = fmt.Sprint(f.Nname) - } else if f.Embedded != 0 { - // Using type aliases and embedded fields, it's possible to - // construct types that can't be directly represented as a - // type literal. For example, given "type Int = int" (#50190), - // it would be incorrect to format "struct{ Int }" as either - // "struct{ int }" or "struct{ Int int }", because those each - // represent other, distinct types. - // - // So for the purpose of LinkString (i.e., fmtTypeID), we use - // the non-standard syntax "struct{ Int = int }" to represent - // embedded fields that have been renamed through the use of - // type aliases. - if mode == fmtTypeID { - // Compute styp, the symbol that would normally be used as - // the field name when embedding f.Type. - // TODO(mdempsky): Check for other occurences of this logic - // and deduplicate. - typ := f.Type - if typ.Sym() == nil && typ.IsPtr() { - typ = typ.Elem() - } - styp := typ.Sym() - if styp != nil && IsExported(styp.Name) { - styp = LocalPkg.Lookup(styp.Name) - } - - // If embedded field was renamed, use syntax extension. - if s != styp { - name = sconv(s, 0, mode) - nameSep = " = " - } - } } else if verb == 'L' { name = s.Name if name == ".F" { @@ -691,7 +658,7 @@ func fldconv(b *bytes.Buffer, f *Field, verb rune, mode fmtMode, visited map[*Ty if name != "" { b.WriteString(name) - b.WriteString(nameSep) + b.WriteString(" ") } if f.IsDDD() { |