Skip to content

Commit

Permalink
Auto merge of #4870 - lzutao:check-macro-missing_inline_in_public_ite…
Browse files Browse the repository at this point in the history
…ms, r=flip1995

account for external macro in MISSING_INLINE_IN_PUBLIC_ITEMS lint

Closes #4861
changelog: Fix FP (external macro) in [`missing_inline_in_public_items`] lint
  • Loading branch information
bors committed Dec 1, 2019
2 parents e47ae20 + 5488672 commit 5a75502
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 3 additions & 3 deletions clippy_lints/src/missing_inline.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::utils::span_lint;
use rustc::hir;
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
use rustc::lint::{self, LateContext, LateLintPass, LintArray, LintContext, LintPass};
use rustc::{declare_lint_pass, declare_tool_lint};
use syntax::ast;
use syntax::source_map::Span;
Expand Down Expand Up @@ -81,7 +81,7 @@ declare_lint_pass!(MissingInline => [MISSING_INLINE_IN_PUBLIC_ITEMS]);

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

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

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

Expand Down
4 changes: 4 additions & 0 deletions tests/ui/missing_inline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,7 @@ impl Foo {
impl PubFoo {
pub fn PubFooImpl() {} // missing #[inline]
}

// do not lint this since users cannot control the external code
#[derive(Debug)]
pub struct S {}

0 comments on commit 5a75502

Please sign in to comment.