From 3db4888a05fb15035d332a360cb610f2c05370ab Mon Sep 17 00:00:00 2001 From: Cuong Manh Le Date: Thu, 2 Sep 2021 10:42:43 +0700 Subject: [PATCH] cmd/compile: use types2.Unsafe to represent package unsafe in gcimports Followup todo in CL 346769. Change-Id: I6c870014523426d65d135da999f97a818a997237 Reviewed-on: https://go-review.googlesource.com/c/go/+/347270 Trust: Cuong Manh Le Run-TryBot: Cuong Manh Le TryBot-Result: Go Bot Reviewed-by: Matthew Dempsky --- src/cmd/compile/internal/noder/irgen.go | 2 +- src/cmd/compile/internal/noder/reader2.go | 4 ---- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/src/cmd/compile/internal/noder/irgen.go b/src/cmd/compile/internal/noder/irgen.go index 70f7991a8e0..fd29c51c8af 100644 --- a/src/cmd/compile/internal/noder/irgen.go +++ b/src/cmd/compile/internal/noder/irgen.go @@ -35,7 +35,7 @@ func checkFiles(noders []*noder) (posMap, *types2.Package, *types2.Info) { // typechecking importer := gcimports{ - packages: make(map[string]*types2.Package), + packages: map[string]*types2.Package{"unsafe": types2.Unsafe}, } conf := types2.Config{ GoVersion: base.Flag.Lang, diff --git a/src/cmd/compile/internal/noder/reader2.go b/src/cmd/compile/internal/noder/reader2.go index a775ffda34a..cffa0372364 100644 --- a/src/cmd/compile/internal/noder/reader2.go +++ b/src/cmd/compile/internal/noder/reader2.go @@ -147,10 +147,6 @@ func (r *reader2) doPkg() *types2.Package { if path == "builtin" { return nil // universe } - if path == "unsafe" { - // TODO(mdempsky): This should be in r.p.imports. - return types2.Unsafe - } if path == "" { path = r.p.pkgPath }