this repo has no description
0
fork

Configure Feed

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

all: tidy up deprecation warnings a bit

In APIs like Runtime.Compile, point to non-deprecated alternatives,
rather than pointing to methods which are themselves also deprecated.

While here, tidy up other deprecated notes so that they use doc links.

Also note that Instance.LookupField had two deprecation notices;
only the second seems to have been up to date.

Fixes #1735.

Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
Change-Id: Ie8d8ba3e76855f36d3746a1e65c9d8af17737dbc
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1195013
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>
Unity-Result: CUE porcuepine <cue.porcuepine@gmail.com>
Reviewed-by: Paul Jolly <paul@myitcv.io>

+22 -23
+6 -5
cue/build.go
··· 31 31 // The zero value of Runtime works for legacy reasons, but 32 32 // should not be used. It may panic at some point. 33 33 // 34 - // Deprecated: use Context. 34 + // Deprecated: use [Context]. 35 35 type Runtime runtime.Runtime 36 36 37 37 func (r *Runtime) runtime() *runtime.Runtime { ··· 57 57 // name in position information. The source may import builtin packages. Use 58 58 // Build to allow importing non-builtin packages. 59 59 // 60 - // Deprecated: use Parse or ParseBytes. The use of Instance is being phased out. 60 + // Deprecated: use [Context] with methods like [Context.CompileString] or [Context.CompileBytes]. 61 + // The use of [Instance] is being phased out. 61 62 func (r *hiddenRuntime) Compile(filename string, source interface{}) (*Instance, error) { 62 63 cfg := &runtime.Config{Filename: filename} 63 64 v, p := r.runtime().Compile(cfg, source) ··· 67 68 // CompileFile compiles the given source file into an Instance. The source may 68 69 // import builtin packages. Use Build to allow importing non-builtin packages. 69 70 // 70 - // Deprecated: use BuildFile. The use of Instance is being phased out. 71 + // Deprecated: use [Context.BuildFile]. The use of [Instance] is being phased out. 71 72 func (r *hiddenRuntime) CompileFile(file *ast.File) (*Instance, error) { 72 73 v, p := r.runtime().CompileFile(nil, file) 73 74 return r.complete(p, v) ··· 77 78 // may import builtin packages. Use Build to allow importing non-builtin 78 79 // packages. 79 80 // 80 - // Deprecated: use BuildExpr. The use of Instance is being phased out. 81 + // Deprecated: use [Context.BuildExpr]. The use of [Instance] is being phased out. 81 82 func (r *hiddenRuntime) CompileExpr(expr ast.Expr) (*Instance, error) { 82 83 f, err := astutil.ToFile(expr) 83 84 if err != nil { ··· 148 149 // FromExpr creates an instance from an expression. 149 150 // Any references must be resolved beforehand. 150 151 // 151 - // Deprecated: use CompileExpr 152 + // Deprecated: use [Context.BuildExpr]. The use of [Instance] is being phased out. 152 153 func (r *hiddenRuntime) FromExpr(expr ast.Expr) (*Instance, error) { 153 154 return r.CompileFile(&ast.File{ 154 155 Decls: []ast.Decl{&ast.EmbedDecl{Expr: expr}},
+2 -1
cue/errors/errors.go
··· 84 84 } 85 85 86 86 // NewMessage creates an error message for human consumption. 87 - // Deprecated: Use NewMessagef instead. 87 + // 88 + // Deprecated: Use [NewMessagef] instead. 88 89 func NewMessage(format string, args []interface{}) Message { 89 90 return NewMessagef(format, args...) 90 91 }
+5 -8
cue/instance.go
··· 244 244 // identifier to bind to the top-level field in inst. The top-level fields in 245 245 // inst take precedence over predeclared identifier and builtin functions. 246 246 // 247 - // Deprecated: use Context.Build 247 + // Deprecated: use [Context.BuildInstance] 248 248 func (inst *hiddenInstance) Build(p *build.Instance) *Instance { 249 249 p.Complete() 250 250 ··· 279 279 // empty path returns the top-level configuration struct. Use LookupDef for definitions or LookupField for 280 280 // any kind of field. 281 281 // 282 - // Deprecated: use Value.LookupPath 282 + // Deprecated: use [Value.LookupPath] 283 283 func (inst *hiddenInstance) Lookup(path ...string) Value { 284 284 return inst.Value().Lookup(path...) 285 285 } ··· 288 288 // Exists method of the returned value will report false if the definition did 289 289 // not exist. The Err method reports if any error occurred during evaluation. 290 290 // 291 - // Deprecated: use Value.LookupPath 291 + // Deprecated: use [Value.LookupPath] 292 292 func (inst *hiddenInstance) LookupDef(path string) Value { 293 293 return inst.Value().LookupDef(path) 294 294 } ··· 298 298 // 299 299 // It cannot look up hidden or unexported fields. 300 300 // 301 - // Deprecated: this API does not work with new-style definitions. Use 302 - // FieldByName defined on inst.Value(). 303 - // 304 - // Deprecated: use Value.LookupPath 301 + // Deprecated: use [Value.LookupPath] 305 302 func (inst *hiddenInstance) LookupField(path ...string) (f FieldInfo, err error) { 306 303 v := inst.Value() 307 304 for _, k := range path { ··· 329 326 // a Value. In the latter case, it will panic if the Value is not from the same 330 327 // Runtime. 331 328 // 332 - // Deprecated: use Value.FillPath() 329 + // Deprecated: use [Value.FillPath] 333 330 func (inst *hiddenInstance) Fill(x interface{}, path ...string) (*Instance, error) { 334 331 v := inst.Value().Fill(x, path...) 335 332
+8 -8
cue/types.go
··· 1304 1304 1305 1305 // Elem returns the value of undefined element types of lists and structs. 1306 1306 // 1307 - // Deprecated: use LookupPath in combination with "AnyString" or "AnyIndex". 1307 + // Deprecated: use [Value.LookupPath] in combination with "AnyString" or "AnyIndex". 1308 1308 func (v hiddenValue) Elem() (Value, bool) { 1309 1309 sel := AnyString 1310 1310 if v.v.IsList() { ··· 1472 1472 // Struct returns the underlying struct of a value or an error if the value 1473 1473 // is not a struct. 1474 1474 // 1475 - // Deprecated: use Fields. 1475 + // Deprecated: use [Value.Fields]. 1476 1476 func (v hiddenValue) Struct() (*Struct, error) { 1477 1477 ctx := v.ctx() 1478 1478 obj, err := v.structValOpts(ctx, options{}) ··· 1641 1641 1642 1642 // LookupDef is equal to LookupPath(MakePath(Def(name))). 1643 1643 // 1644 - // Deprecated: use LookupPath. 1644 + // Deprecated: use [Value.LookupPath]. 1645 1645 func (v hiddenValue) LookupDef(name string) Value { 1646 1646 return v.LookupPath(MakePath(Def(name))) 1647 1647 } ··· 1652 1652 // look up a definition or hidden field (starting with `_` or `_#`). Otherwise 1653 1653 // it interprets name as an arbitrary string for a regular field. 1654 1654 // 1655 - // Deprecated: use LookupPath. 1655 + // Deprecated: use [Value.LookupPath]. 1656 1656 func (v hiddenValue) FieldByName(name string, isIdent bool) (f FieldInfo, err error) { 1657 1657 s, err := v.Struct() 1658 1658 if err != nil { ··· 1663 1663 1664 1664 // LookupField reports information about a field of v. 1665 1665 // 1666 - // Deprecated: use LookupPath 1666 + // Deprecated: use [Value.LookupPath]. 1667 1667 func (v hiddenValue) LookupField(name string) (FieldInfo, error) { 1668 1668 s, err := v.Struct() 1669 1669 if err != nil { ··· 1701 1701 // Any reference in v referring to the value at the given path will resolve 1702 1702 // to x in the newly created value. The resulting value is not validated. 1703 1703 // 1704 - // Deprecated: use FillPath. 1704 + // Deprecated: use [Value.FillPath]. 1705 1705 func (v hiddenValue) Fill(x interface{}, path ...string) Value { 1706 1706 if v.v == nil { 1707 1707 return v ··· 1807 1807 // The returned function returns the value that would be unified with field 1808 1808 // given its name. 1809 1809 // 1810 - // Deprecated: use LookupPath in combination with using optional selectors. 1810 + // Deprecated: use [Value.LookupPath] in combination with using optional selectors. 1811 1811 func (v hiddenValue) Template() func(label string) Value { 1812 1812 if v.v == nil { 1813 1813 return nil ··· 2162 2162 2163 2163 // ResolveReferences forces the evaluation of references when outputting. 2164 2164 // 2165 - // Deprecated: Syntax will now always attempt to resolve dangling references and 2165 + // Deprecated: [Value.Syntax] will now always attempt to resolve dangling references and 2166 2166 // make the output self-contained. When [Final] or [Concrete] are used, 2167 2167 // it will already attempt to resolve all references. 2168 2168 // See also [InlineImports].
+1 -1
pkg/list/sort.go
··· 211 211 return arc 212 212 } 213 213 214 - // Deprecated: use Sort, which is always stable 214 + // Deprecated: use [Sort], which is always stable 215 215 func SortStable(list []cue.Value, cmp cue.Value) (sorted []cue.Value, err error) { 216 216 s := makeValueSorter(list, cmp) 217 217 sort.Stable(&s)