]> git.lizzy.rs Git - rust.git/log
rust.git
5 years agoRollup merge of #53001 - petrochenkov:master, r=estebank
kennytm [Sat, 4 Aug 2018 06:35:55 +0000 (14:35 +0800)]
Rollup merge of #53001 - petrochenkov:master, r=estebank

privacy: Fix an ICE in `path_is_private_type`

Fixes https://github.com/rust-lang/rust/issues/52879

(Untested.)

5 years agoRollup merge of #52996 - cuviper:1.28-or_default, r=Mark-Simulacrum
kennytm [Sat, 4 Aug 2018 06:35:54 +0000 (14:35 +0800)]
Rollup merge of #52996 - cuviper:1.28-or_default, r=Mark-Simulacrum

RELEASES.md: fix the `hash_map::Entry::or_default` link

None

5 years agoRollup merge of #52995 - cramertj:smaller-await, r=withoutboats
kennytm [Sat, 4 Aug 2018 06:35:53 +0000 (14:35 +0800)]
Rollup merge of #52995 - cramertj:smaller-await, r=withoutboats

Remove unnecessary local in await! generator

This makes `async { await!(future::ready(())) }` 4 bytes instead of 16. [Playground example](http://play.rust-lang.org/?gist=54c075599b9ff390fe505c75d6b98feb&version=nightly&mode=debug&edition=2018)

5 years agoRollup merge of #52969 - Keruspe:local_rebuild, r=alexcrichton
kennytm [Sat, 4 Aug 2018 06:35:51 +0000 (14:35 +0800)]
Rollup merge of #52969 - Keruspe:local_rebuild, r=alexcrichton

rustbuild: fix local_rebuild

If we detect a local rebuild (e.g. bootstrap compiler is the same version as target compiler), we set stage to 1.
When trying to build e.g. UnstableBook, we use Mode::ToolBootstrap and stage is 1.
Just allow Mode::ToolBootstrap and stagge != 0 if we are in a local_rebuild

This fixes building current master using current beta (as master hasn't yet been bumped to 1.30).
This should be backported to beta too, as currently we cannot build beta using itself because of that.

r? @alexcrichton

5 years agoRollup merge of #52968 - zackmdavis:app-lint-cability, r=estebank
kennytm [Sat, 4 Aug 2018 06:35:50 +0000 (14:35 +0800)]
Rollup merge of #52968 - zackmdavis:app-lint-cability, r=estebank

App-lint-cability

@eminence recently pointed out (rust-lang/cargo#5846) that it's
surprising that `cargo fix` (now shipping with Cargo itself!) doesn't
fix very common lint warnings, which is as good of a reminder as any
that we should finish #50723.

(Previously, we did this on the librustc and libsyntax crates in #50724. I filed cmr/this-week-in-rust#685 in hopes of recruiting new contributors to do the rest.)

r? @estebank

5 years agoRollup merge of #52940 - kennytm:move-checktool-protection-week, r=alexcrichton
kennytm [Sat, 4 Aug 2018 06:35:49 +0000 (14:35 +0800)]
Rollup merge of #52940 - kennytm:move-checktool-protection-week, r=alexcrichton

Align 6-week cycle check with beta promotion instead of stable release.

The regression check is to make beta promotion easier, so it makes more
sense to use the Tuesday of the release week (T-2) as the end point of the
regression prevention, instead of Thursday (T-0). But since the beta
promotion PR is sent at Tuesday evening at UTC, the protection should
include the whole Tuesday as well, meaning the 6-week cycle will start from
Wednesdays.

This will also move the start of the regression protection week one day
earlier.

5 years agoAuto merge of #53035 - alexcrichton:debug-travis, r=kennytm
bors [Sat, 4 Aug 2018 03:45:55 +0000 (03:45 +0000)]
Auto merge of #53035 - alexcrichton:debug-travis, r=kennytm

travis: Attempt to debug shutdowns

These snippets recommend by Travis support

5 years agoAuto merge of #52927 - Mark-Simulacrum:cratestore-cleanup, r=alexcrichton
bors [Sat, 4 Aug 2018 01:44:25 +0000 (01:44 +0000)]
Auto merge of #52927 - Mark-Simulacrum:cratestore-cleanup, r=alexcrichton

Crate store cleanup

Each commit mostly stands on its own.

Most of the diff is lifetime-related and uninteresting.

5 years agoAuto merge of #53034 - Manishearth:clippyup, r=oli-obk
bors [Fri, 3 Aug 2018 21:11:00 +0000 (21:11 +0000)]
Auto merge of #53034 - Manishearth:clippyup, r=oli-obk

Update clippy

r? @kennytm @alexcrichton

5 years agotravis: Attempt to debug shutdowns
Alex Crichton [Fri, 3 Aug 2018 19:20:45 +0000 (12:20 -0700)]
travis: Attempt to debug shutdowns

These snippets recommend by Travis support

5 years agoAuto merge of #52973 - davidtwco:issue-52663-lifetimes-not-included-in-span, r=pnkfelix
bors [Fri, 3 Aug 2018 17:46:13 +0000 (17:46 +0000)]
Auto merge of #52973 - davidtwco:issue-52663-lifetimes-not-included-in-span, r=pnkfelix

NLL mentions lifetimes that are not included in printed span(s).

Part of #52663.

r? @pnkfelix

5 years agoMove unused trait functions to inherent functions
Mark Rousskov [Tue, 31 Jul 2018 23:23:29 +0000 (17:23 -0600)]
Move unused trait functions to inherent functions

5 years agoUpdate clippy
Manish Goregaokar [Fri, 3 Aug 2018 17:16:07 +0000 (10:16 -0700)]
Update clippy

5 years agoStore concrete crate stores where possible
Mark Rousskov [Tue, 31 Jul 2018 21:23:31 +0000 (15:23 -0600)]
Store concrete crate stores where possible

5 years agoVisibility is now a query
Mark Rousskov [Tue, 31 Jul 2018 21:35:35 +0000 (15:35 -0600)]
Visibility is now a query

5 years agoDelete dummy crate store
Mark Rousskov [Tue, 31 Jul 2018 20:24:31 +0000 (14:24 -0600)]
Delete dummy crate store

5 years agoMove validate_crate_name to rustc_metadata
Mark Rousskov [Tue, 31 Jul 2018 18:07:37 +0000 (12:07 -0600)]
Move validate_crate_name to rustc_metadata

5 years agoAuto merge of #52712 - oli-obk:const_eval_cleanups, r=RalfJung
bors [Fri, 3 Aug 2018 14:28:12 +0000 (14:28 +0000)]
Auto merge of #52712 - oli-obk:const_eval_cleanups, r=RalfJung

Reintroduce `Undef` and properly check constant value sizes

r? @RalfJung

cc @eddyb

basically all kinds of silent failures that never occurred are assertions now

5 years agoAuto merge of #52887 - yurydelendik:disable-lld-symbols, r=alexcrichton
bors [Fri, 3 Aug 2018 12:22:17 +0000 (12:22 +0000)]
Auto merge of #52887 - yurydelendik:disable-lld-symbols, r=alexcrichton

Disable debug sections when optimization flags is set for LLD.

Currently LLD does not error when optimization is set and debugging information sections are present. (See discussion at https://reviews.llvm.org/D47901)

Using `--strip-debug` along with the `-O` option.

5 years agoUnify API of `Scalar` and `ScalarMaybeUndef`
Oliver Schneider [Fri, 3 Aug 2018 10:40:03 +0000 (12:40 +0200)]
Unify API of `Scalar` and `ScalarMaybeUndef`

5 years agoReintroduce alignment check
Oliver Schneider [Fri, 3 Aug 2018 09:28:06 +0000 (11:28 +0200)]
Reintroduce alignment check

5 years agoRemove spurious whitespace
Oliver Schneider [Fri, 3 Aug 2018 09:24:36 +0000 (11:24 +0200)]
Remove spurious whitespace

5 years agoAuto merge of #52948 - davidtwco:issue-52633-later-loop-iteration, r=pnkfelix
bors [Fri, 3 Aug 2018 09:22:11 +0000 (09:22 +0000)]
Auto merge of #52948 - davidtwco:issue-52633-later-loop-iteration, r=pnkfelix

NLL: Better Diagnostic When "Later" means "A Future Loop Iteration"

Part of #52663.

r? @pnkfelix

5 years agoRemove some more unnecessary `mut`
Oliver Schneider [Fri, 3 Aug 2018 09:21:44 +0000 (11:21 +0200)]
Remove some more unnecessary `mut`

5 years agoAuto merge of #52925 - RalfJung:sanity_check, r=oli-obk
bors [Fri, 3 Aug 2018 06:34:16 +0000 (06:34 +0000)]
Auto merge of #52925 - RalfJung:sanity_check, r=oli-obk

check_const: use the same ParamEnv as codegen for statics

Fixes at least part of https://github.com/rust-lang/rust/issues/52849 (my CTFE-stress benchmark). Note that I do not know what I am doing here, this is just based on hints from @oli-obk.

r? @oli-obk

5 years agoAuto merge of #52919 - alexcrichton:update-cargo, r=Mark-Simulacrum
bors [Fri, 3 Aug 2018 02:53:17 +0000 (02:53 +0000)]
Auto merge of #52919 - alexcrichton:update-cargo, r=Mark-Simulacrum

Update tool submodules, update feature unification strategy

* Bring in some fixes for `cargo fix`
* Update RLS/rustfmt to keep them compiling
* Update all tools to [depend on `rustc-workspace-hack`](https://github.com/rust-lang/rust/pull/52919#issuecomment-409802418)
* Change how we deal with feature unification amongst these builds.

5 years agoUpdate Cargo submodule
Alex Crichton [Tue, 31 Jul 2018 21:16:55 +0000 (14:16 -0700)]
Update Cargo submodule

Bring in some fixes for `cargo fix` notably

5 years agoAuto merge of #51657 - wesleywiser:wip_profiling, r=eddyb
bors [Fri, 3 Aug 2018 00:50:09 +0000 (00:50 +0000)]
Auto merge of #51657 - wesleywiser:wip_profiling, r=eddyb

Implement a self profiler

This is a work in progress implementation of #50780. I'd love feedback on the overall structure and code as well as some specific things:

- [The query categorization mechanism](https://github.com/rust-lang/rust/compare/master...wesleywiser:wip_profiling?expand=1#diff-19e0a69c10eff31eb2d16805e79f3437R101). This works but looks kind of ugly to me. Perhaps there's a better way?

- [The profiler assumes only one activity can run at a time](https://github.com/rust-lang/rust/compare/master...wesleywiser:wip_profiling?expand=1#diff-f8a403b2d88d873e4b27c097c614a236R177). This is obviously incompatible with the ongoing parallel queries.

- [The output code is just a bunch of `format!()`s](https://github.com/rust-lang/rust/compare/master...wesleywiser:wip_profiling?expand=1#diff-f8a403b2d88d873e4b27c097c614a236R91). Is there a better way to generate markdown or json in the compiler?

- [The query categorizations are likely wrong](https://github.com/rust-lang/rust/compare/master...wesleywiser:wip_profiling?expand=1#diff-19e0a69c10eff31eb2d16805e79f3437R101). I've marked what seemed obvious to me but I'm sure I got a lot of them wrong.

The overhead currently seems very low. Running `perf` on a sample compilation with profiling enabled reveals:
![image](https://user-images.githubusercontent.com/831192/41657821-9775efec-7462-11e8-9e5e-47ec94105d9d.png)

5 years agoGenerate self-profiler types with macros
Wesley Wiser [Tue, 24 Jul 2018 01:52:39 +0000 (21:52 -0400)]
Generate self-profiler types with macros

5 years agoFix tidy
Wesley Wiser [Sat, 21 Jul 2018 01:28:37 +0000 (21:28 -0400)]
Fix tidy

5 years agoRemove some dead code
Wesley Wiser [Wed, 20 Jun 2018 11:57:22 +0000 (07:57 -0400)]
Remove some dead code

5 years agoInclude additional data in the json output
Wesley Wiser [Thu, 14 Jun 2018 02:08:41 +0000 (22:08 -0400)]
Include additional data in the json output

5 years agoInclude query hits/totals
Wesley Wiser [Thu, 14 Jun 2018 00:49:22 +0000 (20:49 -0400)]
Include query hits/totals

5 years agoRefactor json printing
Wesley Wiser [Tue, 12 Jun 2018 03:41:11 +0000 (23:41 -0400)]
Refactor json printing

5 years agoFirst pass at json output
Wesley Wiser [Wed, 6 Jun 2018 03:05:30 +0000 (23:05 -0400)]
First pass at json output

5 years agoFix more missed query data
Wesley Wiser [Wed, 6 Jun 2018 01:37:31 +0000 (21:37 -0400)]
Fix more missed query data

5 years agoRemove redundant s in output
Wesley Wiser [Tue, 5 Jun 2018 03:10:23 +0000 (23:10 -0400)]
Remove redundant s in output

5 years agoFix some missed query data
Wesley Wiser [Tue, 5 Jun 2018 02:43:27 +0000 (22:43 -0400)]
Fix some missed query data

5 years agoSwitch to markdown output
Wesley Wiser [Thu, 31 May 2018 03:41:20 +0000 (23:41 -0400)]
Switch to markdown output

5 years agoAdd units to times
Wesley Wiser [Wed, 30 May 2018 22:56:36 +0000 (18:56 -0400)]
Add units to times

5 years agoBasic incremental stats
Wesley Wiser [Wed, 30 May 2018 03:12:49 +0000 (23:12 -0400)]
Basic incremental stats

5 years agoBasic profiling
Wesley Wiser [Sat, 19 May 2018 17:50:58 +0000 (13:50 -0400)]
Basic profiling

5 years agoprivacy: Fix an ICE in `path_is_private_type`
Vadim Petrochenkov [Thu, 2 Aug 2018 21:43:49 +0000 (00:43 +0300)]
privacy: Fix an ICE in `path_is_private_type`

Fixes https://github.com/rust-lang/rust/issues/52879

(Untested.)

5 years agoAuto merge of #52841 - petrochenkov:premacro, r=alexcrichton
bors [Thu, 2 Aug 2018 21:39:14 +0000 (21:39 +0000)]
Auto merge of #52841 - petrochenkov:premacro, r=alexcrichton

resolve: Implement prelude search for macro paths, implement tool attributes

When identifier is macro path is resolved in scopes (i.e. the first path segment - `foo` in `foo::mac!()` or `foo!()`), scopes are searched in the same order as for non-macro paths - items in modules, extern prelude, tool prelude (see later), standard library prelude, language prelude, but with some extra shadowing restrictions (names from globs and macro expansions cannot shadow names from outer scopes). See the comment in `fn resolve_lexical_macro_path_segment` for more details.

"Tool prelude" currently contains two "tool modules" `rustfmt` and `clippy`, and is searched immediately after extern prelude.
This makes the [possible long-term solution](https://github.com/rust-lang/rfcs/blob/master/text/2103-tool-attributes.md#long-term-solution) for tool attributes exactly equivalent to the existing extern prelude scheme, except that `--extern=my_crate` making crate names available in scope is replaced with something like `--tool=my_tool` making tool names available in scope.

The `tool_attributes` feature is still unstable and `#![feature(tool_attributes)]` now implicitly enables `#![feature(use_extern_macros)]`. `use_extern_macros` is a prerequisite for `tool_attributes`, so their stabilization will happen in the same order.
If `use_extern_macros` is not enabled, then tool attributes are treated as custom attributes (this is temporary, anyway).

Fixes https://github.com/rust-lang/rust/issues/52576
Fixes https://github.com/rust-lang/rust/issues/52512
Fixes https://github.com/rust-lang/rust/issues/51277
cc https://github.com/rust-lang/rust/issues/52269

5 years agoRELEASES.md: fix the `hash_map::Entry::or_default` link
Josh Stone [Thu, 2 Aug 2018 20:54:21 +0000 (13:54 -0700)]
RELEASES.md: fix the `hash_map::Entry::or_default` link

5 years agoRemove unnecessary local in await! macro
Taylor Cramer [Thu, 2 Aug 2018 20:07:55 +0000 (13:07 -0700)]
Remove unnecessary local in await! macro

5 years agoAuto merge of #52782 - pnkfelix:issue-45696-dangly-paths-for-box, r=eddyb
bors [Thu, 2 Aug 2018 19:42:19 +0000 (19:42 +0000)]
Auto merge of #52782 - pnkfelix:issue-45696-dangly-paths-for-box, r=eddyb

[NLL] Dangly paths for box

Special-case `Box` in `rustc_mir::borrow_check`.

Since we know dropping a box will not access any `&mut` or `&` references, it is safe to model its destructor as only touching the contents *owned* by the box.

----

There are three main things going on here:

1. The first main thing, this PR is fixing a bug in NLL where `rustc` previously would issue a diagnostic error in a case like this:
```rust
fn foo(x: Box<&mut i32>) -> &mut i32 { &mut **x }
```

such code was accepted by the AST-borrowck in the past, but NLL was rejecting it with the following message ([playground](https://play.rust-lang.org/?gist=13c5560f73bfb16d6dab3ceaad44c0f8&version=nightly&mode=release&edition=2015))
```
error[E0597]: `**x` does not live long enough
 --> src/main.rs:3:40
  |
3 | fn foo(x: Box<&mut i32>) -> &mut i32 { &mut **x }
  |                                        ^^^^^^^^ - `**x` dropped here while still borrowed
  |                                        |
  |                                        borrowed value does not live long enough
  |
note: borrowed value must be valid for the anonymous lifetime #1 defined on the function body at 3:1...
 --> src/main.rs:3:1
  |
3 | fn foo(x: Box<&mut i32>) -> &mut i32 { &mut **x }
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: aborting due to previous error
```

2. The second main thing: The reason such code was previously rejected was because NLL (MIR-borrowck) incorporates a fix for issue #31567, where it models a destructor's execution as potentially accessing any borrows held by the thing being destructed. The tests with `Scribble` model this, showing that the compiler now catches such unsoundness.

However, that fix for issue #31567 is too strong, in that NLL (MIR-borrowck) includes `Box` as one of the types with a destructor that potentially accesses any borrows held by the box. This thus was the cause of the main remaining discrepancy between AST-borrowck and MIR-borrowck, as documented in issue #45696, specifically in [the last example of this comment](https://github.com/rust-lang/rust/issues/45696#issuecomment-345367873), which I have adapted into the `fn foo` shown above.

We did close issue #45696 back in December of 2017, but AFAICT that example was not fixed by PR #46268. (And we did not include a test, etc etc.)

This PR fixes that case, by trying to model the so-called `DerefPure` semantics of `Box<T>` when we traverse the type of the input to `visit_terminator_drop`.

3. The third main thing is that during a review of the first draft of this PR, @matthewjasper pointed out that the new traversal of `Box<T>` could cause the compiler to infinite loop. I have adjusted the PR to avoid this (by tracking what types we have previously seen), and added a much needed test of this somewhat odd scenario. (Its an odd scenario because the particular case only arises for things like `struct A(Box<A>);`, something which cannot be constructed in practice.)

Fix #45696.

5 years agoAuto merge of #52949 - Mark-Simulacrum:snap, r=alexcrichton
bors [Thu, 2 Aug 2018 15:34:21 +0000 (15:34 +0000)]
Auto merge of #52949 - Mark-Simulacrum:snap, r=alexcrichton

Switch to bootstrapping from 1.29 beta

r? @alexcrichton

5 years agoAuto merge of #52975 - pnkfelix:issue-52967-edition-2018-implies-2-phase-borrows...
bors [Thu, 2 Aug 2018 12:40:35 +0000 (12:40 +0000)]
Auto merge of #52975 - pnkfelix:issue-52967-edition-2018-implies-2-phase-borrows, r=Mark-Simulacrum

NLL migration in the 2018 edition needs two-phase borrows too!

NLL migration in the 2018 edition needs two-phase borrows too!

Fix #52967.

5 years agoWhen we turn on NLL migration in the 2018 edition, we need two-phase borrows too!
Felix S. Klock II [Thu, 2 Aug 2018 11:51:13 +0000 (13:51 +0200)]
When we turn on NLL migration in the 2018 edition, we need two-phase borrows too!

Fix #52967.

5 years agoSecond field of ScalarPair can be undef in some cases
Oliver Schneider [Thu, 2 Aug 2018 11:16:53 +0000 (13:16 +0200)]
Second field of ScalarPair can be undef in some cases

5 years agoAuto merge of #52906 - RalfJung:jemalloc, r=alexcrichton
bors [Thu, 2 Aug 2018 10:28:42 +0000 (10:28 +0000)]
Auto merge of #52906 - RalfJung:jemalloc, r=alexcrichton

enable jemalloc assertions when configured to do so

This is essentially a re-submission of the functional part of https://github.com/rust-lang/rust/pull/43648. I was unable to reproduce the issue I had back then, maybe something changed somewhere to no longer trigger the assertion.

Fixes https://github.com/rust-lang/rust/issues/44152

5 years agoExplicitly label any named lifetimes mentioned in error messages.
David Wood [Thu, 2 Aug 2018 10:00:15 +0000 (12:00 +0200)]
Explicitly label any named lifetimes mentioned in error messages.

5 years agoAuto merge of #52890 - djrenren:test-visibility, r=petrochenkov
bors [Thu, 2 Aug 2018 08:24:14 +0000 (08:24 +0000)]
Auto merge of #52890 - djrenren:test-visibility, r=petrochenkov

Reexport tests without polluting namespaces

This should fix issue #52557.

Basically now we gensym a new name for the test function and reexport that.
That way the test function's reexport name can't conflict because it was impossible for the test author to write it down.
We then use a `use` statement to expose the original name using the original visibility.

5 years agoReading values should not be looking at the variant
Oliver Schneider [Thu, 2 Aug 2018 08:19:37 +0000 (10:19 +0200)]
Reading values should not be looking at the variant

5 years agorustbuild: fix local_rebuild
Marc-Antoine Perennou [Thu, 2 Aug 2018 06:49:36 +0000 (08:49 +0200)]
rustbuild: fix local_rebuild

If we detect a local rebuild (e.g. bootstrap compiler is the same version as target compiler), we set stage to 1.
When trying to build e.g. UnstableBook, we use Mode::ToolBootstrap and stage is 1.
Just allow Mode::ToolBootstrap and stagge != 0 if we are in a local_rebuild

Signed-off-by: Marc-Antoine Perennou <Marc-Antoine@Perennou.com>
5 years ago`Applicability`-ify librustc_lint
Zack M. Davis [Thu, 2 Aug 2018 03:30:04 +0000 (20:30 -0700)]
`Applicability`-ify librustc_lint

Andrew Chin recently pointed out (rust-lang/cargo#5846) that it's
surprising that `cargo fix` (now shipping with Cargo itself!) doesn't
fix very common lint warnings, which is as good of a reminder as any
that we should finish #50723.

5 years agoAuto merge of #52847 - upsuper:thread-stack-reserve, r=alexcrichton
bors [Thu, 2 Aug 2018 04:22:23 +0000 (04:22 +0000)]
Auto merge of #52847 - upsuper:thread-stack-reserve, r=alexcrichton

Don't commit thread stack on Windows

On Windows, there is a system level resource limitation called commit limit, which is roughly the sum of physical memory + paging files[1]. `CreateThread` by default commits the stack size[2], which unnecessarily takes such resource from the shared limit.

This PR changes it to only reserve the stack size rather than commit it. Reserved memory would only take the address space of the current process until it's actually accessed.

This should make the behavior on Windows match other platforms, and is also a pretty standard practice on Windows nowadays.

[1] https://blogs.technet.microsoft.com/markrussinovich/2008/11/17/pushing-the-limits-of-windows-virtual-memory/
[2] https://docs.microsoft.com/zh-cn/windows/desktop/api/processthreadsapi/nf-processthreadsapi-createthread

5 years agoAuto merge of #52787 - riscv-rust:riscv-rust-pr, r=alexcrichton
bors [Thu, 2 Aug 2018 02:24:15 +0000 (02:24 +0000)]
Auto merge of #52787 - riscv-rust:riscv-rust-pr, r=alexcrichton

Enable RISCV

- Enable LLVM backend.
- Implement call abi.
- Add built-in target riscv32imac-unknown-none.
- Enable CI.

5 years agoAuto merge of #52206 - RalfJung:zst-slices, r=alexcrichton
bors [Thu, 2 Aug 2018 00:14:21 +0000 (00:14 +0000)]
Auto merge of #52206 - RalfJung:zst-slices, r=alexcrichton

slices: fix ZST slice iterators making up pointers; debug_assert alignment in from_raw_parts

This fixes the problem that we are fabricating pointers out of thin air. I also managed to share more code between the mutable and shared iterators, while reducing the amount of macros.

I am not sure how useful it really is to add a `debug_assert!` in libcore. Everybody gets a release version of that anyway, right? Is there at least a CI job that runs the test suite with a debug version?

Fixes #42789

5 years agouse the same length computation everywhere
Ralf Jung [Mon, 30 Jul 2018 07:04:03 +0000 (09:04 +0200)]
use the same length computation everywhere

5 years agoIntroduce another way to compute the length, to fix position codegen regression
Ralf Jung [Sun, 29 Jul 2018 21:52:36 +0000 (23:52 +0200)]
Introduce another way to compute the length, to fix position codegen regression

5 years agosimplify len macro: No longer require the type
Ralf Jung [Sat, 28 Jul 2018 11:55:17 +0000 (13:55 +0200)]
simplify len macro: No longer require the type

Also use ident, not expr, to avoid accidental side-effects

5 years agomacro-inline len() and is_empty() to fix performance regressions
Ralf Jung [Sat, 28 Jul 2018 11:20:07 +0000 (13:20 +0200)]
macro-inline len() and is_empty() to fix performance regressions

This also changes the IR for nth(), but the new IR actually looks nicer that the old
(and it is one instruction shorter).

5 years agomake the code for nth closer to what it used to be
Ralf Jung [Thu, 19 Jul 2018 10:41:10 +0000 (12:41 +0200)]
make the code for nth closer to what it used to be

5 years agotest nth better
Ralf Jung [Thu, 19 Jul 2018 10:28:43 +0000 (12:28 +0200)]
test nth better

5 years agouse wrapping_offset; fix logic error in nth
Ralf Jung [Wed, 18 Jul 2018 16:29:44 +0000 (18:29 +0200)]
use wrapping_offset; fix logic error in nth

5 years agocomments
Ralf Jung [Wed, 11 Jul 2018 19:36:50 +0000 (21:36 +0200)]
comments

5 years agoslice iterators: ZST iterators no longer just "make up" addresses
Ralf Jung [Tue, 10 Jul 2018 07:01:10 +0000 (09:01 +0200)]
slice iterators: ZST iterators no longer just "make up" addresses

5 years agoAuto merge of #52958 - pietroalbini:rollup, r=pietroalbini
bors [Wed, 1 Aug 2018 19:54:06 +0000 (19:54 +0000)]
Auto merge of #52958 - pietroalbini:rollup, r=pietroalbini

Rollup of 15 pull requests

Successful merges:

 - #52793 (Add test for NLL: unexpected "free region `` does not outlive" error )
 - #52799 (Use BitVector for global sets of AttrId)
 - #52809 (Add test for unexpected region for local data ReStatic)
 - #52834 ([NLL] Allow conflicting borrows of promoted length zero arrays)
 - #52835 (Fix Alias intra doc ICE)
 - #52854 (fix memrchr in miri)
 - #52899 (tests/ui: Add missing mips{64} ignores)
 - #52908 (Use SetLenOnDrop in Vec::truncate())
 - #52915 (Don't count MIR locals as borrowed after StorageDead when finding locals live across a yield terminator)
 - #52926 (rustc: Trim down the `rust_2018_idioms` lint group)
 - #52930 (rustc_resolve: record single-segment extern crate import resolutions.)
 - #52939 (Make io::Read::read_to_end consider io::Take::limit)
 - #52942 (Another SmallVec.extend optimization)
 - #52947 (1.27 actually added the `armv5te-unknown-linux-musleabi` target)
 - #52954 (async can begin expressions)

Failed merges:

r? @ghost

5 years agoRollup merge of #52954 - cramertj:async-parse, r=petrochenkov
Pietro Albini [Wed, 1 Aug 2018 19:46:40 +0000 (21:46 +0200)]
Rollup merge of #52954 - cramertj:async-parse, r=petrochenkov

async can begin expressions

Fix https://github.com/rust-lang/rust/issues/52951

r? @petrochenkov

5 years agoRollup merge of #52947 - Susurrus:patch-1, r=alexcrichton
Pietro Albini [Wed, 1 Aug 2018 19:46:39 +0000 (21:46 +0200)]
Rollup merge of #52947 - Susurrus:patch-1, r=alexcrichton

1.27 actually added the `armv5te-unknown-linux-musleabi` target

The PR title says `armv5te-unknown-linux-musl`, but it looks like the final code merge renamed the target to `armv5te-unknown-linux-musleabi`. `rustup` reports this as correct as well.

The [Rust Platform Support](https://forge.rust-lang.org/platform-support.html) page needs this added as well, but I'm not certain what codebase that is generated from.

5 years agoRollup merge of #52942 - llogiq:smallvec-opt, r=Mark-Simulacrum
Pietro Albini [Wed, 1 Aug 2018 19:46:37 +0000 (21:46 +0200)]
Rollup merge of #52942 - llogiq:smallvec-opt, r=Mark-Simulacrum

Another SmallVec.extend optimization

This improves SmallVec.extend even more over #52859 while making the code easier to read.

Before

```
test small_vec::tests::fill_small_vec_1_10_with_cap  ... bench:          31 ns/iter (+/- 5)
test small_vec::tests::fill_small_vec_1_10_wo_cap    ... bench:          70 ns/iter (+/- 4)
test small_vec::tests::fill_small_vec_1_50_with_cap  ... bench:          36 ns/iter (+/- 3)
test small_vec::tests::fill_small_vec_1_50_wo_cap    ... bench:         256 ns/iter (+/- 17)
test small_vec::tests::fill_small_vec_32_10_with_cap ... bench:          31 ns/iter (+/- 5)
test small_vec::tests::fill_small_vec_32_10_wo_cap   ... bench:          26 ns/iter (+/- 1)
test small_vec::tests::fill_small_vec_32_50_with_cap ... bench:          49 ns/iter (+/- 4)
test small_vec::tests::fill_small_vec_32_50_wo_cap   ... bench:         219 ns/iter (+/- 11)
test small_vec::tests::fill_small_vec_8_10_with_cap  ... bench:          32 ns/iter (+/- 2)
test small_vec::tests::fill_small_vec_8_10_wo_cap    ... bench:          61 ns/iter (+/- 12)
test small_vec::tests::fill_small_vec_8_50_with_cap  ... bench:          37 ns/iter (+/- 3)
test small_vec::tests::fill_small_vec_8_50_wo_cap    ... bench:         210 ns/iter (+/- 10)
```

After:

```
test small_vec::tests::fill_small_vec_1_10_wo_cap    ... bench:          31 ns/iter (+/- 3)
test small_vec::tests::fill_small_vec_1_50_with_cap  ... bench:          39 ns/iter (+/- 4)
test small_vec::tests::fill_small_vec_1_50_wo_cap    ... bench:          35 ns/iter (+/- 4)
test small_vec::tests::fill_small_vec_32_10_with_cap ... bench:          37 ns/iter (+/- 3)
test small_vec::tests::fill_small_vec_32_10_wo_cap   ... bench:          32 ns/iter (+/- 2)
test small_vec::tests::fill_small_vec_32_50_with_cap ... bench:          52 ns/iter (+/- 4)
test small_vec::tests::fill_small_vec_32_50_wo_cap   ... bench:          46 ns/iter (+/- 0)
test small_vec::tests::fill_small_vec_8_10_with_cap  ... bench:          35 ns/iter (+/- 4)
test small_vec::tests::fill_small_vec_8_10_wo_cap    ... bench:          31 ns/iter (+/- 0)
test small_vec::tests::fill_small_vec_8_50_with_cap  ... bench:          40 ns/iter (+/- 15)
test small_vec::tests::fill_small_vec_8_50_wo_cap    ... bench:          36 ns/iter (+/- 2)
```

5 years agoRollup merge of #52939 - ljedrz:fix_51746, r=kennytm
Pietro Albini [Wed, 1 Aug 2018 19:46:36 +0000 (21:46 +0200)]
Rollup merge of #52939 - ljedrz:fix_51746, r=kennytm

Make io::Read::read_to_end consider io::Take::limit

Add a custom implementation of `io::Read::read_to_end` for `io::Take` that doesn't reserve the default 32 bytes but rather `Take::limit` if `Take::limit < 32`.

It's a conservative adjustment that preserves the default behavior for `Take::limit >= 32`.

Fixes #51746.

5 years agoRollup merge of #52930 - eddyb:issue-52489, r=cramertj
Pietro Albini [Wed, 1 Aug 2018 19:46:35 +0000 (21:46 +0200)]
Rollup merge of #52930 - eddyb:issue-52489, r=cramertj

rustc_resolve: record single-segment extern crate import resolutions.

Fixes #52489 by recording special-cased single-segment imports for later (e.g. stability) checks.

cc @alexcrichton @Mark-Simulacrum @petrochenkov

Does this need to be backported?

5 years agoRollup merge of #52926 - alexcrichton:trim-idioms-lints, r=oli-obk
Pietro Albini [Wed, 1 Aug 2018 19:46:33 +0000 (21:46 +0200)]
Rollup merge of #52926 - alexcrichton:trim-idioms-lints, r=oli-obk

rustc: Trim down the `rust_2018_idioms` lint group

These migration lints aren't all up to par in terms of a good migration
experience. Some, like `unreachable_pub`, hit bugs like #52665 and unprepared
macros to be handled enough of the time. Others like linting against
`#[macro_use]` are swimming upstream in an ecosystem that's not quite ready (and
slightly buggy pending a few current PRs).

The general idea is that we will continue to recommend the `rust_2018_idioms`
lint group as part of the transition guide (as an optional step) but we'll be
much more selective about which lints make it into this group. Only those with a
strong track record of not causing too much churn will make the cut.

cc #52679

5 years agoRollup merge of #52915 - Zoxc:refine-gen-borrow-analysis, r=eddyb
Pietro Albini [Wed, 1 Aug 2018 19:46:32 +0000 (21:46 +0200)]
Rollup merge of #52915 - Zoxc:refine-gen-borrow-analysis, r=eddyb

Don't count MIR locals as borrowed after StorageDead when finding locals live across a yield terminator

This should fix https://github.com/rust-lang/rust/issues/52792.

r? @eddyb

5 years agoRollup merge of #52908 - lnicola:vec-truncate-opt, r=alexcrichton
Pietro Albini [Wed, 1 Aug 2018 19:46:31 +0000 (21:46 +0200)]
Rollup merge of #52908 - lnicola:vec-truncate-opt, r=alexcrichton

Use SetLenOnDrop in Vec::truncate()

This avoids a redundant length check in some cases when calling
`Vec::truncate` or `Vec::clear`.

Fixes #51802

Note that the generated code still seems suboptimal. I tested with the following functions:

```rust
#[no_mangle]
pub extern fn foo(x: &mut Vec<u8>) {
    x.clear();
}

#[no_mangle]
pub extern fn bar(x: &mut Vec<u8>) {
    x.truncate(5);
}

#[no_mangle]
pub extern fn baz(x: &mut Vec<u8>, n: usize) {
    x.truncate(n);
}

#[no_mangle]
pub extern fn foo_string(x: &mut Vec<String>) {
    x.clear();
}

#[no_mangle]
pub extern fn bar_string(x: &mut Vec<String>) {
    x.truncate(5);
}

#[no_mangle]
pub extern fn baz_string(x: &mut Vec<String>, n: usize) {
    x.truncate(n);
}
```

<details>
  <summary>Old output</summary>

```asm
00000000000460a0 <foo>:
   460a0:       48 83 7f 10 00          cmpq   $0x0,0x10(%rdi)
   460a5:       74 08                   je     460af <foo+0xf>
   460a7:       48 c7 47 10 00 00 00    movq   $0x0,0x10(%rdi)
   460ae:       00
   460af:       c3                      retq

00000000000460b0 <bar>:
   460b0:       48 83 7f 10 06          cmpq   $0x6,0x10(%rdi)
   460b5:       72 08                   jb     460bf <bar+0xf>
   460b7:       48 c7 47 10 05 00 00    movq   $0x5,0x10(%rdi)
   460be:       00
   460bf:       c3                      retq

00000000000460c0 <baz>:
   460c0:       48 39 77 10             cmp    %rsi,0x10(%rdi)
   460c4:       76 04                   jbe    460ca <baz+0xa>
   460c6:       48 89 77 10             mov    %rsi,0x10(%rdi)
   460ca:       c3                      retq
   460cb:       0f 1f 44 00 00          nopl   0x0(%rax,%rax,1)

00000000000460d0 <foo_string>:
   460d0:       41 57                   push   %r15
   460d2:       41 56                   push   %r14
   460d4:       53                      push   %rbx
   460d5:       48 8b 47 10             mov    0x10(%rdi),%rax
   460d9:       48 85 c0                test   %rax,%rax
   460dc:       74 4a                   je     46128 <foo_string+0x58>
   460de:       49 89 fe                mov    %rdi,%r14
   460e1:       48 8b 0f                mov    (%rdi),%rcx
   460e4:       48 8d 14 40             lea    (%rax,%rax,2),%rdx
   460e8:       48 8d 58 ff             lea    -0x1(%rax),%rbx
   460ec:       4c 8d 3c d1             lea    (%rcx,%rdx,8),%r15
   460f0:       49 83 c7 f0             add    $0xfffffffffffffff0,%r15
   460f4:       66 2e 0f 1f 84 00 00    nopw   %cs:0x0(%rax,%rax,1)
   460fb:       00 00 00
   460fe:       66 90                   xchg   %ax,%ax
   46100:       49 89 5e 10             mov    %rbx,0x10(%r14)
   46104:       49 8b 37                mov    (%r15),%rsi
   46107:       48 85 f6                test   %rsi,%rsi
   4610a:       74 0e                   je     4611a <foo_string+0x4a>
   4610c:       49 8b 7f f8             mov    -0x8(%r15),%rdi
   46110:       ba 01 00 00 00          mov    $0x1,%edx
   46115:       e8 a6 e9 ff ff          callq  44ac0 <__rust_dealloc@plt>
   4611a:       48 83 c3 ff             add    $0xffffffffffffffff,%rbx
   4611e:       49 83 c7 e8             add    $0xffffffffffffffe8,%r15
   46122:       48 83 fb ff             cmp    $0xffffffffffffffff,%rbx
   46126:       75 d8                   jne    46100 <foo_string+0x30>
   46128:       5b                      pop    %rbx
   46129:       41 5e                   pop    %r14
   4612b:       41 5f                   pop    %r15
   4612d:       c3                      retq
   4612e:       66 90                   xchg   %ax,%ax

0000000000046130 <bar_string>:
   46130:       41 57                   push   %r15
   46132:       41 56                   push   %r14
   46134:       53                      push   %rbx
   46135:       4c 8b 7f 10             mov    0x10(%rdi),%r15
   46139:       49 83 ff 06             cmp    $0x6,%r15
   4613d:       72 49                   jb     46188 <bar_string+0x58>
   4613f:       49 89 fe                mov    %rdi,%r14
   46142:       48 8b 07                mov    (%rdi),%rax
   46145:       4b 8d 0c 7f             lea    (%r15,%r15,2),%rcx
   46149:       48 8d 1c c8             lea    (%rax,%rcx,8),%rbx
   4614d:       48 83 c3 f0             add    $0xfffffffffffffff0,%rbx
   46151:       66 2e 0f 1f 84 00 00    nopw   %cs:0x0(%rax,%rax,1)
   46158:       00 00 00
   4615b:       0f 1f 44 00 00          nopl   0x0(%rax,%rax,1)
   46160:       49 83 c7 ff             add    $0xffffffffffffffff,%r15
   46164:       4d 89 7e 10             mov    %r15,0x10(%r14)
   46168:       48 8b 33                mov    (%rbx),%rsi
   4616b:       48 85 f6                test   %rsi,%rsi
   4616e:       74 0e                   je     4617e <bar_string+0x4e>
   46170:       48 8b 7b f8             mov    -0x8(%rbx),%rdi
   46174:       ba 01 00 00 00          mov    $0x1,%edx
   46179:       e8 42 e9 ff ff          callq  44ac0 <__rust_dealloc@plt>
   4617e:       48 83 c3 e8             add    $0xffffffffffffffe8,%rbx
   46182:       49 83 ff 05             cmp    $0x5,%r15
   46186:       77 d8                   ja     46160 <bar_string+0x30>
   46188:       5b                      pop    %rbx
   46189:       41 5e                   pop    %r14
   4618b:       41 5f                   pop    %r15
   4618d:       c3                      retq
   4618e:       66 90                   xchg   %ax,%ax

0000000000046190 <baz_string>:
   46190:       41 57                   push   %r15
   46192:       41 56                   push   %r14
   46194:       41 54                   push   %r12
   46196:       53                      push   %rbx
   46197:       50                      push   %rax
   46198:       4c 8b 67 10             mov    0x10(%rdi),%r12
   4619c:       49 39 f4                cmp    %rsi,%r12
   4619f:       76 46                   jbe    461e7 <baz_string+0x57>
   461a1:       49 89 f6                mov    %rsi,%r14
   461a4:       49 89 ff                mov    %rdi,%r15
   461a7:       48 8b 07                mov    (%rdi),%rax
   461aa:       4b 8d 0c 64             lea    (%r12,%r12,2),%rcx
   461ae:       48 8d 1c c8             lea    (%rax,%rcx,8),%rbx
   461b2:       48 83 c3 f0             add    $0xfffffffffffffff0,%rbx
   461b6:       66 2e 0f 1f 84 00 00    nopw   %cs:0x0(%rax,%rax,1)
   461bd:       00 00 00
   461c0:       49 83 c4 ff             add    $0xffffffffffffffff,%r12
   461c4:       4d 89 67 10             mov    %r12,0x10(%r15)
   461c8:       48 8b 33                mov    (%rbx),%rsi
   461cb:       48 85 f6                test   %rsi,%rsi
   461ce:       74 0e                   je     461de <baz_string+0x4e>
   461d0:       48 8b 7b f8             mov    -0x8(%rbx),%rdi
   461d4:       ba 01 00 00 00          mov    $0x1,%edx
   461d9:       e8 e2 e8 ff ff          callq  44ac0 <__rust_dealloc@plt>
   461de:       48 83 c3 e8             add    $0xffffffffffffffe8,%rbx
   461e2:       4d 39 f4                cmp    %r14,%r12
   461e5:       77 d9                   ja     461c0 <baz_string+0x30>
   461e7:       48 83 c4 08             add    $0x8,%rsp
   461eb:       5b                      pop    %rbx
   461ec:       41 5c                   pop    %r12
   461ee:       41 5e                   pop    %r14
   461f0:       41 5f                   pop    %r15
   461f2:       c3                      retq
   461f3:       90                      nop
   461f4:       66 2e 0f 1f 84 00 00    nopw   %cs:0x0(%rax,%rax,1)
   461fb:       00 00 00
   461fe:       66 90                   xchg   %ax,%ax
```
</details>

<details>
  <summary>New output</summary>

```asm
0000000000084d10 <foo>:
   84d10:       48 c7 47 10 00 00 00    movq   $0x0,0x10(%rdi)
   84d17:       00
   84d18:       c3                      retq
   84d19:       0f 1f 80 00 00 00 00    nopl   0x0(%rax)

0000000000084d20 <bar>:
   84d20:       48 8b 47 10             mov    0x10(%rdi),%rax
   84d24:       48 83 f8 05             cmp    $0x5,%rax
   84d28:       b9 05 00 00 00          mov    $0x5,%ecx
   84d2d:       48 0f 42 c8             cmovb  %rax,%rcx
   84d31:       48 89 4f 10             mov    %rcx,0x10(%rdi)
   84d35:       c3                      retq
   84d36:       66 2e 0f 1f 84 00 00    nopw   %cs:0x0(%rax,%rax,1)
   84d3d:       00 00 00

0000000000084d40 <baz>:
   84d40:       48 8b 47 10             mov    0x10(%rdi),%rax
   84d44:       48 39 f0                cmp    %rsi,%rax
   84d47:       48 0f 47 c6             cmova  %rsi,%rax
   84d4b:       48 89 47 10             mov    %rax,0x10(%rdi)
   84d4f:       c3                      retq

0000000000084d50 <foo_string>:
   84d50:       41 57                   push   %r15
   84d52:       41 56                   push   %r14
   84d54:       53                      push   %rbx
   84d55:       49 89 fe                mov    %rdi,%r14
   84d58:       4c 8b 7f 10             mov    0x10(%rdi),%r15
   84d5c:       4d 85 ff                test   %r15,%r15
   84d5f:       74 2f                   je     84d90 <foo_string+0x40>
   84d61:       49 8b 06                mov    (%r14),%rax
   84d64:       4b 8d 0c 7f             lea    (%r15,%r15,2),%rcx
   84d68:       48 8d 1c c8             lea    (%rax,%rcx,8),%rbx
   84d6c:       48 83 c3 f0             add    $0xfffffffffffffff0,%rbx
   84d70:       48 8b 33                mov    (%rbx),%rsi
   84d73:       48 85 f6                test   %rsi,%rsi
   84d76:       74 0e                   je     84d86 <foo_string+0x36>
   84d78:       48 8b 7b f8             mov    -0x8(%rbx),%rdi
   84d7c:       ba 01 00 00 00          mov    $0x1,%edx
   84d81:       e8 1a b1 ff ff          callq  7fea0 <__rust_dealloc@plt>
   84d86:       48 83 c3 e8             add    $0xffffffffffffffe8,%rbx
   84d8a:       49 83 c7 ff             add    $0xffffffffffffffff,%r15
   84d8e:       75 e0                   jne    84d70 <foo_string+0x20>
   84d90:       49 c7 46 10 00 00 00    movq   $0x0,0x10(%r14)
   84d97:       00
   84d98:       5b                      pop    %rbx
   84d99:       41 5e                   pop    %r14
   84d9b:       41 5f                   pop    %r15
   84d9d:       c3                      retq
   84d9e:       66 90                   xchg   %ax,%ax

0000000000084da0 <bar_string>:
   84da0:       41 57                   push   %r15
   84da2:       41 56                   push   %r14
   84da4:       53                      push   %rbx
   84da5:       49 89 fe                mov    %rdi,%r14
   84da8:       4c 8b 7f 10             mov    0x10(%rdi),%r15
   84dac:       49 83 ff 06             cmp    $0x6,%r15
   84db0:       72 44                   jb     84df6 <bar_string+0x56>
   84db2:       49 8b 06                mov    (%r14),%rax
   84db5:       4b 8d 0c 7f             lea    (%r15,%r15,2),%rcx
   84db9:       48 8d 1c c8             lea    (%rax,%rcx,8),%rbx
   84dbd:       48 83 c3 f0             add    $0xfffffffffffffff0,%rbx
   84dc1:       49 83 c7 fb             add    $0xfffffffffffffffb,%r15
   84dc5:       66 2e 0f 1f 84 00 00    nopw   %cs:0x0(%rax,%rax,1)
   84dcc:       00 00 00
   84dcf:       90                      nop
   84dd0:       48 8b 33                mov    (%rbx),%rsi
   84dd3:       48 85 f6                test   %rsi,%rsi
   84dd6:       74 0e                   je     84de6 <bar_string+0x46>
   84dd8:       48 8b 7b f8             mov    -0x8(%rbx),%rdi
   84ddc:       ba 01 00 00 00          mov    $0x1,%edx
   84de1:       e8 ba b0 ff ff          callq  7fea0 <__rust_dealloc@plt>
   84de6:       48 83 c3 e8             add    $0xffffffffffffffe8,%rbx
   84dea:       49 83 c7 ff             add    $0xffffffffffffffff,%r15
   84dee:       75 e0                   jne    84dd0 <bar_string+0x30>
   84df0:       41 bf 05 00 00 00       mov    $0x5,%r15d
   84df6:       4d 89 7e 10             mov    %r15,0x10(%r14)
   84dfa:       5b                      pop    %rbx
   84dfb:       41 5e                   pop    %r14
   84dfd:       41 5f                   pop    %r15
   84dff:       c3                      retq

0000000000084e00 <baz_string>:
   84e00:       41 57                   push   %r15
   84e02:       41 56                   push   %r14
   84e04:       41 54                   push   %r12
   84e06:       53                      push   %rbx
   84e07:       50                      push   %rax
   84e08:       49 89 ff                mov    %rdi,%r15
   84e0b:       48 8b 47 10             mov    0x10(%rdi),%rax
   84e0f:       49 89 c4                mov    %rax,%r12
   84e12:       49 29 f4                sub    %rsi,%r12
   84e15:       76 3c                   jbe    84e53 <baz_string+0x53>
   84e17:       49 89 f6                mov    %rsi,%r14
   84e1a:       49 8b 0f                mov    (%r15),%rcx
   84e1d:       48 8d 04 40             lea    (%rax,%rax,2),%rax
   84e21:       48 8d 1c c1             lea    (%rcx,%rax,8),%rbx
   84e25:       48 83 c3 f0             add    $0xfffffffffffffff0,%rbx
   84e29:       0f 1f 80 00 00 00 00    nopl   0x0(%rax)
   84e30:       48 8b 33                mov    (%rbx),%rsi
   84e33:       48 85 f6                test   %rsi,%rsi
   84e36:       74 0e                   je     84e46 <baz_string+0x46>
   84e38:       48 8b 7b f8             mov    -0x8(%rbx),%rdi
   84e3c:       ba 01 00 00 00          mov    $0x1,%edx
   84e41:       e8 5a b0 ff ff          callq  7fea0 <__rust_dealloc@plt>
   84e46:       48 83 c3 e8             add    $0xffffffffffffffe8,%rbx
   84e4a:       49 83 c4 ff             add    $0xffffffffffffffff,%r12
   84e4e:       75 e0                   jne    84e30 <baz_string+0x30>
   84e50:       4c 89 f0                mov    %r14,%rax
   84e53:       49 89 47 10             mov    %rax,0x10(%r15)
   84e57:       48 83 c4 08             add    $0x8,%rsp
   84e5b:       5b                      pop    %rbx
   84e5c:       41 5c                   pop    %r12
   84e5e:       41 5e                   pop    %r14
   84e60:       41 5f                   pop    %r15
   84e62:       c3                      retq
   84e63:       90                      nop
   84e64:       66 2e 0f 1f 84 00 00    nopw   %cs:0x0(%rax,%rax,1)
   84e6b:       00 00 00
   84e6e:       66 90                   xchg   %ax,%ax
```
</details>

For calling `truncate` with non-zero lengths on non-`Drop` types, it seems that a redundant load and comparison gets replaced with an awkward sequence with a conditional move. In the unknown length case, the new code is no longer awkward.

Maybe someone moderately proficient at assembly could tell if this looks like a win or not.

---

This came up when discussing replacing `unsafe { vec.set_len(0) }` with `vec.clear()` in a project where the author was worried about potential performance degradation. It might be worth replacing some unsafe code, even it it's trivial to see that it's actually safe.

5 years agoRollup merge of #52899 - draganmladjenovic:ui_tests64, r=alexcrichton
Pietro Albini [Wed, 1 Aug 2018 19:46:30 +0000 (21:46 +0200)]
Rollup merge of #52899 - draganmladjenovic:ui_tests64, r=alexcrichton

tests/ui: Add missing mips{64} ignores

5 years agoRollup merge of #52854 - RalfJung:memrchr, r=Kimundi
Pietro Albini [Wed, 1 Aug 2018 19:46:28 +0000 (21:46 +0200)]
Rollup merge of #52854 - RalfJung:memrchr, r=Kimundi

fix memrchr in miri

The previous PR https://github.com/rust-lang/rust/pull/52744 was not enough because it assumed that the split between the `mid` and `end` parts returned by `align_to` was aligned. But really the only guarantee we have is that the `mid` part is aligned, so make use of that.

5 years agoRollup merge of #52835 - GuillaumeGomez:ice-rustdoc-links, r=eddyb
Pietro Albini [Wed, 1 Aug 2018 19:46:27 +0000 (21:46 +0200)]
Rollup merge of #52835 - GuillaumeGomez:ice-rustdoc-links, r=eddyb

Fix Alias intra doc ICE

Fixes #52611.

cc @QuietMisdreavus

r? @varkor

5 years agoRollup merge of #52834 - matthewjasper:allow-zst-conflicts, r=pnkfelix
Pietro Albini [Wed, 1 Aug 2018 19:46:26 +0000 (21:46 +0200)]
Rollup merge of #52834 - matthewjasper:allow-zst-conflicts, r=pnkfelix

[NLL] Allow conflicting borrows of promoted length zero arrays

This is currently overkill as there's no way to create two conflicting borrows of any promoted.
It is possible that the following code might not fail due to const eval in the future (@oli-obk?). In which case either the array marked needs to not be promoted, or to be checked for conflicts

```rust
static mut A: () = {
    let mut y = None;
    let z;
    let mut done_y = false;
    loop {
        let x = &mut [1];  // < this array
        if done_y {
            z = x;
            break;
        }
        y = Some(x);
        done_y = true;
    }
    some_const_fn(y, z); // some_const_fn expects that y to not alias z.
};
```

r? @pnkfelix  @nikomatsakis

closes #52671
cc #51823

5 years agoRollup merge of #52809 - davidtwco:issue-49579, r=pnkfelix
Pietro Albini [Wed, 1 Aug 2018 19:46:25 +0000 (21:46 +0200)]
Rollup merge of #52809 - davidtwco:issue-49579, r=pnkfelix

Add test for unexpected region for local data ReStatic

Fixes #49579.

r? @pnkfelix @nikomatsakis

5 years agoRollup merge of #52799 - Mark-Simulacrum:attr-id-bitvecs, r=michaelwoerister
Pietro Albini [Wed, 1 Aug 2018 19:46:23 +0000 (21:46 +0200)]
Rollup merge of #52799 - Mark-Simulacrum:attr-id-bitvecs, r=michaelwoerister

Use BitVector for global sets of AttrId

5 years agoRollup merge of #52793 - davidtwco:issue-49824, r=pnkfelix
Pietro Albini [Wed, 1 Aug 2018 19:46:22 +0000 (21:46 +0200)]
Rollup merge of #52793 - davidtwco:issue-49824, r=pnkfelix

Add test for NLL: unexpected "free region `` does not outlive" error

Fixes #49824.

r? @pnkfelix @nikomatsakis

5 years agoUse the correct allow
John Renner [Wed, 1 Aug 2018 19:33:10 +0000 (12:33 -0700)]
Use the correct allow

5 years agoAllow test imports to go unused
John Renner [Wed, 1 Aug 2018 18:28:08 +0000 (11:28 -0700)]
Allow test imports to go unused

5 years agoSwitch to bootstrapping from 1.29 beta
Mark Rousskov [Wed, 1 Aug 2018 13:37:38 +0000 (07:37 -0600)]
Switch to bootstrapping from 1.29 beta

5 years agoAuto merge of #51609 - dscorbett:is_numeric, r=alexcrichton
bors [Wed, 1 Aug 2018 17:44:25 +0000 (17:44 +0000)]
Auto merge of #51609 - dscorbett:is_numeric, r=alexcrichton

Treat gc=No characters as numeric

[`char::is_numeric`](https://doc.rust-lang.org/std/primitive.char.html#method.is_numeric) and [`char::is_alphanumeric`](https://doc.rust-lang.org/std/primitive.char.html#method.is_alphanumeric) are documented to be defined “in terms of the Unicode General Categories 'Nd', 'Nl', 'No'”, but unicode.py does not group 'No' with the other 'N' categories. These functions therefore currently return `false` for characters like ⟨¾⟩ and ⟨①⟩.

5 years agoasync can begin expressions
Taylor Cramer [Wed, 1 Aug 2018 16:50:15 +0000 (09:50 -0700)]
async can begin expressions

5 years agoFix bug in test pointed out during review.
Felix S. Klock II [Mon, 30 Jul 2018 23:10:06 +0000 (01:10 +0200)]
Fix bug in test pointed out during review.

5 years agoExpand long-live-borrows-in-boxes test to include simplier illustrative cases.
Felix S. Klock II [Mon, 30 Jul 2018 14:17:04 +0000 (16:17 +0200)]
Expand long-live-borrows-in-boxes test to include simplier illustrative cases.

After talking about the PR with eddyb, I decided it was best to try to
have some test cases that simplify the problem down to its core, so
that people trying to understand what the issue is here will see those
core examples first.

5 years agoTest for (previously uncaught) infinite loop identified by matthewjasper.
Felix S. Klock II [Mon, 30 Jul 2018 13:38:18 +0000 (15:38 +0200)]
Test for (previously uncaught) infinite loop identified by matthewjasper.

5 years agoRegression tests.
Felix S. Klock II [Fri, 27 Jul 2018 13:52:17 +0000 (15:52 +0200)]
Regression tests.

5 years agominor fallout from the change.
Felix S. Klock II [Fri, 27 Jul 2018 15:58:17 +0000 (17:58 +0200)]
minor fallout from the change.

(Presumably the place that borrow_check ends up reporting for the
error about is no longer the root `Local` itself, and thus the note
diagnostic here stops firing.)

5 years agoErrors are more specific in cases where borrows are used in future iterations of...
David Wood [Wed, 1 Aug 2018 15:02:43 +0000 (17:02 +0200)]
Errors are more specific in cases where borrows are used in future iterations of loops.

5 years agoSpecial-case `Box` in `rustc_mir::borrow_check`.
Felix S. Klock II [Thu, 26 Jul 2018 20:29:50 +0000 (22:29 +0200)]
Special-case `Box` in `rustc_mir::borrow_check`.

This should address issue 45696.

Since we know dropping a box will not access any `&mut` or `&`
references, it is safe to model its destructor as only touching the
contents *owned* by the box.

Note: At some point we may want to generalize this machinery to other
reference and collection types that are "pure" in the same sense as
box. If we add a `&move` reference type, it would probably also fall
into this branch of code. But for the short term, we will be
conservative and restrict this change to `Box<T>` alone.

The code works by recursively descending a deref of the `Box`. We
prevent `visit_terminator_drop` infinite-loop (which can arise in a
very obscure scenario) via a linked-list of seen types.

Note: A similar style stack-only linked-list definition can be found
in `rustc_mir::borrow_check::places_conflict`. It might be good at
some point in the future to unify the two types and put the resulting
definition into `librustc_data_structures/`.

----

One final note: Review feedback led to significant simplification of
logic here.

During review, eddyb RalfJung and I uncovered the heart of why I
needed a so-called "step 2" aka the Shallow Write to the Deref of the
box. It was because the `visit_terminator_drop`, in its base case,
will not emit any write at all (shallow or deep) to a place unless
that place has a need_drop.

So I was encoding a Shallow Write by hand for a `Box<T>`, as a
separate step from recursively descending through `*a_box` (which was
at the time known as "step 1"; it is now the *only* step, apart from
the change to the base case for `visit_terminator_drop` that this
commit now has encoded).

eddyb aruged that *something* should be emitting some sort of write in
the base case here (even a shallow one), of the dropped place, since
by analogy we also emit a write when you *move* a place. That led
to the revision here in this commit.

 * (Its possible that this desired write should be attached in some
   manner to StorageDead instead of Drop. But in this PR, I tried to
   leave the StorageDead logic alone and focus my attention solely on
   how Drop(x) is modelled in MIR-borrowck.)

5 years agoAdded test for #49824.
David Wood [Fri, 27 Jul 2018 22:09:23 +0000 (00:09 +0200)]
Added test for #49824.

5 years ago1.27 actually added the `armv5te-unknown-linux-musleabi` target
Bryant Mairs [Wed, 1 Aug 2018 15:24:18 +0000 (08:24 -0700)]
1.27 actually added the `armv5te-unknown-linux-musleabi` target

The PR title says `armv5te-unknown-linux-musl`, but it looks like the final code merge renamed the target to `armv5te-unknown-linux-musleabi`. `rustup` reports this as correct as well.

The [Rust Platform Support](https://forge.rust-lang.org/platform-support.html) page needs this added as well, but I'm not certain what codebase that is generated from.

5 years agorustc: Trim down the `rust_2018_idioms` lint group
Alex Crichton [Tue, 31 Jul 2018 22:45:11 +0000 (15:45 -0700)]
rustc: Trim down the `rust_2018_idioms` lint group

These migration lints aren't all up to par in terms of a good migration
experience. Some, like `unreachable_pub`, hit bugs like #52665 and unprepared
macros to be handled enough of the time. Others like linting against
`#[macro_use]` are swimming upstream in an ecosystem that's not quite ready (and
slightly buggy pending a few current PRs).

The general idea is that we will continue to recommend the `rust_2018_idioms`
lint group as part of the transition guide (as an optional step) but we'll be
much more selective about which lints make it into this group. Only those with a
strong track record of not causing too much churn will make the cut.

cc #52679