Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
internal/lsp: fix fillstruct for structs with unsafe.Pointer
Provide a default value for unsafe.Pointer in fillstruct. Fixes golang/go#52640 Change-Id: I10a1878fbf53b082f83f44e0ba2788ead14439d6 Reviewed-on: https://go-review.googlesource.com/c/tools/+/403535 TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Suzy Mueller <suzmue@golang.org> gopls-CI: kokoro <noreply+kokoro@google.com> Reviewed-by: Robert Findley <rfindley@google.com> Reviewed-by: David Chase <drchase@google.com>
- Loading branch information
Showing
6 changed files
with
40 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package fillstruct | ||
|
||
import "unsafe" | ||
|
||
type unsafeStruct struct { | ||
x int | ||
p unsafe.Pointer | ||
} | ||
|
||
func fill() { | ||
_ := unsafeStruct{} //@suggestedfix("}", "refactor.rewrite") | ||
} |
17 changes: 17 additions & 0 deletions
17
internal/lsp/testdata/fillstruct/fill_struct_unsafe.go.golden
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
-- suggestedfix_fill_struct_unsafe_11_20 -- | ||
package fillstruct | ||
|
||
import "unsafe" | ||
|
||
type unsafeStruct struct { | ||
x int | ||
p unsafe.Pointer | ||
} | ||
|
||
func fill() { | ||
_ := unsafeStruct{ | ||
x: 0, | ||
p: nil, | ||
} //@suggestedfix("}", "refactor.rewrite") | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters