Commit Graph

76614 Commits

Author SHA1 Message Date
bors
c75d5e242f Auto merge of #48647 - alexcrichton:update-sccache, r=kennytm
Update sccache to its master branch

Ideally I'd like to soon enable sccache for rustbuild itself and some of the
stage0 tools, but for that to work we'll need some better Rust support than the
pretty old version we were previously using!
2018-04-03 22:21:37 +00:00
memoryleak47
03e1509f57 make tidy happy 2018-04-03 23:36:47 +02:00
memoryleak47
da4bf14057 running compiletest with --compare-mode will now run, even if the stamp is up to date 2018-04-03 22:22:58 +02:00
Austin Bonander
5d74990ceb expand macro invocations in extern {} blocks 2018-04-03 13:16:11 -07:00
steveklabnik
77b570f831 Re-write the documentation index
The docs team has decided that we're framing resources in three ways:
"learning Rust," "using Rust," "mastering Rust." This is a more useful
split than "beginner/intermediate/advanced." As we add more resources
in the future, we expect "using Rust" to grow. "the bookshelf" as a
concept is great, but isn't really organized along these lines. As such,
this reorganizes the docs along these lines.
2018-04-03 15:58:15 -04:00
Mark Simulacrum
184d3bca6c Stop checking that the graph produced by a dry run is equivalent
This is too likely to cause spurious bounces on CI; what we run may be
dependent on what ran successfully before hand (e.g. RLS features with
Clippy), which makes this not tenable. There's no good way to ignore
specifically these problematic steps so we'll just ignore everything for
the time being. We still test that a dry run worked though so largely
this is the same from a ensure-that-tests-work perspective.

Eventually we'll want to undo this commit, though, to make our tests
more accurate.
2018-04-03 11:43:14 -06:00
Mark Simulacrum
0ce5cf0697 Fix a few accidental expectations 2018-04-03 11:43:14 -06:00
Mark Simulacrum
545b92f46d Avoid printing output when in dry run mode 2018-04-03 11:43:14 -06:00
Mark Simulacrum
a727447f59 Refactor to use a dry-run config instead of cfg(test)
This ensures that each build will support the testing design of "dry
running" builds. It's also checked that a dry run build is equivalent
step-wise to a "wet" run build; the graphs we generate when running are
directly compared node/node and edge/edge, both for order and contents.
2018-04-03 11:43:14 -06:00
Mark Simulacrum
b0dbc7c15d Implement generating graphs of the build steps 2018-04-03 11:43:12 -06:00
Mark Simulacrum
f4620a3d14 Stub out less code 2018-04-03 11:41:51 -06:00
Mark Simulacrum
42fde21c27 Add tests to rustbuild
In order to run tests, previous commits have cfg'd out various parts of
rustbuild. Generally speaking, these are filesystem-related operations
and process-spawning related parts. Then, rustbuild is run "as normal"
and the various steps that where run are retrieved from the cache and
checked against the expected results.

Note that this means that the current implementation primarily tests
"what" we build, but doesn't actually test that what we build *will*
build. In other words, it doesn't do any form of dependency verification
for any crate. This is possible to implement, but is considered future
work.

This implementation strives to cfg out as little code as possible; it
also does not currently test anywhere near all of rustbuild. The current
tests are also not checked for "correctness," rather, they simply
represent what we do as of this commit, which may be wrong.

