]> git.lizzy.rs Git - rust.git/log
rust.git
6 years agoOnly emit save-analysis data for `cargo build` tasks
Nick Cameron [Tue, 17 Apr 2018 09:31:33 +0000 (21:31 +1200)]
Only emit save-analysis data for `cargo build` tasks

Previously, we were emittinng analysis data for all tasks, including `doc`. That meant we got two sets of save-analysis data, one from the normal build and one from the docs. That means indexing with the RLS took twice as long and made downloads larger and build times longer.

cc https://github.com/rust-lang-nursery/rls/issues/826

6 years agoAuto merge of #49882 - Zoxc:sync-misc2, r=michaelwoerister
bors [Tue, 17 Apr 2018 06:46:31 +0000 (06:46 +0000)]
Auto merge of #49882 - Zoxc:sync-misc2, r=michaelwoerister

More thread-safety changes

r? @michaelwoerister

6 years agoAuto merge of #49664 - alexcrichton:stable-simd, r=BurntSushi
bors [Tue, 17 Apr 2018 03:57:22 +0000 (03:57 +0000)]
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

6 years agoAuto merge of #50012 - Zoxc:msvc-fix, r=Mark-Simulacrum
bors [Tue, 17 Apr 2018 01:41:43 +0000 (01:41 +0000)]
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

6 years agoDon't look for cc/cxx when testing with bogus targets
John Kåre Alsaker [Mon, 16 Apr 2018 23:59:00 +0000 (01:59 +0200)]
Don't look for cc/cxx when testing with bogus targets

6 years agoAuto merge of #49488 - alexcrichton:small-wasm-panic, r=sfackler
bors [Mon, 16 Apr 2018 23:19:41 +0000 (23:19 +0000)]
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.

6 years agoSeparately gate each target_feature feature
Alex Crichton [Thu, 5 Apr 2018 15:02:11 +0000 (08:02 -0700)]
Separately gate each target_feature feature

Use an explicit whitelist for what features are actually stable and can be
enabled.

6 years agoAuto merge of #50003 - kennytm:rollup, r=kennytm
bors [Mon, 16 Apr 2018 20:35:57 +0000 (20:35 +0000)]
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:

6 years agoRollup merge of #49647 - kennytm:duplicated-features, r=aturon
kennytm [Mon, 16 Apr 2018 19:34:55 +0000 (03:34 +0800)]
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.

6 years agoRollup merge of #49994 - frewsxcv:frewsxcv-doc-tests, r=QuietMisdreavus
kennytm [Mon, 16 Apr 2018 17:51:05 +0000 (01:51 +0800)]
Rollup merge of #49994 - frewsxcv:frewsxcv-doc-tests, r=QuietMisdreavus

Remove unnecessary indentation in rustdoc book codeblock.

None

6 years agoRollup merge of #49965 - nikic:fix-49622, r=rkruppe
kennytm [Mon, 16 Apr 2018 17:51:04 +0000 (01:51 +0800)]
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?

6 years agoRollup merge of #49959 - cuviper:debuginfo-tools, r=Mark-Simulacrum
kennytm [Mon, 16 Apr 2018 17:51:02 +0000 (01:51 +0800)]
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.

6 years agoRollup merge of #49931 - csmoe:end_span, r=estebank
kennytm [Mon, 16 Apr 2018 17:51:01 +0000 (01:51 +0800)]
Rollup merge of #49931 - csmoe:end_span, r=estebank

Fix incorrect span in `&mut` suggestion

Fixes #49859

6 years agoRemove `underscore_lifetimes` and `match_default_bindings` from active feature list
kennytm [Wed, 4 Apr 2018 10:43:00 +0000 (18:43 +0800)]
Remove `underscore_lifetimes` and `match_default_bindings` from active feature list

These are already stabilized in 1.26.

6 years agoRollup merge of #49646 - glandium:uninitialized-box, r=alexcrichton
kennytm [Mon, 16 Apr 2018 17:50:59 +0000 (01:50 +0800)]
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.

6 years agoRollup merge of #49606 - varkor:pipe-repair, r=alexcrichton
kennytm [Mon, 16 Apr 2018 17:50:58 +0000 (01:50 +0800)]
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.

