Revert "gopls/internal/analysis: disable ssa/ir analyzers on range-over-func"

This reverts commit a432b16a0474611e70de0c50694f95a1f70010ea (CL 538778)

Reason for revert: workaround no longer needed.

Updates golang/go#67262

Change-Id: I995bca3a2d835880318ee2a68fa7352aa7ba8776
Reviewed-on: https://go-review.googlesource.com/c/tools/+/623295
Reviewed-by: Robert Findley <rfindley@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Alan Donovan <adonovan@google.com>
diff --git a/gopls/internal/analysis/norangeoverfunc/norangeoverfunc.go b/gopls/internal/analysis/norangeoverfunc/norangeoverfunc.go
deleted file mode 100644
index aa58e89..0000000
--- a/gopls/internal/analysis/norangeoverfunc/norangeoverfunc.go
+++ /dev/null
@@ -1,50 +0,0 @@
-// Copyright 2024 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package norangeoverfunc
-
-// TODO(adonovan): delete this when #67237 and dominikh/go-tools#1494 are fixed.
-
-import (
-	_ "embed"
-	"fmt"
-	"go/ast"
-	"go/types"
-
-	"golang.org/x/tools/go/analysis"
-	"golang.org/x/tools/go/analysis/passes/inspect"
-	"golang.org/x/tools/go/ast/inspector"
-)
-
-var Analyzer = &analysis.Analyzer{
-	Name: "norangeoverfunc",
-	Doc: `norangeoverfunc fails if a package uses go1.23 range-over-func
-
-Require it from any analyzer that cannot yet safely process this new feature.`,
-	Requires: []*analysis.Analyzer{inspect.Analyzer},
-	Run:      run,
-}
-
-func run(pass *analysis.Pass) (any, error) {
-	inspect := pass.ResultOf[inspect.Analyzer].(*inspector.Inspector)
-	filter := []ast.Node{(*ast.RangeStmt)(nil)}
-
-	// TODO(adonovan): opt: short circuit if not using go1.23.
-
-	var found *ast.RangeStmt
-	inspect.Preorder(filter, func(n ast.Node) {
-		if found == nil {
-			stmt := n.(*ast.RangeStmt)
-			if _, ok := pass.TypesInfo.TypeOf(stmt.X).Underlying().(*types.Signature); ok {
-				found = stmt
-			}
-		}
-	})
-	if found != nil {
-		return nil, fmt.Errorf("package %q uses go1.23 range-over-func; cannot build SSA or IR (#67237)",
-			pass.Pkg.Path())
-	}
-
-	return nil, nil
-}
diff --git a/gopls/internal/settings/analysis.go b/gopls/internal/settings/analysis.go
index 86fa476..6bb85f1 100644
--- a/gopls/internal/settings/analysis.go
+++ b/gopls/internal/settings/analysis.go
@@ -50,7 +50,6 @@
 	"golang.org/x/tools/gopls/internal/analysis/fillreturns"
 	"golang.org/x/tools/gopls/internal/analysis/infertypeargs"
 	"golang.org/x/tools/gopls/internal/analysis/nonewvars"
-	"golang.org/x/tools/gopls/internal/analysis/norangeoverfunc"
 	"golang.org/x/tools/gopls/internal/analysis/noresultvalues"
 	"golang.org/x/tools/gopls/internal/analysis/simplifycompositelit"
 	"golang.org/x/tools/gopls/internal/analysis/simplifyrange"
@@ -60,7 +59,6 @@
 	"golang.org/x/tools/gopls/internal/analysis/unusedvariable"
 	"golang.org/x/tools/gopls/internal/analysis/useany"
 	"golang.org/x/tools/gopls/internal/protocol"
-	"honnef.co/go/tools/staticcheck"
 )
 
 // Analyzer augments a [analysis.Analyzer] with additional LSP configuration.
