From e591801c2d4e9296e6c1912b807665f160c01345 Mon Sep 17 00:00:00 2001 From: Alan Donovan Date: Wed, 25 Feb 2015 12:37:17 -0500 Subject: [PATCH] refactor/rename: fix misplaced 'continue'. This was not a visible bug since the only caller discards the relevant result, so I also deleted the result. Fixes #9999 Change-Id: I276d6523b2891d3cb9c8137448e1aed32a5fd197 Reviewed-on: https://go-review.googlesource.com/5921 Reviewed-by: Michael Matloob Reviewed-by: Robert Griesemer --- refactor/rename/mvpkg.go | 4 +--- refactor/rename/rename.go | 12 +++++------- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/refactor/rename/mvpkg.go b/refactor/rename/mvpkg.go index bf8edd6f5a..e31166da81 100644 --- a/refactor/rename/mvpkg.go +++ b/refactor/rename/mvpkg.go @@ -244,9 +244,7 @@ func (m *mover) move() error { // None of the subpackages will change their name---only the from package // itself will. for p := range m.rev[m.from] { - _, err := importName( - m.iprog, m.iprog.Imported[p], m.from, path.Base(m.from), newName) - if err != nil { + if err := importName(m.iprog, m.iprog.Imported[p], m.from, path.Base(m.from), newName); err != nil { return err } } diff --git a/refactor/rename/rename.go b/refactor/rename/rename.go index d37f5b0043..18a3219477 100644 --- a/refactor/rename/rename.go +++ b/refactor/rename/rename.go @@ -164,10 +164,9 @@ var reportError = func(posn token.Position, message string) { // importName renames imports of the package with the given path in // the given package. If fromName is not empty, only imports as -// fromName will be renamed. Even if renaming is successful, there -// may be some files that are unchanged; they are reported in -// unchangedFiles. -func importName(iprog *loader.Program, info *loader.PackageInfo, fromPath, fromName, to string) (unchangedFiles []string, err error) { +// fromName will be renamed. If the renaming would lead to a conflict, +// the file is left unchanged. +func importName(iprog *loader.Program, info *loader.PackageInfo, fromPath, fromName, to string) error { for _, f := range info.Files { var from types.Object for _, imp := range f.Imports { @@ -193,13 +192,12 @@ func importName(iprog *loader.Program, info *loader.PackageInfo, fromPath, fromN r.check(from) if r.hadConflicts { continue // ignore errors; leave the existing name - unchangedFiles = append(unchangedFiles, f.Name.Name) } if err := r.update(); err != nil { - return nil, err + return err } } - return unchangedFiles, nil + return nil } func Main(ctxt *build.Context, offsetFlag, fromFlag, to string) error {