6 years agoRollup merge of #49555 - nox:inline-into-boxed, r=alexcrichton
kennytm [Mon, 16 Apr 2018 17:50:56 +0000 (01:50 +0800)]
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.

6 years agoAuto merge of #49130 - smmalis37:range, r=alexcrichton
bors [Mon, 16 Apr 2018 16:07:10 +0000 (16:07 +0000)]
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

6 years agoStabilize x86/x86_64 SIMD
Alex Crichton [Tue, 3 Apr 2018 18:11:49 +0000 (11:11 -0700)]
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

6 years agoAuto merge of #48945 - clarcharr:iter_exhaust, r=Kimundi
bors [Mon, 16 Apr 2018 13:21:56 +0000 (13:21 +0000)]
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.

6 years agoAuto merge of #49433 - varkor:metadata-skip-mir-opt, r=michaelwoerister
bors [Mon, 16 Apr 2018 10:30:57 +0000 (10:30 +0000)]
Auto merge of #49433 - varkor:metadata-skip-mir-opt, r=michaelwoerister

Skip MIR encoding for cargo check

Resolves #48662.

r? @michaelwoerister

6 years agoAuto merge of #49963 - llogiq:stabilize-13226, r=kennytm
bors [Mon, 16 Apr 2018 07:44:25 +0000 (07:44 +0000)]
Auto merge of #49963 - llogiq:stabilize-13226, r=kennytm

stabilize fetch_nand

This closes #13226 and makes `Atomic*.fetch_nand` stable.

6 years agoRemove unnecessary indentation in rustdoc book codeblock.
Corey Farwell [Mon, 16 Apr 2018 07:25:57 +0000 (16:25 +0900)]
Remove unnecessary indentation in rustdoc book codeblock.

6 years agoAuto merge of #49956 - QuietMisdreavus:rustdoc-codegen, r=GuillaumeGomez
bors [Mon, 16 Apr 2018 05:00:14 +0000 (05:00 +0000)]
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.

6 years agoAuto merge of #49847 - sinkuu:save_analysis_implicit_extern, r=petrochenkov
bors [Mon, 16 Apr 2018 02:34:32 +0000 (02:34 +0000)]
Auto merge of #49847 - sinkuu:save_analysis_implicit_extern, r=petrochenkov

Fix save-analysis generation with extern_in_paths/extern_absolute_paths

Fixes #48742.

6 years agoUse locks for Session.lint_store and Session.buffered_lints
John Kåre Alsaker [Fri, 13 Apr 2018 17:33:31 +0000 (19:33 +0200)]
Use locks for Session.lint_store and Session.buffered_lints

6 years agoAuto merge of #49719 - mark-i-m:no_sep, r=petrochenkov
bors [Mon, 16 Apr 2018 00:06:10 +0000 (00:06 +0000)]
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

6 years agoAuto merge of #49947 - oli-obk:turing_complete_const_eval, r=nagisa
bors [Sun, 15 Apr 2018 21:18:37 +0000 (21:18 +0000)]
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)

6 years agoTweaks to intern_ty
John Kåre Alsaker [Fri, 13 Apr 2018 17:33:21 +0000 (19:33 +0200)]
Tweaks to intern_ty

6 years agoMake use of thread-safe arenas
John Kåre Alsaker [Sun, 15 Apr 2018 14:01:38 +0000 (16:01 +0200)]
Make use of thread-safe arenas

6 years agoMake arenas thread safe
John Kåre Alsaker [Sun, 3 Dec 2017 12:49:46 +0000 (13:49 +0100)]
Make arenas thread safe

6 years agoAdd misc timings
John Kåre Alsaker [Thu, 15 Mar 2018 09:17:04 +0000 (10:17 +0100)]
Add misc timings

6 years agoMake layout_depth thread-safe
John Kåre Alsaker [Fri, 6 Apr 2018 12:53:11 +0000 (14:53 +0200)]
Make layout_depth thread-safe

6 years agoCheck generated save-analysis, instead of `bug!()`ing
Shotaro Yamada [Sun, 15 Apr 2018 11:47:45 +0000 (20:47 +0900)]
Check generated save-analysis, instead of `bug!()`ing

Injected crates don't have extern info. Let's skip them.

6 years agoAuto merge of #49833 - oli-obk:incremental_miri_regression, r=michaelwoerister
bors [Sun, 15 Apr 2018 12:32:13 +0000 (12:32 +0000)]
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

