cue/ast: allow CommentGroups in NewStruct

Change-Id: I1808763b88e4b249a7db470f8b26507aafa3c130
Reviewed-on: https://cue-review.googlesource.com/c/cue/+/5082
Reviewed-by: Marcel van Lohuizen <mpvl@golang.org>
diff --git a/cue/ast/ast.go b/cue/ast/ast.go
index 069926d..3238a99 100644
--- a/cue/ast/ast.go
+++ b/cue/ast/ast.go
@@ -479,12 +479,14 @@
 }
 
 // NewStruct creates a struct from the given fields.
-// A field is either a *Field, an *Elipsis or a Label, optionally followed by a
-// a token.OPTION to indicate the field is optional, optionally followed by a
-// token.ISA to indicate the field is a defintion followed by an expression
-// for the field value.
-// It will panic if a values not matching these patterns are given.
-// Useful for ASTs generated by code other than the CUE parser.
+//
+// A field is either a *Field, an *Elipsis, a *CommentGroup, or a Label,
+// optionally followed by a a token.OPTION to indicate the field is optional,
+// optionally followed by a token.ISA to indicate the field is a defintion
+// followed by an expression for the field value.
+//
+// It will panic if a values not matching these patterns are given. Useful for
+// ASTs generated by code other than the CUE parser.
 func NewStruct(fields ...interface{}) *StructLit {
 	s := &StructLit{}
 	for i := 0; i < len(fields); i++ {
@@ -499,6 +501,9 @@
 		case *Field:
 			s.Elts = append(s.Elts, x)
 			continue
+		case *CommentGroup:
+			s.Elts = append(s.Elts, x)
+			continue
 		case *Ellipsis:
 			s.Elts = append(s.Elts, x)
 			continue