rustc save-analysis records variant struct-literal spans as referencing enum not variant #96985
Labels
A-diagnostics
Area: Messages for errors, warnings, and lints
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
This came out of investigation into a bug in Mozilla's SearchFox tool output:
https://bugzilla.mozilla.org/show_bug.cgi?id=1623824
(I went into detail about the investigation there, as well as a proof-of-concept patch)
It looks like in a struct-literal construction such as
MyEnum::MyVariant { ... }
, the "MyVariant" span ends up recorded as a reference to MyEnum, not MyVariant.Given the following code: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=e34b9b11c38581770e7cd82f1372b264
The current output is:
Ideally the output should look like:
When searching for references to a particular variant, save-analysis should give us the information to enumerate them, including when used as struct literals.
The downstream effect of this in our SearchFox tool is that we get more hits for the string "CreateExternalSurface" than we do for the enum variant symbol
NativeSurfaceOperationDetails::CreateExternalSurface
:https://searchfox.org/mozilla-central/search?q=CreateExternalSurface&path=*.rs
https://searchfox.org/mozilla-central/search?q=symbol:webrender%3A%3Acomposite%3A%3ANativeSurfaceOperationDetails%3A%3ACreateExternalSurface&redirect=false
The text was updated successfully, but these errors were encountered: