Rollup merge of #59351 - phil-opp:llvm-ar, r=alexcrichton
Include llvm-ar with llvm-tools component
Adds the `llvm-ar` tool to the `llvm-tools` component. This is useful for [building and linking native code](https://doc.rust-lang.org/cargo/reference/build-scripts.html#case-study-building-some-native-code) in cargo build scripts without needing to use the platform specific `ar`. According to #58663 it is also useful for WASM.
`llvm-ar` is very small (~82KB), so it does not significantly increase the size of the `llvm-tools` component.
Rollup merge of #58803 - haraldh:fs_copy_fix, r=alexcrichton
fs::copy() unix: set file mode early
A convenience method like fs::copy() should try to prevent pitfalls a
normal user doesn't think about.
In case of an empty umask, setting the file mode early prevents
temporarily world readable or even writeable files,
because the default mode is 0o666.
In case the target is a named pipe or special device node, setting the
file mode can lead to unwanted side effects, like setting permissons on
`/dev/stdout` or for root setting permissions on `/dev/null`.
copy_file_range() returns EINVAL, if the destination is a FIFO/pipe or
a device like "/dev/null", so fallback to io::copy, too.
Josh Stone [Thu, 28 Mar 2019 01:15:42 +0000 (18:15 -0700)]
Rollup merge of #59459 - JohnTitor:add-tests, r=Centril
Add some tests
close #52977
It seems that there are no tests for this issue, so I opened this PR.
off-topic: I noticed [this test](https://github.com/rust-lang/rust/blob/master/src/test/ui/existential_types/nested_existential_types.rs)'s indents are bad, could I include commit to fix this, or should I separate?
Josh Stone [Thu, 28 Mar 2019 01:15:41 +0000 (18:15 -0700)]
Rollup merge of #59451 - TimDiekmann:patch-1, r=sfackler
Add `Default` to `std::alloc::System`
`System` is a unit struct, thus, it can be constructed without any additional information. Therefore `Default` is a noop. However, in generic code, a `T: Default` may happen as in
```rust
#[derive(Default)]
struct Foo<A> {
allocator: A
}
```
Does this need a feature gate?
Should I also add `PartialEq/Eq/PartialOrd/Ord/Hash`?
Josh Stone [Thu, 28 Mar 2019 01:15:38 +0000 (18:15 -0700)]
Rollup merge of #59439 - Centril:generalize-assign-to-bool-diagnostic, r=oli-obk
Generalize diagnostic for `x = y` where `bool` is the expected type
Extracted out of https://github.com/rust-lang/rust/pull/59288.
Currently we special case a diagnostic for `if x = y { ...` since the expected type is `bool` in this case and we instead suggest `if x == y`. This PR generalizes this such that given an expression of form `x = y` (`ExprKind::Assign(..)`) where the expected type is `bool`, we emit a suggestion `x == y`.
r? @oli-obk
Let's do a perf run to make sure this was not the source of regressions in #59288.
Josh Stone [Thu, 28 Mar 2019 01:15:33 +0000 (18:15 -0700)]
Rollup merge of #59420 - cuviper:ci-image-info, r=alexcrichton
[CI] record docker image info for reuse
This writes an extra `dist/image-$image.txt` which contains the S3 URL
of the cached image and the `sha256` digest of the docker entry point.
This will be uploaded with the rest of the deployed artifacts in the
Travis `after_success` script.
Josh Stone [Thu, 28 Mar 2019 01:15:25 +0000 (18:15 -0700)]
Rollup merge of #59283 - SimonSapin:branchless-ascii-case, r=joshtriplett
Make ASCII case conversions more than 4× faster
Reformatted output of `./x.py bench src/libcore --test-args ascii` below. The `libcore` benchmark calls `[u8]::make_ascii_lowercase`. `lookup` has code (effectively) identical to that before this PR, and ~~`branchless`~~ `mask_shifted_bool_match_range` after this PR.
~~See [code comments](https://github.com/rust-lang/rust/pull/59283/commits/ce933f77c865a15670855ac5941fe200752b739f#diff-01076f91a26400b2db49663d787c2576R3796) in `u8::to_ascii_uppercase` in `src/libcore/num/mod.rs` for an explanation of the branchless algorithm.~~
**Update:** the algorithm was simplified while keeping the performance. See `branchless` v.s. `mask_shifted_bool_match_range` benchmarks.
Credits to @raphlinus for the idea in https://twitter.com/raphlinus/status/1107654782544736261, which extends this algorithm to “fake SIMD” on `u32` to convert four bytes at a time. The `fake_simd_u32` benchmarks implements this with [`let (before, aligned, after) = bytes.align_to_mut::<u32>()`](https://doc.rust-lang.org/std/primitive.slice.html#method.align_to_mut). Note however that this is buggy when addition carries/overflows into the next byte (which does not happen if the input is known to be ASCII).
This could be fixed (to optimize `[u8]::make_ascii_lowercase` and `[u8]::make_ascii_uppercase` in `src/libcore/slice/mod.rs`) either with some more bitwise trickery that I didn’t quite figure out, or by using “real” SIMD intrinsics for byte-wise addition. I did not pursue this however because the current (incorrect) fake SIMD algorithm is only marginally faster than the one-byte-at-a-time branchless algorithm. This is because LLVM auto-vectorizes the latter, as can be seen on https://rust.godbolt.org/z/anKtbR.
Benchmark results on Linux x64 with Intel i7-7700K: (updated from https://github.com/rust-lang/rust/pull/59283#issuecomment-474146863)
Josh Stone [Thu, 28 Mar 2019 01:15:19 +0000 (18:15 -0700)]
Rollup merge of #57565 - petrochenkov:turbowarn, r=Centril
syntax: Remove warning for unnecessary path disambiguators
`rustfmt` is now stable and it removes unnecessary turbofishes, so removing the warning as discussed in https://github.com/rust-lang/rust/pull/43540 (where it was introduced).
One hardcoded warning less.
bors [Wed, 27 Mar 2019 13:20:16 +0000 (13:20 +0000)]
Auto merge of #59415 - varkor:values_since_snapshot, r=eddyb
Refactor InferenceFudger (née RegionFudger)
- Rename `RegionFudger` (and related methods) to `InferenceFudger`.
- Take integer and float inference variables into account.
- Refactor `types_created_since_snapshot` and `vars_created_since_snapshot` with the [new version of ena](https://github.com/rust-lang-nursery/ena/pull/21).
- Some other refactoring in the area.
bors [Wed, 27 Mar 2019 08:58:40 +0000 (08:58 +0000)]
Auto merge of #55780 - ogoffart:span_source_text, r=petrochenkov
Introduce proc_macro::Span::source_text
A function to extract the actual source behind a Span.
Background: I would like to use `syn` in a `build.rs` script to parse the rust code, and extract part of the source code. However, `syn` only gives access to proc_macro2::Span, and i would like to get the source code behind that.
I opened an issue on proc_macro2 bug tracker for this feature https://github.com/alexcrichton/proc-macro2/issues/110 and @alexcrichton said the feature should first go upstream in proc_macro. So there it is!
Since most of the Span API is unstable anyway, this is guarded by the same `proc_macro_span` feature as everything else.
bors [Wed, 27 Mar 2019 05:25:50 +0000 (05:25 +0000)]
Auto merge of #59447 - GuillaumeGomez:rollup, r=GuillaumeGomez
Rollup of 7 pull requests
Successful merges:
- #59004 ([rustdoc] Improve "in parameters" search and search more generally)
- #59026 (Fix moving text in search tabs headers)
- #59197 (Exclude old book redirect stubs from search engines)
- #59330 (Improve the documentation for std::convert (From, Into, AsRef and AsMut))
- #59424 (Fix code block display in portability element in dark theme)
- #59427 (Link to PhantomData in NonNull documentation)
- #59432 (Improve some compiletest documentation)
Guillaume Gomez [Tue, 26 Mar 2019 21:26:42 +0000 (22:26 +0100)]
Rollup merge of #59330 - DevQps:improve-std-convert-documentation, r=steveklabnik
Improve the documentation for std::convert (From, Into, AsRef and AsMut)
# Description
In this PR I updated the documentation of From, Into, AsRef and AsMut, as well as the general std::convert module documentation. The discussion in #59163 provided information that was not yet present in the docs, or was not expressed clearly enough. I tried to clarify the examples that were already present in the docs as well as add more information about considered best-practices that came out of the discussion in #59163
@steveklabnik I hope I didn't change too much. This is an initial version! I will scan through everything tomorrow as well again to see if I made any typo's or errors, and maybe make some small changes here and there.
bors [Tue, 26 Mar 2019 13:58:30 +0000 (13:58 +0000)]
Auto merge of #59434 - Centril:bootstrap-to-2019-03-20, r=Mark-Simulacrum
Bump bootstrap compiler to 2019-03-20
Includes https://github.com/rust-lang/rust/pull/59295 and by extension https://github.com/rust-lang/rust/pull/59047, which unblocks https://github.com/rust-lang/rust/pull/58253, https://github.com/rust-lang/rust/pull/58837, and possibly https://github.com/rust-lang/rust/pull/59336, and so therefore:
Rollup merge of #59374 - faern:simplify-checked-duration-since, r=shepmaster
Simplify checked_duration_since
This follows the same design as we updated to in #56490. Internally, all the system specific time implementations are checked, no panics. Then the panicking publicly exported API can just call the checked version of itself and make do with a single panic (`expect`) at the top.
Since the internal sys implementations are now checked, this gets rid of the extra `if self >= &earlier` check in `checked_duration_since`. Except likely making the generated machine code simpler, it also reduces the algorithm from "Check panic condition -> call possibly panicking method" to just "call non panicking method".
Added two test cases:
* Edge case: Make sure `checked_duration_since` on two equal `Instant`s produce a zero duration, not a `None`.
* Most common/intended usage: Make sure `later.checked_duration_since(earlier)`, returns an expected value.
Rollup merge of #59362 - pnkfelix:demo-from-iterator-short-circuiting, r=Centril
Demo `FromIterator` short-circuiting
while looking at a FIXME in `FromIterator for Option` and `FromIterator for Result`, I realized that the current documentation does not have example code showing exactly what is meant by "no further elements are taken."
The code snippets provided here are meant to correct that.
Josh Stone [Mon, 25 Mar 2019 22:27:49 +0000 (15:27 -0700)]
[CI] record docker image info for reuse
This writes an extra `dist/image-$image.txt` which contains the S3 URL
of the cached image and the `sha256` digest of the docker entry point.
This will be uploaded with the rest of the deployed artifacts in the
Travis `after_success` script.