Skip to content

Commit dbcd74e

Browse files
authored
Rollup merge of #136657 - jdonszelmann:empty-line-after, r=y21,flip1995,WaffleLapkin
Make empty-line-after an early clippy lint r? ```@y21``` 95% a refiling of rust-lang/rust-clippy#13658 but for correctness it needed 2 extra methods in `rust_lint` which made it much easier to apply on `rust-lang/rust` than `rust-lang/rust-clippy`. Commits have been thoroughly reviewed on `rust-lang/clippy already`. The last two review comments there (about using `Option` and popping for assoc items have been applied here.
2 parents 2d87a07 + cd52a95 commit dbcd74e

17 files changed

+621
-472
lines changed

compiler/rustc_lint/src/early.rs

+8
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,14 @@ impl<'ast, 'ecx, 'tcx, T: EarlyLintPass> ast_visit::Visitor<'ast>
246246
}
247247
}
248248
ast_visit::walk_assoc_item(cx, item, ctxt);
249+
match ctxt {
250+
ast_visit::AssocCtxt::Trait => {
251+
lint_callback!(cx, check_trait_item_post, item);
252+
}
253+
ast_visit::AssocCtxt::Impl => {
254+
lint_callback!(cx, check_impl_item_post, item);
255+
}
256+
}
249257
});
250258
}
251259

compiler/rustc_lint/src/passes.rs

+2
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,9 @@ macro_rules! early_lint_methods {
162162
c: rustc_span::Span,
163163
d_: rustc_ast::NodeId);
164164
fn check_trait_item(a: &rustc_ast::AssocItem);
165+
fn check_trait_item_post(a: &rustc_ast::AssocItem);
165166
fn check_impl_item(a: &rustc_ast::AssocItem);
167+
fn check_impl_item_post(a: &rustc_ast::AssocItem);
166168
fn check_variant(a: &rustc_ast::Variant);
167169
fn check_attribute(a: &rustc_ast::Attribute);
168170
fn check_attributes(a: &[rustc_ast::Attribute]);

src/tools/clippy/clippy_lints/src/declared_lints.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,6 @@ pub static LINTS: &[&crate::LintInfo] = &[
144144
crate::doc::DOC_NESTED_REFDEFS_INFO,
145145
crate::doc::DOC_OVERINDENTED_LIST_ITEMS_INFO,
146146
crate::doc::EMPTY_DOCS_INFO,
147-
crate::doc::EMPTY_LINE_AFTER_DOC_COMMENTS_INFO,
148-
crate::doc::EMPTY_LINE_AFTER_OUTER_ATTR_INFO,
149147
crate::doc::MISSING_ERRORS_DOC_INFO,
150148
crate::doc::MISSING_PANICS_DOC_INFO,
151149
crate::doc::MISSING_SAFETY_DOC_INFO,
@@ -162,6 +160,8 @@ pub static LINTS: &[&crate::LintInfo] = &[
162160
crate::else_if_without_else::ELSE_IF_WITHOUT_ELSE_INFO,
163161
crate::empty_drop::EMPTY_DROP_INFO,
164162
crate::empty_enum::EMPTY_ENUM_INFO,
163+
crate::empty_line_after::EMPTY_LINE_AFTER_DOC_COMMENTS_INFO,
164+
crate::empty_line_after::EMPTY_LINE_AFTER_OUTER_ATTR_INFO,
165165
crate::empty_with_brackets::EMPTY_ENUM_VARIANTS_WITH_BRACKETS_INFO,
166166
crate::empty_with_brackets::EMPTY_STRUCTS_WITH_BRACKETS_INFO,
167167
crate::endian_bytes::BIG_ENDIAN_BYTES_INFO,

src/tools/clippy/clippy_lints/src/doc/empty_line_after.rs

-345
This file was deleted.

0 commit comments

Comments
 (0)