Commit Graph

76969 Commits

Author SHA1 Message Date
bors 186db76159 Auto merge of #49664 - alexcrichton:stable-simd, r=BurntSushi
Stabilize x86/x86_64 SIMD

This commit stabilizes the SIMD in Rust for the x86/x86_64 platforms. Notably
this commit is stabilizing:

* The `std::arch::{x86, x86_64}` modules and the intrinsics contained inside.
* The `is_x86_feature_detected!` macro in the standard library
* The `#[target_feature(enable = "...")]` attribute
* The `#[cfg(target_feature = "...")]` matcher

Stabilization of the module and intrinsics were primarily done in
rust-lang-nursery/stdsimd#414 and the two attribute stabilizations are done in
this commit. The standard library is also tweaked a bit with the new way that
stdsimd is integrated.

Note that other architectures like `std::arch::arm` are not stabilized as part
of this commit, they will likely stabilize in the future after they've been
implemented and fleshed out. Similarly the `std::simd` module is also not being
stabilized in this commit, only `std::arch`. Finally, nothing related to `__m64`
is stabilized in this commit either (MMX), only SSE and up types and intrinsics
are stabilized.

Closes #29717
Closes #44839
Closes #48556
2018-04-17 03:57:22 +00:00
bors 94516c5038 Auto merge of #50012 - Zoxc:msvc-fix, r=Mark-Simulacrum
Don't look for cc/cxx when testing with bogus targets

This fixes test builds on Windows.

r? @Mark-Simulacrum
2018-04-17 01:41:43 +00:00
John Kåre Alsaker 52e1c84732 Don't look for cc/cxx when testing with bogus targets 2018-04-17 01:59:00 +02:00
bors 3809bbf47c Auto merge of #49488 - alexcrichton:small-wasm-panic, r=sfackler
std: Minimize size of panicking on wasm

This commit applies a few code size optimizations for the wasm target to
the standard library, namely around panics. We notably know that in most
configurations it's impossible for us to print anything in
wasm32-unknown-unknown so we can skip larger portions of panicking that
are otherwise simply informative. This allows us to get quite a nice
size reduction.

Finally we can also tweak where the allocation happens for the
`Box<Any>` that we panic with. By only allocating once unwinding starts
we can reduce the size of a panicking wasm module from 44k to 350 bytes.
2018-04-16 23:19:41 +00:00
Alex Crichton 1217d70465 Separately gate each target_feature feature
Use an explicit whitelist for what features are actually stable and can be
enabled.
2018-04-16 13:58:42 -07:00
bors 4a3ab8b234 Auto merge of #50003 - kennytm:rollup, r=kennytm
Rollup of 8 pull requests

Successful merges:

 - #49555 (Inline most of the code paths for conversions with boxed slices)
 - #49606 (Prevent broken pipes causing ICEs)
 - #49646 (Use box syntax instead of Box::new in Mutex::remutex on Windows)
 - #49647 (Remove `underscore_lifetimes` and `match_default_bindings` from active feature list)
 - #49931 (Fix incorrect span in `&mut` suggestion)
 - #49959 (rustbuild: allow building tools with debuginfo)
 - #49965 (Remove warning about f64->f32 cast being potential UB)
 - #49994 (Remove unnecessary indentation in rustdoc book codeblock.)

Failed merges:
2018-04-16 20:35:57 +00:00
kennytm bf16e4bc54
Rollup merge of #49647 - kennytm:duplicated-features, r=aturon
Remove `underscore_lifetimes` and `match_default_bindings` from active feature list

These are already stabilized in 1.26.
2018-04-17 03:34:55 +08:00
kennytm 932431ceda
Rollup merge of #49994 - frewsxcv:frewsxcv-doc-tests, r=QuietMisdreavus
Remove unnecessary indentation in rustdoc book codeblock.

None
2018-04-17 03:34:34 +08:00
kennytm 87cd53e63f
Rollup merge of #49965 - nikic:fix-49622, r=rkruppe
Remove warning about f64->f32 cast being potential UB

As discussed in #15536, the LLVM documentation incorrect described overflowing f64->f32 casts as being undefined behavior. LLVM never treated them as such, and the documentation has been adjusted in https://reviews.llvm.org/rL329065. As such, this warning can now be removed.

Closes #49622.

---

