Skip to content

Commit 5488672

Browse files
committed
account for external macro in MISSING_INLINE_IN_PUBLIC_ITEMS lint
1 parent e47ae20 commit 5488672

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

clippy_lints/src/missing_inline.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use crate::utils::span_lint;
22
use rustc::hir;
3-
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
3+
use rustc::lint::{self, LateContext, LateLintPass, LintArray, LintContext, LintPass};
44
use rustc::{declare_lint_pass, declare_tool_lint};
55
use syntax::ast;
66
use syntax::source_map::Span;
@@ -81,7 +81,7 @@ declare_lint_pass!(MissingInline => [MISSING_INLINE_IN_PUBLIC_ITEMS]);
8181

8282
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingInline {
8383
fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, it: &'tcx hir::Item) {
84-
if is_executable(cx) {
84+
if lint::in_external_macro(cx.sess(), it.span) || is_executable(cx) {
8585
return;
8686
}
8787

@@ -131,7 +131,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingInline {
131131

132132
fn check_impl_item(&mut self, cx: &LateContext<'a, 'tcx>, impl_item: &'tcx hir::ImplItem) {
133133
use rustc::ty::{ImplContainer, TraitContainer};
134-
if is_executable(cx) {
134+
if lint::in_external_macro(cx.sess(), impl_item.span) || is_executable(cx) {
135135
return;
136136
}
137137

tests/ui/missing_inline.rs

+4
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,7 @@ impl Foo {
6060
impl PubFoo {
6161
pub fn PubFooImpl() {} // missing #[inline]
6262
}
63+
64+
// do not lint this since users cannot control the external code
65+
#[derive(Debug)]
66+
pub struct S {}

0 commit comments

Comments
 (0)