cue/ast: remove support for TemplateLabel

This really hasn't been parsed in ages, so if this
hasn't resulted in problems yet, it is unlikely
this will.

Change-Id: I45c79ad2605479fec4dbdb1df901d458f8662dea
Reviewed-on: https://cue-review.googlesource.com/c/cue/+/9561
Reviewed-by: CUE cueckoo <cueckoo@gmail.com>
Reviewed-by: Paul Jolly <paul@myitcv.org.uk>
diff --git a/cue/ast/ast.go b/cue/ast/ast.go
index 95cc0ce..a7c99a9 100644
--- a/cue/ast/ast.go
+++ b/cue/ast/ast.go
@@ -414,18 +414,6 @@
 	expr
 }
 
-// A TemplateLabel represents a field template declaration in a struct.
-//
-// Deprecated: use square bracket notation through ListLit.
-type TemplateLabel struct {
-	Langle token.Pos
-	Ident  *Ident
-	Rangle token.Pos
-
-	comments
-	label
-}
-
 // A BasicLit node represents a literal of basic type.
 type BasicLit struct {
 	ValuePos token.Pos   // literal position
@@ -770,8 +758,6 @@
 func (x *BadExpr) pos() *token.Pos       { return &x.From }
 func (x *Ident) Pos() token.Pos          { return x.NamePos }
 func (x *Ident) pos() *token.Pos         { return &x.NamePos }
-func (x *TemplateLabel) Pos() token.Pos  { return x.Langle }
-func (x *TemplateLabel) pos() *token.Pos { return &x.Langle }
 func (x *BasicLit) Pos() token.Pos       { return x.ValuePos }
 func (x *BasicLit) pos() *token.Pos      { return &x.ValuePos }
 func (x *Interpolation) Pos() token.Pos  { return x.Elts[0].Pos() }
@@ -817,8 +803,7 @@
 func (x *Ident) End() token.Pos {
 	return x.NamePos.Add(len(x.Name))
 }
-func (x *TemplateLabel) End() token.Pos { return x.Rangle }
-func (x *BasicLit) End() token.Pos      { return x.ValuePos.Add(len(x.Value)) }
+func (x *BasicLit) End() token.Pos { return x.ValuePos.Add(len(x.Value)) }
 
 func (x *Interpolation) End() token.Pos { return x.Elts[len(x.Elts)-1].Pos() }
 func (x *StructLit) End() token.Pos {
diff --git a/cue/ast/astutil/apply.go b/cue/ast/astutil/apply.go
index 8da54fa..58e0fce 100644
--- a/cue/ast/astutil/apply.go
+++ b/cue/ast/astutil/apply.go
@@ -350,9 +350,6 @@
 	case *ast.BottomLit, *ast.BadExpr, *ast.Ident, *ast.BasicLit:
 		// nothing to do
 
-	case *ast.TemplateLabel:
-		apply(v, c, &n.Ident)
-
 	case *ast.Interpolation:
 		applyExprList(v, c, &n, n.Elts)
 
diff --git a/cue/ast/astutil/resolve.go b/cue/ast/astutil/resolve.go
index 68155e4..b1081b0 100644
--- a/cue/ast/astutil/resolve.go
+++ b/cue/ast/astutil/resolve.go
@@ -334,13 +334,6 @@
 				}
 			})
 			walk(s, expr)
-
-		case *ast.TemplateLabel:
-			s = newScope(s.file, s, x, nil)
-			name, err := ast.ParseIdent(label.Ident)
-			if err == nil {
-				s.insert(name, x.Label, x) // Field used for entire lambda.
-			}
 		}
 
 		if n := x.Value; n != nil {
diff --git a/cue/ast/astutil/walk.go b/cue/ast/astutil/walk.go
index 269e371..a3e0249 100644
--- a/cue/ast/astutil/walk.go
+++ b/cue/ast/astutil/walk.go
@@ -95,9 +95,6 @@
 	case *ast.BottomLit, *ast.BadExpr, *ast.Ident, *ast.BasicLit:
 		// nothing to do
 
-	case *ast.TemplateLabel:
-		walk(v, n.Ident)
-
 	case *ast.Interpolation:
 		for _, e := range n.Elts {
 			walk(v, e)
diff --git a/cue/ast/walk.go b/cue/ast/walk.go
index 659d6c4..a0f81fd 100644
--- a/cue/ast/walk.go
+++ b/cue/ast/walk.go
@@ -100,9 +100,6 @@
 	case *BottomLit, *BadExpr, *Ident, *BasicLit:
 		// nothing to do
 
-	case *TemplateLabel:
-		walk(v, n.Ident)
-
 	case *Interpolation:
 		for _, e := range n.Elts {
 			walk(v, e)
diff --git a/cue/format/node.go b/cue/format/node.go
index bbc6e02..697d538 100644
--- a/cue/format/node.go
+++ b/cue/format/node.go
@@ -485,11 +485,6 @@
 		}
 		f.print(n.ValuePos, str)
 
-	case *ast.TemplateLabel:
-		f.print(n.Langle, token.LSS, indent)
-		f.label(n.Ident, false)
-		f.print(unindent, n.Rangle, token.GTR)
-
 	case *ast.ListLit:
 		f.expr(n)
 
diff --git a/internal/astinternal/debugstr.go b/internal/astinternal/debugstr.go
index c67b392..b305969 100644
--- a/internal/astinternal/debugstr.go
+++ b/internal/astinternal/debugstr.go
@@ -158,12 +158,6 @@
 	case *ast.Ident:
 		return v.Name
 
-	case *ast.TemplateLabel:
-		out := "<"
-		out += DebugStr(v.Ident)
-		out += ">"
-		return out
-
 	case *ast.SelectorExpr:
 		return DebugStr(v.X) + "." + DebugStr(v.Sel)
 
diff --git a/tools/fix/fix.go b/tools/fix/fix.go
index 1e814fb..2fbbb43 100644
--- a/tools/fix/fix.go
+++ b/tools/fix/fix.go
@@ -150,26 +150,6 @@
 		}
 	}
 
-	// Rewrite TemplateLabel to ListLit.
-	// Note: there is a chance that the name will clash with the
-	// scope in which it is defined. We drop the alias if it is not
-	// used to mitigate this issue.
-	f = astutil.Apply(f, func(c astutil.Cursor) bool {
-		n := c.Node()
-		switch x := n.(type) {
-		case *ast.TemplateLabel:
-			var expr ast.Expr = ast.NewIdent("string")
-			if _, ok := referred[x]; ok {
-				expr = &ast.Alias{
-					Ident: x.Ident,
-					Expr:  ast.NewIdent("_"),
-				}
-			}
-			c.Replace(ast.NewList(expr))
-		}
-		return true
-	}, nil).(*ast.File)
-
 	// Rewrite quoted identifier fields that are referenced.
 	f = astutil.Apply(f, func(c astutil.Cursor) bool {
 		n := c.Node()