Commit Graph

106357 Commits

Author SHA1 Message Date
Dylan DPC
2d8f6389d0
Rollup merge of #68524 - jonas-schievink:generator-resume-arguments, r=Zoxc
Generator Resume Arguments

cc https://github.com/rust-lang/rust/issues/43122 and https://github.com/rust-lang/rust/issues/56974

Blockers:
* [x] Fix miscompilation when resume argument is live across a yield point (https://github.com/rust-lang/rust/pull/68524#issuecomment-578459069)
* [x] Fix 10% compile time regression in `await-call-tree` benchmarks (https://github.com/rust-lang/rust/pull/68524#issuecomment-578487162)
  * [x] Fix remaining 1-3% regression (https://github.com/rust-lang/rust/pull/68524#issuecomment-579566255) - resolved (https://github.com/rust-lang/rust/pull/68524#issuecomment-581144901)
* [x] Make dropck rules account for resume arguments (https://github.com/rust-lang/rust/pull/68524#issuecomment-578541137)

Follow-up work:
* Change async/await desugaring to make use of this feature
* Rewrite [`box_region.rs`](3d8778d767/src/librustc_data_structures/box_region.rs) to use resume arguments (this shows up in profiles too)
2020-02-06 22:38:33 +01:00
Dylan DPC
26c86a6a28
Rollup merge of #67359 - eddyb:macro-backtrace-all-the-same, r=petrochenkov
Rename -Zexternal-macro-backtrace to -Zmacro-backtrace and clean up implementation.

This is my attempt at dealing with https://github.com/rust-lang/rust/pull/66364#issuecomment-565517232, although I'm not sure it's the least disruptive one.

The behavior of `-Zexternal-macro-backtrace` was already to enable full macro backtraces for *all* macros, the only part of it that was specific to cross-crate macros was showing this when *not used*:
```
note: this error originates in a macro outside of the current crate
  (in Nightly builds, run with -Z external-macro-backtrace for more info)
```

After this PR:
* the flag is renamed to `-Zmacro-backtrace`
  * do we need to have a deprecation period? cc @rust-lang/compiler
* the message informing you about the flag is always shown when an expansion of a bang macro/attribute/derive is involved, not just cross-crate ones
  * this accounts for most of the changes in tests
  * we could perhaps only show it for the bang macro case? feels odd for derives
* `fix_multispans_in_std_macros` is split into `fix_multispans_in_extern_macros` and `render_multispans_macro_backtrace`
  * this roughly reverts the non-behavioral parts of #46605, which combined the two functionalities
  * not sure where the old `std_macros` name came from, perhaps the `<std macros>` synthetic "file"? even then, odd that `std` specifically was mentioned
* `render_multispan_macro_backtrace`, by default (i.e. without `-Zmacro-backtrace`), hides the `in this macro invocation` label specifically to avoid redundancy in the diagnostic
  * that is, showing the macro use site is only useful when the diagnostic is inside the macro definition and the user can't otherwise tell which use site it applies to, not when the diagnostic is at/inside the use site already (which would make the label redundant)
  * before, it was only checking for the situation in which a cross-crate macro *definition* span would be replaced with the invocation span, which both made the connection to redundancy unobvious, and didn't help with other redundancy (e.g. when the diagnostic was pointing to an argument inside the macro invocation)
  * this accounts for the remaining test changes, which I've first noticed in https://github.com/rust-lang/rust/pull/66364#discussion_r356135967 but only later understood as part of this PR (hence the "redundancy" descriptions)

This PR is not needed for #66364, but it would help, as after this PR there's only one `.span_to_filename(...).is_macros()` check (i.e. for `<... macros>` synthetic "files") left in `rustc_errors`, and it's much more self-contained.

r? @petrochenkov
2020-02-06 22:38:31 +01:00
Eduard-Mihai Burtescu
96af578cd9 tests: add a revision to macro_backtrace without -Zmacro-backtrace. 2020-02-06 21:46:42 +02:00
Eduard-Mihai Burtescu
4c7eb59e81 rustc_macros: don't limit the -Zmacro-backtrace suggestion to extern macros. 2020-02-06 21:46:38 +02:00
Eduard-Mihai Burtescu
ab080973cb rustc_errors: hide "in this macro invocation" when redundant, more explicitly. 2020-02-06 21:32:07 +02:00
Eduard-Mihai Burtescu
5eaa9a150d rustc_errors: deduplicate the -Zmacro-backtrace suggestion message. 2020-02-06 21:32:07 +02:00
Eduard-Mihai Burtescu
f6fc80206e rustc: rename -Zexternal-macro-backtrace to -Zmacro-backtrace. 2020-02-06 21:32:07 +02:00
Eduard-Mihai Burtescu
8f286dbf27 rustc_errors: split macro backtrace rendering from <*macros> hacks. 2020-02-06 21:32:07 +02:00
bors
442ae7f040 Auto merge of #68893 - Dylan-DPC:rollup-3f2421a, r=Dylan-DPC
Rollup of 9 pull requests

Successful merges:

 - #68691 (Remove `RefCell` usage from `ObligationForest`.)
 - #68751 (Implement `unused_parens` for `const` and `static` items)
 - #68788 (Towards unified `fn` grammar)
 - #68837 (Make associated item collection a query)
 - #68842 (or_patterns: add regression test for #68785)
 - #68844 (use def_path_str for missing_debug_impls message)
 - #68845 (stop using BytePos for computing spans in librustc_parse/parser/mod.rs)
 - #68869 (clean up E0271 explanation)
 - #68880 (Forbid using `0` as issue number)

Failed merges:

r? @ghost
2020-02-06 15:43:00 +00:00
Dylan DPC
1ad674afcf
Rollup merge of #68880 - JohnTitor:issue-non-zero, r=Dylan-DPC
Forbid using `0` as issue number

Fixes #67496

r? @Centril
2020-02-06 15:37:51 +01:00
Dylan DPC
2210d3f356
Rollup merge of #68869 - GuillaumeGomez:err-explanation-e0271, r=Dylan-DPC
clean up E0271 explanation

r? @Dylan-DPC
2020-02-06 15:37:49 +01:00
Dylan DPC
ec24833325
Rollup merge of #68845 - dwrensha:fix-68783, r=estebank
stop using BytePos for computing spans in librustc_parse/parser/mod.rs

Computing spans using logic such as `self.token.span.lo() + BytePos(1)` can cause internal compiler errors like #68730 when non-ascii characters are given as input.

#68735 partially addressed this problem, but only for one case. Moreover, its usage of `next_point()` does not actually align with what `bump_with()` expects. For example, given the token `>>=`, we should pass the span consisting of the final two characters `>=`, but `next_point()` advances the span beyond the end of the `=`.

This pull request instead computes the start of the new span by doing `start_point(self.token.span).hi()`. This matches `self.token.span.lo() + BytePos(1)` in the common case where the characters are ascii, and it gracefully handles multibyte characters.

Fixes #68783.
2020-02-06 15:37:47 +01:00
Dylan DPC
16e4e8f2de
Rollup merge of #68844 - euclio:debug-impl-def-path, r=petrochenkov
use def_path_str for missing_debug_impls message

The lint message will now use the full, correct path to the `Debug`
trait, even in `no_std`.
2020-02-06 15:37:46 +01:00
Dylan DPC
226a8e2932
Rollup merge of #68842 - Centril:issue-68785, r=estebank
or_patterns: add regression test for #68785

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

(Fixed by https://github.com/rust-lang/rust/pull/67668.)

cc https://github.com/rust-lang/rust/issues/54883
r? @estebank
2020-02-06 15:37:44 +01:00
Dylan DPC
f6bfdf4620
Rollup merge of #68837 - jonas-schievink:assoc-item-lookup-2, r=estebank
Make associated item collection a query

Before this change, every time associated items were iterated over (which rustc does *a lot* – this can probably be further optimized), there would be N+1 queries to fetch all assoc. items. Now there's just one after they've been computed once.
2020-02-06 15:37:43 +01:00
Dylan DPC
424304a14f
Rollup merge of #68788 - Centril:unified-fn-bodies, r=petrochenkov
Towards unified `fn` grammar

Part of https://github.com/rust-lang/rust/pull/68728.

- Syntactically, `fn` items in `extern { ... }` blocks can now have bodies (`fn foo() { ... }` as opposed to `fn foo();`). As above, we use semantic restrictions instead.

- Syntactically, `fn` items in free contexts (directly in a file or a module) can now be without bodies (`fn foo();` as opposed to `fn foo() { ... }`. As above, we use semantic restrictions instead, including for non-ident parameter patterns.

- We move towards unifying the `fn` front matter; this is fully realized in https://github.com/rust-lang/rust/pull/68728.

r? @petrochenkov
2020-02-06 15:37:41 +01:00
Dylan DPC
bf13861e6c
Rollup merge of #68751 - Tyg13:unused_parens_const_static, r=Centril
Implement `unused_parens` for `const` and `static` items

Fixes #67942
2020-02-06 15:37:39 +01:00
Dylan DPC
a1478b7604
Rollup merge of #68691 - nnethercote:rm-RefCell-from-ObligationForest, r=nikomatsakis
Remove `RefCell` usage from `ObligationForest`.

It's not needed.

This doesn't affect performance, it just simplifies the code a little.

r? @nikomatsakis
2020-02-06 15:37:38 +01:00
Jonas Schievink
9d7b214ac6 Ignore panic-drops-resume.rs on wasm/emscripten
It does not have unwinding support
2020-02-06 15:00:36 +01:00
Jonas Schievink
732913afcb Clarify comment about _2 living across a yield 2020-02-06 12:34:31 +01:00
Jonas Schievink
84dd07a2c4 Simplify implicit resume argument 2020-02-06 12:27:35 +01:00
bors
1f8df2508f Auto merge of #68664 - tspiteri:no_run-complete-build, r=nikomatsakis
rustdoc: attempt full build for compile_fail test

Some code fails when doing a full build but does not fail when only emitting metadata. This commit makes sure compile_fail tests for such code behave as expected, that is, the test succeeds because the compilation fails.

Fixes #67771.
2020-02-06 08:48:01 +00:00
Yuki Okushi
bf269335d0 Forbid using 0 as issue number 2020-02-06 16:19:39 +09:00
bors
333c32a5a4 Auto merge of #68583 - estebank:hrlt, r=oli-obk
Account for HR lifetimes when suggesting introduction of named lifetime

```
error[E0106]: missing lifetime specifier
 --> src/test/ui/suggestions/fn-missing-lifetime-in-item.rs:2:32
  |
2 | struct S2<F: Fn(&i32, &i32) -> &i32>(F);
  |                 ----  ----     ^ expected named lifetime parameter
  |
  = help: this function's return type contains a borrowed value, but the signature does not say whether it is borrowed from argument 1 or argument 2
  = note: for more information on higher-ranked polymorphism, visit https://doc.rust-lang.org/nomicon/hrtb.html
help: consider making the bound lifetime-generic with a new `'a` lifetime
  |
2 | struct S2<F: for<'a> Fn(&'a i32, &'a i32) -> &'a i32>(F);
  |              ^^^^^^^    ^^^^^^^  ^^^^^^^     ^^^
help: consider introducing a named lifetime parameter
  |
2 | struct S2<'a, F: Fn(&'a i32, &'a i32) -> &'a i32>(F);=
  |           ^^^       ^^^^^^^  ^^^^^^^     ^^^
```

Follow up to #68267. Addresses the diagnostics part of #49287.
2020-02-06 05:19:52 +00:00
Tyler Lanphear
d8cf95010f unused-parens: implement for const/static items 2020-02-05 21:01:23 -05:00
bors
ed853b8619 Auto merge of #68861 - Dylan-DPC:rollup-0m09hsg, r=Dylan-DPC
Rollup of 8 pull requests

Successful merges:

 - #68762 (Strip unnecessary subexpression)
 - #68790 (Improve `merge_from_succ`)
 - #68809 (Make more arithmetic functions unstably const)
 - #68832 (Clean up E0264, E0267 and E0268 explanations)
 - #68840 (On suggesting `#![recursion_limit = "X"]`, note current crate name)
 - #68846 (doc fix on doc attribute)
 - #68851 (Fix issue number of `capacity` method)
 - #68858 (Merge item id stable hashing functions)

Failed merges:

r? @ghost
2020-02-06 01:46:46 +00:00
Nicholas Nethercote
6ad725e9f0 Remove RefCell usage from ObligationForest.
It's not needed.
2020-02-06 12:00:50 +11:00
bors
a25d58b41b Auto merge of #68461 - cjgillot:split_infer_prelude, r=matthewjasper
Move datatypes definitions in specific modules inside rustc::{traits, infer}

Prelude to #67953

Some data types inside `rustc::traits` and `rustc::infer` are used in other parts of `librustc`. These cannot go to a separate crate `librustc_infer`.

This PR moves those data types to `traits::types` and `infer::types` modules, from where everything is reexported.

Note for review: some imports feature the `crate -> rustc` substitution. This is cruft from the splitting out of #67953. This can be reverted, but are bound to be put back by #67953.

r? @Centril
cc @Zoxc
2020-02-05 22:41:54 +00:00
Guillaume Gomez
c182461a20 clean E0271 explanation 2020-02-05 23:03:03 +01:00
bors
58b834344f Auto merge of #67429 - mati865:mingw-ultimate-fix, r=alexcrichton
windows-gnu: prefer system crt libraries if they are available

The origin of the issue is the fact Rust ships mingw-w64 libraries but no headers and prefers own libraries over the system ones.
This leads to situation when headers aren't compatible with libraries (mingw-w64 doesn't provide any forward compatibility and AFAIK backwards compatibility is guaranteed only within major release series).

It's easier to understand how this PR works when looking at the linker invocation before and with this PR: https://www.diffchecker.com/GEuYFmzo
It adds system libraries path before Rust libraries so the linker will prefer them.
It has potential issue when system has files with the same names as Rust but that could be avoided by moving Rust shipped mingw-w64 libraries from `lib/rustlib/x86_64-pc-windows-gnu/lib` to say `lib/rustlib/x86_64-pc-windows-gnu/lib/mingw`. Then adding linker paths in this order: Rust libraries, system libraries, Rust shipped mingw-w64 libraries.

Fixes #47048
Fixes #49078
Fixes #53454
Fixes #60912
2020-02-05 19:11:04 +00:00
Esteban Küber
609a37407f Fix test 2020-02-05 10:59:14 -08:00
Esteban Küber
96bbb0d67e Account for impl Trait
Address #49287
2020-02-05 10:32:01 -08:00
Esteban Küber
1beac2b774 Move code to diagnostics.rs 2020-02-05 10:32:01 -08:00
Esteban Küber
49f9bf897b review comments 2020-02-05 10:32:01 -08:00
Esteban Küber
30d927874a review comments: wording 2020-02-05 10:32:01 -08:00
Esteban Küber
92505df338 Account for fn() types in lifetime suggestions 2020-02-05 10:32:01 -08:00
Esteban Küber
ba3b44c508 Account for '_ in suggestions 2020-02-05 10:32:01 -08:00
Esteban Küber
2100b31535 review comments 2020-02-05 10:32:01 -08:00
Esteban Küber
fa4594196d Suggest 'r instead of 'lifetime 2020-02-05 10:32:01 -08:00
Esteban Küber
7e1464336a When suggesting lifetimes, propose adding the new lifetime to all arguments 2020-02-05 10:32:01 -08:00
Esteban Küber
70dbf5526d Use spans for input borrowed types unrelated to return type 2020-02-05 10:32:01 -08:00
Esteban Küber
183dfac1f3 Account for HKTB when suggesting introduction of named lifetime 2020-02-05 10:32:01 -08:00
Dylan DPC
b37f968632
Rollup merge of #68858 - ljedrz:collapse_stable_hash_foos, r=michaelwoerister
Merge item id stable hashing functions

Supersedes https://github.com/rust-lang/rust/pull/67999 splitting out the pure cleanup bits, i.e. merging `hash_item_id`, `hash_impl_item_id` and `hash_trait_item_id` into a common `hash_reference_to_item`.

r? @michaelwoerister
2020-02-05 13:14:37 +01:00
Dylan DPC
cf32b7118d
Rollup merge of #68851 - JohnTitor:fix-issue-number, r=Centril
Fix issue number of `capacity` method

Follow-up of https://github.com/rust-lang/rust/pull/68558#issuecomment-582117131

r? @alexcrichton
2020-02-05 13:14:34 +01:00
Dylan DPC
c0fbac58db
Rollup merge of #68846 - king6cong:doc-fix, r=GuillaumeGomez
doc fix on doc attribute

None
2020-02-05 13:14:33 +01:00
Dylan DPC
3096e1317a
Rollup merge of #68840 - Centril:rec-lim-curr-crate, r=estebank
On suggesting `#![recursion_limit = "X"]`, note current crate name

This would have saved me much confusion e.g. when reading the log output in https://github.com/rust-lang/rust/pull/68788#issuecomment-581852191.

r? @estebank
2020-02-05 13:14:31 +01:00
Dylan DPC
ae0bb2489a
Rollup merge of #68832 - GuillaumeGomez:clean-up-3-err-codes, r=estebank
Clean up E0264, E0267 and E0268 explanations

r? @Dylan-DPC
2020-02-05 13:14:30 +01:00
Dylan DPC
16555ac861
Rollup merge of #68809 - ecstatic-morse:const-int-functions, r=oli-obk
Make more arithmetic functions unstably const

This is a smaller version of #66884 (thanks @9999years) that constifies many of the arithmetic functions on integer primitives from #53718 that were blocked on #49146.

This makes the following things unstably const.

- `feature = const_int_unchecked_arith`
  - `intrinsics::unchecked_add`
  - `intrinsics::unchecked_sub`
  - `intrinsics::unchecked_mul`
  - `intrinsics::unchecked_div`
  - `intrinsics::unchecked_rem`

- `feature = const_checked_int_methods`
  - `checked_add`
  - `checked_sub`
  - `checked_mul`
  - `checked_div` (Uses `intrinsics::unchecked_div` internally)
  - `checked_rem` (Uses `intrinsics::unchecked_rem` internally)
  - `checked_neg`
  - `checked_shl`
  - `checked_shr`
  - `checked_abs`

- `feature = const_saturating_int_methods`
  - `saturating_mul`
  - `saturating_neg`  (Uses `intrinsics::unchecked_sub` internally)
  - `saturating_abs` (Uses `intrinsics::unchecked_sub` internally)

- `feature = const_wrapping_int_methods`
  - `wrapping_div`
  - `wrapping_rem`

- `feature = const_overflowing_int_methods`
  - `overflowing_div`
  - `overflowing_rem`

- `feature = const_euclidean_int_methods`
  - `checked_div_euclid`
  - `checked_rem_euclid`
  - `wrapping_div_euclid`
  - `wrapping_rem_euclid`
  - `overflowing_div_euclid`
  - `overflowing_rem_euclid`

Exponentiation and operations on the `NonZero` types are left to a later PR.

r? @oli-obk
cc @rust-lang/wg-const-eval @rust-lang/libs
2020-02-05 13:14:28 +01:00
Dylan DPC
c1779412fa
Rollup merge of #68790 - nnethercote:improve-merge_from_succ, r=nikomatsakis
Improve `merge_from_succ`

A couple of small performance wins.

r? @nikomatsakis
2020-02-05 13:14:25 +01:00
Dylan DPC
d694f22521
Rollup merge of #68762 - ForNeVeR:patch-1, r=alexcrichton
Strip unnecessary subexpression

It became unnecessary since a06baa56b9 reformatted the file. The comment is currently a bit misleading.
2020-02-05 13:14:22 +01:00