mirror of
https://github.com/mjl-/mox.git
synced 2025-07-21 14:46:39 +03:00
update to latest golang.org/x dependencies
This commit is contained in:
34
vendor/golang.org/x/tools/internal/gcimporter/iexport.go
generated
vendored
34
vendor/golang.org/x/tools/internal/gcimporter/iexport.go
generated
vendored
@ -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))
|
||||
}
|
||||
}
|
||||
|
3
vendor/golang.org/x/tools/internal/gcimporter/iimport.go
generated
vendored
3
vendor/golang.org/x/tools/internal/gcimporter/iimport.go
generated
vendored
@ -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)
|
||||
}
|
||||
|
Reference in New Issue
Block a user