cue: delete dead code
Change-Id: I49a7f3b46b5c40290ee21309fa832e0d55d0a54a
Reviewed-on: https://cue-review.googlesource.com/c/cue/+/2209
Reviewed-by: Marcel van Lohuizen <mpvl@google.com>
diff --git a/cmd/cue/cmd/custom.go b/cmd/cue/cmd/custom.go
index 67f6a45..74aaa24 100644
--- a/cmd/cue/cmd/custom.go
+++ b/cmd/cue/cmd/custom.go
@@ -294,10 +294,6 @@
}, nil
}
-func isValid(v cue.Value) bool {
- return v.Kind() == cue.BottomKind
-}
-
func init() {
itask.Register("cmd/cue/cmd.Test", newTestServerCmd)
}
diff --git a/cmd/cue/cmd/get_go.go b/cmd/cue/cmd/get_go.go
index 707eb3d..34523d8 100644
--- a/cmd/cue/cmd/get_go.go
+++ b/cmd/cue/cmd/get_go.go
@@ -215,11 +215,6 @@
var cueTestRoot string // the CUE module root for test purposes.
-type dstUsed struct {
- dst string
- used bool
-}
-
func (e *extractor) initExclusions(str string) {
e.exclude = str
for _, re := range strings.Split(str, ",") {
@@ -245,7 +240,6 @@
cmd *cobra.Command
stderr io.Writer
- err error
pkgs []*packages.Package
done map[string]bool
@@ -277,14 +271,6 @@
e.usedInFile[pkg] = true
}
-func (e *extractor) errorf(format string, args ...interface{}) {
- err := fmt.Errorf(format, args...)
- fmt.Fprintln(e.stderr, err)
- if e.err == nil {
- e.err = err
- }
-}
-
func initInterfaces() error {
cfg := &packages.Config{
Mode: packages.LoadAllSyntax,
diff --git a/cmd/cue/cmd/import.go b/cmd/cue/cmd/import.go
index 16801ba..a48416b 100644
--- a/cmd/cue/cmd/import.go
+++ b/cmd/cue/cmd/import.go
@@ -23,7 +23,6 @@
"os"
"path/filepath"
"regexp"
- "strconv"
"strings"
"sync"
"unicode"
@@ -543,10 +542,6 @@
}
}
-func newString(s string) *ast.BasicLit {
- return &ast.BasicLit{Kind: token.STRING, Value: strconv.Quote(s)}
-}
-
func (x *listIndex) label(label ast.Label) *listIndex {
key := internal.DebugStr(label)
idx := x.index[key]
diff --git a/cmd/cue/cmd/root.go b/cmd/cue/cmd/root.go
index 5b3a964..49abeb7 100644
--- a/cmd/cue/cmd/root.go
+++ b/cmd/cue/cmd/root.go
@@ -38,8 +38,6 @@
var log = logger.New(os.Stderr, "", logger.Lshortfile)
-var cfgFile string
-
// newRootCmd creates the base command when called without any subcommands
func newRootCmd() *Command {
cmd := &cobra.Command{
diff --git a/cmd/cue/cmd/trim.go b/cmd/cue/cmd/trim.go
index 5d3d3dc..2468957 100644
--- a/cmd/cue/cmd/trim.go
+++ b/cmd/cue/cmd/trim.go
@@ -564,16 +564,3 @@
func iterKey(v cue.Iterator) key {
return key{v.Label(), v.IsHidden()}
}
-
-func nodeKey(v *ast.Field) key {
- if v == nil {
- return key{}
- }
- name, _ := ast.LabelName(v.Label)
- hidden := false
- if ident, ok := v.Label.(*ast.Ident); ok &&
- strings.HasPrefix(ident.Name, "_") {
- hidden = true
- }
- return key{name, hidden}
-}
diff --git a/cue/binop.go b/cue/binop.go
index c2e8787..260aaf4 100644
--- a/cue/binop.go
+++ b/cue/binop.go
@@ -846,10 +846,6 @@
return boolTonode(src, result)
}
-func (x *numLit) updateNumInfo(a, b *numLit) {
- x.numInfo = unifyNuminfo(a.numInfo, b.numInfo)
-}
-
func (x *numLit) binOp(ctx *context, src source, op op, other evaluated) evaluated {
switch y := other.(type) {
case *basicType, *bound, *customValidator: // for better error reporting
diff --git a/cue/build.go b/cue/build.go
index aac42eb..69bd84b 100644
--- a/cue/build.go
+++ b/cue/build.go
@@ -257,11 +257,6 @@
}
func resolveFile(idx *index, f *ast.File, p *build.Instance, allFields map[string]ast.Node) error {
- type importInfo struct {
- node ast.Node
- inst *Instance
- used bool // TODO: use a more general unresolved value technique
- }
index := map[string][]*ast.Ident{}
for _, u := range f.Unresolved {
index[u.Name] = append(index[u.Name], u)
diff --git a/cue/copy.go b/cue/copy.go
index 75011c3..f4f3f28 100644
--- a/cue/copy.go
+++ b/cue/copy.go
@@ -39,7 +39,7 @@
if emit != nil {
emit = ctx.copy(x.emit)
}
- obj.emit = x.emit
+ obj.emit = emit
t := x.template
if t != nil {
diff --git a/cue/debug.go b/cue/debug.go
index 148941c..252bdc8 100644
--- a/cue/debug.go
+++ b/cue/debug.go
@@ -22,10 +22,7 @@
)
func debugStr(ctx *context, v value) string {
- p := &printer{
- ctx: ctx,
- w: &bytes.Buffer{},
- }
+ p := newPrinter(ctx)
p.debugStr(v)
return p.w.String()
}
@@ -130,13 +127,6 @@
w *bytes.Buffer
}
-func (p *printer) str(v value) string {
- p.debugStr(v)
- str := p.w.String()
- p.w.Reset()
- return str
-}
-
func (p *printer) label(f label) string {
if p.ctx == nil {
return strconv.Itoa(int(f))
diff --git a/cue/errors.go b/cue/errors.go
index 0a8d845..0d7d84f 100644
--- a/cue/errors.go
+++ b/cue/errors.go
@@ -97,17 +97,6 @@
return false
}
-func recoverable(v value) bool {
- if err, ok := v.(*bottom); ok {
- switch err.code {
- case codeFatal,
- codeCycle: // only recoverable when explicitly handled and discarded
- return false
- }
- }
- return true
-}
-
var errNotExists = &bottom{code: codeNotExist, msg: "undefined value"}
func exists(v value) bool {
@@ -126,7 +115,6 @@
exprDepth int
value value
offendingValue value
- replacement evaluated // for cycle resolution
pos source
msg string
@@ -178,15 +166,6 @@
return nil
}
-func (idx *index) mkErrUnify(src source, a, b evaluated) evaluated {
- if err := firstBottom(a, b); err != nil {
- return err
- }
- e := binSrc(src.Pos(), opUnify, a, b)
- // TODO: show string of values and show location of both values.
- return idx.mkErr(e, "incompatible values &(%s, %s)", a.kind(), b.kind())
-}
-
func (c *context) mkIncompatible(src source, op op, a, b evaluated) evaluated {
if err := firstBottom(a, b); err != nil {
return err
@@ -235,12 +214,3 @@
}
return nil
}
-
-func expectType(idx *index, t kind, n evaluated) value {
- if isBottom(n) {
- return n
- }
- return idx.mkErr(n, "value should of type %s, found %s", n.kind(), t)
-}
-
-// TODO: consider returning a type or subsuption error for op != opUnify
diff --git a/cue/export.go b/cue/export.go
index 1382ad8..45ed181 100644
--- a/cue/export.go
+++ b/cue/export.go
@@ -23,10 +23,9 @@
"unicode"
"unicode/utf8"
- "github.com/cockroachdb/apd"
-
"cuelang.org/go/cue/ast"
"cuelang.org/go/cue/token"
+ "github.com/cockroachdb/apd"
)
func doEval(m options) bool {
@@ -837,7 +836,6 @@
fallthrough
case 1:
s.max = nil
- t = r.typ
return r.typ
}
}
diff --git a/cue/format/format.go b/cue/format/format.go
index 9bb81a5..dfa255a 100644
--- a/cue/format/format.go
+++ b/cue/format/format.go
@@ -224,7 +224,6 @@
pos int8
settings
- commentNewline bool
}
type settings struct {
diff --git a/cue/format/format_test.go b/cue/format/format_test.go
index 46b8a4a..a602529 100644
--- a/cue/format/format_test.go
+++ b/cue/format/format_test.go
@@ -21,7 +21,6 @@
"errors"
"flag"
"fmt"
- "io"
"io/ioutil"
"path/filepath"
"testing"
@@ -394,28 +393,6 @@
}
}
-var stmts = []string{
- "i := 0",
- "select {}\nvar a, b = 1, 2\nreturn a + b",
- "go f()\ndefer func() {}()",
-}
-
-type limitWriter struct {
- remaining int
- errCount int
-}
-
-func (l *limitWriter) Write(buf []byte) (n int, err error) {
- n = len(buf)
- if n >= l.remaining {
- n = l.remaining
- err = io.EOF
- l.errCount++
- }
- l.remaining -= n
- return n, err
-}
-
// TextX is a skeleton test that can be filled in for debugging one-off cases.
// Do not remove.
func TestX(t *testing.T) {
diff --git a/cue/format/node.go b/cue/format/node.go
index 0b19a33..8cecc49 100644
--- a/cue/format/node.go
+++ b/cue/format/node.go
@@ -464,7 +464,6 @@
default:
panic(fmt.Sprintf("unimplemented type %T", x))
}
- return
}
func (f *formatter) clause(clause ast.Clause) {
diff --git a/cue/format/printer.go b/cue/format/printer.go
index fbbc4ee..920bb6e 100644
--- a/cue/format/printer.go
+++ b/cue/format/printer.go
@@ -27,14 +27,11 @@
// produced by the formatter and adjusts the spacing based on the original
// source code.
type printer struct {
- w tabwriter.Writer
-
cfg *config
allowed whiteSpace
requested whiteSpace
indentStack []whiteSpace
- indentPos int
pos token.Position // current pos in AST
@@ -143,7 +140,6 @@
// TODO: if implied comma, postpone comment
data = x.Text
p.lastTok = token.COMMENT
- break
case whiteSpace:
p.allowed |= x
@@ -366,5 +362,5 @@
case token.QUO:
before = s[0] == '*' // /*
}
- return false, false
+ return before, false
}
diff --git a/cue/go_test.go b/cue/go_test.go
index 50f9248..441d84c 100644
--- a/cue/go_test.go
+++ b/cue/go_test.go
@@ -105,7 +105,7 @@
"<0>{a: 3, b: 4}",
}, {
struct {
- A int `json:",bb" yaml:"" protobuf:"aa"`
+ A int `json:"" yaml:"" protobuf:"aa"`
B int `yaml:"cc" json:"bb" protobuf:"aa"`
}{3, 4},
"<0>{aa: 3, bb: 4}",
diff --git a/cue/kind.go b/cue/kind.go
index ea4aad8..fd6382d 100644
--- a/cue/kind.go
+++ b/cue/kind.go
@@ -16,8 +16,6 @@
import (
"fmt"
-
- "cuelang.org/go/cue/token"
)
func unifyType(a, b kind) kind {
@@ -148,16 +146,6 @@
return str
}
-type kindInfo struct {
- kind
- subsumes []*kindInfo
- subsumedBy []*kindInfo
- unary []token.Token
- binary []token.Token
-}
-
-var toKindInfo = map[kind]*kindInfo{}
-
// matchBinOpKind returns the result kind of applying the given op to operands with
// the given kinds. The operation is disallowed if the return value is bottomKind. If
// the second return value is true, the operands should be swapped before evaluation.
diff --git a/cue/lit.go b/cue/lit.go
index 0d8e4f6..5e7f14c 100644
--- a/cue/lit.go
+++ b/cue/lit.go
@@ -18,20 +18,10 @@
"math/big"
"cuelang.org/go/cue/ast"
- "cuelang.org/go/cue/errors"
"cuelang.org/go/cue/literal"
"github.com/cockroachdb/apd"
)
-// errRange indicates that a value is out of range for the target type.
-var errRange = errors.New("value out of range")
-
-// errSyntax indicates that a value does not have the right syntax for the
-// target type.
-var errSyntax = errors.New("invalid syntax")
-
-var errInvalidString = errors.New("invalid string")
-
type numInfo struct {
rep multiplier
k kind
diff --git a/cue/rewrite_test.go b/cue/rewrite_test.go
index adf3476..7f27066 100644
--- a/cue/rewrite_test.go
+++ b/cue/rewrite_test.go
@@ -14,11 +14,6 @@
package cue
-import (
- "fmt"
- "strings"
-)
-
type rewriteMode int
const (
@@ -36,23 +31,6 @@
return rewriteRec(ctx, v, v.evalPartial(ctx), m)
}
-var indentLevel int
-
-func (c *context) ind() int {
- old := indentLevel
- indentLevel += 2
- return old
-}
-
-func (c *context) unindent(old int) {
- indentLevel = old
-}
-
-func (c *context) printIndent(args ...interface{}) {
- fmt.Print(strings.Repeat(" ", indentLevel))
- c.println(args...)
-}
-
func rewriteRec(ctx *context, raw value, eval evaluated, m rewriteMode) (result value) {
if m >= evalPartial {
if isIncomplete(eval) {
diff --git a/cue/scanner/scanner_test.go b/cue/scanner/scanner_test.go
index 18cbd3f..0e0ad45 100644
--- a/cue/scanner/scanner_test.go
+++ b/cue/scanner/scanner_test.go
@@ -594,7 +594,7 @@
eh := func(pos token.Pos, msg string) {
t.Errorf("error handler called (pos = %v, msg = %s)", pos, msg)
}
- trim := func(s string) string { return strings.Trim(s, `#"\\()`) }
+ trim := func(s string) string { return strings.Trim(s, `#"\()`) }
sources := []string{
`"first\(first)\\second\(second)"`,
diff --git a/cue/subsume.go b/cue/subsume.go
index 892742c..7b728af 100644
--- a/cue/subsume.go
+++ b/cue/subsume.go
@@ -18,10 +18,6 @@
"bytes"
)
-type valueSubsumer interface {
- subsumesImpl(ctx *context, v value) bool
-}
-
type subsumeMode int
const (
diff --git a/cue/types.go b/cue/types.go
index e199984..759dbe5 100644
--- a/cue/types.go
+++ b/cue/types.go
@@ -185,14 +185,13 @@
// An Iterator iterates over values.
//
type Iterator struct {
- val Value
- ctx *context
- iter iterAtter
- len int
- p int
- cur Value
- f label
- attrs *attributes
+ val Value
+ ctx *context
+ iter iterAtter
+ len int
+ p int
+ cur Value
+ f label
}
// Next advances the iterator to the next value and reports whether there was
@@ -807,14 +806,6 @@
return nil
}
-func (v Value) err() *bottom {
- // TODO(incomplete): change to not return an error for incomplete.
- if err := v.checkKind(v.ctx(), bottomKind); err != nil {
- return err
- }
- return nil
-}
-
// Pos returns position information.
func (v Value) Pos() token.Pos {
if v.path == nil || v.Source() == nil {
@@ -1433,10 +1424,6 @@
return Attribute{err: v.toErr(errNotExists)}
}
-var (
- errNoSuchAttribute = errors.New("entry for key does not exist")
-)
-
// An Attribute contains meta data about a field.
type Attribute struct {
attr parsedAttr
diff --git a/cue/types_test.go b/cue/types_test.go
index a4e60c4..f24011b 100644
--- a/cue/types_test.go
+++ b/cue/types_test.go
@@ -390,7 +390,7 @@
t.Errorf("mantExp: got %s %d; want %s %d", mstr, exp, tc.mant, tc.exp)
}
- b, err := n.AppendFloat(nil, tc.fmt, tc.prec)
+ b, _ := n.AppendFloat(nil, tc.fmt, tc.prec)
want := tc.float
if got := string(b); got != want {
t.Errorf("append: got %v; want %v", got, want)
diff --git a/cue/value.go b/cue/value.go
index 4ffbbb1..dbcf507 100644
--- a/cue/value.go
+++ b/cue/value.go
@@ -319,13 +319,6 @@
return n
}
-func resultNumBase(a, b numBase) numBase {
- return numBase{
- baseValue: a.baseValue,
- numInfo: unifyNuminfo(a.numInfo, b.numInfo),
- }
-}
-
type numLit struct {
numBase
v apd.Decimal