Issue #9629 -- permit freezing `&mut` found within an `&` pointer
Add defun motions for rust-mode.

Specifically, we can now use:
+ beginning-of-defun
+ end-of-defun
+ mark-defun

where "defun" means a Rust item.

+ Add tests in rust-mode-tests.el
+ Fix indentation in rust-mode-tests.el
+ Add support for trait to Imenu
Extend allocation lint for boxing expressions
auto merge of #10881 : sanxiyn/rust/allocation-lint-2, r=alexcrichton
Store metadata separately in rlib files

Right now whenever an rlib file is linked against, all of the metadata from the
rlib is pulled in to the final staticlib or binary. The reason for this is that
the metadata is currently stored in a section of the object file. Note that this
is intentional for dynamic libraries in order to distribute metadata bundled
with static libraries.

This commit alters the situation for rlib libraries to instead store the
metadata in a separate file in the archive. In doing so, when the archive is
passed to the linker, none of the metadata will get pulled into the result
executable. Furthermore, the metadata file is skipped when assembling rlibs into
an archive.

The snag in this implementation comes with multiple output formats. When
generating a dylib, the metadata needs to be in the object file, but when
generating an rlib this needs to be separate. In order to accomplish this, the
metadata variable is inserted into an entirely separate LLVM Module which is
then codegen'd into a different location (foo.metadata.o). This is then linked
into dynamic libraries and silently ignored for rlib files.

While changing how metadata is inserted into archives, I have also stopped
compressing metadata when inserted into rlib files. We have wanted to stop
compressing metadata, but the sections it creates in object file sections are
apparently too large. Thankfully if it's just an arbitrary file it doesn't
matter how large it is.

I have seen massive reductions in executable sizes, as well as staticlib output
sizes (to confirm that this is all working).
Add missing .com
Implement PortReader and ChanWriter
Address nits for PR for #9629
Make main pub in test case (cc #9629)
auto merge of #10823 : rapha/rust/master, r=alexcrichton

Hi, first pull request here so let me know if I've missed any of the procedure.
Implement LTO

This commit implements LTO for rust leveraging LLVM's passes. What this means
is:

* When compiling an rlib, in addition to insdering foo.o into the archive, also
  insert foo.bc (the LLVM bytecode) of the optimized module.

* When the compiler detects the -Z lto option, it will attempt to perform LTO on
  a staticlib or binary output. The compiler will emit an error if a dylib or
  rlib output is being generated.

* The actual act of performing LTO is as follows:

    1. Force all upstream libraries to have an rlib version available.
    2. Load the bytecode of each upstream library from the rlib.
    3. Link all this bytecode into the current LLVM module (just using llvm
       apis)
    4. Run an internalization pass which internalizes all symbols except those
       found reachable for the local crate of compilation.
    5. Run the LLVM LTO pass manager over this entire module

    6a. If assembling an archive, then add all upstream rlibs into the output
        archive. This ignores all of the object/bitcode/metadata files rust
        generated and placed inside the rlibs.
    6b. If linking a binary, create copies of all upstream rlibs, remove the
        rust-generated object-file, and then link everything as usual.

As I have explained in #10741, this process is excruciatingly slow, so this is
*not* turned on by default, and it is also why I have decided to hide it behind
a -Z flag for now. The good news is that the binary sizes are about as small as
they can be as a result of LTO, so it's definitely working.

Closes #10741
Closes #10740
Register new snapshots

Makes the `dead_code` lint a citizen of stage0 to silence the "unknown lint"
warnings.
auto merge of #10812 : alexcrichton/rust/lto, r=pcwalton

The first commit was approved from another pull request, but I wanted to rebase LTO on top of it.

LTO is not turned on by default at all, and it's hidden behind a `-Z` flag. I have added a few small tests for it, however.
Fix up float highlighting in Vim.

This fixes a regression introduced in #10793.

Having a colorscheme which highlights Float the same as Number (I
believe most do), I hadn't noticed that having the special case of "5."
floats (which was one of the added features in #10793) last made it take
precedence, and so it was left to @thestinger to notice it.

The regression meant that in `5.0`, the `5.` was a `rustFloat` (linked
by default to `Float`) and the `0` was a `rustDecNumber` (linked by
default to `Number`), and for `5.0f32` the `5.` was a `rustFloat` and
the `0f32` was a second `rustFloat` (and thus appeared correctly, though
for the wrong reason).
Vim keyword highlighting improvements.

- Removed the `log` keyword;
- Removed keyword duplicates;
- Highlighted `const` as `Error` rather than `StorageClass`; and
- Highlighted all the reserved keywords as `Error` rather than as
  `Keyword`.

(As usual, these highlightings can be overridden if desired.)
auto merge of #10873 : pradeep90/rust/rust-mode-changes, r=pcwalton

Specifically, we can now use:
+ beginning-of-defun
+ end-of-defun
+ mark-defun

where "defun" means a Rust item.

+ Add tests in rust-mode-tests.el
+ Fix indentation in rust-mode-tests.el
+ Add support for trait to Imenu
Add some more commentary to FFI tutorial.

Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
Check the privacy of implemented traits

This bug showed up because the visitor only visited the path of the implemented
trait via walk_path (with no corresponding visit_path function). I have modified
the visitor to use visit_path (which is now overridable), and the privacy
visitor overrides this function and now properly checks for the privacy of all
paths.

Closes #10857
auto merge of #10862 : alexcrichton/rust/issue-10857, r=huonw

This bug showed up because the visitor only visited the path of the implemented
trait via walk_path (with no corresponding visit_path function). I have modified
the visitor to use visit_path (which is now overridable), and the privacy
visitor overrides this function and now properly checks for the privacy of all
paths.

Closes #10857
auto merge of #10822 : ezyang/rust/master, r=huonw

Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>