account for external macro in MISSING_INLINE_IN_PUBLIC_ITEMS lint

This commit is contained in:
Lzu Tao 2019-12-01 19:26:33 +07:00
parent e47ae20b5b
commit 5488672d1f
2 changed files with 7 additions and 3 deletions

View File

@ -1,6 +1,6 @@
use crate::utils::span_lint; use crate::utils::span_lint;
use rustc::hir; 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 rustc::{declare_lint_pass, declare_tool_lint};
use syntax::ast; use syntax::ast;
use syntax::source_map::Span; use syntax::source_map::Span;
@ -81,7 +81,7 @@ declare_lint_pass!(MissingInline => [MISSING_INLINE_IN_PUBLIC_ITEMS]);
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingInline { impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingInline {
fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, it: &'tcx hir::Item) { 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; return;
} }
@ -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) { fn check_impl_item(&mut self, cx: &LateContext<'a, 'tcx>, impl_item: &'tcx hir::ImplItem) {
use rustc::ty::{ImplContainer, TraitContainer}; use rustc::ty::{ImplContainer, TraitContainer};
if is_executable(cx) { if lint::in_external_macro(cx.sess(), impl_item.span) || is_executable(cx) {
return; return;
} }

View File

@ -60,3 +60,7 @@ impl Foo {
impl PubFoo { impl PubFoo {
pub fn PubFooImpl() {} // missing #[inline] pub fn PubFooImpl() {} // missing #[inline]
} }
// do not lint this since users cannot control the external code
#[derive(Debug)]
pub struct S {}