Commit graph

91662 commits

Author SHA1 Message Date
Esteban Küber
925ca49cf1 Add test 2019-03-27 19:35:30 -07:00
Esteban Küber
0acb7867c2 Do not suggest borrowing when the span comes from a macro 2019-03-27 19:35:30 -07:00
Chris Gregory
ffaa5c904e Document that std::io::BufReader discards contents on drop
Resolves #55546
2019-03-27 22:11:13 -04:00
bors
d20e000272 Auto merge of #59471 - cuviper:rollup, r=cuviper
Rollup of 18 pull requests

Successful merges:

 - #57293 (Make some lints incremental)
 - #57565 (syntax: Remove warning for unnecessary path disambiguators)
 - #58253 (librustc_driver => 2018)
 - #58837 (librustc_interface => 2018)
 - #59268 (Add suggestion to use `&*var` when `&str: From<String>` is expected)
 - #59283 (Make ASCII case conversions more than 4× faster)
 - #59284 (adjust MaybeUninit API to discussions)
 - #59372 (add rustfix-able suggestions to trim_{left,right} deprecations)
 - #59390 (Make `ptr::eq` documentation mention fat-pointer behavior)
 - #59393 (Refactor tuple comparison tests)
 - #59420 ([CI] record docker image info for reuse)
 - #59421 (Reject integer suffix when tuple indexing)
 - #59430 (Renames `EvalContext` to `InterpretCx`)
 - #59439 (Generalize diagnostic for `x = y` where `bool` is the expected type)
 - #59449 (fix: Make incremental artifact deletion more robust)
 - #59451 (Add `Default` to `std::alloc::System`)
 - #59459 (Add some tests)
 - #59460 (Include id in Thread's Debug implementation)

Failed merges:

r? @ghost
2019-03-28 02:00:57 +00:00
varkor
40db5756b4 Add a regression test for #47131 2019-03-28 01:47:39 +00:00
Chris Gregory
25452501ee Move link to rust book to next line to pass 100 column limit 2019-03-27 21:46:25 -04:00
varkor
b3011dd711 Visit ItemKind::Impl for dead code lint 2019-03-28 01:45:50 +00:00
Josh Stone
a2c4562690
Rollup merge of #59460 - xfix:include-id-in-thread-debug, r=Amanieu
Include id in Thread's Debug implementation

Since Rust 1.19.0, `id` is a stable method, so there is no reason to not include it in Debug implementation.
2019-03-27 18:15:44 -07:00
Josh Stone
4a322f5fdd
Rollup merge of #59459 - JohnTitor:add-tests, r=Centril
Add some tests

close #52977

