]> git.lizzy.rs Git - rust.git/log
rust.git
4 years agoparser: `prev_span` -> `prev_token.span`
Vadim Petrochenkov [Sat, 29 Feb 2020 11:56:15 +0000 (14:56 +0300)]
parser: `prev_span` -> `prev_token.span`

4 years agoAuto merge of #69227 - Marwes:buffer_stderr, r=varkor
bors [Sat, 29 Feb 2020 07:27:29 +0000 (07:27 +0000)]
Auto merge of #69227 - Marwes:buffer_stderr, r=varkor

perf: Buffer stderr when writing json errors/warnings

Since `stderr` is unbuffered, writing out json messages actually take up
about ~10%/0.1s of the runtime of the `inflate` benchmark as it generates a fair number of warnings.

cc #64413

4 years agoAuto merge of #69255 - estebank:e0599-details, r=varkor
bors [Sat, 29 Feb 2020 03:52:53 +0000 (03:52 +0000)]
Auto merge of #69255 - estebank:e0599-details, r=varkor

Add more context to E0599 errors

Point at the intermediary unfulfilled trait bounds.

Fix #52523, fix #61661, cc #36513, fix #68131, fix #64417, fix #61768, cc #57457, cc #9082, fix #57994, cc #64934, cc #65149.

4 years agoAuto merge of #69208 - RalfJung:debug-assert, r=Mark-Simulacrum
bors [Sat, 29 Feb 2020 00:20:44 +0000 (00:20 +0000)]
Auto merge of #69208 - RalfJung:debug-assert, r=Mark-Simulacrum

debug_assert a few more raw pointer methods

Makes progress for https://github.com/rust-lang/rust/issues/53871

4 years agoIgnore output for some platforms with diverging test output
Esteban Küber [Fri, 28 Feb 2020 20:01:29 +0000 (12:01 -0800)]
Ignore output for some platforms with diverging test output

Get around #53081.

4 years agoDo not suggest implementing traits if present in predicates
Esteban Küber [Tue, 25 Feb 2020 20:10:48 +0000 (12:10 -0800)]
Do not suggest implementing traits if present in predicates

4 years agoReword message
Esteban Küber [Tue, 25 Feb 2020 20:08:22 +0000 (12:08 -0800)]
Reword message

4 years agoReduce verbosity when suggesting restricting type params
Esteban Küber [Tue, 25 Feb 2020 07:25:54 +0000 (23:25 -0800)]
Reduce verbosity when suggesting restricting type params

4 years agokeep predicate order and tweak output
Esteban Küber [Tue, 25 Feb 2020 02:55:51 +0000 (18:55 -0800)]
keep predicate order and tweak output

4 years agoReview comments: split requirement text to multiple lines for readability
Esteban Küber [Fri, 21 Feb 2020 21:39:47 +0000 (13:39 -0800)]
Review comments: split requirement text to multiple lines for readability

4 years agoAccount for arbitrary self types in E0599
Esteban Küber [Wed, 19 Feb 2020 23:57:21 +0000 (15:57 -0800)]
Account for arbitrary self types in E0599

4 years agoSuggest constraining type parameters
Esteban Küber [Wed, 19 Feb 2020 22:26:46 +0000 (14:26 -0800)]
Suggest constraining type parameters

4 years agoTweak wording
Esteban Küber [Wed, 19 Feb 2020 02:36:56 +0000 (18:36 -0800)]
Tweak wording

4 years agoMention the full path of the implementing trait
Esteban Küber [Wed, 19 Feb 2020 02:20:23 +0000 (18:20 -0800)]
Mention the full path of the implementing trait

4 years agoPoint at closure definitions
Esteban Küber [Wed, 19 Feb 2020 02:06:03 +0000 (18:06 -0800)]
Point at closure definitions

4 years agoShow information of chain of bound obligations
Esteban Küber [Wed, 19 Feb 2020 01:53:25 +0000 (17:53 -0800)]
Show information of chain of bound obligations

When the obligation that couldn't be fulfilled is specific to a nested
obligation, maintain both the nested and parent obligations around for
more accurate and detailed error reporting.

4 years agoTrack all predicates in errors, not just trait obligations
Esteban Küber [Wed, 19 Feb 2020 00:35:47 +0000 (16:35 -0800)]
Track all predicates in errors, not just trait obligations

Surface associated type projection bounds that could not be fulfilled in
E0599 errors. Always present the list of unfulfilled trait bounds,
regardless of whether we're pointing at the ADT or trait that didn't
satisfy it.

4 years agoDeduplicate information in E0599
Esteban Küber [Tue, 18 Feb 2020 10:13:30 +0000 (02:13 -0800)]
Deduplicate information in E0599

4 years agoOn single local candidate, use span label
Esteban Küber [Tue, 18 Feb 2020 09:35:18 +0000 (01:35 -0800)]
On single local candidate, use span label

4 years agoReduce vebosity of E0599
Esteban Küber [Tue, 18 Feb 2020 07:59:21 +0000 (23:59 -0800)]
Reduce vebosity of E0599

4 years agoAdd more context to E0599 errors
Esteban Küber [Tue, 18 Feb 2020 07:22:19 +0000 (23:22 -0800)]
Add more context to E0599 errors

Point at the intermediary unfullfilled trait bounds.

4 years agoAuto merge of #69555 - Centril:rollup-e53lxz4, r=Centril
bors [Fri, 28 Feb 2020 17:53:10 +0000 (17:53 +0000)]
Auto merge of #69555 - Centril:rollup-e53lxz4, r=Centril

Rollup of 10 pull requests

Successful merges:

 - #68989 (Update RELEASES.md for 1.42.0)
 - #69340 (instantiate_value_path: on `SelfCtor`, avoid unconstrained tyvars)
 - #69384 (parser: `token` -> `normalized_token`, `nonnormalized_token` -> `token`)
 - #69452 (typeck: use `Pattern` obligation cause more for better diagnostics)
 - #69481 (use char instead of &str for single char patterns)
 - #69522 (error_derive_forbidden_on_non_adt: be more graceful)
 - #69538 (Stabilize `boxed_slice_try_from`)
 - #69539 (late resolve, visit_fn: bail early if there's no body.)
 - #69541 (Remove unneeded calls to format!())
 - #69547 (remove redundant clones, references to operands, explicit boolean comparisons and filter(x).next() calls.)

Failed merges:

r? @ghost

4 years agoRollup merge of #69547 - matthiaskrgr:more_misc, r=Mark-Simulacrum
Mazdak Farrokhzad [Fri, 28 Feb 2020 16:17:38 +0000 (17:17 +0100)]
Rollup merge of #69547 - matthiaskrgr:more_misc, r=Mark-Simulacrum

remove redundant clones, references to operands, explicit boolean comparisons and filter(x).next() calls.

4 years agoRollup merge of #69541 - dotdash:format, r=Mark-Simulacrum
Mazdak Farrokhzad [Fri, 28 Feb 2020 16:17:36 +0000 (17:17 +0100)]
Rollup merge of #69541 - dotdash:format, r=Mark-Simulacrum

Remove unneeded calls to format!()

4 years agoRollup merge of #69539 - Centril:fix-69401, r=petrochenkov
Mazdak Farrokhzad [Fri, 28 Feb 2020 16:17:34 +0000 (17:17 +0100)]
Rollup merge of #69539 - Centril:fix-69401, r=petrochenkov

late resolve, visit_fn: bail early if there's no body.

Fixes https://github.com/rust-lang/rust/issues/69401 which was injected by https://github.com/rust-lang/rust/commit/b2c6eeb713d4cf9b35b7dda6ff2b0274e7f24684 in https://github.com/rust-lang/rust/pull/68788.

r? @petrochenkov

4 years agoRollup merge of #69538 - JohnTitor:boxed-slice-try-from, r=Centril
Mazdak Farrokhzad [Fri, 28 Feb 2020 16:17:33 +0000 (17:17 +0100)]
Rollup merge of #69538 - JohnTitor:boxed-slice-try-from, r=Centril

Stabilize `boxed_slice_try_from`

Closes #69202

4 years agoRollup merge of #69522 - Centril:fix-69341, r=petrochenkov
Mazdak Farrokhzad [Fri, 28 Feb 2020 16:17:31 +0000 (17:17 +0100)]
Rollup merge of #69522 - Centril:fix-69341, r=petrochenkov

error_derive_forbidden_on_non_adt: be more graceful

Fixes #69341 which was injected by #67052.

r? @petrochenkov

4 years agoRollup merge of #69481 - matthiaskrgr:single_char, r=ecstatic-morse
Mazdak Farrokhzad [Fri, 28 Feb 2020 16:17:30 +0000 (17:17 +0100)]
Rollup merge of #69481 - matthiaskrgr:single_char, r=ecstatic-morse

use char instead of &str for single char patterns

4 years agoRollup merge of #69452 - Centril:typeck-pat, r=estebank
Mazdak Farrokhzad [Fri, 28 Feb 2020 16:17:28 +0000 (17:17 +0100)]
Rollup merge of #69452 - Centril:typeck-pat, r=estebank

typeck: use `Pattern` obligation cause more for better diagnostics

r? @estebank

4 years agoRollup merge of #69384 - petrochenkov:nounnorm, r=Centril
Mazdak Farrokhzad [Fri, 28 Feb 2020 16:17:26 +0000 (17:17 +0100)]
Rollup merge of #69384 - petrochenkov:nounnorm, r=Centril

parser: `token` -> `normalized_token`, `nonnormalized_token` -> `token`

So, after https://github.com/rust-lang/rust/pull/69006, its follow-ups and an attempt to remove `Parser::prev_span` I came to the conclusion that the unnormalized token and its span is what you want in most cases, so it should be default.

Normalization only makes difference in few cases where we are checking against `token::Ident` or `token::Lifetime` specifically.
This PR uses `normalized_token` for those cases.

Using normalization explicitly means that people writing code should remember about `NtIdent` and `NtLifetime` in general. (That is alleviated by the fact that `token.ident()` and `fn parse_ident_*` are already written.)
Remembering about `NtIdent`, was, however, already the case, kind of, because the implicit normalization was performed only for the current/previous token, but not for things like `look_ahead`.
As a result, most of token classification methods in `token.rs` already take `NtIdent` into account (this PR fixes a few pre-existing minor mistakes though).

