Commit Graph

98125 Commits

Author SHA1 Message Date
Vadim Petrochenkov
ec45b87957 resolve: Block expansion of a derive container until all its derives are resolved
Also mark derive helpers as known as a part of the derive container's expansion instead of expansion of the derives themselves which may happen too late.
2019-08-27 00:31:55 +03:00
bors
9b91b9c10e Auto merge of #63901 - estebank:unknown-receiver-type, r=zackmdavis
Point at method call on missing annotation error

Make it clearer where the type name that couldn't be inferred comes from.

Before:

```
error[E0282]: type annotations needed
 --> src/test/ui/span/type-annotations-needed-expr.rs:2:13
  |
2 |     let _ = (vec![1,2,3]).into_iter().sum() as f64; //~ ERROR E0282
  |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type for `S`
  |
  = note: type must be known at this point
```
after
```
error[E0282]: type annotations needed
 --> src/test/ui/span/type-annotations-needed-expr.rs:2:39
  |
2 |     let _ = (vec![1,2,3]).into_iter().sum() as f64; //~ ERROR E0282
  |                                       ^^^ cannot infer type for `S`
  |
  = note: type must be known at this point
```

CC #63852.
2019-08-26 17:33:50 +00:00
bors
9fa8f14023 Auto merge of #63897 - petrochenkov:prettycomma, r=estebank
pprust: Do not print spaces before some tokens

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

r? @Mark-Simulacrum
2019-08-26 13:45:18 +00:00
bors
555d7a2fd6 Auto merge of #63580 - wesleywiser:move_promoted_out, r=oli-obk
Move promoted MIR out of `mir::Body`

r? @oli-obk
2019-08-26 07:48:24 +00:00
bors
e2b4165a6c Auto merge of #62891 - vext01:improve-black-box-docs, r=RalfJung,Centril,gnzlbg
Improve the documentation for std::hint::black_box.

The other day a colleague was reviewing some of my code which was using `black_box` to block constant propogation. There was a little confusion because the documentation kind of implies that `black_box` is only useful for dead code elimination, and only in benchmarking scenarios.

The docs currently say:

> A function that is opaque to the optimizer, to allow benchmarks to pretend to use outputs to assist in avoiding dead-code elimination.

Here is our discussion, in which I show (using godbolt) that a black box can also block constant propagation:
https://github.com/softdevteam/yk/pull/21#discussion_r302985038

This change makes the docstring for `black_box` a little more general, and while we are here, I've added an example (the same one from our discussion).

