-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
rustc::lint-API: Distinguish directly applicable from colloquial code suggestions #33691
Comments
IMO such a feature would probably be more involved than just span_suggestion, with hooks for replacing individual bits of code (instead of text substitution) in a typed fashion. But if not, a distinguishing span_help_code would be nice. |
@Manishearth what does "in a typed fashion" mean? I would expect that all the hard processing would be done by the tool generating the suggestion (rustc, clippy) and the suggestion is just a set of spans and replacement text (where the replacement text might be the empty string for deletions and the span to be replaced might be zero-length for insertions). We might also want to let the replacing tool format the text, so the suggestion text could be some kind of reification of the AST. That has horrible problems. Alternatively the suggestion could be unformatted source code and if the replacement tool wants to reformat, it can re-parse and reformat. |
Currently clippy takes But yeah, splice-and-feed-to-rustfmt sort of works too. |
Related internals post: https://internals.rust-lang.org/t/rustcs-json-output-format/3446/11?u=ker if things like |
Yeah, I think in that case we don't want to output code in the first place |
Not sure I understand? If there's an ambiguity, the user can decide, but often it's still possible to provide sensible choices, so the user can click on a choice and the IDE inserts that one. Are you suggesting to never provide snippets if there are ambiguities or heuristics involved? |
I guess? We'd need a clear distinction then, right. |
I think it is enough to simply clarify that |
Yeah, that was my point -- we don't do it now and we can continue not doing it. |
I think we have two interesting distinctions to make:
|
I think this has been resolved by the |
There has been some inquiry into a "quick fix" IDE feature for Rust. Given that lints (including clippy) already generate suggestions based on code, a quick win could be made by allowing the lints to distinguish directly applicable suggestions and perhaps somehow flag those for tools using rustc's JSON output. Then IDEs could weave the suggestions into the code based on the reported span.
cc @jonathandturner @nrc @Manishearth @mcarton @birkenfeld
The text was updated successfully, but these errors were encountered: