]> git.lizzy.rs Git - rust.git/log
rust.git
4 years agoRollup merge of #70289 - nnethercote:refactor-codegen, r=eddyb
Mazdak Farrokhzad [Tue, 24 Mar 2020 06:13:42 +0000 (07:13 +0100)]
Rollup merge of #70289 - nnethercote:refactor-codegen, r=eddyb

Refactor `codegen`

`codegen` in `src/librustc_codegen_llvm/back/write.rs` is long and has complex control flow. These commits refactor it and make it easier to understand.

4 years agoRollup merge of #70284 - lcnr:issue70273-what-the-heck-git, r=eddyb
Mazdak Farrokhzad [Tue, 24 Mar 2020 06:13:40 +0000 (07:13 +0100)]
Rollup merge of #70284 - lcnr:issue70273-what-the-heck-git, r=eddyb

correctly handle const params in type_of

extends #70223, retry of #70276

fixes #70273

r? @eddyb cc @varkor

4 years agoRollup merge of #70259 - wesleywiser:use_reveal_all, r=eddyb
Mazdak Farrokhzad [Tue, 24 Mar 2020 06:13:38 +0000 (07:13 +0100)]
Rollup merge of #70259 - wesleywiser:use_reveal_all, r=eddyb

Use Reveal::All in MIR optimizations

Resolves some code review feedback in #67662.

Fixes #68855

r? @eddyb

4 years agoRollup merge of #70213 - eddyb:stalled-on-ty-or-const, r=nikomatsakis
Mazdak Farrokhzad [Tue, 24 Mar 2020 06:13:37 +0000 (07:13 +0100)]
Rollup merge of #70213 - eddyb:stalled-on-ty-or-const, r=nikomatsakis

traits/fulfill: allow `stalled_on` to track `ty::Const::Infer(_)` (unused yet).

This PR addresses the representation side of #70180, but only *actually collects* `ty::Infer`s via `Ty::walk` into `stalled_on` (collecting `ty::ConstKind::Infer`s requires #70164).

However, it should be enough to handle #70107's needs (WF obligations are stalled only on the outermost type/const being an inference variable, no `walk`-ing is involved).

This is my second attempt, see #70181 for the previous one, which unacceptably regressed perf.

r? @nikomatsakis cc @nnethercote

4 years agoRollup merge of #70077 - Aaron1011:feature/new-def-path-ident, r=petrochenkov
Mazdak Farrokhzad [Tue, 24 Mar 2020 06:13:35 +0000 (07:13 +0100)]
Rollup merge of #70077 - Aaron1011:feature/new-def-path-ident, r=petrochenkov

Store idents for `DefPathData` into crate metadata

Previously, we threw away the `Span` associated with a definition's
identifier when we encoded crate metadata, causing us to lose location
and hygiene information.

We now store the identifier's `Span` in a side table, which gets encoded
into the crate metadata. When we decode items from the metadata, we
combine the name and span back into an `Ident`.

This improves the output of several tests, which previously had messages
suppressed due to dummy spans.

This is a prerequisite for #68686, since throwing away a `Span` means
that we lose hygiene information.

4 years agoRollup merge of #70074 - Centril:unpanictry, r=petrochenkov
Mazdak Farrokhzad [Tue, 24 Mar 2020 06:13:33 +0000 (07:13 +0100)]
Rollup merge of #70074 - Centril:unpanictry, r=petrochenkov

Expand: nix all fatal errors

Basically, we go after all `.span_fatal` / `FatalError.raise()` and similar things and remove them one by one until there are no fatal errors left.

r? @petrochenkov

4 years agoRollup merge of #69788 - ArekPiekarz:unstable_book_optin_builtin_traits, r=Dylan-DPC
Mazdak Farrokhzad [Tue, 24 Mar 2020 06:13:31 +0000 (07:13 +0100)]
Rollup merge of #69788 - ArekPiekarz:unstable_book_optin_builtin_traits, r=Dylan-DPC

Fix sequence of Type and Trait in optin-builtin-traits in Unstable Book

A simple fix in docs - the sequence of words in basic example of negative trait implementation was reversed.

4 years agoRollup merge of #68884 - Zoxc:gen-type, r=nikomatsakis
Mazdak Farrokhzad [Tue, 24 Mar 2020 06:13:28 +0000 (07:13 +0100)]
Rollup merge of #68884 - Zoxc:gen-type, r=nikomatsakis

Make the `type_of` return a generic type for generators

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

r? @nikomatsakis

4 years agopacify missing sysroot spans issue
Mazdak Farrokhzad [Mon, 23 Mar 2020 00:31:03 +0000 (01:31 +0100)]
pacify missing sysroot spans issue

4 years agofix rebase fallout due to #69497.
Mazdak Farrokhzad [Sat, 21 Mar 2020 21:12:24 +0000 (22:12 +0100)]
fix rebase fallout due to #69497.

