convert uses of interface{} to any

Done via:
  find . -name "*.go" | xargs sed -i -E 's/interface\{\}/any/g'

PiperOrigin-RevId: 487033228
This commit is contained in:
Kevin Krakauer
2022-11-08 13:14:06 -08:00
committed by gVisor bot
parent c82b70015d
commit d8aa09e04c
220 changed files with 509 additions and 509 deletions
+1 -1
View File
@@ -47,7 +47,7 @@ import (
// pointers to active go objects (pointer fields aren't allowed in ABI
// structs anyways), or we'd be violating the go runtime contract and
// the GC may malfunction.
func RandomizeValue(x interface{}) {
func RandomizeValue(x any) {
v := reflect.Indirect(reflect.ValueOf(x))
if !v.CanSet() {
panic("RandomizeType() called with an unaddressable value. You probably need to pass a pointer to the argument")
+5 -5
View File
@@ -147,7 +147,7 @@ func abortAt(p token.Position, msg string) {
}
// debugf conditionally prints a debug message.
func debugf(f string, a ...interface{}) {
func debugf(f string, a ...any) {
if debugEnabled() {
fmt.Printf(f, a...)
}
@@ -155,7 +155,7 @@ func debugf(f string, a ...interface{}) {
// debugfAt conditionally prints a debug message with a reference to a position
// in the input source.
func debugfAt(p token.Position, f string, a ...interface{}) {
func debugfAt(p token.Position, f string, a ...any) {
if debugEnabled() {
fmt.Printf("%s:\n %s", p, fmt.Sprintf(f, a...))
}
@@ -178,7 +178,7 @@ func debugfAt(p token.Position, f string, a ...interface{}) {
//
// Calling emit with a single argument that is not a string will result in a
// panic, as the caller's intent is ambiguous.
func emit(out io.Writer, indent int, a ...interface{}) {
func emit(out io.Writer, indent int, a ...any) {
const spacesPerIndentLevel = 4
if len(a) < 1 {
@@ -245,11 +245,11 @@ func (b *sourceBuffer) decIndent() {
b.indent--
}
func (b *sourceBuffer) emit(a ...interface{}) {
func (b *sourceBuffer) emit(a ...any) {
emit(&b.b, b.indent, a...)
}
func (b *sourceBuffer) emitNoIndent(a ...interface{}) {
func (b *sourceBuffer) emitNoIndent(a ...any) {
emit(&b.b, 0 /*indent*/, a...)
}
+25 -25
View File
@@ -44,7 +44,7 @@ type mockCopyContext struct {
}
// populate fills the task memory with the contents of val.
func (t *mockCopyContext) populate(val interface{}) {
func (t *mockCopyContext) populate(val any) {
var buf bytes.Buffer
// Use binary.Write so we aren't testing go-marshal against its own
// potentially buggy implementation.
@@ -120,7 +120,7 @@ func unsafeMemory(m marshal.Marshallable) []byte {
// returned slice is related to m, the caller must ensure m lives long enough.
//
// Precondition: m must be a slice.
func unsafeMemorySlice(m interface{}, elt marshal.Marshallable) []byte {
func unsafeMemorySlice(m any, elt marshal.Marshallable) []byte {
kind := reflect.TypeOf(m).Kind()
if kind != reflect.Slice {
panic("unsafeMemorySlice called on non-slice")
@@ -305,52 +305,52 @@ func TestLimitedMarshalling(t *testing.T) {
func TestLimitedSliceMarshalling(t *testing.T) {
types := []struct {
arrayPtrType reflect.Type
copySliceIn func(cc marshal.CopyContext, addr hostarch.Addr, dstSlice interface{}) (int, error)
copySliceOut func(cc marshal.CopyContext, addr hostarch.Addr, srcSlice interface{}) (int, error)
unsafeMemory func(arrPtr interface{}) []byte
copySliceIn func(cc marshal.CopyContext, addr hostarch.Addr, dstSlice any) (int, error)
copySliceOut func(cc marshal.CopyContext, addr hostarch.Addr, srcSlice any) (int, error)
unsafeMemory func(arrPtr any) []byte
}{
// Packed types.
{
reflect.TypeOf((*[20]test.Stat)(nil)),
func(cc marshal.CopyContext, addr hostarch.Addr, dst interface{}) (int, error) {
func(cc marshal.CopyContext, addr hostarch.Addr, dst any) (int, error) {
slice := dst.(*[20]test.Stat)[:]
return test.CopyStatSliceIn(cc, addr, slice)
},
func(cc marshal.CopyContext, addr hostarch.Addr, src interface{}) (int, error) {
func(cc marshal.CopyContext, addr hostarch.Addr, src any) (int, error) {
slice := src.(*[20]test.Stat)[:]
return test.CopyStatSliceOut(cc, addr, slice)
},
func(a interface{}) []byte {
func(a any) []byte {
slice := a.(*[20]test.Stat)[:]
return unsafeMemorySlice(slice, &slice[0])
},
},
{
reflect.TypeOf((*[1]test.Stat)(nil)),
func(cc marshal.CopyContext, addr hostarch.Addr, dst interface{}) (int, error) {
func(cc marshal.CopyContext, addr hostarch.Addr, dst any) (int, error) {
slice := dst.(*[1]test.Stat)[:]
return test.CopyStatSliceIn(cc, addr, slice)
},
func(cc marshal.CopyContext, addr hostarch.Addr, src interface{}) (int, error) {
func(cc marshal.CopyContext, addr hostarch.Addr, src any) (int, error) {
slice := src.(*[1]test.Stat)[:]
return test.CopyStatSliceOut(cc, addr, slice)
},
func(a interface{}) []byte {
func(a any) []byte {
slice := a.(*[1]test.Stat)[:]
return unsafeMemorySlice(slice, &slice[0])
},
},
{
reflect.TypeOf((*[5]test.SignalSetAlias)(nil)),
func(cc marshal.CopyContext, addr hostarch.Addr, dst interface{}) (int, error) {
func(cc marshal.CopyContext, addr hostarch.Addr, dst any) (int, error) {
slice := dst.(*[5]test.SignalSetAlias)[:]
return test.CopySignalSetAliasSliceIn(cc, addr, slice)
},
func(cc marshal.CopyContext, addr hostarch.Addr, src interface{}) (int, error) {
func(cc marshal.CopyContext, addr hostarch.Addr, src any) (int, error) {
slice := src.(*[5]test.SignalSetAlias)[:]
return test.CopySignalSetAliasSliceOut(cc, addr, slice)
},
func(a interface{}) []byte {
func(a any) []byte {
slice := a.(*[5]test.SignalSetAlias)[:]
return unsafeMemorySlice(slice, &slice[0])
},
@@ -358,45 +358,45 @@ func TestLimitedSliceMarshalling(t *testing.T) {
// Non-packed types.
{
reflect.TypeOf((*[20]test.Type1)(nil)),
func(cc marshal.CopyContext, addr hostarch.Addr, dst interface{}) (int, error) {
func(cc marshal.CopyContext, addr hostarch.Addr, dst any) (int, error) {
slice := dst.(*[20]test.Type1)[:]
return test.CopyType1SliceIn(cc, addr, slice)
},
func(cc marshal.CopyContext, addr hostarch.Addr, src interface{}) (int, error) {
func(cc marshal.CopyContext, addr hostarch.Addr, src any) (int, error) {
slice := src.(*[20]test.Type1)[:]
return test.CopyType1SliceOut(cc, addr, slice)
},
func(a interface{}) []byte {
func(a any) []byte {
slice := a.(*[20]test.Type1)[:]
return unsafeMemorySlice(slice, &slice[0])
},
},
{
reflect.TypeOf((*[1]test.Type1)(nil)),
func(cc marshal.CopyContext, addr hostarch.Addr, dst interface{}) (int, error) {
func(cc marshal.CopyContext, addr hostarch.Addr, dst any) (int, error) {
slice := dst.(*[1]test.Type1)[:]
return test.CopyType1SliceIn(cc, addr, slice)
},
func(cc marshal.CopyContext, addr hostarch.Addr, src interface{}) (int, error) {
func(cc marshal.CopyContext, addr hostarch.Addr, src any) (int, error) {
slice := src.(*[1]test.Type1)[:]
return test.CopyType1SliceOut(cc, addr, slice)
},
func(a interface{}) []byte {
func(a any) []byte {
slice := a.(*[1]test.Type1)[:]
return unsafeMemorySlice(slice, &slice[0])
},
},
{
reflect.TypeOf((*[7]test.Type8)(nil)),
func(cc marshal.CopyContext, addr hostarch.Addr, dst interface{}) (int, error) {
func(cc marshal.CopyContext, addr hostarch.Addr, dst any) (int, error) {
slice := dst.(*[7]test.Type8)[:]
return test.CopyType8SliceIn(cc, addr, slice)
},
func(cc marshal.CopyContext, addr hostarch.Addr, src interface{}) (int, error) {
func(cc marshal.CopyContext, addr hostarch.Addr, src any) (int, error) {
slice := src.(*[7]test.Type8)[:]
return test.CopyType8SliceOut(cc, addr, slice)
},
func(a interface{}) []byte {
func(a any) []byte {
slice := a.(*[7]test.Type8)[:]
return unsafeMemorySlice(slice, &slice[0])
},
@@ -428,7 +428,7 @@ func TestLimitedSliceMarshalling(t *testing.T) {
elem := reflect.New(arrayTy.Elem()).Interface().(marshal.Marshallable)
// Equivalent:
// var expected, actual interface{}
// var expected, actual any
// expected = new([20]test.Stat)
// actual = new([20]test.Stat)
expected := reflect.New(arrayTy).Interface()
@@ -483,7 +483,7 @@ func TestLimitedSliceMarshalling(t *testing.T) {
elem := reflect.New(arrayTy.Elem()).Interface().(marshal.Marshallable)
// Equivalent:
// var expected, actual interface{}
// var expected, actual any
// expected = new([20]test.Stat)
// actual = new([20]test.Stat)
expected := reflect.New(arrayTy).Interface()