@@ -108,32 +106,7 @@
 var DefaultAnalyzers = make(map[string]*Analyzer) // initialized below
 
 func init() {
-	// Emergency workaround for #67237 to allow standard library
-	// to use range over func: disable SSA-based analyses of
-	// go1.23 packages that use range-over-func.
-	suppressOnRangeOverFunc := func(a *analysis.Analyzer) {
-		a.Requires = append(a.Requires, norangeoverfunc.Analyzer)
-	}
-	// buildir is non-exported so we have to scan the Analysis.Requires graph to find it.
-	var buildir *analysis.Analyzer
-	for _, a := range staticcheck.Analyzers {
-		for _, req := range a.Analyzer.Requires {
-			if req.Name == "buildir" {
-				buildir = req
-			}
-		}
-
-		// Temporarily disable SA4004 CheckIneffectiveLoop as
-		// it crashes when encountering go1.23 range-over-func
-		// (#67237, dominikh/go-tools#1494).
-		if a.Analyzer.Name == "SA4004" {
-			suppressOnRangeOverFunc(a.Analyzer)
-		}
-	}
-	if buildir != nil {
-		suppressOnRangeOverFunc(buildir)
-	}
-
+	// The traditional vet suite:
 	analyzers := []*Analyzer{
 		// The traditional vet suite:
 		{analyzer: appends.Analyzer, enabled: true},
diff --git a/gopls/internal/test/marker/testdata/diagnostics/range-over-func-67237.txt b/gopls/internal/test/marker/testdata/diagnostics/range-over-func-67237.txt
deleted file mode 100644
index e2aa142..0000000
--- a/gopls/internal/test/marker/testdata/diagnostics/range-over-func-67237.txt
+++ /dev/null
@@ -1,82 +0,0 @@
-
-This test verifies that SSA-based analyzers don't run on packages that
-use range-over-func. This is an emergency fix of #67237 (for buildssa)
-until we land https://go.dev/cl/555075.
-
-Similarly, it is an emergency fix of dominikh/go-tools#1494 (for
-buildir) until that package is similarly fixed for go1.23.
-
-Explanation:
-- Package p depends on q and r, and analyzers buildssa and buildir
-  depend on norangeoverfunc.
-- Analysis pass norangeoverfunc@q fails, thus norangeoverfunc@p is not
-  executed; but norangeoverfunc@r is ok
-- nilness requires buildssa, which is not facty, so it can run on p and r.
-- SA4010 (CheckIneffectiveAppend) requires buildir, which is facty,
-  so SA4010 can run only on r.
-
-We don't import any std packages because even "fmt" depends on
-range-over-func now (which means that in practice, everything does).
-
--- flags --
--min_go=go1.23
-
--- settings.json --
-{
-	"staticcheck": true,
-	"analyses": {"SA4010": true}
-}
-
--- go.mod --
-module example.com
-
-go 1.23
-
--- p/p.go --
-package p // a dependency uses range-over-func, so nilness runs but SA4010 cannot (buildir is facty)
-
-import (
-	_ "example.com/q"
-	_ "example.com/r"
-)
-
-func f(ptr *int) {
-	if ptr == nil {
-		println(*ptr) //@diag(re"[*]ptr", re"nil dereference in load")
-	}
-
-	var s []int
-	s = append(s, 1) // no SA4010 finding
-}
-
--- q/q.go --
-package q // uses range-over-func, so no diagnostics from SA4010
-
-type iterSeq[T any] func(yield func(T) bool)
-
-func f(seq iterSeq[int]) {
-	for x := range seq {
-		println(x)
-	}
-
-	var s []int
-	s = append(s, 1) // no SA4010 finding
-}
-
-func _(ptr *int) {
-	if ptr == nil {
-		println(*ptr) //@diag(re"[*]ptr", re"nil dereference in load")
-	}
-}
-
--- r/r.go --
-package r // does not use range-over-func, so nilness and SA4010 report diagnosticcs
-
-func f(ptr *int) {
-	if ptr == nil {
-		println(*ptr) //@diag(re"[*]ptr", re"nil dereference in load")
-	}
-
-	var s []int
-	s = append(s, 1) //@ diag(re`s`, re`s is never used`), diag(re`append`, re`append is never used`)
-}