Guide: Puts the toc again in the doc

Closes #17505
Fix atomic::fence documentation typos
Fix panic due to overly long borrow of RefCell

Closes #18711
Add regression test for #18711
Derive Clone for TypeId.
Remove unnecessary `.to_string()`s from `Vec.swap_remove`'s doc example.
rustc: Process #[cfg]/#[cfg_attr] on crates

This commit implements processing these two attributes at the crate level as
well as at the item level. When #[cfg] is applied at the crate level, then the
entire crate will be omitted if the cfg doesn't match. The #[cfg_attr] attribute
is processed as usual in that the attribute is included or not depending on
whether the cfg matches.

This was spurred on by motivations of #18585 where #[cfg_attr] annotations will
be applied at the crate-level.

cc #18585
Implement len() for EnumSet.
auto merge of #18723 : mprobinson/rust/fence-typos, r=thestinger
libtime: alter strftime to use a TmFmt

The internals of strftime were converted to use a single formatter,
instead of creating and concatenating a bunch of small strings. This
showed ~3x improvement in the benches.

Also, since the formatted time may be going straight to a Writer, TmFmt
was introduced, and is returned from all formatting methods on Tm. This
allows the saving of another string allocation. Anyone wanting a String
can just call .to_string() on the returned value.

[breaking-change]
auto merge of #18724 : gamazeps/rust/toc, r=alexcrichton

Using @adrientetar advices

Closes #17505
auto merge of #18729 : bkoropoff/rust/issue-18711, r=cmr

Closes #18711
auto merge of #18556 : seanmonstar/rust/tm-fmt, r=alexcrichton

The internals of strftime were converted to use a single formatter,
instead of creating and concatenating a bunch of small strings. This
showed ~3x improvement in the benches.

Also, since the formatted time may be going straight to a Writer, TmFmt
was introduced, and is returned from all formatting methods on Tm. This
allows the saving of another string allocation. Anyone wanting a String
can just call .to_string() on the returned value.

This runs validation prior to return the created `TmFmt`, catching errors before formatting happens. The specialized formats skip this validation, since we already know they are valid.

[breaking-change]
auto merge of #18634 : alexcrichton/rust/cfg-attr-crate-level, r=sfackler

This commit implements processing these two attributes at the crate level as
well as at the item level. When #[cfg] is applied at the crate level, then the
entire crate will be omitted if the cfg doesn't match. The #[cfg_attr] attribute
is processed as usual in that the attribute is included or not depending on
whether the cfg matches.

This was spurred on by motivations of #18585 where #[cfg_attr] annotations will
be applied at the crate-level.

cc #18585
auto merge of #18731 : chris-morgan/rust/derive-Clone-for-TypeId, r=alexcrichton
auto merge of #18735 : utkarshkukreti/rust/remove-unnecessary-to_string-from-vec-docs, r=huonw

I don't think they're needed.
auto merge of #18740 : jbcrail/rust/implement-enum-set-len, r=alexcrichton

This commit adds the missing EnumSet method mentioned by @Gankro.

cc #18424
Basic structure of a declaration shadowing lint

This is a first attempt only, and does not cover all cases. The basic
idea is to use check_pat() method of LintPass to look up the given pat
in each enclosing scope.

The check_pat() method will need to eventually comply with Rust code
style and idioms.

check_pat() is also perhaps not the only method on LintPass that will be
needed for declaration shadowing detection to work.
simple test for decl. shadowing lint
A better attempt at shadow detection with Visitor

We define a Visitor which maintains a mapping of Names to
NodeIds. During analysis of Pats, if a Name is determined to exist in
the Visitor's mappings, we check if the pre-existing Name encloses the
current Name which indicates a shadow. We emit a lint and a span_note
describing the shadowed name and the locations of the shadowing names.