internal/goexperiment: delete RangeFunc goexperiment

It is now always enabeld. The GOEXPERIMENT doesn't control
anything. Remove.

Change-Id: I50eb09f4537f90ec28152eb59a5a689127843fce
Reviewed-on: https://go-review.googlesource.com/c/go/+/684838
Reviewed-by: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
This commit is contained in:
Cherry Mui 2025-06-30 17:34:01 -04:00
parent 7961bf71f8
commit 25816d401c
15 changed files with 6 additions and 59 deletions

View File

@ -399,12 +399,6 @@ func TestIssue47243_TypedRHS(t *testing.T) {
}
func TestCheck(t *testing.T) {
old := buildcfg.Experiment.RangeFunc
defer func() {
buildcfg.Experiment.RangeFunc = old
}()
buildcfg.Experiment.RangeFunc = true
DefPredeclaredTestFuncs()
testDirFiles(t, "../../../../internal/types/testdata/check", 50, false) // TODO(gri) narrow column tolerance
}

View File

@ -9,7 +9,6 @@ package types2
import (
"cmd/compile/internal/syntax"
"go/constant"
"internal/buildcfg"
. "internal/types/errors"
)
@ -237,7 +236,7 @@ func rangeKeyVal(check *Checker, orig Type, allowVersion func(goVersion) bool) (
assert(typ.dir != SendOnly)
return typ.elem, nil, "", true
case *Signature:
if !buildcfg.Experiment.RangeFunc && allowVersion != nil && !allowVersion(go1_23) {
if allowVersion != nil && !allowVersion(go1_23) {
return bad("requires go1.23 or later")
}
// check iterator arity

View File

@ -426,12 +426,6 @@ func TestIssue47243_TypedRHS(t *testing.T) {
}
func TestCheck(t *testing.T) {
old := buildcfg.Experiment.RangeFunc
defer func() {
buildcfg.Experiment.RangeFunc = old
}()
buildcfg.Experiment.RangeFunc = true
DefPredeclaredTestFuncs()
testDirFiles(t, "../../internal/types/testdata/check", false)
}

View File

@ -12,7 +12,6 @@ package types
import (
"go/ast"
"go/constant"
"internal/buildcfg"
. "internal/types/errors"
)
@ -240,7 +239,7 @@ func rangeKeyVal(check *Checker, orig Type, allowVersion func(goVersion) bool) (
assert(typ.dir != SendOnly)
return typ.elem, nil, "", true
case *Signature:
if !buildcfg.Experiment.RangeFunc && allowVersion != nil && !allowVersion(go1_23) {
if allowVersion != nil && !allowVersion(go1_23) {
return bad("requires go1.23 or later")
}
// check iterator arity

View File

@ -1,8 +0,0 @@
// Code generated by mkconsts.go. DO NOT EDIT.
//go:build !goexperiment.rangefunc
package goexperiment
const RangeFunc = false
const RangeFuncInt = 0

View File

@ -1,8 +0,0 @@
// Code generated by mkconsts.go. DO NOT EDIT.
//go:build goexperiment.rangefunc
package goexperiment
const RangeFunc = true
const RangeFuncInt = 1

View File

@ -100,9 +100,6 @@ type Flags struct {
// inlining phase within the Go compiler.
NewInliner bool
// RangeFunc enables range over func.
RangeFunc bool
// AliasTypeParams enables type parameters for alias types.
// Requires that gotypesalias=1 is set with GODEBUG.
// This flag will be removed with Go 1.25.

View File

@ -610,7 +610,6 @@ func testTraceProg(t *testing.T, progName string, extra func(t *testing.T, trace
buildCmd.Args = append(buildCmd.Args, "-race")
}
buildCmd.Args = append(buildCmd.Args, testPath)
buildCmd.Env = append(os.Environ(), "GOEXPERIMENT=rangefunc")
buildOutput, err := buildCmd.CombinedOutput()
if err != nil {
t.Fatalf("failed to build %s: %v: output:\n%s", testPath, err, buildOutput)

View File

@ -186,21 +186,6 @@ func buildTestProg(t *testing.T, binary string, flags ...string) (string, error)
t.Logf("running %v", cmd)
cmd.Dir = "testdata/" + binary
cmd = testenv.CleanCmdEnv(cmd)
// Add the rangefunc GOEXPERIMENT unconditionally since some tests depend on it.
// TODO(61405): Remove this once it's enabled by default.
edited := false
for i := range cmd.Env {
e := cmd.Env[i]
if _, vars, ok := strings.Cut(e, "GOEXPERIMENT="); ok {
cmd.Env[i] = "GOEXPERIMENT=" + vars + ",rangefunc"
edited = true
}
}
if !edited {
cmd.Env = append(cmd.Env, "GOEXPERIMENT=rangefunc")
}
out, err := cmd.CombinedOutput()
if err != nil {
target.err = fmt.Errorf("building %s %v: %v\n%s", binary, flags, err, out)

View File

@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//go:build goexperiment.rangefunc
package race_test
import (

View File

@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//go:build goexperiment.rangefunc
package main
import (

View File

@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//go:build goexperiment.rangefunc && !windows
//go:build !windows
package main

View File

@ -1,4 +1,4 @@
// errorcheck -goexperiment rangefunc
// errorcheck
// Copyright 2023 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style

View File

@ -1,4 +1,4 @@
// run -goexperiment rangefunc
// run
// Copyright 2023 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style

View File

@ -1,4 +1,4 @@
// runoutput -goexperiment rangefunc
// runoutput
// Copyright 2023 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style