103804 Commits

Author SHA1 Message Date
Mazdak Farrokhzad
35e9e097e7 More c-variadic errors as semantic restrictions. 2019-12-12 18:01:33 +01:00
Mazdak Farrokhzad
3a57a2cca4 ast_validation: move trait item logic to proper place. 2019-12-12 18:01:33 +01:00
Mazdak Farrokhzad
0d41d0fe14 Move allow_c_varadic logic to ast_validation. 2019-12-12 18:01:33 +01:00
Mazdak Farrokhzad
b499a88dfc Unify assoc item visitors more. 2019-12-12 18:01:33 +01:00
Mazdak Farrokhzad
51ccdebe0b Unify associated item parsing more. 2019-12-12 18:00:00 +01:00
Mazdak Farrokhzad
0d8a9d74e3 Unify associated item visitor. 2019-12-12 18:00:00 +01:00
Mazdak Farrokhzad
c6c17e3e00 Simplify nt_to_tokenstream. 2019-12-12 17:54:49 +01:00
Mazdak Farrokhzad
76576d401c Unify associated item mut visitors. 2019-12-12 17:54:49 +01:00
Mazdak Farrokhzad
9193d7a07e Unify associated item pretty printing. 2019-12-12 17:54:49 +01:00
Mazdak Farrokhzad
34d91709b6 parse: refactor fun ret ty & param ty 2019-12-12 17:54:49 +01:00
Mazdak Farrokhzad
404013e015 Leave a FIXME re. allow_plus. 2019-12-12 17:54:49 +01:00
Mazdak Farrokhzad
fa828d7a05 Relocate is_const_item. 2019-12-12 17:54:49 +01:00
Mazdak Farrokhzad
63a9030e7b Unify associated item parsing.
An exception is `fn` params.
2019-12-12 17:54:49 +01:00
Mazdak Farrokhzad
7672bff378 Unify associated function parsing. 2019-12-12 17:54:48 +01:00
Mazdak Farrokhzad
10270bcd30 Fuse associated type parsing. 2019-12-12 17:54:48 +01:00
Mazdak Farrokhzad
2d92aa5535 Fuse associated constant parsing. 2019-12-12 17:54:48 +01:00
Mazdak Farrokhzad
92a372b020 Unify {Impl,Trait}Item as AssocItem. 2019-12-12 17:54:48 +01:00
Mazdak Farrokhzad
39073767a4 Unify {Trait,Impl}ItemKind::TyAlias structures. 2019-12-12 17:54:48 +01:00
Mazdak Farrokhzad
c02fd31302 TraitItemKind::Type -> TraitItemKind::TyAlias. 2019-12-12 17:54:48 +01:00
Mazdak Farrokhzad
f6403c6c76 Use Option in ImplItemKind::Method. 2019-12-12 17:54:48 +01:00
Mazdak Farrokhzad
73557faed2 Use Option in ImplItemKind::Const. 2019-12-12 17:54:48 +01:00
Mazdak Farrokhzad
c4bbe9cbbe Alias TraitItem & ImplItem.
Allow defaultness on trait items syntactically.
2019-12-12 17:54:48 +01:00
bors
3eebe058e5 Auto merge of #67079 - nnethercote:optimize-shallow_resolve_changed, r=nikomatsakis
Optimize `shallow_resolve_changed`

r? @nikomatsakis
2019-12-12 11:51:26 +00:00
bors
f284f8b4be Auto merge of #67246 - JohnTitor:rollup-nfa7skn, r=JohnTitor
Rollup of 8 pull requests

Successful merges:

 - #62514 (Clarify `Box<T>` representation and its use in FFI)
 - #66983 (Fix `unused_parens` triggers on macro by example code)
 - #67215 (Fix `-Z print-type-sizes`'s handling of zero-sized fields.)
 - #67230 (Remove irelevant comment on `register_dtor`)
 - #67236 (resolve: Always resolve visibilities on impl items)
 - #67237 (Some small readability improvements)
 - #67238 (Small std::borrow::Cow improvements)
 - #67239 (Make TinyList::remove iterate instead of recurse)

