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