I could not find any existing test checking for this warning. Should I be adding a test for the absence of the warning instead?
2018-04-17 03:34:33 +08:00
kennytm 34ee31d6f2
Rollup merge of #49959 - cuviper:debuginfo-tools, r=Mark-Simulacrum
rustbuild: allow building tools with debuginfo

Debugging information for the extended tools is currently disabled for
concerns about the size.  This patch adds `--enable-debuginfo-tools` to
let one opt into having that debuginfo.

This is useful for debugging the tools in distro packages.  We always
strip debuginfo into separate packages anyway, so the extra size is not
a concern in regular use.
2018-04-17 03:34:31 +08:00
kennytm 73ea8939ee
Rollup merge of #49931 - csmoe:end_span, r=estebank
Fix incorrect span in `&mut` suggestion

Fixes #49859
2018-04-17 03:34:30 +08:00
kennytm 6c3e1d7555
Remove `underscore_lifetimes` and `match_default_bindings` from active feature list
These are already stabilized in 1.26.
2018-04-17 03:28:25 +08:00
kennytm e4991b2f48
Rollup merge of #49646 - glandium:uninitialized-box, r=alexcrichton
Use box syntax instead of Box::new in Mutex::remutex on Windows

The Box::new(mem::uninitialized()) pattern actually actively copies
uninitialized bytes from the stack into the box, which is a waste of
time. Using the box syntax instead avoids the useless copy.
2018-04-17 01:50:59 +08:00
kennytm ccd2c403ac
Rollup merge of #49606 - varkor:pipe-repair, r=alexcrichton
Prevent broken pipes causing ICEs

As the private `std::io::print_to` panics if there is an I/O error, which is used by `println!`, the compiler would ICE if one attempted to use a broken pipe (e.g. `rustc --help | false`). This introduces a new (private) macro `try_println!` which allows us to avoid this.

