Rollup merge of #60188 - estebank:recover-block, r=varkor
Identify when a stmt could have been parsed as an expr
There are some expressions that can be parsed as a statement without
a trailing semicolon depending on the context, which can lead to
confusing errors due to the same looking code being accepted in some
places and not others. Identify these cases and suggest enclosing in
parenthesis making the parse non-ambiguous without changing the
accepted grammar.
bors [Thu, 9 May 2019 18:43:00 +0000 (18:43 +0000)]
Auto merge of #60672 - Centril:rollup-fhcx463, r=Centril
Rollup of 5 pull requests
Successful merges:
- #60601 (Add a `cast` method to raw pointers.)
- #60638 (pin: make the to-module link more visible)
- #60647 (cleanup: Remove `DefIndexAddressSpace`)
- #60656 (Inline some Cursor calls for slices)
- #60657 (Stabilize and re-export core::array in std)
Rollup merge of #60656 - petertodd:2019-inline-cursor-over-slice, r=sfackler
Inline some Cursor calls for slices
(Partially) brings back https://github.com/rust-lang/rust/pull/33921
I've noticed in some serialization code I was writing that writes to slices produce much, much, worse code than you'd expect even with optimizations turned on. For example, you'd expect something like this to be zero cost:
```
use std::io::{self, Cursor, Write};
pub fn serialize((a, b): (u64, u64)) -> [u8;8+8] {
let mut r = [0u8;16];
{
let mut w = Cursor::new(&mut r[..]);
w.write(&a.to_le_bytes()).unwrap();
w.write(&b.to_le_bytes()).unwrap();
}
r
}
```
...but it compiles down to [dozens of instructions](https://rust.godbolt.org/z/bdwDzb) because the `slice_write()` calls aren't inlined, which in turn means `unwrap()` can't be optimized away, and so on.
To be clear, this pull-req isn't sufficient by itself: if we want to go down that path we also need to add `#[inline]`'s to the default implementations for functions like `write_all()` in the `Write` trait and so on, or implement them separately in the `Cursor` impls. But I figured I'd start a conversation about what tradeoffs we're expecting here.
Rollup merge of #60647 - petrochenkov:nospace, r=michaelwoerister
cleanup: Remove `DefIndexAddressSpace`
The scheme with two address spaces for `DefIndex` was needed in the past, but apparently not needed anymore (after removing `DefId`s from locals and `HirId`-ification).
bors [Wed, 8 May 2019 22:59:23 +0000 (22:59 +0000)]
Auto merge of #60651 - Centril:rollup-zoamjfk, r=Centril
Rollup of 8 pull requests
Successful merges:
- #59979 (to_xe_bytes for isize and usize returns an array of different size)
- #60491 (std: Update compiler-builtins crate)
- #60550 (Add tests for concrete const types)
- #60572 (Add test for #59972)
- #60627 (test for #50518)
- #60634 (Document + Cleanup lang_items.rs)
- #60641 (Instead of ICEing on incorrect pattern, use delay_span_bug)
- #60644 (Use `delay_span_bug` for "Failed to unify obligation")
Where's the best place to add this test? I *think* we want "compile-pass" for this test (no need to run a binary, and not running saves us a millisecond of process creation) , but there's no compile-pass anymore.
Should this be UI test with empty stdout, stderr and zero return code?
Rollup merge of #60550 - skinny121:concrete_const_tests, r=varkor
Add tests for concrete const types
In response to the request for help in https://github.com/rust-lang/rust/issues/44580#issuecomment-488819344, I have added several ui tests around the use of concrete const types, i.e. A<2>.
Rollup merge of #59979 - stepancheg:num-size, r=ehuss
to_xe_bytes for isize and usize returns an array of different size
... on different platforms.
Official rustdoc of
[`usize::to_le_bytes`](https://doc.rust-lang.org/std/primitive.usize.html#method.to_le_bytes)
displays signature
```
pub fn to_ne_bytes(self) -> [u8; 8]
```
which might be misleading: this function returns 4 bytes on 32-bit
systems.
With this commit applied rustdoc for `isize` and `usize` is this:
<img width="740" alt="2019-04-15_0020" src="https://user-images.githubusercontent.com/28969/56100765-9f69b380-5f14-11e9-974c-daa25edaa881.png">
bors [Wed, 8 May 2019 18:38:14 +0000 (18:38 +0000)]
Auto merge of #60402 - michaelwoerister:update-profiler-rt-build, r=alexcrichton
libprofiler_builtins: Set compilation flags more correctly for C code.
In particular, set `COMPILER_RT_HAS_FCNTL_LCK` and `COMPILER_RT_HAS_ATOMICS` as appropriate. This should get rid of the various runtime warnings when executing instrumented binaries.
The build script is using a heuristic here that hopefully is sufficient for the time being.
bors [Wed, 8 May 2019 08:26:48 +0000 (08:26 +0000)]
Auto merge of #60378 - froydnj:apple-target-modifications, r=michaelwoerister
conditionally modify darwin targets to macosx targets with versions
We need this behavior so that Rust LLVM IR objects match the target triple for Clang LLVM IR objects. This matching then convinces the linker that yes, you really can do cross-language LTO with objects from different compilers.
The newly-added tests seem to pass locally on x86_64-unknown-linux-gnu. I haven't done a full test run or tried the new compiler in an cross-language LTO setup yet.
bors [Tue, 7 May 2019 22:33:12 +0000 (22:33 +0000)]
Auto merge of #60586 - cramertj:await, r=oli-obk
Implement built-in await syntax
Adds support for .await under the existing async_await feature gate.
Moves macro-like await! syntax to the await_macro feature gate.
Removes support for `await` as a non-keyword under the `async_await`
feature.
This new syntax is not final, but is the consensus solution proposed by the lang team, as explained in https://boats.gitlab.io/blog/post/await-decision/
Taylor Cramer [Thu, 18 Apr 2019 19:55:23 +0000 (12:55 -0700)]
Implement built-in await syntax
Adds support for .await under the existing async_await feature gate.
Moves macro-like await! syntax to the await_macro feature gate.
Removes support for `await` as a non-keyword under the `async_await`
feature.
bors [Tue, 7 May 2019 19:39:52 +0000 (19:39 +0000)]
Auto merge of #60612 - Centril:rollup-61drhqt, r=Centril
Rollup of 5 pull requests
Successful merges:
- #60489 (Remove hamburger button from source code page)
- #60535 (Correct handling of arguments in async fn)
- #60579 (Rename `ParamTy::idx` to `ParamTy::index`)
- #60583 (Fix parsing issue with negative literals as const generic arguments)
- #60609 (Be a bit more explicit asserting over the vec rather than the len)
David Wood [Mon, 6 May 2019 21:56:47 +0000 (22:56 +0100)]
Trust signature over return expr for generators.
This commit extends the logic used to determine what the expected
signature of a closure is so that it can also determine the expected
signature of a generator. This improves a diagnostic where the fn
signature was blamed instead of the generator body. It doesn't fix
fix the diagnostic for `async fn`.
bors [Tue, 7 May 2019 05:53:18 +0000 (05:53 +0000)]
Auto merge of #60596 - ehuss:update-cargo, r=alexcrichton
Update cargo
12 commits in beb8fcb5248dc2e6aa488af9613216d5ccb31c6a..759b6161a328db1d4863139e90875308ecd25a75
2019-04-30 23:58:00 +0000 to 2019-05-06 20:47:49 +0000
- Small things (rust-lang/cargo#6910)
- Fix skipping over invalid registry packages (rust-lang/cargo#6912)
- Fixes rust-lang/cargo#6874 (rust-lang/cargo#6905)
- doc: Format examples of version to ease reading (rust-lang/cargo#6907)
- fix more typos (codespell) (rust-lang/cargo#6903)
- Parse less JSON on null builds (rust-lang/cargo#6880)
- chore: Update opener to 0.4 (rust-lang/cargo#6902)
- Update documentation for auto-discovery. (rust-lang/cargo#6898)
- Update some doc links. (rust-lang/cargo#6897)
- Default Cargo.toml template provide help for completing the metadata (rust-lang/cargo#6881)
- Run 'cargo fmt --all' (rust-lang/cargo#6896)
- Refactor command definition (rust-lang/cargo#6894)
bors [Tue, 7 May 2019 02:58:40 +0000 (02:58 +0000)]
Auto merge of #60464 - eddyb:not-overly-specific-pipelining, r=alexcrichton
rustc: rename -Z emit-directives to -Z emit-artifact-notifications and simplify the output.
This is my take on #60006 / #60419 (see https://github.com/rust-lang/rust/pull/60006#discussion_r275983732).
I'm not too attached the "notifications" part, it's pretty much bikeshed material.
**EDIT**: for "artifact", @matklad pointed out Cargo already uses it (in https://github.com/rust-lang/rust/pull/60464#issuecomment-488576998)
The first two commits are fixes that could be landed independently, especially the `compiletest` one, which removes the need for any of the normalization added in #60006 to land the test.
The last commit enables the emission for all outputs, which was my main suggestion for #60006, mostly to show that it's minimal and not really a "scope creep" (as suggested in https://github.com/rust-lang/rust/pull/60006#discussion_r279964081).
David Wood [Mon, 6 May 2019 19:45:47 +0000 (20:45 +0100)]
Add test for current behaviour.
This commit adds a test for the current behaviour of signature deduction
of generators when there is a type mismatch between the return type of
the function body and the signature.
bors [Mon, 6 May 2019 20:54:30 +0000 (20:54 +0000)]
Auto merge of #60526 - alexcrichton:wasm-main-symbols, r=oli-obk
rustc: Always handle exported symbols on the wasm target
Currently when linking an artifact rustc will only conditionally call
the `Linker::export_symbols` function, but this causes issues on some
targets, like WebAssembly, where it means that executable outputs will
not have the same symbols exported that cdylib outputs have. This commit
sinks the conditional call to `export_symbols` inside the various
implementations of the function that still need it, and otherwise the
wasm linker is configured to always pass through symbol visibility
lists.
bors [Mon, 6 May 2019 16:43:25 +0000 (16:43 +0000)]
Auto merge of #53645 - varkor:const-generics-redux, r=eddyb
The Genesis of Generic Germination
*Long had its coming been foretold: a collaborative effort with @yodaldevoid, set in motion by @jplatte, to beget a new Kind: one of a very different Sort to those that come before it. Amidst promises of ineffable powers previously thought unobtainable, few dared believe that the prophecies were true. But as they gazed upon that which claimed to be the Beginning, a few gentle sparks of hope fluttered deep within. It was not Time yet. But it was a Sign. And maybe, for some, that was enough.*
There's a long way to go, but we're at the point where we would benefit from GitHub's reviewing capabilities.
bors [Mon, 6 May 2019 00:16:16 +0000 (00:16 +0000)]
Auto merge of #60261 - matklad:one-escape, r=petrochenkov
introduce unescape module
A WIP PR to gauge early feedback
Currently, we deal with escape sequences twice: once when we [lex](https://github.com/rust-lang/rust/blob/112f7e9ac564e2cfcfc13d599c8376a219fde1bc/src/libsyntax/parse/lexer/mod.rs#L928-L1065) a string, and a second time when we [unescape](https://github.com/rust-lang/rust/blob/112f7e9ac564e2cfcfc13d599c8376a219fde1bc/src/libsyntax/parse/mod.rs#L313-L366) literals. Note that we also produce different sets of diagnostics in these two cases.
This PR aims to remove this duplication, by introducing a new `unescape` module as a single source of truth for character escaping rules.
I think this would be a useful cleanup by itself, but I also need this for https://github.com/rust-lang/rust/pull/59706.
In the current state, the PR has `unescape` module which fully (modulo bugs) deals with string and char literals. I am quite happy about the state of this module
What this PR doesn't have yet are:
* [x] handling of byte and byte string literals (should be simple to add)
* [x] good diagnostics
* [x] actual removal of code from lexer (giant `scan_char_or_byte` should go away completely)
* [x] performance check
* [x] general cleanup of the new code
Diagnostics will be the most labor-consuming bit here, but they are mostly a question of just correctly adjusting spans to sub-tokens. The current setup for diagnostics is that `unescape` produces a plain old `enum` with various problems, and they are rendered into `Handler` separately. This bit is not actually required (it is possible to just pass the `Handler` in), but I like the separation between diagnostics and logic this approach imposes, and such separation should again be useful for #59706
bors [Sun, 5 May 2019 21:11:47 +0000 (21:11 +0000)]
Auto merge of #60567 - Manishearth:rollup-rjagqnw, r=Manishearth
Rollup of 5 pull requests
Successful merges:
- #60131 (Fix broken link in rustc_plugin doc)
- #60426 (Stop `-O`/`-C opt-level` and `-g`/`-C debuginfo` conflicting)
- #60515 (use span instead of div for since version)
- #60530 (rustc: rename all occurences of "freevar" to "upvar".)
- #60536 (Correct code points to match their textual description)
Rollup merge of #60536 - brainplot:fix-unicode-character, r=dtolnay
Correct code points to match their textual description
Probably due to a copy-paste error, in the sentence
> For example, despite looking similar, the 'é' character is one Unicode code point while 'é' is two Unicode code points:
the two `é`'s were actually the same character in the text (i.e. the same Unicode character U+00E9).
The code listing below instead had two different Unicode characters for the two `é`s, as it was supposed to.
The example shown wasn't clear at first so I started inspecting the text and found this out.
I simply copied the character from the code listing to the description surrounding the code.
It's a minor thing but I thought it would make things clearer for others, especially since the example is about how Rust handles `char`s.
Rollup merge of #60530 - eddyb:unfreevars, r=oli-obk
rustc: rename all occurences of "freevar" to "upvar".
Most of the more recent code talks about "(closure) upvars", so I believe that's the name we want to use.
There's also the possibility of using "capture" which is more user-facing, but I'd rather not change *both* "freevar" and "upvar" to something else in this one PR.
Rollup merge of #60426 - varkor:fix-duplicate-arg-handling, r=alexcrichton
Stop `-O`/`-C opt-level` and `-g`/`-C debuginfo` conflicting
Allow `-O` and `-C opt-level`, and `-g` and `-C debuginfo` to be specified simultaneously without conflict. In such cases, the rightmost provided option is chosen.