1
0
mirror of https://github.com/golang/go synced 2024-11-23 03:50:03 -07:00

cmd/compile/internal/syntax: remove AllowTypeSets mode

The respective issue has been accepted, so we can always
accept constraint literals with omitted interfaces.

For #48424.

Change-Id: Ia3d325401252a5a22d5ffa98d2ae6af73178dec0
Reviewed-on: https://go-review.googlesource.com/c/go/+/355709
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
This commit is contained in:
Robert Griesemer 2021-10-13 11:50:46 -07:00
parent b90d258b18
commit 276fb279d1
7 changed files with 9 additions and 10 deletions

View File

@ -36,7 +36,7 @@ func LoadPackage(filenames []string) {
mode := syntax.CheckBranches
if supportsGenerics {
mode |= syntax.AllowGenerics | syntax.AllowTypeSets
mode |= syntax.AllowGenerics
}
// Limit the number of simultaneously open files.

View File

@ -130,7 +130,7 @@ func testSyntaxErrors(t *testing.T, filename string) {
var mode Mode
if strings.HasSuffix(filename, ".go2") {
mode = AllowGenerics | AllowTypeSets
mode = AllowGenerics
}
ParseFile(filename, func(err error) {
e, ok := err.(Error)

View File

@ -1820,7 +1820,7 @@ func (p *parser) paramDeclOrNil(name *Name, follow token) *Field {
}
// type set notation is ok in type parameter lists
typeSetsOk := p.mode&AllowTypeSets != 0 && follow == _Rbrack
typeSetsOk := follow == _Rbrack
pos := p.pos()
if name != nil {

View File

@ -26,11 +26,11 @@ var (
)
func TestParse(t *testing.T) {
ParseFile(*src_, func(err error) { t.Error(err) }, nil, AllowGenerics|AllowTypeSets)
ParseFile(*src_, func(err error) { t.Error(err) }, nil, AllowGenerics)
}
func TestVerify(t *testing.T) {
ast, err := ParseFile(*src_, func(err error) { t.Error(err) }, nil, AllowGenerics|AllowTypeSets)
ast, err := ParseFile(*src_, func(err error) { t.Error(err) }, nil, AllowGenerics)
if err != nil {
return // error already reported
}
@ -46,7 +46,7 @@ func TestParseGo2(t *testing.T) {
for _, fi := range list {
name := fi.Name()
if !fi.IsDir() && !strings.HasPrefix(name, ".") {
ParseFile(filepath.Join(dir, name), func(err error) { t.Error(err) }, nil, AllowGenerics|AllowTypeSets)
ParseFile(filepath.Join(dir, name), func(err error) { t.Error(err) }, nil, AllowGenerics)
}
}
}

View File

@ -72,7 +72,7 @@ var stringTests = []string{
"package p; func (*R[A, B, C]) _()",
"package p; func (_ *R[A, B, C]) _()",
// type constraint literals with elided interfaces (only if AllowTypeSets is set)
// type constraint literals with elided interfaces
"package p; func _[P ~int, Q int | string]() {}",
"package p; func _[P struct{f int}, Q *P]() {}",
@ -94,7 +94,7 @@ var stringTests = []string{
func TestPrintString(t *testing.T) {
for _, want := range stringTests {
ast, err := Parse(nil, strings.NewReader(want), nil, nil, AllowGenerics|AllowTypeSets)
ast, err := Parse(nil, strings.NewReader(want), nil, nil, AllowGenerics)
if err != nil {
t.Error(err)
continue

View File

@ -17,7 +17,6 @@ type Mode uint
const (
CheckBranches Mode = 1 << iota // check correct use of labels, break, continue, and goto statements
AllowGenerics
AllowTypeSets // requires AllowGenerics; remove once #48424 is decided
)
// Error describes a syntax error. Error implements the error interface.

View File

@ -100,7 +100,7 @@ func testFiles(t *testing.T, filenames []string, colDelta uint, manual bool) {
var mode syntax.Mode
if strings.HasSuffix(filenames[0], ".go2") {
mode |= syntax.AllowGenerics | syntax.AllowTypeSets
mode |= syntax.AllowGenerics
}
// parse files and collect parser errors
files, errlist := parseFiles(t, filenames, mode)