Test cases are drawn from the old implementation of rustbuild, though
the expected results may vary.
2018-04-03 11:41:50 -06:00
Mark Simulacrum
8fd42ec130 Extract default Config into function
Will permit creating Config in tests without having to parse a toml
file.
2018-04-03 11:39:16 -06:00
Mark Simulacrum
fde70b0963 Make test steps sortable
Ensures that test cases will be somewhat easier to write.
2018-04-03 11:39:16 -06:00
Mark Simulacrum
cd33d3a0e4 Stub out various functions during testing 2018-04-03 11:39:16 -06:00
Mark Simulacrum
e7342b8f42 Permit constructing Build without executing 2018-04-03 11:39:16 -06:00
Mark Simulacrum
a5e56b62c5 Permit constructing Builder without executing 2018-04-03 11:39:16 -06:00
Mark Simulacrum
84b5b34021 Stop accessing current_dir in bootstrap
This ensures that the working directory of rustbuild has no effect on
it's run; since tests will run with a different cwd this is required for
consistent behavior.
2018-04-03 11:39:15 -06:00
Dirkjan Ochtman
da0ceeff5a Introduce Vec::resize_with method (see #41758) 2018-04-03 17:12:59 +02:00
Alex Burka
333b0a0471
tweak format_args! docs
Swap the variable names in the example.
2018-04-03 09:20:04 -04:00
leonardo.yvens
0a3eb5c508 Simplify code around expected argument types. 2018-04-03 10:19:26 -03:00
Alex Burka
93a3e93bf3
tweak fmt::Arguments docs
Remove an outdated claim about passing something or other to a function. Also swap the variable names in the example.
2018-04-03 09:11:41 -04:00
leonardo.yvens
ba5a5cf219 Remove single use helper function. 2018-04-03 10:04:56 -03:00
Vadzim Dambrouski
f5c42655b5 Fix warning when compilin libcore on 16bit targets.
Fixes #49617
2018-04-03 15:33:32 +03:00
leonardo.yvens
21641d6d2c Refactor inner function into closure.
So we can cut some params by using stuff from the environment.
2018-04-03 09:31:45 -03:00
Wim Looman
c4c521457b impl Unpin for Pin 2018-04-03 14:30:07 +02:00
bors
637ac17c52 Auto merge of #49447 - pnkfelix:remove-cfg-const-pat-hack-47295, r=nikomatsakis
Remove adjacent all-const match arm hack.

An old fix for moves-in-guards had a hack for adjacent all-const match arms.

The hack was explained in a comment, which you can see here:
https://github.com/rust-lang/rust/pull/22580/files#diff-402a0fa4b3c6755c5650027c6d4cf1efR497

But hack was incomplete (and thus unsound), as pointed out here:
https://github.com/rust-lang/rust/issues/47295#issuecomment-357108458

Plus, it is likely to be at least tricky to reimplement this hack in
the new NLL borrowck.

So rather than try to preserve the hack, we want to try to just remove
it outright. (At least to see the results of a crater run.)

[breaking-change]

This is a breaking-change, but our hope is that no one is actually
relying on such an extreme special case. (We hypothesize the hack was
originally added to accommodate a file in our own test suite, not code
in the wild.)
2018-04-03 11:50:11 +00:00
bors
b12af86a77 Auto merge of #49348 - bobtwinkles:extend_2pb, r=nikomatsakis
Extend two-phase borrows to apply to method receiver autorefs

Fixes #48598 by permitting two-phase borrows on the autorefs created when functions and methods.
2018-04-03 09:11:35 +00:00
Aidan Hobson Sayers
9b5859aea1 Remove all unstable placement features
Closes #22181, #27779
2018-04-03 11:02:34 +02:00
Jorge Aparicio
862c839fb9 extend no-std-ness check to all *-none-* targets 2018-04-03 08:29:09 +02:00
bors
577d29c10a Auto merge of #49098 - matklad:find_map, r=KodrAus
Add Iterator::find_map

I'd like to propose to add `find_map` method to the `Iterator`: an occasionally useful utility, which relates to `filter_map` in the same way that `find` relates to `filter`.

`find_map` takes an `Option`-returning function, applies it to the elements of the iterator, and returns the first non-`None` result. In other words, `find_map(f) == filter_map(f).next()`.

Why do we want to add a function to the `Iterator`, which can be trivially expressed as a combination of existing ones? Observe that `find(f) == filter(f).next()`, so, by the same logic, `find` itself is unnecessary!

The more positive argument is that desugaring of  `find[_map]` in terms of `filter[_map]().next()` is not super obvious, because the `filter` operation reads as if it is applies to the whole collection, although in reality we are interested only in the first element. That is, the jump from "I need a **single** result" to "let's use a function which maps **many** values to **many** values" is a non-trivial speed-bump, and causes friction when reading and writing code.

Does the need for `find_map` arise in practice? Yes!

* Anecdotally, I've more than once searched the docs for the function with `[T] -> (T -> Option<U>) -> Option<U>` signature.
* The direct cause for this PR was [this](1291c50e86 (r174934173)) discussion in Cargo, which boils down to "there's some pattern that we try to express here, but current approaches looks non-pretty" (and the pattern is `filter_map`
* There are several `filter_map().next` combos in Cargo: [[1]](545a4a2c93/src/cargo/ops/cargo_new.rs (L585)), [[2]](545a4a2c93/src/cargo/core/resolver/mod.rs (L1130)), [[3]](545a4a2c93/src/cargo/ops/cargo_rustc/mod.rs (L1086)).
* I've also needed similar functionality in `Kotlin` several times. There, it is expressed as `mapNotNull {}.firstOrNull`, as can be seen [here](ee8bdb4e07/src/main/kotlin/org/rust/cargo/project/model/impl/CargoProjectImpl.kt (L154)), [here](ee8bdb4e07/src/main/kotlin/org/rust/lang/core/resolve/ImplLookup.kt (L444)) [here](ee8bdb4e07/src/main/kotlin/org/rust/ide/inspections/RsLint.kt (L38)) and [here](ee8bdb4e07/src/main/kotlin/org/rust/cargo/toolchain/RustToolchain.kt (L74)) (and maybe in some other cases as well)

Note that it is definitely not among the most popular functions (it definitely is less popular than `find`), but, for example it (in case of Cargo) seems to be more popular than `rposition` (1 occurrence), `step_by` (zero occurrences) and `nth` (three occurrences as `nth(0)` which probably should be replaced with `next`).

Do we necessary need this function in `std`? Could we move it to itertools? That is possible, but observe that `filter`, `filter_map`, `find` and `find_map` together really form a complete table:

|||
|-------|---------|
| filter| find|
|filter_map|find_map|

It would be somewhat unsatisfying to have one quarter of this table live elsewhere :) Also, if `Itertools` adds an `find_map` method, it would be more difficult to move it to std due to name collision.

Hm, at this point I've searched for `filter_map` the umpteenth time, and, strangely, this time I do find this RFC: https://github.com/rust-lang/rfcs/issues/1801. I guess this could be an implementation though? :)

To sum up:

Pro:
  - complete the symmetry with existing method
  - codify a somewhat common non-obvious pattern

Contra:
  - niche use case
  - we can, and do, live without it
2018-04-03 06:28:41 +00:00
Jorge Aparicio
d0693548cd merge dist-various-3 into dist-various-1 2018-04-03 08:26:24 +02:00
Tatsuyuki Ishi
7db854b36f Fix imports 2018-04-03 12:42:36 +09:00
Thayne McCombs
e75c6a741e Remove splice page from unstable book. 2018-04-02 19:41:22 -06:00
Thayne McCombs
a64acaa1a2 Merge remote-tracking branch 'upstream/master' into string-splice-stabilize 2018-04-02 19:36:13 -06:00
Thayne McCombs
9ab5788e0e Fix "since" version for getpid feature.
It was stabilized right before the beta branch was cut for 1.26.0.

See https://github.com/rust-lang/rust/pull/49523#issuecomment-377996315
2018-04-02 19:34:06 -06:00
Austin Bonander
58217edd2f run-pass/attr-stmt-expr: expand test cases 2018-04-02 17:21:37 -07:00
Josh Stone
9db63bb033 Stabilize iterator_try_fold in 1.27.0 2018-04-02 16:40:53 -07:00
Josh Stone
d8c4c83dad Stabilize iter_rfind in 1.27.0 2018-04-02 16:37:06 -07:00
Josh Stone
1c8d10bce5 Stabilize iter_rfold in 1.27.0 2018-04-02 16:33:09 -07:00
bors
5ee891cfea Auto merge of #49590 - alexcrichton:update-deps, r=Mark-Simulacrum
Bump to 1.27.0

Also update some `Cargo.lock` dependencies, finishing up some final steps of our
[release process]!

This doesn't update the bootstrap compiler just yet but that will come in a
follow-up PR.

[release process]: https://forge.rust-lang.org/release-process.html
2018-04-02 22:37:15 +00:00
David Wood
138472bdc6
Checking location and syntax of non_exhaustive attribute. 2018-04-02 23:02:29 +01:00
varkor
b2ed9dd546
Replace as_ref with & 2018-04-02 22:57:47 +01:00
Aleksey Kladov
591dd5d992 Add Iterator::find_map 2018-04-03 00:47:00 +03:00
Alex Crichton
553c04d9eb proc_macro: Reorganize public API
This commit is a reorganization of the `proc_macro` crate's public user-facing
API. This is the result of a number of discussions at the recent Rust All-Hands
where we're hoping to get the `proc_macro` crate into ship shape for
stabilization of a subset of its functionality in the Rust 2018 release.

The reorganization here is motivated by experiences from the `proc-macro2`,
`quote`, and `syn` crates on crates.io (and other crates which depend on them).
The main focus is future flexibility along with making a few more operations
consistent and/or fixing bugs. A summary of the changes made from today's
`proc_macro` API is:

* The `TokenNode` enum has been removed and the public fields of `TokenTree`
  have also been removed. Instead the `TokenTree` type is now a public enum
  (what `TokenNode` was) and each variant is an opaque struct which internally
  contains `Span` information. This makes the various tokens a bit more
  consistent, require fewer wrappers, and otherwise provides good
  future-compatibility as opaque structs are easy to modify later on.

* `Literal` integer constructors have been expanded to be unambiguous as to what
  they're doing and also allow for more future flexibility. Previously
  constructors like `Literal::float` and `Literal::integer` were used to create
  unsuffixed literals and the concrete methods like `Literal::i32` would create
  a suffixed token. This wasn't immediately clear to all users (the
  suffixed/unsuffixed aspect) and having *one* constructor for unsuffixed
  literals required us to pick a largest type which may not always be true. To
  fix these issues all constructors are now of the form
  `Literal::i32_unsuffixed` or `Literal::i32_suffixed` (for all integral types).
  This should allow future compatibility as well as being immediately clear
  what's suffixed and what isn't.

