Skip to content

Commit cbed854

Browse files
committed
all: unconvert -apply ./...
See https://github.com/mdempsky/unconvert. Apply it everywhere except the vendored golangorgx code. Signed-off-by: Daniel Martí <[email protected]> Change-Id: I58d838c38b38911d6a731d386dc98c1012627aae Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1210505 Reviewed-by: Roger Peppe <[email protected]> TryBot-Result: CUEcueckoo <[email protected]> Unity-Result: CUE porcuepine <[email protected]>
1 parent bebbaa9 commit cbed854

File tree

14 files changed

+29
-29
lines changed

14 files changed

+29
-29
lines changed

cue/ast/astutil/sanitize.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ func (z *sanitizer) uniqueName(base string, hidden bool) string {
347347

348348
const mask = 0xff_ffff_ffff_ffff // max bits; stay clear of int64 overflow
349349
const shift = 4 // rate of growth
350-
for n := int64(0x10); ; n = int64(mask&((n<<shift)-1)) + 1 {
350+
for n := int64(0x10); ; n = mask&((n<<shift)-1) + 1 {
351351
num := z.rand.Intn(int(n))
352352
name := fmt.Sprintf("%s_%01X", base, num)
353353
if !z.names[name] {

cue/parser/error_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ func expectedErrors(t *testing.T, file *token.File, src []byte) map[token.Pos]st
8383
if s[1] == "HERE" {
8484
pos = here
8585
}
86-
errors[pos] = string(s[2])
86+
errors[pos] = s[2]
8787
}
8888
default:
8989
prev = pos

cue/token/position.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ func (f *File) Pos(offset int, rel RelPos) Pos {
414414
// f.Offset(f.Pos(offset)) == offset.
415415
func (f *File) Offset(p Pos) int {
416416
x := p.index()
417-
if x < 1 || x > 1+index(f.size) {
417+
if x < 1 || x > 1+f.size {
418418
panic("illegal Pos value")
419419
}
420420
return int(x - 1)
@@ -436,7 +436,7 @@ func searchLineInfos(a []lineInfo, x int) int {
436436
func (f *File) unpack(offset index, adjusted bool) (filename string, line, column int) {
437437
filename = f.name
438438
if i := searchInts(f.lines, offset); i >= 0 {
439-
line, column = int(i+1), int(offset-f.lines[i]+1)
439+
line, column = i+1, int(offset-f.lines[i]+1)
440440
}
441441
if adjusted && len(f.infos) > 0 {
442442
// almost no files have extra line infos

cue/types.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1095,7 +1095,7 @@ func (v Value) checkKind(ctx *adt.OpContext, want adt.Kind) *adt.Bottom {
10951095

10961096
func makeInt(v Value, x int64) Value {
10971097
n := &adt.Num{K: adt.IntKind}
1098-
n.X.SetInt64(int64(x))
1098+
n.X.SetInt64(x)
10991099
return remakeFinal(v, n)
11001100
}
11011101

cue/types_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ func TestInt(t *testing.T) {
421421

422422
vu, err := n.Uint64()
423423
checkErr(t, err, tc.errU, "Uint64")
424-
if vu != uint64(tc.uint) {
424+
if vu != tc.uint {
425425
t.Errorf("Uint64: got %v; want %v", vu, tc.uint)
426426
}
427427
})

encoding/openapi/build.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ func (b *builder) fillSchema(v cue.Value) *ast.StructLit {
257257
}
258258

259259
schema := b.finish()
260-
s := (*ast.StructLit)(schema)
260+
s := schema
261261

262262
simplify(b, s)
263263

@@ -529,7 +529,7 @@ func (b *builder) disjunction(a []cue.Value, f typeFunc) {
529529
c := newOASBuilder(b)
530530
c.value(v, f)
531531
t := c.finish()
532-
schemas[i] = (*ast.StructLit)(t)
532+
schemas[i] = t
533533
if len(t.Elts) == 0 {
534534
if c.typ == "" {
535535
return
@@ -1207,7 +1207,7 @@ func (b *builder) add(t *ast.StructLit) {
12071207
func (b *builder) addConjunct(f func(*builder)) {
12081208
c := newOASBuilder(b)
12091209
f(c)
1210-
b.add((*ast.StructLit)(c.finish()))
1210+
b.add(c.finish())
12111211
}
12121212

12131213
func (b *builder) addRef(v cue.Value, inst cue.Value, ref cue.Path) {

internal/core/compile/label.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ func (c *compiler) label(n ast.Node) adt.Feature {
4444
return adt.InvalidLabel
4545
}
4646

47-
i := int64(index.StringToIndex(norm.NFC.String(s)))
47+
i := index.StringToIndex(norm.NFC.String(s))
4848
f, err := adt.MakeLabel(n, i, adt.StringLabel)
4949
if err != nil {
5050
c.errf(n, msg, err)

internal/core/convert/go.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ func (c *goConverter) convertRec(nilIsTop bool, x interface{}) (result adt.Value
344344
case int32:
345345
return c.toInt(int64(v))
346346
case int64:
347-
return c.toInt(int64(v))
347+
return c.toInt(v)
348348
case uint:
349349
return c.toUint(uint64(v))
350350
case uint8:
@@ -354,7 +354,7 @@ func (c *goConverter) convertRec(nilIsTop bool, x interface{}) (result adt.Value
354354
case uint32:
355355
return c.toUint(uint64(v))
356356
case uint64:
357-
return c.toUint(uint64(v))
357+
return c.toUint(v)
358358
case uintptr:
359359
return c.toUint(uint64(v))
360360
case float64:

internal/core/export/export.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -686,7 +686,7 @@ func findUnique(set featureSet, base string) (f adt.Feature, name string) {
686686
const mask = 0xff_ffff_ffff_ffff // max bits; stay clear of int64 overflow
687687
const shift = 4 // rate of growth
688688
digits := 1
689-
for n := int64(0x10); ; n = int64(mask&((n<<shift)-1)) + 1 {
689+
for n := int64(0x10); ; n = mask&((n<<shift)-1) + 1 {
690690
num := set.intn(int(n)-1) + 1
691691
name := fmt.Sprintf("%[1]s_%0[2]*[3]X", base, digits, num)
692692
if f, ok := set.makeFeature(name); ok {

internal/core/export/label.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ func (e *exporter) stringLabel(f adt.Feature) ast.Label {
3131
x := f.Index()
3232
switch f.Typ() {
3333
case adt.IntLabel:
34-
return ast.NewLit(token.INT, strconv.Itoa(int(x)))
34+
return ast.NewLit(token.INT, strconv.Itoa(x))
3535

3636
case adt.DefinitionLabel, adt.HiddenLabel, adt.HiddenDefinitionLabel:
3737
s := e.identString(f)

internal/core/export/value_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,8 @@ func TestValueX(t *testing.T) {
110110
a := cuetxtar.Load(archive, t.TempDir())
111111

112112
r := runtime.New()
113-
(*runtime.Runtime)(r).SetVersion(internal.DevVersion)
114-
(*runtime.Runtime)(r).SetDebugOptions(&cuedebug.Config{Sharing: true})
113+
r.SetVersion(internal.DevVersion)
114+
r.SetDebugOptions(&cuedebug.Config{Sharing: true})
115115

116116
v, errs := compile.Files(nil, r, "", a[0].Files...)
117117
if errs != nil {

internal/mod/modpkgload/pkgload_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ func TestLoadPackages(t *testing.T) {
8888
}
8989
}
9090
}
91-
if diff := cmp.Diff(string(want), out.String()); diff != "" {
91+
if diff := cmp.Diff(want, out.String()); diff != "" {
9292
t.Logf("actual result:\n%s", out.String())
9393
t.Fatalf("unexpected results (-want +got):\n%s", diff)
9494
}

internal/pkg/context.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ func (c *CallCtxt) Int8(i int) int8 { return int8(c.intValue(i, 8, "int8")) }
109109
func (c *CallCtxt) Int16(i int) int16 { return int16(c.intValue(i, 16, "int16")) }
110110
func (c *CallCtxt) Int32(i int) int32 { return int32(c.intValue(i, 32, "int32")) }
111111
func (c *CallCtxt) Rune(i int) rune { return rune(c.intValue(i, 32, "rune")) }
112-
func (c *CallCtxt) Int64(i int) int64 { return int64(c.intValue(i, 64, "int64")) }
112+
func (c *CallCtxt) Int64(i int) int64 { return c.intValue(i, 64, "int64") }
113113

114114
func (c *CallCtxt) intValue(i, bits int, typ string) int64 {
115115
arg := c.args[i]
@@ -132,7 +132,7 @@ func (c *CallCtxt) Uint8(i int) uint8 { return uint8(c.uintValue(i, 8, "uint8"
132132
func (c *CallCtxt) Byte(i int) uint8 { return byte(c.uintValue(i, 8, "byte")) }
133133
func (c *CallCtxt) Uint16(i int) uint16 { return uint16(c.uintValue(i, 16, "uint16")) }
134134
func (c *CallCtxt) Uint32(i int) uint32 { return uint32(c.uintValue(i, 32, "uint32")) }
135-
func (c *CallCtxt) Uint64(i int) uint64 { return uint64(c.uintValue(i, 64, "uint64")) }
135+
func (c *CallCtxt) Uint64(i int) uint64 { return c.uintValue(i, 64, "uint64") }
136136

137137
func (c *CallCtxt) uintValue(i, bits int, typ string) uint64 {
138138
x := value.Make(c.ctx, c.args[i])

pkg/uuid/uuid.go

+10-10
Original file line numberDiff line numberDiff line change
@@ -35,19 +35,19 @@ func Valid(s string) error {
3535
// encoding: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.
3636
func Parse(s string) (string, error) {
3737
x, err := uuid.Parse(s)
38-
return string(x.String()), err
38+
return x.String(), err
3939
}
4040

4141
// TODO(mvdan): what is ToString meant to do? it appears like a no-op?
4242

4343
// String represents a 128-bit UUID value as a string.
4444
func ToString(x string) string {
45-
return string(x)
45+
return x
4646
}
4747

4848
// URN reports the canonical URN of a UUID.
4949
func URN(x string) (string, error) {
50-
u, err := uuid.Parse(string(x))
50+
u, err := uuid.Parse(x)
5151
if err != nil {
5252
return "", err
5353
}
@@ -66,7 +66,7 @@ func FromInt(i *big.Int) (string, error) {
6666
b = buf[:]
6767
}
6868
u, err := uuid.FromBytes(b)
69-
return string(u.String()), err
69+
return u.String(), err
7070
}
7171

7272
// ToInt represents a UUID string as a 128-bit value.
@@ -78,7 +78,7 @@ func ToInt(x string) *big.Int {
7878

7979
// Variant reports the UUID variant.
8080
func Variant(x string) (int, error) {
81-
u, err := uuid.Parse(string(x))
81+
u, err := uuid.Parse(x)
8282
if err != nil {
8383
return 0, err
8484
}
@@ -87,7 +87,7 @@ func Variant(x string) (int, error) {
8787

8888
// Version reports the UUID version.
8989
func Version(x string) (int, error) {
90-
u, err := uuid.Parse(string(x))
90+
u, err := uuid.Parse(x)
9191
if err != nil {
9292
return 0, err
9393
}
@@ -96,19 +96,19 @@ func Version(x string) (int, error) {
9696

9797
// SHA1 generates a version 5 UUID based on the supplied name space and data.
9898
func SHA1(space string, data []byte) (string, error) {
99-
u, err := uuid.Parse(string(space))
99+
u, err := uuid.Parse(space)
100100
if err != nil {
101101
return "", err
102102
}
103-
return string(uuid.NewSHA1(u, data).String()), nil
103+
return uuid.NewSHA1(u, data).String(), nil
104104
}
105105

106106
// MD5 generates a version 3 UUID based on the supplied name space and data.
107107
// Use SHA1 instead if you can.
108108
func MD5(space string, data []byte) (string, error) {
109-
u, err := uuid.Parse(string(space))
109+
u, err := uuid.Parse(space)
110110
if err != nil {
111111
return "", err
112112
}
113-
return string(uuid.NewMD5(u, data).String()), nil
113+
return uuid.NewMD5(u, data).String(), nil
114114
}

0 commit comments

Comments
 (0)