6 years agoAdd a tracking issue for making the warning a lint
Oliver Schneider [Sun, 15 Apr 2018 11:28:15 +0000 (13:28 +0200)]
Add a tracking issue for making the warning a lint

6 years agoAuto merge of #49885 - spastorino:fn_ref_unsound, r=nikomatsakis
bors [Sun, 15 Apr 2018 09:14:43 +0000 (09:14 +0000)]
Auto merge of #49885 - spastorino:fn_ref_unsound, r=nikomatsakis

Fix unsoundness bug in functions input references

Fixes #48803

r? @nikomatsakis

6 years agoRemove #[inline(always)] on Vec::into_boxed_slice
Anthony Ramine [Sun, 15 Apr 2018 08:34:57 +0000 (10:34 +0200)]
Remove #[inline(always)] on Vec::into_boxed_slice

6 years agoAuto merge of #49884 - alexcrichton:less-unwrap, r=Mark-Simulacrum
bors [Sun, 15 Apr 2018 06:33:48 +0000 (06:33 +0000)]
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.

6 years agoAuto merge of #49881 - varkor:partialord-opt, r=Manishearth
bors [Sun, 15 Apr 2018 03:54:15 +0000 (03:54 +0000)]
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.

6 years agoAuto merge of #48173 - GuillaumeGomez:error-codes-libsyntax_ext, r=estebank
bors [Sun, 15 Apr 2018 01:26:11 +0000 (01:26 +0000)]
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

6 years agoAuto merge of #49850 - alexcrichton:moreinline, r=sfackler
bors [Sat, 14 Apr 2018 20:22:19 +0000 (20:22 +0000)]
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!

6 years agoignore stage1 testing
Guillaume Gomez [Fri, 13 Apr 2018 21:22:01 +0000 (23:22 +0200)]
ignore stage1 testing

6 years agoAdd tests and longer error explanation
Guillaume Gomez [Mon, 26 Mar 2018 20:04:27 +0000 (22:04 +0200)]
Add tests and longer error explanation

6 years agoAdd error codes for libsyntax_ext
Guillaume Gomez [Mon, 12 Feb 2018 22:21:20 +0000 (23:21 +0100)]
Add error codes for libsyntax_ext

6 years agoRemove warning about f64->f32 cast being potential UB
Nikita Popov [Sat, 14 Apr 2018 14:21:46 +0000 (16:21 +0200)]
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.

6 years agostabilize fetch_nand
Andre Bogus [Sat, 14 Apr 2018 13:20:25 +0000 (15:20 +0200)]
stabilize fetch_nand

6 years agoAuto merge of #49939 - kennytm:rollup, r=kennytm
bors [Sat, 14 Apr 2018 13:11:24 +0000 (13:11 +0000)]
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:

6 years agoRollup merge of #49864 - QuietMisdreavus:doctest-target-features, r=GuillaumeGomez
kennytm [Sat, 14 Apr 2018 10:50:41 +0000 (18:50 +0800)]
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

6 years agoRollup merge of #49871 - SimonSapin:int-bytes, r=sfackler
kennytm [Sat, 14 Apr 2018 10:49:58 +0000 (18:49 +0800)]
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

6 years agoRollup merge of #49958 - glandium:cleanup, r=SimonSapin
kennytm [Sat, 14 Apr 2018 10:48:09 +0000 (18:48 +0800)]
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.

6 years agoAdd to_bytes and from_bytes to primitive integers
Simon Sapin [Tue, 10 Apr 2018 22:04:32 +0000 (00:04 +0200)]
Add to_bytes and from_bytes to primitive integers

6 years agoAuto merge of #49289 - varkor:emit-metadata-without-link, r=michaelwoerister
bors [Sat, 14 Apr 2018 10:27:03 +0000 (10:27 +0000)]
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

6 years agoGet rid of redundant `HashSet`
Oliver Schneider [Fri, 13 Apr 2018 16:48:41 +0000 (18:48 +0200)]
Get rid of redundant `HashSet`

6 years agoReduce the number of calls to `cdata`
Oliver Schneider [Wed, 11 Apr 2018 11:31:51 +0000 (13:31 +0200)]
Reduce the number of calls to `cdata`

