this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

cue/ast: remove the deprecated File.Imports slice

The replacement, File.ImportSpecs, was added in mid 2025
alongside a deprecation and a `//go:fix inline` directive.
This was all released with CUE v0.15.0 in November 2025.

Now that we're working towards CUE v0.17.0, probably to be released
around June 2026, it's time to remove this as planned.

Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
Change-Id: Ib2d0d0d716ffffb3900a9739734948733a7b18bb
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1235757
Unity-Result: CUE porcuepine <cue.porcuepine@gmail.com>
Reviewed-by: Matthew Sackman <matthew@cue.works>
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>

+5 -67
-4
cue/ast/ast.go
··· 1093 1093 Filename string 1094 1094 Decls []Decl // top-level declarations; or nil 1095 1095 1096 - // Deprecated: use [File.ImportSpecs]. 1097 - // TODO(mvdan): remove in mid 2026. 1098 - Imports []*ImportSpec // imports in this file 1099 - 1100 1096 Unresolved []*Ident // unresolved identifiers in this file 1101 1097 1102 1098 // TODO remove this field: it's here as a temporary
+5 -11
cue/ast/astutil/sanitize.go
··· 17 17 import ( 18 18 "fmt" 19 19 "math/rand/v2" 20 + "slices" 20 21 "strings" 21 22 22 23 "cuelang.org/go/cue/ast" ··· 171 172 } 172 173 173 174 func (z *sanitizer) cleanImports() { 174 - var fileImports []*ast.ImportSpec 175 175 for decl := range z.file.ImportDecls() { 176 - newLen := 0 177 - for _, spec := range decl.Specs { 178 - if _, ok := z.referenced[spec]; ok { 179 - fileImports = append(fileImports, spec) 180 - decl.Specs[newLen] = spec 181 - newLen++ 182 - } 183 - } 184 - decl.Specs = decl.Specs[:newLen] 176 + decl.Specs = slices.DeleteFunc(decl.Specs, func(spec *ast.ImportSpec) bool { 177 + _, ok := z.referenced[spec] 178 + return !ok 179 + }) 185 180 } 186 - z.file.Imports = fileImports 187 181 // Ensure that the first import always starts a new section 188 182 // so that if the file has a comment, it won't be associated with 189 183 // the import comment rather than the file.
-1
cue/build/instance_test.go
··· 44 44 Expr: &ast.Ident{Name: "bar", Node: spec2}, 45 45 }, 46 46 }, 47 - Imports: []*ast.ImportSpec{spec1, spec2}, 48 47 } 49 48 50 49 p := &Instance{
-4
cue/parser/parser.go
··· 72 72 73 73 // Non-syntactic parser control 74 74 exprLev int // < 0: in control clause, >= 0: in expression 75 - 76 - imports []*ast.ImportSpec // list of imports 77 75 } 78 76 79 77 func (p *parser) init(filename string, src []byte, opts []Option) { ··· 1860 1858 Path: &ast.BasicLit{ValuePos: pos, Kind: token.STRING, Value: path}, 1861 1859 } 1862 1860 c.closeNode(p, spec) 1863 - p.imports = append(p.imports, spec) 1864 1861 1865 1862 return spec 1866 1863 } ··· 1978 1975 p.closeList() 1979 1976 1980 1977 f := &ast.File{ 1981 - Imports: p.imports, 1982 1978 Decls: decls, 1983 1979 LanguageVersion: p.cfg.Version, 1984 1980 }
-47
internal/astinternal/testdata/debugprint/file.txtar
··· 100 100 Rparen: token.Pos("imports.cue:8:1", newline) 101 101 } 102 102 } 103 - Imports: []*ast.ImportSpec{ 104 - { 105 - Path: *ast.BasicLit{ 106 - ValuePos: token.Pos("imports.cue:3:8", blank) 107 - Kind: token.Token("STRING") 108 - Value: "\"foo\"" 109 - } 110 - } 111 - { 112 - Path: *ast.BasicLit{ 113 - ValuePos: token.Pos("imports.cue:6:2", newline) 114 - Kind: token.Token("STRING") 115 - Value: "\"bar\"" 116 - } 117 - } 118 - { 119 - Name: *ast.Ident{ 120 - NamePos: token.Pos("imports.cue:7:2", newline) 121 - Name: "name" 122 - } 123 - Path: *ast.BasicLit{ 124 - ValuePos: token.Pos("imports.cue:7:7", blank) 125 - Kind: token.Token("STRING") 126 - Value: "\"baz\"" 127 - } 128 - } 129 - } 130 103 LanguageVersion: "v0.13.0" 131 104 } 132 105 -- out/debugprint/empty.cue/omitempty-strings -- ··· 196 169 Value: "\"baz\"" 197 170 } 198 171 } 199 - } 200 - } 201 - } 202 - Imports: []*ast.ImportSpec{ 203 - { 204 - Path: *ast.BasicLit{ 205 - Value: "\"foo\"" 206 - } 207 - } 208 - { 209 - Path: *ast.BasicLit{ 210 - Value: "\"bar\"" 211 - } 212 - } 213 - { 214 - Name: *ast.Ident{ 215 - Name: "name" 216 - } 217 - Path: *ast.BasicLit{ 218 - Value: "\"baz\"" 219 172 } 220 173 } 221 174 }