Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

account for external macro in MISSING_INLINE_IN_PUBLIC_ITEMS lint #4870

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 {}