x/tools/go/packages: "unsafe" should contain GoFiles=["unsafe/unsafe.go"] #59929
Labels
Tools
This label describes issues relating to any tools in the x/tools repository.
Milestone
Since its inception, go/packages has discarded the GoFiles field of the
unsafe
package. (I don't remember why I implemented it this way: perhaps I thought that GoFiles was for files that contain valid Go syntax but are de-selected from the build due to non-matching build tags, whereas it's debatable whether unsafe.go is valid Go. It can't be compiled without a .s file because it has missing function bodies, for example.) In any case, the unsafe package nearly always needs special handling by client applications, and it is inconvenient for some (e.g. gopls) to know the location of the unsafe.go file, so that it can be presented as documentation, and there is insufficient information to compute it from the packages.Package record for package "unsafe", which contains only the ID, Path, and Name fields, but no file names at all.In hindsight I think it makes sense to include unsafe.go among the non-compiled GoFiles. I suspect the change is low risk because (as I mentioned) unsafe nearly always requires special handling anyway, and the GoFiles are never processed by the type checker.
The text was updated successfully, but these errors were encountered: