Skip to content

#[inline] section could use additional details #349

Closed
@jonathanstrong

Description

@jonathanstrong

In trying to choose whether to use #[inline] on a function, I found the section in this book. However, here are several questions I had after reading it:

  • Does #[inline] apply to all implementations of a function defined by a trait, if the trait's declaration of that function is annotated?
  • Does #[inline] apply to an implementation of a trait function if the trait's declaration does not have an #[inline] annotation?
  • Will rustc ever inline a function from another crate without #[inline]?
  • Will rustc inline a function from another crate if it is annotated with #[inline]?
  • In what types of situations would incorrectly using this annotation cause programs to be slower? What makes those uses of inline slower? I'm guessing it's related to keeping the instruction size small and cache-friendly, but I don't know for sure.

I volunteer to write the answers to these questions in polished form for the book and submit a pull request if someone can answer the substance of them here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Language CleanupImprovements to existing language which is correct but not clear, or missing examples, or the like.New ContentMissing features or aspects of language not currently documented.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions