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