4 years agofix rebase fallout
Mazdak Farrokhzad [Fri, 20 Mar 2020 16:01:53 +0000 (17:01 +0100)]
fix rebase fallout

4 years agoexpand: address review comments
Mazdak Farrokhzad [Wed, 18 Mar 2020 12:34:11 +0000 (13:34 +0100)]
expand: address review comments

4 years agoexpand: add recovery for parse_nt
Mazdak Farrokhzad [Tue, 17 Mar 2020 13:13:32 +0000 (14:13 +0100)]
expand: add recovery for parse_nt

4 years agodefatalize expand_test_or_bench
Mazdak Farrokhzad [Tue, 17 Mar 2020 12:27:56 +0000 (13:27 +0100)]
defatalize expand_test_or_bench

4 years agodefatalize get_test_runner
Mazdak Farrokhzad [Tue, 17 Mar 2020 12:19:06 +0000 (13:19 +0100)]
defatalize get_test_runner

4 years agoexpand: nix unused method
Mazdak Farrokhzad [Tue, 17 Mar 2020 12:06:01 +0000 (13:06 +0100)]
expand: nix unused method

4 years agodefatalize `compile_declarative_macro`
Mazdak Farrokhzad [Tue, 17 Mar 2020 11:54:57 +0000 (12:54 +0100)]
defatalize `compile_declarative_macro`

4 years agombe::transcribe: defatalize errors.
Mazdak Farrokhzad [Tue, 17 Mar 2020 11:12:57 +0000 (12:12 +0100)]
mbe::transcribe: defatalize errors.

4 years agoremove ExtCxt::struct_span_warn
Mazdak Farrokhzad [Tue, 17 Mar 2020 10:35:21 +0000 (11:35 +0100)]
remove ExtCxt::struct_span_warn

4 years agodefatalize ProcMacroDerive::expand
Mazdak Farrokhzad [Tue, 17 Mar 2020 10:30:53 +0000 (11:30 +0100)]
defatalize ProcMacroDerive::expand

Also remove ExtCtxt::struct_span_fatal.

4 years agodefatalize AttrProcMacro::expand
Mazdak Farrokhzad [Tue, 17 Mar 2020 09:56:00 +0000 (10:56 +0100)]
defatalize AttrProcMacro::expand

4 years agodefatalize BangProcMacro::expand
Mazdak Farrokhzad [Tue, 17 Mar 2020 09:09:18 +0000 (10:09 +0100)]
defatalize BangProcMacro::expand

4 years agogeneric_extension: defatalize Error case
Mazdak Farrokhzad [Tue, 17 Mar 2020 08:37:59 +0000 (09:37 +0100)]
generic_extension: defatalize Error case

4 years agonix remaining rustc_expand::panictry! uses.
Mazdak Farrokhzad [Tue, 17 Mar 2020 07:59:56 +0000 (08:59 +0100)]
nix remaining rustc_expand::panictry! uses.

4 years agonix panictry! in ParserAnyMacro::make
Mazdak Farrokhzad [Tue, 17 Mar 2020 07:55:28 +0000 (08:55 +0100)]
nix panictry! in ParserAnyMacro::make

4 years agorustc_expand::base: nix panictry! uses
Mazdak Farrokhzad [Tue, 17 Mar 2020 07:29:34 +0000 (08:29 +0100)]
rustc_expand::base: nix panictry! uses

4 years agoAuto merge of #70343 - Centril:rollup-94egfvs, r=Centril
bors [Tue, 24 Mar 2020 00:53:25 +0000 (00:53 +0000)]
Auto merge of #70343 - Centril:rollup-94egfvs, r=Centril

Rollup of 11 pull requests

Successful merges:

 - #67761 (Move the dep_graph construction to a dedicated crate.)
 - #69740 (Replace some desc logic in librustc_lint with article_and_desc)
 - #69981 (Evaluate repeat expression lengths as late as possible)
 - #70087 (Remove const eval loop detector)
 - #70242 (Improve E0308 error message wording)
 - #70264 (Fix invalid suggestion on `&mut` iterators yielding `&` references)
 - #70267 (get rid of ConstPropUnsupported; use ZST marker structs instead)
 - #70277 (Remove `ReClosureBound`)
 - #70283 (Add regression test for #70155.)
 - #70294 (Account for bad placeholder types in where clauses)
 - #70309 (Clean up E0452 explanation)

Failed merges:

r? @ghost

4 years agoRollup merge of #70309 - GuillaumeGomez:cleanup-e0452, r=Dylan-DPC
Mazdak Farrokhzad [Mon, 23 Mar 2020 23:49:54 +0000 (00:49 +0100)]
Rollup merge of #70309 - GuillaumeGomez:cleanup-e0452, r=Dylan-DPC

Clean up E0452 explanation

r? @Dylan-DPC

4 years agoRollup merge of #70294 - estebank:bad-placeholder-in-where, r=Centril
Mazdak Farrokhzad [Mon, 23 Mar 2020 23:49:52 +0000 (00:49 +0100)]
Rollup merge of #70294 - estebank:bad-placeholder-in-where, r=Centril

