]> git.lizzy.rs Git - rust.git/log
rust.git
4 years agoupdate miri
Ralf Jung [Tue, 27 Aug 2019 13:49:47 +0000 (15:49 +0200)]
update miri

4 years agoAuto merge of #63897 - petrochenkov:prettycomma, r=estebank
bors [Mon, 26 Aug 2019 13:45:18 +0000 (13:45 +0000)]
Auto merge of #63897 - petrochenkov:prettycomma, r=estebank

pprust: Do not print spaces before some tokens

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

r? @Mark-Simulacrum

4 years agoAuto merge of #63580 - wesleywiser:move_promoted_out, r=oli-obk
bors [Mon, 26 Aug 2019 07:48:24 +0000 (07:48 +0000)]
Auto merge of #63580 - wesleywiser:move_promoted_out, r=oli-obk

Move promoted MIR out of `mir::Body`

r? @oli-obk

4 years agoAuto merge of #62891 - vext01:improve-black-box-docs, r=RalfJung,Centril,gnzlbg
bors [Mon, 26 Aug 2019 04:10:54 +0000 (04:10 +0000)]
Auto merge of #62891 - vext01:improve-black-box-docs, r=RalfJung,Centril,gnzlbg

Improve the documentation for std::hint::black_box.

The other day a colleague was reviewing some of my code which was using `black_box` to block constant propogation. There was a little confusion because the documentation kind of implies that `black_box` is only useful for dead code elimination, and only in benchmarking scenarios.

The docs currently say:

> A function that is opaque to the optimizer, to allow benchmarks to pretend to use outputs to assist in avoiding dead-code elimination.

Here is our discussion, in which I show (using godbolt) that a black box can also block constant propagation:
https://github.com/softdevteam/yk/pull/21#discussion_r302985038

This change makes the docstring for `black_box` a little more general, and while we are here, I've added an example (the same one from our discussion).

