Skip to content

Commit f2ec001

Browse files
committed
go/doc: mark comparable predeclared
Add comparable to the list of predeclared types. Fixes golang#51141. Change-Id: I4a2d4e7e5680e115de9bca03b6c8ad454551cb82 Reviewed-on: https://go-review.googlesource.com/c/go/+/385114 Trust: Jonathan Amsterdam <jba@google.com> Run-TryBot: Jonathan Amsterdam <jba@google.com> Reviewed-by: Robert Findley <rfindley@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
1 parent e50f0f3 commit f2ec001

File tree

5 files changed

+19
-0
lines changed

5 files changed

+19
-0
lines changed

src/go/doc/reader.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -927,6 +927,7 @@ var predeclaredTypes = map[string]bool{
927927
"any": true,
928928
"bool": true,
929929
"byte": true,
930+
"comparable": true,
930931
"complex64": true,
931932
"complex128": true,
932933
"error": true,

src/go/doc/testdata/b.0.golden

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ VARIABLES
4646

4747

4848
FUNCTIONS
49+
// Associated with comparable type if AllDecls is set.
50+
func ComparableFactory() comparable
51+
4952
//
5053
func F(x int) int
5154

src/go/doc/testdata/b.1.golden

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,12 @@ TYPES
3838
//
3939
func (x *T) M()
4040

41+
// Should only appear if AllDecls is set.
42+
type comparable struct{} // overrides a predeclared type comparable
43+
44+
// Associated with comparable type if AllDecls is set.
45+
func ComparableFactory() comparable
46+
4147
//
4248
type notExported int
4349

src/go/doc/testdata/b.2.golden

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ VARIABLES
4646

4747

4848
FUNCTIONS
49+
// Associated with comparable type if AllDecls is set.
50+
func ComparableFactory() comparable
51+
4952
//
5053
func F(x int) int
5154

src/go/doc/testdata/b.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,15 @@ func UintFactory() uint {}
2727
// Associated with uint type if AllDecls is set.
2828
func uintFactory() uint {}
2929

30+
// Associated with comparable type if AllDecls is set.
31+
func ComparableFactory() comparable {}
32+
3033
// Should only appear if AllDecls is set.
3134
type uint struct{} // overrides a predeclared type uint
3235

36+
// Should only appear if AllDecls is set.
37+
type comparable struct{} // overrides a predeclared type comparable
38+
3339
// ----------------------------------------------------------------------------
3440
// Exported declarations associated with non-exported types must always be shown.
3541

0 commit comments

Comments
 (0)