-
-
Notifications
You must be signed in to change notification settings - Fork 115
Draft: refactor cli with annotate-snippets
#939
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
base: main
Are you sure you want to change the base?
Draft: refactor cli with annotate-snippets
#939
Conversation
|
I quite like the new format, it looks very promising — especially with the annotated snippets! Are the annotations based on line/column information only, since we don't yet have byte spans in rustdoc JSON? Some thoughts for further experimentation:
|
|
I'm currently working on the final write-up for GSoC, so I'll respond more thoroughly when I'm done with that, but just a note that this current design is imitating the current If we wanted more consistency with rustc/clippy, we could not do that first part with the info and move parts of it to each instance of the lint occurring, and some to |
|
I think if we're going for clippy / rustc consistency, we should go all the way and tweak our error format to print once-per-instance instead of grouping like we currently do. The only thing I'd keep is the initial info on which crate is being scanned / how many lints are being run and why etc. For all the actual lint findings, the sweet spots are probably at either end of the spectrum, not in the middle. |
If it becomes overwhelming, you can omit some of the details for a lint after the first occurrence. |
|
This looks very promising, I like it quite a bit. I think the Thank you for being open to iterate on this — it's a really, really hard problem to nail down all the edge cases. I would recommend not spending 100% of time on only this: we'll have to iterate a bunch more here, and it's nice to mix in some building & merging every so often just for personal satisfaction and morale :) A few thoughts for things to look at next:
|
|
We may need to improve how we handle spans before we can have snippets like this. Currently, we really only have the |
|
100% agreed. Lints could expose In the long run, we'll eventually probably need to use the coarse spans available in rustdoc JSON as a guide for loading & parsing the affected Rust file, and then extracting more precise spans on-demand as needed. In the short run, I'm not sure what the best answer is. Maybe we can investigate adding |
|
I know this was blocked on not being able to have spans with perfect granularity, but are you still interested to try with the heuristic you mentioned and expose statusI (evidently) haven't had as much bandwidth as I would've liked to be able to contribute here, but I would like to do something. I've still been idly thinking about witness generation, and I think we need a fair bit of infrastructure to be able to generate correct code in every scenario, and I haven't had the time to work on that recently. I can write up my thoughts on what we'll need though. ...that is to say, if the CLI refactor is less of a priority, I can work on other things here if you'd like, but probably something smaller than witnesses for now. |
|
Thank you for staying on top of this and for continuing to contribute as much as you can — I really appreciate it! I'm a bit wary of starting complex refactors if it's unclear when they might be complete, since their intermediate states tend to be high-friction and high-maintenance. That said:
|
|
Also, if you're looking for "short-arc contributions" that advance the project's goals without requiring weeks of effort, I'm sure we have lots of low-hanging fruit that you have sufficient context to tackle. I'd be happy to suggest some if that'd be helpful! |





Opening this PR not to merge immediately (or even ever) but to show what we could do with
annotate-snippetsand get feedback on the CLI design (to be more rustc/clippy-like).Screenshots:
cargo semver-checks --baseline-root test_crates/function_const_removed/old --manifest-path test_crates/function_const_removed/new -Z unstable-options --witness-hintsold
new
when file is not available for span
on
manifest_tests/workspace_overridestest crate (warnings + errors)old
new
On compatibility with clippy/rustc:
This is mostly just a port of our current failure printing to use
annotate-snippets(and adding printing the one-line span snippet).clippy/rustclinters show generally less information per lint, and don't group instances of lints occurring by lint type. We group all lint results and print lots of info for each lint (description, ref link, info link) as well as per-result error info.sample clippy/rustc lints
I don't know if we actually want parity with
rustcin this regard, though.