As a side note, it seems this macro might be useful publicly (and actually there seems to be [a crate specifically for this purpose](https://crates.io/crates/try_print/)), though that can probably be left for a future discussion.

One slight alternative approach would be to simply early exit without an error (i.e. exit code `0`), which [this comment](https://github.com/rust-lang/rust/issues/34376#issuecomment-377822526) suggests is the usual approach. I've opted not to take that approach initially, because I think it's more helpful to know when there is a broken pipe.

Fixes #34376.
2018-04-17 01:50:58 +08:00
kennytm bf60295211
Rollup merge of #49555 - nox:inline-into-boxed, r=alexcrichton
Inline most of the code paths for conversions with boxed slices

This helps with the specific problem described in #49541, obviously without making any large change to how inlining works in the general case.

Everything involved in the conversions is made `#[inline]`, except for the `<Vec<T>>::into_boxed_slice` entry point which is made `#[inline(always)]` after checking that duplicating the function mentioned in the issue prevented its inlining if I only annotate it with
`#[inline]`.

For the record, that function was:

```rust
pub fn foo() -> Box<[u8]> {
    vec![0].into_boxed_slice()
}
```

To help the inliner's job, we also hoist a `self.capacity() != self.len` check in `<Vec<T>>::shrink_to_fit` and mark it as `#[inline]` too.
2018-04-17 01:50:56 +08:00
bors 49317cd511 Auto merge of #49130 - smmalis37:range, r=alexcrichton
Move Range*::contains to a single default impl on RangeBounds

Per the ongoing discussion in #32311.

This is my first PR to Rust (woo!), so I don't know if this requires an amendment to the original range_contains RFC, or not, or if we can just do a psuedo-RFC here. While this may no longer follow the explicit decision made in that RFC, I believe this better follows its spirit by adding the new contains method to all Ranges. It also allows users to be generic over all ranges and use this method without writing it themselves (my personal desired use case).

This also somewhat answers the unanswered question about Wrapping ranges in the above issue by instead just punting it to the question of what those types should return for start() & end(), or if they should implement RangeArgument at all. Those types could also implement their own contains method without implementing this trait, in which case the question remains the same.

This does add a new contains method to types that already implemented RangeArgument but not contains. These types are RangeFull, (Bound<T>, Bound<T>), (Bound<&'a T>, Bound<&'a T>). No tests have been added for these types yet. No inherent method has been added either.

r? @alexcrichton
2018-04-16 16:07:10 +00:00
Alex Crichton 598d836fff Stabilize x86/x86_64 SIMD
This commit stabilizes the SIMD in Rust for the x86/x86_64 platforms. Notably
this commit is stabilizing:

* The `std::arch::{x86, x86_64}` modules and the intrinsics contained inside.
* The `is_x86_feature_detected!` macro in the standard library
* The `#[target_feature(enable = "...")]` attribute
* The `#[cfg(target_feature = "...")]` matcher

Stabilization of the module and intrinsics were primarily done in
rust-lang-nursery/stdsimd#414 and the two attribute stabilizations are done in
this commit. The standard library is also tweaked a bit with the new way that
stdsimd is integrated.

Note that other architectures like `std::arch::arm` are not stabilized as part
of this commit, they will likely stabilize in the future after they've been
implemented and fleshed out. Similarly the `std::simd` module is also not being
stabilized in this commit, only `std::arch`. Finally, nothing related to `__m64`
is stabilized in this commit either (MMX), only SSE and up types and intrinsics
are stabilized.

Closes #29717
Closes #44839
Closes #48556
2018-04-16 07:25:10 -07:00
bors 1ef1563518 Auto merge of #48945 - clarcharr:iter_exhaust, r=Kimundi
Replace manual iterator exhaust with for_each(drop)

This originally added a dedicated method, `Iterator::exhaust`, and has since been replaced with `for_each(drop)`, which is more idiomatic.

<del>This is just shorthand for `for _ in &mut self {}` or `while let Some(_) = self.next() {}`. This states the intent a lot more clearly than the identical code: run the iterator to completion.

<del>At least personally, my eyes tend to gloss over `for _ in &mut self {}` without fully paying attention to what it does; having a `Drop` implementation akin to:

<del>`for _ in &mut self {}; unsafe { free(self.ptr); }`</del>

<del>Is not as clear as:

<del>`self.exhaust(); unsafe { free(self.ptr); }`

<del>Additionally, I've seen debate over whether `while let Some(_) = self.next() {}` or `for _ in &mut self {}` is more clear, whereas `self.exhaust()` is clearer than both.
2018-04-16 13:21:56 +00:00
bors d6a2dd9912 Auto merge of #49433 - varkor:metadata-skip-mir-opt, r=michaelwoerister
Skip MIR encoding for cargo check

Resolves #48662.

r? @michaelwoerister
2018-04-16 10:30:57 +00:00
bors 532764cb79 Auto merge of #49963 - llogiq:stabilize-13226, r=kennytm
stabilize fetch_nand

This closes #13226 and makes `Atomic*.fetch_nand` stable.
2018-04-16 07:44:25 +00:00
Corey Farwell afa22d63d7 Remove unnecessary indentation in rustdoc book codeblock. 2018-04-16 16:25:57 +09:00
bors 3e70dfd655 Auto merge of #49956 - QuietMisdreavus:rustdoc-codegen, r=GuillaumeGomez
rustdoc: port the -C option from rustc

Blocked on https://github.com/rust-lang/rust/pull/49864. The included test won't work without those changes, so this PR includes those commits as well.

When documenting items that require certain target features, it helps to be able to force those target features into existence. Rather than include a flag just to parse those features, i instead decided to port the `-C` flag from rustc in its entirety. It takes the same parameters, because it runs through the same parsing function. This has the added benefit of being able to control the codegen of doctests as well.

One concern i have with the flag is that i set it to stable here. My rationale is that it is a direct port of functionality on rustc that is currently stable, used only in mechanisms that it is originally used for. If needed, i can set it back to be unstable.
2018-04-16 05:00:14 +00:00
bors 748c549185 Auto merge of #49847 - sinkuu:save_analysis_implicit_extern, r=petrochenkov
Fix save-analysis generation with extern_in_paths/extern_absolute_paths

Fixes #48742.
2018-04-16 02:34:32 +00:00
bors d6ba1b9b02 Auto merge of #49719 - mark-i-m:no_sep, r=petrochenkov
Update `?` repetition disambiguation.

**Do not merge** (yet)

This is a test implementation of some ideas from discussion in https://github.com/rust-lang/rust/issues/48075 . This PR
- disallows `?` repetition from taking a separator, since the separator is never used.
- disallows the use of `?` as a separator. This allows patterns like `$(a)?+` to match `+` and `a+` rather than `a?a?a`. This is a _breaking change_, but maybe that's ok? Perhaps a crater run is the right approach?

cc @durka @alexreg @nikomatsakis
2018-04-16 00:06:10 +00:00
bors 8de5353f75 Auto merge of #49947 - oli-obk:turing_complete_const_eval, r=nagisa
Don't abort const eval due to long running evals, just warn

one check-box of #49930

r? @nagisa (https://github.com/rust-lang/rfcs/pull/2344#issuecomment-368246665)
2018-04-15 21:18:37 +00:00
Shotaro Yamada c3dc014378 Check generated save-analysis, instead of `bug!()`ing
Injected crates don't have extern info. Let's skip them.
2018-04-15 21:41:28 +09:00
bors 7360d6dd67 Auto merge of #49833 - oli-obk:incremental_miri_regression, r=michaelwoerister
Don't recurse into allocations, use a global table instead

r? @michaelwoerister

fixes #49663
2018-04-15 12:32:13 +00:00
Oliver Schneider 907df8c0f7
Add a tracking issue for making the warning a lint 2018-04-15 13:28:15 +02:00
bors 602b3957f1 Auto merge of #49885 - spastorino:fn_ref_unsound, r=nikomatsakis
Fix unsoundness bug in functions input references

Fixes #48803

r? @nikomatsakis
2018-04-15 09:14:43 +00:00
Anthony Ramine b59fa0d9e8 Remove #[inline(always)] on Vec::into_boxed_slice 2018-04-15 10:34:57 +02:00
bors 56109dbf70 Auto merge of #49884 - alexcrichton:less-unwrap, r=Mark-Simulacrum
core: Remove panics from some `Layout` methods

`Layout` is often used at the core of allocation APIs and is as a result pretty
sensitive to codegen in various circumstances. I was profiling `-C opt-level=z`
with a wasm project recently and noticed that the `unwrap()` wasn't removed
inside of `Layout`, causing the program to be much larger than it otherwise
would be. If inlining were more aggressive LLVM would have figured out that the
panic could be eliminated, but in general the methods here can't panic in the
first place!

As a result this commit makes the following tweaks:

* Removes `unwrap()` and replaces it with `unsafe` in `Layout::new` and
  `Layout::for_value`. For posterity though a debug assertion was left behind.
* Removes an `unwrap()` in favor of `?` in the `repeat` method. The comment
  indicating that the function call couldn't panic wasn't quite right in that if
  `alloc_size` becomes too large and if `align` is high enough it could indeed
  cause a panic.

This'll hopefully mean that panics never get introduced into code in the first
place, ensuring that `opt-level=z` is closer to `opt-level=s` in this regard.
2018-04-15 06:33:48 +00:00
bors bc001fa07f Auto merge of #49881 - varkor:partialord-opt, r=Manishearth
Fix derive(PartialOrd) and optimise final field operation

```rust
// Before (`lt` on 2-field struct)
self.f1 < other.f1 || (!(other.f1 < self.f1) &&
(self.f2 < other.f2 || (!(other.f2 < self.f2) &&
(false)
))
)

// After
self.f1 < other.f1 || (!(other.f1 < self.f1) &&
self.f2 < other.f2
)

// Before (`le` on 2-field struct)
self.f1 < other.f1 || (!(other.f1 < self.f1) &&
(self.f2 < other.f2 || (!(other.f2 < self.f2) &&
(true)
))
)

// After
self.f1 < other.f1 || (self.f1 == other.f1 &&
self.f2 <= other.f2
)
```

(The big diff is mainly because of a past faulty rustfmt application that I corrected 😒)

Fixes #49650 and fixes #49505.
2018-04-15 03:54:15 +00:00
bors d4d43e2483 Auto merge of #48173 - GuillaumeGomez:error-codes-libsyntax_ext, r=estebank
Add error codes for libsyntax_ext

I intend to add error codes for `libsyntax_ext` as well. However, they cannot be used at stage 0 directly so I thought it might be possible to enable them at the stage 1 only so we can have access to the macros. However, the error code registration seems to not work this way. Currently I get the following error:

```
error: used diagnostic code E0660 not registered
  --> libsyntax_ext/asm.rs:93:25
   |
93 |                         span_err!(cx, sp, E0660, "malformed inline assembly");
   |                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)

error: used diagnostic code E0661 not registered
   --> libsyntax_ext/asm.rs:151:33
    |
151 | /                                 span_err!(cx, sp, E0661,
152 | |                                           "output operand constraint lacks '=' or '+'");
    | |________________________________________________________________________________________^
    |
    = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)

error: aborting due to 2 previous errors

error: Could not compile `syntax_ext`.
```

If anyone has an idea, I'd gladly take it. I'm trying to figure this out on my side as well. I also opened this PR to know if it was worth it to continue (maybe we don't want this?).

Anyway, any answer for both questions is very welcome!

cc @rust-lang/compiler
2018-04-15 01:26:11 +00:00
bors bd40cbbe1f Auto merge of #49850 - alexcrichton:moreinline, r=sfackler
core: Inline `From<AllocErr> for CollectionAllocErr`

This shows up in allocations of vectors and such, so no need for it to not be
inlined!
2018-04-14 20:22:19 +00:00
Guillaume Gomez f367567e06 ignore stage1 testing 2018-04-14 18:04:16 +02:00
Guillaume Gomez 5d52ef5091 Add tests and longer error explanation 2018-04-14 17:25:35 +02:00
Guillaume Gomez 44c686113f Add error codes for libsyntax_ext 2018-04-14 17:25:35 +02:00
Nikita Popov cbabb1be32 Remove warning about f64->f32 cast being potential UB
As discussed in #15536, the LLVM documentation incorrect described
overflowing f64->f32 casts as being undefined behavior. LLVM never
treated them as such, and the documentation has been adjusted in
https://reviews.llvm.org/rL329065. As such, this warning can now
be removed.

Closes #49622.
2018-04-14 16:21:46 +02:00
Andre Bogus c68c90a232 stabilize fetch_nand 2018-04-14 15:51:31 +02:00
bors 21dae950be Auto merge of #49939 - kennytm:rollup, r=kennytm
Rollup of 14 pull requests

Successful merges: #49908, #49876, #49916, #49951, #49465, #49922, #49866, #49915, #49886, #49913, #49852, #49958, #49871, #49864

Failed merges:
2018-04-14 13:11:24 +00:00
kennytm 0e9d6f9bb0
Rollup merge of #49864 - QuietMisdreavus:doctest-target-features, r=GuillaumeGomez
add target features when extracting and running doctests

When rendering documentation, rustdoc will happily load target features into the cfg environment from the current target, but fails to do this when doing anything with doctests. This would lead to situations where, thanks to https://github.com/rust-lang/rust/pull/48759, functions tagged with `#[target_feature]` couldn't run doctests, thanks to the automatic `#[doc(cfg(target_feature = "..."))]`.

Currently, there's no way to pass codegen options to rustdoc that will affect its rustc sessions, but for now this will let you use target features that come default on the platform you're targeting.

Fixes https://github.com/rust-lang/rust/issues/49723
2018-04-14 18:50:41 +08:00
kennytm 709ec4010d
Rollup merge of #49871 - SimonSapin:int-bytes, r=sfackler
Add to_bytes and from_bytes to primitive integers

Discussion issue turned tracking issue: https://github.com/rust-lang/rust/issues/49792
2018-04-14 18:49:58 +08:00
kennytm 9659f052a4
Rollup merge of #49958 - glandium:cleanup, r=SimonSapin
Cleanup liballoc use statements

Some modules were still using the deprecated `allocator` module, use the
`alloc` module instead.

Some modules were using `super` while it's not needed.

Some modules were more or less ordering them, and other not, so the
latter have been modified to match the others.
2018-04-14 18:48:09 +08:00
Simon Sapin 447299130a Add to_bytes and from_bytes to primitive integers 2018-04-14 12:31:22 +02:00
bors cfc3465b9d Auto merge of #49289 - varkor:emit-metadata-without-link, r=michaelwoerister
Make --emit=metadata output metadata regardless of link

Fixes #40109. I'm not sure whether this condition was important here or not, but I can't see why it is required (removing it doesn't cause the error the comment warns about, so I'm assuming it's safe). If this is too heavy-handed, I can special-case on `OutputType::Metadata`.

r? @nrc
2018-04-14 10:27:03 +00:00
Oliver Schneider 7f7d4c376a
Get rid of redundant `HashSet` 2018-04-14 12:22:10 +02:00
Oliver Schneider 748e71e8f4
Reduce the number of calls to `cdata` 2018-04-14 12:21:46 +02:00
Oliver Schneider 04b3ab67d9
Encode items before encoding the list of AllocIds 2018-04-14 12:21:46 +02:00
Oliver Schneider 6f251c2a03
Use `LazySeq` instead of `Vec` 2018-04-14 12:21:46 +02:00
Oliver Schneider 62c0501be8
Stop referring to statics' AllocIds directly 2018-04-14 12:21:46 +02:00