Rename {enter,exit}_lint_attrs
to check_attributes{,_post}
This commit is contained in:
parent
47265adb1a
commit
733c7af87f
@ -143,13 +143,13 @@ fn parse_attr(sess: &Session, attrs: &[Attribute]) -> Option<RustcVersion> {
|
|||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn enter_lint_attrs(&mut self, sess: &Session, attrs: &[Attribute]) {
|
pub fn check_attributes(&mut self, sess: &Session, attrs: &[Attribute]) {
|
||||||
if let Some(version) = Self::parse_attr(sess, attrs) {
|
if let Some(version) = Self::parse_attr(sess, attrs) {
|
||||||
self.stack.push(version);
|
self.stack.push(version);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn exit_lint_attrs(&mut self, sess: &Session, attrs: &[Attribute]) {
|
pub fn check_attributes_post(&mut self, sess: &Session, attrs: &[Attribute]) {
|
||||||
if Self::parse_attr(sess, attrs).is_some() {
|
if Self::parse_attr(sess, attrs).is_some() {
|
||||||
self.stack.pop();
|
self.stack.pop();
|
||||||
}
|
}
|
||||||
|
@ -158,10 +158,10 @@ fn check_fn(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn enter_lint_attrs(&mut self, cx: &LateContext<'tcx>, attrs: &'tcx [Attribute]) {
|
fn check_attributes(&mut self, cx: &LateContext<'tcx>, attrs: &'tcx [Attribute]) {
|
||||||
self.limit.push_attrs(cx.sess(), attrs, "cognitive_complexity");
|
self.limit.push_attrs(cx.sess(), attrs, "cognitive_complexity");
|
||||||
}
|
}
|
||||||
fn exit_lint_attrs(&mut self, cx: &LateContext<'tcx>, attrs: &'tcx [Attribute]) {
|
fn check_attributes_post(&mut self, cx: &LateContext<'tcx>, attrs: &'tcx [Attribute]) {
|
||||||
self.limit.pop_attrs(cx.sess(), attrs, "cognitive_complexity");
|
self.limit.pop_attrs(cx.sess(), attrs, "cognitive_complexity");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -162,12 +162,12 @@ fn search_span(&self, cur_span: Span) -> Option<Span> {
|
|||||||
impl_lint_pass!(MissingDoc => [MISSING_DOCS_IN_PRIVATE_ITEMS]);
|
impl_lint_pass!(MissingDoc => [MISSING_DOCS_IN_PRIVATE_ITEMS]);
|
||||||
|
|
||||||
impl<'tcx> LateLintPass<'tcx> for MissingDoc {
|
impl<'tcx> LateLintPass<'tcx> for MissingDoc {
|
||||||
fn enter_lint_attrs(&mut self, _: &LateContext<'tcx>, attrs: &'tcx [ast::Attribute]) {
|
fn check_attributes(&mut self, _: &LateContext<'tcx>, attrs: &'tcx [ast::Attribute]) {
|
||||||
let doc_hidden = self.doc_hidden() || is_doc_hidden(attrs);
|
let doc_hidden = self.doc_hidden() || is_doc_hidden(attrs);
|
||||||
self.doc_hidden_stack.push(doc_hidden);
|
self.doc_hidden_stack.push(doc_hidden);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn exit_lint_attrs(&mut self, _: &LateContext<'tcx>, _: &'tcx [ast::Attribute]) {
|
fn check_attributes_post(&mut self, _: &LateContext<'tcx>, _: &'tcx [ast::Attribute]) {
|
||||||
self.doc_hidden_stack.pop().expect("empty doc_hidden_stack");
|
self.doc_hidden_stack.pop().expect("empty doc_hidden_stack");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ fn check_item(&mut self, cx: &LateContext<'_>, item: &hir::Item<'_>) {
|
|||||||
.filter(|t| matches!(t.unpack(), GenericArgKind::Type(_)))
|
.filter(|t| matches!(t.unpack(), GenericArgKind::Type(_)))
|
||||||
.any(|t| match_type(cx, t.expect_ty(), &paths::MSRV))
|
.any(|t| match_type(cx, t.expect_ty(), &paths::MSRV))
|
||||||
})
|
})
|
||||||
&& !items.iter().any(|item| item.ident.name == sym!(enter_lint_attrs))
|
&& !items.iter().any(|item| item.ident.name == sym!(check_attributes))
|
||||||
{
|
{
|
||||||
let context = if is_late_pass { "LateContext" } else { "EarlyContext" };
|
let context = if is_late_pass { "LateContext" } else { "EarlyContext" };
|
||||||
let lint_pass = if is_late_pass { "LateLintPass" } else { "EarlyLintPass" };
|
let lint_pass = if is_late_pass { "LateLintPass" } else { "EarlyLintPass" };
|
||||||
|
@ -131,14 +131,14 @@
|
|||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! extract_msrv_attr {
|
macro_rules! extract_msrv_attr {
|
||||||
($context:ident) => {
|
($context:ident) => {
|
||||||
fn enter_lint_attrs(&mut self, cx: &rustc_lint::$context<'_>, attrs: &[rustc_ast::ast::Attribute]) {
|
fn check_attributes(&mut self, cx: &rustc_lint::$context<'_>, attrs: &[rustc_ast::ast::Attribute]) {
|
||||||
let sess = rustc_lint::LintContext::sess(cx);
|
let sess = rustc_lint::LintContext::sess(cx);
|
||||||
self.msrv.enter_lint_attrs(sess, attrs);
|
self.msrv.check_attributes(sess, attrs);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn exit_lint_attrs(&mut self, cx: &rustc_lint::$context<'_>, attrs: &[rustc_ast::ast::Attribute]) {
|
fn check_attributes_post(&mut self, cx: &rustc_lint::$context<'_>, attrs: &[rustc_ast::ast::Attribute]) {
|
||||||
let sess = rustc_lint::LintContext::sess(cx);
|
let sess = rustc_lint::LintContext::sess(cx);
|
||||||
self.msrv.exit_lint_attrs(sess, attrs);
|
self.msrv.check_attributes_post(sess, attrs);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user