]> git.lizzy.rs Git - rust.git/blob - tests/ui/missing_inline.rs
Merge pull request #3285 from devonhollowood/pedantic-dogfood-items-after-statements
[rust.git] / tests / ui / missing_inline.rs
1 // Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution.
3 //
4 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
5 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
6 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
7 // option. This file may not be copied, modified, or distributed
8 // except according to those terms.
9
10
11 #![feature(tool_lints)]
12
13 /* This file incorporates work covered by the following copyright and
14  * permission notice:
15  *   Copyright 2013 The Rust Project Developers. See the COPYRIGHT
16  *   file at the top-level directory of this distribution and at
17  *   http://rust-lang.org/COPYRIGHT.
18  *
19  *   Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
20  *   http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
21  *   <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
22  *   option. This file may not be copied, modified, or distributed
23  *   except according to those terms.
24  */
25 #![warn(clippy::missing_inline_in_public_items)]
26 #![crate_type = "dylib"]
27 // When denying at the crate level, be sure to not get random warnings from the
28 // injected intrinsics by the compiler.
29 #![allow(dead_code, non_snake_case)]
30
31 type Typedef = String;
32 pub type PubTypedef = String;
33
34 struct Foo {} // ok
35 pub struct PubFoo { } // ok
36 enum FooE {} // ok
37 pub enum PubFooE {} // ok
38
39 mod module {} // ok
40 pub mod pub_module {} // ok
41
42 fn foo() {}
43 pub fn pub_foo() {} // missing #[inline]
44 #[inline] pub fn pub_foo_inline() {} // ok
45 #[inline(always)] pub fn pub_foo_inline_always() {} // ok
46
47 #[allow(clippy::missing_inline_in_public_items)]
48 pub fn pub_foo_no_inline() {}
49
50 trait Bar {
51     fn Bar_a(); // ok
52     fn Bar_b() {} // ok
53 }
54
55
56 pub trait PubBar {
57     fn PubBar_a(); // ok
58     fn PubBar_b() {} // missing #[inline]
59     #[inline] fn PubBar_c() {} // ok
60 }
61
62 // none of these need inline because Foo is not exported
63 impl PubBar for Foo {
64     fn PubBar_a() {} // ok
65     fn PubBar_b() {} // ok
66     fn PubBar_c() {} // ok
67 }
68
69 // all of these need inline because PubFoo is exported
70 impl PubBar for PubFoo {
71     fn PubBar_a() {} // missing #[inline]
72     fn PubBar_b() {} // missing #[inline]
73     fn PubBar_c() {} // missing #[inline]
74 }
75
76 // do not need inline because Foo is not exported
77 impl Foo {
78     fn FooImpl() {} // ok
79 }
80
81 // need inline because PubFoo is exported
82 impl PubFoo {
83     pub fn PubFooImpl() {} // missing #[inline]
84 }