The #[doc] attribute lets you control various aspects of how rustdoc does
its job.

The most basic function of #[doc] is to handle the actual documentation
text. That is, /// is syntax sugar for #[doc]. This means that these two
are the same:

/// This is a doc comment.
#[doc = " This is a doc comment."]

(Note the leading space in the attribute version.)

In most cases, /// is easier to use than #[doc]. One case where the latter is easier is
when generating documentation in macros; the collapse-docs pass will combine multiple
#[doc] attributes into a single doc comment, letting you generate code like this:

#[doc = "This is"]
#[doc = " a "]
#[doc = "doc comment"]

Which can feel more flexible. Note that this would generate this:

#[doc = "This is\n a \ndoc comment"]

but given that docs are rendered via Markdown, it will remove these newlines.

The doc attribute has more options though! These don't involve the text of
the output, but instead, various aspects of the presentation of the output.
We've split them into two kinds below: attributes that are useful at the
crate level, and ones that are useful at the item level.

This form of the doc attribute is mostly only useful for the standard library;
When a feature is unstable, an issue number for tracking the feature must be
given. rustdoc uses this number, plus the base URL given here, to link to
the tracking issue.

Here, because bar is not public, Bar wouldn't have its own page, so there's nowhere
to link to. rustdoc will inline these definitions, and so we end up in the same case
as the #[doc(inline)] above; Bar is in a Structs section, as if it were defined at
the top level. If we add the no_inline form of the attribute:

Since primitive types are defined in the compiler, there's no place to attach documentation
attributes. This attribute is used by the standard library to provide a way to generate
documentation for primitive types.