Skip to content

Commit

Permalink
cue/load: clean up allTags
Browse files Browse the repository at this point in the history
It was a remnant of this refactor and hasn't been used since:
https://cue-review.googlesource.com/c/cue/+/7901

Originally (before that CL) the Instance.AllTags field was populated
from //+build comments, something that's never been a supported thing in
CUE. It seems like it was a remnant of the original Go code this was
derived from.

Since that CL, the `AllTags` field has always remained empty and never
populated.

Signed-off-by: Roger Peppe <[email protected]>
Change-Id: I2a90c720ff567bd4eed7cec21f7a980654600cd2
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1197523
Reviewed-by: Paul Jolly <[email protected]>
Unity-Result: CUE porcuepine <[email protected]>
TryBot-Result: CUEcueckoo <[email protected]>
  • Loading branch information
rogpeppe committed Jul 11, 2024
1 parent d5d4815 commit 59fe2e4
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 11 deletions.
2 changes: 2 additions & 0 deletions cue/build/instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ type Instance struct {

// AllTags are the build tags that can influence file selection in this
// directory.
//
// Deprecated: this field is not used.
AllTags []string `api:"alpha"`

// Incomplete reports whether any dependencies had an error.
Expand Down
9 changes: 1 addition & 8 deletions cue/load/loader_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ type fileProcessor struct {
firstFile string
firstCommentFile string
imported map[string][]token.Pos
allTags map[string]bool
ignoreOther bool // ignore files from other packages
allPackages bool

Expand All @@ -119,7 +118,6 @@ type fileProcessorConfig = Config
func newFileProcessor(c *fileProcessorConfig, p *build.Instance, tg *tagger) *fileProcessor {
return &fileProcessor{
imported: make(map[string][]token.Pos),
allTags: make(map[string]bool),
c: c,
pkgs: map[string]*build.Instance{"_": p},
pkg: p,
Expand Down Expand Up @@ -151,11 +149,6 @@ func (fp *fileProcessor) finalize(p *build.Instance) errors.Error {
return fp.err
}

for tag := range fp.allTags {
p.AllTags = append(p.AllTags, tag)
}
sort.Strings(p.AllTags)

p.ImportPaths, _ = cleanImports(fp.imported)

return nil
Expand Down Expand Up @@ -187,7 +180,7 @@ func (fp *fileProcessor) add(root string, file *build.File, mode importMode) (ad
return badFile(errors.Promote(err, ""))
}

match, data, err := matchFile(fp.c, file, true, fp.allTags, mode)
match, data, err := matchFile(fp.c, file, true, mode)
switch {
case match:

Expand Down
4 changes: 1 addition & 3 deletions cue/load/match.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,7 @@ func (e excludeError) Is(err error) bool { return err == errExclude }
// If returnImports is true and name denotes a CUE file, matchFile reads
// until the end of the imports (and returns that data) even though it only
// considers text until the first non-comment.
// If allTags is non-nil, matchFile records any encountered build tag
// by setting allTags[tag] = true.
func matchFile(cfg *Config, file *build.File, returnImports bool, allTags map[string]bool, mode importMode) (match bool, data []byte, err errors.Error) {
func matchFile(cfg *Config, file *build.File, returnImports bool, mode importMode) (match bool, data []byte, err errors.Error) {
// Note: file.Source should already have been set by setFileSource just
// after the build.File value was created.
if file.Encoding != build.CUE {
Expand Down

0 comments on commit 59fe2e4

Please sign in to comment.