Skip to content

all: remove unneeded loop variables in tests #76411

@ariel-anieli

Description

@ariel-anieli

CL 711640 removed unneeded loop variables in tests; since 1.22 they are no more needed.

Some leftover are present after that CL, and were addressed partly by CL 719600 and CL 711801.

# git ls-files | xargs -I {} perl -nE 'print "$ARGV:$.:$_" if /\s+(\w+) := \1$/' {} | grep _test
src/cmd/api/api_test.go:235:            context := context
src/cmd/cgo/internal/testerrors/errors_test.go:155:             cflags := cflags
src/cmd/cgo/internal/testsanitizers/asan_test.go:51:            tc := tc
src/cmd/cgo/internal/testsanitizers/cshared_test.go:57:         tc := tc
src/cmd/cgo/internal/testsanitizers/libfuzzer_test.go:46:               tc := tc
src/cmd/cgo/internal/testsanitizers/msan_test.go:65:            tc := tc
src/cmd/cgo/internal/testsanitizers/tsan_test.go:62:            tc := tc
src/cmd/cgo/internal/teststdio/stdio_test.go:59:                file := file
src/cmd/compile/internal/test/reproduciblebuilds_test.go:29:            test := test
src/cmd/compile/internal/test/ssa_test.go:166:                  test := test
src/cmd/compile/internal/types2/api_test.go:2423:                       i := i
src/cmd/compile/internal/types2/api_test.go:2602:               test := test
src/cmd/compile/internal/types2/sizes_test.go:187:              tc := tc
src/cmd/compile/internal/types2/stdlib_test.go:62:              dir := dir
src/cmd/go/go_test.go:1548:             tt := tt
src/cmd/go/internal/modfetch/coderepo_test.go:822:              tt := tt
src/cmd/go/internal/modfetch/coderepo_test.go:905:                      tt := tt
src/cmd/go/internal/modload/query_test.go:182:          tt := tt
src/cmd/go/internal/web/url_test.go:17:         tc := tc
src/cmd/go/internal/web/url_test.go:49:         tc := tc
src/cmd/go/script_test.go:110:          file := file
src/cmd/internal/par/queue_test.go:54:          i := i
src/cmd/link/dwarf_test.go:85:          prog := prog
src/cmd/link/dwarf_test.go:86:          expectDWARF := expectDWARF
src/cmd/link/internal/ld/deadcode_test.go:37:           test := test
src/cmd/link/internal/ld/dwarf_test.go:411:             tc := tc
src/cmd/link/internal/ld/dwarf_test.go:476:             tc := tc
src/cmd/link/internal/ld/dwarf_test.go:558:             tc := tc
src/cmd/link/internal/ld/dwarf_test.go:1983:            opt := opt
src/cmd/link/internal/ld/ld_test.go:357:                tt := tt
src/cmd/link/link_test.go:1625:         test := test
src/crypto/md5/md5_test.go:290: buf := buf
src/math/big/arith_test.go:62:                                  name := name
src/math/big/arith_test.go:68:                                  zz := zz
src/math/big/arith_test.go:115:                                 name := name
src/math/big/arith_test.go:121:                                 zz1 := zz1
src/math/big/arith_test.go:122:                                 zz2 := zz2
src/math/big/arith_test.go:178:                                 name := name
src/math/big/arith_test.go:183:                                 zz := zz
src/math/big/arith_test.go:244:                                         name := name
src/math/big/arith_test.go:249:                                         zz := zz
src/math/big/arith_test.go:295:                                         name := name
src/math/big/arith_test.go:301:                                         zz := zz
src/math/big/arith_test.go:349:                                                 name := name
src/math/big/arith_test.go:355:                                                 zz := zz
src/os/os_windows_test.go:1237:         tt := tt
src/runtime/panic_test.go:42:           t := t
src/runtime/syscall_windows_test.go:781:                arglen := arglen
src/unicode/letter_test.go:470:                 tab := tab
src/unicode/letter_test.go:479:                 tab := tab

All copies could be removed, but the ones in math and unicode.

Metadata

Metadata

Assignees

No one assigned

    Labels

    ImplementationIssues describing a semantics-preserving change to the Go implementation.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions