bors [Thu, 23 Aug 2018 11:46:24 +0000 (11:46 +0000)]
Auto merge of #52602 - scottmcm:tryblock-expr, r=nikomatsakis
Implement try block expressions
I noticed that `try` wasn't a keyword yet in Rust 2018, so...
~~Fixβes https://github.com/rust-lang/rust/issues/52604~~ That was fixed by PR https://github.com/rust-lang/rust/pull/53135
cc https://github.com/rust-lang/rust/issues/31436 https://github.com/rust-lang/rust/issues/50412
bors [Thu, 23 Aug 2018 08:38:22 +0000 (08:38 +0000)]
Auto merge of #53459 - petrochenkov:stabmore, r=nrc
Stabilize a few secondary macro features
- `tool_attributes` - closes https://github.com/rust-lang/rust/issues/44690
- `proc_macro_path_invoc` - this feature was created due to issues with tool attributes (https://github.com/rust-lang/rust/issues/51277), those issues are now fixed (https://github.com/rust-lang/rust/pull/52841)
- partially `proc_macro_gen` - this feature was created due to issue https://github.com/rust-lang/rust/issues/50504, the issue is now fixed (https://github.com/rust-lang/rust/pull/51952), so proc macros can generate modules. They still can't generate `macro_rules` items though due to unclear hygiene interactions.
bors [Thu, 23 Aug 2018 06:34:11 +0000 (06:34 +0000)]
Auto merge of #53235 - varkor:gat_impl_where, r=estebank
Feature gate where clauses on associated type impls
Fixes #52913. This doesn't address the core problem, which is tracked by https://github.com/rust-lang/rust/issues/47206. However, it fixes the stable-to-stable regression: you now have to enable `#![feature(generic_associated_types)]` to trigger the weird behaviour.
bors [Wed, 22 Aug 2018 22:08:03 +0000 (22:08 +0000)]
Auto merge of #52011 - oli-obk:dont_you_hate_it_too_when_everything_panics_constantly, r=eddyb
Allow panicking with string literal messages inside constants
r? @eddyb
cc https://github.com/rust-lang/rust/issues/51999
we can't implement things like `panic!("foo: {}", x)` right now because we can't call trait methods (most notably `Display::fmt`) inside constants. Also most of these impls probably have loops and conditions, so it's messy anyway.
bors [Wed, 22 Aug 2018 19:59:52 +0000 (19:59 +0000)]
Auto merge of #53607 - GuillaumeGomez:rollup, r=GuillaumeGomez
Rollup of 10 pull requests
Successful merges:
- #53418 (Mark some suggestions as MachineApplicable)
- #53431 (Moved some feature gate ui tests to correct location)
- #53442 (Update version of rls-data used with save-analysis)
- #53504 (Set applicability for more suggestions.)
- #53541 (Fix missing impl trait display as ret type)
- #53544 (Point at the trait argument when using unboxed closure)
- #53558 (Normalize source line and column numbers.)
- #53562 (Lament the invincibility of the Turbofish)
- #53574 (Suggest direct raw-pointer dereference)
- #53585 (Remove super old comment on function that parses items)
Failed merges:
- #53472 (Use FxHash{Map,Set} instead of the default Hash{Map,Set} everywhere in rustc.)
- #53563 (use String::new() instead of String::from(""), "".to_string(), "".to_owned() or "".into())
bors [Wed, 22 Aug 2018 17:43:44 +0000 (17:43 +0000)]
Auto merge of #53581 - varkor:tyvariants-rename, r=eddyb
Rename TyVariants and variants
- Rename `TypeVariants` to `TyKind`.
- Remove the `Ty` prefix from each one of its variants (plus the identically-named variants of `PrimTy`).
- Rename `ty::Slice` to `ty::List`.
Guillaume Gomez [Wed, 22 Aug 2018 15:45:43 +0000 (17:45 +0200)]
Rollup merge of #53585 - dtolnay:comment, r=Mark-Simulacrum
Remove super old comment on function that parses items
This comment was added more than 5 years ago in ab03c1e4221. As far as anyone reading this comment today needs to know, the function has never parsed items from inside an extern crate.
Guillaume Gomez [Wed, 22 Aug 2018 15:45:41 +0000 (17:45 +0200)]
Rollup merge of #53574 - vorner:ptr_as_ref_unchecked, r=Mark-Simulacrum
Suggest direct raw-pointer dereference
People often come looking for some kind of `as_ref_unchecked` method on
raw pointers that would give them `&T` and not `Option<&T>` when they
are sure the pointer is not NULL.
There's no such method, but taking a reference of the dereferenced
pointer accomplishes the same thing. Therefore, suggest using that, at
the `as_ref` site β it's a place people are likely going to look into.
Guillaume Gomez [Wed, 22 Aug 2018 15:45:39 +0000 (17:45 +0200)]
Rollup merge of #53562 - varkor:bastion-of-the-turbofish, r=nagisa
Lament the invincibility of the Turbofish
Here a test case is added to ensure that any others attempting to drive the Turbofish to extinction have second thoughts. Previously the [entire test suite would succeed](https://github.com/rust-lang/rust/pull/53511) if generic arguments were accepted without disambiguation, making for [confusing and heartbreaking circumstances](https://github.com/rust-lang/rfcs/pull/2527).
Guillaume Gomez [Wed, 22 Aug 2018 15:45:36 +0000 (17:45 +0200)]
Rollup merge of #53541 - GuillaumeGomez:fix-impl-trait-ret-type, r=oli-obk
Fix missing impl trait display as ret type
I need to convert a `TraitPredicate` into a `TraitBound` to get the returned impl trait. So far, didn't find how or even if it was the good way to do it.
cc @eddyb @oli-obk (since you're the one behind the change apparently π)
Guillaume Gomez [Wed, 22 Aug 2018 15:45:34 +0000 (17:45 +0200)]
Rollup merge of #53504 - ekse:suggestions-applicability-2, r=estebank
Set applicability for more suggestions.
Converts a couple more calls to `span_suggestion_with_applicability` (#50723). To be on the safe side, I marked suggestions that depend on the intent of the user or that are potentially lossy conversions as MaybeIncorrect.
bors [Wed, 22 Aug 2018 15:29:07 +0000 (15:29 +0000)]
Auto merge of #53536 - RalfJung:array-drop, r=eddyb
fix array drop glue: properly turn raw ptr into reference
Discovered while working on https://github.com/rust-lang/rust/pull/53424: The generated drop glue uses an assignment `ptr = cur` where `ptr` is a reference and `cur` a raw pointer. This is not well-formed MIR.
Do we have MIR sanity checks that run on the drop glue and should have caught this?
bors [Wed, 22 Aug 2018 13:16:32 +0000 (13:16 +0000)]
Auto merge of #53524 - alexcrichton:buffer-out, r=eddyb
Buffer LLVM's object output stream
In some profiling on OSX I saw the `write` syscall as quite high up on
the profiling graph, which is definitely not good! It looks like we're
setting the output stream of an object file as directly to a file
descriptor which means that we run the risk of doing lots of little
writes rather than a few large writes.
This commit fixes this issue by adding a buffered stream on the output,
causing the `write` syscall to disappear from the profiles on OSX.
bors [Wed, 22 Aug 2018 11:11:14 +0000 (11:11 +0000)]
Auto merge of #53424 - RalfJung:miri-refactor, r=oli-obk
CTFE engine refactor
* Value gets renamed to `Operand`, so that now `interpret::{Place, Operand}` are the "dynamic" versions of `mir::{Place, Operand}`.
* `Operand` and `Place` share the data for their "stuff is in memory"-base in a new type, `MemPlace`. This also makes it possible to give some more precise types in other areas. Both `Operand` and `MemPlace` have methods available to project into fields (and other kinds of projections) without causing further allocations.
* The type for "a `Scalar` or a `ScalarPair`" is called `Value`, and again used to give some more precise types.
* All of these have versions with an attached layout, so that we can more often drag the layout along instead of recomputing it. This lets us get rid of `PlaceExtra::Downcast`. `MPlaceTy` and `PlaceTy` can only be constructed in place.rs, making sure the layout is handled properly. (The same should eventually be done for `ValTy` and `OpTy`.)
This is used to check, when copying an operand to a place, that the sizes match (which caught a bunch of bugs).
* All the high-level functions to write typed memory take a `Place`, and live in `place.rs`. All the high-level typed functions to read typed memory take an `Operand`, and live in `operands.rs`.
* Remove `cur_frame` and handling of signedess from memory (catching a bug in the float casting code).
* [Only functional change] Enable sanity check to recurse below dyn traits and slices.
Ralf Jung [Sat, 18 Aug 2018 11:46:52 +0000 (13:46 +0200)]
optimize sanity check path printing
During the sanity check, we keep track of the path we are below in a `Vec`. We
avoid cloning that `Vec` unless we hit a pointer indirection. The `String`
representation is only computed when validation actually fails.
Ralf Jung [Fri, 17 Aug 2018 15:47:37 +0000 (17:47 +0200)]
optimize validation iterating over the elements of an array
This is still roughly 45ns slower than the old state, because it now works with
an MPlaceTy and uses the appropriate abstractions, instead of working with a
ptr-align pair directly.
Ralf Jung [Mon, 13 Aug 2018 14:14:22 +0000 (16:14 +0200)]
miri/CTFE refactor
* Value gets renamed to Operand, so that now interpret::{Place, Operand} are the
"dynamic" versions of mir::{Place, Operand}.
* Operand and Place share the data for their "stuff is in memory"-base in a new
type, MemPlace. This also makes it possible to give some more precise types
in other areas. Both Operand and MemPlace have methods available to project
into fields (and other kinds of projections) without causing further
allocations.
* The type for "a Scalar or a ScalarPair" is called Value, and again used to
give some more precise types.
* All of these have versions with an attached layout, so that we can more often
drag the layout along instead of recomputing it. This lets us get rid of
`PlaceExtra::Downcast`. MPlaceTy and PlaceTy can only be constructed
in place.rs, making sure the layout is handled properly.
(The same should eventually be done for ValTy and OpTy.)
* All the high-level functions to write typed memory take a Place, and live in
place.rs. All the high-level typed functions to read typed memory take an
Operand, and live in operands.rs.
bors [Wed, 22 Aug 2018 03:01:14 +0000 (03:01 +0000)]
Auto merge of #53477 - ftilde:exec-rust-gdb-lldb, r=michaelwoerister
Exec gdb/lldb in rust-{gdb/lldb} wrapper scripts
This way, the process we get by executing `rust-gdb` or `rust-lldb` (eventually) is an actual `gdb` or `lldb` process and behaves accordingly. Previously (and at least to me unexpectedly) it was just a script waiting for the debugger to exit. Sending a signal (e.g. SIGINT) to the spawned process did therefore not affect the debugger process (which was just a child of the wrapper script).
In order to work around that we `exec` (according to [this](http://pubs.opengroup.org/onlinepubs/009695399/utilities/exec.html) part of the posix shell) and replace the script process with the debugger in the last line of the script. The lldb script had to be modified to not pass the configuration commands via a script file (which in my opinion is cleaner anyway).
David Tolnay [Wed, 22 Aug 2018 01:46:56 +0000 (21:46 -0400)]
Remove super old comment on function that parses items
This comment was added more than 5 years ago in ab03c1e4221. As far as
anyone reading this comment today needs to know, the function has never
parsed items from inside an extern crate.
bors [Wed, 22 Aug 2018 00:57:00 +0000 (00:57 +0000)]
Auto merge of #50912 - varkor:exhaustive-integer-matching, r=arielb1
Exhaustive integer matching
This adds a new feature flag `exhaustive_integer_patterns` that enables exhaustive matching of integer types by their values. For example, the following is now accepted:
```rust
#![feature(exhaustive_integer_patterns)]
#![feature(exclusive_range_pattern)]
fn matcher(x: u8) {
match x { // ok
0 .. 32 => { /* foo */ }
32 => { /* bar */ }
33 ..= 255 => { /* baz */ }
}
}
```
This matching is permitted on all integer (signed/unsigned and char) types. Sensible error messages are also provided. For example:
```rust
fn matcher(x: u8) {
match x { //~ ERROR
0 .. 32 => { /* foo */ }
}
}
```
results in:
```
error[E0004]: non-exhaustive patterns: `32u8...255u8` not covered
--> matches.rs:3:9
|
6 | match x {
| ^ pattern `32u8...255u8` not covered
```
This implements https://github.com/rust-lang/rfcs/issues/1550 for https://github.com/rust-lang/rust/issues/50907. While there hasn't been a full RFC for this feature, it was suggested that this might be a feature that obviously complements the existing exhaustiveness checks (e.g. for `bool`) and so a feature gate would be sufficient for now.
bors [Tue, 21 Aug 2018 20:33:31 +0000 (20:33 +0000)]
Auto merge of #53471 - petrochenkov:biattr2, r=oli-obk
resolve: Some macro resolution refactoring
Work towards completing https://github.com/rust-lang/rust/pull/50911#issuecomment-411605393
The last commit also fixes https://github.com/rust-lang/rust/issues/53269 by not using `def_id()` on `Def::Err` and also fixes https://github.com/rust-lang/rust/issues/53512.
People often come looking for some kind of `as_ref_unchecked` method on
raw pointers that would give them `&T` and not `Option<&T>` when they
are sure the pointer is not NULL.
There's no such method, but taking a reference of the dereferenced
pointer accomplishes the same thing. Therefore, suggest using that, at
the `as_ref` site β it's a place people are likely going to look into.
bors [Tue, 21 Aug 2018 16:04:11 +0000 (16:04 +0000)]
Auto merge of #53530 - kennytm:rollup, r=kennytm
Rollup of 17 pull requests
Successful merges:
- #53030 (Updated RELEASES.md for 1.29.0)
- #53104 (expand the documentation on the `Unpin` trait)
- #53213 (Stabilize IP associated constants)
- #53296 (When closure with no arguments was expected, suggest wrapping)
- #53329 (Replace usages of ptr::offset with ptr::{add,sub}.)
- #53363 (add individual docs to `core::num::NonZero*`)
- #53370 (Stabilize macro_vis_matcher)
- #53393 (Mark libserialize functions as inline)
- #53405 (restore the page title after escaping out of a search)
- #53452 (Change target triple used to check for lldb in build-manifest)
- #53462 (Document Box::into_raw returns non-null ptr)
- #53465 (Remove LinkMeta struct)
- #53492 (update lld submodule to include RISCV patch)
- #53496 (Fix typos found by codespell.)
- #53521 (syntax: Optimize some literal parsing)
- #53540 (Moved issue-53157.rs into src/test/ui/consts/const-eval/)
- #53551 (Avoid some Place clones.)
David Wood [Tue, 21 Aug 2018 10:57:11 +0000 (12:57 +0200)]
Normalize source line and column numbers.
This commit adds a normalization for line and column numbers in stderr
files where the line/col is from the source directory rather than
the test itself - thereby removing the need to update tests as
compiler source changes.
kennytm [Tue, 21 Aug 2018 03:07:45 +0000 (11:07 +0800)]
Rollup merge of #53521 - alexcrichton:optimize-lit-token, r=michaelwoerister
syntax: Optimize some literal parsing
Currently in the `wasm-bindgen` project we have a very very large crate that's
procedurally generated, `web-sys`. To generate this crate we parse all of a
browser's WebIDL and we then generate bindings for all of the APIs contained
within.
The resulting Rust file is 18MB large (wow!) and currently takes a very long
time to compile in debug mode. On the nightly compiler a *debug* build takes 90s
for the crate to finish. I was curious what was taking so long and upon
investigating a *massive* portion of the time was spent in the `lit_token`
method of the compiler, primarily formatting strings via `format!`.
Upon some more investigation it looks like the `byte_str_lit` was allocating an
error message once per byte, causing a very large number of allocations to
happen for large literals, of which wasm-bindgen generates quite a few (some are
MB large).
This commit fixes the issue by lazily allocating the error message, only doing
so if the error message is actually needed (which should be never). As a result,
the debug mode compilation time for our `web-sys` crate decreased from 90s to
20s, a very nice improvement! (although we've still got some work to do).
kennytm [Mon, 20 Aug 2018 17:20:24 +0000 (01:20 +0800)]
Rollup merge of #53492 - danc86:lld-riscv, r=alexcrichton
update lld submodule to include RISCV patch
This pulls in one new commit, to add support for linking static RISCV
binaries, suitable for the new riscv32imac-unknown-none-elf target.
See: https://github.com/rust-lang/lld/pull/1
kennytm [Mon, 20 Aug 2018 17:20:18 +0000 (01:20 +0800)]
Rollup merge of #53405 - oconnor663:search_esc, r=GuillaumeGomez
restore the page title after escaping out of a search
Currently if I start a search in the docs, but then hit ESC, the "Results for..." title is still there in my browser tab. This is a simple attempt to fix that. I see that there's a separate `var previousTitle = document.title` thing happening in `startSearch()`, but as far as I can tell that's only related to the back stack? I'd also appreciate feedback on the right place to declare the `titleBeforeSearch` variable.
Testing-wise, I've confirmed by hand that the tab title restores correctly after building with `./x.py doc --stage 1 src/libstd`, but nothing more involved than that. What else should I test?
kennytm [Mon, 20 Aug 2018 17:20:16 +0000 (01:20 +0800)]
Rollup merge of #53393 - BurntPizza:serialize-inlines, r=alexcrichton
Mark libserialize functions as inline
Got to thinking: "what if that big pile of tiny functions isn't inlining as it should?"
So a few `replace-regex` later the local perf run says this:
<details>
![](https://i.imgur.com/gvdJEgG.png)
</details>
Not huge, but still a win, which is interesting. Want to verify with the real perf run, but I understand there's a backlog.
I didn't notice any increase in compile time or binary sizes for rustc/libs.