1
0
mirror of https://github.com/golang/go synced 2024-11-18 17:04:41 -07:00

internal/lsp/cache: don't type check types.Unsafe

Recent test runs exposed that we are racing to types.Unsafe, as a result
of parallel type checking. Example:
https://storage.googleapis.com/go-build-log/494dd1dd/linux-amd64-race_c978961e.log

We shouldn't have to type check unsafe, so we can return early instead.

Change-Id: I20143dbfb07925d85d7342b93360bdda1c45e4aa
Reviewed-on: https://go-review.googlesource.com/c/tools/+/218497
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
This commit is contained in:
Rob Findley 2020-02-07 13:21:28 -05:00 committed by Robert Findley
parent a9bd9c230f
commit 58fec203a2

View File

@ -325,6 +325,9 @@ func typeCheck(ctx context.Context, fset *token.FileSet, m *metadata, mode sourc
// Use the default type information for the unsafe package.
if pkg.pkgPath == "unsafe" {
pkg.types = types.Unsafe
// Don't type check Unsafe: it's unnecessary, and doing so exposes a data
// race to Unsafe.completed.
return pkg, nil
} else if len(files) == 0 { // not the unsafe package, no parsed files
return nil, errors.Errorf("no parsed files for package %s, expected: %s, errors: %v, list errors: %v", pkg.pkgPath, pkg.compiledGoFiles, actualErrors, rawErrors)
} else {