@@ -16,8 +16,9 @@ import (
1616"golang.org/x/tools/go/analysis" 
1717"golang.org/x/tools/go/analysis/passes/inspect" 
1818"golang.org/x/tools/go/ast/inspector" 
19- "golang.org/x/tools/internal/analysisinternal " 
19+ "golang.org/x/tools/internal/astutil " 
2020"golang.org/x/tools/internal/typeparams" 
21+ "golang.org/x/tools/internal/typesinternal" 
2122"golang.org/x/tools/internal/versions" 
2223)
2324
@@ -86,7 +87,7 @@ func checkCopyLocksAssign(pass *analysis.Pass, assign *ast.AssignStmt, goversion
8687lhs  :=  assign .Lhs 
8788for  i , x  :=  range  assign .Rhs  {
8889if  path  :=  lockPathRhs (pass , x ); path  !=  nil  {
89- pass .ReportRangef (x , "assignment copies lock value to %v: %v" , analysisinternal .Format (pass .Fset , assign .Lhs [i ]), path )
90+ pass .ReportRangef (x , "assignment copies lock value to %v: %v" , astutil .Format (pass .Fset , assign .Lhs [i ]), path )
9091lhs  =  nil  // An lhs has been reported. We prefer the assignment warning and do not report twice. 
9192}
9293}
@@ -100,7 +101,7 @@ func checkCopyLocksAssign(pass *analysis.Pass, assign *ast.AssignStmt, goversion
100101if  id , ok  :=  l .(* ast.Ident ); ok  &&  id .Name  !=  "_"  {
101102if  obj  :=  pass .TypesInfo .Defs [id ]; obj  !=  nil  &&  obj .Type () !=  nil  {
102103if  path  :=  lockPath (pass .Pkg , obj .Type (), nil ); path  !=  nil  {
103- pass .ReportRangef (l , "for loop iteration copies lock value to %v: %v" , analysisinternal .Format (pass .Fset , l ), path )
104+ pass .ReportRangef (l , "for loop iteration copies lock value to %v: %v" , astutil .Format (pass .Fset , l ), path )
104105}
105106}
106107}
@@ -132,7 +133,7 @@ func checkCopyLocksCompositeLit(pass *analysis.Pass, cl *ast.CompositeLit) {
132133x  =  node .Value 
133134}
134135if  path  :=  lockPathRhs (pass , x ); path  !=  nil  {
135- pass .ReportRangef (x , "literal copies lock value from %v: %v" , analysisinternal .Format (pass .Fset , x ), path )
136+ pass .ReportRangef (x , "literal copies lock value from %v: %v" , astutil .Format (pass .Fset , x ), path )
136137}
137138}
138139}
@@ -166,7 +167,7 @@ func checkCopyLocksCallExpr(pass *analysis.Pass, ce *ast.CallExpr) {
166167}
167168for  _ , x  :=  range  ce .Args  {
168169if  path  :=  lockPathRhs (pass , x ); path  !=  nil  {
169- pass .ReportRangef (x , "call of %s copies lock value: %v" , analysisinternal .Format (pass .Fset , ce .Fun ), path )
170+ pass .ReportRangef (x , "call of %s copies lock value: %v" , astutil .Format (pass .Fset , ce .Fun ), path )
170171}
171172}
172173}
@@ -233,7 +234,7 @@ func checkCopyLocksRangeVar(pass *analysis.Pass, rtok token.Token, e ast.Expr) {
233234return 
234235}
235236if  path  :=  lockPath (pass .Pkg , typ , nil ); path  !=  nil  {
236- pass .Reportf (e .Pos (), "range var %s copies lock: %v" , analysisinternal .Format (pass .Fset , e ), path )
237+ pass .Reportf (e .Pos (), "range var %s copies lock: %v" , astutil .Format (pass .Fset , e ), path )
237238}
238239}
239240
@@ -353,7 +354,7 @@ func lockPath(tpkg *types.Package, typ types.Type, seen map[types.Type]bool) typ
353354// In go1.10, sync.noCopy did not implement Locker. 
354355// (The Unlock method was added only in CL 121876.) 
355356// TODO(adonovan): remove workaround when we drop go1.10. 
356- if  analysisinternal .IsTypeNamed (typ , "sync" , "noCopy" ) {
357+ if  typesinternal .IsTypeNamed (typ , "sync" , "noCopy" ) {
357358return  []string {typ .String ()}
358359}
359360
0 commit comments