go/analysis/passes/fieldalignment: delete doc style comments in fix

CL 278872 fixed the fact that field comments messed up the suggested
edits by removing comments entirely.

This change also remove documentation style comments since they also
produce broken suggestions in the same way.

Change-Id: I18d9c42fbf1453dcd5019b2a4aa3f4be4a58f7c7
Reviewed-on: https://go-review.googlesource.com/c/tools/+/284732
Trust: Rebecca Stambler <rstambler@golang.org>
Trust: Pontus Leitzler <leitzler@gmail.com>
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
This commit is contained in:
Pontus Leitzler 2021-01-19 20:40:15 +01:00 committed by Rebecca Stambler
parent 917f61dfb7
commit 4922717de7
3 changed files with 15 additions and 0 deletions

View File

@ -79,6 +79,7 @@ func fieldalignment(pass *analysis.Pass, node *ast.StructType, typ *types.Struct
// TODO: Preserve comment, for now get rid of them.
// See https://github.com/golang/go/issues/20744
f.Comment = nil
f.Doc = nil
if len(f.Names) <= 1 {
flat = append(flat, f)
continue

View File

@ -35,3 +35,12 @@ type NoNameBad struct { // want "struct of size 20 could be 16"
y int32
z byte
}
type WithComments struct { // want "struct of size 8 could be 4"
// doc style comment
a uint32 // field a comment
b [0]byte // field b comment
// other doc style comment
// and a last comment
}

View File

@ -35,3 +35,8 @@ type NoNameBad struct {
x byte
z byte
}
type WithComments struct {
b [0]byte
a uint32
}