From 6c25ba624fd032a20dcfa94f9f9f0ae32c57c54b Mon Sep 17 00:00:00 2001 From: Alan Donovan Date: Wed, 1 Jun 2022 12:54:00 -0400 Subject: [PATCH] go/token: delete unused File.set field This field is only used for a sanity check in a test. Change-Id: I868ed10131ec33994ebb1b1d88f6740956824bd7 Reviewed-on: https://go-review.googlesource.com/c/go/+/409834 Run-TryBot: Robert Findley TryBot-Result: Gopher Robot Reviewed-by: Robert Findley Reviewed-by: Robert Griesemer --- src/go/token/position.go | 3 +-- src/go/token/serialize.go | 1 - src/go/token/serialize_test.go | 6 ------ 3 files changed, 1 insertion(+), 9 deletions(-) diff --git a/src/go/token/position.go b/src/go/token/position.go index 00f24535bf..bd9ae07b28 100644 --- a/src/go/token/position.go +++ b/src/go/token/position.go @@ -92,7 +92,6 @@ func (p Pos) IsValid() bool { // A File is a handle for a file belonging to a FileSet. // A File has a name, size, and line offset table. type File struct { - set *FileSet name string // file name as provided to AddFile base int // Pos value range for this file is [base...base+size] size int // file size as provided to AddFile @@ -418,7 +417,7 @@ func (s *FileSet) AddFile(filename string, base, size int) *File { panic(fmt.Sprintf("invalid size %d (should be >= 0)", size)) } // base >= s.base && size >= 0 - f := &File{set: s, name: filename, base: base, size: size, lines: []int{0}} + f := &File{name: filename, base: base, size: size, lines: []int{0}} base += size + 1 // +1 because EOF also has a position if base < 0 { panic("token.Pos offset overflow (> 2G of source code in file set)") diff --git a/src/go/token/serialize.go b/src/go/token/serialize.go index ffb69908b9..38c10ebd47 100644 --- a/src/go/token/serialize.go +++ b/src/go/token/serialize.go @@ -31,7 +31,6 @@ func (s *FileSet) Read(decode func(any) error) error { for i := 0; i < len(ss.Files); i++ { f := &ss.Files[i] files[i] = &File{ - set: s, name: f.Name, base: f.Base, size: f.Size, diff --git a/src/go/token/serialize_test.go b/src/go/token/serialize_test.go index 4aa0b0da26..8d9799547a 100644 --- a/src/go/token/serialize_test.go +++ b/src/go/token/serialize_test.go @@ -35,12 +35,6 @@ func equal(p, q *FileSet) error { for i, f := range p.files { g := q.files[i] - if f.set != p { - return fmt.Errorf("wrong fileset for %q", f.name) - } - if g.set != q { - return fmt.Errorf("wrong fileset for %q", g.name) - } if f.name != g.name { return fmt.Errorf("different filenames: %q != %q", f.name, g.name) } -- 2.50.0