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