100060 Commits

Author SHA1 Message Date
Mazdak Farrokhzad
f4aa29fb1e
Rollup merge of #64930 - davidtwco:issue-61798-diverging-await, r=petrochenkov
Silence unreachable code lint from await desugaring

Fixes #61798.

This PR silences the unreachable code lint when it originates from within an await desugaring.
2019-10-01 09:55:37 +02:00
Mazdak Farrokhzad
dc1c1fe456
Rollup merge of #64928 - JohnTitor:add-some-tests, r=Centril
Add tests for some issues

Closes #50571
Closes #58022
Closes #58344
2019-10-01 09:55:35 +02:00
Mazdak Farrokhzad
24a84fae34
Rollup merge of #64907 - alexreg:tidy-up, r=Mark-Simulacrum
A small amount of tidying-up factored out from PR #64648

As requested by @Mark-Simulacrum, I put this in a separate commit to make it easier to review. (As far as I can tell, no violations of the policy here, and they are simply in a separate PR because they're not directly related to the import of that PR.)

r? @Mark-Simulacrum
2019-10-01 09:55:34 +02:00
Mazdak Farrokhzad
b8c5d3a427
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
2019-10-01 09:55:33 +02:00
Mazdak Farrokhzad
25f774a4cf
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
2019-10-01 09:55:31 +02:00
Mazdak Farrokhzad
f45de9a690
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
2019-10-01 09:55:29 +02:00
Mazdak Farrokhzad
3bd34e04e3
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
2019-10-01 09:55:28 +02:00
Mazdak Farrokhzad
64130fd2c4
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.)
2019-10-01 09:55:26 +02:00
Nicholas Nethercote
b2ae3f2a6b Remove the $lt_tcx parameter from direct_interners!.
It's not necessary.
2019-10-01 16:07:57 +10:00
Nicholas Nethercote
475e131b3e Inline and remove intern_method!.
It's only used in two places, and the code is shorter and more readable
with it gone.
2019-10-01 16:06:38 +10:00
Andreas Jonson
8737061cb5 replace try_for_each with try_fold to generate less code
removes two functions to inline by combining the check functions and extra call to try_for_each
2019-10-01 07:56:18 +02:00
Nicholas Nethercote
3724e37b5a Remove special treatment for _intern_canonical_var_infos.
This is a leftover from when there were global and thread-local arenas.
2019-10-01 15:50:51 +10:00
Nicholas Nethercote
e9d54e1860 Reorder the slice interners.
So the order matches the order in `CtxtInterners`.
2019-10-01 15:48:25 +10:00
Lzu Tao
eb4ca2120e Add lower bound doctests for saturating_{add,sub} signed ints 2019-10-01 05:46:50 +00:00
Lzu Tao
3b49ab6e48 Inline {min,max}_value even in debug builds 2019-10-01 04:10:51 +00:00
Mazdak Farrokhzad
5c5dd8069d syntax: reformat passing of FnHeader to parse_item_fn. 2019-10-01 06:10:06 +02:00
Mazdak Farrokhzad
e04690440b syntax: de-closure-ify check_or_expected. 2019-10-01 05:55:28 +02:00
Mazdak Farrokhzad
49780d21b6 syntax: merge things back into parse_visibility. 2019-10-01 05:53:23 +02:00
Mazdak Farrokhzad
30647d1a85 syntax: put helpers of parse_self_param in the method. 2019-10-01 05:45:41 +02:00
Mazdak Farrokhzad
df298b49f2 syntax: document some methods. 2019-10-01 05:13:42 +02:00
bors
42ec6831b0 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
2019-10-01 02:31:48 +00:00
Esteban Küber
13e9b3deb4 Deduplicate closure type errors
Closure typing obligations flow in both direcitons to properly infer
types. Because of this, we will get 2 type errors whenever there's
an unfulfilled obligation. To avoid this, we deduplicate them in the
`InferCtxt`.
2019-09-30 17:48:22 -07:00
AnthonyMikh
50c2a58d08
Fix borrowck errors
Reborrowing doesn't work for loops
2019-10-01 03:22:07 +03:00
AnthonyMikh
fdce4168fc
Hint type for .sum() 2019-10-01 03:04:01 +03:00
AnthonyMikh
515262cc13
Ascript type explicitly 2019-10-01 02:53:44 +03:00
AnthonyMikh
61bc38ecaa
Fix errors 2019-10-01 02:38:35 +03:00
AnthonyMikh
e5db5b34d7
(fmt) remove trailing whitespaces 2019-10-01 02:30:52 +03:00
David Wood
04fa9b1b3f
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>
2019-09-30 23:41:20 +01:00
Sam Radhakrishnan
c9baaa70be Fixes #64919. Suggest fix based on operator precendence. 2019-09-30 18:16:34 -04:00
AnthonyMikh
bb442881fc
Use pattern matching instead of indexing tuples 2019-10-01 01:12:36 +03:00
Esteban Küber
0e6fb8e8da review comments 2019-09-30 15:11:19 -07:00
Esteban Küber
2ae87ff59d Avoid ICE on return outside of fn with literal array
Do not ICE when encountering `enum E { A = return [0][0] }`.
2019-09-30 15:11:19 -07:00
Vadim Petrochenkov
6ea4a52f47 Address review comments 2019-10-01 01:10:12 +03:00
AnthonyMikh
55b54285c8
Simplify a conditional in collect_annotations
Also avoid excessive cloning
2019-10-01 01:08:51 +03:00
Tyler Mandry
913c095bcf
Rollup merge of #64923 - lzutao:improve-doc-needs_drop, r=jonas-schievink
Add missing links for mem::needs_drop

r? @jonas-schievink
2019-09-30 14:38:32 -07:00
Tyler Mandry
e9d28796ec
Rollup merge of #64921 - JohnTitor:add-test-enum, r=varkor
Add test for issue-64662

Closes #64662
r? @varkor
2019-09-30 14:38:31 -07:00
Tyler Mandry
5560f8c664
Rollup merge of #64911 - hman523:64844, r=Dylan-DPC
Fixed a misleading documentation issue #64844

Made the suggested change from @steveklabnik on issue #64844
2019-09-30 14:38:28 -07:00
Tyler Mandry
a8ed9bfe02
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>>`
2019-09-30 14:38:27 -07:00
Tyler Mandry
1cd9b4bc85
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
```
2019-09-30 14:38:25 -07:00
Tyler Mandry
3add9790ab
Rollup merge of #64838 - GuillaumeGomez:long-err-explanation-e0550, r=oli-obk
Add long error explanation for E0550

Part of #61137
2019-09-30 14:38:24 -07:00
Tyler Mandry
686ad4da9e
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`).
2019-09-30 14:38:22 -07:00
Tyler Mandry
fb8f9b47eb
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
2019-09-30 14:38:21 -07:00
Tyler Mandry
30ba6fd99c
Rollup merge of #64377 - GuillaumeGomez:E0493, r=estebank
Add long error explanation for E0493

Part of #61137.
2019-09-30 14:38:19 -07:00
AnthonyMikh
9d73176978
Remove redundant .iter_mut() 2019-10-01 00:10:23 +03:00
AnthonyMikh
7a807c5b14
Simplify EmitterWriter::emit_suggestion_default
Make function return early if source map is not present
2019-10-01 00:01:22 +03:00
AnthonyMikh
21724eda05
Update doc comment for style_or_override 2019-09-30 23:50:58 +03:00
Mark Rousskov
1a1067d1a5 Make the default parallelism 1
This changes the default parallelism for parallel compilers to one,
instead of the previous default, which was "num cpus". This is likely
not an optimal default long-term, but it is a good default for testing
whether parallel compilers are not a significant regression over a
sequential compiler.

Notably, this in theory makes a parallel-enabled compiler behave
exactly like a sequential compiler with respect to the jobserver.
2019-09-30 16:49:19 -04:00
AnthonyMikh
7b4c5c62aa
Simplify EmitterWriter::get_max_line_num 2019-09-30 23:47:51 +03:00
AnthonyMikh
6b6a79b190
Simplify EmitterWriter::get_multispan_max_line_num 2019-09-30 23:43:24 +03:00
Esteban Küber
5cbe6aa6ca Reword E0392 slightly
Make it clearer that a type or lifetime argument not being used can be
fixed by referencing it in a struct's fields, not just using `PhathomData`.
2019-09-30 13:35:26 -07:00