2018-07-28 15:34:52 +00:00
|
|
|
#![warn(clippy::missing_inline_in_public_items)]
|
2018-07-04 14:39:52 +00:00
|
|
|
#![crate_type = "dylib"]
|
2018-07-04 08:51:04 +00:00
|
|
|
// When denying at the crate level, be sure to not get random warnings from the
|
|
|
|
// injected intrinsics by the compiler.
|
|
|
|
#![allow(dead_code, non_snake_case)]
|
|
|
|
|
|
|
|
type Typedef = String;
|
|
|
|
pub type PubTypedef = String;
|
|
|
|
|
2022-03-27 12:41:09 +00:00
|
|
|
struct Foo; // ok
|
|
|
|
pub struct PubFoo; // ok
|
2018-07-04 08:51:04 +00:00
|
|
|
enum FooE {} // ok
|
|
|
|
pub enum PubFooE {} // ok
|
|
|
|
|
|
|
|
mod module {} // ok
|
|
|
|
pub mod pub_module {} // ok
|
|
|
|
|
|
|
|
fn foo() {}
|
2023-07-28 18:40:44 +00:00
|
|
|
// missing #[inline]
|
|
|
|
pub fn pub_foo() {}
|
2023-07-28 19:35:48 +00:00
|
|
|
//~^ ERROR: missing `#[inline]` for a function
|
|
|
|
//~| NOTE: `-D clippy::missing-inline-in-public-items` implied by `-D warnings`
|
2018-12-09 22:26:16 +00:00
|
|
|
#[inline]
|
|
|
|
pub fn pub_foo_inline() {} // ok
|
|
|
|
#[inline(always)]
|
|
|
|
pub fn pub_foo_inline_always() {} // ok
|
2018-07-04 08:51:04 +00:00
|
|
|
|
2018-07-28 15:34:52 +00:00
|
|
|
#[allow(clippy::missing_inline_in_public_items)]
|
2018-07-04 08:51:04 +00:00
|
|
|
pub fn pub_foo_no_inline() {}
|
|
|
|
|
|
|
|
trait Bar {
|
|
|
|
fn Bar_a(); // ok
|
|
|
|
fn Bar_b() {} // ok
|
|
|
|
}
|
|
|
|
|
|
|
|
pub trait PubBar {
|
|
|
|
fn PubBar_a(); // ok
|
2023-07-28 18:40:44 +00:00
|
|
|
// missing #[inline]
|
|
|
|
fn PubBar_b() {}
|
2023-07-28 19:35:48 +00:00
|
|
|
//~^ ERROR: missing `#[inline]` for a default trait method
|
2018-12-09 22:26:16 +00:00
|
|
|
#[inline]
|
|
|
|
fn PubBar_c() {} // ok
|
2018-07-04 08:51:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// none of these need inline because Foo is not exported
|
|
|
|
impl PubBar for Foo {
|
|
|
|
fn PubBar_a() {} // ok
|
|
|
|
fn PubBar_b() {} // ok
|
|
|
|
fn PubBar_c() {} // ok
|
|
|
|
}
|
|
|
|
|
|
|
|
// all of these need inline because PubFoo is exported
|
|
|
|
impl PubBar for PubFoo {
|
2023-07-28 18:40:44 +00:00
|
|
|
// missing #[inline]
|
|
|
|
fn PubBar_a() {}
|
2023-07-28 19:35:48 +00:00
|
|
|
//~^ ERROR: missing `#[inline]` for a method
|
2023-07-28 18:40:44 +00:00
|
|
|
// missing #[inline]
|
|
|
|
fn PubBar_b() {}
|
2023-07-28 19:35:48 +00:00
|
|
|
//~^ ERROR: missing `#[inline]` for a method
|
2023-07-28 18:40:44 +00:00
|
|
|
// missing #[inline]
|
|
|
|
fn PubBar_c() {}
|
2023-07-28 19:35:48 +00:00
|
|
|
//~^ ERROR: missing `#[inline]` for a method
|
2018-07-04 08:51:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// do not need inline because Foo is not exported
|
|
|
|
impl Foo {
|
|
|
|
fn FooImpl() {} // ok
|
|
|
|
}
|
|
|
|
|
|
|
|
// need inline because PubFoo is exported
|
|
|
|
impl PubFoo {
|
2023-07-28 18:40:44 +00:00
|
|
|
// missing #[inline]
|
|
|
|
pub fn PubFooImpl() {}
|
2023-07-28 19:35:48 +00:00
|
|
|
//~^ ERROR: missing `#[inline]` for a method
|
2018-07-04 08:51:04 +00:00
|
|
|
}
|
2019-12-01 12:26:33 +00:00
|
|
|
|
|
|
|
// do not lint this since users cannot control the external code
|
|
|
|
#[derive(Debug)]
|
2022-03-27 12:41:09 +00:00
|
|
|
pub struct S;
|