]> git.lizzy.rs Git - rust.git/log
rust.git
6 years agoMake `-Z borrowck-mir` imply that `EndRegion`'s should be emitted.
Felix S. Klock II [Wed, 20 Sep 2017 13:25:44 +0000 (15:25 +0200)]
Make `-Z borrowck-mir` imply that `EndRegion`'s should be emitted.

6 years agoAuto merge of #44355 - Xaeroxe:optimize_drain_filter, r=alexcrichton
bors [Wed, 20 Sep 2017 06:29:42 +0000 (06:29 +0000)]
Auto merge of #44355 - Xaeroxe:optimize_drain_filter, r=alexcrichton

Optimize drain_filter

This PR cuts out two copies from each iteration of `drain_filter` by exchanging the swap operation for a copy_nonoverlapping function call instead.  Since the data being swapped is not needed anymore we can just overwrite it instead.

6 years agoAuto merge of #44350 - GuillaumeGomez:id-false-positive, r=QuietMisdreavus
bors [Wed, 20 Sep 2017 02:46:25 +0000 (02:46 +0000)]
Auto merge of #44350 - GuillaumeGomez:id-false-positive, r=QuietMisdreavus

Improve how rustdoc warnings are displayed

cc @rust-lang/dev-tools
r? @nrc

6 years agoAuto merge of #44505 - nikomatsakis:lotsa-comments, r=steveklabnik
bors [Tue, 19 Sep 2017 22:43:58 +0000 (22:43 +0000)]
Auto merge of #44505 - nikomatsakis:lotsa-comments, r=steveklabnik

rework the README.md for rustc and add other readmes

OK, so, long ago I committed to the idea of trying to write some high-level documentation for rustc. This has proved to be much harder for me to get done than I thought it would! This PR is far from as complete as I had hoped, but I wanted to open it so that people can give me feedback on the conventions that it establishes. If this seems like a good way forward, we can land it and I will open an issue with a good check-list of things to write (and try to take down some of them myself).

Here are the conventions I established on which I would like feedback.

**Use README.md files**. First off, I'm aiming to keep most of the high-level docs in `README.md` files, rather than entries on forge. My thought is that such files are (a) more discoverable than forge and (b) closer to the code, and hence can be edited in a single PR. However, since they are not *in the code*, they will naturally get out of date, so the intention is to focus on the highest-level details, which are least likely to bitrot. I've included a few examples of common functions and so forth, but never tried to (e.g.) exhaustively list the names of functions and so forth.
    - I would like to use the tidy scripts to try and check that these do not go out of date. Future work.

**librustc/README.md as the main entrypoint.** This seems like the most natural place people will look first. It lays out how the crates are structured and **is intended** to give pointers to the main data structures of the compiler (I didn't update that yet; the existing material is terribly dated).

**A glossary listing abbreviations and things.** It's much harder to read code if you don't know what some obscure set of letters like `infcx` stands for.

**Major modules each have their own README.md that documents the high-level idea.** For example, I wrote some stuff about `hir` and `ty`. Both of them have many missing topics, but I think that is roughly the level of depth that would be good. The idea is to give people a "feeling" for what the code does.

What is missing primarily here is lots of content. =) Here are some things I'd like to see:

- A description of what a QUERY is and how to define one
    - Some comments for `librustc/ty/maps.rs`
- An overview of how compilation proceeds now (i.e., the hybrid demand-driven and forward model) and how we would like to see it going in the future (all demand-driven)
- Some coverage of how incremental will work under red-green
- An updated list of the major IRs in use of the compiler (AST, HIR, TypeckTables, MIR) and major bits of interesting code (typeck, borrowck, etc)
- More advice on how to use `x.py`, or at least pointers to that
- Good choice for `config.toml`
- How to use `RUST_LOG` and other debugging flags (e.g., `-Zverbose`, `-Ztreat-err-as-bug`)
- Helpful conventions for `debug!` statement formatting

cc @rust-lang/compiler @mgattozzi

6 years agoImprove how warnings are displayed
Guillaume Gomez [Wed, 6 Sep 2017 09:53:50 +0000 (11:53 +0200)]
Improve how warnings are displayed

6 years agoincorporate suggestions from arielb1
Niko Matsakis [Tue, 19 Sep 2017 16:36:32 +0000 (12:36 -0400)]
incorporate suggestions from arielb1

6 years agostart writing some typeck docs (incomplete)
Niko Matsakis [Tue, 19 Sep 2017 12:43:15 +0000 (08:43 -0400)]
start writing some typeck docs (incomplete)

6 years agodefine span
Niko Matsakis [Mon, 18 Sep 2017 15:35:47 +0000 (11:35 -0400)]
define span

6 years agorevamp the Compiler Process section to be more up to date
Niko Matsakis [Mon, 18 Sep 2017 14:55:15 +0000 (10:55 -0400)]
revamp the Compiler Process section to be more up to date

6 years agosplit maps into submodules, document
Niko Matsakis [Mon, 18 Sep 2017 09:40:13 +0000 (05:40 -0400)]
split maps into submodules, document

6 years agoAuto merge of #44620 - zackmdavis:rfc_1940_housekeeping, r=nikomatsakis
bors [Tue, 19 Sep 2017 13:06:31 +0000 (13:06 +0000)]
Auto merge of #44620 - zackmdavis:rfc_1940_housekeeping, r=nikomatsakis

RFC 1940 housekeeping

* move test to own directory, as requested in https://github.com/rust-lang/rust/issues/43302#issuecomment-329579185
* exercise trait methods in test
* unstable book section

r? @nikomatsakis

