go/packages: change import cycle errorkind from UnknownError to ListError

The import cycle not allowed error should be returned as a ListError not
an UnknownError.

Fixes golang/go#35964

Change-Id: Ibc575f92d926ff715c0da67a4fceda05badcc652
Reviewed-on: https://go-review.googlesource.com/c/tools/+/212138
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
Run-TryBot: Rohan Challa <rohan@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
Rohan Challa 2019-12-19 10:01:26 -05:00
parent 979b82bfef
commit 4f29fbcc08
2 changed files with 5 additions and 4 deletions

View File

@ -811,8 +811,9 @@ func golistDriver(cfg *Config, rootsDirs func() *goInfo, words ...string) (*driv
msg += fmt.Sprintf(": import stack: %v", p.Error.ImportStack)
}
pkg.Errors = append(pkg.Errors, Error{
Pos: p.Error.Pos,
Msg: msg,
Pos: p.Error.Pos,
Msg: msg,
Kind: ListError,
})
}

View File

@ -72,7 +72,7 @@ func Diagnostics(ctx context.Context, snapshot Snapshot, f File, withAnalysis bo
// Prepare any additional reports for the errors in this package.
for _, e := range pkg.GetErrors() {
// We only need to handle lower-level errors.
if !(e.Kind == UnknownError || e.Kind == ListError) {
if e.Kind != ListError {
continue
}
// If no file is associated with the error, default to the current file.
@ -138,7 +138,7 @@ func diagnostics(ctx context.Context, snapshot Snapshot, pkg Package, reports ma
case TypeError:
set.typeErrors = append(set.typeErrors, diag)
diag.Source = "compiler"
case ListError, UnknownError:
case ListError:
set.listErrors = append(set.listErrors, diag)
diag.Source = "go list"
}