Account for bad placeholder types in where clauses

Fix #70291. Follow up to #69148.

4 years agoRollup merge of #70283 - CDirkx:regression-test-70155, r=oli-obk
Mazdak Farrokhzad [Mon, 23 Mar 2020 23:49:50 +0000 (00:49 +0100)]
Rollup merge of #70283 - CDirkx:regression-test-70155, r=oli-obk

Add regression test for #70155.

With #70166 merged, `RangeInclusive` now derives `PartialEq` and `Eq`, implementing structural equality and as a side effect the range is now usable with const generics, closing #70155.

As per [#70166 (comment)](https://github.com/rust-lang/rust/pull/70166#issuecomment-601872201) a test is added to avoid a change to the private fields or the equality implementation of the range from subtly reverting #70155.

4 years agoRollup merge of #70277 - matthewjasper:remove-closurebound, r=nikomatsakis
Mazdak Farrokhzad [Mon, 23 Mar 2020 23:49:48 +0000 (00:49 +0100)]
Rollup merge of #70277 - matthewjasper:remove-closurebound, r=nikomatsakis

Remove `ReClosureBound`

We now substitute external names for regions in the query response.

r? @nikomatsakis

4 years agoRollup merge of #70267 - RalfJung:const-prop-unsup, r=oli-obk,wesleywiser
Mazdak Farrokhzad [Mon, 23 Mar 2020 23:49:46 +0000 (00:49 +0100)]
Rollup merge of #70267 - RalfJung:const-prop-unsup, r=oli-obk,wesleywiser

get rid of ConstPropUnsupported; use ZST marker structs instead

This gets rid of yet another machine-specific error variant.

r? @oli-obk

4 years agoRollup merge of #70264 - tirr-c:issue-69789-mut-suggestion, r=estebank
Mazdak Farrokhzad [Mon, 23 Mar 2020 23:49:45 +0000 (00:49 +0100)]
Rollup merge of #70264 - tirr-c:issue-69789-mut-suggestion, r=estebank

Fix invalid suggestion on `&mut` iterators yielding `&` references

Fixes #69789.

rustc suggested an invalid code when `&` reference from `&mut` iterator is mutated. The compiler knew we're mutating a value behind `&` reference, but as the assignment RHS is from desugaring, it could only see the iterator expression from source and inserted `mut` there.

r? @estebank

4 years agoRollup merge of #70242 - DeeDeeG:improve-e0308, r=Dylan-DPC
Mazdak Farrokhzad [Mon, 23 Mar 2020 23:49:43 +0000 (00:49 +0100)]
Rollup merge of #70242 - DeeDeeG:improve-e0308, r=Dylan-DPC

Improve E0308 error message wording

Hi folks,

I made [a post on Reddit](https://old.reddit.com/r/rust/comments/fmi11x/consider_linting_rusts_documentationerror_text/) about how (IMO) the docs/error messages can be a bit intimidating, one thing led to another, and I was encouraged to submit a Pull Request if I felt I could re-phrase the error message that I used as an example.

So that's this Pull Request. Open to any feedback or style changes, and I understand this is subjective.

(On another note: I am happy to see [this message was recently improved](https://github.com/rust-lang/rust/pull/69139) in `master`, so it's already better than it is in stable Rust 1.42.0.)

Ideally the last sentence could be split into at least two: [sentence explaining the inferred type.] [Sentence explaining explicit type.] [Sentence that summarizes that "this is bad," and why.]

But I'm not sure how to do so; I'm wary of writing something that turns out to be technically incorrect.

4 years agoRollup merge of #70087 - ecstatic-morse:remove-const-eval-loop-detector, r=RalfJung
Mazdak Farrokhzad [Mon, 23 Mar 2020 23:49:41 +0000 (00:49 +0100)]
Rollup merge of #70087 - ecstatic-morse:remove-const-eval-loop-detector, r=RalfJung

Remove const eval loop detector

Now that there is a configurable instruction limit for CTFE (see #67260), we can replace the loop detector with something much simpler. See #66946 for more discussion about this. Although the instruction limit is nightly-only, the only practical way to reach the default limit uses nightly-only features as well (although CTFE will still execute code using such features inside an array initializer on stable).

This will at the very least require a crater run, since it will result in an error wherever the "long running const eval" warning appeared before. We may need to increase the default for `const_eval_limit` to work around this.

Resolves #54384 cc #49980
r? @oli-obk cc @RalfJung

4 years agoRollup merge of #69981 - oli-obk:const_blocks, r=eddyb
Mazdak Farrokhzad [Mon, 23 Mar 2020 23:49:39 +0000 (00:49 +0100)]
Rollup merge of #69981 - oli-obk:const_blocks, r=eddyb

Evaluate repeat expression lengths as late as possible

Fixes #68567

r? @varkor

4 years agoRollup merge of #69740 - mark-i-m:describe-it-3, r=eddyb
Mazdak Farrokhzad [Mon, 23 Mar 2020 23:49:37 +0000 (00:49 +0100)]
Rollup merge of #69740 - mark-i-m:describe-it-3, r=eddyb

Replace some desc logic in librustc_lint with article_and_desc

r? @eddyb @Centril @matthewjasper

Followup to https://github.com/rust-lang/rust/pull/69674

Blocked on #69498

4 years agoRollup merge of #67761 - cjgillot:split_graph, r=Zoxc
Mazdak Farrokhzad [Mon, 23 Mar 2020 23:49:36 +0000 (00:49 +0100)]
Rollup merge of #67761 - cjgillot:split_graph, r=Zoxc

Move the dep_graph construction to a dedicated crate.

The interface for librustc consists in two traits: `DepKind` and `DepContext`.

The `DepKind` is the main interface. It allows to probe properties of the dependency.
As before, `DepNode` is the pair of a `DepKind` object and a hash fingerprint.

The `DepContext` takes the place of the `TyCtxt`, and handles communication with the query engine.

The use of the `ImplicitCtxt` through `ty::tls` is done through the `DepKind` trait.
This may not be the best choice, but it seemed like the simplest.

4 years agoRun rustfmt
Oliver Scherer [Mon, 23 Mar 2020 23:16:05 +0000 (00:16 +0100)]
Run rustfmt

4 years agoMove import.
Camille GILLOT [Mon, 23 Mar 2020 06:28:53 +0000 (07:28 +0100)]
Move import.

4 years agoFully qualify the path to DepKind.
Camille GILLOT [Sun, 22 Mar 2020 23:16:00 +0000 (00:16 +0100)]
Fully qualify the path to DepKind.

This is needed since `middle::cstore` defines another type named
`DepKind`, and we should not rely on shadowing to get the right one.

4 years agoAddress review.
Camille GILLOT [Sun, 22 Mar 2020 19:47:30 +0000 (20:47 +0100)]
Address review.

4 years agoPut extract_def_id back on DepNode.
Camille GILLOT [Sat, 21 Mar 2020 08:28:37 +0000 (09:28 +0100)]
Put extract_def_id back on DepNode.

4 years agoRemove assert_ignored and with_ignore_deps.
Camille GILLOT [Fri, 20 Mar 2020 23:27:09 +0000 (00:27 +0100)]
Remove assert_ignored and with_ignore_deps.

4 years agoMerge ensure_node_can_be_forced into force_from_dep_node.
Camille GILLOT [Fri, 20 Mar 2020 23:21:57 +0000 (00:21 +0100)]
Merge ensure_node_can_be_forced into force_from_dep_node.

4 years agoFallout in other crates.
Camille GILLOT [Wed, 18 Mar 2020 09:32:58 +0000 (10:32 +0100)]
Fallout in other crates.

4 years agoMake librustc_query_system compile.
Camille GILLOT [Wed, 18 Mar 2020 09:25:22 +0000 (10:25 +0100)]
Make librustc_query_system compile.

4 years agoMove dep_graph to new crate librustc_query_system.
Camille GILLOT [Tue, 31 Dec 2019 09:51:58 +0000 (10:51 +0100)]
Move dep_graph to new crate librustc_query_system.

4 years agoAuto merge of #70322 - matthiaskrgr:submodule_upd, r=Dylan-DPC
bors [Mon, 23 Mar 2020 22:02:13 +0000 (22:02 +0000)]
Auto merge of #70322 - matthiaskrgr:submodule_upd, r=Dylan-DPC

submodules: update clippy from d8e6e4cf to 1ff81c1b

Changes:
````
rustup https://github.com/rust-lang/rust/pull/69968/
Fix documentation generation for configurable lints
Fix single binding in closure
Improvement: Don't show function body in needless_lifetimes
````
Fixes #70310
r? @Dylan-DPC

4 years agoSplit out some impls from rustc::mir into a separate submodule
Oliver Scherer [Mon, 23 Mar 2020 21:39:59 +0000 (22:39 +0100)]
Split out some impls from rustc::mir into a separate submodule

4 years agoRemove leftover mentions of `from_anon_const`
Oliver Scherer [Mon, 23 Mar 2020 21:24:31 +0000 (22:24 +0100)]
Remove leftover mentions of `from_anon_const`

4 years agoAccount for bad placeholder types in where clauses
Esteban Küber [Mon, 23 Mar 2020 01:50:30 +0000 (18:50 -0700)]
Account for bad placeholder types in where clauses

4 years agoAuto merge of #70330 - Centril:rollup-ts0clvx, r=Centril
bors [Mon, 23 Mar 2020 18:48:02 +0000 (18:48 +0000)]
Auto merge of #70330 - Centril:rollup-ts0clvx, r=Centril

Rollup of 9 pull requests

Successful merges:

 - #68700 (Add Wake trait for safe construction of Wakers.)
 - #69494 (Stabilize --crate-version option in rustdoc)
 - #70080 (rustc_mir: remove extra space when pretty-printing MIR.)
 - #70195 (Add test for issue #53275)
 - #70199 (Revised span-to-lines conversion to produce an empty vec on DUMMY_SP.)
 - #70299 (add err_machine_stop macro)
 - #70300 (Reword unused variable warning)
 - #70315 (Rename remaining occurences of Void to Opaque.)
 - #70318 (Split long derive lists into two derive attributes.)

Failed merges:

r? @ghost

4 years agoLimit `from_anon_const` to `AnonConst`s.
Oliver Scherer [Mon, 23 Mar 2020 18:35:19 +0000 (19:35 +0100)]
Limit `from_anon_const` to `AnonConst`s.

4 years agoUpdate tests
John Kåre Alsaker [Thu, 6 Feb 2020 09:33:05 +0000 (10:33 +0100)]
Update tests

4 years agoMerge tests.
CDirkx [Mon, 23 Mar 2020 18:27:13 +0000 (19:27 +0100)]
Merge tests.

Merge tests to a single test file.

4 years agoAddress review comments
Oliver Scherer [Mon, 23 Mar 2020 18:19:07 +0000 (19:19 +0100)]
Address review comments

4 years agoAdd const generics test for all range types.
CDirkx [Mon, 23 Mar 2020 18:16:12 +0000 (19:16 +0100)]
Add const generics test for all range types.

In addition to the regression test of `RangeInclusive` for #70155, now all range types are checked for usability within const generics:

- `RangeFrom`
- `RangeFull`
- `RangeToInclusive`
- `RangeTo`
- `Range`

The test are moved from `test\ui\const-generics\issues\issue-70155` to `test\ui\const-generics\std\range` in anticipation of future similar tests for std types.

4 years agoRollup merge of #70318 - anyska:multiple-derives, r=Dylan-DPC
Mazdak Farrokhzad [Mon, 23 Mar 2020 18:04:57 +0000 (19:04 +0100)]
Rollup merge of #70318 - anyska:multiple-derives, r=Dylan-DPC

Split long derive lists into two derive attributes.

4 years agoRollup merge of #70315 - anyska:void-rename, r=Mark-Simulacrum
Mazdak Farrokhzad [Mon, 23 Mar 2020 18:04:55 +0000 (19:04 +0100)]
Rollup merge of #70315 - anyska:void-rename, r=Mark-Simulacrum

Rename remaining occurences of Void to Opaque.

Two mentions of the type were missed when the type was renamed.

4 years agoRollup merge of #70300 - aleksator:66636_reword_unused_variable_warning, r=Dylan-DPC
Mazdak Farrokhzad [Mon, 23 Mar 2020 18:04:54 +0000 (19:04 +0100)]
Rollup merge of #70300 - aleksator:66636_reword_unused_variable_warning, r=Dylan-DPC

Reword unused variable warning

Fixes #66636

4 years agoRollup merge of #70299 - RalfJung:err_machine_stop, r=oli-obk
Mazdak Farrokhzad [Mon, 23 Mar 2020 18:04:52 +0000 (19:04 +0100)]
Rollup merge of #70299 - RalfJung:err_machine_stop, r=oli-obk

add err_machine_stop macro

We have that for all other error kinds, but here I somehow forgot it.

r? @oli-obk

4 years agoRollup merge of #70199 - pnkfelix:issue-68808-dont-turn-dummy-spans-into-invalid...
Mazdak Farrokhzad [Mon, 23 Mar 2020 18:04:51 +0000 (19:04 +0100)]
Rollup merge of #70199 - pnkfelix:issue-68808-dont-turn-dummy-spans-into-invalid-lines, r=estebank

Revised span-to-lines conversion to produce an empty vec on DUMMY_SP.

This required revising some of the client code to stop relying on the returned set of lines being non-empty.

Fix #68808

4 years agoRollup merge of #70195 - rylev:test-for-53275, r=Centril
Mazdak Farrokhzad [Mon, 23 Mar 2020 18:04:49 +0000 (19:04 +0100)]
Rollup merge of #70195 - rylev:test-for-53275, r=Centril

Add test for issue #53275

Fixes #53275

4 years agoRollup merge of #70080 - anyska:mir-double-space, r=oli-obk
Mazdak Farrokhzad [Mon, 23 Mar 2020 18:04:47 +0000 (19:04 +0100)]
Rollup merge of #70080 - anyska:mir-double-space, r=oli-obk

rustc_mir: remove extra space when pretty-printing MIR.

4 years agoRollup merge of #69494 - GuillaumeGomez:stabilize-crate-version, r=ehuss,aleksator...
Mazdak Farrokhzad [Mon, 23 Mar 2020 18:04:45 +0000 (19:04 +0100)]
Rollup merge of #69494 - GuillaumeGomez:stabilize-crate-version, r=ehuss,aleksator,ollie27

Stabilize --crate-version option in rustdoc

I don't see any reason to not stabilize it anymore, so let's go!

cc @kinnison @ehuss

r? @ollie27

4 years agoRollup merge of #68700 - withoutboats:wake-trait, r=withoutboats
Mazdak Farrokhzad [Mon, 23 Mar 2020 18:04:43 +0000 (19:04 +0100)]
Rollup merge of #68700 - withoutboats:wake-trait, r=withoutboats

Add Wake trait for safe construction of Wakers.

Currently, constructing a waker requires calling the unsafe `Waker::from_raw` API. This API requires the user to manually construct a vtable for the waker themself - which is both cumbersome and very error prone. This API would provide an ergonomic, straightforward and guaranteed memory-safe way of constructing a waker.

It has been our longstanding intention that the `Waker` type essentially function as an `Arc<dyn Wake>`, with a `Wake` trait as defined here. Two considerations prevented the original API from being shipped as simply an `Arc<dyn Wake>`:

- We want to support futures on embedded systems, which may not have an allocator, and in optimized executors for which this API may not be best-suited. Therefore, we have always explicitly supported the maximally-flexible (but also memory-unsafe) `RawWaker` API, and `Waker` has always lived in libcore.
- Because `Waker` lives in libcore and `Arc` lives in liballoc, it has not been feasible to provide a constructor for `Waker` from `Arc<dyn Wake>`.

Therefore, the Wake trait was left out of the initial version of the task waker API.

However, as Rust 1.41, it is possible under the more flexible orphan rules to implement `From<Arc<W>> for Waker where W: Wake` in liballoc. Therefore, we can now define this constructor even though `Waker` lives in libcore.

This PR adds these APIs:

- A `Wake` trait, which contains two methods
    - A required method `wake`, which is called by `Waker::wake`
    - A provided method `wake_by_ref`, which is called by `Waker::wake_by_ref` and which implementors can override if they can optimize this use case.
- An implementation of `From<Arc<W>> for Waker where W: Wake + Send + Sync + 'static`
- A similar implementation of `From<Arc<W>> for RawWaker`.

4 years agoUpdate src/librustc_span/source_map.rs
Felix S Klock II [Mon, 23 Mar 2020 17:32:23 +0000 (13:32 -0400)]
Update src/librustc_span/source_map.rs

Co-Authored-By: Mazdak Farrokhzad <twingoow@gmail.com>
4 years agoMake the `type_of` return a generic type for generators
John Kåre Alsaker [Tue, 14 Jan 2020 01:54:55 +0000 (02:54 +0100)]
Make the `type_of` return a generic type for generators

4 years agofix comment
Bastian Kauschke [Mon, 23 Mar 2020 16:08:41 +0000 (17:08 +0100)]
fix comment

4 years agoAuto merge of #70311 - RalfJung:miri, r=RalfJung
bors [Mon, 23 Mar 2020 15:47:42 +0000 (15:47 +0000)]
Auto merge of #70311 - RalfJung:miri, r=RalfJung

update miri

r? @ghost Cc @oli-obk

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

4 years agosubmodules: update clippy from d8e6e4cf to 1ff81c1b
Matthias Krüger [Mon, 23 Mar 2020 15:46:46 +0000 (16:46 +0100)]
submodules: update clippy from d8e6e4cf to 1ff81c1b

Changes:
````
rustup https://github.com/rust-lang/rust/pull/69968/
Fix documentation generation for configurable lints
Fix single binding in closure
Improvement: Don't show function body in needless_lifetimes
````

4 years agoRemove `ReClosureBound`
Matthew Jasper [Wed, 11 Mar 2020 22:24:20 +0000 (22:24 +0000)]
Remove `ReClosureBound`

4 years agoSplit long derive lists into two derive attributes.
Ana-Maria Mihalache [Mon, 23 Mar 2020 14:48:59 +0000 (14:48 +0000)]
Split long derive lists into two derive attributes.

4 years agoApply suggestions from code review
Saoirse Shipwreckt [Mon, 23 Mar 2020 00:36:08 +0000 (01:36 +0100)]
Apply suggestions from code review

Co-Authored-By: Ashley Mannix <ashleymannix@live.com.au>
4 years agoUpdate src/liballoc/task.rs
Saoirse Shipwreckt [Mon, 23 Mar 2020 00:35:15 +0000 (01:35 +0100)]
Update src/liballoc/task.rs

Co-Authored-By: Ashley Mannix <ashleymannix@live.com.au>
4 years agoUpdate src/libstd/lib.rs
Saoirse Shipwreckt [Mon, 23 Mar 2020 00:35:01 +0000 (01:35 +0100)]
Update src/libstd/lib.rs

Co-Authored-By: Ashley Mannix <ashleymannix@live.com.au>
4 years agoMore explicit; CFG on atomic pointer
Without Boats [Sun, 2 Feb 2020 15:51:54 +0000 (16:51 +0100)]
More explicit; CFG on atomic pointer

4 years agotypo
Without Boats [Fri, 31 Jan 2020 16:14:20 +0000 (17:14 +0100)]
typo

4 years agoImprove safety implementation, fix typos
Without Boats [Fri, 31 Jan 2020 16:01:41 +0000 (17:01 +0100)]
Improve safety implementation, fix typos

4 years agoAdd `wake_trait` feature directive to std
Without Boats [Fri, 31 Jan 2020 13:43:41 +0000 (14:43 +0100)]
Add `wake_trait` feature directive to std

4 years agoAdd Wake trait for safe construction of Wakers.
Without Boats [Fri, 31 Jan 2020 13:26:24 +0000 (14:26 +0100)]
Add Wake trait for safe construction of Wakers.

Currently, constructing a waker requires calling the unsafe
`Waker::from_raw` API. This API requires the user to manually construct
a vtable for the waker themself - which is both cumbersome and very
error prone. This API would provide an ergonomic, straightforward and
guaranteed memory-safe way of constructing a waker.

It has been our longstanding intention that the `Waker` type essentially
function as an `Arc<dyn Wake>`, with a `Wake` trait as defined here. Two
considerations prevented the original API from being shipped as simply
an `Arc<dyn Wake>`:

- We want to support futures on embedded systems, which may not have an
  allocator, and in optimized executors for which this API may not be
  best-suited. Therefore, we have always explicitly supported the
  maximally-flexible (but also memory-unsafe) `RawWaker` API, and
  `Waker` has always lived in libcore.
- Because `Waker` lives in libcore and `Arc` lives in liballoc, it has
  not been feasible to provide a constructor for `Waker` from `Arc<dyn
  Wake>`.

Therefore, the Wake trait was left out of the initial version of the
task waker API.

However, as Rust 1.41, it is possible under the more flexible orphan
rules to implement `From<Arc<W>> for Waker where W: Wake` in liballoc.
Therefore, we can now define this constructor even though `Waker` lives
in libcore.

This PR adds these APIs:

- A `Wake` trait, which contains two methods
    - A required method `wake`, which is called by `Waker::wake`
    - A provided method `wake_by_ref`, which is called by
      `Waker::wake_by_ref` and which implementors can override if they
      can optimize this use case.
- An implementation of `From<Arc<W>> for Waker where W: Wake + Send +
  Sync + 'static`
- A similar implementation of `From<Arc<W>> for RawWaker`.

4 years agoRename remaining occurences of Void to Opaque.
Ana-Maria Mihalache [Mon, 23 Mar 2020 13:18:51 +0000 (13:18 +0000)]
Rename remaining occurences of Void to Opaque.

4 years agoupdate miri
Ralf Jung [Mon, 23 Mar 2020 12:42:08 +0000 (13:42 +0100)]
update miri

4 years agoAuto merge of #69649 - estebank:negative-impl-span, r=Centril
bors [Mon, 23 Mar 2020 12:40:36 +0000 (12:40 +0000)]
Auto merge of #69649 - estebank:negative-impl-span, r=Centril

Tweak output for invalid negative impl errors

Follow up to #69722. Tweak negative impl errors emitted in the HIR:

```
error[E0192]: invalid negative impl
  --> $DIR/E0192.rs:9:6
   |
LL | impl !Trait for Foo { }
   |      ^^^^^^
   |
   = note: negative impls are only allowed for auto traits, like `Send` and `Sync`
```

4 years agoUse `DefId`s to identify anon consts when converting from HIR to ty::Const
Oliver Scherer [Tue, 17 Mar 2020 17:54:20 +0000 (18:54 +0100)]
Use `DefId`s to identify anon consts when converting from HIR to ty::Const

4 years agoInline `const_param_def_id` at its only use site
Oliver Scherer [Sat, 14 Mar 2020 19:12:54 +0000 (20:12 +0100)]
Inline `const_param_def_id` at its only use site

4 years agoDocument most methods on `ty::Const`
Oliver Scherer [Sat, 14 Mar 2020 14:53:00 +0000 (15:53 +0100)]
Document most methods on `ty::Const`

4 years agoEvaluate repeat expression lengths as late as possible
Oliver Scherer [Sat, 14 Mar 2020 14:30:35 +0000 (15:30 +0100)]
Evaluate repeat expression lengths as late as possible

4 years agoClean up E0452 explanation
Guillaume Gomez [Mon, 23 Mar 2020 11:40:14 +0000 (12:40 +0100)]
Clean up E0452 explanation

4 years agoMake sure issue 53275 test goes through codegen
Ryan Levick [Mon, 23 Mar 2020 10:11:54 +0000 (11:11 +0100)]
Make sure issue 53275 test goes through codegen

4 years agomake sure we are checking the size of the right thing
Ralf Jung [Mon, 23 Mar 2020 10:03:39 +0000 (11:03 +0100)]
make sure we are checking the size of the right thing

4 years agoadd macro to reduce boilerplate and keep readable messages
Ralf Jung [Mon, 23 Mar 2020 09:58:43 +0000 (10:58 +0100)]
add macro to reduce boilerplate and keep readable messages

4 years agotype_of AnonConst AssocTy does not require parent
Bastian Kauschke [Mon, 23 Mar 2020 09:58:07 +0000 (10:58 +0100)]
type_of AnonConst AssocTy does not require parent

4 years agoAuto merge of #70305 - Centril:rollup-zi13fz4, r=Centril
bors [Mon, 23 Mar 2020 09:30:00 +0000 (09:30 +0000)]
Auto merge of #70305 - Centril:rollup-zi13fz4, r=Centril

Rollup of 8 pull requests

Successful merges:

 - #69080 (rustc_codegen_llvm: don't generate any type debuginfo for -Cdebuginfo=1.)
 - #69940 (librustc_codegen_llvm: Replace deprecated API usage)
 - #69942 (Increase verbosity when suggesting subtle code changes)
 - #69968 (rustc: keep upvars tupled in {Closure,Generator}Substs.)
 - #70123 (Ensure LLVM is in the link path for rustc tools)
 - #70159 (Update the bundled wasi-libc with libstd)
 - #70233 (resolve: Do not resolve visibilities on proc macro definitions twice)
 - #70286 (Miri error type: remove UbExperimental variant)

Failed merges:

r? @ghost

4 years agoRollup merge of #70286 - RalfJung:no-experiments, r=petrochenkov
Mazdak Farrokhzad [Mon, 23 Mar 2020 09:29:18 +0000 (10:29 +0100)]
Rollup merge of #70286 - RalfJung:no-experiments, r=petrochenkov

Miri error type: remove UbExperimental variant

In https://github.com/rust-lang/miri/pull/1250, I will move Miri away from that variant, and use a custom `MachineStop` exception instead.

4 years agoRollup merge of #70233 - petrochenkov:superproc, r=ecstatic-morse
Mazdak Farrokhzad [Mon, 23 Mar 2020 09:29:16 +0000 (10:29 +0100)]
Rollup merge of #70233 - petrochenkov:superproc, r=ecstatic-morse

resolve: Do not resolve visibilities on proc macro definitions twice

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

4 years agoRollup merge of #70159 - alexcrichton:update-wasi, r=pietroalbini
Mazdak Farrokhzad [Mon, 23 Mar 2020 09:29:14 +0000 (10:29 +0100)]
Rollup merge of #70159 - alexcrichton:update-wasi, r=pietroalbini

Update the bundled wasi-libc with libstd

Brings in WebAssembly/wasi-libc#184 which can help standalone programs
with environment variables!

4 years agoRollup merge of #70123 - cuviper:library-path, r=Mark-Simulacrum
Mazdak Farrokhzad [Mon, 23 Mar 2020 09:29:13 +0000 (10:29 +0100)]
Rollup merge of #70123 - cuviper:library-path, r=Mark-Simulacrum

Ensure LLVM is in the link path for rustc tools

The build script for `rustc_llvm` outputs LLVM information in `cargo:rustc-link-lib` and `cargo:rustc-link-search` so the compiler can be linked correctly. However, while the lib is carried along in metadata, the search paths are not. So when cargo is invoked again later for rustc _tools_, they'll also try to link with LLVM, but the necessary paths may be left out.

Rustbuild can use the environment to set the LLVM link path for tools -- `LIB` for MSVC toolchains and `LIBRARY_PATH` for everyone else.

Fixes #68714.

4 years agoRollup merge of #69968 - eddyb:tupled-closure-captures, r=nikomatsakis
Mazdak Farrokhzad [Mon, 23 Mar 2020 09:29:11 +0000 (10:29 +0100)]
Rollup merge of #69968 - eddyb:tupled-closure-captures, r=nikomatsakis

rustc: keep upvars tupled in {Closure,Generator}Substs.

Previously, each closure/generator capture's (aka "upvar") type was tracked as one "synthetic" type parameter in the closure/generator substs, and figuring out where the parent `fn`'s generics end and the synthetics start involved slicing at `tcx.generics_of(def_id).parent_count`.

Needing to query `generics_of` limited @davidtwco (who wants to compute some `TypeFlags` differently for parent generics vs upvars, and `TyCtxt` is not available there), which is how I got started on this, but it's also possible that the `generics_of` queries are slowing down `{Closure,Generator}Substs` methods.

To give an example, for a `foo::<T, U>::{closure#0}` with captures `x: X` and `y: Y`, substs are:
* before this PR: `[T, U, /*kind*/, /*signature*/, X, Y]`
* after this PR: `[T, U, /*kind*/, /*signature*/, (X, Y)]`

You can see that, with this PR, no matter how many captures, the last 3 entries in the substs (or 5 for a generator) are always the "synthetic" ones, with the last one being the tuple of capture types.

r? @nikomatsakis cc @Zoxc