* Each variant of `TokenTree` internally contains a `Span` which can also be
  configured via `set_span`. For example `Literal` and `Term` now both
  internally contain a `Span` rather than having it stored in an auxiliary
  location.

* Constructors of all tokens are called `new` now (aka `Term::intern` is gone)
  and most do not take spans. Manufactured tokens typically don't have a fresh
  span to go with them and the span is purely used for error-reporting
  **except** the span for `Term`, which currently affects hygiene. The default
  spans for all these constructed tokens is `Span::call_site()` for now.

  The `Term` type's constructor explicitly requires passing in a `Span` to
  provide future-proofing against possible hygiene changes. It's intended that a
  first pass of stabilization will likely only stabilize `Span::call_site()`
  which is an explicit opt-in for "I would like no hygiene here please". The
  intention here is to make this explicit in procedural macros to be
  forwards-compatible with a hygiene-specifying solution.

* Some of the conversions for `TokenStream` have been simplified a little.

* The `TokenTreeIter` iterator was renamed to `token_stream::IntoIter`.

Overall the hope is that this is the "final pass" at the API of `TokenStream`
and most of `TokenTree` before stabilization. Explicitly left out here is any
changes to `Span`'s API which will likely need to be re-evaluated before
stabilization.

All changes in this PR have already been reflected to the [`proc-macro2`],
`quote`, and `syn` crates. New versions of all these crates have also been
published to crates.io.

