Skip to content

Commit 070951c

Browse files
constraints: remove package
It has moved to golang.org/x/exp/constraints. Perhaps it will move back to the standard library in a future release. For #45458 Fixes #50792 Change-Id: I93aa251a7afe7b329a3d3faadc0c5d6388b1f0e9 Reviewed-on: https://go-review.googlesource.com/c/go/+/382460 Trust: Ian Lance Taylor <[email protected]> Run-TryBot: Ian Lance Taylor <[email protected]> Reviewed-by: Robert Griesemer <[email protected]> TryBot-Result: Gopher Robot <[email protected]>
1 parent 8384fe8 commit 070951c

File tree

11 files changed

+28
-203
lines changed

11 files changed

+28
-203
lines changed

api/go1.18.txt

-6
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
11
pkg bufio, method (*Writer) AvailableBuffer() []uint8
22
pkg bufio, method (ReadWriter) AvailableBuffer() []uint8
33
pkg bytes, func Cut([]uint8, []uint8) ([]uint8, []uint8, bool)
4-
pkg constraints, type Complex interface {}
5-
pkg constraints, type Float interface {}
6-
pkg constraints, type Integer interface {}
7-
pkg constraints, type Ordered interface {}
8-
pkg constraints, type Signed interface {}
9-
pkg constraints, type Unsigned interface {}
104
pkg crypto/tls, method (*Conn) NetConn() net.Conn
115
pkg debug/buildinfo, func Read(io.ReaderAt) (*debug.BuildInfo, error)
126
pkg debug/buildinfo, func ReadFile(string) (*debug.BuildInfo, error)

doc/go1.18.html

-8
Original file line numberDiff line numberDiff line change
@@ -467,14 +467,6 @@ <h2 id="linker">Linker</h2>
467467

468468
<h2 id="library">Core library</h2>
469469

470-
<h3 id="constraints">New <code>constraints</code> package</h3>
471-
472-
<p><!-- CL 349709 -->
473-
The new <a href="/pkg/constraints/"><code>constraints</code></a> package
474-
defines a set of useful constraints that can be used with type parameters of
475-
generic functions.
476-
</p>
477-
478470
<h3 id="debug/buildinfo">New <code>debug/buildinfo</code> package</h3>
479471

480472
<p><!-- golang.org/issue/39301 -->

src/cmd/compile/internal/types2/testdata/fixedbugs/issue47818.go2

-4
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88

99
package go1_17
1010

11-
import "constraints"
12-
1311
type T[P /* ERROR type parameters require go1\.18 or later */ any /* ERROR undeclared name: any \(requires version go1\.18 or later\) */ ] struct{}
1412

1513
// for init (and main, but we're not in package main) we should only get one error
@@ -57,5 +55,3 @@ type (
5755
_ = C1
5856
_ = C2
5957
)
60-
61-
type Ordered constraints /* ERROR using type constraint constraints\.Ordered requires go1\.18 or later */ .Ordered

src/cmd/compile/internal/types2/testdata/fixedbugs/issue49705.go2

+5-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,11 @@
44

55
package p
66

7-
import "constraints"
7+
type Integer interface {
8+
~int | ~int8 | ~int16 | ~int32 | ~int64 |
9+
~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~uintptr
10+
}
811

9-
func shl[I constraints.Integer](n int) I {
12+
func shl[I Integer](n int) I {
1013
return 1 << n
1114
}

src/constraints/constraints.go

-50
This file was deleted.

src/constraints/constraints_test.go

-117
This file was deleted.

src/go/types/testdata/fixedbugs/issue47818.go2

-4
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88

99
package go1_17
1010

11-
import "constraints"
12-
1311
type T[P /* ERROR type parameters require go1\.18 or later */ any /* ERROR undeclared name: any \(requires version go1\.18 or later\) */ ] struct{}
1412

1513
// for init (and main, but we're not in package main) we should only get one error
@@ -57,5 +55,3 @@ type (
5755
_ = C1
5856
_ = C2
5957
)
60-
61-
type Ordered constraints /* ERROR using type constraint constraints\.Ordered requires go1\.18 or later */ .Ordered

src/go/types/testdata/fixedbugs/issue49705.go2

+5-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,11 @@
44

55
package p
66

7-
import "constraints"
7+
type Integer interface {
8+
~int | ~int8 | ~int16 | ~int32 | ~int64 |
9+
~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~uintptr
10+
}
811

9-
func shl[I constraints.Integer](n int) I {
12+
func shl[I Integer](n int) I {
1013
return 1 << n
1114
}

test/typeparam/issue50121.dir/a.go

+6-2
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,15 @@
55
package a
66

77
import (
8-
"constraints"
98
"math/rand"
109
)
1110

12-
type Builder[T constraints.Integer] struct{}
11+
type Integer interface {
12+
~int | ~int8 | ~int16 | ~int32 | ~int64 |
13+
~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~uintptr
14+
}
15+
16+
type Builder[T Integer] struct{}
1317

1418
func (r Builder[T]) New() T {
1519
return T(rand.Int())

test/typeparam/issue50121b.dir/a.go

+5-4
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@
44

55
package a
66

7-
import (
8-
"constraints"
9-
)
7+
type Integer interface {
8+
~int | ~int8 | ~int16 | ~int32 | ~int64 |
9+
~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~uintptr
10+
}
1011

11-
type Builder[T constraints.Integer] struct{}
12+
type Builder[T Integer] struct{}
1213

1314
func (r Builder[T]) New() T {
1415
return T(42)

test/typeparam/issue50193.go

+7-4
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,20 @@
77
package main
88

99
import (
10-
"constraints"
1110
"fmt"
1211
)
1312

14-
func zero[T constraints.Complex]() T {
13+
type Complex interface {
14+
~complex64 | ~complex128
15+
}
16+
17+
func zero[T Complex]() T {
1518
return T(0)
1619
}
17-
func pi[T constraints.Complex]() T {
20+
func pi[T Complex]() T {
1821
return T(3.14)
1922
}
20-
func sqrtN1[T constraints.Complex]() T {
23+
func sqrtN1[T Complex]() T {
2124
return T(-1i)
2225
}
2326

0 commit comments

Comments
 (0)