6 years agopromote maps into its own directory
Niko Matsakis [Mon, 18 Sep 2017 09:49:15 +0000 (05:49 -0400)]
promote maps into its own directory

6 years agoapply various nits
Niko Matsakis [Fri, 15 Sep 2017 20:19:44 +0000 (16:19 -0400)]
apply various nits

6 years agorework the README.md for rustc and add other readmes
Niko Matsakis [Thu, 31 Aug 2017 18:33:19 +0000 (14:33 -0400)]
rework the README.md for rustc and add other readmes

This takes way longer than I thought it would. =)

6 years agoAuto merge of #44601 - alexcrichton:lower-attributes-in-hir, r=nrc
bors [Tue, 19 Sep 2017 08:19:45 +0000 (08:19 +0000)]
Auto merge of #44601 - alexcrichton:lower-attributes-in-hir, r=nrc

rustc: Forbid interpolated tokens in the HIR

Right now the HIR contains raw `syntax::ast::Attribute` structure but nowadays
these can contain arbitrary tokens. One variant of the `Token` enum is an
"interpolated" token which basically means to shove all the tokens for a
nonterminal in this position. A "nonterminal" in this case is roughly analagous
to a macro argument:

    macro_rules! foo {
        ($a:expr) => {
            // $a is a nonterminal as an expression
        }
    }

Currently nonterminals contain namely items and expressions, and this poses a
problem for incremental compilation! With incremental we want a stable hash of
all HIR items, but this means we may transitively need a stable hash *of the
entire AST*, which is certainly not stable w/ node ids and whatnot. Hence today
there's a "bug" where the "stable hash" of an AST is just the raw hash value of
the AST, and this only arises with interpolated nonterminals. The downside of
this approach, however, is that a bunch of errors get spewed out during
compilation about how this isn't a great idea.

This PR is focused at fixing these warnings, basically deleting them from the
compiler. The implementation here is to alter attributes as they're lowered from
the AST to HIR, expanding all nonterminals in-place as we see them. This code
for expanding a nonterminal to a token stream already exists for the
`proc_macro` crate, so we basically just reuse the same implementation there.

After this PR it's considered a bug to have an `Interpolated` token and hence
the stable hash implementation simply uses `bug!` in this location.

Closes #40946

6 years agoAuto merge of #44026 - QuietMisdreavus:trimmed-std, r=steveklabnik
bors [Tue, 19 Sep 2017 04:20:56 +0000 (04:20 +0000)]
Auto merge of #44026 - QuietMisdreavus:trimmed-std, r=steveklabnik

hide internal types/traits from std docs via new #[doc(masked)] attribute

Fixes #43701 (hopefully for good this time)

This PR introduces a new parameter to the `#[doc]` attribute that rustdoc looks for on `extern crate` statements. When it sees `#[doc(masked)]` on such a statement, it hides traits and types from that crate from appearing in either the "Trait Implementations" section of many type pages, or the "Implementors" section of trait pages. This is then applied to the `libc`/`rand`/`compiler_builtins` imports in libstd to prevent those crates from creating broken links in the std docs.

Like in #43348, this also introduces a feature gate, `doc_masked`, that controls the use of this parameter.

To view the std docs generated with this change, head to https://tonberry.quietmisdreavus.net/std-43701/std/index.html.

6 years agorustc: Forbid interpolated tokens in the HIR
Alex Crichton [Fri, 15 Sep 2017 15:28:34 +0000 (08:28 -0700)]
rustc: Forbid interpolated tokens in the HIR

Right now the HIR contains raw `syntax::ast::Attribute` structure but nowadays
these can contain arbitrary tokens. One variant of the `Token` enum is an
"interpolated" token which basically means to shove all the tokens for a
nonterminal in this position. A "nonterminal" in this case is roughly analagous
to a macro argument:

    macro_rules! foo {
        ($a:expr) => {
            // $a is a nonterminal as an expression
        }
    }

Currently nonterminals contain namely items and expressions, and this poses a
problem for incremental compilation! With incremental we want a stable hash of
all HIR items, but this means we may transitively need a stable hash *of the
entire AST*, which is certainly not stable w/ node ids and whatnot. Hence today
there's a "bug" where the "stable hash" of an AST is just the raw hash value of
the AST, and this only arises with interpolated nonterminals. The downside of
this approach, however, is that a bunch of errors get spewed out during
compilation about how this isn't a great idea.

This PR is focused at fixing these warnings, basically deleting them from the
compiler. The implementation here is to alter attributes as they're lowered from
the AST to HIR, expanding all nonterminals in-place as we see them. This code
for expanding a nonterminal to a token stream already exists for the
`proc_macro` crate, so we basically just reuse the same implementation there.

After this PR it's considered a bug to have an `Interpolated` token and hence
the stable hash implementation simply uses `bug!` in this location.

Closes #40946

6 years agoAuto merge of #44680 - infinity0:master, r=Mark-Simulacrum
bors [Mon, 18 Sep 2017 23:46:15 +0000 (23:46 +0000)]
Auto merge of #44680 - infinity0:master, r=Mark-Simulacrum

rustbuild: with --no-fail-fast, report the specific commands that failed

I'm not sure this is the most elegant way of doing it, I'm still a bit of a rust noob. I tried `Vec<Command>` and keeping `Cell` instead of `RefCell` but couldn't fight my way past the borrow errors, this was the first arrangement that I could make work.

6 years agorustbuild: with --no-fail-fast, report the specific commands that failed
Ximin Luo [Mon, 18 Sep 2017 19:21:24 +0000 (21:21 +0200)]
rustbuild: with --no-fail-fast, report the specific commands that failed