The next step is removing `normalized(_prev)_token` entirely and replacing it with `token.ident()` (mostly) and `token.normalize()` (occasionally).
I want to make it a separate PR for that and run it though perf.
`normalized_token` filled on every bump has both a potential to avoid repeated normalization, and to do unnecessary work in advance (it probably doesn't matter anyway, the normalization is very cheap).

r? @Centril

4 years agoRollup merge of #69340 - Centril:self-ctor-normalize, r=nikomatsakis
Mazdak Farrokhzad [Fri, 28 Feb 2020 16:17:25 +0000 (17:17 +0100)]
Rollup merge of #69340 - Centril:self-ctor-normalize, r=nikomatsakis

instantiate_value_path: on `SelfCtor`, avoid unconstrained tyvars

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

On `Self(...)` (that is, a `Res::SelfCtor`), do not use `self.impl_self_ty(...)`. The problem with that method is that it creates unconstrained inference variables for type parameters in the `impl` (e.g. `impl<T> S0<T>`). These variables then eventually get substituted for something else when they come in contact with the expected type (e.g. `S0<u8>`) or merely the arguments passed to the tuple constructor (e.g. the `0` in `Self(0)`).

Instead of using `self.impl_self_ty(...)`, we instead merely use `let ty = self.normalize_ty(span, tcx.at(span).type_of(impl_def_id));` to get the rewritten `res`.

r? @eddyb

4 years agoRollup merge of #68989 - XAMPPRocky:relnotes-1.42.0, r=Mark-Simulacrum
Mazdak Farrokhzad [Fri, 28 Feb 2020 16:17:23 +0000 (17:17 +0100)]
Rollup merge of #68989 - XAMPPRocky:relnotes-1.42.0, r=Mark-Simulacrum

Update RELEASES.md for 1.42.0

### [Rendered](https://github.com/XAMPPRocky/rust/blob/relnotes-1.42.0/RELEASES.md)

r? @Mark-Simulacrum
cc @rust-lang/release

4 years agoAuto merge of #69148 - estebank:cold-as-ice, r=oli-obk
bors [Fri, 28 Feb 2020 14:24:57 +0000 (14:24 +0000)]
Auto merge of #69148 - estebank:cold-as-ice, r=oli-obk

Account for bounds and asociated items when denying `_`

Fix #68801, #69204. Follow up to #67597 and #68071.

Output for the original ICE report:

```
    Checking vinoteca v5.0.0 (/Users/ekuber/workspace/vinoteca)
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
  --> src/producers.rs:43:70
   |
43 | pub fn top<Table: diesel::Table + diesel::query_dsl::InternalJoinDsl<_, diesel::query_source::joins::Inner, _>>(table: Table, limit: usize, connection: DbConn) -> RestResult<Vec<TopWineType>> {
   |                                                                      ^ not allowed in type signatures       ^ not allowed in type signatures

error: aborting due to previous error
```

4 years agoremove redundant clones, references to operands, explicit boolean comparisons and...
Matthias Krüger [Fri, 28 Feb 2020 12:36:45 +0000 (13:36 +0100)]
remove redundant clones, references to operands, explicit boolean comparisons and filter(x).next() calls.

4 years agoAuto merge of #68827 - ssomers:btree_navigation_revisited, r=Mark-Simulacrum
bors [Fri, 28 Feb 2020 09:32:34 +0000 (09:32 +0000)]
Auto merge of #68827 - ssomers:btree_navigation_revisited, r=Mark-Simulacrum

BTreeMap navigation done safer & faster

It turns out that there was a faster way to do the tree navigation code bundled in #67073, by moving from edge to KV and from KV to next edge separately. It extracts most of the code as safe functions, and contains the duplication of handles within the short wrapper functions.

This somehow hits a sweet spot in the compiler because it reports boosts all over the board:
```
>cargo benchcmp pre3.txt posz4.txt --threshold 5
 name                                           pre3.txt ns/iter  posz4.txt ns/iter  diff ns/iter   diff %  speedup
 btree::map::first_and_last_0                   40                37                           -3   -7.50%   x 1.08
 btree::map::first_and_last_100                 58                44                          -14  -24.14%   x 1.32
 btree::map::iter_1000                          8,920             3,419                    -5,501  -61.67%   x 2.61
 btree::map::iter_100000                        1,069,290         411,615                -657,675  -61.51%   x 2.60
 btree::map::iter_20                            169               58                         -111  -65.68%   x 2.91
 btree::map::iter_mut_1000                      8,701             3,303                    -5,398  -62.04%   x 2.63
 btree::map::iter_mut_100000                    1,034,560         405,975                -628,585  -60.76%   x 2.55
 btree::map::iter_mut_20                        165               58                         -107  -64.85%   x 2.84
 btree::set::clone_100                          1,831             1,562                      -269  -14.69%   x 1.17
 btree::set::clone_100_and_clear                1,831             1,565                      -266  -14.53%   x 1.17
 btree::set::clone_100_and_into_iter            1,917             1,541                      -376  -19.61%   x 1.24
 btree::set::clone_100_and_pop_all              2,609             2,441                      -168   -6.44%   x 1.07
 btree::set::clone_100_and_remove_all           4,598             3,927                      -671  -14.59%   x 1.17
 btree::set::clone_100_and_remove_half          2,765             2,551                      -214   -7.74%   x 1.08
 btree::set::clone_10k                          191,610           164,616                 -26,994  -14.09%   x 1.16
 btree::set::clone_10k_and_clear                192,003           164,616                 -27,387  -14.26%   x 1.17
 btree::set::clone_10k_and_into_iter            200,037           163,010                 -37,027  -18.51%   x 1.23
 btree::set::clone_10k_and_pop_all              267,023           250,913                 -16,110   -6.03%   x 1.06
 btree::set::clone_10k_and_remove_all           536,230           464,100                 -72,130  -13.45%   x 1.16
 btree::set::clone_10k_and_remove_half          453,350           430,545                 -22,805   -5.03%   x 1.05
 btree::set::difference_random_100_vs_100       1,787             801                        -986  -55.18%   x 2.23
 btree::set::difference_random_100_vs_10k       2,978             2,696                      -282   -9.47%   x 1.10
 btree::set::difference_random_10k_vs_100       111,075           54,734                  -56,341  -50.72%   x 2.03
 btree::set::difference_random_10k_vs_10k       246,380           175,980                 -70,400  -28.57%   x 1.40
 btree::set::difference_staggered_100_vs_100    1,789             951                        -838  -46.84%   x 1.88
 btree::set::difference_staggered_100_vs_10k    2,798             2,606                      -192   -6.86%   x 1.07
 btree::set::difference_staggered_10k_vs_10k    176,452           97,401                  -79,051  -44.80%   x 1.81
 btree::set::intersection_100_neg_vs_10k_pos    34                32                           -2   -5.88%   x 1.06
 btree::set::intersection_100_pos_vs_100_neg    30                27                           -3  -10.00%   x 1.11
 btree::set::intersection_random_100_vs_100     1,537             613                        -924  -60.12%   x 2.51
 btree::set::intersection_random_100_vs_10k     2,793             2,649                      -144   -5.16%   x 1.05
 btree::set::intersection_random_10k_vs_10k     222,127           147,166                 -74,961  -33.75%   x 1.51
 btree::set::intersection_staggered_100_vs_100  1,447             622                        -825  -57.01%   x 2.33
 btree::set::intersection_staggered_100_vs_10k  2,606             2,382                      -224   -8.60%   x 1.09
 btree::set::intersection_staggered_10k_vs_10k  143,620           58,790                  -84,830  -59.07%   x 2.44
 btree::set::is_subset_100_vs_100               1,349             488                        -861  -63.83%   x 2.76
 btree::set::is_subset_100_vs_10k               1,720             1,428                      -292  -16.98%   x 1.20
 btree::set::is_subset_10k_vs_10k               135,984           48,527                  -87,457  -64.31%   x 2.80
```
The `first_and_last` ones are noise (they don't do iteration), the others seem genuine.
As always, approved by Miri.

Also, a separate commit with some more benchmarks of mutable behaviour (which also benefit).

r? @cuviper

4 years agolate resolve, visit_fn: bail early if there's no body.
Mazdak Farrokhzad [Fri, 28 Feb 2020 06:58:37 +0000 (07:58 +0100)]
late resolve, visit_fn: bail early if there's no body.

4 years agoAuto merge of #68505 - skinny121:canonicalize-const-eval-inputs, r=nikomatsakis
bors [Fri, 28 Feb 2020 06:14:52 +0000 (06:14 +0000)]
Auto merge of #68505 - skinny121:canonicalize-const-eval-inputs, r=nikomatsakis

Canonicalize inputs to const eval where needed

Canonicalize inputs to const eval, so that they can contain inference variables. Which enables invoking const eval queries even if the current param env has inference variable within it, which can occur during trait selection.

This is a reattempt of #67717, in a far less invasive way.

Fixes #68477

r? @nikomatsakis
cc @eddyb

4 years agoStabilize `boxed_slice_try_from`
Yuki Okushi [Fri, 28 Feb 2020 04:28:09 +0000 (13:28 +0900)]
Stabilize `boxed_slice_try_from`

4 years agoAuto merge of #69534 - Dylan-DPC:rollup-fwa2lip, r=Dylan-DPC
bors [Fri, 28 Feb 2020 02:19:31 +0000 (02:19 +0000)]
Auto merge of #69534 - Dylan-DPC:rollup-fwa2lip, r=Dylan-DPC

Rollup of 9 pull requests

Successful merges:

 - #69379 (Fail on multiple declarations of `main`.)
 - #69430 (librustc_typeck: remove loop that never actually loops)
 - #69449 (Do not ping PR reviewers in toolstate breakage)
 - #69491 (rustc_span: Add `Symbol::to_ident_string` for use in diagnostic messages)
 - #69495 (don't take redundant references to operands)
 - #69496 (use find(x) instead of filter(x).next())
 - #69501 (note that find(f) is equivalent to filter(f).next() in the docs.)
 - #69527 (Ignore untracked paths when running `rustfmt` on repository.)
 - #69529 (don't use .into() to convert types into identical types.)

Failed merges:

r? @ghost

4 years agoRollup merge of #69529 - matthiaskrgr:clippy_identity_conversion, r=Mark-Simulacrum
Dylan DPC [Fri, 28 Feb 2020 00:55:49 +0000 (01:55 +0100)]
Rollup merge of #69529 - matthiaskrgr:clippy_identity_conversion, r=Mark-Simulacrum

don't use .into() to convert types into identical types.

This removes redundant `.into()` calls.

example: `let s: String = format!("hello").into();`

4 years agoRollup merge of #69527 - pnkfelix:issue-69291-dont-run-rustfmt-on-untracked-paths...
Dylan DPC [Fri, 28 Feb 2020 00:55:48 +0000 (01:55 +0100)]
Rollup merge of #69527 - pnkfelix:issue-69291-dont-run-rustfmt-on-untracked-paths, r=Mark-Simulacrum

Ignore untracked paths when running `rustfmt` on repository.

This is a step towards resolving #69291

(It might be the only step necessary at the moment; I'm not yet sure.)

4 years agoRollup merge of #69501 - matthiaskrgr:find_note, r=ecstatic-morse
Dylan DPC [Fri, 28 Feb 2020 00:55:46 +0000 (01:55 +0100)]
Rollup merge of #69501 - matthiaskrgr:find_note, r=ecstatic-morse

note that find(f) is equivalent to filter(f).next() in the docs.

r? @ecstatic-morse

4 years agoRollup merge of #69496 - matthiaskrgr:filter_next, r=ecstatic-morse
Dylan DPC [Fri, 28 Feb 2020 00:55:45 +0000 (01:55 +0100)]
Rollup merge of #69496 - matthiaskrgr:filter_next, r=ecstatic-morse

use find(x) instead of filter(x).next()

4 years agoRollup merge of #69495 - matthiaskrgr:op_ref, r=oli-obk
Dylan DPC [Fri, 28 Feb 2020 00:55:43 +0000 (01:55 +0100)]
Rollup merge of #69495 - matthiaskrgr:op_ref, r=oli-obk

don't take redundant references to operands

4 years agoRollup merge of #69491 - petrochenkov:symprint, r=Mark-Simulacrum
Dylan DPC [Fri, 28 Feb 2020 00:55:42 +0000 (01:55 +0100)]
Rollup merge of #69491 - petrochenkov:symprint, r=Mark-Simulacrum

rustc_span: Add `Symbol::to_ident_string` for use in diagnostic messages

Covers the same error reporting use case (https://github.com/rust-lang/rust/pull/69387#discussion_r382999205) as the `Display` impl for `Ident`.
cc https://github.com/rust-lang/rust/issues/69053

Follow-up to https://github.com/rust-lang/rust/pull/69387.
r? @Mark-Simulacrum

4 years agoRollup merge of #69449 - JohnTitor:toolstate-ping, r=Mark-Simulacrum
Dylan DPC [Fri, 28 Feb 2020 00:55:40 +0000 (01:55 +0100)]
Rollup merge of #69449 - JohnTitor:toolstate-ping, r=Mark-Simulacrum

Do not ping PR reviewers in toolstate breakage

As per https://github.com/rust-lang/rust/issues/69419#issuecomment-590470520

We should also remove author part?

4 years agoRollup merge of #69430 - matthiaskrgr:noloop, r=varkor
Dylan DPC [Fri, 28 Feb 2020 00:55:39 +0000 (01:55 +0100)]
Rollup merge of #69430 - matthiaskrgr:noloop, r=varkor

librustc_typeck: remove loop that never actually loops

4 years agoRollup merge of #69379 - jumbatm:llvm-sigsegv, r=pnkfelix
Dylan DPC [Fri, 28 Feb 2020 00:55:35 +0000 (01:55 +0100)]
Rollup merge of #69379 - jumbatm:llvm-sigsegv, r=pnkfelix

Fail on multiple declarations of `main`.

Closes #67946.

Previously, when inserting the entry function, we only checked for
duplicate _definitions_ of `main`.  However, it's possible to cause
problems even only having a duplicate _declaration_. For example,
shadowing `main` using an extern block isn't caught by the current
check, and causes an assertion failure down the line in in LLVM code.

r? @pnkfelix

4 years agoMake implementation of navigation simpler, safer and faster
Stein Somers [Tue, 4 Feb 2020 14:00:51 +0000 (15:00 +0100)]
Make implementation of navigation simpler, safer and faster

4 years agoAccount for associated items when denying `_`
Esteban Küber [Mon, 17 Feb 2020 20:07:50 +0000 (12:07 -0800)]
Account for associated items when denying `_`

4 years agoAccount for bounds when denying `_` in type parameters
Esteban Küber [Thu, 13 Feb 2020 21:34:00 +0000 (13:34 -0800)]
Account for bounds when denying `_` in type parameters

4 years agoRevert "Backport only: avoid ICE on bad placeholder type"
Esteban Küber [Thu, 27 Feb 2020 23:59:08 +0000 (15:59 -0800)]
Revert "Backport only: avoid ICE on bad placeholder type"

This reverts commit 1cb555a1dc809a8d310354678ef9c43f01e41ad4.

4 years agoFix and test implementation of BTreeMap's first_entry, last_entry, pop_first, pop_last
Stein Somers [Tue, 4 Feb 2020 21:19:05 +0000 (22:19 +0100)]
Fix and test implementation of BTreeMap's first_entry, last_entry, pop_first, pop_last

4 years agoAuto merge of #69513 - tmiasko:revert-checked-unused, r=petrochenkov
bors [Thu, 27 Feb 2020 23:04:51 +0000 (23:04 +0000)]
Auto merge of #69513 - tmiasko:revert-checked-unused, r=petrochenkov

Revert "Mark attributes consumed by `check_mod_attrs` as normal"

This reverts commit d78b22f35ec367368643fe7d6f7e87d01762692b.

Those changes were incompatible with incremental compilation since the
effect `check_mod_attrs` has with respect to marking the attributes as
used is neither persisted nor recomputed.

4 years agodon't use .into() to convert types into identical types.
Matthias Krüger [Tue, 25 Feb 2020 17:10:34 +0000 (18:10 +0100)]
don't use .into() to convert types into identical types.

example:
    let s: String = format!("hello").into();

4 years agoIgnore untracked paths when running `rustfmt` on repository.
Felix S. Klock II [Thu, 27 Feb 2020 20:52:09 +0000 (15:52 -0500)]
Ignore untracked paths when running `rustfmt` on repository.

4 years agoerror_derive_forbidden_on_non_adt: be more graceful
Mazdak Farrokhzad [Thu, 27 Feb 2020 19:09:14 +0000 (20:09 +0100)]
error_derive_forbidden_on_non_adt: be more graceful

4 years agoAuto merge of #68434 - varkor:astconv-mismatch-error, r=nikomatsakis
bors [Thu, 27 Feb 2020 18:38:19 +0000 (18:38 +0000)]
Auto merge of #68434 - varkor:astconv-mismatch-error, r=nikomatsakis

Move generic arg/param validation to `create_substs_for_generic_args` to resolve various const generics issues

This changes some diagnostics, but I think they're around as helpful as the previous ones, and occur infrequently regardless.

Fixes https://github.com/rust-lang/rust/issues/68257.
Fixes https://github.com/rust-lang/rust/issues/68398.

r? @eddyb

4 years agoAuto merge of #68528 - ecstatic-morse:maybe-init-variants, r=oli-obk
bors [Thu, 27 Feb 2020 15:17:47 +0000 (15:17 +0000)]
Auto merge of #68528 - ecstatic-morse:maybe-init-variants, r=oli-obk

Mark other variants as uninitialized after switch on discriminant

During drop elaboration, which builds the drop ladder that handles destruction during stack unwinding, we attempt to remove MIR `Drop` terminators that will never be reached in practice. This reduces the number of basic blocks that are passed to LLVM, which should improve performance. In #66753, a user pointed out that unreachable `Drop` terminators are common in functions like `Option::unwrap`, which move out of an `enum`. While discussing possible remedies for that issue, @eddyb suggested moving const-checking after drop elaboration. This would allow the former, which looks for `Drop` terminators and replicates a small amount of drop elaboration to determine whether a dropped local has been moved out, leverage the work done by the latter.

However, it turns out that drop elaboration is not as precise as it could be when it comes to eliminating useless drop terminators. For example, let's look at the code for `unwrap_or`.

```rust
fn unwrap_or<T>(opt: Option<T>, default: T) -> T {
    match opt {
        Some(inner) => inner,
        None => default,
    }
}
```

`opt` never needs to be dropped, since it is either moved out of (if it is `Some`) or has no drop glue (if it is `None`), and `default` only needs to be dropped if `opt` is `Some`. This is not reflected in the MIR we currently pass to codegen.

![pasted_image](https://user-images.githubusercontent.com/29463364/73384403-109a0d80-4280-11ea-8500-0637b368f2dc.png)

@eddyb also suggested the solution to this problem. When we switch on an enum discriminant, we should be marking all fields in other variants as definitely uninitialized. I implemented this on top of alongside a small optimization (split out into #68943) that suppresses drop terminators for enum variants with no fields (e.g. `Option::None`). This is the resulting MIR for `unwrap_or`.

![after](https://user-images.githubusercontent.com/29463364/73384823-e432c100-4280-11ea-84bd-d0bcc3b777b4.png)

In concert with #68943, this change speeds up many [optimized and debug builds](https://perf.rust-lang.org/compare.html?start=d55f3e9f1da631c636b54a7c22c1caccbe4bf0db&end=0077a7aa11ebc2462851676f9f464d5221b17d6a). We need to carefully investigate whether I have introduced any miscompilations before merging this. Code that never drops anything would be very fast indeed until memory is exhausted.

4 years agoRemove unneeded calls to format!()
Björn Steinbrink [Thu, 27 Feb 2020 12:34:08 +0000 (13:34 +0100)]
Remove unneeded calls to format!()

4 years agodocs: note that find(f) is equivalent to filter(f).next() in the iterator docs.
Matthias Krüger [Wed, 26 Feb 2020 23:35:04 +0000 (00:35 +0100)]
docs: note that find(f) is equivalent to filter(f).next() in the iterator docs.

4 years agolibrustc_typeck: remove loop that never actually loops
Matthias Krüger [Mon, 24 Feb 2020 14:50:40 +0000 (15:50 +0100)]
librustc_typeck: remove loop that never actually loops

4 years agouse char instead of &str for single char patterns
Matthias Krüger [Wed, 26 Feb 2020 12:03:46 +0000 (13:03 +0100)]
use char instead of &str for single char patterns

4 years agouse find(x) instead of filter(x).next()
Matthias Krüger [Wed, 26 Feb 2020 22:03:45 +0000 (23:03 +0100)]
use find(x) instead of filter(x).next()

4 years agoavoid a negation in is_nonoverlapping
Ralf Jung [Thu, 27 Feb 2020 08:45:32 +0000 (09:45 +0100)]
avoid a negation in is_nonoverlapping

4 years agodisable debug assertion in ptr::write for now
Ralf Jung [Thu, 27 Feb 2020 08:43:20 +0000 (09:43 +0100)]
disable debug assertion in ptr::write for now

4 years agoAuto merge of #69507 - JohnTitor:rollup-jqf1gmw, r=JohnTitor
bors [Thu, 27 Feb 2020 08:29:24 +0000 (08:29 +0000)]
Auto merge of #69507 - JohnTitor:rollup-jqf1gmw, r=JohnTitor

Rollup of 7 pull requests

Successful merges:

 - #69324 (Backport only: avoid ICE on bad placeholder type)
 - #69439 (resolve: `lifetimes.rs` -> `late/lifetimes.rs`)
 - #69473 (update llvm to silence gcc 9 warnings)
 - #69479 (clarify operator precedence)
 - #69480 (Clean up E0373 explanation)
 - #69500 (Simplify the signature of par_for_each_in)
 - #69505 (Enable setting diagnostic labels)

Failed merges:

r? @ghost

4 years agoRollup merge of #69505 - Mark-Simulacrum:triagebot-diag-labels, r=Centril
Yuki Okushi [Thu, 27 Feb 2020 05:38:11 +0000 (14:38 +0900)]
Rollup merge of #69505 - Mark-Simulacrum:triagebot-diag-labels, r=Centril

Enable setting diagnostic labels

4 years agoRollup merge of #69500 - cuviper:par_for_each_in-item, r=Mark-Simulacrum
Yuki Okushi [Thu, 27 Feb 2020 05:38:09 +0000 (14:38 +0900)]
Rollup merge of #69500 - cuviper:par_for_each_in-item, r=Mark-Simulacrum

Simplify the signature of par_for_each_in

Given `T: IntoIterator`/`IntoParallelIterator`, `T::Item` is
unambiguous, so we don't need the explicit trait casting.

4 years agoRollup merge of #69480 - GuillaumeGomez:clean-up-e0373, r=Dylan-DPC
Yuki Okushi [Thu, 27 Feb 2020 05:38:08 +0000 (14:38 +0900)]
Rollup merge of #69480 - GuillaumeGomez:clean-up-e0373, r=Dylan-DPC

Clean up E0373 explanation

r? @Dylan-DPC

4 years agoRollup merge of #69479 - matthiaskrgr:op_pred, r=Dylan-DPC
Yuki Okushi [Thu, 27 Feb 2020 05:38:06 +0000 (14:38 +0900)]
Rollup merge of #69479 - matthiaskrgr:op_pred, r=Dylan-DPC

clarify operator precedence

4 years agoRollup merge of #69473 - contrun:update-llvm, r=nikomatsakis
Yuki Okushi [Thu, 27 Feb 2020 05:38:05 +0000 (14:38 +0900)]
Rollup merge of #69473 - contrun:update-llvm, r=nikomatsakis

update llvm to silence gcc 9 warnings

Closes https://github.com/rust-lang/rust/issues/69078

4 years agoRollup merge of #69439 - petrochenkov:latelife, r=matthewjasper
Yuki Okushi [Thu, 27 Feb 2020 05:38:03 +0000 (14:38 +0900)]
Rollup merge of #69439 - petrochenkov:latelife, r=matthewjasper

resolve: `lifetimes.rs` -> `late/lifetimes.rs`

Lifetime resolution should ideally be merged into the late resolution pass, at least for named lifetimes.
Let's move it closer to it for a start.

4 years agoRollup merge of #69324 - estebank:ice-break-backport-bad-placeholder-type, r=Centril
Yuki Okushi [Thu, 27 Feb 2020 05:38:02 +0000 (14:38 +0900)]
Rollup merge of #69324 - estebank:ice-break-backport-bad-placeholder-type, r=Centril

Backport only: avoid ICE on bad placeholder type

 #69148 has a proper fix, but it is too big to backport.
This change avoids the ICE by actually emitting an appropriate error. The
output will be duplicated in some cases, but that's better than the
avoidable ICE.

r? @Centril

4 years agoAuto merge of #67332 - matthewjasper:drop-in-place-cgus, r=michaelwoerister
bors [Thu, 27 Feb 2020 04:51:34 +0000 (04:51 +0000)]
Auto merge of #67332 - matthewjasper:drop-in-place-cgus, r=michaelwoerister

Don't instantiate so many copies of drop_in_place

Split out from #66703.

r? @ghost

4 years agoEnable setting diagnostic labels
Mark Rousskov [Thu, 27 Feb 2020 01:54:13 +0000 (20:54 -0500)]
Enable setting diagnostic labels

4 years agoRevert "Mark attributes consumed by `check_mod_attrs` as normal"
Tomasz Miąsko [Thu, 27 Feb 2020 00:00:00 +0000 (00:00 +0000)]
Revert "Mark attributes consumed by `check_mod_attrs` as normal"

This reverts commit d78b22f35ec367368643fe7d6f7e87d01762692b.

Those changes were incompatible with incremental compilation since the
effect `check_mod_attrs` has with respect to marking the attributes as
used is neither persisted nor recomputed.

4 years agoSimplify the signature of par_for_each_in
Josh Stone [Wed, 26 Feb 2020 23:08:21 +0000 (15:08 -0800)]
Simplify the signature of par_for_each_in

Given `T: IntoIterator`/`IntoParallelIterator`, `T::Item` is
unambiguous, so we don't need the explicit trait casting.

4 years agodon't take redundant references to operands
Matthias Krüger [Wed, 26 Feb 2020 21:42:29 +0000 (22:42 +0100)]
don't take redundant references to operands

4 years agoAuto merge of #67742 - mark-i-m:describe-it, r=matthewjasper
bors [Wed, 26 Feb 2020 20:50:56 +0000 (20:50 +0000)]
Auto merge of #67742 - mark-i-m:describe-it, r=matthewjasper

Generalized article_and_description

r? @matthewjasper

The logic of finding the right word and article to print seems to be repeated elsewhere... this is an experimental method to unify this logic...

4 years agoMerge branch 'master' into relnotes-1.42.0
XAMPPRocky [Wed, 26 Feb 2020 20:39:30 +0000 (21:39 +0100)]
Merge branch 'master' into relnotes-1.42.0

4 years agoUpdate codegen-units tests
Matthew Jasper [Sun, 15 Dec 2019 19:53:07 +0000 (19:53 +0000)]
Update codegen-units tests

4 years agorustc_span: Add `Symbol::to_ident_string` for use in diagnostic messages
Vadim Petrochenkov [Wed, 26 Feb 2020 18:24:22 +0000 (21:24 +0300)]
rustc_span: Add `Symbol::to_ident_string` for use in diagnostic messages

4 years agoinstantiate_value_path: .impl_self_ty -> .type_of
Mazdak Farrokhzad [Fri, 21 Feb 2020 03:53:32 +0000 (04:53 +0100)]
instantiate_value_path: .impl_self_ty -> .type_of

4 years agoAuto merge of #69484 - Dylan-DPC:rollup-j6ripxy, r=Dylan-DPC
bors [Wed, 26 Feb 2020 16:01:21 +0000 (16:01 +0000)]
Auto merge of #69484 - Dylan-DPC:rollup-j6ripxy, r=Dylan-DPC

Rollup of 5 pull requests

Successful merges:

 - #68712 (Add methods to 'leak' RefCell borrows as references with the lifetime of the original reference)
 - #69209 (Miscellaneous cleanup to formatting)
 - #69381 (Allow getting `no_std` from the config file)
 - #69434 (rustc_metadata: Use binary search from standard library)
 - #69447 (Minor refactoring of statement parsing)

Failed merges:

r? @ghost

4 years agoRollup merge of #69447 - Centril:minor-stmt-refactor, r=estebank
Dylan DPC [Wed, 26 Feb 2020 14:34:35 +0000 (15:34 +0100)]
Rollup merge of #69447 - Centril:minor-stmt-refactor, r=estebank

Minor refactoring of statement parsing

Extracted out of https://github.com/rust-lang/rust/pull/69445.

r? @estebank

4 years agoRollup merge of #69434 - petrochenkov:metabs, r=Mark-Simulacrum
Dylan DPC [Wed, 26 Feb 2020 14:34:33 +0000 (15:34 +0100)]
Rollup merge of #69434 - petrochenkov:metabs, r=Mark-Simulacrum

rustc_metadata: Use binary search from standard library

instead of a hand rolled one.

Noticed while reviewing https://github.com/rust-lang/rust/pull/68941.

4 years agoRollup merge of #69381 - QuiltOS:no-std-from-config, r=Mark-Simulacrum
Dylan DPC [Wed, 26 Feb 2020 14:34:32 +0000 (15:34 +0100)]
Rollup merge of #69381 - QuiltOS:no-std-from-config, r=Mark-Simulacrum

Allow getting `no_std` from the config file

Currently, it is only set correctly in the sanity checking implicit
default fallback code. Having a config file at all will for force
`no_std = false`.

4 years agoRollup merge of #69209 - Mark-Simulacrum:strip-unsafe, r=dtolnay
Dylan DPC [Wed, 26 Feb 2020 14:34:30 +0000 (15:34 +0100)]
Rollup merge of #69209 - Mark-Simulacrum:strip-unsafe, r=dtolnay

Miscellaneous cleanup to formatting

Each commit stands alone.

This pull request will also resolve #58320.

4 years agoRollup merge of #68712 - HeroicKatora:finalize-ref-cell, r=dtolnay
Dylan DPC [Wed, 26 Feb 2020 14:34:29 +0000 (15:34 +0100)]
Rollup merge of #68712 - HeroicKatora:finalize-ref-cell, r=dtolnay

Add methods to 'leak' RefCell borrows as references with the lifetime of the original reference

Usually, references to the interior are only created by the `Deref` and
`DerefMut` impl of the guards `Ref` and `RefMut`. Note that `RefCell`
already has to cope with leaks of such guards which, when it occurs,
effectively makes it impossible to ever acquire a mutable guard or any
guard for `Ref` and `RefMut` respectively. It is already safe to use
this to create a reference to the inner of the ref cell that lives as
long as the reference to the `RefCell` itself, e.g.

```rust
fn leak(r: &RefCell<usize>) -> Option<&usize> {
    let guard = r.try_borrow().ok()?;
    let leaked = Box::leak(Box::new(guard));
    Some(&*leaked)
}
```

The newly added methods allow the same reference conversion without an
indirection over a leaked allocation. It's placed on the `Ref`/`RefMut` to
compose with both borrow and try_borrow directly.

4 years agoAuto merge of #67290 - jonas-schievink:leak-audit, r=KodrAus
bors [Wed, 26 Feb 2020 12:48:53 +0000 (12:48 +0000)]
Auto merge of #67290 - jonas-schievink:leak-audit, r=KodrAus

Audit liballoc for leaks in `Drop` impls when user destructor panics

Inspired by https://github.com/rust-lang/rust/pull/67243 and https://github.com/rust-lang/rust/pull/67235, this audits and hopefully fixes the remaining `Drop` impls in liballoc for resource leaks in the presence of panics in destructors called by the affected `Drop` impl.

This does not touch `Hash{Map,Set}` since they live in hashbrown. They have similar issues though.

r? @KodrAus

4 years agoClean up E0373 explanation
Guillaume Gomez [Wed, 26 Feb 2020 11:56:30 +0000 (12:56 +0100)]
Clean up E0373 explanation

4 years agoclarify operator precedence
Matthias Krüger [Wed, 26 Feb 2020 11:43:37 +0000 (12:43 +0100)]
clarify operator precedence

4 years agoAuto merge of #61812 - jonas-schievink:assoc-ty-defaults, r=nikomatsakis
bors [Wed, 26 Feb 2020 09:27:06 +0000 (09:27 +0000)]
Auto merge of #61812 - jonas-schievink:assoc-ty-defaults, r=nikomatsakis

Implement RFC 2532 – Associated Type Defaults

This is a partial implementation that is still missing the changes to object types, since I ran into some trouble while implementing that. I'm opening this part already to get feedback on the implementation and the unexpected test fallout (see my comments below). The remaining changes can be done in a later PR.

Blockers before this can land:
* [x] Resolve unsoundness around interaction with specialization (https://github.com/rust-lang/rust/pull/61812#discussion_r300504010) - #64564

cc https://github.com/rust-lang/rust/issues/29661
Fixes #53907
Fixes #54182
Fixes #62211
Fixes #41868
Fixes #63593
Fixes #47385
Fixes #43924
Fixes #32350
Fixes #26681
Fixes https://github.com/rust-lang/rust/issues/67187

4 years agoupdate llvm to silence gcc 9 warnings
YI [Wed, 26 Feb 2020 00:56:55 +0000 (08:56 +0800)]
update llvm to silence gcc 9 warnings

Closes https://github.com/rust-lang/rust/issues/69078

4 years agoAuto merge of #69474 - Dylan-DPC:rollup-ciotplu, r=Dylan-DPC
bors [Wed, 26 Feb 2020 01:48:27 +0000 (01:48 +0000)]
Auto merge of #69474 - Dylan-DPC:rollup-ciotplu, r=Dylan-DPC

Rollup of 7 pull requests

Successful merges:

 - #67637 (Add primitive module to libcore)
 - #69387 (Deduplicate identifier printing a bit)
 - #69412 (Mark attributes consumed by `check_mod_attrs` as normal)
 - #69423 (syntax: Remove `Nt(Impl,Trait,Foreign)Item`)
 - #69429 (remove redundant clones and import)
 - #69457 (Clean up e0370 e0371)
 - #69468 ([master] Backport release notes of 1.41.1)

Failed merges:

r? @ghost

4 years agoRollup merge of #69468 - pietroalbini:master-1.41.1-notes, r=Mark-Simulacrum
Dylan DPC [Wed, 26 Feb 2020 01:07:18 +0000 (02:07 +0100)]
Rollup merge of #69468 - pietroalbini:master-1.41.1-notes, r=Mark-Simulacrum

[master] Backport release notes of 1.41.1

r? @Mark-Simulacrum

4 years agoRollup merge of #69457 - GuillaumeGomez:clean-up-e0370-e0371, r=Dylan-DPC
Dylan DPC [Wed, 26 Feb 2020 01:07:17 +0000 (02:07 +0100)]
Rollup merge of #69457 - GuillaumeGomez:clean-up-e0370-e0371, r=Dylan-DPC

Clean up e0370 e0371

r? @Dylan-DPC

4 years agoRollup merge of #69429 - matthiaskrgr:clippy_, r=estebank
Dylan DPC [Wed, 26 Feb 2020 01:07:15 +0000 (02:07 +0100)]
Rollup merge of #69429 - matthiaskrgr:clippy_, r=estebank

remove redundant clones and import

4 years agoRollup merge of #69423 - petrochenkov:nont, r=Centril
Dylan DPC [Wed, 26 Feb 2020 01:07:14 +0000 (02:07 +0100)]
Rollup merge of #69423 - petrochenkov:nont, r=Centril

syntax: Remove `Nt(Impl,Trait,Foreign)Item`

Follow-up to https://github.com/rust-lang/rust/pull/69366.
r? @Centril