Skip to content

feature: find-references for std::fmt::Debug and std::fmt::Display should include usage in format strings #19335

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
davidbarsky opened this issue Mar 10, 2025 · 4 comments
Labels
A-ide general IDE features A-macro macro expansion C-feature Category: feature request

Comments

@davidbarsky
Copy link
Contributor

@hawkw mentioned to me that it'd be very helpful if rust-analyzer could include the usages of std::fmt::Debug and std::fmt::Display inside calls to format!.

I assume #19130 is a necessary pre-requisite.

@davidbarsky davidbarsky added A-ide general IDE features A-macro macro expansion C-feature Category: feature request labels Mar 10, 2025
@ChayimFriedman2
Copy link
Contributor

I don't think #19130 is a prerequisite, we can do it as well without it, but I don't see how we can do that reasonably: the only textual thing we can search for is format!() (and friends), and I assume it'll have a lot of false positives that will be expensive to validate.

@davidbarsky
Copy link
Contributor Author

I guess it doesn't strike me as any more expensive than a regular find-references.

@Veykril
Copy link
Member

Veykril commented Mar 10, 2025

This isn't really generally doable. Sure we could search for format!, format_args! and println!, but then that only works for those. It won't work for tracing templates for example, or any other third party macro that we aren't hardcoding (and we won't be hardcoding any crate macros here). If rust had f"" strings instead of stupid macros this would be actually doable though

@davidbarsky
Copy link
Contributor Author

Do we need to hardcode macros beyond a reasonable starting set? I imagine we could have a few default options and expose a configuration option to add additional macros.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-ide general IDE features A-macro macro expansion C-feature Category: feature request
Projects
None yet
Development

No branches or pull requests

3 participants