kennytm [Fri, 12 Oct 2018 14:04:07 +0000 (22:04 +0800)]
Rollup merge of #54891 - rust-lang:SimonSapin-patch-1, r=nagisa
Fix tracking issue for Once::is_completed
https://github.com/rust-lang/rust/pull/53027 was merged without a tracking issue. I just filed https://github.com/rust-lang/rust/issues/54890. CC @matklad
kennytm [Fri, 12 Oct 2018 14:04:04 +0000 (22:04 +0800)]
Rollup merge of #54860 - mandeep:vec-initialize, r=alexcrichton
Add doc comments about safest way to initialize a vector of zeros
This adds more information about the vec! macro as discussed in #54628. I think this is a good starting point, but I think additional detail is needed so that we can explain why vec! is safer than the alternatives.
kennytm [Fri, 12 Oct 2018 14:04:03 +0000 (22:04 +0800)]
Rollup merge of #54825 - davidtwco:issue-52663-deref-raw-pointer, r=pnkfelix
NLL says "borrowed content" instead of more precise "dereference of raw pointer"
Part of #52663.
Previously, move errors involving the dereference of a raw pointer would
say "borrowed content". This commit changes it to say "dereference of
raw pointer".
kennytm [Fri, 12 Oct 2018 14:04:01 +0000 (22:04 +0800)]
Rollup merge of #54811 - pnkfelix:issue-24840-separate-bootstrap-default-for-optimize-from-debug-setting, r=nikomatsakis
During rustc bootstrap, make default for `optimize` independent of `debug`
It may have taken me three and a half years, but I'm following through on my ["threat"](https://github.com/rust-lang/rust/issues/24840#issuecomment-97911700)
kennytm [Fri, 12 Oct 2018 14:04:00 +0000 (22:04 +0800)]
Rollup merge of #54755 - lucasloisp:document-reference-address-eq, r=QuietMisdreavus
Documents reference equality by address (#54197)
Clarification of the use of `ptr::eq` to test equality of references via address by pointer coercion, regarding issue #54197 .
The same example as in `ptr::eq` docs is shown here to clarify that
`PartialEq` compares values pointed-to instead of via address (which can be desired in some cases)
bors [Thu, 11 Oct 2018 19:38:15 +0000 (19:38 +0000)]
Auto merge of #54592 - GabrielMajeri:no-plt, r=nagisa
Support for disabling PLT for better function call performance
This PR gives `rustc` the ability to skip the PLT when generating function calls into shared libraries. This can improve performance by reducing branch indirection.
AFAIK, the only advantage of using the PLT is to allow for ELF lazy binding. However, since Rust already [enables full relro for security](https://github.com/rust-lang/rust/pull/43170), lazy binding was disabled anyway.
This is a little known feature which is supported by [GCC](https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html) and [Clang](https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-fplt) as `-fno-plt` (some Linux distros [enable it by default](https://git.archlinux.org/svntogit/packages.git/tree/trunk/makepkg.conf?h=packages/pacman#n40) for all builds).
Implementation inspired by [this patch](https://reviews.llvm.org/D39079#change-YvkpNDlMs_LT) which adds `-fno-plt` support to Clang.
## Performance
I didn't run a lot of benchmarks, but these are the results on my machine for a `clap` [benchmark](https://github.com/clap-rs/clap/blob/master/benches/05_ripgrep.rs):
```
name control ns/iter no-plt ns/iter diff ns/iter diff % speedup
build_app_long 11,097 10,733 -364 -3.28% x 1.03
build_app_short 11,089 10,742 -347 -3.13% x 1.03
build_help_long 186,835 182,713 -4,122 -2.21% x 1.02
build_help_short 80,949 78,455 -2,494 -3.08% x 1.03
parse_clean 12,385 12,044 -341 -2.75% x 1.03
parse_complex 19,438 19,017 -421 -2.17% x 1.02
parse_lots 431,493 421,421 -10,072 -2.33% x 1.02
```
A small performance improvement across the board, with no downsides. It's likely binaries which make a lot of function calls into dynamic libraries could see even more improvements. [This comment](https://patchwork.ozlabs.org/patch/468993/#1028255) suggests that, in some cases, `-fno-plt` could improve PIC/PIE code performance by 10%.
## Security benefits
**Bonus**: some of the speculative execution attacks rely on the PLT, by disabling it we reduce a big attack surface and reduce the need for [`retpoline`](https://reviews.llvm.org/D41723).
## Remaining PLT calls
The compiled binaries still have plenty of PLT calls, coming from C/C++ libraries. Building dependencies with `CFLAGS=-fno-plt CXXFLAGS=-fno-plt` removes them.
bors [Thu, 11 Oct 2018 09:19:23 +0000 (09:19 +0000)]
Auto merge of #54850 - mcr431:fix-54707-trait-function-from-macro, r=nikomatsakis
Fix #54707 - parse_trait_item_ now handles interpolated blocks as function body decls
Fix #54707 - parse_trait_item_ now handles interpolated blocks as function body decls
Previously parsing trait items only handled opening brace token and semicolon, I added a branch to the match statement that will also handle interpolated blocks.
bors [Wed, 10 Oct 2018 22:24:48 +0000 (22:24 +0000)]
Auto merge of #54747 - levex:inline-asm-bad-operands, r=nagisa
codegen_llvm: verify that inline assembly operands are scalars
Another set of inline assembly fixes. This time let's emit an error message when the operand value cannot be coerced into the operand constraint.
Two questions:
1) Should I reuse `E0668` which was introduced in #54568 or just use `E0669` as it stands because they do mean different things, but maybe that's not too user-friendly. Just a thought.
2) The `try_fold` returns the operand which failed to be converted into a scalar value, any suggestions on how to use that in the error message?
bors [Wed, 10 Oct 2018 12:13:03 +0000 (12:13 +0000)]
Auto merge of #54461 - RalfJung:pointer-provenance, r=oli-obk
miri engine: basic support for pointer provenance tracking
This enriches pointers with a new member, `tag`, that can be used to do provenance tracking. This is a new type parameter that propagates up through everything. It defaults to `()` (no tag), which is also the value used by CTFE -- but miri will use another type.
The only actually interesting piece here, I think, is what I had to do in the memory's `get`. The problem is that `tcx` (storing the allocations for statics) uses `()` for provenance information. But the machine might need another tag. The machine has a function to do the conversion, but if a conversion actually happened, we need to store the result of this *somewhere* -- we cannot return a pointer into `tcx` as we usually would.
So I introduced `MonoHashMap` which uses `RefCell` to be able to insert new entries even when we just have a shared ref. However, it is important that we can also return shared refs into the map without holding the `RefCell` opan. This is achieved by boxing the values stored in the map, so their addresses remain stable even when the map's table gets reallocated. This is all implemented in `mono_hash_map.rs`.
NOTE: This PR also contains the commits from https://github.com/rust-lang/rust/pull/54380#issuecomment-423130753. Only the [last two commits](https://github.com/rust-lang/rust/pull/54461/files/8e74ee0998a5b11f28d61600dbb881c7168a4a40..HEAD) are new.
bors [Wed, 10 Oct 2018 02:08:23 +0000 (02:08 +0000)]
Auto merge of #54764 - tromey:test-rust-lldb, r=alexcrichton
Run debuginfo tests against rust-enabled lldb, when possible
If the rust-enabled lldb was built, then use it when running the
debuginfo tests. Updating the lldb submodule was necessary as this
needed a way to differentiate the rust-enabled lldb, so I added a line
to the --version output.
This adds compiletest commands to differentiate between the
rust-enabled and non-rust-enabled lldb, as is already done for gdb. A
new "rust-lldb" header directive is also added, but not used in this
patch; I plan to use it in #54004.
bors [Tue, 9 Oct 2018 22:36:14 +0000 (22:36 +0000)]
Auto merge of #54734 - pawroman:fix_range_borrowing_suggestion, r=varkor
Fix range literals borrowing suggestions
Fixes #54505. The compiler issued incorrect range borrowing suggestions (missing `()` around borrows of range literals). This was not correct syntax (see the issue for an example).
With changes in this PR, this is fixed for all types of `Range` literals.
Thanks again to @varkor and @estebank for their invaluable help and guidance.
bors [Tue, 9 Oct 2018 17:19:56 +0000 (17:19 +0000)]
Auto merge of #54762 - RalfJung:miri-validate, r=oli-obk
Prepare miri engine for enforcing validity invariant during execution
In particular, make recursive checking of references optional, and add a `const_mode` parameter that says whether `usize` is allowed to contain a pointer. Also refactor validation a bit to be type-driven at the "leafs" (primitive types), and separately validate scalar layout to catch `NonNull` violations (which it did not properly validate before).
Fixes https://github.com/rust-lang/rust/issues/53826
Also fixes https://github.com/rust-lang/rust/issues/54751
David Wood [Thu, 4 Oct 2018 19:48:50 +0000 (21:48 +0200)]
Improve message for closure returning a closure.
Now when a `FnMut` closure is returning a closure that contains a
reference to a captured variable, we provide an error that makes it more
clear what is happening.
bors [Tue, 9 Oct 2018 07:22:14 +0000 (07:22 +0000)]
Auto merge of #54798 - matthewjasper:free-region-closure-errors, r=nikomatsakis
[NLL] Improve closure region bound errors
Previously, we would report free region errors that originate from closure with the span of the closure and a "closure body requires ..." message. This is now updated to use a reason and span from inside the closure.
Tom Tromey [Tue, 2 Oct 2018 16:13:30 +0000 (10:13 -0600)]
Run debuginfo tests against rust-enabled lldb, when possible
If the rust-enabled lldb was built, then use it when running the
debuginfo tests. Updating the lldb submodule was necessary as this
needed a way to differentiate the rust-enabled lldb, so I added a line
to the --version output.
This adds compiletest commands to differentiate between the
rust-enabled and non-rust-enabled lldb, as is already done for gdb. A
new "rust-lldb" header directive is also added, but not used in this
patch; I plan to use it in #54004.
Added text explaining the (new) relative roles of `optimize`+`debug`
and to briefly touch on the theory of debugging rustc versus the
practice of such.