Skip to content

Commit 6b138e4

Browse files
committed
cue/load: remove some unused code
As found by staticcheck; these seem to have never been used. Change-Id: I698aa9db61a17ed5addcae20e7e8dfd69c436157 Signed-off-by: Daniel Martí <mvdan@mvdan.cc> Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/536098 Reviewed-by: Roger Peppe <rogpeppe@gmail.com> Unity-Result: CUEcueckoo <cueckoo@cuelang.org> TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>
1 parent e74624b commit 6b138e4

File tree

3 files changed

+0
-89
lines changed

3 files changed

+0
-89
lines changed

cue/load/config.go

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import (
1919
"os"
2020
pathpkg "path"
2121
"path/filepath"
22-
goruntime "runtime"
2322
"strings"
2423

2524
"cuelang.org/go/cue/ast"
@@ -629,13 +628,3 @@ func (c Config) findRoot(dir string) string {
629628
abs = d
630629
}
631630
}
632-
633-
func home() string {
634-
env := "HOME"
635-
if goruntime.GOOS == "windows" {
636-
env = "USERPROFILE"
637-
} else if goruntime.GOOS == "plan9" {
638-
env = "home"
639-
}
640-
return os.Getenv(env)
641-
}

cue/load/errors.go

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -24,23 +24,6 @@ import (
2424
"cuelang.org/go/cue/token"
2525
)
2626

27-
func lastError(p *build.Instance) *PackageError {
28-
if p == nil {
29-
return nil
30-
}
31-
switch v := p.Err.(type) {
32-
case *PackageError:
33-
return v
34-
}
35-
return nil
36-
}
37-
38-
func report(p *build.Instance, err *PackageError) {
39-
if err != nil {
40-
p.ReportError(err)
41-
}
42-
}
43-
4427
// A PackageError describes an error loading information about a package.
4528
type PackageError struct {
4629
ImportStack []string // shortest path from package named on command line to this one

cue/load/loader.go

Lines changed: 0 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import (
2323
pathpkg "path"
2424
"path/filepath"
2525
"strings"
26-
"unicode"
2726

2827
"cuelang.org/go/cue/ast"
2928
"cuelang.org/go/cue/build"
@@ -257,63 +256,3 @@ func (s *importStack) Pop() {
257256
func (s *importStack) Copy() []string {
258257
return append([]string{}, *s...)
259258
}
260-
261-
// shorterThan reports whether sp is shorter than t.
262-
// We use this to record the shortest import sequences
263-
// that leads to a particular package.
264-
func (sp *importStack) shorterThan(t []string) bool {
265-
s := *sp
266-
if len(s) != len(t) {
267-
return len(s) < len(t)
268-
}
269-
// If they are the same length, settle ties using string ordering.
270-
for i := range s {
271-
if s[i] != t[i] {
272-
return s[i] < t[i]
273-
}
274-
}
275-
return false // they are equal
276-
}
277-
278-
// reusePackage reuses package p to satisfy the import at the top
279-
// of the import stack stk. If this use causes an import loop,
280-
// reusePackage updates p's error information to record the loop.
281-
func (l *loader) reusePackage(p *build.Instance) *build.Instance {
282-
// We use p.Internal.Imports==nil to detect a package that
283-
// is in the midst of its own loadPackage call
284-
// (all the recursion below happens before p.Internal.Imports gets set).
285-
if p.ImportPaths == nil {
286-
if err := lastError(p); err == nil {
287-
err = l.errPkgf(nil, "import cycle not allowed")
288-
err.IsImportCycle = true
289-
report(p, err)
290-
}
291-
p.Incomplete = true
292-
}
293-
// Don't rewrite the import stack in the error if we have an import cycle.
294-
// If we do, we'll lose the path that describes the cycle.
295-
if err := lastError(p); err != nil && !err.IsImportCycle && l.stk.shorterThan(err.ImportStack) {
296-
err.ImportStack = l.stk.Copy()
297-
}
298-
return p
299-
}
300-
301-
// dirToImportPath returns the pseudo-import path we use for a package
302-
// outside the CUE path. It begins with _/ and then contains the full path
303-
// to the directory. If the package lives in c:\home\gopher\my\pkg then
304-
// the pseudo-import path is _/c_/home/gopher/my/pkg.
305-
// Using a pseudo-import path like this makes the ./ imports no longer
306-
// a special case, so that all the code to deal with ordinary imports works
307-
// automatically.
308-
func dirToImportPath(dir string) string {
309-
return pathpkg.Join("_", strings.Map(makeImportValid, filepath.ToSlash(dir)))
310-
}
311-
312-
func makeImportValid(r rune) rune {
313-
// Should match Go spec, compilers, and ../../go/parser/parser.go:/isValidImport.
314-
const illegalChars = `!"#$%&'()*,:;<=>?[\]^{|}` + "`\uFFFD"
315-
if !unicode.IsGraphic(r) || unicode.IsSpace(r) || strings.ContainsRune(illegalChars, r) {
316-
return '_'
317-
}
318-
return r
319-
}

0 commit comments

Comments
 (0)