![image](https://user-images.githubusercontent.com/604955/61701322-ddf1e400-ad35-11e9-878c-b5b44a20770c.png)

OK to go in?
2019-08-26 04:10:54 +00:00
bors
4c58535d09 Auto merge of #62603 - cuviper:no-unwind-abort, r=joshtriplett
Permit unwinding through FFI by default

This repeats #62505 for master (Rust 1.38+), as #58794 is not yet resolved. This is a stopgap until a stable alternative is available, like [RFC 2699](https://github.com/rust-lang/rfcs/pull/2699), as long as progress is being made to that end.

r? @joshtriplett
2019-08-26 00:27:17 +00:00
Esteban Küber
8458eba41b Point at method call on missing annotation error
Make it clearer where the type name that couldn't be infered comes from.
2019-08-25 13:39:11 -07:00
bors
521d784074 Auto merge of #61613 - sinkuu:impl_trait_inline, r=ollie27
Support `impl Trait` in inlined documentation

`impl Trait` in argument position was not properly rendered when inlined from other crates. ([a live example on docs.rs](https://docs.rs/libp2p/0.8.1/libp2p/floodsub/struct.Floodsub.html#method.unsubscribe))

![old](https://user-images.githubusercontent.com/7091080/59089838-14ba9900-8946-11e9-830b-53b317bdecb4.png)
↓
![new](https://user-images.githubusercontent.com/7091080/59089844-16845c80-8946-11e9-9fe3-8998af9d73ce.png)
2019-08-25 19:20:20 +00:00
Vadim Petrochenkov
5b7df0922e pprust: Do not print spaces before some tokens 2019-08-25 21:23:17 +03:00
Josh Stone
367b793790 Force #[unwind(aborts)] in test/codegen/c-variadic.rs 2019-08-25 09:47:50 -07:00
Josh Stone
d810e77f4e Revert "Allow a dirty MirBuilt for make_extern and make_method_extern"
This reverts commit b4a6f59793.
2019-08-25 09:47:50 -07:00
Mark Rousskov
39412ca969 Permit unwinding through FFI by default
See #58794 for context.
2019-08-25 09:47:50 -07:00
bors
b1522e6023 Auto merge of #63878 - phansch:update_clippy_submodule, r=Manishearth
submodules: update Clippy from 2bcb615 to 05f603e

changes: 2bcb615...05f603e

Should fix the Clippy toolstate.
2019-08-25 15:42:13 +00:00
Philipp Hansch
4f30d2ae5a
submodules: update clippy from 2bcb615594 to 05f603e6ce 2019-08-25 12:54:31 +02:00
bors
d760df5aea Auto merge of #63874 - spastorino:places-drive-by-cleanups, r=Centril
Places drive by cleanups

Small fixes of things meanwhile I was doing the box part of Place 2.0, based on @centril reviews.
2019-08-25 08:06:06 +00:00
bors
783469ca09 Auto merge of #63862 - Centril:match-cleanup, r=oli-obk
typeck: refactor patterns => `pat.rs`  + make the `def_bm` algo more declarative

Spurred by the relative difficulty I had in working up an explanation of how default match bindings work in https://github.com/rust-lang/rust/pull/63118#issuecomment-524161584, this PR refactors the type checking of patterns into `pat.rs`.

The PR is probably best read commit-by-commit and includes various changes beyond the following, which are the most important highlights:

- The algorithm for determining `def_bm` is encoded in a more declarative fashion now with important sub-steps divided into functions that make sense as logical units (and as described in the reference). This is done starting with *"extract `is_no_ref_pat`."* to *"extract `calc_default_binding_mode`"*.

- Dedicated functions like `check_pat_{lit,range,ident,tuple,box,ref,slice}` are then introduced for the various kinds of patterns to make things overall more readable.

- `fn check_pat_top(...)` becomes the sole entry point to type checking patterns.

   This will take care of initializing the default binding mode (hence: `def_bm`) to `BindByValue` and is called by all contexts that have a pattern that needs to be type checked (functions, `match`, `if let`, `let`, ...). The overall result is that the notion of `def_bm` is internal to checking patterns.

- Various diagnostics are extracted to dedicated functions to disturb the flow of type checking logic less.

r? @oli-obk
2019-08-25 04:26:26 +00:00
Santiago Pastorino
53f4734794
Add a period at the end of the sentence 2019-08-24 21:00:50 -04:00
Santiago Pastorino
717e8a5219
Join arms patterns, body is empty in all arms 2019-08-24 21:00:50 -04:00
Santiago Pastorino
59c063302f
Allow lifetime parameters to be inferred 2019-08-24 21:00:36 -04:00
bors
9267119019 Auto merge of #63873 - Centril:rollup-jgglypd, r=Centril
Rollup of 6 pull requests

Successful merges:

 - #62744 (Refactor `TinyList::contains` and `len` to iterate instead of recurse)
 - #63813 (Do not suggest `.try_into()` on `i32::from(x)`)
 - #63833 (Suggest calling closure with resolved return type when appropriate)
 - #63839 (Ensure miri can do bit ops on pointer values)
 - #63854 (Modifies how Arg, Arm, Field, FieldPattern and Variant are visited)
 - #63859 (Don't unwrap the result of `span_to_snippet`)

Failed merges:

r? @ghost
2019-08-25 00:47:28 +00:00
Mazdak Farrokhzad
4d3d06ae53
Rollup merge of #63859 - matthewjasper:check-snippet-result, r=Centril
Don't unwrap the result of `span_to_snippet`

Closes #63800
2019-08-25 02:45:05 +02:00
Mazdak Farrokhzad
b0d374a0b1
Rollup merge of #63854 - c410-f3r:attrs-visit, r=petrochenkov
Modifies how Arg, Arm, Field, FieldPattern and Variant are visited

Part of the necessary work to accomplish #63468.
2019-08-25 02:45:04 +02:00
Mazdak Farrokhzad
7059f0571a
Rollup merge of #63839 - oli-obk:intptrcast, r=RalfJung
Ensure miri can do bit ops on pointer values

r? @RalfJung

Fixes https://github.com/rust-lang/miri/issues/916
2019-08-25 02:45:02 +02:00
Mazdak Farrokhzad
3d4b1135f8
Rollup merge of #63833 - estebank:suggest-closure-call, r=petrochenkov
Suggest calling closure with resolved return type when appropriate

Follow up to #63337. CC #63100.

```
error[E0308]: mismatched types
  --> $DIR/fn-or-tuple-struct-without-args.rs:46:20
   |
LL |     let closure = || 42;
   |                   -- closure defined here
LL |     let _: usize = closure;
   |                    ^^^^^^^
   |                    |
   |                    expected usize, found closure
   |                    help: use parentheses to call this closure: `closure()`
   |
   = note: expected type `usize`
              found type `[closure@$DIR/fn-or-tuple-struct-without-args.rs:45:19: 45:24]`
```
2019-08-25 02:45:01 +02:00
Mazdak Farrokhzad
ed8e13c2cb
Rollup merge of #63813 - estebank:int-from, r=varkor
Do not suggest `.try_into()` on `i32::from(x)`

Fix #63697.
2019-08-25 02:44:59 +02:00
Mazdak Farrokhzad
5761fc759a
Rollup merge of #62744 - llogiq:tiny-list-refactor, r=eddyb
Refactor `TinyList::contains` and `len` to iterate instead of recurse

None
2019-08-25 02:44:58 +02:00
Mazdak Farrokhzad
5a7e1cb46a typeck/pat.rs: dedup in check_pat_box. 2019-08-25 00:27:55 +02:00
Mazdak Farrokhzad
4f75327659 typeck/pat.rs: dedup in check_pat_ref. 2019-08-25 00:08:47 +02:00
Esteban Küber
3890befa8e review comment 2019-08-24 14:54:35 -07:00
Edd Barrett
a4b3dbe4c1 Improve the documentation for std::hint::black_box. 2019-08-24 19:00:13 +01:00
Mazdak Farrokhzad
5fbfcd8872 typeck/pat.rs: extract error_inexistent_fields. 2019-08-24 19:57:05 +02:00
Mazdak Farrokhzad
ba2a784c38 typeck/pat.rs: extract error_unmentioned_fields. 2019-08-24 19:57:05 +02:00
Mazdak Farrokhzad
25f605ae99 typeck/pat.rs: extract error_field_already_bound. 2019-08-24 19:57:05 +02:00
Mazdak Farrokhzad
729fbeb70b typeck/pat.rs: extract diagnostics from check_pat_slice. 2019-08-24 19:57:05 +02:00
Mazdak Farrokhzad
2ab69aef03 typeck/pat.rs: extract new_ref_ty. 2019-08-24 19:57:05 +02:00
Mazdak Farrokhzad
97986b5704 typeck/pat.rs: some common imports. 2019-08-24 19:57:05 +02:00
Mazdak Farrokhzad
41e8aed3cf typeck/pat.rs: check_pat_walk -> check_pat.
It's just shorter and we usually don't use the `_walk` suffix.
2019-08-24 19:57:05 +02:00
Mazdak Farrokhzad
65deeae76d typeck/pat.rs: check_pat_top is the entry point.
This clarifies the fact that type checking patterns unconditionally
starts with `BindByValue` as the default binding mode making the
notion of a default binding mode internal to type checking patterns.
2019-08-24 19:56:56 +02:00
bors
eeba189cfb Auto merge of #63858 - matthiaskrgr:submodule_upd, r=oli-obk
submodules: update clippy from cd3df6be to 2bcb6155

Changes:
````
Refactor some minor things
Use more if-chains
Refactor 'lint_or_fun_call'
Refactor 'check_unwrap_or_default'
Refactor 'check_impl_item'
Add missing field to LitKind::Str
Run update_lints for Unicode lint
Re-add false positive check
Add raw string regression test for useless_format lint
Re-factor useless_format lint
Update Unicode lint tests
Add two more tests, allow 2 other lints.
Fix `temporary_cstring_as_ptr` false negative
Add more testcases for redundant_pattern_matching
Fix suggestions for redundant_pattern_matching
Add note on how to find the latest beta commit
Remove feature gate for async_await
Update if_chain doc link
Requested test cleanup
Requested changes
Ignore lines starting with '#'
run-rustfix for unseparated-prefix-literals
Add autofixable suggestion for unseparated integer literal suffices
Further text improvements
Add image
docs: Explain how to update the changelog
````

r? @oli-obk  @Manishearth
2019-08-24 17:49:35 +00:00
Matthew Jasper
365ff62fca Don't unwrap the result of span_to_snippet
It can return `Err` due to macros being expanded across crates or
files.
2019-08-24 18:25:34 +01:00
Mazdak Farrokhzad
9d69783a46 typeck/pat.rs: (*) -> (note_1) for clarity. 2019-08-24 19:15:52 +02:00
Mazdak Farrokhzad
862bb385d1 typeck/pat.rs: simplify check_pat_walk. 2019-08-24 19:15:47 +02:00
Mazdak Farrokhzad
f09f1a7139 typeck/pat.rs: extract check_pat_slice. 2019-08-24 19:15:42 +02:00
Mazdak Farrokhzad
b4a4e718de typeck/pat.rs: extract check_pat_ref. 2019-08-24 19:15:36 +02:00
Mazdak Farrokhzad
3de221a862 typeck/pat.rs: extract check_pat_box. 2019-08-24 19:15:31 +02:00
Mazdak Farrokhzad
3a51caa648 typeck/pat.rs: extract check_pat_tuple. 2019-08-24 19:15:26 +02:00
Mazdak Farrokhzad
c16248d3a1 typeck/pat.rs: extract check_pat_ident. 2019-08-24 19:15:21 +02:00
Mazdak Farrokhzad
d4afae943f typeck/pat.rs: extract check_pat_range. 2019-08-24 19:15:16 +02:00
Mazdak Farrokhzad
d891e70b64 typeck/pat.rs: extract check_pat_lit. 2019-08-24 19:15:11 +02:00
Mazdak Farrokhzad
23dc37d21d typeck/pat.rs: extract calc_default_binding_mode. 2019-08-24 19:15:05 +02:00