Commit Graph

99894 Commits

Author SHA1 Message Date
Mazdak Farrokhzad
66148f6393
Rollup merge of #64943 - lzutao:doc-saturating, r=shepmaster
Add lower bound doctests for `saturating_{add,sub}` signed ints

Closes #64940
2019-10-01 23:56:26 +02:00
Mazdak Farrokhzad
67cbeee9ee
Rollup merge of #64933 - sam09:master, r=estebank
Fixes #64919. Suggest fix based on operator precendence.

Fixes https://github.com/rust-lang/rust/issues/64919
2019-10-01 23:56:24 +02:00
Mazdak Farrokhzad
7628cada4f
Rollup merge of #64912 - lzutao:unneeded-main-doc, r=jonas-schievink
Remove unneeded `fn main` blocks from docs

## [No whitespace diff](https://github.com/rust-lang/rust/pull/64912/files?w=1)
2019-10-01 23:56:23 +02:00
Mazdak Farrokhzad
db9689333a
Rollup merge of #64910 - Centril:params-cleanup, r=petrochenkov
syntax: cleanup param, method, and misc parsing

Do some misc cleanup of the parser:
- Method and parameter parsing is refactored.
- A parser for `const | mut` is introduced that https://github.com/rust-lang/rust/pull/64588 can reuse.
- Some other misc parsing.

Next up in a different PR:
- ~Implementing https://github.com/rust-lang/rust/issues/64252.~ -- maybe some other time...
- Heavily restructuring up `item.rs` which is a mess (hopefully, no promises ^^).

r? @petrochenkov
2019-10-01 23:56:21 +02:00
Mazdak Farrokhzad
69028ae85b
Rollup merge of #64820 - ssomers:master, r=bluss
BTreeSet intersection, is_subset & difference optimizations

...based on the range of values contained; in particular, a massive improvement when these ranges are disjoint (or merely touching), like in the neg-vs-pos benchmarks already in liballoc. Inspired by #64383 but none of the ideas there worked out.

I introduced another variant in IntersectionInner and in DifferenceInner, because I couldn't find a way to initialize these iterators as empty if there's no empty set around.

Also, reduced the size of "large" sets in test cases - if Miri can't handle it, it was needlessly slowing down everyone.
2019-10-01 23:56:20 +02:00
Mazdak Farrokhzad
baba6284bf
Rollup merge of #63416 - RalfJung:apfloat, r=eddyb
apfloat: improve doc comments

r? @eddyb @nagisa
2019-10-01 23:56:16 +02:00
Stein Somers
d132a70bf4 BTreeSet intersection, difference & is_subnet optimizations 2019-10-01 15:50:11 +02:00
Lzu Tao
6c1b447f2e Remove unneeded fn main blocks from docs 2019-10-01 11:55:46 +00:00
Sam Radhakrishnan
9e4eb46790 Change to use exprPrecedence instead of exprKind. 2019-10-01 05:00:22 -04:00
bors
702b45e409 Auto merge of #64946 - Centril:rollup-66mj5o0, r=Centril
Rollup of 10 pull requests

Successful merges:

 - #63674 (syntax: Support modern attribute syntax in the `meta` matcher)
 - #63931 (Stabilize macros in some more positions)
 - #64887 (syntax: recover trailing `|` in or-patterns)
 - #64895 (async/await: improve not-send errors)
 - #64896 (Remove legacy grammar)
 - #64907 (A small amount of tidying-up factored out from PR #64648)
 - #64928 (Add tests for some issues)
 - #64930 (Silence unreachable code lint from await desugaring)
 - #64935 (Improve code clarity)
 - #64937 (Deduplicate closure type errors)

Failed merges:

r? @ghost
2019-10-01 07:56:52 +00:00
Mazdak Farrokhzad
46bf6ad416
Rollup merge of #64937 - estebank:dedup-closure-err, r=Centril
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-10-01 09:55:39 +02:00
Mazdak Farrokhzad
5c6a8ee9dd
Rollup merge of #64935 - AnthonyMikh:librustc_errors/emmiter__code-clarity, r=estebank
Improve code clarity

No commit except 55b54285c8 address performance, just making the existing code more clear.

r? @estebank
2019-10-01 09:55:38 +02:00
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
Lzu Tao
eb4ca2120e Add lower bound doctests for saturating_{add,sub} signed ints 2019-10-01 05:46:50 +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
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