]> git.lizzy.rs Git - rust.git/log
rust.git
4 years agoRollup merge of #64896 - XAMPPRocky:remove-grammar, r=Centril
Mazdak Farrokhzad [Tue, 1 Oct 2019 07:55:33 +0000 (09:55 +0200)]
Rollup merge of #64896 - XAMPPRocky:remove-grammar, r=Centril

Remove legacy grammar

Revival of #50835 & #55545

On the #wg-grammar discord there was agreement that enough progress has been made to be able to remove the legacy grammar.

r? @Centril @qmx

cc @rust-lang/wg-grammar

4 years agoRollup merge of #64895 - davidtwco:issue-64130-async-error-definition, r=nikomatsakis
Mazdak Farrokhzad [Tue, 1 Oct 2019 07:55:31 +0000 (09:55 +0200)]
Rollup merge of #64895 - davidtwco:issue-64130-async-error-definition, r=nikomatsakis

async/await: improve not-send errors

cc #64130.

```
note: future does not implement `std::marker::Send` because this value is used across an await
  --> $DIR/issue-64130-non-send-future-diags.rs:15:5
   |
LL |     let g = x.lock().unwrap();
   |         - has type `std::sync::MutexGuard<'_, u32>`
LL |     baz().await;
   |     ^^^^^^^^^^^ await occurs here, with `g` maybe used later
LL | }
   | - `g` is later dropped here
```

r? @nikomatsakis

4 years agoRollup merge of #64887 - Centril:recover-trailing-vert, r=estebank
Mazdak Farrokhzad [Tue, 1 Oct 2019 07:55:29 +0000 (09:55 +0200)]
Rollup merge of #64887 - Centril:recover-trailing-vert, r=estebank

syntax: recover trailing `|` in or-patterns

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

For example (this also shows that we are sensitive to the typo `||`):

```
error: a trailing `|` is not allowed in an or-pattern
  --> $DIR/remove-leading-vert.rs:33:11
   |
LL |         A || => {}
   |         - ^^ help: remove the `||`
   |         |
   |         while parsing this or-pattern starting here
   |
   = note: alternatives in or-patterns are separated with `|`, not `||`
```

r? @estebank

4 years agoRollup merge of #63931 - petrochenkov:stabmac, r=Centril
Mazdak Farrokhzad [Tue, 1 Oct 2019 07:55:28 +0000 (09:55 +0200)]
Rollup merge of #63931 - petrochenkov:stabmac, r=Centril

Stabilize macros in some more positions

- Fn-like macros and attribute macros in `extern` blocks
- Fn-like procedural macros in type positions
- ~Attribute macros on inline modules~ (moved to https://github.com/rust-lang/rust/pull/64273)

Stabilization report: https://github.com/rust-lang/rust/pull/63931#issuecomment-526362396.

Closes https://github.com/rust-lang/rust/issues/49476
cc https://github.com/rust-lang/rust/issues/54727

4 years agoRollup merge of #63674 - petrochenkov:meta2, r=Centril
Mazdak Farrokhzad [Tue, 1 Oct 2019 07:55:26 +0000 (09:55 +0200)]
Rollup merge of #63674 - petrochenkov:meta2, r=Centril

syntax: Support modern attribute syntax in the `meta` matcher

Where "modern" means https://github.com/rust-lang/rust/pull/57367:
```
PATH
PATH `(` TOKEN_STREAM `)`
PATH `[` TOKEN_STREAM `]`
PATH `{` TOKEN_STREAM `}`
```

Unfortunately, `meta` wasn't future-proofed using the `FOLLOW` token set like other matchers (https://github.com/rust-lang/rust/issues/34011), so code like `$meta:meta {` or `$meta:meta [` may break, and we need a crater run to find out how often this happens in practice.

Closes https://github.com/rust-lang/rust/issues/49629 (by fully supporting `meta` rather than removing it.)

4 years agoAuto merge of #64932 - tmandry:rollup-7t8x1nz, r=tmandry
bors [Tue, 1 Oct 2019 02:31:48 +0000 (02:31 +0000)]
Auto merge of #64932 - tmandry:rollup-7t8x1nz, r=tmandry

Rollup of 9 pull requests

Successful merges:

 - #64377 (Add long error explanation for E0493)
 - #64786 (Use https for curl when building for linux)
 - #64828 (Graphviz debug output for generic dataflow analysis)
 - #64838 (Add long error explanation for E0550)
 - #64891 (Fix `vec![x; n]` with null raw fat pointer zeroing the pointer metadata)
 - #64893 (Zero-initialize `vec![None; n]` for `Option<&T>`, `Option<&mut T>` and `Option<Box<T>>`)
 - #64911 (Fixed a misleading documentation issue #64844)
 - #64921 (Add test for issue-64662)
 - #64923 (Add missing links for mem::needs_drop)

Failed merges:

 - #64918 (Add long error explanation for E0551)

r? @ghost

4 years agoasync/await: improve obligation errors
David Wood [Wed, 25 Sep 2019 12:58:41 +0000 (13:58 +0100)]
async/await: improve obligation errors

This commit improves obligation errors for async/await:

```
note: future does not implement `std::marker::Send` because this value is used across an
      await
  --> $DIR/issue-64130-non-send-future-diags.rs:15:5
   |
LL |     let g = x.lock().unwrap();
   |         - has type `std::sync::MutexGuard<'_, u32>`
LL |     baz().await;
   |     ^^^^^^^^^^^ await occurs here, with `g` maybe used later
LL | }
   | - `g` is later dropped here
```

Signed-off-by: David Wood <david@davidtw.co>
4 years agoAddress review comments
Vadim Petrochenkov [Mon, 30 Sep 2019 21:58:30 +0000 (00:58 +0300)]
Address review comments

4 years agoRollup merge of #64923 - lzutao:improve-doc-needs_drop, r=jonas-schievink
Tyler Mandry [Mon, 30 Sep 2019 21:38:32 +0000 (14:38 -0700)]
Rollup merge of #64923 - lzutao:improve-doc-needs_drop, r=jonas-schievink

Add missing links for mem::needs_drop

r? @jonas-schievink

4 years agoRollup merge of #64921 - JohnTitor:add-test-enum, r=varkor
Tyler Mandry [Mon, 30 Sep 2019 21:38:31 +0000 (14:38 -0700)]
Rollup merge of #64921 - JohnTitor:add-test-enum, r=varkor

Add test for issue-64662

Closes #64662
r? @varkor

4 years agoRollup merge of #64911 - hman523:64844, r=Dylan-DPC
Tyler Mandry [Mon, 30 Sep 2019 21:38:28 +0000 (14:38 -0700)]
Rollup merge of #64911 - hman523:64844, r=Dylan-DPC

Fixed a misleading documentation issue #64844

Made the suggested change from @steveklabnik on issue #64844

4 years agoRollup merge of #64893 - SimonSapin:vec-of-option-box, r=sfackler
Tyler Mandry [Mon, 30 Sep 2019 21:38:27 +0000 (14:38 -0700)]
Rollup merge of #64893 - SimonSapin:vec-of-option-box, r=sfackler

Zero-initialize `vec![None; n]` for `Option<&T>`, `Option<&mut T>` and `Option<Box<T>>`

4 years agoRollup merge of #64891 - SimonSapin:vec-of-fat-raw-ptr, r=sfackler
Tyler Mandry [Mon, 30 Sep 2019 21:38:25 +0000 (14:38 -0700)]
Rollup merge of #64891 - SimonSapin:vec-of-fat-raw-ptr, r=sfackler

Fix `vec![x; n]` with null raw fat pointer zeroing the pointer metadata

https://github.com/rust-lang/rust/pull/49496 introduced specialization based on:

```rust
unsafe impl<T: ?Sized> IsZero for *mut T {
    fn is_zero(&self) -> bool {
        (*self).is_null()
    }
}
```

… to call `RawVec::with_capacity_zeroed` for creating `Vec<*mut T>`, which is incorrect for fat pointers since `<*mut T>::is_null` only looks at the data component. That is, a fat pointer can be “null” without being made entirely of zero bits.

This commit fixes it by removing the `?Sized` bound on this impl (and the corresponding `*const T` one). This regresses `vec![x; n]` with `x` a null raw slice of length zero, but that seems exceptionally uncommon. (Vtable pointers are never null, so raw trait objects would not take the fast path anyway.)

An alternative to keep the `?Sized` bound (or even generalize to `impl<U: Copy> IsZero for U`) would be to cast to `&[u8]` of length `size_of::<U>()`, but the optimizer seems not to be able to propagate alignment information and sticks with comparing one byte at a time:

https://rust.godbolt.org/z/xQFkwL

----

Without the library change, the new test fails as follows:

```rust
---- vec::vec_macro_repeating_null_raw_fat_pointer stdout ----
[src/liballoc/tests/vec.rs:1301] ptr_metadata(raw_dyn) = 0x00005596ef95f9a8
[src/liballoc/tests/vec.rs:1306] ptr_metadata(vec[0]) = 0x0000000000000000
thread 'vec::vec_macro_repeating_null_raw_fat_pointer' panicked at 'assertion failed: vec[0] == null_raw_dyn', src/liballoc/tests/vec.rs:1307:5
```

4 years agoRollup merge of #64838 - GuillaumeGomez:long-err-explanation-e0550, r=oli-obk
Tyler Mandry [Mon, 30 Sep 2019 21:38:24 +0000 (14:38 -0700)]
Rollup merge of #64838 - GuillaumeGomez:long-err-explanation-e0550, r=oli-obk

Add long error explanation for E0550

Part of #61137

4 years agoRollup merge of #64828 - ecstatic-morse:generic-dataflow-graphviz, r=oli-obk
Tyler Mandry [Mon, 30 Sep 2019 21:38:22 +0000 (14:38 -0700)]
Rollup merge of #64828 - ecstatic-morse:generic-dataflow-graphviz, r=oli-obk

Graphviz debug output for generic dataflow analysis

A follow up to #64566.

This outputs graphviz diagrams in the generic dataflow engine when `#[rustc_mir(borrowck_graphviz_postflow="suffix.dot")]` is set on an item. This code is based on [`dataflow/graphviz.rs`](https://github.com/rust-lang/rust/blob/master/src/librustc_mir/dataflow/graphviz.rs), but displays different information since there are no "gen"/"kill" sets and transfer functions cannot be coalesced in the generic analysis. As a result, we show the dataflow state at the start and end of each block, as well as the changes resulting from each statement. I also render the state bitset in full  (`{_1,_2}`) instead of hex-encoded as the current renderer does (`06`).

4 years agoRollup merge of #64786 - tmandry:patch-1, r=alexcrichton
Tyler Mandry [Mon, 30 Sep 2019 21:38:21 +0000 (14:38 -0700)]
Rollup merge of #64786 - tmandry:patch-1, r=alexcrichton

Use https for curl when building for linux

I noticed that the dist-x86_64-linux builder uses http to fetch curl and doesn't do any signature verification. It should probably use https.

r? @alexcrichton @Mark-Simulacrum

4 years agoRollup merge of #64377 - GuillaumeGomez:E0493, r=estebank
Tyler Mandry [Mon, 30 Sep 2019 21:38:19 +0000 (14:38 -0700)]
Rollup merge of #64377 - GuillaumeGomez:E0493, r=estebank

Add long error explanation for E0493

Part of #61137.

4 years agosyntax: Support modern attribute syntax in the `meta` matcher
Vadim Petrochenkov [Sat, 17 Aug 2019 22:10:56 +0000 (01:10 +0300)]
syntax: Support modern attribute syntax in the `meta` matcher

4 years agosyntax: Split `ast::Attribute` into container and inner parts
Vadim Petrochenkov [Sat, 17 Aug 2019 20:55:41 +0000 (23:55 +0300)]
syntax: Split `ast::Attribute` into container and inner parts

4 years agoStabilize proc macros in type positions
Vadim Petrochenkov [Tue, 27 Aug 2019 00:48:48 +0000 (03:48 +0300)]
Stabilize proc macros in type positions

4 years agoStabilize macros in `extern` blocks
Vadim Petrochenkov [Mon, 26 Aug 2019 23:07:26 +0000 (02:07 +0300)]
Stabilize macros in `extern` blocks

Add some tests for macros in extern blocks, remove duplicate tests

4 years agoStop printing `Qualif` results in debug logs
Dylan MacKenzie [Mon, 30 Sep 2019 04:45:10 +0000 (21:45 -0700)]
Stop printing `Qualif` results in debug logs

Now we can use the dataflow graphviz debugging.

4 years agoUse separate files for debugging `Qualif` dataflow results
Dylan MacKenzie [Mon, 30 Sep 2019 04:43:09 +0000 (21:43 -0700)]
Use separate files for debugging `Qualif` dataflow results

4 years agoUpdate consumers of `generic::Engine` API
Dylan MacKenzie [Mon, 30 Sep 2019 04:33:51 +0000 (21:33 -0700)]
Update consumers of `generic::Engine` API

4 years agoAdd graphviz debug output for generic dataflow
Dylan MacKenzie [Thu, 26 Sep 2019 23:26:11 +0000 (16:26 -0700)]
Add graphviz debug output for generic dataflow

4 years agoAllow `ResultsCursor` to borrow the underlying `Results`
Dylan MacKenzie [Thu, 26 Sep 2019 23:25:27 +0000 (16:25 -0700)]
Allow `ResultsCursor` to borrow the underlying `Results`

4 years agoFix typo in docs
Dylan MacKenzie [Thu, 26 Sep 2019 23:24:02 +0000 (16:24 -0700)]
Fix typo in docs

4 years agoAdd missing links for mem::needs_drop
Lzu Tao [Mon, 30 Sep 2019 16:12:01 +0000 (16:12 +0000)]
Add missing links for mem::needs_drop

4 years agoAdd test for issue-64662
Yuki Okushi [Mon, 30 Sep 2019 15:38:08 +0000 (00:38 +0900)]
Add test for issue-64662

4 years agoupdate ui tests
Guillaume Gomez [Fri, 27 Sep 2019 12:08:47 +0000 (14:08 +0200)]
update ui tests

4 years agoAdd long error explanation for E0550
Guillaume Gomez [Fri, 27 Sep 2019 11:36:50 +0000 (13:36 +0200)]
Add long error explanation for E0550

4 years agoAuto merge of #64778 - csmoe:index, r=eddyb
bors [Mon, 30 Sep 2019 13:33:15 +0000 (13:33 +0000)]
Auto merge of #64778 - csmoe:index, r=eddyb

Introduce librustc_index crate

Closes #50592

4 years agoupdate tests
Guillaume Gomez [Thu, 12 Sep 2019 13:52:51 +0000 (15:52 +0200)]
update tests

4 years agoAdd long error explanation for E0493
Guillaume Gomez [Wed, 11 Sep 2019 11:51:03 +0000 (13:51 +0200)]
Add long error explanation for E0493

4 years agoAuto merge of #64600 - scottmcm:no-slice-tryfold-unroll, r=bluss
bors [Mon, 30 Sep 2019 09:52:29 +0000 (09:52 +0000)]
Auto merge of #64600 - scottmcm:no-slice-tryfold-unroll, r=bluss

Remove manual unrolling from slice::Iter(Mut)::try_fold

While this definitely helps sometimes (particularly for trivial closures), it's also a pessimization sometimes, so it's better to leave this to (hypothetical) future LLVM improvements instead of forcing this on everyone.

I think it's better for the advice to be that sometimes you need to unroll manually than you sometimes need to not-unroll manually (like #64545).

---

For context see https://github.com/rust-lang/rust/pull/64572#issuecomment-532961046

4 years agoAuto merge of #64904 - ollie27:rustdoc_logo, r=Mark-Simulacrum
bors [Mon, 30 Sep 2019 06:01:48 +0000 (06:01 +0000)]
Auto merge of #64904 - ollie27:rustdoc_logo, r=Mark-Simulacrum

rustdoc: Fix default logo filename

This was a typo made in #64443. It's the reason the logo is missing on the [nightly docs](https://doc.rust-lang.org/nightly/std/).

r? @Mark-Simulacrum

4 years agoRemove legacy grammar
Erin Power [Sun, 29 Sep 2019 14:04:14 +0000 (16:04 +0200)]
Remove legacy grammar

4 years agoFixed a misleading documentation issue #64844
hman523 [Mon, 30 Sep 2019 05:26:42 +0000 (00:26 -0500)]
Fixed a misleading documentation issue #64844

4 years agoAuto merge of #64881 - RalfJung:miri, r=RalfJung
bors [Mon, 30 Sep 2019 02:09:43 +0000 (02:09 +0000)]
Auto merge of #64881 - RalfJung:miri, r=RalfJung

bump Miri

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

4 years agoAuto merge of #64673 - Mark-Simulacrum:opt-match-ck, r=oli-obk
bors [Sun, 29 Sep 2019 22:21:43 +0000 (22:21 +0000)]
Auto merge of #64673 - Mark-Simulacrum:opt-match-ck, r=oli-obk

Optimize try_eval_bits to avoid layout queries

This specifically targets match checking, but is possibly more widely
useful as well. In code with large, single-value match statements, we
were previously spending a lot of time running layout_of for the
primitive types (integers, chars) -- which is essentially useless. This
optimizes the code to avoid those query calls by directly obtaining the
size for these types, when possible.

It may be worth considering adding a `size_of` query in the future which
might be far faster, especially if specialized for "const" cases --
match arms being the most obvious example. It's possibly such a function
would benefit from *not* being a query as well, since it's trivially
evaluatable from the sty for many cases whereas a query needs to hash
the input and such.

4 years agoOptimize try_eval_bits to avoid layout queries
Mark Rousskov [Sat, 21 Sep 2019 22:39:35 +0000 (18:39 -0400)]
Optimize try_eval_bits to avoid layout queries

This specifically targets match checking, but is possibly more widely
useful as well. In code with large, single-value match statements, we
were previously spending a lot of time running layout_of for the
primitive types (integers, chars) -- which is essentially useless. This
optimizes the code to avoid those query calls by directly obtaining the
size for these types, when possible.

It may be worth considering adding a `size_of` query in the future which
might be far faster, especially if specialized for "const" cases --
match arms being the most obvious example. It's possibly such a function
would benefit from *not* being a query as well, since it's trivially
evaluatable from the sty for many cases whereas a query needs to hash
the input and such.

4 years agorustdoc: Fix default logo filename
Oliver Middleton [Sun, 29 Sep 2019 21:17:03 +0000 (22:17 +0100)]
rustdoc: Fix default logo filename

4 years agoUse https for curl when building for linux
Tyler Mandry [Sat, 28 Sep 2019 22:44:20 +0000 (15:44 -0700)]
Use https for curl when building for linux

4 years agoAuto merge of #64902 - Centril:rollup-1i431vs, r=Centril
bors [Sun, 29 Sep 2019 18:35:04 +0000 (18:35 +0000)]
Auto merge of #64902 - Centril:rollup-1i431vs, r=Centril

Rollup of 6 pull requests

Successful merges:

 - #64691 (Point at definition when misusing ADT)
 - #64735 (Add long error explanation for E0533)
 - #64825 (Point at enclosing match when expecting `()` in arm)
 - #64858 (Add support for relating slices in `super_relate_consts`)
 - #64894 (syntax: fix dropping of attribute on first param of non-method assocated fn)
 - #64898 (fixed typo)

Failed merges:

r? @ghost

4 years agoRollup merge of #64898 - jakevossen5:master, r=jonas-schievink
Mazdak Farrokhzad [Sun, 29 Sep 2019 18:34:19 +0000 (20:34 +0200)]
Rollup merge of #64898 - jakevossen5:master, r=jonas-schievink

fixed typo

Accidentally had a typo in https://github.com/rust-lang/rust/pull/64884, sorry!

4 years agoRollup merge of #64894 - Centril:fix-64682, r=petrochenkov
Mazdak Farrokhzad [Sun, 29 Sep 2019 18:34:18 +0000 (20:34 +0200)]
Rollup merge of #64894 - Centril:fix-64682, r=petrochenkov

syntax: fix dropping of attribute on first param of non-method assocated fn

Fixes #64682.

The general idea is that we bake parsing of `self` into `parse_param_general` and then we just use standard list parsing. Overall, this simplifies the parsing and makes it more consistent.

r? @petrochenkov cc @c410-f3r

4 years agoRollup merge of #64858 - skinny121:str-const-generics, r=varkor
Mazdak Farrokhzad [Sun, 29 Sep 2019 18:34:16 +0000 (20:34 +0200)]
Rollup merge of #64858 - skinny121:str-const-generics, r=varkor

Add support for relating slices in `super_relate_consts`

This allows passing strings as generic arguments.

Fixes #63773
Fixes #60813

r? @varkor

4 years agoRollup merge of #64825 - estebank:match-unit, r=Centril
Mazdak Farrokhzad [Sun, 29 Sep 2019 18:34:15 +0000 (20:34 +0200)]
Rollup merge of #64825 - estebank:match-unit, r=Centril

Point at enclosing match when expecting `()` in arm

When encountering code like the following:

```rust
fn main() {
    match 3 {
        4 => 1,
        3 => {
            println!("Yep it maches.");
            2
        }
        _ => 2
    }
    println!("Bye!")
}
```

point at the enclosing `match` expression and suggest ignoring the
returned value:

```
error[E0308]: mismatched types
  --> $DIR/match-needing-semi.rs:8:13
   |
LL | /     match 3 {
LL | |         4 => 1,
LL | |         3 => {
LL | |             2
   | |             ^ expected (), found integer
LL | |         }
LL | |         _ => 2
LL | |     }
   | |     -- help: consider using a semicolon here
   | |_____|
   |       expected this to be `()`
   |
   = note: expected type `()`
              found type `{integer}
```

Fix #40799.

4 years agoRollup merge of #64735 - GuillaumeGomez:long-err-explanation-E0533, r=Centril
Mazdak Farrokhzad [Sun, 29 Sep 2019 18:34:14 +0000 (20:34 +0200)]
Rollup merge of #64735 - GuillaumeGomez:long-err-explanation-E0533, r=Centril

Add long error explanation for E0533

Part of https://github.com/rust-lang/rust/issues/61137

4 years agoRollup merge of #64691 - estebank:unexpected-variant, r=Centril
Mazdak Farrokhzad [Sun, 29 Sep 2019 18:34:12 +0000 (20:34 +0200)]
Rollup merge of #64691 - estebank:unexpected-variant, r=Centril

Point at definition when misusing ADT

When given `struct Foo(usize)` and using it as `Foo {}` or `Foo`, point at `Foo`'s definition in the error.

4 years agobump Miri
Ralf Jung [Sun, 29 Sep 2019 17:57:26 +0000 (13:57 -0400)]
bump Miri

4 years agoremove indexed_vec re-export from rustc_data_structures
csmoe [Thu, 26 Sep 2019 05:38:33 +0000 (05:38 +0000)]
remove indexed_vec re-export from rustc_data_structures

4 years agoremove bit_set re-export from rustc_data_structures
csmoe [Thu, 26 Sep 2019 05:30:10 +0000 (05:30 +0000)]
remove bit_set re-export from rustc_data_structures

4 years agomove bit_set into rustc_index
csmoe [Thu, 26 Sep 2019 03:26:16 +0000 (03:26 +0000)]
move bit_set into rustc_index

4 years agomove index_vec into rustc_index
csmoe [Wed, 25 Sep 2019 19:09:51 +0000 (03:09 +0800)]
move index_vec into rustc_index

4 years agoinit librustc_index crate
csmoe [Wed, 25 Sep 2019 18:55:18 +0000 (02:55 +0800)]
init librustc_index crate

4 years agofixed typo
= [Sun, 29 Sep 2019 15:58:29 +0000 (09:58 -0600)]
fixed typo

4 years agoAuto merge of #64158 - tmandry:libtest-panic-abort, r=alexcrichton
bors [Sun, 29 Sep 2019 13:53:08 +0000 (13:53 +0000)]
Auto merge of #64158 - tmandry:libtest-panic-abort, r=alexcrichton

panic=abort support in libtest

Add experimental support for tests compiled with panic=abort. Enabled with `-Z panic_abort_tests`.

r? @alexcrichton
cc @cramertj

4 years agosyntax: fix #64682.
Mazdak Farrokhzad [Sun, 29 Sep 2019 07:26:02 +0000 (09:26 +0200)]
syntax: fix #64682.

Fuse parsing of `self` into `parse_param_general`.

4 years agoAuto merge of #64546 - weiznich:bugfix/rfc-2451-rerebalance-tests, r=nikomatsakis
bors [Sun, 29 Sep 2019 09:52:58 +0000 (09:52 +0000)]
Auto merge of #64546 - weiznich:bugfix/rfc-2451-rerebalance-tests, r=nikomatsakis

Bugfix/rfc 2451 rerebalance tests

r? @nikomatsakis

Fixes #64412
Depends/Contains on #64414

cc #55437 and #63599

4 years agoZero-initialize `vec![None; n]` for `Option<&T>`, `Option<&mut T>` and `Option<Box...
Simon Sapin [Sun, 29 Sep 2019 09:14:59 +0000 (11:14 +0200)]
Zero-initialize `vec![None; n]` for `Option<&T>`, `Option<&mut T>` and `Option<Box<T>>`

4 years agoFix `vec![x; n]` with null raw fat pointer zeroing the pointer metadata
Simon Sapin [Sun, 29 Sep 2019 08:45:47 +0000 (10:45 +0200)]
Fix `vec![x; n]` with null raw fat pointer zeroing the pointer metadata

https://github.com/rust-lang/rust/pull/49496 introduced specialization based on:

```
unsafe impl<T: ?Sized> IsZero for *mut T {
    fn is_zero(&self) -> bool {
        (*self).is_null()
    }
}
```

… to call `RawVec::with_capacity_zeroed` for creating `Vec<*mut T>`,
which is incorrect for fat pointers
since `<*mut T>::is_null` only looks at the data component.
That is, a fat pointer can be “null” without being made entirely of zero bits.

This commit fixes it by removing the `?Sized` bound on this impl
(and the corresponding `*const T` one).
This regresses `vec![x; n]` with `x` a null raw slice of length zero,
but that seems exceptionally uncommon.
(Vtable pointers are never null, so raw trait objects would not take
the fast path anyway.

An alternative to keep the `?Sized` bound
(or even generalize to `impl<U: Copy> IsZero for U`)
would be to cast to `&[u8]` of length `size_of::<U>()`,
but the optimizer seems not to be able to propagate alignment information
and sticks with comparing one byte at a time:

https://rust.godbolt.org/z/xQFkwL

----

Without the library change, the new test fails as follows:

```
---- vec::vec_macro_repeating_null_raw_fat_pointer stdout ----
[src/liballoc/tests/vec.rs:1301] ptr_metadata(raw_dyn) = 0x00005596ef95f9a8
[src/liballoc/tests/vec.rs:1306] ptr_metadata(vec[0]) = 0x0000000000000000
thread 'vec::vec_macro_repeating_null_raw_fat_pointer' panicked at 'assertion failed: vec[0] == null_raw_dyn', src/liballoc/tests/vec.rs:1307:5
```

4 years agoAuto merge of #64886 - Centril:rollup-30dqh8j, r=Centril
bors [Sun, 29 Sep 2019 06:08:50 +0000 (06:08 +0000)]
Auto merge of #64886 - Centril:rollup-30dqh8j, r=Centril

Rollup of 5 pull requests

Successful merges:

 - #63492 (Remove redundancy from the implementation of C variadics.)
 - #64589 (Differentiate AArch64 bare-metal targets between hf and non-hf.)
 - #64799 (Fix double panic when printing query stack during an ICE)
 - #64824 (No StableHasherResult everywhere)
 - #64884 (Add pkg-config to dependency list if building for Linux on Linux)

Failed merges:

r? @ghost

4 years agosyntax: recover trailing `|` in or-patterns.
Mazdak Farrokhzad [Sun, 29 Sep 2019 04:21:20 +0000 (06:21 +0200)]
syntax: recover trailing `|` in or-patterns.

4 years agoRollup merge of #64884 - jakevossen5:master, r=Mark-Simulacrum
Mazdak Farrokhzad [Sun, 29 Sep 2019 02:36:04 +0000 (04:36 +0200)]
Rollup merge of #64884 - jakevossen5:master, r=Mark-Simulacrum

Add pkg-config to dependency list if building for Linux on Linux

I got this message when building from source on Ubuntu:

```
It looks like you're compiling on Linux and also targeting Linux. Currently this
requires the `pkg-config` utility to find OpenSSL but unfortunately `pkg-config`
could not be found. If you have OpenSSL installed you can likely fix this by
installing `pkg-config`.
```

I feel like it would be a better experience to show this in the dependencies instead of having to run into this issue.

4 years agoRollup merge of #64824 - Mark-Simulacrum:no-stable-hasher-result-everywhere, r=michae...
Mazdak Farrokhzad [Sun, 29 Sep 2019 02:36:02 +0000 (04:36 +0200)]
Rollup merge of #64824 - Mark-Simulacrum:no-stable-hasher-result-everywhere, r=michaelwoerister

No StableHasherResult everywhere

This removes the generic parameter on `StableHasher`, instead moving it to the call to `finish`. This has the side-effect of making all `HashStable` impls nicer, since we no longer need the verbose `<W: StableHasherResult>` that previously existed -- often forcing line wrapping.

This is done for two reasons:
 * we should avoid false "generic" dependency on the result of StableHasher
     * we don't need to codegen two/three copies of all the HashStable impls when they're transitively used to produce a fingerprint, u64, or u128. I haven't measured, but this might actually make our artifacts somewhat smaller too.
 * Easier to understand/read/write code -- the result of the stable hasher is irrelevant when writing a hash impl.

4 years agoRollup merge of #64799 - Aaron1011:fix/double-panic, r=Mark-Simulacrum
Mazdak Farrokhzad [Sun, 29 Sep 2019 02:36:01 +0000 (04:36 +0200)]
Rollup merge of #64799 - Aaron1011:fix/double-panic, r=Mark-Simulacrum

Fix double panic when printing query stack during an ICE

On the latest nightly, any call to `bug` or `span_bug` will result in two panics - the first one as a normal result of calling `bug` / `span_bug`, and the second as a result of trying to print the query stack from the panic handler. This is caused by the query-printing code attempting to acquire a lock on `HandlerInnder`, which is still being held by `bug`.

This PR moves the actual panic out of `HandlerInner`, into `Handler`. This allows us to release the lock on `HandlerInner` before triggering the panic, ensuring that the panic handler will be able to acquire the lock if necessary.

4 years agoRollup merge of #64589 - andre-richter:aarch64_bare_metal, r=Amanieu
Mazdak Farrokhzad [Sun, 29 Sep 2019 02:35:59 +0000 (04:35 +0200)]
Rollup merge of #64589 - andre-richter:aarch64_bare_metal, r=Amanieu

Differentiate AArch64 bare-metal targets between hf and non-hf.

CC @parched, kindly request you to review.

~~Note: This change breaks code that uses the target `aarch64-unknown-none` for the sake of clearer naming as discussed in the links posted below. A search on github reveals that code using `aarch64-unknown-none` is almost exclusively forked from our embedded WG's OS tutorials repo at https://github.com/rust-embedded/rust-raspi3-OS-tutorials, for which the target was originally created.~~

~~I will adapt this repo to the new target name asap once this PR would go upstream. The minor annoyance for the forks to break temporarily should be acceptable for the sake of introducing a better differentiation now before it is too late.
Also, the break would only happen upon updating the toolchain, giving the user a good hint at what has happened.~~

---------- Patch commit message:
Following up on [1] and [2], this PR adds differntiation for aarch64 bare-metal
targets between versions with and without floating point enabled.

This streamlines the target naming with other existing ARM targets and provides
the user clear indication if he is getting float or non-float for his bare-metal
target.

[1] https://github.com/rust-lang/rust/pull/60135#issuecomment-485851356
[2] https://github.com/rust-embedded/wg/issues/230

Closes: rust-embedded/wg#230
4 years agoRollup merge of #63492 - eddyb:cvarargs, r=nagisa,matthewjasper
Mazdak Farrokhzad [Sun, 29 Sep 2019 02:35:58 +0000 (04:35 +0200)]
Rollup merge of #63492 - eddyb:cvarargs, r=nagisa,matthewjasper

Remove redundancy from the implementation of C variadics.

This cleanup was first described in https://github.com/rust-lang/rust/issues/44930#issuecomment-497163539:

* AST doesn't track `c_variadic: bool` anymore, relying solely on a trailing `CVarArgs` type in fn signatures
* HIR doesn't have a `CVarArgs` anymore, relying solely on `c_variadic: bool`
  * same for `ty::FnSig` (see tests for diagnostics improvements from that)
  * `{hir,mir}::Body` have one extra argument than the signature when `c_variadic == true`
  * `rustc_typeck` and `rustc_mir::{build,borrowck}` need to give that argument the right type (which no longer uses a lifetime parameter, but a function-internal scope)
* `rustc_target::abi::call` doesn't need special hacks anymore (since it never sees the `VaListImpl` now, it's all inside the body)

r? @nagisa / @rkruppe cc @dlrobertson @oli-obk

4 years agoAuto merge of #64470 - ecstatic-morse:split-promotion-and-validation, r=eddyb,oli-obk
bors [Sun, 29 Sep 2019 02:33:15 +0000 (02:33 +0000)]
Auto merge of #64470 - ecstatic-morse:split-promotion-and-validation, r=eddyb,oli-obk

Implement dataflow-based const validation

This PR adds a separate, dataflow-enabled pass that checks the bodies of `const`s, `static`s and `const fn`s for [const safety](https://github.com/rust-rfcs/const-eval/blob/master/const.md). This is based on my work in #63860, which tried to integrate into the existing pass in [`qualify_consts.rs`](https://github.com/rust-lang/rust/blob/master/src/librustc_mir/transform/qualify_consts.rs). However, the resulting pass was even more unwieldy than the original. Unlike its predecessor, this PR is designed to be combined with #63812 to replace the existing pass completely.

The new checker lives in [`librustc_mir/transform/check_consts`](https://github.com/ecstatic-morse/rust/tree/split-promotion-and-validation/src/librustc_mir/transform/check_consts).

[`qualifs.rs`](https://github.com/ecstatic-morse/rust/blob/split-promotion-and-validation/src/librustc_mir/transform/check_consts/qualifs.rs) contains small modifications to the existing `Qualif` trait and its implementors, but is mostly unchanged except for the removal of `IsNotPromotable` and `IsNotImplicitlyPromotable`, which are only necessary for promotion.

[`resolver.rs`](https://github.com/ecstatic-morse/rust/blob/split-promotion-and-validation/src/librustc_mir/transform/check_consts/resolver.rs) contains the dataflow analysis used to propagate qualifs between locals.

Finally, [`validation.rs`](https://github.com/ecstatic-morse/rust/blob/split-promotion-and-validation/src/librustc_mir/transform/check_consts/validation.rs) contains a refactored version of the existing [`Visitor`](https://github.com/rust-lang/rust/blob/ca3766e2e58f462a20922e42c821a37eaf0e13db/src/librustc_mir/transform/qualify_consts.rs#L1024) in `qualfy_consts.rs`. All errors have been associated with a `struct` to make [comparison with the existing pass](https://github.com/ecstatic-morse/rust/blob/1c19f2d540ca0a964900449d79a5d5181b43146d/src/librustc_mir/transform/qualify_consts.rs#L1006) simple.

The existing validation logic in [`qualify_consts`](https://github.com/rust-lang/rust/blob/master/src/librustc_mir/transform/qualify_consts.rs) has been modified to allow it to run in parallel with the new validator. If [`use_new_validator`](https://github.com/rust-lang/rust/pull/64470/files#diff-c2552a106550d05b69d5e07612f0f812R950) is not set, the old validation will be responsible for actually generating the errors, but those errors can be compared with the ones from the new validator.

4 years agoAuto merge of #64883 - Centril:rollup-uehjt63, r=Centril
bors [Sat, 28 Sep 2019 22:42:58 +0000 (22:42 +0000)]
Auto merge of #64883 - Centril:rollup-uehjt63, r=Centril

Rollup of 10 pull requests

Successful merges:

 - #64131 (data_structures: Add deterministic FxHashMap and FxHashSet wrappers)
 - #64387 (Fix redundant semicolon lint interaction with proc macro attributes)
 - #64678 (added more context for duplicate lang item errors (fixes #60561))
 - #64763 (Add E0734 and its long explanation)
 - #64793 (Fix format macro expansions spans to be macro-generated)
 - #64837 (Improve wording in documentation of MaybeUninit)
 - #64852 (Print ParamTy span when accessing a field (#52082))
 - #64875 (Upgrade async/await to "used" keywords.)
 - #64876 (Fix typo in intrinsics op safety)
 - #64880 (Slice docs: fix typo)

Failed merges:

r? @ghost

4 years agoPut panic=abort test support behind -Z panic_abort_tests
Tyler Mandry [Fri, 20 Sep 2019 02:33:38 +0000 (19:33 -0700)]
Put panic=abort test support behind -Z panic_abort_tests

4 years agoAdd test for libtest panic=abort mode
Tyler Mandry [Fri, 20 Sep 2019 01:34:23 +0000 (18:34 -0700)]
Add test for libtest panic=abort mode

4 years agoSpawn one subprocess per unit test when panic=abort
Tyler Mandry [Thu, 12 Sep 2019 00:13:34 +0000 (17:13 -0700)]
Spawn one subprocess per unit test when panic=abort

4 years agoSupport run-fail ui tests
Tyler Mandry [Fri, 20 Sep 2019 01:33:22 +0000 (18:33 -0700)]
Support run-fail ui tests

4 years agolinux -> Linux
= [Sat, 28 Sep 2019 20:18:29 +0000 (14:18 -0600)]
linux -> Linux

4 years agoadd pkg-config to dependencies
= [Sat, 28 Sep 2019 20:17:09 +0000 (14:17 -0600)]
add pkg-config to dependencies

4 years agoRollup merge of #64880 - llogiq:slice-docs, r=Centril
Mazdak Farrokhzad [Sat, 28 Sep 2019 20:12:11 +0000 (22:12 +0200)]
Rollup merge of #64880 - llogiq:slice-docs, r=Centril

Slice docs: fix typo

With #64703, I introduced a typo. Here is the fix. Sorry for the inconvenience.

4 years agoRollup merge of #64876 - vertexclique:vcq/fix-fn-name-intrinsic-op-unsafety, r=varkor
Mazdak Farrokhzad [Sat, 28 Sep 2019 20:12:10 +0000 (22:12 +0200)]
Rollup merge of #64876 - vertexclique:vcq/fix-fn-name-intrinsic-op-unsafety, r=varkor

Fix typo in intrinsics op safety

Title pretty much sums up.

4 years agoRollup merge of #64875 - ehuss:async-await-reserved, r=estebank
Mazdak Farrokhzad [Sat, 28 Sep 2019 20:12:08 +0000 (22:12 +0200)]
Rollup merge of #64875 - ehuss:async-await-reserved, r=estebank

Upgrade async/await to "used" keywords.

AFAIK, this only affects error messages, removing the word "reserved".

Closes #64853

4 years agoRollup merge of #64852 - Baranowski:param_note_52082, r=estebank
Mazdak Farrokhzad [Sat, 28 Sep 2019 20:12:07 +0000 (22:12 +0200)]
Rollup merge of #64852 - Baranowski:param_note_52082, r=estebank

Print ParamTy span when accessing a field (#52082)

4 years agoRollup merge of #64837 - nliberg:patch-2, r=Centril
Mazdak Farrokhzad [Sat, 28 Sep 2019 20:12:06 +0000 (22:12 +0200)]
Rollup merge of #64837 - nliberg:patch-2, r=Centril

Improve wording in documentation of MaybeUninit

Changes

> variables are properly initialized **at** their respective type

into

> variables are properly initialized **as** their respective type

4 years agoRollup merge of #64793 - immunant:format_spans, r=matthewjasper
Mazdak Farrokhzad [Sat, 28 Sep 2019 20:12:04 +0000 (22:12 +0200)]
Rollup merge of #64793 - immunant:format_spans, r=matthewjasper

Fix format macro expansions spans to be macro-generated

New Exprs generated as part of the format macro expansion should get the macro
expansion span with an expansion context, rather than the span of the format string
which does not.

4 years agoRollup merge of #64763 - GuillaumeGomez:long-err-explanation-E0734, r=estebank
Mazdak Farrokhzad [Sat, 28 Sep 2019 20:12:02 +0000 (22:12 +0200)]
Rollup merge of #64763 - GuillaumeGomez:long-err-explanation-E0734, r=estebank

Add E0734 and its long explanation

Part of https://github.com/rust-lang/rust/issues/61137

4 years agoRollup merge of #64678 - tomtau:fix/no-std-error, r=matthewjasper
Mazdak Farrokhzad [Sat, 28 Sep 2019 20:12:01 +0000 (22:12 +0200)]
Rollup merge of #64678 - tomtau:fix/no-std-error, r=matthewjasper

added more context for duplicate lang item errors (fixes #60561)

Some more information about #60561 -- these errors are pretty common when one works in restrictive environments with `no_std` or customized `std`, but they don't provide much context for debugging, as any transitive dependency could have brought in `std` crate. With that, currently, one needs to use something like `cargo tree` and investigate transitive dependencies one by one.

It'll be more helpful to know at least the crate that uses `std` (which `cargo tree` doesn't show) to pin down this investigation when debugging.

I'm not sure what the best way to get this context is inside rustc internals (I'm new to them). I found that `all_crate_nums` query returns the crates in some dependency order, so printing out the name of the preceding crate seems to do the trick. But I welcome suggestions if this can be done in a better way.

4 years agoRollup merge of #64387 - nathanwhit:redundant-semi-fix, r=varkor
Mazdak Farrokhzad [Sat, 28 Sep 2019 20:11:59 +0000 (22:11 +0200)]
Rollup merge of #64387 - nathanwhit:redundant-semi-fix, r=varkor

Fix redundant semicolon lint interaction with proc macro attributes

Fixes #63967 and fixes #63947, both of which were caused by the lint's changes to the parser interacting poorly with proc macro attributes and causing span information to be lost

r? @varkor

4 years agoRollup merge of #64131 - shivan1b:deterministic-fxhashmap, r=Mark-Simulacrum
Mazdak Farrokhzad [Sat, 28 Sep 2019 20:11:58 +0000 (22:11 +0200)]
Rollup merge of #64131 - shivan1b:deterministic-fxhashmap, r=Mark-Simulacrum

data_structures: Add deterministic FxHashMap and FxHashSet wrappers

StableMap
A wrapper for FxHashMap that allows to `insert`, `remove`, `get`, `get_mut` and convert a hashmap into a sorted vector using the method `into_sorted_vector` but no iteration support.

StableSet
A wrapper for FxHashSet that allows to `insert`, `remove`, `get` and convert a hashset into a sorted vector using the method `into_sorted_vector` but no iteration support.

Addresses issue #63713

4 years agoAdd a couple more test cases, including non-ascii strings.
ben [Sat, 28 Sep 2019 19:39:48 +0000 (08:39 +1300)]
Add a couple more test cases, including non-ascii strings.

4 years agoSlice docs: fix typo
Andre Bogus [Sat, 28 Sep 2019 19:02:51 +0000 (21:02 +0200)]
Slice docs: fix typo

4 years agoclean up
Esteban Küber [Sat, 28 Sep 2019 01:42:30 +0000 (18:42 -0700)]
clean up

4 years agoreview comments
Esteban Küber [Sat, 28 Sep 2019 01:35:34 +0000 (18:35 -0700)]
review comments

4 years agoPoint at enclosing match when expecting `()` in arm
Esteban Küber [Fri, 27 Sep 2019 00:16:34 +0000 (17:16 -0700)]
Point at enclosing match when expecting `()` in arm

When encountering code like the following:

```rust
fn main() {
    match 3 {
        4 => 1,
        3 => {
            println!("Yep it maches.");
            2
        }
        _ => 2
    }
    println!("Bye!")
}
```

point at the enclosing `match` expression and suggest ignoring the
returned value:

```
error[E0308]: mismatched types
  --> $DIR/match-needing-semi.rs:8:13
   |
LL | /     match 3 {
LL | |         4 => 1,
LL | |         3 => {
LL | |             2
   | |             ^ expected (), found integer
LL | |         }
LL | |         _ => 2
LL | |     }
   | |     -- help: consider using a semicolon here
   | |_____|
   |       expected this to be `()`
   |
   = note: expected type `()`
              found type `{integer}
```

Fix #40799.

4 years agoFix typo in intrinsics op safety
Mahmut Bulut [Sat, 28 Sep 2019 16:24:05 +0000 (18:24 +0200)]
Fix typo in intrinsics op safety

4 years agoUpgrade async/await to "used" keywords.
Eric Huss [Sat, 28 Sep 2019 16:15:06 +0000 (09:15 -0700)]
Upgrade async/await to "used" keywords.

4 years agoAuto merge of #64419 - wesleywiser:const_prop_use_ecx, r=oli-obk
bors [Sat, 28 Sep 2019 15:54:12 +0000 (15:54 +0000)]
Auto merge of #64419 - wesleywiser:const_prop_use_ecx, r=oli-obk

Deduplicate some code between miri and const prop

r? @oli-obk

4 years agoSwitch over all StableHash impls to new format
Mark Rousskov [Thu, 26 Sep 2019 22:54:39 +0000 (18:54 -0400)]
Switch over all StableHash impls to new format

4 years agoStableHasher does not need to be generic over the Result type
Mark Rousskov [Thu, 26 Sep 2019 22:28:02 +0000 (18:28 -0400)]
StableHasher does not need to be generic over the Result type

4 years agorustc_codegen_ssa: remove redundant `va_list_ref` field from `FunctionCx`.
Eduard-Mihai Burtescu [Mon, 12 Aug 2019 12:27:31 +0000 (15:27 +0300)]
rustc_codegen_ssa: remove redundant `va_list_ref` field from `FunctionCx`.

4 years agorustc: rely on c_variadic == true instead of CVarArgs in HIR/Ty fn signatures.
Eduard-Mihai Burtescu [Sat, 10 Aug 2019 11:38:17 +0000 (14:38 +0300)]
rustc: rely on c_variadic == true instead of CVarArgs in HIR/Ty fn signatures.

4 years agorustc: don't store a lifetime in hir::TyKind::CVarArgs.
Eduard-Mihai Burtescu [Sun, 11 Aug 2019 15:34:31 +0000 (18:34 +0300)]
rustc: don't store a lifetime in hir::TyKind::CVarArgs.