diff options
| author | Alan Donovan <adonovan@google.com> | 2025-11-11 14:48:22 -0500 |
|---|---|---|
| committer | Gopher Robot <gobot@golang.org> | 2025-11-11 19:59:40 -0800 |
| commit | 4bfc3a9d14c0b3bfcfe4ce987e47cda6720785a2 (patch) | |
| tree | 0cbf1ec55d3a61af8bf45ac4a00af7e7bcc426db /src/cmd/compile | |
| parent | 2263d4aabdde8a4a466009ecc356501f87c7efb7 (diff) | |
| download | go-4bfc3a9d14c0b3bfcfe4ce987e47cda6720785a2.tar.xz | |
std,cmd: go fix -any std cmd
This change mechanically replaces all occurrences of interface{}
by 'any' (where deemed safe by the 'any' modernizer) throughout
std and cmd, minus their vendor trees.
Since this fix is relatively numerous, it gets its own CL.
Also, 'go generate go/types'.
Change-Id: I14a6b52856c3291c1d27935409bca8d5fd4242a2
Reviewed-on: https://go-review.googlesource.com/c/go/+/719702
Commit-Queue: Alan Donovan <adonovan@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Auto-Submit: Alan Donovan <adonovan@google.com>
Diffstat (limited to 'src/cmd/compile')
47 files changed, 139 insertions, 139 deletions
diff --git a/src/cmd/compile/internal/abt/avlint32.go b/src/cmd/compile/internal/abt/avlint32.go index ddfca346a2..e41a6c0ca4 100644 --- a/src/cmd/compile/internal/abt/avlint32.go +++ b/src/cmd/compile/internal/abt/avlint32.go @@ -28,7 +28,7 @@ type T struct { type node32 struct { // Standard conventions hold for left = smaller, right = larger left, right *node32 - data interface{} + data any key int32 height_ int8 } @@ -49,21 +49,21 @@ func (t *T) IsSingle() bool { // VisitInOrder applies f to the key and data pairs in t, // with keys ordered from smallest to largest. -func (t *T) VisitInOrder(f func(int32, interface{})) { +func (t *T) VisitInOrder(f func(int32, any)) { if t.root == nil { return } t.root.visitInOrder(f) } -func (n *node32) nilOrData() interface{} { +func (n *node32) nilOrData() any { if n == nil { return nil } return n.data } -func (n *node32) nilOrKeyAndData() (k int32, d interface{}) { +func (n *node32) nilOrKeyAndData() (k int32, d any) { if n == nil { k = NOT_KEY32 d = nil @@ -83,7 +83,7 @@ func (n *node32) height() int8 { // Find returns the data associated with x in the tree, or // nil if x is not in the tree. -func (t *T) Find(x int32) interface{} { +func (t *T) Find(x int32) any { return t.root.find(x).nilOrData() } @@ -92,7 +92,7 @@ func (t *T) Find(x int32) interface{} { // x was already a key in the tree. The previous data associated // with x is returned, and is nil if x was not previously a // key in the tree. -func (t *T) Insert(x int32, data interface{}) interface{} { +func (t *T) Insert(x int32, data any) any { if x == NOT_KEY32 { panic("Cannot use sentinel value -0x80000000 as key") } @@ -105,7 +105,7 @@ func (t *T) Insert(x int32, data interface{}) interface{} { } else { newroot, n, o = n.aInsert(x) } - var r interface{} + var r any if o != nil { r = o.data } else { @@ -121,7 +121,7 @@ func (t *T) Copy() *T { return &u } -func (t *T) Delete(x int32) interface{} { +func (t *T) Delete(x int32) any { n := t.root if n == nil { return nil @@ -135,7 +135,7 @@ func (t *T) Delete(x int32) interface{} { return d.data } -func (t *T) DeleteMin() (int32, interface{}) { +func (t *T) DeleteMin() (int32, any) { n := t.root if n == nil { return NOT_KEY32, nil @@ -149,7 +149,7 @@ func (t *T) DeleteMin() (int32, interface{}) { return d.key, d.data } -func (t *T) DeleteMax() (int32, interface{}) { +func (t *T) DeleteMax() (int32, any) { n := t.root if n == nil { return NOT_KEY32, nil @@ -172,7 +172,7 @@ func (t *T) Size() int { // not be symmetric. If f returns nil, then the key and data are not // added to the result. If f itself is nil, then whatever value was // already present in the smaller set is used. -func (t *T) Intersection(u *T, f func(x, y interface{}) interface{}) *T { +func (t *T) Intersection(u *T, f func(x, y any) any) *T { if t.Size() == 0 || u.Size() == 0 { return &T{} } @@ -227,7 +227,7 @@ func (t *T) Intersection(u *T, f func(x, y interface{}) interface{}) *T { // is given by f(t's data, u's data) -- f need not be symmetric. If f returns nil, // then the key and data are not added to the result. If f itself is nil, then // whatever value was already present in the larger set is used. -func (t *T) Union(u *T, f func(x, y interface{}) interface{}) *T { +func (t *T) Union(u *T, f func(x, y any) any) *T { if t.Size() == 0 { return u } @@ -284,7 +284,7 @@ func (t *T) Union(u *T, f func(x, y interface{}) interface{}) *T { // of f applied to data corresponding to equal keys. If f returns nil // (or if f is nil) then the key+data are excluded, as usual. If f // returns not-nil, then that key+data pair is inserted. instead. -func (t *T) Difference(u *T, f func(x, y interface{}) interface{}) *T { +func (t *T) Difference(u *T, f func(x, y any) any) *T { if t.Size() == 0 { return &T{} } @@ -365,7 +365,7 @@ func (t *node32) equals(u *node32) bool { return it.done() == iu.done() } -func (t *T) Equiv(u *T, eqv func(x, y interface{}) bool) bool { +func (t *T) Equiv(u *T, eqv func(x, y any) bool) bool { if t == u { return true } @@ -375,7 +375,7 @@ func (t *T) Equiv(u *T, eqv func(x, y interface{}) bool) bool { return t.root.equiv(u.root, eqv) } -func (t *node32) equiv(u *node32, eqv func(x, y interface{}) bool) bool { +func (t *node32) equiv(u *node32, eqv func(x, y any) bool) bool { if t == u { return true } @@ -404,7 +404,7 @@ type Iterator struct { it iterator } -func (it *Iterator) Next() (int32, interface{}) { +func (it *Iterator) Next() (int32, any) { x := it.it.next() if x == nil { return NOT_KEY32, nil @@ -461,37 +461,37 @@ func (it *iterator) next() *node32 { // Min returns the minimum element of t. // If t is empty, then (NOT_KEY32, nil) is returned. -func (t *T) Min() (k int32, d interface{}) { +func (t *T) Min() (k int32, d any) { return t.root.min().nilOrKeyAndData() } // Max returns the maximum element of t. // If t is empty, then (NOT_KEY32, nil) is returned. -func (t *T) Max() (k int32, d interface{}) { +func (t *T) Max() (k int32, d any) { return t.root.max().nilOrKeyAndData() } // Glb returns the greatest-lower-bound-exclusive of x and the associated // data. If x has no glb in the tree, then (NOT_KEY32, nil) is returned. -func (t *T) Glb(x int32) (k int32, d interface{}) { +func (t *T) Glb(x int32) (k int32, d any) { return t.root.glb(x, false).nilOrKeyAndData() } // GlbEq returns the greatest-lower-bound-inclusive of x and the associated // data. If x has no glbEQ in the tree, then (NOT_KEY32, nil) is returned. -func (t *T) GlbEq(x int32) (k int32, d interface{}) { +func (t *T) GlbEq(x int32) (k int32, d any) { return t.root.glb(x, true).nilOrKeyAndData() } // Lub returns the least-upper-bound-exclusive of x and the associated // data. If x has no lub in the tree, then (NOT_KEY32, nil) is returned. -func (t *T) Lub(x int32) (k int32, d interface{}) { +func (t *T) Lub(x int32) (k int32, d any) { return t.root.lub(x, false).nilOrKeyAndData() } // LubEq returns the least-upper-bound-inclusive of x and the associated // data. If x has no lubEq in the tree, then (NOT_KEY32, nil) is returned. -func (t *T) LubEq(x int32) (k int32, d interface{}) { +func (t *T) LubEq(x int32) (k int32, d any) { return t.root.lub(x, true).nilOrKeyAndData() } @@ -499,7 +499,7 @@ func (t *node32) isLeaf() bool { return t.left == nil && t.right == nil && t.height_ == LEAF_HEIGHT } -func (t *node32) visitInOrder(f func(int32, interface{})) { +func (t *node32) visitInOrder(f func(int32, any)) { if t.left != nil { t.left.visitInOrder(f) } diff --git a/src/cmd/compile/internal/abt/avlint32_test.go b/src/cmd/compile/internal/abt/avlint32_test.go index 7fa9ed4fd6..71962445f2 100644 --- a/src/cmd/compile/internal/abt/avlint32_test.go +++ b/src/cmd/compile/internal/abt/avlint32_test.go @@ -317,7 +317,7 @@ func applicIterator(te *testing.T, x []int32) { } } -func equiv(a, b interface{}) bool { +func equiv(a, b any) bool { sa, sb := a.(*sstring), b.(*sstring) return *sa == *sb } @@ -450,16 +450,16 @@ func TestEquals(t *testing.T) { []int32{1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 24, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2}) } -func first(x, y interface{}) interface{} { +func first(x, y any) any { return x } -func second(x, y interface{}) interface{} { +func second(x, y any) any { return y } -func alwaysNil(x, y interface{}) interface{} { +func alwaysNil(x, y any) any { return nil } -func smaller(x, y interface{}) interface{} { +func smaller(x, y any) any { xi, _ := strconv.Atoi(fmt.Sprint(x)) yi, _ := strconv.Atoi(fmt.Sprint(y)) if xi < yi { @@ -560,7 +560,7 @@ func (s *sstring) String() string { return s.s } -func stringer(s string) interface{} { +func stringer(s string) any { return &sstring{s} } diff --git a/src/cmd/compile/internal/base/print.go b/src/cmd/compile/internal/base/print.go index 9e3348c1ec..6bfc84cd62 100644 --- a/src/cmd/compile/internal/base/print.go +++ b/src/cmd/compile/internal/base/print.go @@ -45,7 +45,7 @@ func SyntaxErrors() int { } // addErrorMsg adds a new errorMsg (which may be a warning) to errorMsgs. -func addErrorMsg(pos src.XPos, code errors.Code, format string, args ...interface{}) { +func addErrorMsg(pos src.XPos, code errors.Code, format string, args ...any) { msg := fmt.Sprintf(format, args...) // Only add the position if know the position. // See issue golang.org/issue/11361. @@ -108,12 +108,12 @@ func sameline(a, b src.XPos) bool { } // Errorf reports a formatted error at the current line. -func Errorf(format string, args ...interface{}) { +func Errorf(format string, args ...any) { ErrorfAt(Pos, 0, format, args...) } // ErrorfAt reports a formatted error message at pos. -func ErrorfAt(pos src.XPos, code errors.Code, format string, args ...interface{}) { +func ErrorfAt(pos src.XPos, code errors.Code, format string, args ...any) { msg := fmt.Sprintf(format, args...) if strings.HasPrefix(msg, "syntax error") { @@ -164,7 +164,7 @@ func UpdateErrorDot(line string, name, expr string) { // In general the Go compiler does NOT generate warnings, // so this should be used only when the user has opted in // to additional output by setting a particular flag. -func Warn(format string, args ...interface{}) { +func Warn(format string, args ...any) { WarnfAt(Pos, format, args...) } @@ -172,7 +172,7 @@ func Warn(format string, args ...interface{}) { // In general the Go compiler does NOT generate warnings, // so this should be used only when the user has opted in // to additional output by setting a particular flag. -func WarnfAt(pos src.XPos, format string, args ...interface{}) { +func WarnfAt(pos src.XPos, format string, args ...any) { addErrorMsg(pos, 0, format, args...) if Flag.LowerM != 0 { FlushErrors() @@ -191,7 +191,7 @@ func WarnfAt(pos src.XPos, format string, args ...interface{}) { // prints a stack trace. // // If -h has been specified, Fatalf panics to force the usual runtime info dump. -func Fatalf(format string, args ...interface{}) { +func Fatalf(format string, args ...any) { FatalfAt(Pos, format, args...) } @@ -209,7 +209,7 @@ var bugStack = counter.NewStack("compile/bug", 16) // 16 is arbitrary; used by g // prints a stack trace. // // If -h has been specified, FatalfAt panics to force the usual runtime info dump. -func FatalfAt(pos src.XPos, format string, args ...interface{}) { +func FatalfAt(pos src.XPos, format string, args ...any) { FlushErrors() bugStack.Inc() @@ -244,14 +244,14 @@ func Assert(b bool) { } // Assertf reports a fatal error with Fatalf, unless b is true. -func Assertf(b bool, format string, args ...interface{}) { +func Assertf(b bool, format string, args ...any) { if !b { Fatalf(format, args...) } } // AssertfAt reports a fatal error with FatalfAt, unless b is true. -func AssertfAt(b bool, pos src.XPos, format string, args ...interface{}) { +func AssertfAt(b bool, pos src.XPos, format string, args ...any) { if !b { FatalfAt(pos, format, args...) } diff --git a/src/cmd/compile/internal/base/timings.go b/src/cmd/compile/internal/base/timings.go index f48ac93699..cbcd4dc6f5 100644 --- a/src/cmd/compile/internal/base/timings.go +++ b/src/cmd/compile/internal/base/timings.go @@ -168,7 +168,7 @@ type lines [][]string func (lines *lines) add(label string, n int, dt, tot time.Duration, events []*event) { var line []string - add := func(format string, args ...interface{}) { + add := func(format string, args ...any) { line = append(line, fmt.Sprintf(format, args...)) } diff --git a/src/cmd/compile/internal/ir/dump.go b/src/cmd/compile/internal/ir/dump.go index 4c218682ea..3e5e6fbdce 100644 --- a/src/cmd/compile/internal/ir/dump.go +++ b/src/cmd/compile/internal/ir/dump.go @@ -21,7 +21,7 @@ import ( ) // DumpAny is like FDumpAny but prints to stderr. -func DumpAny(root interface{}, filter string, depth int) { +func DumpAny(root any, filter string, depth int) { FDumpAny(os.Stderr, root, filter, depth) } @@ -42,7 +42,7 @@ func DumpAny(root interface{}, filter string, depth int) { // rather than their type; struct fields with zero values or // non-matching field names are omitted, and "…" means recursion // depth has been reached or struct fields have been omitted. -func FDumpAny(w io.Writer, root interface{}, filter string, depth int) { +func FDumpAny(w io.Writer, root any, filter string, depth int) { if root == nil { fmt.Fprintln(w, "nil") return @@ -110,7 +110,7 @@ func (p *dumper) Write(data []byte) (n int, err error) { } // printf is a convenience wrapper. -func (p *dumper) printf(format string, args ...interface{}) { +func (p *dumper) printf(format string, args ...any) { if _, err := fmt.Fprintf(p, format, args...); err != nil { panic(err) } diff --git a/src/cmd/compile/internal/ir/func.go b/src/cmd/compile/internal/ir/func.go index 668537c90e..e027fe8290 100644 --- a/src/cmd/compile/internal/ir/func.go +++ b/src/cmd/compile/internal/ir/func.go @@ -90,7 +90,7 @@ type Func struct { Marks []Mark FieldTrack map[*obj.LSym]struct{} - DebugInfo interface{} + DebugInfo any LSym *obj.LSym // Linker object in this function's native ABI (Func.ABI) Inl *Inline diff --git a/src/cmd/compile/internal/ir/name.go b/src/cmd/compile/internal/ir/name.go index 6f8d0a7fcc..01f1c0c502 100644 --- a/src/cmd/compile/internal/ir/name.go +++ b/src/cmd/compile/internal/ir/name.go @@ -43,8 +43,8 @@ type Name struct { Func *Func // TODO(austin): nil for I.M Offset_ int64 val constant.Value - Opt interface{} // for use by escape analysis - Embed *[]Embed // list of embedded files, for ONAME var + Opt any // for use by escape analysis + Embed *[]Embed // list of embedded files, for ONAME var // For a local variable (not param) or extern, the initializing assignment (OAS or OAS2). // For a closure var, the ONAME node of the original (outermost) captured variable. diff --git a/src/cmd/compile/internal/ir/sizeof_test.go b/src/cmd/compile/internal/ir/sizeof_test.go index 14b6b4f3cd..b805155e6e 100644 --- a/src/cmd/compile/internal/ir/sizeof_test.go +++ b/src/cmd/compile/internal/ir/sizeof_test.go @@ -16,9 +16,9 @@ func TestSizeof(t *testing.T) { const _64bit = unsafe.Sizeof(uintptr(0)) == 8 var tests = []struct { - val interface{} // type as a value - _32bit uintptr // size on 32bit platforms - _64bit uintptr // size on 64bit platforms + val any // type as a value + _32bit uintptr // size on 32bit platforms + _64bit uintptr // size on 64bit platforms }{ {Func{}, 184, 312}, {Name{}, 96, 160}, diff --git a/src/cmd/compile/internal/logopt/log_opts.go b/src/cmd/compile/internal/logopt/log_opts.go index d08f6fb5d6..c47c9ee5af 100644 --- a/src/cmd/compile/internal/logopt/log_opts.go +++ b/src/cmd/compile/internal/logopt/log_opts.go @@ -224,12 +224,12 @@ type Diagnostic struct { // A LoggedOpt is what the compiler produces and accumulates, // to be converted to JSON for human or IDE consumption. type LoggedOpt struct { - pos src.XPos // Source code position at which the event occurred. If it is inlined, outer and all inlined locations will appear in JSON. - lastPos src.XPos // Usually the same as pos; current exception is for reporting entire range of transformed loops - compilerPass string // Compiler pass. For human/adhoc consumption; does not appear in JSON (yet) - functionName string // Function name. For human/adhoc consumption; does not appear in JSON (yet) - what string // The (non) optimization; "nilcheck", "boundsCheck", "inline", "noInline" - target []interface{} // Optional target(s) or parameter(s) of "what" -- what was inlined, why it was not, size of copy, etc. 1st is most important/relevant. + pos src.XPos // Source code position at which the event occurred. If it is inlined, outer and all inlined locations will appear in JSON. + lastPos src.XPos // Usually the same as pos; current exception is for reporting entire range of transformed loops + compilerPass string // Compiler pass. For human/adhoc consumption; does not appear in JSON (yet) + functionName string // Function name. For human/adhoc consumption; does not appear in JSON (yet) + what string // The (non) optimization; "nilcheck", "boundsCheck", "inline", "noInline" + target []any // Optional target(s) or parameter(s) of "what" -- what was inlined, why it was not, size of copy, etc. 1st is most important/relevant. } type logFormat uint8 @@ -325,7 +325,7 @@ var mu = sync.Mutex{} // mu protects loggedOpts. // Pos is the source position (including inlining), what is the message, pass is which pass created the message, // funcName is the name of the function // A typical use for this to accumulate an explanation for a missed optimization, for example, why did something escape? -func NewLoggedOpt(pos, lastPos src.XPos, what, pass, funcName string, args ...interface{}) *LoggedOpt { +func NewLoggedOpt(pos, lastPos src.XPos, what, pass, funcName string, args ...any) *LoggedOpt { pass = strings.ReplaceAll(pass, " ", "_") return &LoggedOpt{pos, lastPos, pass, funcName, what, args} } @@ -333,7 +333,7 @@ func NewLoggedOpt(pos, lastPos src.XPos, what, pass, funcName string, args ...in // LogOpt logs information about a (usually missed) optimization performed by the compiler. // Pos is the source position (including inlining), what is the message, pass is which pass created the message, // funcName is the name of the function. -func LogOpt(pos src.XPos, what, pass, funcName string, args ...interface{}) { +func LogOpt(pos src.XPos, what, pass, funcName string, args ...any) { if Format == None { return } @@ -346,7 +346,7 @@ func LogOpt(pos src.XPos, what, pass, funcName string, args ...interface{}) { // LogOptRange is the same as LogOpt, but includes the ability to express a range of positions, // not just a point. -func LogOptRange(pos, lastPos src.XPos, what, pass, funcName string, args ...interface{}) { +func LogOptRange(pos, lastPos src.XPos, what, pass, funcName string, args ...any) { if Format == None { return } diff --git a/src/cmd/compile/internal/loopvar/loopvar.go b/src/cmd/compile/internal/loopvar/loopvar.go index 5a4590d299..267df2f905 100644 --- a/src/cmd/compile/internal/loopvar/loopvar.go +++ b/src/cmd/compile/internal/loopvar/loopvar.go @@ -557,7 +557,7 @@ func LogTransformations(transformed []VarAndLoop) { if logopt.Enabled() { // For automated checking of coverage of this transformation, include this in the JSON information. - var nString interface{} = n + var nString any = n if inner != outer { nString = fmt.Sprintf("%v (from inline)", n) } diff --git a/src/cmd/compile/internal/noder/writer.go b/src/cmd/compile/internal/noder/writer.go index 9c90d221c2..0b5aa007bf 100644 --- a/src/cmd/compile/internal/noder/writer.go +++ b/src/cmd/compile/internal/noder/writer.go @@ -120,12 +120,12 @@ func newPkgWriter(m posMap, pkg *types2.Package, info *types2.Info, otherInfo ma } // errorf reports a user error about thing p. -func (pw *pkgWriter) errorf(p poser, msg string, args ...interface{}) { +func (pw *pkgWriter) errorf(p poser, msg string, args ...any) { base.ErrorfAt(pw.m.pos(p), 0, msg, args...) } // fatalf reports an internal compiler error about thing p. -func (pw *pkgWriter) fatalf(p poser, msg string, args ...interface{}) { +func (pw *pkgWriter) fatalf(p poser, msg string, args ...any) { base.FatalfAt(pw.m.pos(p), msg, args...) } diff --git a/src/cmd/compile/internal/ssa/block.go b/src/cmd/compile/internal/ssa/block.go index 1240bfd655..278a6b0d1d 100644 --- a/src/cmd/compile/internal/ssa/block.go +++ b/src/cmd/compile/internal/ssa/block.go @@ -424,9 +424,9 @@ func (b *Block) likelyBranch() bool { return true } -func (b *Block) Logf(msg string, args ...interface{}) { b.Func.Logf(msg, args...) } -func (b *Block) Log() bool { return b.Func.Log() } -func (b *Block) Fatalf(msg string, args ...interface{}) { b.Func.Fatalf(msg, args...) } +func (b *Block) Logf(msg string, args ...any) { b.Func.Logf(msg, args...) } +func (b *Block) Log() bool { return b.Func.Log() } +func (b *Block) Fatalf(msg string, args ...any) { b.Func.Fatalf(msg, args...) } type BranchPrediction int8 diff --git a/src/cmd/compile/internal/ssa/cache.go b/src/cmd/compile/internal/ssa/cache.go index 0c16efcd57..59d768c34f 100644 --- a/src/cmd/compile/internal/ssa/cache.go +++ b/src/cmd/compile/internal/ssa/cache.go @@ -29,7 +29,7 @@ type Cache struct { ValueToProgAfter []*obj.Prog debugState debugState - Liveness interface{} // *gc.livenessFuncCache + Liveness any // *gc.livenessFuncCache // Free "headers" for use by the allocators in allocators.go. // Used to put slices in sync.Pools without allocation. diff --git a/src/cmd/compile/internal/ssa/config.go b/src/cmd/compile/internal/ssa/config.go index ec0240941c..3540db498c 100644 --- a/src/cmd/compile/internal/ssa/config.go +++ b/src/cmd/compile/internal/ssa/config.go @@ -126,17 +126,17 @@ func (t *Types) SetTypPtrs() { type Logger interface { // Logf logs a message from the compiler. - Logf(string, ...interface{}) + Logf(string, ...any) // Log reports whether logging is not a no-op // some logging calls account for more than a few heap allocations. Log() bool // Fatalf reports a compiler error and exits. - Fatalf(pos src.XPos, msg string, args ...interface{}) + Fatalf(pos src.XPos, msg string, args ...any) // Warnl writes compiler messages in the form expected by "errorcheck" tests - Warnl(pos src.XPos, fmt_ string, args ...interface{}) + Warnl(pos src.XPos, fmt_ string, args ...any) // Forwards the Debug flags from gc Debug_checknil() bool diff --git a/src/cmd/compile/internal/ssa/copyelim_test.go b/src/cmd/compile/internal/ssa/copyelim_test.go index fe31b12191..20e548f7fc 100644 --- a/src/cmd/compile/internal/ssa/copyelim_test.go +++ b/src/cmd/compile/internal/ssa/copyelim_test.go @@ -20,7 +20,7 @@ func BenchmarkCopyElim100000(b *testing.B) { benchmarkCopyElim(b, 100000) } func benchmarkCopyElim(b *testing.B, n int) { c := testConfig(b) - values := make([]interface{}, 0, n+2) + values := make([]any, 0, n+2) values = append(values, Valu("mem", OpInitMem, types.TypeMem, 0, nil)) last := "mem" for i := 0; i < n; i++ { diff --git a/src/cmd/compile/internal/ssa/debug.go b/src/cmd/compile/internal/ssa/debug.go index 7edc414bda..687abc42cc 100644 --- a/src/cmd/compile/internal/ssa/debug.go +++ b/src/cmd/compile/internal/ssa/debug.go @@ -195,7 +195,7 @@ type RegisterSet uint64 // logf prints debug-specific logging to stdout (always stdout) if the // current function is tagged by GOSSAFUNC (for ssa output directed // either to stdout or html). -func (s *debugState) logf(msg string, args ...interface{}) { +func (s *debugState) logf(msg string, args ...any) { if s.f.PrintOrHtmlSSA { fmt.Printf(msg, args...) } diff --git a/src/cmd/compile/internal/ssa/expand_calls.go b/src/cmd/compile/internal/ssa/expand_calls.go index 1e2a0df072..8a5b364c2f 100644 --- a/src/cmd/compile/internal/ssa/expand_calls.go +++ b/src/cmd/compile/internal/ssa/expand_calls.go @@ -951,7 +951,7 @@ func (x *expandState) indent(n int) { } // Printf does an indented fmt.Printf on the format and args. -func (x *expandState) Printf(format string, a ...interface{}) (n int, err error) { +func (x *expandState) Printf(format string, a ...any) (n int, err error) { if x.indentLevel > 0 { fmt.Printf("%[1]*s", x.indentLevel, "") } diff --git a/src/cmd/compile/internal/ssa/export_test.go b/src/cmd/compile/internal/ssa/export_test.go index c33c77f891..3ab0be7311 100644 --- a/src/cmd/compile/internal/ssa/export_test.go +++ b/src/cmd/compile/internal/ssa/export_test.go @@ -98,12 +98,12 @@ func (TestFrontend) UseWriteBarrier() bool { return true // only writebarrier_test cares } -func (d TestFrontend) Logf(msg string, args ...interface{}) { d.t.Logf(msg, args...) } -func (d TestFrontend) Log() bool { return true } +func (d TestFrontend) Logf(msg string, args ...any) { d.t.Logf(msg, args...) } +func (d TestFrontend) Log() bool { return true } -func (d TestFrontend) Fatalf(_ src.XPos, msg string, args ...interface{}) { d.t.Fatalf(msg, args...) } -func (d TestFrontend) Warnl(_ src.XPos, msg string, args ...interface{}) { d.t.Logf(msg, args...) } -func (d TestFrontend) Debug_checknil() bool { return false } +func (d TestFrontend) Fatalf(_ src.XPos, msg string, args ...any) { d.t.Fatalf(msg, args...) } +func (d TestFrontend) Warnl(_ src.XPos, msg string, args ...any) { d.t.Logf(msg, args...) } +func (d TestFrontend) Debug_checknil() bool { return false } func (d TestFrontend) Func() *ir.Func { return d.f diff --git a/src/cmd/compile/internal/ssa/func.go b/src/cmd/compile/internal/ssa/func.go index fc8cb3f2fe..56690c8284 100644 --- a/src/cmd/compile/internal/ssa/func.go +++ b/src/cmd/compile/internal/ssa/func.go @@ -336,7 +336,7 @@ func (f *Func) newValueNoBlock(op Op, t *types.Type, pos src.XPos) *Value { // context to allow item-by-item comparisons across runs. // For example: // awk 'BEGIN {FS="\t"} $3~/TIME/{sum+=$4} END{print "t(ns)=",sum}' t.log -func (f *Func) LogStat(key string, args ...interface{}) { +func (f *Func) LogStat(key string, args ...any) { value := "" for _, a := range args { value += fmt.Sprintf("\t%v", a) @@ -729,12 +729,12 @@ func (f *Func) ConstOffPtrSP(t *types.Type, c int64, sp *Value) *Value { return v } -func (f *Func) Frontend() Frontend { return f.fe } -func (f *Func) Warnl(pos src.XPos, msg string, args ...interface{}) { f.fe.Warnl(pos, msg, args...) } -func (f *Func) Logf(msg string, args ...interface{}) { f.fe.Logf(msg, args...) } -func (f *Func) Log() bool { return f.fe.Log() } +func (f *Func) Frontend() Frontend { return f.fe } +func (f *Func) Warnl(pos src.XPos, msg string, args ...any) { f.fe.Warnl(pos, msg, args...) } +func (f *Func) Logf(msg string, args ...any) { f.fe.Logf(msg, args...) } +func (f *Func) Log() bool { return f.fe.Log() } -func (f *Func) Fatalf(msg string, args ...interface{}) { +func (f *Func) Fatalf(msg string, args ...any) { stats := "crashed" if f.Log() { f.Logf(" pass %s end %s\n", f.pass.name, stats) diff --git a/src/cmd/compile/internal/ssa/func_test.go b/src/cmd/compile/internal/ssa/func_test.go index 4639d674e1..1a378d4a95 100644 --- a/src/cmd/compile/internal/ssa/func_test.go +++ b/src/cmd/compile/internal/ssa/func_test.go @@ -206,7 +206,7 @@ func (c *Conf) Fun(entry string, blocs ...bloc) fun { // Bloc defines a block for Fun. The bloc name should be unique // across the containing Fun. entries should consist of calls to valu, // as well as one call to Goto, If, or Exit to specify the block kind. -func Bloc(name string, entries ...interface{}) bloc { +func Bloc(name string, entries ...any) bloc { b := bloc{} b.name = name seenCtrl := false diff --git a/src/cmd/compile/internal/ssa/html.go b/src/cmd/compile/internal/ssa/html.go index 85a414f31e..7a6683e9f0 100644 --- a/src/cmd/compile/internal/ssa/html.go +++ b/src/cmd/compile/internal/ssa/html.go @@ -53,13 +53,13 @@ func NewHTMLWriter(path string, f *Func, cfgMask string) *HTMLWriter { } // Fatalf reports an error and exits. -func (w *HTMLWriter) Fatalf(msg string, args ...interface{}) { +func (w *HTMLWriter) Fatalf(msg string, args ...any) { fe := w.Func.Frontend() fe.Fatalf(src.NoXPos, msg, args...) } // Logf calls the (w *HTMLWriter).Func's Logf method passing along a msg and args. -func (w *HTMLWriter) Logf(msg string, args ...interface{}) { +func (w *HTMLWriter) Logf(msg string, args ...any) { w.Func.Logf(msg, args...) } @@ -945,7 +945,7 @@ func (w *HTMLWriter) WriteMultiTitleColumn(phase string, titles []string, class, w.WriteString("</td>\n") } -func (w *HTMLWriter) Printf(msg string, v ...interface{}) { +func (w *HTMLWriter) Printf(msg string, v ...any) { if _, err := fmt.Fprintf(w.w, msg, v...); err != nil { w.Fatalf("%v", err) } diff --git a/src/cmd/compile/internal/ssa/schedule.go b/src/cmd/compile/internal/ssa/schedule.go index 325118a182..8006253145 100644 --- a/src/cmd/compile/internal/ssa/schedule.go +++ b/src/cmd/compile/internal/ssa/schedule.go @@ -36,13 +36,13 @@ type ValHeap struct { func (h ValHeap) Len() int { return len(h.a) } func (h ValHeap) Swap(i, j int) { a := h.a; a[i], a[j] = a[j], a[i] } -func (h *ValHeap) Push(x interface{}) { +func (h *ValHeap) Push(x any) { // Push and Pop use pointer receivers because they modify the slice's length, // not just its contents. v := x.(*Value) h.a = append(h.a, v) } -func (h *ValHeap) Pop() interface{} { +func (h *ValHeap) Pop() any { old := h.a n := len(old) x := old[n-1] diff --git a/src/cmd/compile/internal/ssa/sizeof_test.go b/src/cmd/compile/internal/ssa/sizeof_test.go index a27002ee3a..766598ebd5 100644 --- a/src/cmd/compile/internal/ssa/sizeof_test.go +++ b/src/cmd/compile/internal/ssa/sizeof_test.go @@ -16,9 +16,9 @@ func TestSizeof(t *testing.T) { const _64bit = unsafe.Sizeof(uintptr(0)) == 8 var tests = []struct { - val interface{} // type as a value - _32bit uintptr // size on 32bit platforms - _64bit uintptr // size on 64bit platforms + val any // type as a value + _32bit uintptr // size on 32bit platforms + _64bit uintptr // size on 64bit platforms }{ {Value{}, 72, 112}, {Block{}, 164, 304}, diff --git a/src/cmd/compile/internal/ssa/value.go b/src/cmd/compile/internal/ssa/value.go index 51a70c7fd4..809ed6c85a 100644 --- a/src/cmd/compile/internal/ssa/value.go +++ b/src/cmd/compile/internal/ssa/value.go @@ -471,9 +471,9 @@ func (v *Value) copyIntoWithXPos(b *Block, pos src.XPos) *Value { return c } -func (v *Value) Logf(msg string, args ...interface{}) { v.Block.Logf(msg, args...) } -func (v *Value) Log() bool { return v.Block.Log() } -func (v *Value) Fatalf(msg string, args ...interface{}) { +func (v *Value) Logf(msg string, args ...any) { v.Block.Logf(msg, args...) } +func (v *Value) Log() bool { return v.Block.Log() } +func (v *Value) Fatalf(msg string, args ...any) { v.Block.Func.fe.Fatalf(v.Pos, msg, args...) } diff --git a/src/cmd/compile/internal/ssagen/phi.go b/src/cmd/compile/internal/ssagen/phi.go index 0dcf353bf4..4043ac4576 100644 --- a/src/cmd/compile/internal/ssagen/phi.go +++ b/src/cmd/compile/internal/ssagen/phi.go @@ -396,11 +396,11 @@ type blockHeap struct { func (h *blockHeap) Len() int { return len(h.a) } func (h *blockHeap) Swap(i, j int) { a := h.a; a[i], a[j] = a[j], a[i] } -func (h *blockHeap) Push(x interface{}) { +func (h *blockHeap) Push(x any) { v := x.(*ssa.Block) h.a = append(h.a, v) } -func (h *blockHeap) Pop() interface{} { +func (h *blockHeap) Pop() any { old := h.a n := len(old) x := old[n-1] diff --git a/src/cmd/compile/internal/ssagen/ssa.go b/src/cmd/compile/internal/ssagen/ssa.go index ae7d57566f..3dea733bbd 100644 --- a/src/cmd/compile/internal/ssagen/ssa.go +++ b/src/cmd/compile/internal/ssagen/ssa.go @@ -1115,13 +1115,13 @@ func (s *state) label(sym *types.Sym) *ssaLabel { return lab } -func (s *state) Logf(msg string, args ...interface{}) { s.f.Logf(msg, args...) } -func (s *state) Log() bool { return s.f.Log() } -func (s *state) Fatalf(msg string, args ...interface{}) { +func (s *state) Logf(msg string, args ...any) { s.f.Logf(msg, args...) } +func (s *state) Log() bool { return s.f.Log() } +func (s *state) Fatalf(msg string, args ...any) { s.f.Frontend().Fatalf(s.peekPos(), msg, args...) } -func (s *state) Warnl(pos src.XPos, msg string, args ...interface{}) { s.f.Warnl(pos, msg, args...) } -func (s *state) Debug_checknil() bool { return s.f.Frontend().Debug_checknil() } +func (s *state) Warnl(pos src.XPos, msg string, args ...any) { s.f.Warnl(pos, msg, args...) } +func (s *state) Debug_checknil() bool { return s.f.Frontend().Debug_checknil() } func ssaMarker(name string) *ir.Name { return ir.NewNameAt(base.Pos, &types.Sym{Name: name}, nil) @@ -7714,7 +7714,7 @@ func (e *ssafn) SplitSlot(parent *ssa.LocalSlot, suffix string, offset int64, t } // Logf logs a message from the compiler. -func (e *ssafn) Logf(msg string, args ...interface{}) { +func (e *ssafn) Logf(msg string, args ...any) { if e.log { fmt.Printf(msg, args...) } @@ -7725,15 +7725,15 @@ func (e *ssafn) Log() bool { } // Fatalf reports a compiler error and exits. -func (e *ssafn) Fatalf(pos src.XPos, msg string, args ...interface{}) { +func (e *ssafn) Fatalf(pos src.XPos, msg string, args ...any) { base.Pos = pos - nargs := append([]interface{}{ir.FuncName(e.curfn)}, args...) + nargs := append([]any{ir.FuncName(e.curfn)}, args...) base.Fatalf("'%s': "+msg, nargs...) } // Warnl reports a "warning", which is usually flag-triggered // logging output for the benefit of tests. -func (e *ssafn) Warnl(pos src.XPos, fmt_ string, args ...interface{}) { +func (e *ssafn) Warnl(pos src.XPos, fmt_ string, args ...any) { base.WarnfAt(pos, fmt_, args...) } diff --git a/src/cmd/compile/internal/syntax/branches.go b/src/cmd/compile/internal/syntax/branches.go index 8b360176e8..3a2479bb8a 100644 --- a/src/cmd/compile/internal/syntax/branches.go +++ b/src/cmd/compile/internal/syntax/branches.go @@ -61,7 +61,7 @@ type block struct { lstmt *LabeledStmt // labeled statement associated with this block, or nil } -func (ls *labelScope) errf(pos Pos, format string, args ...interface{}) { +func (ls *labelScope) errf(pos Pos, format string, args ...any) { ls.errh(Error{pos, fmt.Sprintf(format, args...)}) } diff --git a/src/cmd/compile/internal/syntax/dumper.go b/src/cmd/compile/internal/syntax/dumper.go index d5247886da..9a021a4582 100644 --- a/src/cmd/compile/internal/syntax/dumper.go +++ b/src/cmd/compile/internal/syntax/dumper.go @@ -89,7 +89,7 @@ type writeError struct { } // printf is a convenience wrapper that takes care of print errors. -func (p *dumper) printf(format string, args ...interface{}) { +func (p *dumper) printf(format string, args ...any) { if _, err := fmt.Fprintf(p, format, args...); err != nil { panic(writeError{err}) } diff --git a/src/cmd/compile/internal/syntax/printer.go b/src/cmd/compile/internal/syntax/printer.go index d86d77e73f..86d93e8932 100644 --- a/src/cmd/compile/internal/syntax/printer.go +++ b/src/cmd/compile/internal/syntax/printer.go @@ -247,7 +247,7 @@ func mayCombine(prev token, next byte) (b bool) { // return } -func (p *printer) print(args ...interface{}) { +func (p *printer) print(args ...any) { for i := 0; i < len(args); i++ { switch x := args[i].(type) { case nil: @@ -455,7 +455,7 @@ func (p *printer) printRawNode(n Node) { p.printExprList(n.ElemList) case *ArrayType: - var len interface{} = _DotDotDot + var len any = _DotDotDot if n.Len != nil { len = n.Len } diff --git a/src/cmd/compile/internal/syntax/scanner.go b/src/cmd/compile/internal/syntax/scanner.go index 807d838386..700908f6bd 100644 --- a/src/cmd/compile/internal/syntax/scanner.go +++ b/src/cmd/compile/internal/syntax/scanner.go @@ -50,12 +50,12 @@ func (s *scanner) init(src io.Reader, errh func(line, col uint, msg string), mod } // errorf reports an error at the most recently read character position. -func (s *scanner) errorf(format string, args ...interface{}) { +func (s *scanner) errorf(format string, args ...any) { s.error(fmt.Sprintf(format, args...)) } // errorAtf reports an error at a byte column offset relative to the current token start. -func (s *scanner) errorAtf(offset int, format string, args ...interface{}) { +func (s *scanner) errorAtf(offset int, format string, args ...any) { s.errh(s.line, s.col+uint(offset), fmt.Sprintf(format, args...)) } diff --git a/src/cmd/compile/internal/syntax/syntax.go b/src/cmd/compile/internal/syntax/syntax.go index 83b102da9f..dd8f2b8200 100644 --- a/src/cmd/compile/internal/syntax/syntax.go +++ b/src/cmd/compile/internal/syntax/syntax.go @@ -36,7 +36,7 @@ type ErrorHandler func(err error) // A Pragma value augments a package, import, const, func, type, or var declaration. // Its meaning is entirely up to the PragmaHandler, // except that nil is used to mean “no pragma seen.” -type Pragma interface{} +type Pragma any // A PragmaHandler is used to process //go: directives while scanning. // It is passed the current pragma value, which starts out being nil, diff --git a/src/cmd/compile/internal/test/fixedbugs_test.go b/src/cmd/compile/internal/test/fixedbugs_test.go index 8ff7a60aae..b6d3e248ad 100644 --- a/src/cmd/compile/internal/test/fixedbugs_test.go +++ b/src/cmd/compile/internal/test/fixedbugs_test.go @@ -24,7 +24,7 @@ func makeT() T { var g T -var sink interface{} +var sink any func TestIssue15854(t *testing.T) { for i := 0; i < 10000; i++ { diff --git a/src/cmd/compile/internal/test/iface_test.go b/src/cmd/compile/internal/test/iface_test.go index db41eb8e55..cb7dc70c2f 100644 --- a/src/cmd/compile/internal/test/iface_test.go +++ b/src/cmd/compile/internal/test/iface_test.go @@ -13,7 +13,7 @@ var x int func TestEfaceConv1(t *testing.T) { a := 5 - i := interface{}(a) + i := any(a) a += 2 if got := i.(int); got != 5 { t.Errorf("wanted 5, got %d\n", got) @@ -23,7 +23,7 @@ func TestEfaceConv1(t *testing.T) { func TestEfaceConv2(t *testing.T) { a := 5 sink = &a - i := interface{}(a) + i := any(a) a += 2 if got := i.(int); got != 5 { t.Errorf("wanted 5, got %d\n", got) @@ -38,7 +38,7 @@ func TestEfaceConv3(t *testing.T) { } //go:noinline -func e2int3(i interface{}) int { +func e2int3(i any) int { x = 7 return i.(int) } @@ -51,7 +51,7 @@ func TestEfaceConv4(t *testing.T) { } //go:noinline -func e2int4(i interface{}, p *int) int { +func e2int4(i any, p *int) int { *p = 7 return i.(int) } @@ -69,7 +69,7 @@ func (i Int) foo() { func TestIfaceConv1(t *testing.T) { a := Int(5) - i := interface{}(a) + i := any(a) a += 2 if got := i.(Int); got != 5 { t.Errorf("wanted 5, got %d\n", int(got)) @@ -79,7 +79,7 @@ func TestIfaceConv1(t *testing.T) { func TestIfaceConv2(t *testing.T) { a := Int(5) sink = &a - i := interface{}(a) + i := any(a) a += 2 if got := i.(Int); got != 5 { t.Errorf("wanted 5, got %d\n", int(got)) @@ -121,7 +121,7 @@ func BenchmarkEfaceInteger(b *testing.B) { } //go:noinline -func i2int(i interface{}) int { +func i2int(i any) int { return i.(int) } diff --git a/src/cmd/compile/internal/test/shift_test.go b/src/cmd/compile/internal/test/shift_test.go index 492379e188..d540f25c73 100644 --- a/src/cmd/compile/internal/test/shift_test.go +++ b/src/cmd/compile/internal/test/shift_test.go @@ -916,7 +916,7 @@ func TestShiftGeneric(t *testing.T) { signed bool shiftWidth int left bool - f interface{} + f any }{ {64, true, 64, true, func(n int64, s uint64) int64 { return n << s }}, {64, true, 64, false, func(n int64, s uint64) int64 { return n >> s }}, diff --git a/src/cmd/compile/internal/typecheck/typecheck.go b/src/cmd/compile/internal/typecheck/typecheck.go index c97220e6c2..d7aad9c6b9 100644 --- a/src/cmd/compile/internal/typecheck/typecheck.go +++ b/src/cmd/compile/internal/typecheck/typecheck.go @@ -713,7 +713,7 @@ func implicitstar(n ir.Node) ir.Node { return Expr(star) } -func needOneArg(n *ir.CallExpr, f string, args ...interface{}) (ir.Node, bool) { +func needOneArg(n *ir.CallExpr, f string, args ...any) (ir.Node, bool) { if len(n.Args) == 0 { p := fmt.Sprintf(f, args...) base.Errorf("missing argument to %s: %v", p, n) diff --git a/src/cmd/compile/internal/types/fmt.go b/src/cmd/compile/internal/types/fmt.go index 67e2e99f02..848720ee89 100644 --- a/src/cmd/compile/internal/types/fmt.go +++ b/src/cmd/compile/internal/types/fmt.go @@ -183,7 +183,7 @@ var BasicTypeNames = []string{ } var fmtBufferPool = sync.Pool{ - New: func() interface{} { + New: func() any { return new(bytes.Buffer) }, } diff --git a/src/cmd/compile/internal/types/sizeof_test.go b/src/cmd/compile/internal/types/sizeof_test.go index ba033ec499..1b80659c8e 100644 --- a/src/cmd/compile/internal/types/sizeof_test.go +++ b/src/cmd/compile/internal/types/sizeof_test.go @@ -16,9 +16,9 @@ func TestSizeof(t *testing.T) { const _64bit = unsafe.Sizeof(uintptr(0)) == 8 var tests = []struct { - val interface{} // type as a value - _32bit uintptr // size on 32bit platforms - _64bit uintptr // size on 64bit platforms + val any // type as a value + _32bit uintptr // size on 32bit platforms + _64bit uintptr // size on 64bit platforms }{ {Sym{}, 32, 64}, {Type{}, 60, 96}, diff --git a/src/cmd/compile/internal/types/type.go b/src/cmd/compile/internal/types/type.go index da859290f7..8de589bae3 100644 --- a/src/cmd/compile/internal/types/type.go +++ b/src/cmd/compile/internal/types/type.go @@ -174,7 +174,7 @@ type Type struct { // TARRAY: *Array // TSLICE: Slice // TSSA: string - extra interface{} + extra any // width is the width of this Type in bytes. width int64 // valid if Align > 0 diff --git a/src/cmd/compile/internal/types2/check.go b/src/cmd/compile/internal/types2/check.go index 8b27d9d3c1..77c59451fd 100644 --- a/src/cmd/compile/internal/types2/check.go +++ b/src/cmd/compile/internal/types2/check.go @@ -118,7 +118,7 @@ type action struct { // If debug is set, describef sets a printf-formatted description for action a. // Otherwise, it is a no-op. -func (a *action) describef(pos poser, format string, args ...interface{}) { +func (a *action) describef(pos poser, format string, args ...any) { if debug { a.desc = &actionDesc{pos, format, args} } @@ -129,7 +129,7 @@ func (a *action) describef(pos poser, format string, args ...interface{}) { type actionDesc struct { pos poser format string - args []interface{} + args []any } // A Checker maintains the state of the type checker. diff --git a/src/cmd/compile/internal/types2/errors.go b/src/cmd/compile/internal/types2/errors.go index 44f2adc7b7..e2f5508a1a 100644 --- a/src/cmd/compile/internal/types2/errors.go +++ b/src/cmd/compile/internal/types2/errors.go @@ -56,7 +56,7 @@ func (check *Checker) newError(code Code) *error_ { // Subsequent calls to addf provide additional information in the form of additional lines // in the error message (types2) or continuation errors identified by a tab-indented error // message (go/types). -func (err *error_) addf(at poser, format string, args ...interface{}) { +func (err *error_) addf(at poser, format string, args ...any) { err.desc = append(err.desc, errorDesc{atPos(at), err.check.sprintf(format, args...)}) } diff --git a/src/cmd/compile/internal/types2/expr.go b/src/cmd/compile/internal/types2/expr.go index d62b024757..39bf4055a3 100644 --- a/src/cmd/compile/internal/types2/expr.go +++ b/src/cmd/compile/internal/types2/expr.go @@ -1247,7 +1247,7 @@ Error: // represented as an integer (such as 1.0) it is returned as an integer value. // This ensures that constants of different kind but equal value (such as // 1.0 + 0i, 1.0, 1) result in the same value. -func keyVal(x constant.Value) interface{} { +func keyVal(x constant.Value) any { switch x.Kind() { case constant.Complex: f := constant.ToFloat(x) diff --git a/src/cmd/compile/internal/types2/hilbert_test.go b/src/cmd/compile/internal/types2/hilbert_test.go index df8a3e7d78..6cc0974c33 100644 --- a/src/cmd/compile/internal/types2/hilbert_test.go +++ b/src/cmd/compile/internal/types2/hilbert_test.go @@ -68,7 +68,7 @@ type gen struct { bytes.Buffer } -func (g *gen) p(format string, args ...interface{}) { +func (g *gen) p(format string, args ...any) { fmt.Fprintf(&g.Buffer, format, args...) } diff --git a/src/cmd/compile/internal/types2/sizeof_test.go b/src/cmd/compile/internal/types2/sizeof_test.go index 13b9620911..092e82318a 100644 --- a/src/cmd/compile/internal/types2/sizeof_test.go +++ b/src/cmd/compile/internal/types2/sizeof_test.go @@ -15,9 +15,9 @@ func TestSizeof(t *testing.T) { const _64bit = ^uint(0)>>32 != 0 var tests = []struct { - val interface{} // type as a value - _32bit uintptr // size on 32bit platforms - _64bit uintptr // size on 64bit platforms + val any // type as a value + _32bit uintptr // size on 32bit platforms + _64bit uintptr // size on 64bit platforms }{ // Types {Basic{}, 16, 32}, diff --git a/src/cmd/compile/internal/types2/stdlib_test.go b/src/cmd/compile/internal/types2/stdlib_test.go index a579c8184e..f778a01a7a 100644 --- a/src/cmd/compile/internal/types2/stdlib_test.go +++ b/src/cmd/compile/internal/types2/stdlib_test.go @@ -460,7 +460,7 @@ func pkgFilenames(dir string, includeTest bool) ([]string, error) { return filenames, nil } -func walkPkgDirs(dir string, pkgh func(dir string, filenames []string), errh func(args ...interface{})) { +func walkPkgDirs(dir string, pkgh func(dir string, filenames []string), errh func(args ...any)) { w := walker{pkgh, errh} w.walk(dir) } diff --git a/src/cmd/compile/internal/types2/stmt.go b/src/cmd/compile/internal/types2/stmt.go index efe9c99d87..47ca4d90ec 100644 --- a/src/cmd/compile/internal/types2/stmt.go +++ b/src/cmd/compile/internal/types2/stmt.go @@ -192,7 +192,7 @@ func (check *Checker) suspendedCall(keyword string, call syntax.Expr) { } // goVal returns the Go value for val, or nil. -func goVal(val constant.Value) interface{} { +func goVal(val constant.Value) any { // val should exist, but be conservative and check if val == nil { return nil @@ -226,7 +226,7 @@ func goVal(val constant.Value) interface{} { // types we need to also check the value's types (e.g., byte(1) vs myByte(1)) // when the switch expression is of interface type. type ( - valueMap map[interface{}][]valueType // underlying Go value -> valueType + valueMap map[any][]valueType // underlying Go value -> valueType valueType struct { pos syntax.Pos typ Type diff --git a/src/cmd/compile/internal/types2/unify.go b/src/cmd/compile/internal/types2/unify.go index f4f24f4d1b..7250d82478 100644 --- a/src/cmd/compile/internal/types2/unify.go +++ b/src/cmd/compile/internal/types2/unify.go @@ -141,7 +141,7 @@ func (u *unifier) unify(x, y Type, mode unifyMode) bool { return u.nify(x, y, mode, nil) } -func (u *unifier) tracef(format string, args ...interface{}) { +func (u *unifier) tracef(format string, args ...any) { fmt.Println(strings.Repeat(". ", u.depth) + sprintf(nil, true, format, args...)) } diff --git a/src/cmd/compile/internal/types2/version.go b/src/cmd/compile/internal/types2/version.go index 765b0f7e9a..512285055c 100644 --- a/src/cmd/compile/internal/types2/version.go +++ b/src/cmd/compile/internal/types2/version.go @@ -58,7 +58,7 @@ func (check *Checker) allowVersion(want goVersion) bool { // verifyVersionf is like allowVersion but also accepts a format string and arguments // which are used to report a version error if allowVersion returns false. -func (check *Checker) verifyVersionf(at poser, v goVersion, format string, args ...interface{}) bool { +func (check *Checker) verifyVersionf(at poser, v goVersion, format string, args ...any) bool { if !check.allowVersion(v) { check.versionErrorf(at, v, format, args...) return false |
