diff options
author | Dan Willemsen <dwillemsen@google.com> | 2021-08-27 17:18:36 -0700 |
---|---|---|
committer | Dan Willemsen <dwillemsen@google.com> | 2021-08-30 13:27:02 -0700 |
commit | d6d1ab63f7e2d16fb9a1f1d29755d12da90aa0bb (patch) | |
tree | 43d64d6569248844fcab027c24cc369681f688d5 /cmd/guru | |
parent | bcc6484babb4e999e4bdb6a982bfa7e92fc640d2 (diff) | |
parent | 3e0d083b858b3fdb7d095b5a3deb184aa0a5d35e (diff) | |
download | golang-x-tools-d6d1ab63f7e2d16fb9a1f1d29755d12da90aa0bb.tar.gz |
Merge remote-tracking branch 'aosp/upstream-master'
Change-Id: I7e0065c8f43268921768c0469ad2f0467d93fc8d
Diffstat (limited to 'cmd/guru')
-rw-r--r-- | cmd/guru/describe.go | 16 | ||||
-rw-r--r-- | cmd/guru/isAlias18.go | 1 | ||||
-rw-r--r-- | cmd/guru/isAlias19.go | 1 | ||||
-rw-r--r-- | cmd/guru/referrers.go | 2 | ||||
-rw-r--r-- | cmd/guru/testdata/src/describe/main.go | 5 | ||||
-rw-r--r-- | cmd/guru/testdata/src/describe/main.golden | 7 | ||||
-rw-r--r-- | cmd/guru/testdata/src/referrers-json/main.golden | 2 |
7 files changed, 24 insertions, 10 deletions
diff --git a/cmd/guru/describe.go b/cmd/guru/describe.go index 125e40972..41189f662 100644 --- a/cmd/guru/describe.go +++ b/cmd/guru/describe.go @@ -738,6 +738,22 @@ func formatMember(obj types.Object, maxname int) string { } } if typestr == "" { + // The fix for #44515 changed the printing of unsafe.Pointer + // such that it uses a qualifier if one is provided. Using + // the types.RelativeTo qualifier provided here, the output + // is just "Pointer" rather than "unsafe.Pointer". This is + // consistent with the printing of non-type objects but it + // breaks an existing test which needs to work with older + // versions of Go. Re-establish the original output by not + // using a qualifier at all if we're printing a type from + // package unsafe - there's only unsafe.Pointer (#44596). + // NOTE: This correction can be removed (and the test's + // golden file adjusted) once we only run against go1.17 + // or bigger. + qualifier := qualifier + if obj.Pkg() == types.Unsafe { + qualifier = nil + } typestr = types.TypeString(typ, qualifier) } buf.WriteString(typestr) diff --git a/cmd/guru/isAlias18.go b/cmd/guru/isAlias18.go index 6a2a4c0d2..6d9101735 100644 --- a/cmd/guru/isAlias18.go +++ b/cmd/guru/isAlias18.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build !go1.9 // +build !go1.9 package main diff --git a/cmd/guru/isAlias19.go b/cmd/guru/isAlias19.go index 25096ab88..4d6367996 100644 --- a/cmd/guru/isAlias19.go +++ b/cmd/guru/isAlias19.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build go1.9 // +build go1.9 package main diff --git a/cmd/guru/referrers.go b/cmd/guru/referrers.go index a3f167611..9d1507157 100644 --- a/cmd/guru/referrers.go +++ b/cmd/guru/referrers.go @@ -95,7 +95,7 @@ func referrers(q *Query) error { if pkglevel { return globalReferrersPkgLevel(q, obj, fset) } - // We'll use the the object's position to identify it in the larger program. + // We'll use the object's position to identify it in the larger program. objposn := fset.Position(obj.Pos()) defpkg := obj.Pkg().Path() // defining package return globalReferrers(q, qpos.info.Pkg.Path(), defpkg, objposn) diff --git a/cmd/guru/testdata/src/describe/main.go b/cmd/guru/testdata/src/describe/main.go index dad321d17..2e24396fd 100644 --- a/cmd/guru/testdata/src/describe/main.go +++ b/cmd/guru/testdata/src/describe/main.go @@ -10,7 +10,10 @@ import ( "lib" "nosuchpkg" // @describe badimport1 "nosuchpkg" nosuchpkg2 "nosuchpkg" // @describe badimport2 "nosuchpkg2" - _ "unsafe" // @describe unsafe "unsafe" + // The unsafe package changed in Go 1.17 with the addition of + // unsafe.Add and unsafe.Slice. While we still support older versions + // of Go, the test case below cannot be enabled. + // _ "unsafe" // @describe unsafe "unsafe" ) var _ nosuchpkg.T diff --git a/cmd/guru/testdata/src/describe/main.golden b/cmd/guru/testdata/src/describe/main.golden index fe8c878ca..68de5279a 100644 --- a/cmd/guru/testdata/src/describe/main.golden +++ b/cmd/guru/testdata/src/describe/main.golden @@ -20,13 +20,6 @@ import of package "nosuchpkg" -------- @describe badimport2 -------- reference to package "nosuchpkg" --------- @describe unsafe -------- -import of package "unsafe" - builtin Alignof - builtin Offsetof - type Pointer unsafe.Pointer - builtin Sizeof - -------- @describe type-ref-builtin -------- reference to built-in type float64 diff --git a/cmd/guru/testdata/src/referrers-json/main.golden b/cmd/guru/testdata/src/referrers-json/main.golden index 0e5ff9c1c..9f8c93143 100644 --- a/cmd/guru/testdata/src/referrers-json/main.golden +++ b/cmd/guru/testdata/src/referrers-json/main.golden @@ -43,7 +43,7 @@ "package": "describe", "refs": [ { - "pos": "testdata/src/describe/main.go:92:8", + "pos": "testdata/src/describe/main.go:95:8", "text": "\tvar _ lib.Outer // @describe lib-outer \"Outer\"" } ] |