Skip to content

Commit 3fec3b4

Browse files
committed
refactor function
1 parent 14cbdf2 commit 3fec3b4

File tree

1 file changed

+14
-16
lines changed

1 file changed

+14
-16
lines changed

clippy_lints/src/missing_inline.rs

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -67,19 +67,17 @@ declare_clippy_lint! {
6767

6868
pub struct MissingInline;
6969

70-
impl MissingInline {
71-
fn check_missing_inline_attrs(&self, cx: &LateContext,
72-
attrs: &[ast::Attribute], sp: Span, desc: &'static str) {
73-
let has_inline = attrs
74-
.iter()
75-
.any(|a| a.name() == "inline" );
76-
if !has_inline {
77-
cx.span_lint(
78-
MISSING_INLINE_IN_PUBLIC_ITEMS,
79-
sp,
80-
&format!("missing `#[inline]` for {}", desc),
81-
);
82-
}
70+
fn check_missing_inline_attrs(cx: &LateContext,
71+
attrs: &[ast::Attribute], sp: Span, desc: &'static str) {
72+
let has_inline = attrs
73+
.iter()
74+
.any(|a| a.name() == "inline" );
75+
if !has_inline {
76+
cx.span_lint(
77+
MISSING_INLINE_IN_PUBLIC_ITEMS,
78+
sp,
79+
&format!("missing `#[inline]` for {}", desc),
80+
);
8381
}
8482
}
8583

@@ -112,7 +110,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingInline {
112110
match it.node {
113111
hir::ItemFn(..) => {
114112
let desc = "a function";
115-
self.check_missing_inline_attrs(cx, &it.attrs, it.span, desc);
113+
check_missing_inline_attrs(cx, &it.attrs, it.span, desc);
116114
},
117115
hir::ItemTrait(ref _is_auto, ref _unsafe, ref _generics,
118116
ref _bounds, ref trait_items) => {
@@ -129,7 +127,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingInline {
129127
// an impl is not provided
130128
let desc = "a default trait method";
131129
let item = cx.tcx.hir.expect_trait_item(tit.id.node_id);
132-
self.check_missing_inline_attrs(cx, &item.attrs,
130+
check_missing_inline_attrs(cx, &item.attrs,
133131
item.span, desc);
134132
}
135133
},
@@ -195,6 +193,6 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingInline {
195193
},
196194
}
197195

198-
self.check_missing_inline_attrs(cx, &impl_item.attrs, impl_item.span, desc);
196+
check_missing_inline_attrs(cx, &impl_item.attrs, impl_item.span, desc);
199197
}
200198
}

0 commit comments

Comments
 (0)