6 years agoEncode items before encoding the list of AllocIds
Oliver Schneider [Wed, 11 Apr 2018 11:31:37 +0000 (13:31 +0200)]
Encode items before encoding the list of AllocIds

6 years agoUse `LazySeq` instead of `Vec`
Oliver Schneider [Wed, 11 Apr 2018 08:47:52 +0000 (10:47 +0200)]
Use `LazySeq` instead of `Vec`

6 years agoStop referring to statics' AllocIds directly
Oliver Schneider [Tue, 10 Apr 2018 14:25:10 +0000 (16:25 +0200)]
Stop referring to statics' AllocIds directly

6 years agoDon't recurse into allocations, use a global table instead
Oliver Schneider [Tue, 10 Apr 2018 07:58:46 +0000 (09:58 +0200)]
Don't recurse into allocations, use a global table instead

6 years agoReplace remaining uses of deprecated Heap with Global
Mike Hommey [Sat, 14 Apr 2018 07:48:27 +0000 (16:48 +0900)]
Replace remaining uses of deprecated Heap with Global

6 years agoReplace remaining uses of deprecated std::heap with std::alloc
Mike Hommey [Sat, 14 Apr 2018 07:47:38 +0000 (16:47 +0900)]
Replace remaining uses of deprecated std::heap with std::alloc

6 years agoRollup merge of #49922 - f-bro:zmiri, r=oli-obk
kennytm [Sat, 14 Apr 2018 07:23:37 +0000 (15:23 +0800)]
Rollup merge of #49922 - f-bro:zmiri, r=oli-obk

Remove -Zmiri debugging option

6 years agoRollup merge of #49916 - llogiq:doc-atomic-fetch-update, r=kennytm
kennytm [Sat, 14 Apr 2018 07:23:21 +0000 (15:23 +0800)]
Rollup merge of #49916 - llogiq:doc-atomic-fetch-update, r=kennytm

improve Atomic*::fetch_update docs

This clarifies that fetch_update *always* returns the previous value, either as `Ok(_)` or `Err(_)`, depending on whether the supplied update function returned `Some(_)` or `None`.

6 years agoRollup merge of #49915 - llogiq:doc-shift-types, r=joshtriplett
kennytm [Sat, 14 Apr 2018 07:23:08 +0000 (15:23 +0800)]
Rollup merge of #49915 - llogiq:doc-shift-types, r=joshtriplett

[doc] note the special type inference handling for shift ops

This adds a note to the docs about the difference between the shift ops and the corresponding trait methods when it comes to type inference.

6 years agoRollup merge of #49913 - varkor:RegionParameterDef-InternedString, r=petrochenkov
kennytm [Sat, 14 Apr 2018 07:22:57 +0000 (15:22 +0800)]
Rollup merge of #49913 - varkor:RegionParameterDef-InternedString, r=petrochenkov

Use InternedString rather than Name for RegionParameterDef

This makes it consistent with `TypeParameterDef`.

6 years agoRollup merge of #49908 - chrisccoulson:fix-rustdoc-themes-test-without-rpath, r=Mark...
kennytm [Sat, 14 Apr 2018 07:22:39 +0000 (15:22 +0800)]
Rollup merge of #49908 - chrisccoulson:fix-rustdoc-themes-test-without-rpath, r=Mark-Simulacrum

Fix test failure in src/tools/rustdoc-themes when rust.rpath = false

See https://github.com/rust-lang/rust/issues/49907

6 years agoRollup merge of #49886 - varkor:generate-deriving-span-tests-usability, r=nikomatsakis
kennytm [Sat, 14 Apr 2018 07:22:27 +0000 (15:22 +0800)]
Rollup merge of #49886 - varkor:generate-deriving-span-tests-usability, r=nikomatsakis

Ignore copyright year when generating deriving span tests

Previously, generate-deriving-span-tests.py would regenerate all the tests anew, even if they hadn't changed. This creates unnecessary diffs that only change the copyright year. Now we check to see if any of the content of the test has changed before generating the new one.

6 years agoRollup merge of #49465 - ollie27:rustbuild_test_docs, r=steveklabnik,QuietMisdreavus...
kennytm [Sat, 14 Apr 2018 07:22:17 +0000 (15:22 +0800)]
Rollup merge of #49465 - ollie27:rustbuild_test_docs, r=steveklabnik,QuietMisdreavus,frewsxcv,GuillaumeGomez

