@@ -72,7 +72,6 @@ const (
72
72
fmtDebug
73
73
fmtTypeID
74
74
fmtTypeIDName
75
- fmtTypeIDHash
76
75
)
77
76
78
77
// Sym
@@ -144,18 +143,6 @@ func symfmt(b *bytes.Buffer, s *Sym, verb rune, mode fmtMode) {
144
143
if q := pkgqual (s .Pkg , verb , mode ); q != "" {
145
144
b .WriteString (q )
146
145
b .WriteByte ('.' )
147
- switch mode {
148
- case fmtTypeIDHash :
149
- // If name is a generic instantiation, don't hash the instantiating types.
150
- // This isn't great, but it is safe. If we hash the instantiating types, then
151
- // we need to make sure they have just the package name. At this point, they
152
- // either have "", or the whole package path, and it is hard to reconcile
153
- // the two without depending on -p (which we might do someday).
154
- // See issue 51250.
155
- if i := strings .Index (name , "[" ); i >= 0 {
156
- name = name [:i ]
157
- }
158
- }
159
146
}
160
147
b .WriteString (name )
161
148
}
@@ -183,7 +170,7 @@ func pkgqual(pkg *Pkg, verb rune, mode fmtMode) string {
183
170
case fmtDebug :
184
171
return pkg .Name
185
172
186
- case fmtTypeIDName , fmtTypeIDHash :
173
+ case fmtTypeIDName :
187
174
// dcommontype, typehash
188
175
return pkg .Name
189
176
@@ -329,7 +316,7 @@ func tconv2(b *bytes.Buffer, t *Type, verb rune, mode fmtMode, visited map[*Type
329
316
if t == AnyType || t == ByteType || t == RuneType {
330
317
// in %-T mode collapse predeclared aliases with their originals.
331
318
switch mode {
332
- case fmtTypeIDName , fmtTypeIDHash , fmtTypeID :
319
+ case fmtTypeIDName , fmtTypeID :
333
320
t = Types [t .Kind ()]
334
321
default :
335
322
sconv2 (b , t .Sym (), 'S' , mode )
@@ -420,7 +407,7 @@ func tconv2(b *bytes.Buffer, t *Type, verb rune, mode fmtMode, visited map[*Type
420
407
case TPTR :
421
408
b .WriteByte ('*' )
422
409
switch mode {
423
- case fmtTypeID , fmtTypeIDName , fmtTypeIDHash :
410
+ case fmtTypeID , fmtTypeIDName :
424
411
if verb == 'S' {
425
412
tconv2 (b , t .Elem (), 'S' , mode , visited )
426
413
return
@@ -482,7 +469,7 @@ func tconv2(b *bytes.Buffer, t *Type, verb rune, mode fmtMode, visited map[*Type
482
469
case IsExported (f .Sym .Name ):
483
470
sconv2 (b , f .Sym , 'S' , mode )
484
471
default :
485
- if mode != fmtTypeIDName && mode != fmtTypeIDHash {
472
+ if mode != fmtTypeIDName {
486
473
mode = fmtTypeID
487
474
}
488
475
sconv2 (b , f .Sym , 'v' , mode )
@@ -552,7 +539,7 @@ func tconv2(b *bytes.Buffer, t *Type, verb rune, mode fmtMode, visited map[*Type
552
539
b .WriteByte (byte (open ))
553
540
fieldVerb := 'v'
554
541
switch mode {
555
- case fmtTypeID , fmtTypeIDName , fmtTypeIDHash , fmtGo :
542
+ case fmtTypeID , fmtTypeIDName , fmtGo :
556
543
// no argument names on function signature, and no "noescape"/"nosplit" tags
557
544
fieldVerb = 'S'
558
545
}
@@ -686,7 +673,7 @@ func fldconv(b *bytes.Buffer, f *Field, verb rune, mode fmtMode, visited map[*Ty
686
673
if name == ".F" {
687
674
name = "F" // Hack for toolstash -cmp.
688
675
}
689
- if ! IsExported (name ) && mode != fmtTypeIDName && mode != fmtTypeIDHash {
676
+ if ! IsExported (name ) && mode != fmtTypeIDName {
690
677
name = sconv (s , 0 , mode ) // qualify non-exported names (used on structs, not on funarg)
691
678
}
692
679
} else {
@@ -754,7 +741,7 @@ func FmtConst(v constant.Value, sharp bool) string {
754
741
755
742
// TypeHash computes a hash value for type t to use in type switch statements.
756
743
func TypeHash (t * Type ) uint32 {
757
- p := tconv ( t , 0 , fmtTypeIDHash )
744
+ p := t . LinkString ( )
758
745
759
746
// Using SHA256 is overkill, but reduces accidental collisions.
760
747
h := notsha256 .Sum256 ([]byte (p ))
0 commit comments