Failed merges:

r? @ghost
2019-12-12 02:11:31 +00:00
Yuki Okushi
685d4cc746
Rollup merge of #67239 - llogiq:tiny-list-iterative-remove, r=Mark-Simulacrum
Make TinyList::remove iterate instead of recurse

Most of the diff is from from rustfmt, the actual change is in line 91..79 (or 79..89 in the "after" diff).

I had converted the other methods to iterate instead of recurse already, so this is the last recursive function on `TinyList`.
2019-12-12 10:09:29 +09:00
Yuki Okushi
60ebeda94f
Rollup merge of #67238 - llogiq:moo-and-improved, r=Dylan-DPC
Small std::borrow::Cow improvements

This is a small set of improvements (+ one more tested code path) for `Cow`.
2019-12-12 10:09:28 +09:00
Yuki Okushi
59eed49115
Rollup merge of #67237 - llogiq:improve-str, r=Dylan-DPC
Some small readability improvements
2019-12-12 10:09:26 +09:00
Yuki Okushi
0f286e855f
Rollup merge of #67236 - petrochenkov:docerr2, r=matthewjasper
resolve: Always resolve visibilities on impl items

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

Similarly to https://github.com/rust-lang/rust/pull/67106 this was an issue with visitor discipline.
Impl items were visited as a part of visiting `ast::ItemKind::Impl`, but they should be visit-able in isolation  from their parents as well, because that's how they are visited when they are expanded from macros.

I've checked that all the remaining `resolve_visibility` calls are used correctly.

r? @matthewjasper
2019-12-12 10:09:24 +09:00
Yuki Okushi
3cf799640f
Rollup merge of #67230 - chansuke:remove-irrelevant-passage, r=Dylan-DPC
Remove irelevant comment on `register_dtor`

Fixes #66572.
2019-12-12 10:09:23 +09:00
Yuki Okushi
a82390407a
Rollup merge of #67215 - nnethercote:fix-Zprint-type-size-zero-sized-fields, r=pnkfelix
Fix `-Z print-type-sizes`'s handling of zero-sized fields.

Currently, the type `struct S { x: u32, y: u32, tag: () }` is
incorrectly described like this:
```
print-type-size type: `S`: 8 bytes, alignment: 4 bytes
print-type-size     field `.x`: 4 bytes
print-type-size     field `.tag`: 0 bytes, offset: 0 bytes, alignment: 1 bytes
print-type-size     padding: 4 bytes
print-type-size     field `.y`: 4 bytes, alignment: 4 bytes
```
Specifically:
- The `padding` line is wrong. (There is no padding.)
- The `offset` and `alignment` on the `.tag` line shouldn't be printed.

The problem is that multiple fields can end up with the same offset, and
the printing code doesn't handle this correctly.

This commit fixes it by adjusting the field sorting so that zero-sized fields
are dealt with before non-zero-sized fields. With that in place, the
printing code works correctly.

The commit also corrects the "something is very wrong" comment.

The new output looks like this:
```
print-type-size type: `S`: 8 bytes, alignment: 4 bytes
print-type-size     field `.tag`: 0 bytes
print-type-size     field `.x`: 4 bytes
print-type-size     field `.y`: 4 bytes
```
r? @pnkfelix
2019-12-12 10:09:21 +09:00
Yuki Okushi
f642dc4124
Rollup merge of #66983 - weiznich:bugfix/issue_66295, r=estebank
Fix `unused_parens` triggers on macro by example code

Fix #66295

Unfortunately this does also break [an existing test](4787e97475/src/test/ui/lint/issue-47775-nested-macro-unnecessary-parens-arg.rs (L22)). I'm not sure how to handle that, because that seems to be quite similar to the allowed cases

If this gets accepted it would be great to backport this fix to beta.
2019-12-12 10:09:19 +09:00
Yuki Okushi
9860a4eeb7
Rollup merge of #62514 - stephaneyfx:box-ffi, r=nikomatsakis
Clarify `Box<T>` representation and its use in FFI

