summaryrefslogtreecommitdiff
path: root/vendor/golang.org/x/tools/internal/gcimporter
diff options
context:
space:
mode:
authorLibravatar kim <grufwub@gmail.com>2025-05-10 14:27:25 +0000
committerLibravatar kim <gruf@noreply.codeberg.org>2025-05-10 14:27:25 +0000
commitd2f13e7564059cb4be90650b570b93e4acc964a9 (patch)
treeef47f253925ae524ad9da242345ac4afadcaa970 /vendor/golang.org/x/tools/internal/gcimporter
parent[chore] Poke at `bundle_licenses.sh` a bit to make the output slightly easier... (diff)
downloadgotosocial-d2f13e7564059cb4be90650b570b93e4acc964a9.tar.xz
[chore] update direct Go dependencies (#4162)
- update gruf/go-stroage v0.2.0 -> v0.2.1 - update KimMachineGun/automemlimit v0.7.1 -> v0.7.2 - update miekg/dns v1.1.65 -> v1.1.66 - update ncruces/go-sqlite3 v0.25.1 -> v0.25.2 - update spf13/cast v1.7.1 -> v1.8.0 - update tdewolff/minify/v2 v2.23.1 -> v2.23.5 - update x/crypto v0.37.0 -> v0.38.0 - update x/image v0.26.0 -> v0.27.0 - update x/net v0.39.0 -> v0.40.0 - update x/oauth2 v0.29.0 -> v0.30.0 - update x/sys v0.32.0 -> v0.33.0 - update x/text v0.24.0 -> v0.25.0 Reviewed-on: https://codeberg.org/superseriousbusiness/gotosocial/pulls/4162 Co-authored-by: kim <grufwub@gmail.com> Co-committed-by: kim <grufwub@gmail.com>
Diffstat (limited to 'vendor/golang.org/x/tools/internal/gcimporter')
-rw-r--r--vendor/golang.org/x/tools/internal/gcimporter/iexport.go34
-rw-r--r--vendor/golang.org/x/tools/internal/gcimporter/iimport.go3
2 files changed, 23 insertions, 14 deletions
diff --git a/vendor/golang.org/x/tools/internal/gcimporter/iexport.go b/vendor/golang.org/x/tools/internal/gcimporter/iexport.go
index 253d6493c..780873e3a 100644
--- a/vendor/golang.org/x/tools/internal/gcimporter/iexport.go
+++ b/vendor/golang.org/x/tools/internal/gcimporter/iexport.go
@@ -236,6 +236,7 @@ import (
"io"
"math/big"
"reflect"
+ "slices"
"sort"
"strconv"
"strings"
@@ -271,10 +272,10 @@ import (
// file system, be sure to include a cryptographic digest of the executable in
// the key to avoid version skew.
//
-// If the provided reportf func is non-nil, it will be used for reporting bugs
-// encountered during export.
-// TODO(rfindley): remove reportf when we are confident enough in the new
-// objectpath encoding.
+// If the provided reportf func is non-nil, it is used for reporting
+// bugs (e.g. recovered panics) encountered during export, enabling us
+// to obtain via telemetry the stack that would otherwise be lost by
+// merely returning an error.
func IExportShallow(fset *token.FileSet, pkg *types.Package, reportf ReportFunc) ([]byte, error) {
// In principle this operation can only fail if out.Write fails,
// but that's impossible for bytes.Buffer---and as a matter of
@@ -283,7 +284,7 @@ func IExportShallow(fset *token.FileSet, pkg *types.Package, reportf ReportFunc)
// TODO(adonovan): use byte slices throughout, avoiding copying.
const bundle, shallow = false, true
var out bytes.Buffer
- err := iexportCommon(&out, fset, bundle, shallow, iexportVersion, []*types.Package{pkg})
+ err := iexportCommon(&out, fset, bundle, shallow, iexportVersion, []*types.Package{pkg}, reportf)
return out.Bytes(), err
}
@@ -323,20 +324,27 @@ const bundleVersion = 0
// so that calls to IImportData can override with a provided package path.
func IExportData(out io.Writer, fset *token.FileSet, pkg *types.Package) error {
const bundle, shallow = false, false
- return iexportCommon(out, fset, bundle, shallow, iexportVersion, []*types.Package{pkg})
+ return iexportCommon(out, fset, bundle, shallow, iexportVersion, []*types.Package{pkg}, nil)
}
// IExportBundle writes an indexed export bundle for pkgs to out.
func IExportBundle(out io.Writer, fset *token.FileSet, pkgs []*types.Package) error {
const bundle, shallow = true, false
- return iexportCommon(out, fset, bundle, shallow, iexportVersion, pkgs)
+ return iexportCommon(out, fset, bundle, shallow, iexportVersion, pkgs, nil)
}
-func iexportCommon(out io.Writer, fset *token.FileSet, bundle, shallow bool, version int, pkgs []*types.Package) (err error) {
+func iexportCommon(out io.Writer, fset *token.FileSet, bundle, shallow bool, version int, pkgs []*types.Package, reportf ReportFunc) (err error) {
if !debug {
defer func() {
if e := recover(); e != nil {
+ // Report the stack via telemetry (see #71067).
+ if reportf != nil {
+ reportf("panic in exporter")
+ }
if ierr, ok := e.(internalError); ok {
+ // internalError usually means we exported a
+ // bad go/types data structure: a violation
+ // of an implicit precondition of Export.
err = ierr
return
}
@@ -458,7 +466,7 @@ func (p *iexporter) encodeFile(w *intWriter, file *token.File, needed []uint64)
w.uint64(size)
// Sort the set of needed offsets. Duplicates are harmless.
- sort.Slice(needed, func(i, j int) bool { return needed[i] < needed[j] })
+ slices.Sort(needed)
lines := file.Lines() // byte offset of each line start
w.uint64(uint64(len(lines)))
@@ -812,7 +820,7 @@ func (p *iexporter) doDecl(obj types.Object) {
n := named.NumMethods()
w.uint64(uint64(n))
- for i := 0; i < n; i++ {
+ for i := range n {
m := named.Method(i)
w.pos(m.Pos())
w.string(m.Name())
@@ -1089,7 +1097,7 @@ func (w *exportWriter) doTyp(t types.Type, pkg *types.Package) {
w.pkg(fieldPkg)
w.uint64(uint64(n))
- for i := 0; i < n; i++ {
+ for i := range n {
f := t.Field(i)
if w.p.shallow {
w.objectPath(f)
@@ -1138,7 +1146,7 @@ func (w *exportWriter) doTyp(t types.Type, pkg *types.Package) {
w.startType(unionType)
nt := t.Len()
w.uint64(uint64(nt))
- for i := 0; i < nt; i++ {
+ for i := range nt {
term := t.Term(i)
w.bool(term.Tilde())
w.typ(term.Type(), pkg)
@@ -1267,7 +1275,7 @@ func tparamName(exportName string) string {
func (w *exportWriter) paramList(tup *types.Tuple) {
n := tup.Len()
w.uint64(uint64(n))
- for i := 0; i < n; i++ {
+ for i := range n {
w.param(tup.At(i))
}
}
diff --git a/vendor/golang.org/x/tools/internal/gcimporter/iimport.go b/vendor/golang.org/x/tools/internal/gcimporter/iimport.go
index bc6c9741e..82e6c9d2d 100644
--- a/vendor/golang.org/x/tools/internal/gcimporter/iimport.go
+++ b/vendor/golang.org/x/tools/internal/gcimporter/iimport.go
@@ -16,6 +16,7 @@ import (
"go/types"
"io"
"math/big"
+ "slices"
"sort"
"strings"
@@ -314,7 +315,7 @@ func iimportCommon(fset *token.FileSet, getPackages GetPackagesFunc, data []byte
pkgs = pkgList[:1]
// record all referenced packages as imports
- list := append(([]*types.Package)(nil), pkgList[1:]...)
+ list := slices.Clone(pkgList[1:])
sort.Sort(byPath(list))
pkgs[0].SetImports(list)
}