/src/tools/clippy/tests/ui/missing_inline.rs

https://gitlab.com/rust-lang/rust · Rust · 66 lines · 47 code · 12 blank · 7 comment · 2 complexity · 4a91c2db334881c992aa3df58b48a8ae MD5 · raw file

  1. #![warn(clippy::missing_inline_in_public_items)]
  2. #![crate_type = "dylib"]
  3. // When denying at the crate level, be sure to not get random warnings from the
  4. // injected intrinsics by the compiler.
  5. #![allow(dead_code, non_snake_case)]
  6. type Typedef = String;
  7. pub type PubTypedef = String;
  8. struct Foo; // ok
  9. pub struct PubFoo; // ok
  10. enum FooE {} // ok
  11. pub enum PubFooE {} // ok
  12. mod module {} // ok
  13. pub mod pub_module {} // ok
  14. fn foo() {}
  15. pub fn pub_foo() {} // missing #[inline]
  16. #[inline]
  17. pub fn pub_foo_inline() {} // ok
  18. #[inline(always)]
  19. pub fn pub_foo_inline_always() {} // ok
  20. #[allow(clippy::missing_inline_in_public_items)]
  21. pub fn pub_foo_no_inline() {}
  22. trait Bar {
  23. fn Bar_a(); // ok
  24. fn Bar_b() {} // ok
  25. }
  26. pub trait PubBar {
  27. fn PubBar_a(); // ok
  28. fn PubBar_b() {} // missing #[inline]
  29. #[inline]
  30. fn PubBar_c() {} // ok
  31. }
  32. // none of these need inline because Foo is not exported
  33. impl PubBar for Foo {
  34. fn PubBar_a() {} // ok
  35. fn PubBar_b() {} // ok
  36. fn PubBar_c() {} // ok
  37. }
  38. // all of these need inline because PubFoo is exported
  39. impl PubBar for PubFoo {
  40. fn PubBar_a() {} // missing #[inline]
  41. fn PubBar_b() {} // missing #[inline]
  42. fn PubBar_c() {} // missing #[inline]
  43. }
  44. // do not need inline because Foo is not exported
  45. impl Foo {
  46. fn FooImpl() {} // ok
  47. }
  48. // need inline because PubFoo is exported
  49. impl PubFoo {
  50. pub fn PubFooImpl() {} // missing #[inline]
  51. }
  52. // do not lint this since users cannot control the external code
  53. #[derive(Debug)]
  54. pub struct S;