-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Convert EMPTY_LINE_AFTER_OUTER_ATTR
and EMPTY_LINE_AFTER_OUTER_ATTR
lint into early lints
#13658
base: master
Are you sure you want to change the base?
Convert EMPTY_LINE_AFTER_OUTER_ATTR
and EMPTY_LINE_AFTER_OUTER_ATTR
lint into early lints
#13658
Conversation
b7f66a1
to
0f8ba1c
Compare
yayyy |
@@ -690,7 +611,7 @@ fn check_attrs(cx: &LateContext<'_>, valid_idents: &FxHashSet<String>, attrs: &[ | |||
Some(("fake".into(), "fake".into())) | |||
} | |||
|
|||
if suspicious_doc_comments::check(cx, attrs) || empty_line_after::check(cx, attrs) || is_doc_hidden(attrs) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It said this check was to avoid spurious warnings somewhere, but we don't do it anymore. Is that a problem?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I ran cargo uibless
so I think it's ok if nothing new got picked up. To be confirmed by someone more knowledgeable though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's intended for e.g. #12917
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So what should we do here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It may cause some confusion but if attrs are being reworked it's something we could live without unless we want to add another early -> late storage hack
clippy_lints/src/empty_line_after.rs
Outdated
impl Stop { | ||
fn convert_to_inner(&self) -> (Span, String) { | ||
let inner = match self.kind { | ||
// #|[...] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick, but this should be #!
not #|
I think
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah indeed!
@@ -5,7 +5,7 @@ LL | / /// for the crate | |||
LL | | | |||
| |_ | |||
LL | fn first_in_crate() {} | |||
| ------------------- the comment documents this function | |||
| ---------------------- the comment documents this function |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this now points to the entire function, while previously it pointed to the signature of the function. That'd mean that if the function is longer than 0 lines it'd also highlight the block. Do we want that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I supposed it was fine but I can try to see if it can be shortened somehow.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -71,8 +74,11 @@ error: empty line after outer attribute | |||
LL | / #[repr(C)] | |||
LL | | | |||
| |_ | |||
LL | struct Foo { | |||
| ---------- the attribute applies to this struct | |||
LL | / struct Foo { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here I guess, you can see it better here
5a15864
to
7089e72
Compare
…R` lint into early lints
7089e72
to
1f9ccc2
Compare
much better |
Is there a link to why this is needed? |
So as part of rust-lang/compiler-team#796, I bumped into a few issues with clippy where some lints are late, but use a lot of information that mostly relates to the AST, and have very little reason to interact with the hir. After lowering, clippy is the only part of the compiler using information such as the AttrId, AttrStyle and Span on attributes. By moving these lints to be early:
Hope that clears some things up :) |
for 2), that might mean that at some point in the future I will revisit these lints and make them use the new attribute parsing logic. By making them early, they can enjoy the old parsing logic for a little longer while the new parsing logic can be implemented without having to fix clippy at the same time as introducing a large refactoring in the compiler. |
Lintcheck diff is quite big and some of them look like FPs. Now I'm even more concerned that rust-lang/rust#132598 might've introduced FPs... We will see tomorrow, once I can do the sync. |
A lot of them are because of message changes, like: 8 | macro_rules! test_for_each_provider {
- | ----------------------------------- the comment documents this macro
+ | ----------------------------------- the comment documents this macro definition or of span changes like: 51 | struct FlatMapConsumer<'f, C, F> {
- | -------------------------------- the comment documents this struct
+ | ---------------------- the comment documents this struct For changes like: Added clippy::doc_lazy_continuation at [url-2.5.2/src/lib.rs:379](https://docs.rs/url/2.5.2/src/url/lib.rs.html#379)
```
warning: doc list item without indentation
--> target/lintcheck/sources/url-2.5.2/src/lib.rs:379:9
|
379 | /// Without it, the last path component is considered to be a “file” name
| ^
|
= help: if this is supposed to be its own paragraph, add a blank line
= note: `--force-warn clippy::doc-lazy-continuation` implied by `--force-warn clippy::all`
help: indent this line
|
379 | /// Without it, the last path component is considered to be a “file” name
| ++
``` are because of what was discussed here. In short: since it's not part of the doc lints anymore (one of the 3 that was triggering an early return), some more lints are emitted. It's not incorrect but will generate more warnings. |
Just went through all of them: There's actually only 1 FP and I'm not sure if it is related to this PR:
In chrono-0.4.38/src/month.rs:191. Might be because of the double backticks in the 3rd line. But the span is then wrong. |
That seems like a bug into another lint that might have been uncovered by this PR. |
☔ The latest upstream changes (presumably 8298da7) made this pull request unmergeable. Please resolve the merge conflicts. |
This is needed to help the compiler attributes API rewrite.
cc @jdonszelmann @xFrednet
changelog: Convert
EMPTY_LINE_AFTER_OUTER_ATTR
andEMPTY_LINE_AFTER_OUTER_ATTR
lint into early lints