![image](https://user-images.githubusercontent.com/604955/61701322-ddf1e400-ad35-11e9-878c-b5b44a20770c.png)

OK to go in?

4 years agoAuto merge of #62603 - cuviper:no-unwind-abort, r=joshtriplett
bors [Mon, 26 Aug 2019 00:27:17 +0000 (00:27 +0000)]
Auto merge of #62603 - cuviper:no-unwind-abort, r=joshtriplett

Permit unwinding through FFI by default

This repeats #62505 for master (Rust 1.38+), as #58794 is not yet resolved. This is a stopgap until a stable alternative is available, like [RFC 2699](https://github.com/rust-lang/rfcs/pull/2699), as long as progress is being made to that end.

r? @joshtriplett

4 years agoAuto merge of #61613 - sinkuu:impl_trait_inline, r=ollie27
bors [Sun, 25 Aug 2019 19:20:20 +0000 (19:20 +0000)]
Auto merge of #61613 - sinkuu:impl_trait_inline, r=ollie27

Support `impl Trait` in inlined documentation

`impl Trait` in argument position was not properly rendered when inlined from other crates. ([a live example on docs.rs](https://docs.rs/libp2p/0.8.1/libp2p/floodsub/struct.Floodsub.html#method.unsubscribe))

![old](https://user-images.githubusercontent.com/7091080/59089838-14ba9900-8946-11e9-830b-53b317bdecb4.png)

![new](https://user-images.githubusercontent.com/7091080/59089844-16845c80-8946-11e9-9fe3-8998af9d73ce.png)

4 years agopprust: Do not print spaces before some tokens
Vadim Petrochenkov [Sun, 25 Aug 2019 17:41:52 +0000 (20:41 +0300)]
pprust: Do not print spaces before some tokens

4 years agoForce #[unwind(aborts)] in test/codegen/c-variadic.rs
Josh Stone [Fri, 10 May 2019 22:10:15 +0000 (15:10 -0700)]
Force #[unwind(aborts)] in test/codegen/c-variadic.rs

4 years agoRevert "Allow a dirty MirBuilt for make_extern and make_method_extern"
Josh Stone [Tue, 2 Apr 2019 21:53:57 +0000 (14:53 -0700)]
Revert "Allow a dirty MirBuilt for make_extern and make_method_extern"

This reverts commit b4a6f597934f16f89e27058a32a514c9572f148f.

4 years agoPermit unwinding through FFI by default
Mark Rousskov [Thu, 28 Feb 2019 00:21:31 +0000 (17:21 -0700)]
Permit unwinding through FFI by default

See #58794 for context.

4 years agoAuto merge of #63878 - phansch:update_clippy_submodule, r=Manishearth
bors [Sun, 25 Aug 2019 15:42:13 +0000 (15:42 +0000)]
Auto merge of #63878 - phansch:update_clippy_submodule, r=Manishearth

submodules: update Clippy from 2bcb615 to 05f603e

changes: https://github.com/rust-lang/rust-clippy/compare/2bcb615...05f603e

Should fix the Clippy toolstate.

4 years agosubmodules: update clippy from 2bcb6155948e2f8b86db08152a5f54bd5af625e5 to 05f603e6ce...
Philipp Hansch [Sun, 25 Aug 2019 10:54:31 +0000 (12:54 +0200)]
submodules: update clippy from 2bcb6155948e2f8b86db08152a5f54bd5af625e5 to 05f603e6cec63d0b2681a84d4a64a51bccac1624

4 years agoAuto merge of #63874 - spastorino:places-drive-by-cleanups, r=Centril
bors [Sun, 25 Aug 2019 08:06:06 +0000 (08:06 +0000)]
Auto merge of #63874 - spastorino:places-drive-by-cleanups, r=Centril

Places drive by cleanups

Small fixes of things meanwhile I was doing the box part of Place 2.0, based on @centril reviews.

4 years agoAuto merge of #63862 - Centril:match-cleanup, r=oli-obk
bors [Sun, 25 Aug 2019 04:26:26 +0000 (04:26 +0000)]
Auto merge of #63862 - Centril:match-cleanup, r=oli-obk

typeck: refactor patterns => `pat.rs`  + make the `def_bm` algo more declarative

Spurred by the relative difficulty I had in working up an explanation of how default match bindings work in https://github.com/rust-lang/rust/pull/63118#issuecomment-524161584, this PR refactors the type checking of patterns into `pat.rs`.

The PR is probably best read commit-by-commit and includes various changes beyond the following, which are the most important highlights:

- The algorithm for determining `def_bm` is encoded in a more declarative fashion now with important sub-steps divided into functions that make sense as logical units (and as described in the reference). This is done starting with *"extract `is_no_ref_pat`."* to *"extract `calc_default_binding_mode`"*.

- Dedicated functions like `check_pat_{lit,range,ident,tuple,box,ref,slice}` are then introduced for the various kinds of patterns to make things overall more readable.

- `fn check_pat_top(...)` becomes the sole entry point to type checking patterns.

   This will take care of initializing the default binding mode (hence: `def_bm`) to `BindByValue` and is called by all contexts that have a pattern that needs to be type checked (functions, `match`, `if let`, `let`, ...). The overall result is that the notion of `def_bm` is internal to checking patterns.

- Various diagnostics are extracted to dedicated functions to disturb the flow of type checking logic less.

r? @oli-obk

4 years agoAdd a period at the end of the sentence
Santiago Pastorino [Sat, 24 Aug 2019 22:26:25 +0000 (15:26 -0700)]
Add a period at the end of the sentence

4 years agoJoin arms patterns, body is empty in all arms
Santiago Pastorino [Sat, 24 Aug 2019 21:19:32 +0000 (14:19 -0700)]
Join arms patterns, body is empty in all arms

4 years agoAllow lifetime parameters to be inferred
Santiago Pastorino [Sat, 24 Aug 2019 21:16:56 +0000 (14:16 -0700)]
Allow lifetime parameters to be inferred

4 years agoAuto merge of #63873 - Centril:rollup-jgglypd, r=Centril
bors [Sun, 25 Aug 2019 00:47:28 +0000 (00:47 +0000)]
Auto merge of #63873 - Centril:rollup-jgglypd, r=Centril

Rollup of 6 pull requests

Successful merges:

 - #62744 (Refactor `TinyList::contains` and `len` to iterate instead of recurse)
 - #63813 (Do not suggest `.try_into()` on `i32::from(x)`)
 - #63833 (Suggest calling closure with resolved return type when appropriate)
 - #63839 (Ensure miri can do bit ops on pointer values)
 - #63854 (Modifies how Arg, Arm, Field, FieldPattern and Variant are visited)
 - #63859 (Don't unwrap the result of `span_to_snippet`)

Failed merges:

r? @ghost

4 years agoRollup merge of #63859 - matthewjasper:check-snippet-result, r=Centril
Mazdak Farrokhzad [Sun, 25 Aug 2019 00:45:05 +0000 (02:45 +0200)]
Rollup merge of #63859 - matthewjasper:check-snippet-result, r=Centril

Don't unwrap the result of `span_to_snippet`

Closes #63800

4 years agoRollup merge of #63854 - c410-f3r:attrs-visit, r=petrochenkov
Mazdak Farrokhzad [Sun, 25 Aug 2019 00:45:04 +0000 (02:45 +0200)]
Rollup merge of #63854 - c410-f3r:attrs-visit, r=petrochenkov

Modifies how Arg, Arm, Field, FieldPattern and Variant are visited

Part of the necessary work to accomplish #63468.

4 years agoRollup merge of #63839 - oli-obk:intptrcast, r=RalfJung
Mazdak Farrokhzad [Sun, 25 Aug 2019 00:45:02 +0000 (02:45 +0200)]
Rollup merge of #63839 - oli-obk:intptrcast, r=RalfJung

Ensure miri can do bit ops on pointer values

r? @RalfJung

Fixes https://github.com/rust-lang/miri/issues/916

4 years agoRollup merge of #63833 - estebank:suggest-closure-call, r=petrochenkov
Mazdak Farrokhzad [Sun, 25 Aug 2019 00:45:01 +0000 (02:45 +0200)]
Rollup merge of #63833 - estebank:suggest-closure-call, r=petrochenkov

Suggest calling closure with resolved return type when appropriate

Follow up to #63337. CC #63100.

```
error[E0308]: mismatched types
  --> $DIR/fn-or-tuple-struct-without-args.rs:46:20
   |
LL |     let closure = || 42;
   |                   -- closure defined here
LL |     let _: usize = closure;
   |                    ^^^^^^^
   |                    |
   |                    expected usize, found closure
   |                    help: use parentheses to call this closure: `closure()`
   |
   = note: expected type `usize`
              found type `[closure@$DIR/fn-or-tuple-struct-without-args.rs:45:19: 45:24]`
```

4 years agoRollup merge of #63813 - estebank:int-from, r=varkor
Mazdak Farrokhzad [Sun, 25 Aug 2019 00:44:59 +0000 (02:44 +0200)]
Rollup merge of #63813 - estebank:int-from, r=varkor

Do not suggest `.try_into()` on `i32::from(x)`

Fix #63697.

4 years agoRollup merge of #62744 - llogiq:tiny-list-refactor, r=eddyb
Mazdak Farrokhzad [Sun, 25 Aug 2019 00:44:58 +0000 (02:44 +0200)]
Rollup merge of #62744 - llogiq:tiny-list-refactor, r=eddyb

Refactor `TinyList::contains` and `len` to iterate instead of recurse

None

4 years agotypeck/pat.rs: dedup in `check_pat_box`.
Mazdak Farrokhzad [Sat, 24 Aug 2019 22:27:55 +0000 (00:27 +0200)]
typeck/pat.rs: dedup in `check_pat_box`.

4 years agotypeck/pat.rs: dedup in `check_pat_ref`.
Mazdak Farrokhzad [Sat, 24 Aug 2019 22:08:28 +0000 (00:08 +0200)]
typeck/pat.rs: dedup in `check_pat_ref`.

4 years agoreview comment
Esteban Küber [Sat, 24 Aug 2019 21:54:35 +0000 (14:54 -0700)]
review comment

4 years agoImprove the documentation for std::hint::black_box.
Edd Barrett [Tue, 23 Jul 2019 09:30:13 +0000 (10:30 +0100)]
Improve the documentation for std::hint::black_box.

4 years agotypeck/pat.rs: extract `error_inexistent_fields`.
Mazdak Farrokhzad [Sat, 24 Aug 2019 15:54:33 +0000 (17:54 +0200)]
typeck/pat.rs: extract `error_inexistent_fields`.

4 years agotypeck/pat.rs: extract `error_unmentioned_fields`.
Mazdak Farrokhzad [Sat, 24 Aug 2019 15:44:43 +0000 (17:44 +0200)]
typeck/pat.rs: extract `error_unmentioned_fields`.

4 years agotypeck/pat.rs: extract `error_field_already_bound`.
Mazdak Farrokhzad [Sat, 24 Aug 2019 15:34:15 +0000 (17:34 +0200)]
typeck/pat.rs: extract `error_field_already_bound`.

4 years agotypeck/pat.rs: extract diagnostics from `check_pat_slice`.
Mazdak Farrokhzad [Sat, 24 Aug 2019 14:42:15 +0000 (16:42 +0200)]
typeck/pat.rs: extract diagnostics from `check_pat_slice`.

4 years agotypeck/pat.rs: extract `new_ref_ty`.
Mazdak Farrokhzad [Sat, 24 Aug 2019 13:51:48 +0000 (15:51 +0200)]
typeck/pat.rs: extract `new_ref_ty`.

4 years agotypeck/pat.rs: some common imports.
Mazdak Farrokhzad [Sat, 24 Aug 2019 12:49:32 +0000 (14:49 +0200)]
typeck/pat.rs: some common imports.

4 years agotypeck/pat.rs: `check_pat_walk` -> `check_pat`.
Mazdak Farrokhzad [Sat, 24 Aug 2019 12:01:59 +0000 (14:01 +0200)]
typeck/pat.rs: `check_pat_walk` -> `check_pat`.

It's just shorter and we usually don't use the `_walk` suffix.

4 years agotypeck/pat.rs: `check_pat_top` is the entry point.
Mazdak Farrokhzad [Sat, 24 Aug 2019 11:47:07 +0000 (13:47 +0200)]
typeck/pat.rs: `check_pat_top` is the entry point.

This clarifies the fact that type checking patterns unconditionally
starts with `BindByValue` as the default binding mode making the
notion of a default binding mode internal to type checking patterns.

4 years agoAuto merge of #63858 - matthiaskrgr:submodule_upd, r=oli-obk
bors [Sat, 24 Aug 2019 17:49:35 +0000 (17:49 +0000)]
Auto merge of #63858 - matthiaskrgr:submodule_upd, r=oli-obk

submodules: update clippy from cd3df6be to 2bcb6155

Changes:
````
Refactor some minor things
Use more if-chains
Refactor 'lint_or_fun_call'
Refactor 'check_unwrap_or_default'
Refactor 'check_impl_item'
Add missing field to LitKind::Str
Run update_lints for Unicode lint
Re-add false positive check
Add raw string regression test for useless_format lint
Re-factor useless_format lint
Update Unicode lint tests
Add two more tests, allow 2 other lints.
Fix `temporary_cstring_as_ptr` false negative
Add more testcases for redundant_pattern_matching
Fix suggestions for redundant_pattern_matching
Add note on how to find the latest beta commit
Remove feature gate for async_await
Update if_chain doc link
Requested test cleanup
Requested changes
Ignore lines starting with '#'
run-rustfix for unseparated-prefix-literals
Add autofixable suggestion for unseparated integer literal suffices
Further text improvements
Add image
docs: Explain how to update the changelog
````

r? @oli-obk  @Manishearth

4 years agoDon't unwrap the result of `span_to_snippet`
Matthew Jasper [Sat, 24 Aug 2019 17:25:34 +0000 (18:25 +0100)]
Don't unwrap the result of `span_to_snippet`

It can return `Err` due to macros being expanded across crates or
files.

4 years agotypeck/pat.rs: `(*)` -> `(note_1)` for clarity.
Mazdak Farrokhzad [Sat, 24 Aug 2019 11:40:42 +0000 (13:40 +0200)]
typeck/pat.rs: `(*)` -> `(note_1)` for clarity.

4 years agotypeck/pat.rs: simplify `check_pat_walk`.
Mazdak Farrokhzad [Sat, 24 Aug 2019 03:13:57 +0000 (05:13 +0200)]
typeck/pat.rs: simplify `check_pat_walk`.

4 years agotypeck/pat.rs: extract `check_pat_slice`.
Mazdak Farrokhzad [Sat, 24 Aug 2019 03:08:49 +0000 (05:08 +0200)]
typeck/pat.rs: extract `check_pat_slice`.

4 years agotypeck/pat.rs: extract `check_pat_ref`.
Mazdak Farrokhzad [Sat, 24 Aug 2019 02:45:59 +0000 (04:45 +0200)]
typeck/pat.rs: extract `check_pat_ref`.

4 years agotypeck/pat.rs: extract `check_pat_box`.
Mazdak Farrokhzad [Sat, 24 Aug 2019 02:39:23 +0000 (04:39 +0200)]
typeck/pat.rs: extract `check_pat_box`.

4 years agotypeck/pat.rs: extract `check_pat_tuple`.
Mazdak Farrokhzad [Sat, 24 Aug 2019 02:30:03 +0000 (04:30 +0200)]
typeck/pat.rs: extract `check_pat_tuple`.

4 years agotypeck/pat.rs: extract `check_pat_ident`.
Mazdak Farrokhzad [Sat, 24 Aug 2019 02:19:16 +0000 (04:19 +0200)]
typeck/pat.rs: extract `check_pat_ident`.

4 years agotypeck/pat.rs: extract `check_pat_range`.
Mazdak Farrokhzad [Sat, 24 Aug 2019 01:59:15 +0000 (03:59 +0200)]
typeck/pat.rs: extract `check_pat_range`.

4 years agotypeck/pat.rs: extract `check_pat_lit`.
Mazdak Farrokhzad [Sat, 24 Aug 2019 01:52:09 +0000 (03:52 +0200)]
typeck/pat.rs: extract `check_pat_lit`.

4 years agotypeck/pat.rs: extract `calc_default_binding_mode`.
Mazdak Farrokhzad [Fri, 23 Aug 2019 14:06:33 +0000 (16:06 +0200)]
typeck/pat.rs: extract `calc_default_binding_mode`.

4 years agotypeck/pat.rs: simplify `peel_off_references`.
Mazdak Farrokhzad [Fri, 23 Aug 2019 13:55:35 +0000 (15:55 +0200)]
typeck/pat.rs: simplify `peel_off_references`.

4 years agotypeck/pat.rs: extract `peel_off_references` and define `def_bm` algorithm more decla...
Mazdak Farrokhzad [Fri, 23 Aug 2019 13:51:18 +0000 (15:51 +0200)]
typeck/pat.rs: extract `peel_off_references` and define `def_bm` algorithm more declaratively.

4 years agotypeck/pat.rs: extract `is_non_ref_pat`.
Mazdak Farrokhzad [Fri, 23 Aug 2019 13:31:38 +0000 (15:31 +0200)]
typeck/pat.rs: extract `is_non_ref_pat`.

4 years agotypeck/pat.rs: move note out of `check_dereferenceable` as it angers VSCode.
Mazdak Farrokhzad [Fri, 23 Aug 2019 13:05:58 +0000 (15:05 +0200)]
typeck/pat.rs: move note out of `check_dereferenceable` as it angers VSCode.

4 years agotypeck: move `check_pat_walk` and children to `pat.rs`.
Mazdak Farrokhzad [Fri, 23 Aug 2019 13:03:21 +0000 (15:03 +0200)]
typeck: move `check_pat_walk` and children to `pat.rs`.

4 years agoModifies how Arg, Arm, Field, FieldPattern and Variant are visited
Caio [Sat, 24 Aug 2019 16:54:40 +0000 (13:54 -0300)]
Modifies how Arg, Arm, Field, FieldPattern and Variant are visited

Part of the necessary work to accomplish #63468.

4 years agosubmodules: update clippy from cd3df6be to 2bcb6155
Matthias Krüger [Sat, 24 Aug 2019 16:47:43 +0000 (18:47 +0200)]
submodules: update clippy from cd3df6be to 2bcb6155

Changes:
````
Refactor some minor things
Use more if-chains
Refactor 'lint_or_fun_call'
Refactor 'check_unwrap_or_default'
Refactor 'check_impl_item'
Add missing field to LitKind::Str
Run update_lints for Unicode lint
Re-add false positive check
Add raw string regression test for useless_format lint
Re-factor useless_format lint
Update Unicode lint tests
Add two more tests, allow 2 other lints.
Fix `temporary_cstring_as_ptr` false negative
Add more testcases for redundant_pattern_matching
Fix suggestions for redundant_pattern_matching
Add note on how to find the latest beta commit
Remove feature gate for async_await
Update if_chain doc link
Requested test cleanup
Requested changes
Ignore lines starting with '#'
run-rustfix for unseparated-prefix-literals
Add autofixable suggestion for unseparated integer literal suffices
Further text improvements
Add image
docs: Explain how to update the changelog
````

4 years agoAuto merge of #63823 - petrochenkov:noapply2, r=matthewjasper
bors [Sat, 24 Aug 2019 14:07:06 +0000 (14:07 +0000)]
Auto merge of #63823 - petrochenkov:noapply2, r=matthewjasper

Audit uses of `apply_mark` in built-in macros + Remove default macro transparencies

Every use of `apply_mark` in a built-in or procedural macro is supposed to look like this
```rust
location.with_ctxt(SyntaxContext::root().apply_mark(ecx.current_expansion.id))
```
where `SyntaxContext::root()` means that the built-in/procedural macro is defined directly, rather than expanded from some other macro.

However, few people understood what `apply_mark` does, so we had a lot of copy-pasted uses of it looking e.g. like
```rust
span = span.apply_mark(ecx.current_expansion.id);
```
, which doesn't really make sense for procedural macros, but at the same time is not too harmful, if the macros use the traditional `macro_rules` hygiene.

So, to fight this, we stop using `apply_mark` directly in built-in macro implementations, and follow the example of regular proc macros instead and use analogues of `Span::def_site()` and `Span::call_site()`, which are much more intuitive and less error-prone.
- `ecx.with_def_site_ctxt(span)` takes the `span`'s location and combines it with a def-site context.
- `ecx.with_call_site_ctxt(span)` takes the `span`'s location and combines it with a call-site context.

Even if called multiple times (which sometimes happens due to some historical messiness of the built-in macro code) these functions will produce the same result, unlike `apply_mark` which will grow  the mark chain further in this case.

---

After `apply_mark`s in built-in macros are eliminated, the remaining `apply_mark`s are very few in number, so we can start passing the previously implicit `Transparency` argument to them explicitly, thus eliminating the need in `default_transparency` fields in hygiene structures and `#[rustc_macro_transparency]` annotations on built-in macros.

So, the task of making built-in macros opaque can now be formulated as "eliminate `with_legacy_ctxt` in favor of `with_def_site_ctxt`" rather than "replace `#[rustc_macro_transparency = "semitransparent"]` with `#[rustc_macro_transparency = "opaque"]`".

r? @matthewjasper

4 years agoAuto merge of #63637 - alexcrichton:remove-libtest-step, r=Mark-Simulacrum
bors [Sat, 24 Aug 2019 05:39:52 +0000 (05:39 +0000)]
Auto merge of #63637 - alexcrichton:remove-libtest-step, r=Mark-Simulacrum

bootstrap: Merge the libtest build step with libstd

Since its inception rustbuild has always worked in three stages: one for
libstd, one for libtest, and one for rustc. These three stages were
architected around crates.io dependencies, where rustc wants to depend
on crates.io crates but said crates don't explicitly depend on libstd,
requiring a sysroot assembly step in the middle. This same logic was
applied for libtest where libtest wants to depend on crates.io crates
(`getopts`) but `getopts` didn't say that it depended on std, so it
needed `std` built ahead of time.

Lots of time has passed since the inception of rustbuild, however,
and we've since gotten to the point where even `std` itself is depending
on crates.io crates (albeit with some wonky configuration). This
commit applies the same logic to the two dependencies that the `test`
crate pulls in from crates.io, `getopts` and `unicode-width`. Over the
many years since rustbuild's inception `unicode-width` was the only
dependency picked up by the `test` crate, so the extra configuration
necessary to get crates building in this crate graph is unlikely to be
too much of a burden on developers.

After this patch it means that there are now only two build phasese of
rustbuild, one for libstd and one for rustc. The libtest/libproc_macro
build phase is all lumped into one now with `std`.

This was originally motivated by rust-lang/cargo#7216 where Cargo was
having to deal with synthesizing dependency edges but this commit makes
them explicit in this repository.

4 years agoAuto merge of #63824 - Centril:split-feature_gate, r=oli-obk
bors [Sat, 24 Aug 2019 01:50:03 +0000 (01:50 +0000)]
Auto merge of #63824 - Centril:split-feature_gate, r=oli-obk

Refactor `feature_gate.rs` into modules & cleanup

Split `src/libsyntax/feature_gate.rs` into `src/libsyntax/feature_gate/` with files:
- `accepted.rs` (accepted feature gates)
- `removed.rs` (...)
- `active.rs` (...)
- `builtin_attrs.rs` (definition of builtin attributes and their gates as well as gating `cfg` flags)
- `check.rs` (post expansion checking of feature gates)
- `mod.rs` (just reexports)

Additionally, `tidy.rs` is adjusted to respect the new scheme.

Also, `builtin_attrs.rs` sees some cleanup, organization, and DSL-ification to reduce repetition.

This is probably best read commit-by-commit I think.

r? @oli-obk

4 years agoFix incremental tests
Wesley Wiser [Thu, 22 Aug 2019 01:38:23 +0000 (21:38 -0400)]
Fix incremental tests

4 years agoEnsure miri can do bit ops on pointer values
Oliver Scherer [Sat, 24 Aug 2019 00:23:56 +0000 (02:23 +0200)]
Ensure miri can do bit ops on pointer values

4 years agobootstrap: Merge the libtest build step with libstd
Alex Crichton [Fri, 16 Aug 2019 15:29:08 +0000 (08:29 -0700)]
bootstrap: Merge the libtest build step with libstd

Since its inception rustbuild has always worked in three stages: one for
libstd, one for libtest, and one for rustc. These three stages were
architected around crates.io dependencies, where rustc wants to depend
on crates.io crates but said crates don't explicitly depend on libstd,
requiring a sysroot assembly step in the middle. This same logic was
applied for libtest where libtest wants to depend on crates.io crates
(`getopts`) but `getopts` didn't say that it depended on std, so it
needed `std` built ahead of time.

Lots of time has passed since the inception of rustbuild, however,
and we've since gotten to the point where even `std` itself is depending
on crates.io crates (albeit with some wonky configuration). This
commit applies the same logic to the two dependencies that the `test`
crate pulls in from crates.io, `getopts` and `unicode-width`. Over the
many years since rustbuild's inception `unicode-width` was the only
dependency picked up by the `test` crate, so the extra configuration
necessary to get crates building in this crate graph is unlikely to be
too much of a burden on developers.

After this patch it means that there are now only two build phasese of
rustbuild, one for libstd and one for rustc. The libtest/libproc_macro
build phase is all lumped into one now with `std`.

This was originally motivated by rust-lang/cargo#7216 where Cargo was
having to deal with synthesizing dependency edges but this commit makes
them explicit in this repository.

4 years agoAuto merge of #63814 - malbarbo:wasi-error-kind, r=alexcrichton
bors [Fri, 23 Aug 2019 22:09:07 +0000 (22:09 +0000)]
Auto merge of #63814 - malbarbo:wasi-error-kind, r=alexcrichton

Implement decode_error_kind for wasi

Based on the implementation for unix targets,

4 years agoSuggest calling closure with resolved return type when appropriate
Esteban Küber [Fri, 23 Aug 2019 18:14:11 +0000 (11:14 -0700)]
Suggest calling closure with resolved return type when appropriate

4 years agoAuto merge of #63819 - najamelan:patch-1, r=Centril
bors [Fri, 23 Aug 2019 16:22:06 +0000 (16:22 +0000)]
Auto merge of #63819 - najamelan:patch-1, r=Centril

rustc docs: Update single-use-lifetimes

When using this, rustc emits a warning that the lint has been renamed (to having an 's' at the end)

4 years agoImplement decode_error_kind for wasi
Marco A L Barbosa [Thu, 22 Aug 2019 17:40:21 +0000 (14:40 -0300)]
Implement decode_error_kind for wasi

Based on the implementation for unix targets

4 years agoAuto merge of #63815 - sebastinez:sebastinez-doc-#63792, r=jonas-schievink
bors [Fri, 23 Aug 2019 12:40:32 +0000 (12:40 +0000)]
Auto merge of #63815 - sebastinez:sebastinez-doc-#63792, r=jonas-schievink

Update occurences of as_slice to as_str in comments

Fix #63792

4 years agoAuto merge of #63521 - newpavlov:redox_builder, r=pietroalbini
bors [Fri, 23 Aug 2019 08:58:24 +0000 (08:58 +0000)]
Auto merge of #63521 - newpavlov:redox_builder, r=pietroalbini

Re-enable Redox builder (take 2)

Closes: #63160
4 years agoAuto merge of #63808 - Rosto75:master, r=KodrAus
bors [Fri, 23 Aug 2019 05:11:41 +0000 (05:11 +0000)]
Auto merge of #63808 - Rosto75:master, r=KodrAus

A bunch of minor documentation tweaks and fixes.

4 years agoAuto merge of #63801 - jeremystucki:patch-1, r=jonas-schievink
bors [Fri, 23 Aug 2019 01:27:58 +0000 (01:27 +0000)]
Auto merge of #63801 - jeremystucki:patch-1, r=jonas-schievink

Update .mailmap

4 years ago`--bless` some tests due to message format change.
Mazdak Farrokhzad [Thu, 22 Aug 2019 23:09:51 +0000 (01:09 +0200)]
`--bless` some tests due to message format change.

4 years agoFix `tidy` fallout due to `feature_gate.rs` refactoring.
Mazdak Farrokhzad [Thu, 22 Aug 2019 22:06:32 +0000 (00:06 +0200)]
Fix `tidy` fallout due to `feature_gate.rs` refactoring.

4 years agosyntax: move `feature_gate.rs`.
Mazdak Farrokhzad [Thu, 22 Aug 2019 21:49:55 +0000 (23:49 +0200)]
syntax: move `feature_gate.rs`.

4 years agosyntax: extract `check.rs`.
Mazdak Farrokhzad [Thu, 22 Aug 2019 21:48:08 +0000 (23:48 +0200)]
syntax: extract `check.rs`.

4 years agobuiltin_attrs.rs: retain FIXMEs.
Mazdak Farrokhzad [Thu, 22 Aug 2019 21:35:03 +0000 (23:35 +0200)]
builtin_attrs.rs: retain FIXMEs.

4 years agobuiltin_attrs.rs: organize!
Mazdak Farrokhzad [Thu, 22 Aug 2019 21:30:59 +0000 (23:30 +0200)]
builtin_attrs.rs: organize!

4 years agobuiltin_attrs.rs: cleanup with `(un)gated!`.
Mazdak Farrokhzad [Thu, 22 Aug 2019 18:40:50 +0000 (20:40 +0200)]
builtin_attrs.rs: cleanup with `(un)gated!`.

4 years agobuiltin_attrs.rs: refactor `rustc_attrs` entries.
Mazdak Farrokhzad [Thu, 22 Aug 2019 17:37:04 +0000 (19:37 +0200)]
builtin_attrs.rs: refactor `rustc_attrs` entries.

4 years agobuiltin_attrs.rs: simplify `cfg_fn`.
Mazdak Farrokhzad [Thu, 22 Aug 2019 16:37:28 +0000 (18:37 +0200)]
builtin_attrs.rs: simplify `cfg_fn`.

4 years agosyntax: extract `builin_attrs.rs`.
Mazdak Farrokhzad [Thu, 22 Aug 2019 16:32:31 +0000 (18:32 +0200)]
syntax: extract `builin_attrs.rs`.

4 years agosyntax: extract `active.rs` feature gates.
Mazdak Farrokhzad [Tue, 20 Aug 2019 16:50:33 +0000 (18:50 +0200)]
syntax: extract `active.rs` feature gates.

4 years agosyntax: extract `removed.rs` feature gates.
Mazdak Farrokhzad [Tue, 20 Aug 2019 16:41:18 +0000 (18:41 +0200)]
syntax: extract `removed.rs` feature gates.

4 years agosyntax: extract `accepted.rs` feature gates.
Mazdak Farrokhzad [Tue, 20 Aug 2019 16:40:53 +0000 (18:40 +0200)]
syntax: extract `accepted.rs` feature gates.

4 years agoRemove default macro transparencies
Vadim Petrochenkov [Thu, 22 Aug 2019 22:44:18 +0000 (01:44 +0300)]
Remove default macro transparencies

All transparancies are passed explicitly now.
Also remove `#[rustc_macro_transparency]` annotations from built-in macros, they are no longer used.
`#[rustc_macro_transparency]` only makes sense for declarative macros now.

4 years agohygiene: Require passing transparency explicitly to `apply_mark`
Vadim Petrochenkov [Thu, 22 Aug 2019 22:31:01 +0000 (01:31 +0300)]
hygiene: Require passing transparency explicitly to `apply_mark`

4 years agoincremental: Do not rely on default transparency when decoding syntax contexts
Vadim Petrochenkov [Thu, 22 Aug 2019 21:27:46 +0000 (00:27 +0300)]
incremental: Do not rely on default transparency when decoding syntax contexts

Using `ExpnId`s default transparency here instead of the mark's real transparency was actually incorrect.

4 years agoresolve: Do not rely on default transparency when detecting proc macro derives
Vadim Petrochenkov [Wed, 21 Aug 2019 22:29:34 +0000 (01:29 +0300)]
resolve: Do not rely on default transparency when detecting proc macro derives

4 years agoAudit uses of `apply_mark` in built-in macros
Vadim Petrochenkov [Wed, 21 Aug 2019 18:28:22 +0000 (21:28 +0300)]
Audit uses of `apply_mark` in built-in macros

Replace them with equivalents of `Span::{def_site,call_site}` from proc macro API.
The new API is much less error prone and doesn't rely on macros having default transparency.

4 years agoUpdate single-use-lifetimes
Naja Melan [Thu, 22 Aug 2019 22:39:21 +0000 (22:39 +0000)]
Update single-use-lifetimes

When using this, rustc emits a warning that the lint has been renamed (to having an 's' at the end)

4 years agoAuto merge of #63522 - topecongiro:rustfmt-1.4.5, r=Centril
bors [Thu, 22 Aug 2019 21:51:14 +0000 (21:51 +0000)]
Auto merge of #63522 - topecongiro:rustfmt-1.4.5, r=Centril

Update rustfmt to 1.4.5

This update includes a bug fix that fixes generating invalid code when formatting an impl block with const generics inside a where clause.

**Changes**
https://github.com/rust-lang/rustfmt/compare/0462008de87d2757e8ef1dc26f2c54dd789a59a8...1de58ce46d64b1164a214dc0b7fb7c400576c3a6

4 years agoDo not suggest `.try_into()` on `i32::from(x)`
Esteban Küber [Thu, 22 Aug 2019 17:38:09 +0000 (10:38 -0700)]
Do not suggest `.try_into()` on `i32::from(x)`

4 years agoUpdate occurences of as_slice
Sebastian Martinez [Thu, 22 Aug 2019 19:16:22 +0000 (16:16 -0300)]
Update occurences of as_slice

Update occurences of as_slice to as_str

4 years agoAuto merge of #63807 - Centril:rollup-b8lo8ct, r=Centril
bors [Thu, 22 Aug 2019 18:06:31 +0000 (18:06 +0000)]
Auto merge of #63807 - Centril:rollup-b8lo8ct, r=Centril

Rollup of 7 pull requests

Successful merges:

 - #63624 (When declaring a declarative macro in an item it's only accessible inside it)
 - #63737 (Fix naming misspelling)
 - #63767 (Use more optimal Ord implementation for integers)
 - #63782 (Fix confusion in theme picker functions)
 - #63788 (Add amanjeev to rustc-guide toolstate)
 - #63796 (Tweak E0308 on opaque types)
 - #63805 (Apply few Clippy suggestions)

Failed merges:

r? @ghost

4 years agoFix for 7e13679.
Tomasz Różański [Thu, 22 Aug 2019 17:27:16 +0000 (19:27 +0200)]
Fix for 7e13679.

4 years agoUpdate .mailmap
Jeremy Stucki [Thu, 22 Aug 2019 14:47:42 +0000 (16:47 +0200)]
Update .mailmap

4 years agoRollup merge of #63805 - mati865:clippy, r=Centril
Mazdak Farrokhzad [Thu, 22 Aug 2019 13:15:45 +0000 (15:15 +0200)]
Rollup merge of #63805 - mati865:clippy, r=Centril

Apply few Clippy suggestions

Somewhat follow-up of https://github.com/rust-lang/rust/pull/62806

Changes per commit are rather small so I can squash them if that's preferred.

4 years agoRollup merge of #63796 - estebank:opaque_future, r=Centril
Mazdak Farrokhzad [Thu, 22 Aug 2019 13:15:43 +0000 (15:15 +0200)]
Rollup merge of #63796 - estebank:opaque_future, r=Centril

Tweak E0308 on opaque types

```
error[E0308]: if and else have incompatible types
  --> file.rs:21:9
   |
18 | /     if true {
19 | |         thing_one()
   | |         ----------- expected because of this
20 | |     } else {
21 | |         thing_two()
   | |         ^^^^^^^^^^^ expected opaque type, found a different opaque type
22 | |     }.await
   | |_____- if and else have incompatible types
   |
   = note: expected type `impl std::future::Future` (opaque type)
              found type `impl std::future::Future` (opaque type)
   = note: distinct uses of `impl Trait` result in different opaque types
   = help: if both futures resolve to the same type, consider `await`ing on both of them
```

r? @Centril
CC #63167

4 years agoRollup merge of #63788 - mark-i-m:rustc-guide-toolstate-add, r=ehuss
Mazdak Farrokhzad [Thu, 22 Aug 2019 13:15:42 +0000 (15:15 +0200)]
Rollup merge of #63788 - mark-i-m:rustc-guide-toolstate-add, r=ehuss

Add amanjeev to rustc-guide toolstate

cc @amanjeev @spastorino

r? @ehuss

4 years agoRollup merge of #63782 - GuillaumeGomez:theme-switch-fix, r=kinnison
Mazdak Farrokhzad [Thu, 22 Aug 2019 13:15:40 +0000 (15:15 +0200)]
Rollup merge of #63782 - GuillaumeGomez:theme-switch-fix, r=kinnison

Fix confusion in theme picker functions

To reproduce the bug currently: click on the theme picker button twice (to show it then hide it). Then click anywhere else: the dropdown menu appears again.

The problem was coming from a confusion of what the `hideThemeButtonState` and `showThemeButtonState` were supposed to do. I switched their codes and updated the `switchThemeButtonState` function. It now works as expected.

r? @kinnison

4 years agoRollup merge of #63767 - lzutao:integer-ord-suboptimal, r=nagisa
Mazdak Farrokhzad [Thu, 22 Aug 2019 13:15:38 +0000 (15:15 +0200)]
Rollup merge of #63767 - lzutao:integer-ord-suboptimal, r=nagisa

Use more optimal Ord implementation for integers

Closes #63758
r? @nagisa

### Compare results

([godbolt link](https://godbolt.org/z/dsbczy))

Old assembly:
```asm
example::cmp1:
  mov eax, dword ptr [rdi]
  mov ecx, dword ptr [rsi]
  cmp eax, ecx
  setae dl
  add dl, dl
  add dl, -1
  xor esi, esi
  cmp eax, ecx
  movzx eax, dl
  cmove eax, esi
  ret
```

New assembly:
```asm
example::cmp2:
  mov eax, dword ptr [rdi]
  xor ecx, ecx
  cmp eax, dword ptr [rsi]
  seta cl
  mov eax, 255
  cmovae eax, ecx
  ret
```

Old llvm-mca statistics:
```
Iterations:        100
Instructions:      1100
Total Cycles:      243
Total uOps:        1300

Dispatch Width:    6
uOps Per Cycle:    5.35
IPC:               4.53
Block RThroughput: 2.2
```

New llvm-mca statistics:
```
Iterations:        100
Instructions:      700
Total Cycles:      217
Total uOps:        1100

Dispatch Width:    6
uOps Per Cycle:    5.07
IPC:               3.23
Block RThroughput: 1.8
```

4 years agoRollup merge of #63737 - HowJMay:fix_naming, r=jonas-schievink
Mazdak Farrokhzad [Thu, 22 Aug 2019 13:15:36 +0000 (15:15 +0200)]
Rollup merge of #63737 - HowJMay:fix_naming, r=jonas-schievink

Fix naming misspelling

Fixes #63734