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