]> git.lizzy.rs Git - rust.git/log
rust.git
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 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 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 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 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 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

5 years ago[RISCV] Disable c extension and atomic_cas.
David Craven [Sat, 28 Jul 2018 17:20:14 +0000 (19:20 +0200)]
[RISCV] Disable c extension and atomic_cas.

5 years ago[RISCV] Enable CI.
David Craven [Thu, 26 Jul 2018 11:40:40 +0000 (13:40 +0200)]
[RISCV] Enable CI.

5 years ago[RISCV] Add built-in target riscv32imac-unknown-none-elf.
David Craven [Thu, 26 Jul 2018 12:01:24 +0000 (14:01 +0200)]
[RISCV] Add built-in target riscv32imac-unknown-none-elf.

5 years ago[RISCV] Implement call abi.
David Craven [Tue, 24 Jul 2018 10:04:17 +0000 (12:04 +0200)]
[RISCV] Implement call abi.

5 years ago[RISCV] Enable LLVM backend.
David Craven [Tue, 24 Jul 2018 10:03:28 +0000 (12:03 +0200)]
[RISCV] Enable LLVM backend.

5 years agoSplit out growth functionality into BitVector type
Mark Rousskov [Mon, 30 Jul 2018 14:58:14 +0000 (08:58 -0600)]
Split out growth functionality into BitVector type

5 years agoSwitch syntax attribute tracking to BitVector
Mark Rousskov [Mon, 30 Jul 2018 14:39:03 +0000 (08:39 -0600)]
Switch syntax attribute tracking to BitVector

5 years agoAuto merge of #52474 - alexcrichton:better-lto-error, r=eddyb
bors [Wed, 1 Aug 2018 11:38:20 +0000 (11:38 +0000)]
Auto merge of #52474 - alexcrichton:better-lto-error, r=eddyb

rustc: Handle linker diagnostics from LLVM

Previously linker diagnostic were being hidden when two modules were linked
together but failed to link. This commit fixes the situation by ensuring that we
have a diagnostic handler installed and also adds support for handling linker
diagnostics.

5 years agoImplement custom read_to_end for io::Take
ljedrz [Wed, 1 Aug 2018 08:23:07 +0000 (10:23 +0200)]
Implement custom read_to_end for io::Take

5 years agoAnother SmallVec.extend optimization
Andre Bogus [Wed, 1 Aug 2018 11:00:37 +0000 (13:00 +0200)]
Another SmallVec.extend optimization

This improves SmallVec.extend even more over #52859

