Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mention that #[cold] and #[inline] work on closures #469

Merged
merged 1 commit into from
Dec 1, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 7 additions & 12 deletions src/attributes.md
Original file line number Diff line number Diff line change
Expand Up @@ -499,17 +499,17 @@ The `cold` and `inline` attributes give suggestions to the compiler to compile
your code in a way that may be faster than what it would do without the hint.
The attributes are only suggestions, and the compiler may choose to ignore it.

Both attributes can be used on closures, [functions] and function prototypes,
although they do not do anything on function prototypes. When applied to a
function in a [trait], they apply only to that function when used as a default
function for a trait implementation and not to all trait implementations.

#### `inline` Attribute

The *`inline` attribute* suggests to the compiler that it should place a copy of
the attributed function in the caller, rather than generating code to call the
function where it is defined.

This attribute can be used on [functions] and function prototypes, although it
does not do anything on function prototypes. When this attribute is applied to
a function in a [trait], it applies only to that function when used as a default
function for a trait implementation and not to all trait implementations.

> ***Note***: The compiler automatically inlines functions based on internal
> heuristics. Incorrectly inlining functions can actually make the program
> slower, so this attribute should be used with care.
Expand All @@ -522,13 +522,8 @@ There are three ways of using the inline attribute:

#### `cold` Attribute

The *`cold` attribute* suggests to the compiler that the attributed function is
unlikely to be called.

This attribute can be used on [functions] and function prototypes, although it
does not do anything on function prototypes. When this attribute is applied to
a function in a [trait], it applies only to that function when used as a default
function for a trait implementation and not to all trait implementations.
The *`cold` attribute* suggests to the compiler that the attributed function or
closure is unlikely to be called.

### `derive`

Expand Down