This officializes what was only shown as a code example in [the unsafe code guidelines](https://rust-lang.github.io/unsafe-code-guidelines/layout/function-pointers.html?highlight=box#use) and follows [the discussion](https://github.com/rust-lang/unsafe-code-guidelines/issues/157) in the corresponding repository.

It is also related to [the issue](https://github.com/rust-lang/rust/issues/52976) regarding marking `Box<T>` `#[repr(transparent)]`.

If the statement this PR adds is incorrect or a more in-depth discussion is warranted, I apologize. Should it be the case, the example in the unsafe code guidelines should be amended and some document should make it clear that it is not sound/supported.
2019-12-12 10:09:15 +09:00
bors
de0abf7599 Auto merge of #66650 - matthewjasper:nonuniform-array-move, r=pnkfelix
Remove uniform array move MIR passes

This PR fixes a number of bugs caused by limitations of this pass

* Projections from constant indexes weren't being canonicalized
* Constant indexes from the start weren't being canonicalized (they could have different min_lengths)
* It didn't apply to non-moves

This PR makes the following changes to support removing this pass:

* ConstantIndex of arrays are now generated in a canonical form (from the start, min_length is the actual length).
* Subslices are now split when generating move paths and when checking subslices have been moved.

Additionally

* The parent move path of a projection from an array element is now calculated correctly

closes #66502
2019-12-11 23:00:38 +00:00
Andre Bogus
ab3afc0f04 Make TinyList::remove iterate instead of recurse 2019-12-11 21:05:28 +01:00
Andre Bogus
2422797785 Small Cow improvements 2019-12-11 21:01:33 +01:00
Andre Bogus
7f87dd1bc0 Some small readability improvements 2019-12-11 20:49:46 +01:00
bors
27d6f55f47 Auto merge of #65345 - davidtwco:issue-64130-async-send-sync-error-improvements, r=nikomatsakis
async/await: improve not-send errors, part 2

Part of #64130. Fixes #65667.

This PR improves the errors introduced in #64895 so that they have specialized messages for `Send` and `Sync`.

r? @nikomatsakis
2019-12-11 19:39:06 +00:00
Vadim Petrochenkov
914c9aa78d resolve: Always resolve visibilities on impl items 2019-12-11 22:10:09 +03:00
Nicholas Matsakis
5cd9f22464 erase regions instead of using builtin_deref
The reason we were invoking `builtin_deref` was to enable comparisons
when the type was `&T`. For the reasons outlined in the comment, those
comparisons failed because the regions disagreed.
2019-12-11 13:23:07 -05:00
chansuke
e4852da576 Remove irelevant comment on register_dtor 2019-12-12 01:00:37 +09:00
Nicholas Matsakis
fafa489798 clarify that Box<T> should only be used when defined *in Rust* 2019-12-11 10:33:36 -05:00
bors
90b957a17c Auto merge of #66821 - eddyb:global-trait-caching, r=nikomatsakis
rustc: allow non-empty ParamEnv's in global trait select/eval caches.

*Based on #66963*

This appears to alleviate the symptoms of #65510 locally (without fixing WF directly), and is potentially easier to validate as sound (since it's a more ad-hoc version of queries we already have).

I'm opening this PR primarily to test the effects on perf.

r? @nikomatsakis cc @rust-lang/wg-traits
2019-12-11 12:29:35 +00:00
bors
033662dfbc Auto merge of #67220 - Centril:rollup-n3u9wd5, r=Centril
Rollup of 6 pull requests

Successful merges:

 - #66881 (Optimize Ord trait implementation for bool)
 - #67015 (Fix constant propagation for scalar pairs)
 - #67074 (Add options to --extern flag.)
 - #67164 (Ensure that panicking in constants eventually errors)
 - #67174 (Remove `checked_add` in `Layout::repeat`)
 - #67205 (Make `publish_toolstate.sh` executable)

Failed merges:

r? @ghost
2019-12-11 09:12:06 +00:00
Mazdak Farrokhzad
f6ceef546b
Rollup merge of #67205 - JohnTitor:fix-sh, r=pietroalbini
Make `publish_toolstate.sh` executable

It causes a failure on master ([log](https://dev.azure.com/rust-lang/rust/_build/results?buildId=15627)).

r? @pietroalbini
CC: @Mark-Simulacrum
2019-12-11 10:10:49 +01:00
Mazdak Farrokhzad
b768328242
Rollup merge of #67174 - kraai:remove-checked_add, r=rkruppe
Remove `checked_add` in `Layout::repeat`
2019-12-11 10:10:47 +01:00
Mazdak Farrokhzad
96b288f593
Rollup merge of #67164 - matthewjasper:never-remove-const, r=oli-obk
Ensure that panicking in constants eventually errors

based on #67134

closes #66975

r? @oli-obk
2019-12-11 10:10:46 +01:00
Mazdak Farrokhzad
4c3e95e84b
Rollup merge of #67074 - ehuss:extern-options, r=petrochenkov
Add options to --extern flag.

This changes the `--extern` flag so that it can take a series of options that changes its behavior. The general syntax is `[opts ':'] name ['=' path]` where `opts` is a comma separated list of options. Two options are supported, `priv` which replaces `--extern-private` and `noprelude` which avoids adding the crate to the extern prelude.

```text
--extern priv:mylib=/path/to/libmylib.rlib
--extern noprelude:alloc=/path/to/liballoc.rlib
```

`noprelude` is to be used by Cargo's build-std feature in order to use `--extern` to reference standard library crates.

This also includes a second commit which adds the `aux-crate` directive to compiletest. I can split this off into a separate PR if desired, but it helps with defining these kinds of tests. It is based on #54020, and can be used in the future to replace and simplify some of the Makefile tests.
2019-12-11 10:10:44 +01:00
Mazdak Farrokhzad
04e0512c7a
Rollup merge of #67015 - osa1:issue66971, r=wesleywiser
Fix constant propagation for scalar pairs

We now only propagate a scalar pair if the Rvalue is a tuple with two scalars. This for example avoids propagating a (u8, u8) value when Rvalue has type `((), u8, u8)` (see the regression test). While this is a correct thing to do, implementation is tricky and will be done later.

Fixes #66971
Fixes #66339
Fixes #67019
2019-12-11 10:10:42 +01:00
Georg Semmler
ab3f4fd709
Apply review suggestions 2019-12-11 10:10:41 +01:00
Mazdak Farrokhzad
830b4ee76a
Rollup merge of #66881 - krishna-veerareddy:issue-66780-bool-ord-optimization, r=sfackler
Optimize Ord trait implementation for bool

Casting the booleans to `i8`s and converting their difference into `Ordering` generates better assembly than casting them to `u8`s and comparing them.

Fixes #66780

#### Comparison([Godbolt link](https://rust.godbolt.org/z/PjBpvF))

##### Old assembly:
```asm
example::boolean_cmp:
        mov     ecx, edi
        xor     ecx, esi
        test    esi, esi
        mov     eax, 255
        cmove   eax, ecx
        test    edi, edi
        cmovne  eax, ecx
        ret
```

##### New assembly:
```asm
example::boolean_cmp:
        mov     eax, edi
        sub     al, sil
        ret
```

##### Old LLVM-MCA statistics:
```
Iterations:        100
Instructions:      800
Total Cycles:      234
Total uOps:        1000

Dispatch Width:    6
uOps Per Cycle:    4.27
IPC:               3.42
Block RThroughput: 1.7
```

##### New LLVM-MCA statistics:
```
Iterations:        100
Instructions:      300
Total Cycles:      110
Total uOps:        500

Dispatch Width:    6
uOps Per Cycle:    4.55
IPC:               2.73
Block RThroughput: 1.0
```
2019-12-11 10:10:41 +01:00