Once this lands in nightly I plan on making an internals post again summarizing
the changes made here and also calling on all macro authors to give the APIs a
spin and see how they work. Hopefully pending no major issues we can then have
an FCP to stabilize later this cycle!

[`proc-macro2`]: https://docs.rs/proc-macro2/0.3.1/proc_macro2/
2018-04-02 13:48:34 -07:00
Alexandre Martin
1074a22905
Fix comment 2018-04-02 22:25:22 +02:00
Rolf van de Krol
a2a0f21ba1 Fix typo 2018-04-02 21:48:56 +02:00
Alex Crichton
e9d898318c Bump to 1.27.0
Also update some `Cargo.lock` dependencies, finishing up some final steps of our
[release process]!

This doesn't update the bootstrap compiler just yet but that will come in a
follow-up PR.

[release process]: https://forge.rust-lang.org/release-process.html
2018-04-02 12:42:44 -07:00
QuietMisdreavus
8145a77a28 suppress the default allow(unused) under --display-warnings 2018-04-02 14:37:16 -05:00
Alex Crichton
64f7e11fc3 Update sccache to its master branch
Ideally I'd like to soon enable sccache for rustbuild itself and some of the
stage0 tools, but for that to work we'll need some better Rust support than the
pretty old version we were previously using!
2018-04-02 12:24:50 -07:00