-
-
Notifications
You must be signed in to change notification settings - Fork 78
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
Draft: refactor cli with annotate-snippets
#939
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 |
Opening this PR not to merge immediately (or even ever) but to show what we could do with
annotate-snippets
and 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-hints
old
new
when file is not available for span
on
manifest_tests/workspace_overrides
test 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
/rustc
linters 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
rustc
in this regard, though.