Change information
Commit message:
go/analysis/passes/modernize: stditerators: even better name heuristic
This CL causes stditerators to generate a fresh name only when
the preferred name is already declared _and_ is free in
(referenced within) the loop body. This eliminates most cases
where a fresh (ugly) name is needed.
(Most places that use FreshName should do something similar,
though some care will be required to figure out the correct
abstraction.)
Fixes golang/go#76240
Updates golang/go#76241
Change-Id: Ia7a3332ef49e3d4f2934e9f85215b9373226084a
Files:
- M go/analysis/passes/modernize/errorsastype.go
- M go/analysis/passes/modernize/stditerators.go
- M go/analysis/passes/modernize/stringscut.go
- M go/analysis/passes/modernize/stringscutprefix.go
- M go/analysis/passes/modernize/testdata/src/stditerators/stditerators.go
- M go/analysis/passes/modernize/testdata/src/stditerators/stditerators.go.golden
- M internal/refactor/refactor.go
Change size: M
Delta: 7 files changed, 73 insertions(+), 4 deletions(-)
Branch: refs/heads/master
Submit Requirements:
Code-Review: +2 by Robert Findley
TryBots-Pass: LUCI-TryBot-Result+1 by Go LUCI