It seems that there are no tests for this issue, so I opened this PR.
off-topic: I noticed [this test](https://github.com/rust-lang/rust/blob/master/src/test/ui/existential_types/nested_existential_types.rs)'s indents are bad, could I include commit to fix this, or should I separate?

r? @oli-obk
2019-03-27 18:15:42 -07:00
Josh Stone
44c411ec6f
Rollup merge of #59451 - TimDiekmann:patch-1, r=sfackler
Add `Default` to `std::alloc::System`

`System` is a unit struct, thus, it can be constructed without any additional information. Therefore `Default` is a noop. However, in generic code, a `T: Default` may happen as in

```rust
#[derive(Default)]
struct Foo<A> {
    allocator: A
}
```

Does this need a feature gate?
Should I also add `PartialEq/Eq/PartialOrd/Ord/Hash`?
2019-03-27 18:15:41 -07:00
Josh Stone
6e65ae779f
Rollup merge of #59449 - Marwes:issue_57958, r=michaelwoerister
fix: Make incremental artifact deletion more robust

Should fix the intermittent errors reported in #57958

cc #48614
2019-03-27 18:15:39 -07:00
Josh Stone
1e9e80fd91
Rollup merge of #59439 - Centril:generalize-assign-to-bool-diagnostic, r=oli-obk
Generalize diagnostic for `x = y` where `bool` is the expected type

Extracted out of https://github.com/rust-lang/rust/pull/59288.

Currently we special case a diagnostic for `if x = y { ...` since the expected type is `bool` in this case and we instead suggest `if x == y`. This PR generalizes this such that given an expression of form `x = y` (`ExprKind::Assign(..)`) where the expected type is `bool`, we emit a suggestion `x == y`.

r? @oli-obk

Let's do a perf run to make sure this was not the source of regressions in #59288.
2019-03-27 18:15:38 -07:00
Josh Stone
99f6de759e
Rollup merge of #59430 - kenta7777:rename-evalcontext-to-interpretcx, r=oli-obk
Renames `EvalContext` to `InterpretCx`

This PR renames `EvalContext` to `InterpretCx` in `src/librustc_mir`.
This PR is related to #54395 .
2019-03-27 18:15:36 -07:00
Josh Stone
be34621ffc
Rollup merge of #59421 - estebank:tuple-index-suffix, r=petrochenkov
Reject integer suffix when tuple indexing

Fix #59418.

r? @varkor
2019-03-27 18:15:35 -07:00
Josh Stone
468c02f5c8
Rollup merge of #59420 - cuviper:ci-image-info, r=alexcrichton
[CI] record docker image info for reuse

This writes an extra `dist/image-$image.txt` which contains the S3 URL
of the cached image and the `sha256` digest of the docker entry point.
This will be uploaded with the rest of the deployed artifacts in the
Travis `after_success` script.

cc rust-lang/rustup.rs#1724
r? @alexcrichton
2019-03-27 18:15:33 -07:00
Josh Stone
413aaf3227
Rollup merge of #59393 - czipperz:refactor_tuple_comparison_tests, r=shepmaster
Refactor tuple comparison tests
2019-03-27 18:15:32 -07:00
Josh Stone
35b339bd5f
Rollup merge of #59390 - czipperz:ptr_eq_smart_pointer, r=Centril,steveklabnik
Make `ptr::eq` documentation mention fat-pointer behavior

Resolves #59214
2019-03-27 18:15:30 -07:00
Josh Stone
a4bf8557b2
Rollup merge of #59372 - euclio:rename-trim, r=rkruppe
add rustfix-able suggestions to trim_{left,right} deprecations

Fixes #53802 (technically already fixed by #58002, but that issue is about these methods).
2019-03-27 18:15:28 -07:00
Josh Stone
ad5bbf01c0
Rollup merge of #59284 - RalfJung:maybe-uninit, r=sfackler
adjust MaybeUninit API to discussions

uninitialized -> uninit
into_initialized -> assume_init
read_initialized -> read
set -> write
2019-03-27 18:15:27 -07:00
Josh Stone
c70cdc0ed4
Rollup merge of #59283 - SimonSapin:branchless-ascii-case, r=joshtriplett
Make ASCII case conversions more than 4× faster

Reformatted output of `./x.py bench src/libcore --test-args ascii` below. The `libcore` benchmark calls `[u8]::make_ascii_lowercase`. `lookup` has code (effectively) identical to that before this PR, and ~~`branchless`~~ `mask_shifted_bool_match_range` after this PR.

~~See [code comments](ce933f77c8 (diff-01076f91a26400b2db49663d787c2576R3796)) in `u8::to_ascii_uppercase` in `src/libcore/num/mod.rs` for an explanation of the branchless algorithm.~~

**Update:** the algorithm was simplified while keeping the performance. See `branchless` v.s. `mask_shifted_bool_match_range` benchmarks.

Credits to @raphlinus for the idea in https://twitter.com/raphlinus/status/1107654782544736261, which extends this algorithm to “fake SIMD” on `u32` to convert four bytes at a time. The `fake_simd_u32` benchmarks implements this with [`let (before, aligned, after) = bytes.align_to_mut::<u32>()`](https://doc.rust-lang.org/std/primitive.slice.html#method.align_to_mut). Note however that this is buggy when addition carries/overflows into the next byte (which does not happen if the input is known to be ASCII).

This could be fixed (to optimize `[u8]::make_ascii_lowercase` and `[u8]::make_ascii_uppercase` in `src/libcore/slice/mod.rs`) either with some more bitwise trickery that I didn’t quite figure out, or by using “real” SIMD intrinsics for byte-wise addition. I did not pursue this however because the current (incorrect) fake SIMD algorithm is only marginally faster than the one-byte-at-a-time branchless algorithm. This is because LLVM auto-vectorizes the latter, as can be seen on https://rust.godbolt.org/z/anKtbR.

Benchmark results on Linux x64 with Intel i7-7700K: (updated from https://github.com/rust-lang/rust/pull/59283#issuecomment-474146863)

```rust
6830 bytes string:

alloc_only                          ... bench:    112 ns/iter (+/- 0) = 62410 MB/s
black_box_read_each_byte            ... bench:  1,733 ns/iter (+/- 8) = 4033 MB/s
lookup_table                        ... bench:  1,766 ns/iter (+/- 11) = 3958 MB/s
branch_and_subtract                 ... bench:    417 ns/iter (+/- 1) = 16762 MB/s
branch_and_mask                     ... bench:    401 ns/iter (+/- 1) = 17431 MB/s
branchless                          ... bench:    365 ns/iter (+/- 0) = 19150 MB/s
libcore                             ... bench:    367 ns/iter (+/- 1) = 19046 MB/s
fake_simd_u32                       ... bench:    361 ns/iter (+/- 2) = 19362 MB/s
fake_simd_u64                       ... bench:    361 ns/iter (+/- 1) = 19362 MB/s
mask_mult_bool_branchy_lookup_table ... bench:  6,309 ns/iter (+/- 19) = 1107 MB/s
mask_mult_bool_lookup_table         ... bench:  4,183 ns/iter (+/- 29) = 1671 MB/s
mask_mult_bool_match_range          ... bench:    339 ns/iter (+/- 0) = 20619 MB/s
mask_shifted_bool_match_range       ... bench:    339 ns/iter (+/- 1) = 20619 MB/s

32 bytes string:

alloc_only                          ... bench:     15 ns/iter (+/- 0) = 2133 MB/s
black_box_read_each_byte            ... bench:     29 ns/iter (+/- 0) = 1103 MB/s
lookup_table                        ... bench:     24 ns/iter (+/- 4) = 1333 MB/s
branch_and_subtract                 ... bench:     16 ns/iter (+/- 0) = 2000 MB/s
branch_and_mask                     ... bench:     16 ns/iter (+/- 0) = 2000 MB/s
branchless                          ... bench:     16 ns/iter (+/- 0) = 2000 MB/s
libcore                             ... bench:     15 ns/iter (+/- 0) = 2133 MB/s
fake_simd_u32                       ... bench:     17 ns/iter (+/- 0) = 1882 MB/s
fake_simd_u64                       ... bench:     16 ns/iter (+/- 0) = 2000 MB/s
mask_mult_bool_branchy_lookup_table ... bench:     42 ns/iter (+/- 0) = 761 MB/s
mask_mult_bool_lookup_table         ... bench:     35 ns/iter (+/- 0) = 914 MB/s
mask_mult_bool_match_range          ... bench:     16 ns/iter (+/- 0) = 2000 MB/s
mask_shifted_bool_match_range       ... bench:     16 ns/iter (+/- 0) = 2000 MB/s

7 bytes string:

alloc_only                          ... bench:     14 ns/iter (+/- 0) = 500 MB/s
black_box_read_each_byte            ... bench:     22 ns/iter (+/- 0) = 318 MB/s
lookup_table                        ... bench:     16 ns/iter (+/- 0) = 437 MB/s
branch_and_subtract                 ... bench:     16 ns/iter (+/- 0) = 437 MB/s
branch_and_mask                     ... bench:     16 ns/iter (+/- 0) = 437 MB/s
branchless                          ... bench:     19 ns/iter (+/- 0) = 368 MB/s
libcore                             ... bench:     20 ns/iter (+/- 0) = 350 MB/s
fake_simd_u32                       ... bench:     18 ns/iter (+/- 0) = 388 MB/s
fake_simd_u64                       ... bench:     21 ns/iter (+/- 0) = 333 MB/s
mask_mult_bool_branchy_lookup_table ... bench:     20 ns/iter (+/- 0) = 350 MB/s
mask_mult_bool_lookup_table         ... bench:     19 ns/iter (+/- 0) = 368 MB/s
mask_mult_bool_match_range          ... bench:     19 ns/iter (+/- 0) = 368 MB/s
mask_shifted_bool_match_range       ... bench:     19 ns/iter (+/- 0) = 368 MB/s
```
2019-03-27 18:15:25 -07:00
Josh Stone
e5fa59735b
Rollup merge of #59268 - estebank:from-string, r=QuietMisdreavus
Add suggestion to use `&*var` when `&str: From<String>` is expected

Fix #53879.
2019-03-27 18:15:24 -07:00
Josh Stone
ecf63630cf
Rollup merge of #58837 - Centril:librustc_interface_2018, r=petrochenkov
librustc_interface => 2018

r? @oli-obk

This will likely produce an ICE for some reason... so super-WIP.
2019-03-27 18:15:22 -07:00
Josh Stone
2a3c2bfce4
Rollup merge of #58253 - taiki-e:librustc_driver-2018, r=petrochenkov
librustc_driver => 2018

Transitions `librustc_driver` to Rust 2018; cc #58099

r? @Centril
2019-03-27 18:15:21 -07:00
Josh Stone
c818c1a1d6
Rollup merge of #57565 - petrochenkov:turbowarn, r=Centril
syntax: Remove warning for unnecessary path disambiguators

`rustfmt` is now stable and it removes unnecessary turbofishes, so removing the warning as discussed in https://github.com/rust-lang/rust/pull/43540 (where it was introduced).
One hardcoded warning less.

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

r? @nikomatsakis
2019-03-27 18:15:19 -07:00
Josh Stone
74a69f2e74
Rollup merge of #57293 - Zoxc:incr-passes3, r=michaelwoerister
Make some lints incremental

Blocked on https://github.com/rust-lang/rust/pull/57253

r? @michaelwoerister
2019-03-27 18:15:18 -07:00
varkor
c6e3ea475b Visit path in walk_mac 2019-03-27 22:41:41 +00:00
Eric Huss
5113e73e81 Update books 2019-03-27 11:02:55 -07:00
Mateusz Mikuła
c764890d7c musl: build toolchain libs with -fPIC 2019-03-27 18:37:21 +01:00
hgallagher1993
4d648ce1b9 Better diagnostic for binary operation on BoxedValues 2019-03-27 13:13:09 -04:00
David Wood
4187560bdf
Add comments for new AdtDef functions. 2019-03-27 17:27:21 +01:00
Felix S. Klock II
1f63a52ca2 Regression test for rust-lang/rust#56327. 2019-03-27 17:18:49 +01:00
Felix S. Klock II
6d7e5df3d9 Some tests illustrating where the revised lint does and does not apply. 2019-03-27 17:13:51 +01:00
Chris Gregory
f0a7610724 Add higher-ranked trait bounds link 2019-03-27 12:03:14 -04:00
Nikhil Benesch
3e0db7cecd
Clarify behavior of dbg macro 2019-03-27 11:22:55 -04:00
Andy Russell
e1daa36ba7
replace llvm-rebuild-trigger with commit hash 2019-03-27 10:05:32 -04:00
Taiki Endo
d59b46fd49 Add a test 2019-03-27 22:48:39 +09:00
Felix S. Klock II
6046f4a673 Do not lint dyn tokens under macros.
The existing `KeywordIdents` lint blindly scans the token stream for a
macro or macro definition. It does not attempt to parse the input,
which means it cannot distinguish between occurrences of `dyn` that
are truly instances of it as an identifier (e.g. `let dyn = 3;`)
versus occurrences that follow its usage as a contextual keyword (e.g.
the type `Box<dyn Trait>`).

In an ideal world the lint would parse the token stream in order to
distinguish such occurrences; but in general we cannot do this,
because a macro_rules definition does not specify what parsing
contexts the macro being defined is allowed to be used within.

So rather than put a lot of work into attempting to come up with a
more precise but still incomplete solution, I am just taking the short
cut of not linting any instance of `dyn` under a macro. This prevents
`rustfix` from injecting bugs into legal 2015 edition code.
2019-03-27 14:43:29 +01:00
bors
33ef0bad21 Auto merge of #59415 - varkor:values_since_snapshot, r=eddyb
Refactor InferenceFudger (née RegionFudger)

- Rename `RegionFudger` (and related methods) to `InferenceFudger`.
- Take integer and float inference variables into account.
- Refactor `types_created_since_snapshot` and `vars_created_since_snapshot` with the [new version of ena](https://github.com/rust-lang-nursery/ena/pull/21).
- Some other refactoring in the area.

r? @eddyb
2019-03-27 13:20:16 +00:00
Konrad Borowski
ba21e0b368 Include id in Thread's Debug implementation
Since Rust 1.19.0, id is a stable method, so there is no reason to
not include it in Debug implementation.
2019-03-27 12:28:17 +01:00
Yuki OKUSHI
2368aa8e97 Add some tests 2019-03-27 19:30:33 +09:00
varkor
86d5a69d9d Use Vec instead of FxHashMap 2019-03-27 09:44:55 +00:00
varkor
688cbad9b8 Lookup region variable origin instead of choosing one 2019-03-27 09:44:55 +00:00
varkor
2d48ffa9c6 Store type variable origins in InferenceFudger 2019-03-27 09:44:55 +00:00
varkor
58a04f06cb Propitiate tidy 2019-03-27 09:44:55 +00:00
varkor
3683f51352 Update ena to version 0.13.0 2019-03-27 09:44:55 +00:00
varkor
267370ed58 Use eq_relations 2019-03-27 09:44:55 +00:00
varkor
fa18c129c3 Add next_int_var and next_float_var 2019-03-27 09:44:55 +00:00
varkor
f9d8bb8e2c Simplify fudge_inference_if_ok 2019-03-27 09:44:55 +00:00
varkor
ac94858e32 Add int variables and float variables to InferenceFudger 2019-03-27 09:44:55 +00:00
varkor
1f9a2326b5 Rename RegionFudger to InferenceFudger 2019-03-27 09:44:55 +00:00