Before (as of #52859):

```
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 agoAuto merge of #52937 - pietroalbini:rollup, r=pietroalbini
bors [Wed, 1 Aug 2018 08:41:36 +0000 (08:41 +0000)]
Auto merge of #52937 - pietroalbini:rollup, r=pietroalbini

Rollup of 30 pull requests

Successful merges:

 - #52340 (Document From trait implementations for OsStr, OsString, CString, and CStr)
 - #52628 (Cleanup some rustdoc code)
 - #52732 (Remove unstable and deprecated APIs)
 - #52745 (Update clippy to latest master)
 - #52771 (Clarify thread::park semantics)
 - #52778 (Improve readability of serialize.rs)
 - #52810 ([NLL] Don't make "fake" match variables mutable)
 - #52821 (pretty print for std::collections::vecdeque)
 - #52822 (Fix From<LocalWaker>)
 - #52824 (Fix -Wpessimizing-move warnings in rustllvm/PassWrapper)
 - #52825 (Make sure #47772 does not regress)
 - #52831 (remove references to AUTHORS.txt file)
 - #52842 (update comment)
 - #52846 (Add timeout to use of `curl` in bootstrap.py.)
 - #52851 (Make the tool_lints actually usable)
 - #52853 (Improve bootstrap help on stages)
 - #52859 (Use Vec::extend in SmallVec::extend when applicable)
 - #52861 (Add targets for HermitCore (https://hermitcore.org) to the Rust compiler and port libstd to it.)
 - #52867 (releases.md: fix 2 typos)
 - #52870 (Implement Unpin for FutureObj and LocalFutureObj)
 - #52876 (run-pass/const-endianness: negate before to_le())
 - #52878 (Fix wrong issue number in the test name)
 - #52883 (Include lifetime in mutability suggestion in NLL messages)
 - #52888 (Use suggestions for shell format arguments)
 - #52904 (NLL: sort diagnostics by span)
 - #52905 (Fix a typo in unsize.rs)
 - #52907 (NLL: On "cannot move out of type" error, print original before rewrite)
 - #52914 (Only run the sparc-abi test on sparc)
 - #52918 (Backport 1.27.2 release notes)
 - #52929 (Update compatibility note for 1.28.0 to be correct)

Failed merges:

r? @ghost

5 years agoRollup merge of #52929 - Havvy:patch-1, r=alexcrichton
Pietro Albini [Wed, 1 Aug 2018 08:13:10 +0000 (10:13 +0200)]
Rollup merge of #52929 - Havvy:patch-1, r=alexcrichton

Update compatibility note for 1.28.0 to be correct

You can still put implementations on `dyn Trait + Send + Send`, but it'd be the same as putting them on `dyn Trait + Send`. This is why the error is that there are duplicate definitions in the example.

5 years agoRollup merge of #52918 - pietroalbini:1.27.2-notes, r=Mark-Simulacrum
Pietro Albini [Wed, 1 Aug 2018 08:13:08 +0000 (10:13 +0200)]
Rollup merge of #52918 - pietroalbini:1.27.2-notes, r=Mark-Simulacrum

Backport 1.27.2 release notes

r? @Mark-Simulacrum

5 years agoRollup merge of #52914 - nagisa:sparc-is-sparc’s-own-business, r=alexcrichton
Pietro Albini [Wed, 1 Aug 2018 08:13:07 +0000 (10:13 +0200)]
Rollup merge of #52914 - nagisa:sparc-is-sparc’s-own-business, r=alexcrichton

Only run the sparc-abi test on sparc

It is not required for LLVM to have SPARC target support, so it is
necessary to only run this test when LLVM does support SPARC. Sadly, it
isn’t possible to specify exactly this constraint. Instead, we specify
that this test should run on SPARC host only (it surely is sane
assumption to make that compiler running on a SPARC can generate
SPARC, right?)

Since you cannot specify multiple `only-*` to have it run on both 32-bit
and 64-bit SPARC we pick 64-bit SPARC, because it is exactly what is
being tested by this test.

Fixes #52881

5 years agoRollup merge of #52907 - pnkfelix:issue-52877-original-source-should-precede-suggesti...
Pietro Albini [Wed, 1 Aug 2018 08:13:06 +0000 (10:13 +0200)]
Rollup merge of #52907 - pnkfelix:issue-52877-original-source-should-precede-suggestions, r=petrochenkov

NLL: On "cannot move out of type" error, print original before rewrite

NLL: On "cannot move out of type" error, print original source before rewrite.

 * Arguably this change is sometimes injecting noise into the output  (namely in the cases where the suggested rewrite is inline with the   suggestion and we end up highlighting the original source code).   I would not be opposed to something more aggressive/dynamic, like   revising the suggestion code to automatically print the original  source when necessary (e.g. when the error does not have a span   that includes the span of the suggestion).

 * Also, as another note on this change: The doc comment for `Diagnostic::span_suggestion`  says:
```rust
    /// The message
    ///
    /// * should not end in any punctuation (a `:` is added automatically)
    /// * should not be a question
    /// * should not contain any parts like "the following", "as shown"
```
  *  but the `:` is *not* added when the emitted line appears  out-of-line relative to the suggestion. I find that to be an  unfortunate UI experience.

----

As a drive-by fix, also changed code to combine multiple suggestions for a pattern into a single multipart suggestion (which vastly improves user experience IMO).

----

Includes the updates to expected NLL diagnostics.

Fix #52877

5 years agoRollup merge of #52905 - pravic:unsize-typo, r=alexcrichton
Pietro Albini [Wed, 1 Aug 2018 08:13:05 +0000 (10:13 +0200)]
Rollup merge of #52905 - pravic:unsize-typo, r=alexcrichton

Fix a typo in unsize.rs

RfC -> RFC

5 years agoRollup merge of #52904 - pnkfelix:issue-51167-sort-by-span, r=petrochenkov
Pietro Albini [Wed, 1 Aug 2018 08:13:04 +0000 (10:13 +0200)]
Rollup merge of #52904 - pnkfelix:issue-51167-sort-by-span, r=petrochenkov

NLL: sort diagnostics by span

Sorting the output diagnostics by span is a long planned revision to the NLL diagnostics that we hope will yield a less surprising user experience in some case.

Once we got them buffered, it was trivial to implement. (The hard part is skimming the resulting changes to the diagnostics to make sure nothing broke... Note that I largely rubber-stamped the `#[rustc_regions]` output change.)

Fix #51167

5 years agoRollup merge of #52888 - estebank:shell-sugg, r=oli-obk
Pietro Albini [Wed, 1 Aug 2018 08:13:02 +0000 (10:13 +0200)]
Rollup merge of #52888 - estebank:shell-sugg, r=oli-obk

Use suggestions for shell format arguments

Follow up to #52649.

5 years agoRollup merge of #52883 - estebank:nll-diag-mut, r=oli-obk
Pietro Albini [Wed, 1 Aug 2018 08:13:01 +0000 (10:13 +0200)]
Rollup merge of #52883 - estebank:nll-diag-mut, r=oli-obk

Include lifetime in mutability suggestion in NLL messages

Fix #52880.

5 years agoRollup merge of #52878 - mikhail-m1:master, r=kennytm
Pietro Albini [Wed, 1 Aug 2018 08:13:00 +0000 (10:13 +0200)]
Rollup merge of #52878 - mikhail-m1:master, r=kennytm

Fix wrong issue number in the test name

I made a mistake in previous PR #52620, second issue number was wrong, changing from #52133 to #52113

r? @kennytm

5 years agoRollup merge of #52876 - cuviper:const-endianness-be, r=kennytm
Pietro Albini [Wed, 1 Aug 2018 08:12:58 +0000 (10:12 +0200)]
Rollup merge of #52876 - cuviper:const-endianness-be, r=kennytm

run-pass/const-endianness: negate before to_le()

`const LE_I128` needs parentheses to negate the value *before* calling
`to_le()`, otherwise it doesn't match the operations performed in the
black-boxed part of the test.  This only makes a tangible difference on
big-endian targets.

5 years agoRollup merge of #52870 - cramertj:unpin-futureobj, r=aturon
Pietro Albini [Wed, 1 Aug 2018 08:12:57 +0000 (10:12 +0200)]
Rollup merge of #52870 - cramertj:unpin-futureobj, r=aturon

Implement Unpin for FutureObj and LocalFutureObj

cc @MajorBreakfast

r? @aturon

5 years agoRollup merge of #52867 - matthiaskrgr:release_typos, r=Mark-Simulacrum
Pietro Albini [Wed, 1 Aug 2018 08:12:56 +0000 (10:12 +0200)]
Rollup merge of #52867 - matthiaskrgr:release_typos, r=Mark-Simulacrum

releases.md: fix 2 typos

5 years agoRollup merge of #52861 - ColinFinck:master, r=alexcrichton
Pietro Albini [Wed, 1 Aug 2018 08:12:55 +0000 (10:12 +0200)]
Rollup merge of #52861 - ColinFinck:master, r=alexcrichton

Add targets for HermitCore (https://hermitcore.org) to the Rust compiler and port libstd to it.

As a start, the port uses the simplest possible configuration (no jemalloc, abort on panic) and makes use of existing Unix-specific code wherever possible.
It adds targets for x86_64 (current main HermitCore platform) and aarch64 (HermitCore platform under development).

Together with the patches to "liblibc" (https://github.com/rust-lang/libc/pull/1048) and llvm (https://github.com/rust-lang/llvm/pull/122), this enables HermitCore applications to be written in Rust.

5 years agoRollup merge of #52859 - ljedrz:smallvec_true_extend, r=Mark-Simulacrum
Pietro Albini [Wed, 1 Aug 2018 08:12:54 +0000 (10:12 +0200)]
Rollup merge of #52859 - ljedrz:smallvec_true_extend, r=Mark-Simulacrum

Use Vec::extend in SmallVec::extend when applicable

As calculated in #52738, `Vec::extend` is much faster than `push`ing to it in a loop. We can take advantage of this method in `SmallVec` too - at least in cases when its underlying object is an `AccumulateVec::Heap`.

~~This approach also accidentally improves the `push` loop of the `AccumulateVec::Array` variant, because it doesn't utilize `SmallVec::push` which performs `self.reserve(1)` with every iteration; this is unnecessary, because we're already reserving the whole space we will be needing by performing `self.reserve(iter.size_hint().0)` at the beginning.~~

5 years agoRollup merge of #52853 - RalfJung:bootstrap-help, r=alexcrichton
Pietro Albini [Wed, 1 Aug 2018 08:12:52 +0000 (10:12 +0200)]
Rollup merge of #52853 - RalfJung:bootstrap-help, r=alexcrichton

Improve bootstrap help on stages

Cc @eddyb

5 years agoRollup merge of #52851 - flip1995:tool_lints, r=oli-obk
Pietro Albini [Wed, 1 Aug 2018 08:12:51 +0000 (10:12 +0200)]
Rollup merge of #52851 - flip1995:tool_lints, r=oli-obk

Make the tool_lints actually usable

cc #44690

Necessary for rust-lang-nursery/rust-clippy#2955 and rust-lang-nursery/rust-clippy#2977

This PR makes it possible for lint tools (at the moment only for Clippy) to implement the `tool_lints`, like it was documented in #52018.

Because the `declare_lint` macro is pretty cluttered right now, there was not really a good way to add the `tool_name` as an additional argument of the macro. That's why I chose to introduce the new `declare_tool_lint` macro.

The switch from `&str` to `String` in the `lint_groups` `FxHashMap` is because I got weird error messages in the `check_lint_name` method. And the `by_name` field of the `LintStore` also uses `String`.

### What comes with this PR:

If this PR lands and Clippy switches to the `tool_lints`, the currently used methods
```rust
#[cfg_attr(feature = "cargo-clippy", allow(clippy_lint))]
#[allow(unknown_lints, clippy_lint)]
```
to `allow`/`warn`/`deny`/`forbid` Clippy lints, won't have any effects anymore, but also won't produce a warning. That is because the name of `clippy_lint` will then be `clippy::clippy_lint`. (Maybe we can add a clippy lint to search for `cfg_attr` appearances with the `cargo-clippy` feature?)

r? @oli-obk

5 years agoRollup merge of #52846 - kennytm:bootstrap-curl-timeout, r=Mark-Simulacrum
Pietro Albini [Wed, 1 Aug 2018 08:12:50 +0000 (10:12 +0200)]
Rollup merge of #52846 - kennytm:bootstrap-curl-timeout, r=Mark-Simulacrum

Add timeout to use of `curl` in bootstrap.py.

Recently we've seen a lot of "30 minutes no output" spurious errors while downloading the bootstrap compiler. This added several timeout options so if the "30 minutes no output" errors were caused by connection or transfer issue, we could fail quicker for curl to retry.

5 years agoRollup merge of #52842 - toidiu:ak-commentUpdate, r=estebank
Pietro Albini [Wed, 1 Aug 2018 08:12:48 +0000 (10:12 +0200)]
Rollup merge of #52842 - toidiu:ak-commentUpdate, r=estebank

update comment

r? @joshtriplett

Addressing comment: https://github.com/rust-lang/rust/pull/52761#pullrequestreview-141323066

5 years agoRollup merge of #52831 - dsciarra:rm-ref-to-author-file, r=alexcrichton
Pietro Albini [Wed, 1 Aug 2018 08:12:47 +0000 (10:12 +0200)]
Rollup merge of #52831 - dsciarra:rm-ref-to-author-file, r=alexcrichton

remove references to AUTHORS.txt file

Rust does not ship an AUTHORS.txt file anymore.

5 years agoRollup merge of #52825 - RalfJung:codegen, r=alexcrichton
Pietro Albini [Wed, 1 Aug 2018 08:12:46 +0000 (10:12 +0200)]
Rollup merge of #52825 - RalfJung:codegen, r=alexcrichton

Make sure #47772 does not regress

Mostly to make my life in https://github.com/rust-lang/rust/pull/52206 harder.^^

Or should I just add that test there?

5 years agoRollup merge of #52824 - varkor:fix-llvm-ret-move-warnings, r=rkruppe
Pietro Albini [Wed, 1 Aug 2018 08:12:45 +0000 (10:12 +0200)]
Rollup merge of #52824 - varkor:fix-llvm-ret-move-warnings, r=rkruppe

Fix -Wpessimizing-move warnings in rustllvm/PassWrapper

These are producing warnings when building rustc (`warning: moving a local object in a return statement prevents copy elision [-Wpessimizing-move]`).

5 years agoRollup merge of #52822 - MajorBreakfast:fix-from-local-waker, r=cramertj
Pietro Albini [Wed, 1 Aug 2018 08:12:44 +0000 (10:12 +0200)]
Rollup merge of #52822 - MajorBreakfast:fix-from-local-waker, r=cramertj

Fix From<LocalWaker>

This is a follow-up to https://github.com/rust-lang/rust/pull/52640

Fixes `From<LocalWaker>` which is affected by the same accidental drop bug (unless I'm totally mistaken)

r? @cramertj

5 years agoRollup merge of #52821 - fukatani:gdb-vecdeque-print, r=michaelwoerister
Pietro Albini [Wed, 1 Aug 2018 08:12:42 +0000 (10:12 +0200)]
Rollup merge of #52821 - fukatani:gdb-vecdeque-print, r=michaelwoerister

pretty print for std::collections::vecdeque

I want pretty print function for VecDeque like Vec.

```rust
use std::collections::VecDeque;

fn main() {
    let mut d: VecDeque<i32> = VecDeque::new();
    d.push_back(4);
    d.push_back(4);
    d.push_back(6);
    let mut v: Vec<i32> = Vec::new();
    v.push(4);
    v.push(4);
    v.push(6);
}
```

```
(gdb) p v
$1 = Vec<i32>(len: 3, cap: 4) = {4, 4, 6}
(gdb) p d
$2 = VecDeque<i32>(len: 3, cap: 8) = {4, 4, 6}
```

Thanks.

5 years agoRollup merge of #52810 - matthewjasper:more-immutablity, r=pnkfelix
Pietro Albini [Wed, 1 Aug 2018 08:12:41 +0000 (10:12 +0200)]
Rollup merge of #52810 - matthewjasper:more-immutablity, r=pnkfelix

[NLL] Don't make "fake" match variables mutable

These variables can't be mutated by the user, but since they have names the unused-mut lint thinks that it should check them.

5 years agoRollup merge of #52778 - ljedrz:readable_serialize, r=kennytm
Pietro Albini [Wed, 1 Aug 2018 08:12:40 +0000 (10:12 +0200)]
Rollup merge of #52778 - ljedrz:readable_serialize, r=kennytm

Improve readability of serialize.rs

5 years agoRollup merge of #52771 - matklad:patch-1, r=kennytm
Pietro Albini [Wed, 1 Aug 2018 08:12:38 +0000 (10:12 +0200)]
Rollup merge of #52771 - matklad:patch-1, r=kennytm

Clarify thread::park semantics

It took me quite some time to realize that the example is not actually racy, so let's clarify it? :-)

5 years agoRollup merge of #52745 - commandline:master, r=oli-obk
Pietro Albini [Wed, 1 Aug 2018 08:12:37 +0000 (10:12 +0200)]
Rollup merge of #52745 - commandline:master, r=oli-obk

Update clippy to latest master

r? @oli-obk

There is a regression in the version in current nightly that falsely lints `println!` and `writeln!` that use named arguments, thinking all rhs values for the argument expressions are literals even when they are not. This update includes the fix for that.

5 years agoRollup merge of #52732 - SimonSapin:spring, r=Mark-Simulacrum
Pietro Albini [Wed, 1 Aug 2018 08:12:36 +0000 (10:12 +0200)]
Rollup merge of #52732 - SimonSapin:spring, r=Mark-Simulacrum

Remove unstable and deprecated APIs

5 years agoRollup merge of #52628 - Mark-Simulacrum:rustdoc-cleanup-1, r=QuietMisdreavus
Pietro Albini [Wed, 1 Aug 2018 08:12:35 +0000 (10:12 +0200)]
Rollup merge of #52628 - Mark-Simulacrum:rustdoc-cleanup-1, r=QuietMisdreavus

Cleanup some rustdoc code

Commits are mostly individual though some do depend on others.

5 years agoRollup merge of #52340 - cypher:document-from-trait-in-ffi, r=steveklabnik
Pietro Albini [Wed, 1 Aug 2018 08:12:32 +0000 (10:12 +0200)]
Rollup merge of #52340 - cypher:document-from-trait-in-ffi, r=steveklabnik

Document From trait implementations for OsStr, OsString, CString, and CStr

As part of issue #51430 (cc @skade).

The allocation and copy claims should be double-checked.

r? @steveklabnik

5 years agoAuto merge of #52756 - alexcrichton:cap-applicable, r=oli-obk
bors [Wed, 1 Aug 2018 06:44:09 +0000 (06:44 +0000)]
Auto merge of #52756 - alexcrichton:cap-applicable, r=oli-obk

rustc: Disallow machine applicability in foreign macros

Recent changes to lints disallowed lints from being emitted against code located
in foreign macros, except for future-incompatible lints. For a future
incompatible lint, however, the automatic suggestions may not be applicable!

This commit updates this code path to force all applicability suggestions made
to foreign macros to never be `MachineApplicable`. This should avoid rustfix
actually attempting fixing these suggestions, causing non-compiling code to be
produced.

Closes rust-lang/cargo#5799

5 years agorustc_resolve: record single-segment extern crate import resolutions.
Eduard-Mihai Burtescu [Wed, 1 Aug 2018 01:26:58 +0000 (04:26 +0300)]
rustc_resolve: record single-segment extern crate import resolutions.

5 years agoUpdate compatibility note for 1.28.0 to be correct
Ryan Scheel [Wed, 1 Aug 2018 01:31:15 +0000 (18:31 -0700)]
Update compatibility note for 1.28.0 to be correct

5 years agoFixup test case
Mark Rousskov [Sun, 29 Jul 2018 02:22:45 +0000 (20:22 -0600)]
Fixup test case

5 years agoAdd dyn to Write
Mark Rousskov [Sun, 29 Jul 2018 00:15:52 +0000 (18:15 -0600)]
Add dyn to Write

5 years agoCleanup highlighting code
Mark Rousskov [Sun, 22 Jul 2018 20:10:10 +0000 (14:10 -0600)]
Cleanup highlighting code

Removes some unused code and de-publicizes structs

5 years agoRemove global derive_id and reset_ids functions
Mark Rousskov [Sun, 22 Jul 2018 13:25:00 +0000 (07:25 -0600)]
Remove global derive_id and reset_ids functions

Previously these functions relied on TLS but we can instead thread the
relevant state through explicitly.

5 years agoAddress code review
John Renner [Tue, 31 Jul 2018 22:00:45 +0000 (15:00 -0700)]
Address code review

5 years agoUse suggestions for shell format arguments
Esteban Küber [Mon, 30 Jul 2018 23:33:53 +0000 (16:33 -0700)]
Use suggestions for shell format arguments

5 years agoBackport 1.27.2 release notes
Pietro Albini [Tue, 31 Jul 2018 21:13:41 +0000 (23:13 +0200)]
Backport 1.27.2 release notes

5 years agoaddress review feedback (`sort_by_key` is so much cleaner here than `sort_by`!).
Felix S. Klock II [Tue, 31 Jul 2018 21:00:01 +0000 (23:00 +0200)]
address review feedback (`sort_by_key` is so much cleaner here than `sort_by`!).

5 years agoAuto merge of #52234 - petrochenkov:macuse2, r=Mark-Simulacrum
bors [Tue, 31 Jul 2018 20:52:14 +0000 (20:52 +0000)]
Auto merge of #52234 - petrochenkov:macuse2, r=Mark-Simulacrum

resolve: Modularize crate-local `#[macro_export] macro_rules`

Based on https://github.com/rust-lang/rust/pull/50911, cc https://github.com/rust-lang/rust/pull/50911#issuecomment-401151270

`#[macro_export] macro_rules` items are collected from the whole crate and are planted into the root module as items, so the external view of the crate is symmetric with its internal view and something like `$crate::my_macro` where `my_macro` is `#[macro_export] macro_rules` works both locally and from other crates.

Closes https://github.com/rust-lang/rust/issues/52726

5 years agoDon't count MIR locals as borrowed after StorageDead when finding locals live across...
John Kåre Alsaker [Tue, 31 Jul 2018 19:54:30 +0000 (21:54 +0200)]
Don't count MIR locals as borrowed after StorageDead when finding locals live across a yield terminator

5 years agoAllow borrow conflicts for promoted length 0 arrays
Matthew Jasper [Tue, 31 Jul 2018 20:35:22 +0000 (21:35 +0100)]
Allow borrow conflicts for promoted length 0 arrays

5 years agoAllow unnameable tests
John Renner [Tue, 31 Jul 2018 20:17:44 +0000 (13:17 -0700)]
Allow unnameable tests

5 years agoOnly run the sparc-abi test on sparc
Simonas Kazlauskas [Tue, 31 Jul 2018 19:37:41 +0000 (22:37 +0300)]
Only run the sparc-abi test on sparc

It is not required for LLVM to have SPARC target support, so it is
necessary to only run this test when LLVM does support SPARC. Sadly, it
isn’t possible to specify exactly this constraint. Instead, we specify
that this test should run on SPARC host only (it surely is sane
assumption to make that compiler running on a SPARC can generate
SPARC, right?)

Since you cannot specify multiple `only-*` to have it run on both 32-bit
and 64-bit SPARC we pick 64-bit SPARC, because it is exactly what is
being tested by this test.

Fixes #52881

5 years agoPut back original field discovery
Guillaume Gomez [Tue, 31 Jul 2018 19:43:29 +0000 (21:43 +0200)]
Put back original field discovery

5 years agoUse SetLenOnDrop in Vec::truncate()
Laurentiu Nicola [Tue, 31 Jul 2018 15:36:04 +0000 (18:36 +0300)]
Use SetLenOnDrop in Vec::truncate()

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

Fixes #51802

5 years agorustc: Handle linker diagnostic from LLVM
Alex Crichton [Tue, 17 Jul 2018 23:20:51 +0000 (16:20 -0700)]
rustc: Handle linker diagnostic from LLVM

Previously linker diagnostic were being hidden when two modules were linked
together but failed to link. This commit fixes the situation by ensuring that we
have a diagnostic handler installed and also adds support for handling linker
diagnostics.

5 years agoFormat code for easier editing
Mark Rousskov [Sun, 22 Jul 2018 13:39:52 +0000 (07:39 -0600)]
Format code for easier editing