]>
Commit | Line | Data |
---|---|---|
ba9703b0 XL |
1 | An `#[inline(..)]` attribute was incorrectly placed on something other than a |
2 | function or method. | |
60c5eb7d | 3 | |
ba9703b0 | 4 | Example of erroneous code: |
60c5eb7d XL |
5 | |
6 | ```compile_fail,E0518 | |
7 | #[inline(always)] | |
8 | struct Foo; | |
9 | ||
10 | #[inline(never)] | |
11 | impl Foo { | |
12 | // ... | |
13 | } | |
14 | ``` | |
15 | ||
16 | `#[inline]` hints the compiler whether or not to attempt to inline a method or | |
17 | function. By default, the compiler does a pretty good job of figuring this out | |
18 | itself, but if you feel the need for annotations, `#[inline(always)]` and | |
19 | `#[inline(never)]` can override or force the compiler's decision. | |
20 | ||
21 | If you wish to apply this attribute to all methods in an impl, manually annotate | |
22 | each method; it is not possible to annotate the entire impl with an `#[inline]` | |
23 | attribute. |