6 years agoAuto merge of #44678 - alexcrichton:rollup, r=alexcrichton
bors [Mon, 18 Sep 2017 17:30:29 +0000 (17:30 +0000)]
Auto merge of #44678 - alexcrichton:rollup, r=alexcrichton

Rollup of 11 pull requests

- Successful merges: #44364, #44466, #44537, #44548, #44640, #44651, #44657, #44661, #44668, #44671, #44675
- Failed merges:

6 years agoAdd requested comment
Jacob Kiesel [Mon, 18 Sep 2017 16:15:17 +0000 (10:15 -0600)]
Add requested comment

6 years agoRollup merge of #44671 - GuillaumeGomez:run-button, r=steveklabnik
Alex Crichton [Mon, 18 Sep 2017 16:04:28 +0000 (11:04 -0500)]
Rollup merge of #44671 - GuillaumeGomez:run-button, r=steveklabnik

Fix run button

r? @QuietMisdreavus

Before:

![before](https://user-images.githubusercontent.com/3050060/30538927-612c6a44-9c70-11e7-9ca2-f3860d880b95.png)

After:

![after](https://user-images.githubusercontent.com/3050060/30538929-6416ea0e-9c70-11e7-990a-7e4fbf5d7319.png)

Quite urgent.

6 years agoRollup merge of #44668 - iwillspeak:into-iterator-docs, r=steveklabnik
Alex Crichton [Mon, 18 Sep 2017 16:04:27 +0000 (11:04 -0500)]
Rollup merge of #44668 - iwillspeak:into-iterator-docs, r=steveklabnik

Add Example of `IntoIterator` as Trait Bound to Docs

Part of #44600.

6 years agoRollup merge of #44661 - GuillaumeGomez:more-links, r=QuietMisdreavus
Alex Crichton [Mon, 18 Sep 2017 16:04:26 +0000 (11:04 -0500)]
Rollup merge of #44661 - GuillaumeGomez:more-links, r=QuietMisdreavus

Add more links and put the link character to the left

r? @QuietMisdreavus

And of course, a few screenshots:

<img width="1440" alt="screen shot 2017-09-17 at 22 08 46" src="https://user-images.githubusercontent.com/3050060/30524496-44a50208-9bf5-11e7-942e-a3707ba125c3.png">
<img width="1440" alt="screen shot 2017-09-17 at 22 09 47" src="https://user-images.githubusercontent.com/3050060/30524502-49068dbc-9bf5-11e7-8e59-ec38664e0e0f.png">
<img width="1440" alt="screen shot 2017-09-17 at 22 10 56" src="https://user-images.githubusercontent.com/3050060/30524503-491c8c34-9bf5-11e7-9ce5-f1bd5ef8600b.png">

6 years agoRollup merge of #44657 - Ixrec:patch-1, r=eddyb
Alex Crichton [Mon, 18 Sep 2017 16:04:25 +0000 (11:04 -0500)]
Rollup merge of #44657 - Ixrec:patch-1, r=eddyb

Replace str's transmute() calls with pointer casts

After the following conversation in #rust-lang:
```
[14:43:50] <Ixrec> TIL the implementation of from_utf_unchecked is literally just "mem::transmute(x)"
[14:43:59] <Ixrec> no wonder people keep saying transmute is overpowered
[15:15:30] <eddyb> Ixrec: it should be a pointer cast lol
[15:15:46] <eddyb> unless it doesn't let you
[16:50:34] <Ixrec> https://play.rust-lang.org/?gist=d1e6b629ad9ec1baf64ce261c63845e6&version=stable seems like it does let me
[16:52:35] <eddyb> Ixrec: yeah that's the preferred impl
[16:52:46] <eddyb> Ixrec: it just wasn't in 1.0
[16:52:50] <eddyb> IIRC
[16:53:00] <eddyb> (something something fat pointers)
```
Since I already wrote half of the preferred impls in the playground, might as well make an actual PR.

6 years agoRollup merge of #44651 - bluss:document-thread-name-no-nuls, r=steveklabnik
Alex Crichton [Mon, 18 Sep 2017 16:04:24 +0000 (11:04 -0500)]
Rollup merge of #44651 - bluss:document-thread-name-no-nuls, r=steveklabnik

Document thread builder panics for nul bytes in thread names

This seems to have been undocumented. Mention this where the name is set
(Builder::name) and where the panic could happen (Builder::spawn).

Thread::new is private and I think the builder is the only user where
this matters. A short comment was added to "document" Thread::new too.

6 years agoRollup merge of #44640 - budziq:stabilize_splice, r=dtolnay
Alex Crichton [Mon, 18 Sep 2017 16:04:23 +0000 (11:04 -0500)]
Rollup merge of #44640 - budziq:stabilize_splice, r=dtolnay

Stabilized vec_splice and modified splice tracking issue

This stabilizes the vec_splice (Vec part of splice RFC)
Fixes #32310.

6 years agoRollup merge of #44548 - oyvindln:rustc_help_fix, r=arielb1
Alex Crichton [Mon, 18 Sep 2017 16:04:22 +0000 (11:04 -0500)]
Rollup merge of #44548 - oyvindln:rustc_help_fix, r=arielb1

Add proper help line for `-C inline threshold`

Looks like someone accidentally some words when adding this.

This also remove a period on a different help line for consistency, as no options have a period.

6 years agoRollup merge of #44537 - oli-obk:memchr, r=alexcrichton
Alex Crichton [Mon, 18 Sep 2017 16:04:21 +0000 (11:04 -0500)]
Rollup merge of #44537 - oli-obk:memchr, r=alexcrichton

More `align_offset` things

cc #44488

6 years agoRollup merge of #44466 - clarcharr:cow_error, r=alexcrichton
Alex Crichton [Mon, 18 Sep 2017 16:04:20 +0000 (11:04 -0500)]
Rollup merge of #44466 - clarcharr:cow_error, r=alexcrichton

Add Cow<str> -> Box<Error> impls.

Considering how impls exist for `String` and `&str`, it makes sense to also add an impl for `Cow<str>` as well.

This would allow converting `String::from_utf8_lossy` directly into a `Box<Error>` or `io::Error` without having to add an extra `into_ownd()`.

6 years agoRollup merge of #44364 - michaelwoerister:hash-all-the-things2, r=nikomatsakis
Alex Crichton [Mon, 18 Sep 2017 16:04:19 +0000 (11:04 -0500)]
Rollup merge of #44364 - michaelwoerister:hash-all-the-things2, r=nikomatsakis

incr.comp.: Compute fingerprint for all query results.

This PR enables query result fingerprinting in incremental mode. This is an essential piece of infrastructure for red/green tracking. We don't do anything with the fingerprints yet but merging the infrastructure should protect it from bit-rotting and will make it easier to start measuring its performance impact (and thus let us determine if we should switch to a faster hashing algorithm rather sooner than later).

Note, this PR also includes the changes from https://github.com/rust-lang/rust/pull/43887 which I'm therefore closing. No need to re-review the first commit though.

r? @nikomatsakis

6 years agoFix run button
Guillaume Gomez [Mon, 18 Sep 2017 10:51:48 +0000 (12:51 +0200)]
Fix run button

6 years agoincr.comp.: Fix ICE caused by trying to hash INVALID_CRATE_NUM.
Michael Woerister [Mon, 18 Sep 2017 11:14:38 +0000 (13:14 +0200)]
incr.comp.: Fix ICE caused by trying to hash INVALID_CRATE_NUM.

6 years agoincr.comp.: Fix rebase fallout.
Michael Woerister [Mon, 18 Sep 2017 10:14:52 +0000 (12:14 +0200)]
incr.comp.: Fix rebase fallout.

6 years agoincr.comp.: Remove tcx from StableHashingContext.
Michael Woerister [Thu, 14 Sep 2017 13:10:24 +0000 (15:10 +0200)]
incr.comp.: Remove tcx from StableHashingContext.

6 years agoincr.comp.: Make the StableHashingContext mostly independent of the tcx.
Michael Woerister [Thu, 14 Sep 2017 12:01:40 +0000 (14:01 +0200)]
incr.comp.: Make the StableHashingContext mostly independent of the tcx.

6 years agoincr.comp.: Initialize IGNORED_ATTRS in StableHashingContext lazily.
Michael Woerister [Thu, 14 Sep 2017 10:29:16 +0000 (12:29 +0200)]
incr.comp.: Initialize IGNORED_ATTRS in StableHashingContext lazily.

6 years agoincr.comp.: Initialize the CachingCodemapView in StableHashingContext lazily.
Michael Woerister [Thu, 14 Sep 2017 10:08:03 +0000 (12:08 +0200)]
incr.comp.: Initialize the CachingCodemapView in StableHashingContext lazily.

6 years agoincr.comp.: Use StableHash impls instead of functions for hashing most maps.
Michael Woerister [Wed, 13 Sep 2017 16:20:27 +0000 (18:20 +0200)]
incr.comp.: Use StableHash impls instead of functions for hashing most maps.

6 years agoincr.comp.: Already hash HIR bodies during metadata export so they don't have to...
Michael Woerister [Wed, 13 Sep 2017 12:59:10 +0000 (14:59 +0200)]
incr.comp.: Already hash HIR bodies during metadata export so they don't have to be hashed in downstream crates.

6 years agoFix issues uncovered by rebasing:
Michael Woerister [Tue, 12 Sep 2017 15:07:09 +0000 (17:07 +0200)]
Fix issues uncovered by rebasing:

- Don't hash traits in scope as part of HIR hashing any more.
- Some queries returned DefIndexes from other crates.
- Provide a generic way of stably hashing maps (not used everywhere yet).

6 years agoincr.comp.: Move result fingerprinting to DepGraph::with_task().
Michael Woerister [Thu, 7 Sep 2017 14:11:58 +0000 (16:11 +0200)]
incr.comp.: Move result fingerprinting to DepGraph::with_task().

This makes sure that we don't introduce strange cases where we have
nodes outside the query system that could break red/green tracking
and it will allow to keep red/green neatly encapsulated within the
DepGraph implementation.

6 years agoincr.comp.: Compute hashes of all query results.
Michael Woerister [Mon, 14 Aug 2017 16:19:42 +0000 (18:19 +0200)]
incr.comp.: Compute hashes of all query results.

6 years agoUse DefId instead of NodeId as identifier in resolve_lifetime::Region.
Michael Woerister [Tue, 15 Aug 2017 15:05:25 +0000 (17:05 +0200)]
Use DefId instead of NodeId as identifier in resolve_lifetime::Region.

These Region values end up in crate metadata so they should not use NodeId.

6 years agoAuto merge of #44441 - tamird:cargo-bitflags, r=alexcrichton
bors [Mon, 18 Sep 2017 07:00:28 +0000 (07:00 +0000)]
Auto merge of #44441 - tamird:cargo-bitflags, r=alexcrichton

Remove rustc_bitflags; use the bitflags crate

r? @alexcrichton

6 years agoAdd Example of `IntoIterator` as Trait Bound to Docs
Will Speak [Mon, 18 Sep 2017 06:38:32 +0000 (07:38 +0100)]
Add Example of `IntoIterator` as Trait Bound to Docs

Part of #44600.

6 years agoAuto merge of #43628 - oli-obk:orbital_standard_library, r=alexcrichton
bors [Mon, 18 Sep 2017 01:50:29 +0000 (01:50 +0000)]
Auto merge of #43628 - oli-obk:orbital_standard_library, r=alexcrichton

Run the miri test suite on the aux builder and travis

Reopen of #38350

see https://github.com/rust-lang/rust/pull/43340#issuecomment-316940762 for earlier discussion

Rationale for running miri's test suite in rustc's CI is that miri currently contains many features that we want in const eval in the future, and these features would break if the test suite is not run.

fixes #44077

r? @nikomatsakis

cc @eddyb

6 years agoAuto merge of #44529 - alexcrichton:trans-query, r=michaelwoerister
bors [Sun, 17 Sep 2017 22:05:31 +0000 (22:05 +0000)]
Auto merge of #44529 - alexcrichton:trans-query, r=michaelwoerister

Refactor translation unit partitioning/collection as a query

This commit is targeted at #44486 with the ultimate goal of making the `collect_and_partition_translation_items` function a query. This mostly just involved query-ifying a few other systems along with plumbing the tcx instead of `SharedCrateContext` in a few locations.

Currently this only tackles the first bullet of #44486 and doesn't add a dedicated query for a particular codegen unit. I wasn't quite sure how to do that yet but figured this was good to put up.

Closes #44486

6 years agoAdd more links and put the link character to the left
Guillaume Gomez [Sun, 17 Sep 2017 20:11:37 +0000 (22:11 +0200)]
Add more links and put the link character to the left

6 years agoRebase fallout
Oliver Schneider [Sun, 17 Sep 2017 19:45:54 +0000 (21:45 +0200)]
Rebase fallout

6 years agoUpdate miri submodule
Oliver Schneider [Sun, 17 Sep 2017 19:42:35 +0000 (21:42 +0200)]
Update miri submodule

6 years agoPrevent distribution if miri is enabled
Oliver Schneider [Sun, 10 Sep 2017 09:48:56 +0000 (11:48 +0200)]
Prevent distribution if miri is enabled

6 years ago-Zmir-emit-validate is in stage 0
Oliver Schneider [Tue, 5 Sep 2017 15:22:52 +0000 (17:22 +0200)]
-Zmir-emit-validate is in stage 0

6 years agoAdd a file to trivially disable tool building or testing
Oliver Schneider [Wed, 30 Aug 2017 16:59:26 +0000 (18:59 +0200)]
Add a file to trivially disable tool building or testing

6 years agoImprove documentation
Oliver Schneider [Mon, 11 Sep 2017 09:00:51 +0000 (11:00 +0200)]
Improve documentation

6 years agoGet the miri test suite to run inside the rustc dev environment
Oliver Schneider [Mon, 28 Aug 2017 14:54:50 +0000 (16:54 +0200)]
Get the miri test suite to run inside the rustc dev environment

6 years agoAdd `<*const T>::align_offset` and use it in `memchr`
Oliver Schneider [Wed, 13 Sep 2017 10:20:39 +0000 (12:20 +0200)]
Add `<*const T>::align_offset` and use it in `memchr`

6 years agoRemove rustc_bitflags; use the bitflags crate
Tamir Duberstein [Fri, 8 Sep 2017 19:08:01 +0000 (15:08 -0400)]
Remove rustc_bitflags; use the bitflags crate

6 years agorustc: Move codegen to a query
Alex Crichton [Thu, 14 Sep 2017 03:26:39 +0000 (20:26 -0700)]
rustc: Move codegen to a query

This commit moves the actual code generation in the compiler behind a query
keyed by a codegen unit's name. This ended up entailing quite a few internal
refactorings to enable this, along with a few cut corners:

* The `OutputFilenames` structure is now tracked in the `TyCtxt` as it affects a
  whole bunch of trans and such. This is now behind a query and threaded into
  the construction of the `TyCtxt`.

* The `TyCtxt` now has a channel "out the back" intended to send data to worker
  threads in rustc_trans. This is used as a sort of side effect of the codegen
  query but morally what's happening here is the return value of the query
  (currently unit but morally a path) is only valid once the background threads
  have all finished.

* Dispatching work items to the codegen threads was refactored to only rely on
  data in `TyCtxt`, which mostly just involved refactoring where data was
  stored, moving it from the translation thread to the controller thread's
  `CodegenContext` or the like.

* A new thread locals was introduced in trans to work around the query
  system. This is used in the implementation of `assert_module_sources` which
  looks like an artifact of the old query system and will presumably go away
  once red/green is up and running.

6 years agobootstrap: plumb verbosity into submodule ops
Tamir Duberstein [Fri, 15 Sep 2017 17:12:14 +0000 (13:12 -0400)]
bootstrap: plumb verbosity into submodule ops

Fix some lints while I'm here.

6 years agoAuto merge of #44607 - alexcrichton:rustbuild-no-j, r=Mark-Simulacrum
bors [Sun, 17 Sep 2017 17:15:01 +0000 (17:15 +0000)]
Auto merge of #44607 - alexcrichton:rustbuild-no-j, r=Mark-Simulacrum

rustbuild: Don't pass `-j` if called by `make`

In these situations Cargo just prints out a warning about ignoring the flag
anyway, so let `make` take care of jobs and whatnot instead of getting warnings
printed.

6 years agoUse double quotes to appease some TOML parsers
Tamir Duberstein [Sun, 17 Sep 2017 17:14:37 +0000 (13:14 -0400)]
Use double quotes to appease some TOML parsers

6 years agorustc: Attach an mpsc channel to TyCtxt
Alex Crichton [Wed, 13 Sep 2017 23:03:24 +0000 (16:03 -0700)]
rustc: Attach an mpsc channel to TyCtxt

This commit attaches a channel to the LLVM workers to the `TyCtxt` which will
later be used during the codegen query to actually send work to LLVM workers.
Otherwise this commit is just plumbing this channel throughout the compiler to
ensure it reaches the right consumers.

6 years agorustc: Remove another global map from trans
Alex Crichton [Wed, 13 Sep 2017 22:24:13 +0000 (15:24 -0700)]
rustc: Remove another global map from trans

This commit removes the `crate_trans_items` field from the `CrateContext` of
trans. This field, a big map, was calculated during partioning and was a set of
all translation items. This isn't quite incremental-friendly because the map may
change a lot but not have much effect on downstream consumers.

Instead a new query was added for the one location this map was needed, along
with a new comment explaining what the location is doing!

6 years agorustc: Move a comment to the right spot in trans
Alex Crichton [Wed, 13 Sep 2017 22:04:51 +0000 (15:04 -0700)]
rustc: Move a comment to the right spot in trans

I believe this comment here is mostly talking about the `ptrcast` function call
below, so move the comment down to that block.

6 years agorustc: Mostly remove `ExportedSymbols`
Alex Crichton [Wed, 13 Sep 2017 20:22:20 +0000 (13:22 -0700)]
rustc: Mostly remove `ExportedSymbols`

This is a big map that ends up inside of a `CrateContext` during translation for
all codegen units. This means that any change to the map may end up causing an
incremental recompilation of a codegen unit! In order to reduce the amount of
dependencies here between codegen units and the actual input crate this commit
refactors dealing with exported symbols and such into various queries.

The new queries are largely based on existing queries with filled out
implementations for the local crate in addition to external crates, but the main
idea is that while translating codegen untis no unit needs the entire set of
exported symbols, instead they only need queries about particulare `DefId`
instances every now and then.

The linking stage, however, still generates a full list of all exported symbols
from all crates, but that's going to always happen unconditionally anyway, so no
news there!

6 years agorustc: Move some attr methods to queries
Alex Crichton [Tue, 12 Sep 2017 19:18:11 +0000 (12:18 -0700)]
rustc: Move some attr methods to queries

Otherwise we may emit double errors related to the `#[export_name]` attribute,
for example, and using a query should ensure that it's only emitted at most
once.

6 years agorustc: Make trans collect/partition a query
Alex Crichton [Tue, 12 Sep 2017 18:04:46 +0000 (11:04 -0700)]
rustc: Make trans collect/partition a query

This commit moves the `collect_and_partition_translation_items` function into a
query on `TyCtxt` instead of a free function in trans, allowing us to track
dependencies and such of the function.

6 years agorustc: Calculate `ExportedSymbols` in a query
Alex Crichton [Tue, 12 Sep 2017 16:32:37 +0000 (09:32 -0700)]
rustc: Calculate `ExportedSymbols` in a query

This commit moves the definition of the `ExportedSymbols` structure to the
`rustc` crate and then creates a query that'll be used to construct the
`ExportedSymbols` set. This in turn uses the reachablity query exposed in the
previous commit.

6 years agorustc: Use reachablility through a query
Alex Crichton [Tue, 12 Sep 2017 16:04:24 +0000 (09:04 -0700)]
rustc: Use reachablility through a query

Turns out this was already set up as a query, just wasn't using it yet!

6 years agorustc: Refactor trans paritioning to use tcx
Alex Crichton [Tue, 12 Sep 2017 15:32:50 +0000 (08:32 -0700)]
rustc: Refactor trans paritioning to use tcx

This commit refactors the the `partitioning::partition` function to operate with
a `TyCtxt` instead of a `SharedCrateContext` in preparation for making it a
query.

6 years agorustc_trans: Refactor collection to use tcx
Alex Crichton [Tue, 12 Sep 2017 15:28:17 +0000 (08:28 -0700)]
rustc_trans: Refactor collection to use tcx

This commit refactors the `collect_crate_translation_items` function to only
require the `TyCtxt` instead of a `SharedCrateContext` in preparation for
query-ifying this portion of trans.

6 years agorustbuild: Don't pass `-j` if called by `make`
Alex Crichton [Fri, 15 Sep 2017 16:40:35 +0000 (09:40 -0700)]
rustbuild: Don't pass `-j` if called by `make`

In these situations Cargo just prints out a warning about ignoring the flag
anyway, so let `make` take care of jobs and whatnot instead of getting warnings
printed.

6 years agomissed a 'mut'
Ixrec [Sun, 17 Sep 2017 16:11:42 +0000 (17:11 +0100)]
missed a 'mut'

6 years agoReplace str's transmute() calls with pointer casts
Ixrec [Sun, 17 Sep 2017 16:03:56 +0000 (17:03 +0100)]
Replace str's transmute() calls with pointer casts

After the following conversation in #rust-lang:
```
[14:43:50] <Ixrec> TIL the implementation of from_utf_unchecked is literally just "mem::transmute(x)"
[14:43:59] <Ixrec> no wonder people keep saying transmute is overpowered
[15:15:30] <eddyb> Ixrec: it should be a pointer cast lol
[15:15:46] <eddyb> unless it doesn't let you
[16:50:34] <Ixrec> https://play.rust-lang.org/?gist=d1e6b629ad9ec1baf64ce261c63845e6&version=stable seems like it does let me
[16:52:35] <eddyb> Ixrec: yeah that's the preferred impl
[16:52:46] <eddyb> Ixrec: it just wasn't in 1.0
[16:52:50] <eddyb> IIRC
[16:53:00] <eddyb> (something something fat pointers)
```
Since I already wrote half of the preferred impls in the playground, might as well make an actual PR.

6 years agoAuto merge of #44654 - TimNN:rollup, r=TimNN
bors [Sun, 17 Sep 2017 11:19:56 +0000 (11:19 +0000)]
Auto merge of #44654 - TimNN:rollup, r=TimNN

Rollup of 17 pull requests

- Successful merges: #44073, #44088, #44381, #44397, #44509, #44533, #44549, #44553, #44562, #44567, #44595, #44604, #44617, #44622, #44630, #44639, #44647
- Failed merges:

6 years agoRollup merge of #44647 - tmerr:fix-44645, r=dtolnay
Tim Neumann [Sun, 17 Sep 2017 11:19:15 +0000 (13:19 +0200)]
Rollup merge of #44647 - tmerr:fix-44645, r=dtolnay

Ensure tcp test case passes when disconnected from network

net::tcp::tests::connect_timeout_unroutable fails when the network
is unreachable, like on a laptop disconnected from wifi. Check for
this error and allow the test to pass.

Closes #44645

6 years agoRollup merge of #44639 - budziq:stabilize_needs_drop, r=dtolnay
Tim Neumann [Sun, 17 Sep 2017 11:19:14 +0000 (13:19 +0200)]
Rollup merge of #44639 - budziq:stabilize_needs_drop, r=dtolnay

stabilized needs_drop (fixes #41890)

fixes #41890

6 years agoRollup merge of #44630 - RalfJung:compiletest, r=Mark-Simulacrum
Tim Neumann [Sun, 17 Sep 2017 11:19:13 +0000 (13:19 +0200)]
Rollup merge of #44630 - RalfJung:compiletest, r=Mark-Simulacrum

compiletest: print the correct basename of the src dir

See <https://github.com/laumann/compiletest-rs/issues/76>.

Fixes #40712

6 years agoRollup merge of #44622 - frewsxcv:frewsxcv-invalid-link, r=QuietMisdreavus
Tim Neumann [Sun, 17 Sep 2017 11:19:12 +0000 (13:19 +0200)]
Rollup merge of #44622 - frewsxcv:frewsxcv-invalid-link, r=QuietMisdreavus

Fix incorrect `into_inner` link in docs.

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

6 years agoRollup merge of #44617 - alexcrichton:download-from-us-west-1, r=aidanhs
Tim Neumann [Sun, 17 Sep 2017 11:19:11 +0000 (13:19 +0200)]
Rollup merge of #44617 - alexcrichton:download-from-us-west-1, r=aidanhs

ci: Upload/download from a new S3 bucket

Moving buckets from us-east-1 to us-west-1 because us-west-1 is where
rust-central-station itself runs and in general is where we have all our other
buckets.

6 years agoRollup merge of #44604 - alexcrichton:update-cargo, r=Mark-Simulacrum
Tim Neumann [Sun, 17 Sep 2017 11:19:10 +0000 (13:19 +0200)]
Rollup merge of #44604 - alexcrichton:update-cargo, r=Mark-Simulacrum

Update cargo submodule

Just a routine update

6 years agoRollup merge of #44595 - budziq:stabilize_compiler_fences, r=alexcrichton
Tim Neumann [Sun, 17 Sep 2017 11:19:09 +0000 (13:19 +0200)]
Rollup merge of #44595 - budziq:stabilize_compiler_fences, r=alexcrichton

stabilized compiler_fences (fixes #41091)

I did not know what to proceed with "unstable-book" entry. The feature would no longer be unstable so I have deleted it. If it was the wrong call I'll revert it (unfortunately his case is not described in the CONTRIBUTING.md).

6 years agoRollup merge of #44567 - budziq:stabilize_iterator_for_each, r=alexcrichton
Tim Neumann [Sun, 17 Sep 2017 11:19:08 +0000 (13:19 +0200)]
Rollup merge of #44567 - budziq:stabilize_iterator_for_each, r=alexcrichton

stabilized iterator_for_each (closes #42986)

Also updated clippy and rls as these use the iterator_for_each

I've made my first PR's today so most likely I've done something wrong. Sorry about that!

6 years agoRollup merge of #44562 - eddyb:ugh-rustdoc, r=nikomatsakis
Tim Neumann [Sun, 17 Sep 2017 11:19:07 +0000 (13:19 +0200)]
Rollup merge of #44562 - eddyb:ugh-rustdoc, r=nikomatsakis

rustdoc: pretty-print Unevaluated expressions in types.

Fixes #44555.

r? @nikomatsakis

6 years agoRollup merge of #44553 - qmx:refactor-remove-overzealous-box-szero-optimization,...
Tim Neumann [Sun, 17 Sep 2017 11:19:06 +0000 (13:19 +0200)]
Rollup merge of #44553 - qmx:refactor-remove-overzealous-box-szero-optimization, r=arielb1

remove overzealous Box<ZeroSizeType> optimization

6 years agoRollup merge of #44549 - gaurikholkar:master, r=arielb1
Tim Neumann [Sun, 17 Sep 2017 11:19:05 +0000 (13:19 +0200)]
Rollup merge of #44549 - gaurikholkar:master, r=arielb1

extend E0623 for earlybound and latebound for structs

This fixes #44508

r? @nikomatsakis

6 years agoRollup merge of #44533 - nrc:rustfmt-submod, r=alexcrichton
Tim Neumann [Sun, 17 Sep 2017 11:19:04 +0000 (13:19 +0200)]
Rollup merge of #44533 - nrc:rustfmt-submod, r=alexcrichton

Add Rustfmt

r? @alexcrichton

6 years agoRollup merge of #44509 - tamird:remove-rustbuild-feature, r=nikomatsakis
Tim Neumann [Sun, 17 Sep 2017 11:19:03 +0000 (13:19 +0200)]
Rollup merge of #44509 - tamird:remove-rustbuild-feature, r=nikomatsakis

Update compiler-builtins

~~I can't tell if this was ever used, but it's not used today.~~

See commits.

6 years agoRollup merge of #44397 - GuillaumeGomez:codeblock-color, r=QuietMisdreavus
Tim Neumann [Sun, 17 Sep 2017 11:19:02 +0000 (13:19 +0200)]
Rollup merge of #44397 - GuillaumeGomez:codeblock-color, r=QuietMisdreavus

Codeblock color

<img width="1440" alt="screen shot 2017-09-07 at 21 53 58" src="https://user-images.githubusercontent.com/3050060/30183045-4319108e-9419-11e7-98da-da54952cab37.png">

This screenshot has been generated from:

```rust
/// foo
///
/// ```compile_fail
/// foo();
/// ```
///
/// ```ignore
/// goo();
/// ```
///
/// ```
/// let x = 0;
/// ```
pub fn bar() -> usize { 2 }
```

r? @QuietMisdreavus
cc @rust-lang/docs

6 years agoRollup merge of #44381 - jessicah:haiku-ci, r=alexcrichton
Tim Neumann [Sun, 17 Sep 2017 11:19:01 +0000 (13:19 +0200)]
Rollup merge of #44381 - jessicah:haiku-ci, r=alexcrichton

ci: introduce haiku x86_64 builder

6 years agoRollup merge of #44088 - bjorn3:better_trace_macros, r=jseyfried
Tim Neumann [Sun, 17 Sep 2017 11:19:00 +0000 (13:19 +0200)]
Rollup merge of #44088 - bjorn3:better_trace_macros, r=jseyfried

Fix "new trace_macros doesn't work if there's an error during expansion"

Fixes #43493

6 years agoRollup merge of #44073 - murarth:rc-into-raw-unsized, r=alexcrichton
Tim Neumann [Sun, 17 Sep 2017 11:18:59 +0000 (13:18 +0200)]
Rollup merge of #44073 - murarth:rc-into-raw-unsized, r=alexcrichton

Implement `Arc`/`Rc` raw pointer conversions for `?Sized`

* Add `T: ?Sized` bound to {`Arc`,`Rc`}::{`from_raw`,`into_raw`}

6 years agoUpdated tracking issue for String::splice and its unstable-book entry
Michal Budzynski [Sun, 17 Sep 2017 08:41:24 +0000 (10:41 +0200)]
Updated tracking issue for String::splice and its unstable-book entry

6 years agostabilized vec_splice (fixes #32310)
Michal Budzynski [Sat, 16 Sep 2017 23:42:15 +0000 (01:42 +0200)]
stabilized vec_splice (fixes #32310)

6 years agostd: Document thread builder panics for nul bytes in thread names
Ulrik Sverdrup [Sun, 17 Sep 2017 08:19:11 +0000 (10:19 +0200)]
std: Document thread builder panics for nul bytes in thread names

This seems to have been undocumented. Mention this where the name is set
(Builder::name) and where the panic could happen (Builder::spawn).

Thread::new is private and I think the builder is the only user where
this matters. A short comment was added to "document" Thread::new too.

6 years agoAuto merge of #44641 - alexcrichton:disable-more-osx-assertions, r=Mark-Simulacrum
bors [Sun, 17 Sep 2017 05:19:00 +0000 (05:19 +0000)]
Auto merge of #44641 - alexcrichton:disable-more-osx-assertions, r=Mark-Simulacrum

ci: Disable rustc debug assertions on OSX

This commit disables debug assertions for OSX in an effort to improve cycle time
on OSX. It looks like #44610 didn't shave off quite as much time as desired so
let's see how much this helps.

6 years agoEnsure tcp test case passes when disconnected from network
Trevor Merrifield [Sun, 17 Sep 2017 03:36:11 +0000 (23:36 -0400)]
Ensure tcp test case passes when disconnected from network

net::tcp::tests::connect_timeout_unroutable fails when the network
is unreachable, like on a laptop disconnected from wifi. Check for
this error and allow the test to pass.

Closes #44645

6 years agoAuto merge of #44634 - alexcrichton:rollup, r=alexcrichton
bors [Sun, 17 Sep 2017 01:51:55 +0000 (01:51 +0000)]
Auto merge of #44634 - alexcrichton:rollup, r=alexcrichton

Rollup of 19 pull requests

- Successful merges: #44273, #44356, #44395, #44531, #44537, #44542, #44560, #44567, #44574, #44577, #44586, #44589, #44590, #44593, #44598, #44606, #44609, #44616, #44631
- Failed merges:

6 years agoci: Disable rustc debug assertions on OSX
Alex Crichton [Sun, 17 Sep 2017 00:25:12 +0000 (17:25 -0700)]
ci: Disable rustc debug assertions on OSX

This commit disables debug assertions for OSX in an effort to improve cycle time
on OSX. It looks like #44610 didn't shave off quite as much time as desired so
let's see how much this helps.