Add docs for the test crate with the std docs

If the compiler docs aren't going to include the test crate then it may as well be included with std.

Fixes #49388

6 years agoRollup merge of #49876 - oli-obk:no_secret_clippy_on_stable_☹, r=nrc
kennytm [Sat, 14 Apr 2018 07:22:06 +0000 (15:22 +0800)]
Rollup merge of #49876 - oli-obk:no_secret_clippy_on_stable_☹, r=nrc

Don't inject clippy into rls on stable/beta

as discussed at the all-hands

6 years agoRollup merge of #49866 - Mark-Simulacrum:pr-travis-windows, r=alexcrichton
kennytm [Sat, 14 Apr 2018 07:21:39 +0000 (15:21 +0800)]
Rollup merge of #49866 - Mark-Simulacrum:pr-travis-windows, r=alexcrichton

Cross-compile builder to Windows for PRs on Travis

I chose a completely arbitrary windows target here (I have no idea what's best, we could do multiple -- they are relatively fast).

6 years agoRollup merge of #49852 - alexcrichton:fix-more-proc-macros, r=nrc
kennytm [Sat, 14 Apr 2018 07:21:19 +0000 (15:21 +0800)]
Rollup merge of #49852 - alexcrichton:fix-more-proc-macros, r=nrc

proc_macro: Avoid cached TokenStream more often

This commit adds even more pessimization to use the cached `TokenStream` inside
of an AST node. As a reminder the `proc_macro` API requires taking an arbitrary
AST node and transforming it back into a `TokenStream` to hand off to a
procedural macro. Such functionality isn't actually implemented in rustc today,
so the way `proc_macro` works today is that it stringifies an AST node and then
reparses for a list of tokens.

This strategy unfortunately loses all span information, so we try to avoid it
whenever possible. Implemented in #43230 some AST nodes have a `TokenStream`
cache representing the tokens they were originally parsed from. This
`TokenStream` cache, however, has turned out to not always reflect the current
state of the item when it's being tokenized. For example `#[cfg]` processing or
macro expansion could modify the state of an item. Consequently we've seen a
number of bugs (#48644 and #49846) related to using this stale cache.

This commit tweaks the usage of the cached `TokenStream` to compare it to our
lossy stringification of the token stream. If the tokens that make up the cache
and the stringified token stream are the same then we return the cached version
(which has correct span information). If they differ, however, then we will
return the stringified version as the cache has been invalidated and we just
haven't figured that out.

Closes #48644
Closes #49846

6 years agoRollup merge of #49951 - matklad:update-cargo, r=nrc
kennytm [Sat, 14 Apr 2018 07:21:10 +0000 (15:21 +0800)]
Rollup merge of #49951 - matklad:update-cargo, r=nrc

Update Cargo

This includes https://github.com/rust-lang/cargo/pull/5353, which we  want to test via opt-in in the wild.

This'll break RLS, the fix is https://github.com/rust-lang-nursery/rls/pull/822

6 years agoAuto merge of #49396 - Zoxc:sync-on-disk-cache, r=michaelwoerister
bors [Sat, 14 Apr 2018 06:32:20 +0000 (06:32 +0000)]
Auto merge of #49396 - Zoxc:sync-on-disk-cache, r=michaelwoerister

Make OnDiskCache thread-safer

I'm not sure if `synthetic_expansion_infos` is handled correctly.

`interpret_alloc_cache` and `interpret_alloc_size` seems to be wrong though, since the code may now decode two `AllocId`s in parallel. I'd like some input on how to fix that.

cc @oli-obk

r? @michaelwoerister

6 years agoMake debuginfo-tools always default false
Josh Stone [Sat, 14 Apr 2018 04:58:21 +0000 (21:58 -0700)]
Make debuginfo-tools always default false

6 years agoAvoid specific claims about debuginfo size
Josh Stone [Sat, 14 Apr 2018 04:57:53 +0000 (21:57 -0700)]
Avoid specific claims about debuginfo size

6 years agoAuto merge of #49957 - nrc:update, r=simulacrum
bors [Sat, 14 Apr 2018 03:51:44 +0000 (03:51 +0000)]
Auto merge of #49957 - nrc:update, r=simulacrum

Update Rustfmt

Should fix broken RLS/nightlies

r? @alexcrichton

6 years agofix error span
csmoe [Fri, 13 Apr 2018 13:58:42 +0000 (21:58 +0800)]
fix error span

6 years agoUpdate Rustfmt
Nick Cameron [Fri, 13 Apr 2018 21:48:18 +0000 (09:48 +1200)]
Update Rustfmt

6 years agoAuto merge of #49326 - petrochenkov:nteq, r=eddyb
bors [Sat, 14 Apr 2018 01:28:13 +0000 (01:28 +0000)]
Auto merge of #49326 - petrochenkov:nteq, r=eddyb

macros: Remove matching on "complex" nonterminals requiring AST comparisons

So, you can actually use nonterminals from outer macros in left hand side of nested macros and invocations of nested macros will try to match passed arguments to them.

```rust
macro outer($nt_item: item) {
    macro inner($nt_item) {
        struct S;
    }

    inner!($nt_item); // OK, `$nt_item` matches `$nt_item`
}
```

Why this is bad:
- We can't do this matching correctly. When two nonterminals are compared, the original tokens are lost and we have to compare AST fragments instead. Right now the comparison is done by `PartialEq` impls derived on AST structures.
    - On one hand, AST loses information compared to original tokens (e.g. trailing separators and other simplifications done during parsing to AST), so we can produce matches that are not actually correct.
    - On another hand derived `PartialEq` impls for AST structures don't make much sense in general and compare various auxiliary garbage like spans. For the argument nonterminal to match we should use literally the same token (possibly cloned) as was used in the macro LHS (as in the example above). So we can reject matches that are actually correct.
    - Support for nonterminal matching is the only thing that forces us to derive `PartialEq` for all (!) AST structures. As I mentioned these impls are also mostly nonsensical.

This PR removes support for matching on all nonterminals except for "simple" ones like `ident`, `lifetime` and `tt` for which we have original tokens that can be compared.
After this is done I'll submit another PR removing huge number of `PartialEq` impls from AST and HIR structures.

This is an arcane feature and I don't personally know why would anyone use it, but the change should ideally go through crater.
We'll be able to support this feature again in the future when all nonterminals have original token streams attached to them in addition to (or instead of) AST fragments.

6 years agorustbuild: allow building tools with debuginfo
Josh Stone [Fri, 13 Apr 2018 23:52:54 +0000 (16:52 -0700)]
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.

6 years agoCleanup liballoc use statements
Mike Hommey [Fri, 13 Apr 2018 23:13:28 +0000 (08:13 +0900)]
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.

6 years agomacros: Do not match on "complex" nonterminals requiring AST comparisons
Vadim Petrochenkov [Sat, 24 Mar 2018 13:00:44 +0000 (16:00 +0300)]
macros: Do not match on "complex" nonterminals requiring AST comparisons

6 years agoAuto merge of #49585 - GuillaumeGomez:rename-to-compile-pass, r=Mark-Simulacrum
bors [Fri, 13 Apr 2018 22:11:06 +0000 (22:11 +0000)]
Auto merge of #49585 - GuillaumeGomez:rename-to-compile-pass, r=Mark-Simulacrum

Rename must-compile-successfully into compile-pass

Fixes #49568.

r? @Mark-Simulacrum

6 years agoRename must-compile-successfully into compile-pass
Guillaume Gomez [Mon, 2 Apr 2018 11:20:06 +0000 (13:20 +0200)]
Rename must-compile-successfully into compile-pass

6 years agoadd -C to the rustdoc book
QuietMisdreavus [Fri, 13 Apr 2018 21:21:27 +0000 (16:21 -0500)]
add -C to the rustdoc book

6 years agoadd -C parameter to rustdoc
QuietMisdreavus [Thu, 12 Apr 2018 18:12:53 +0000 (13:12 -0500)]
add -C parameter to rustdoc

6 years agoUpdate RLS
Aleksey Kladov [Fri, 13 Apr 2018 20:20:18 +0000 (23:20 +0300)]
Update RLS

6 years agoAuto merge of #49830 - sinkuu:fix_ice_47715, r=cramertj
bors [Fri, 13 Apr 2018 19:22:14 +0000 (19:22 +0000)]
Auto merge of #49830 - sinkuu:fix_ice_47715, r=cramertj

Fix ICE by disallowing `impl Trait` in unsupported position

Fixes #47715.

6 years agoUse InternedString rather than Name for RegionParameterDef
varkor [Thu, 12 Apr 2018 20:16:26 +0000 (21:16 +0100)]
Use InternedString rather than Name for RegionParameterDef

This makes it consistent with TypeParameterDef.

6 years agoUpdate Cargo
Aleksey Kladov [Fri, 13 Apr 2018 17:21:51 +0000 (20:21 +0300)]
Update Cargo

This includes https://github.com/rust-lang/cargo/pull/5353,
which we might want to test via opt-in in the wild

6 years ago[doc] note the special type inference handling for shifts
Andre Bogus [Thu, 12 Apr 2018 20:07:53 +0000 (22:07 +0200)]
[doc] note the special type inference handling for shifts

6 years agoAuto merge of #49808 - spastorino:dump_cause_ice, r=nikomatsakis
bors [Fri, 13 Apr 2018 16:06:14 +0000 (16:06 +0000)]
Auto merge of #49808 - spastorino:dump_cause_ice, r=nikomatsakis

[NLL] Fix ICE when a borrow wrapped in a temporary is used after dropped

Fixes #47646

r? @nikomatsakis

6 years agoDon't abort const eval due to long running evals, just warn
Oliver Schneider [Fri, 13 Apr 2018 15:56:45 +0000 (17:56 +0200)]
Don't abort const eval due to long running evals, just warn

6 years agostd: Avoid allocating panic message unless needed
Alex Crichton [Fri, 6 Apr 2018 21:22:13 +0000 (14:22 -0700)]
std: Avoid allocating panic message unless needed

This commit removes allocation of the panic message in instances like
`panic!("foo: {}", "bar")` if we don't actually end up needing the message. We
don't need it in the case of wasm32 right now, and in general it's not needed
for panic=abort instances that use the default panic hook.

For now this commit only solves the wasm use case where with LTO the allocation
is entirely removed, but the panic=abort use case can be implemented at a later
date if needed.

6 years agocore: Remove an implicit panic from Formatter::pad
Alex Crichton [Fri, 6 Apr 2018 21:20:22 +0000 (14:20 -0700)]
core: Remove an implicit panic from Formatter::pad

The expression `&s[..i]` in general can panic if `i` is out of bounds or not on
a character boundary for a string, and this caused the codegen for
`Formatter::pad` to be a bit larger than it otherwise needed to be. This commit
replaces this with `s.get(..i).unwrap_or(&s)` which while having different
behavior if `i` is out of bounds has a much smaller code footprint and otherwise
avoids the need for `unsafe` code.

6 years agoReduce the size of panics in RawVec
Alex Crichton [Fri, 6 Apr 2018 20:46:10 +0000 (13:46 -0700)]
Reduce the size of panics in RawVec

Create one canonical location which panics with "capacity overflow" instead of
having many. This reduces the size of a `panic!("{}", 1)` binary on wasm from
34k to 17k.

6 years agostd: Minimize size of panicking on wasm
Alex Crichton [Thu, 29 Mar 2018 21:59:13 +0000 (14:59 -0700)]
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.

6 years agocore: Remove panics from some `Layout` methods
Alex Crichton [Wed, 11 Apr 2018 17:47:16 +0000 (10:47 -0700)]
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.

6 years agocore: Inline `From<AllocErr> for CollectionAllocErr`
Alex Crichton [Tue, 10 Apr 2018 18:25:23 +0000 (11:25 -0700)]
core: Inline `From<AllocErr> for CollectionAllocErr`

This shows up in allocations of vectors and such, so no need for it to not be
inlined!

6 years agoAuto merge of #49800 - ishitatsuyuki:intern-goal, r=nikomatsakis
bors [Fri, 13 Apr 2018 13:09:40 +0000 (13:09 +0000)]
Auto merge of #49800 - ishitatsuyuki:intern-goal, r=nikomatsakis

traits: Implement interning for Goal and Clause

r? @nikomatsakis

Close #49054

Contains some refactoring for the interning mechanism, mainly aimed at reducing pain when changing types of interning map.

This should be mostly good, although I'm not sure with the naming of `Goal::from_poly_domain_goal`.