X Tutup
Skip to content

Commit 08f19bb

Browse files
committed
go/printer: forbid empty line before first comment in block
To improve readability when exported fields are removed, forbid the printer from emitting an empty line before the first comment in a const, var, or type block. Also, when printing the "Has filtered or unexported fields." message, add an empty line before it to separate the message from the struct or interfact contents. Before the change: <<< type NamedArg struct { // Name is the name of the parameter placeholder. // // If empty, the ordinal position in the argument list will be // used. // // Name must omit any symbol prefix. Name string // Value is the value of the parameter. // It may be assigned the same value types as the query // arguments. Value interface{} // contains filtered or unexported fields } >>> After the change: <<< type NamedArg struct { // Name is the name of the parameter placeholder. // // If empty, the ordinal position in the argument list will be // used. // // Name must omit any symbol prefix. Name string // Value is the value of the parameter. // It may be assigned the same value types as the query // arguments. Value interface{} // contains filtered or unexported fields } >>> Fixes golang#18264 Change-Id: I9fe17ca39cf92fcdfea55064bd2eaa784ce48c88 Reviewed-on: https://go-review.googlesource.com/71990 Run-TryBot: Joe Tsai <thebrokentoaster@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org>
1 parent 8585f9f commit 08f19bb

File tree

30 files changed

+293
-26
lines changed

30 files changed

+293
-26
lines changed

misc/cgo/test/buildid_linux.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ func testBuildID(t *testing.T) {
3939
}
4040

4141
for len(d) > 0 {
42-
4342
// ELF standards differ as to the sizes in
4443
// note sections. Both the GNU linker and
4544
// gold always generate 32-bit sizes, so that

src/cmd/compile/internal/ssa/gen/rulegen.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -659,7 +659,6 @@ func extract(val string) (op string, typ string, auxint string, aux string, args
659659
// It returns the op and unparsed strings for typ, auxint, and aux restrictions and for all args.
660660
// oparch is the architecture that op is located in, or "" for generic.
661661
func parseValue(val string, arch arch, loc string) (op opData, oparch string, typ string, auxint string, aux string, args []string) {
662-
663662
// Resolve the op.
664663
var s string
665664
s, typ, auxint, aux, args = extract(val)

src/cmd/internal/obj/ppc64/asm9.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2468,7 +2468,6 @@ func (c *ctxt9) asmout(p *obj.Prog, o *Optab, out []uint32) {
24682468
d := c.vregoff(p.GetFrom3())
24692469
var a int
24702470
switch p.As {
2471-
24722471
// These opcodes expect a mask operand that has to be converted into the
24732472
// appropriate operand. The way these were defined, not all valid masks are possible.
24742473
// Left here for compatibility in case they were used or generated.

src/cmd/internal/obj/x86/asm6.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1996,7 +1996,6 @@ func span6(ctxt *obj.Link, s *obj.LSym, newprog obj.ProgAlloc) {
19961996
c = 0
19971997
for p := s.Func.Text; p != nil; p = p.Link {
19981998
if ctxt.Headtype == objabi.Hnacl && p.Isize > 0 {
1999-
20001999
// pad everything to avoid crossing 32-byte boundary
20012000
if c>>5 != (c+int32(p.Isize)-1)>>5 {
20022001
c = naclpad(ctxt, s, c, -c&31)

src/cmd/link/internal/ld/data.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1857,7 +1857,6 @@ func assignAddress(ctxt *Link, sect *sym.Section, n int, s *sym.Symbol, va uint6
18571857
// Only break at outermost syms.
18581858

18591859
if ctxt.Arch.InFamily(sys.PPC64) && s.Outer == nil && ctxt.IsELF && ctxt.LinkMode == LinkExternal && va-sect.Vaddr+funcsize+maxSizeTrampolinesPPC64(s, isTramp) > 0x1c00000 {
1860-
18611860
// Set the length for the previous text section
18621861
sect.Length = va - sect.Vaddr
18631862

src/cmd/link/internal/ppc64/asm.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,6 @@ func archrelocaddr(ctxt *ld.Link, r *sym.Reloc, s *sym.Symbol, val *int64) bool
523523

524524
// resolve direct jump relocation r in s, and add trampoline if necessary
525525
func trampoline(ctxt *ld.Link, r *sym.Reloc, s *sym.Symbol) {
526-
527526
// Trampolines are created if the branch offset is too large and the linker cannot insert a call stub to handle it.
528527
// For internal linking, trampolines are always created for long calls.
529528
// For external linking, the linker can insert a call stub to handle a long call, but depends on having the TOC address in
@@ -542,7 +541,6 @@ func trampoline(ctxt *ld.Link, r *sym.Reloc, s *sym.Symbol) {
542541
if (ctxt.LinkMode == ld.LinkExternal && s.Sect != r.Sym.Sect) || (ctxt.LinkMode == ld.LinkInternal && int64(int32(t<<6)>>6) != t) || (*ld.FlagDebugTramp > 1 && s.File != r.Sym.File) {
543542
var tramp *sym.Symbol
544543
for i := 0; ; i++ {
545-
546544
// Using r.Add as part of the name is significant in functions like duffzero where the call
547545
// target is at some offset within the function. Calls to duff+8 and duff+256 must appear as
548546
// distinct trampolines.

src/encoding/base32/base32.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,6 @@ func (enc *Encoding) decode(dst, src []byte) (n int, end bool, err error) {
290290
dlen := 8
291291

292292
for j := 0; j < 8; {
293-
294293
// We have reached the end and are missing padding
295294
if len(src) == 0 && enc.padChar != NoPadding {
296295
return n, false, CorruptInputError(olen - len(src) - j)

src/go/doc/testdata/blank.0.golden

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ TYPES
4848
H uint32
4949

5050
A uint8
51+
5152
// contains filtered or unexported fields
5253
}
5354

src/go/doc/testdata/blank.2.golden

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ TYPES
4848
H uint32
4949

5050
A uint8
51+
5152
// contains filtered or unexported fields
5253
}
5354

src/go/doc/testdata/testing.0.golden

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ TYPES
4242
// B is a type passed to Benchmark functions to manage benchmark ...
4343
type B struct {
4444
N int
45+
4546
// contains filtered or unexported fields
4647
}
4748

0 commit comments

Comments
 (0)
X Tutup