Commit Graph

62944 Commits

Author SHA1 Message Date
Corey Farwell
25518db1dc Rollup merge of #41120 - clarcharr:c_str_transmute, r=alexcrichton
Remove some CStr transmutes.

Because dedicated methods exist for these, we don't have to add other transmutes.
2017-04-07 09:20:09 -04:00
Corey Farwell
2a92fe2aaa Rollup merge of #41080 - cuviper:generic-powerpc, r=alexcrichton
dist-powerpc-linux: use a pure 32-bit CPU profile

With `-mcpu=power4`, code might use instructions like `fcfid`, excluding
older CPUs like the PowerPC G4, which apparently some users would like
to use.  The generic `-mcpu=powerpc` should stick to pure 32-bit PowerPC
instructions.

Fixes rust-lang/cargo#3852.
2017-04-07 09:20:08 -04:00
Corey Farwell
a2c032631b Rollup merge of #41075 - aidanhs:aphs-enable-appveyor-cache, r=alexcrichton
Re-enable appveyor cache

After breaking the queue last time, I'm cautiously back with a PR to re-enable caching on appveyor.

If you look at https://ci.appveyor.com/project/rust-lang/rust/build/1.0.2623/job/46o90by4ari6gege (one of the multiple runs that started failed, there are actually two errors - one for restoring the cache, one right at the bottom for creating a directory. I only noticed the restore error at the time as I was a bit rushed to revert and didn't stop to wonder why it continued - turns out appveyor [does not abort on cache restore failure](https://github.com/appveyor/ci/issues/723).

Turns out the cause of the build failures was the cache directory existing and me being thinking that because mkdir on windows is [recursive by default](http://stackoverflow.com/a/905239/2352259), it ignores the error if the directory already exists. Apparently this is not true, so now it checks if the directory exists before attempting to create.

In addition, I've added some more paranoia to double check everything is sane.
2017-04-07 09:20:07 -04:00
Corey Farwell
996f06fe35 Rollup merge of #41061 - arielb1:parent-lock, r=eddyb
cstore: return an immutable borrow from `visible_parent_map`

This prevents an ICE when `visible_parent_map` is called multiple times, for example when an item referenced in an impl signature is imported from an  `extern crate` statement occurs within an impl.

Fixes #41053.

r? @eddyb
2017-04-07 09:20:06 -04:00
Corey Farwell
88e97f0541 Rollup merge of #41056 - michaelwoerister:central-defpath-hashes, r=nikomatsakis
Handle DefPath hashing centrally as part of DefPathTable (+ save work during SVH calculation)

In almost all cases where we construct a `DefPath`, we just hash it and throw it away again immediately.
With this PR, the compiler will immediately compute and store the hash for each `DefPath` as it is allocated. This way we
+ can get rid of any subsequent `DefPath` hash caching (e.g. the `DefPathHashes`),
+ don't need to allocate a transient `Vec` for holding the `DefPath` (although I'm always surprised how little these small, dynamic allocations seem to hurt performance), and
+ we don't hash `DefPath` prefixes over and over again.

That last part is because we construct the hash for `prefix::foo` by hashing `(hash(prefix), foo)` instead of hashing every component of prefix.

The last commit of this PR is pretty neat, I think:
```
The SVH (Strict Version Hash) of a crate is currently computed
by hashing the ICHes (Incremental Computation Hashes) of the
crate's HIR. This is fine, expect that for incr. comp. we compute
two ICH values for each HIR item, one for the complete item and
one that just includes the item's interface. The two hashes are
are needed for dependency tracking but if we are compiling
non-incrementally and just need the ICH values for the SVH,
one of them is enough, giving us the opportunity to save some
work in this case.
```

r? @nikomatsakis

This PR depends on https://github.com/rust-lang/rust/pull/40878 to be merged first (you can ignore the first commit for reviewing, that's just https://github.com/rust-lang/rust/pull/40878).
2017-04-07 09:20:05 -04:00
Corey Farwell
ef9eee7402 Rollup merge of #41047 - cuviper:src_is_git, r=alexcrichton
Only use cargo-vendor if building from git sources

The only time we need to vendor sources is when building from git.  If one is
building from a rustc source tarball, everything should already be in place.
This also matters for distros which do offline builds, as they can't install
cargo-vendor this way.

This adds a common `Build::src_is_git` flag, and then uses it in the dist-src
target to decide whether to install or use `cargo-vendor` at all.

Fixes #41042.
2017-04-07 09:20:04 -04:00
Corey Farwell
d860b1c003 Rollup merge of #40797 - GAJaloyan:patch-1, r=arielb1
Correcting mistakes in the README.md

Correcting the two mistakes in the README.md (issue #40793)
2017-04-07 09:20:03 -04:00
Michael Woerister
bb6387295a SVH: Don't hash the HIR twice when once is enough.
The SVH (Strict Version Hash) of a crate is currently computed
by hashing the ICHes (Incremental Computation Hashes) of the
crate's HIR. This is fine, expect that for incr. comp. we compute
two ICH values for each HIR item, one for the complete item and
one that just includes the item's interface. The two hashes are
are needed for dependency tracking but if we are compiling
non-incrementally and just need the ICH values for the SVH,
one of them is enough, giving us the opportunity to save some
work in this case.
2017-04-07 14:37:48 +02:00
Michael Woerister
edc1ac3016 ICH: Centrally compute and cache DefPath hashes as part of DefPathTable. 2017-04-07 14:36:51 +02:00
bors
4c59c92bc4 Auto merge of #40873 - cramertj:on-demandify-queries, r=nikomatsakis
On demandify reachability

cc https://github.com/rust-lang/rust/issues/40746

I tried following this guidance from #40746:
> The following tasks currently execute before a tcx is built, but they could be easily converted into queries that are requested after tcx is built. The main reason they are the way they are was to avoid a gratuitious refcell (but using the refcell map seems fine)...

but the result of moving `region_maps` out of `TyCtxt` and into a query caused a lot of churn, and seems like it could potentially result in a rather large performance hit, since it means a dep-graph lookup on every use of `region_maps` (rather than just a field access). Possibly `TyCtxt` could store a `RefCell<Option<RegionMap>>` internally and use that to prevent repeat lookups, but that feels like it's duplicating the work of the dep-graph. @nikomatsakis What did you have in mind for this?
2017-04-07 08:36:11 +00:00
bors
b9c5197d48 Auto merge of #39987 - japaric:used, r=arielb1
#[used] attribute

(For an explanation of what this feature does, read the commit message)

I'd like to propose landing this as an experimental feature (experimental as in:
no clear stabilization path -- like `asm!`, `#[linkage]`) as it's low
maintenance (I think) and relevant to the "Usage in resource-constrained
environments" exploration area.

The main use case I see is running code before `main`. This could be used, for
instance, to cheaply initialize an allocator before `main` where the alternative
is to use `lazy_static` to initialize the allocator on its first use which it's
more expensive (atomics) and doesn't work on ARM Cortex-M0 microcontrollers (no
`AtomicUsize` on that platform)

Here's a `std` example of that:

``` rust

unsafe extern "C" fn before_main_1() {
    println!("Hello");
}

unsafe extern "C" fn before_main_2() {
    println!("World");
}

#[link_section = ".init_arary"]
#[used]
static INIT_ARRAY: [unsafe extern "C" fn(); 2] = [before_main_1, before_main_2];

fn main() {
    println!("Goodbye");
}
```

```
$ rustc -C lto -C opt-level=3 before_main.rs
$ ./before_main
Hello
World
Goodbye
```

In general, this pattern could be used to let *dependencies* run code before
`main` (which sounds like it could go very wrong in some cases). There are
probably other use cases; I hope that the people I have cc-ed can comment on
those.

Note that I'm personally unsure if the above pattern is something we want to
promote / allow and that's why I'm proposing this feature as experimental. If
this leads to more footguns than benefits then we can just axe the feature.

cc @nikomatsakis ^ I know you have some thoughts on having a process for
experimental features though I'm fine with writing an RFC before landing this.

- `dead_code` lint will have to be updated to special case `#[used]` symbols.

- Should we extend `#[used]` to work on non-generic functions?

cc rust-lang/rfcs#1002
cc rust-lang/rfcs#1459
cc @dpc @JinShil
2017-04-07 04:56:45 +00:00
Jorge Aparicio
98037ca43d don't pass -C to nm
the nm in our macOS bots don't support that flag and it's not really required
2017-04-06 23:53:32 -05:00
Jorge Aparicio
f4f79c3304 ignore the .init_array doctest
as it's specific to ELF and won't pass on macOS / Windows
2017-04-06 18:32:39 -05:00
bors
2277f4bdcc Auto merge of #41121 - frewsxcv:rollup, r=frewsxcv
Rollup of 8 pull requests

- Successful merges: #40878, #40976, #41089, #41090, #41108, #41111, #41112, #41114
- Failed merges:
2017-04-06 22:51:51 +00:00
Clar Charr
9ffb54568c Remove some CStr transmutes. 2017-04-06 17:42:02 -04:00
bors
50c186419b Auto merge of #40863 - eddyb:coerce-only-once, r=arielb1
Avoid type-checking addition and indexing twice.

Fixes #40610 by moving the common `check_expr_coercable_to_type` call before the error reporting logic for binops and removing the one from `check_str_addition`.
Fixes #40861 by removing an unnecessary `check_expr_coercable_to_type` call.
2017-04-06 20:15:17 +00:00
Corey Farwell
8af853b310 Rollup merge of #41114 - nodakai:patch-2, r=petrochenkov
.gitmodules: use the official Git URL w/o redirect
2017-04-06 14:55:09 -04:00
Corey Farwell
f129c0c62b Rollup merge of #41112 - ollie27:rustdoc_pull, r=GuillaumeGomez
rustdoc: Use pulldown-cmark for Markdown HTML rendering

Instead of rendering all of the HTML in rustdoc this relies on
pulldown-cmark's `push_html` to do most of the work. A few iterator
adapters are used to make rustdoc specific modifications to the output.

This also fixes MarkdownHtml and link titles in plain_summary_line.

https://ollie27.github.io/rust_doc_test/ is the docs built with this change and #41111.

Part of #40912.

cc @GuillaumeGomez

r? @steveklabnik
2017-04-06 14:55:08 -04:00
Corey Farwell
202be73aef Rollup merge of #41111 - ollie27:docs_markdown_fix, r=GuillaumeGomez
Fix Markdown issues in the docs

* Since the switch to pulldown-cmark reference links need a blank line
before the URLs. (#40912)
* Reference link references are not case sensitive.
* Doc comments need to be indented uniformly otherwise rustdoc gets
confused.
2017-04-06 14:55:07 -04:00
Corey Farwell
30477a8dec Rollup merge of #41108 - arielb1:tuple-blame, r=estebank
don't try to blame tuple fields for immutability

Tuple fields don't have an `&T` in their declaration that can be changed
to `&mut T` - skip them..

Fixes #41104.

r? @nikomatsakis
2017-04-06 14:55:06 -04:00
Corey Farwell
a7502761ff Rollup merge of #41090 - rap2hpoutre:patch-2, r=steveklabnik
Add example to std::process::abort

This is a second step in order to complete this issue: https://github.com/rust-lang/rust/issues/29370
I submitted this PR with the help of @steveklabnik again. Thanks to him! More info here: https://github.com/rust-lang/rust/issues/29370#issuecomment-290653877
2017-04-06 14:55:05 -04:00
Corey Farwell
9516c80bb7 Rollup merge of #41089 - alexcrichton:update-musl, r=brson
travis: Update musl for i686/x86_64

This is a random stab towards #38618, no idea if it'll work. But hey more
up-to-date software is better, right?
2017-04-06 14:55:04 -04:00
Corey Farwell
966878ee57 Rollup merge of #40976 - matthewjasper:char-const-expr, r=eddyb
Don't warn about `char` comparisons in constexprs

Fixes #40970 by evaluating const-exprs for comparisons on `char`s properly.
2017-04-06 14:55:03 -04:00
Corey Farwell
cce5c2d93a Rollup merge of #40878 - michaelwoerister:dmh, r=nikomatsakis
Introduce HashStable trait and base ICH implementations on it.

This PR introduces the `HashStable` trait which marks that a type can be hashed in a way that is stable across multiple compilation sessions. The PR also moves HIR incr. comp. hashing over to implementations of this trait instead of doing this via a HIR visitor. It also provides many `HashStable` implementations that are not used yet (e.g. for MIR types) but soon will be used when we directly hash crate metadata for incr. comp.

I've only done superficial performance measurements but it looks like the new implementation is a bit faster than the current one (due, I suppose, to some bugs I fixed and some unnecessary inefficiencies I removed). Here is the time in seconds for the `compute_incremental_hashes_map` pass for various crates:

|                 |  OLD  |  NEW  |
|:---------------:|:-----:|:-----:|
| libcore         | 0.507 | 0.409 |
| libsyntax       | 0.320 | 0.260 |
| librustc        | 0.730 | 0.611 |
| librustc_driver | 0.024 | 0.015 |

Some notes regarding the implementation:
* Most `HashStable` implementations are provided via the `impl_hash_stable_for!` macro (as suggested by @nikomatsakis). This works out quite well. A custom_derive would have been better but Macros 1.1 are not available in the compiler.
* The trait implementation take care to exhaustively destructure everything they hash so that fields added in the future don't fall through the cracks. This is a bit verbose but I think it's well worth the trouble since we've had quite a few issues with missing fields or visitor callbacks in this area in the past. Most of it is behind the macro anyway.

cc @rust-lang/compiler
r? @nikomatsakis
2017-04-06 14:55:02 -04:00
Eduard-Mihai Burtescu
edc7f9abec Avoid type-checking addition and indexing twice. 2017-04-06 21:42:25 +03:00
Michael Woerister
c47cdc0d93 Introduce HashStable trait and base ICH implementations on it.
This initial commit provides implementations for HIR, MIR, and
everything that also needs to be supported for those two.
2017-04-06 16:01:51 +02:00
NODA, Kai
1f93a78cdc .gitmodules: use the official Git URL w/o redirect 2017-04-06 21:48:56 +08:00
Jorge Aparicio
7d25e768ea add link to issue number, ignore snippet that requires custom linking 2017-04-06 08:48:48 -05:00
Oliver Middleton
f9fb381b2a rustdoc: Use pulldown-cmark for Markdown HTML rendering
Instead of rendering all of the HTML in rustdoc this relies on
pulldown-cmark's `push_html` to do most of the work. A few iterator
adapters are used to make rustdoc specific modifications to the output.

This also fixes MarkdownHtml and link titles in plain_summary_line.
2017-04-06 13:09:20 +01:00
Oliver Middleton
b4be475836 Fix Markdown issues in the docs
* Since the switch to pulldown-cmark reference links need a blank line
before the URLs.
* Reference link references are not case sensitive.
* Doc comments need to be indented uniformly otherwise rustdoc gets
confused.
2017-04-06 12:57:40 +01:00
bors
44855a4cef Auto merge of #41039 - alexcrichton:process-poll, r=nagisa
std: Use `poll` instead of `select`

This gives us the benefit of supporting file descriptors over the limit that
select supports, which...

Closes #40894
2017-04-06 11:21:55 +00:00
Ariel Ben-Yehuda
95bd41e339 don't try to blame tuple fields for immutability
Tuple fields don't have an `&T` in their declaration that can be changed
to `&mut T` - skip them..

Fixes #41104.
2017-04-06 13:20:24 +03:00
bors
9e84bf8096 Auto merge of #40996 - alexcrichton:update-cargo, r=alexcrichton
Update cargo submodule

Pulls in a fix for rust-lang/rust#40956
2017-04-06 08:53:36 +00:00
raph
16c77d7da1 Update process.rs 2017-04-06 10:17:32 +02:00
bors
e5e92753cc Auto merge of #41102 - frewsxcv:rollup, r=frewsxcv
Rollup of 5 pull requests

- Successful merges: #40908, #41011, #41026, #41037, #41050
- Failed merges:
2017-04-06 06:07:42 +00:00
Jorge Aparicio
763beff5d1 add documentation to the unstable book 2017-04-06 00:04:33 -05:00
Corey Farwell
89b364d687 Rollup merge of #41050 - jseyfried:fix_derive_parsing, r=petrochenkov
macros: fix bug parsing `#[derive]` invocations

Fixes #40962 (introduced in #40346).
r? @nrc
2017-04-05 23:51:43 -04:00
Corey Farwell
e4a62109c9 Rollup merge of #41037 - stjepang:move-libxtest, r=alexcrichton
Move libXtest into libX/tests

This change moves:

1. `libcoretest` into `libcore/tests`
2. `libcollectionstest` into `libcollections/tests`

This is a follow-up to #39561.

r? @alexcrichton
2017-04-05 23:51:42 -04:00
Corey Farwell
1a4aab94c3 Rollup merge of #41026 - CleanCut:rust-40860, r=alexcrichton
Handle symlinks in src/bootstrap/clean.rs (mostly) -- resolves #40860.

In response to #40860

The broken condition can be replicated with:

```shell
export MYARCH=x86_64-apple-darwin && mkdir -p build/$MYARCH/subdir &&
touch build/$MYARCH/subdir/file && ln -s build/$MYARCH/subdir/file
build/$MYARCH/subdir/symlink
```

`src/bootstrap/clean.rs` has a custom implementation of removing a tree
`fn rm_rf` that used `std::path::Path::{is_file, is_dir, exists}` while
recursively deleting directories and files.  Unfortunately, `Path`'s
implementation of `is_file()` and `is_dir()` and `exists()` always
unconditionally follow symlinks, which is the exact opposite of standard
implementations of deleting file trees.

It appears that this custom implementation is being used to workaround a
behavior in Windows where the files often get marked as read-only, which
prevents us from simply using something nice and simple like
`std::fs::remove_dir_all`, which properly deletes links instead of
following them.

So it looks like the fix is to use `.symlink_metadata()` to figure out
whether tree items are files/symlinks/directories.  The one corner case
this won't cover is if there is a broken symlink in the "root"
`build/$MYARCH` directory, because those initial entries are run through
`Path::canonicalize()`, which panics with broken symlinks.  So lets just
never use symlinks in that one directory. :-)
2017-04-05 23:51:41 -04:00
Corey Farwell
083c7a93be Rollup merge of #41011 - CleanCut:bootstrap-help, r=alexcrichton
Overhaul Bootstrap (x.py) Command-Line-Parsing & Help Output

While working on #40417, I got frustrated with the behavior of x.py and the bootstrap binary it wraps, so I decided to do something about it.  This PR should improve documentation, make the command-line-parsing more flexible, and clean up some of the internals.  No command that worked before should stop working.  At least that's the theory. :-)

This should resolve at least #40920 and #38373.

Changes:

- No more manual args manipulation -- getopts used everywhere except the one place it's not possible.  As a result, options can be in any position, now, even before the subcommand.
- The additional options for test, bench, and dist now appear in the help output.
- No more single-letter variable bindings used internally for large scopes.
- Don't output the time measurement when just invoking `x.py` or explicitly passing `-h` or `--help`
- Logic is now much more linear.  We build strings up, and then print them.
- Refer to subcommands as subcommands everywhere (some places we were saying "command")
- Other minor stuff.

@alexcrichton This is my first PR. Do I need to do something specific to request reviewers or anything?
2017-04-05 23:51:40 -04:00
Corey Farwell
a97a9d9d00 Rollup merge of #40908 - dotdash:pers_lt, r=arielb1
Emit proper lifetime start intrinsics for personality slots

We currently only emit a single call to the lifetime start intrinsic
for the personality slot alloca. This happens because we create that
call at the time that we create the alloca, instead of creating it each
time we start using it. Because LLVM usually removes the alloca before
the lifetime intrinsics are even considered, this didn't cause any
problems yet, but we should fix this anyway.
2017-04-05 23:51:39 -04:00
bors
1a9b382168 Auto merge of #40805 - vadimcn:msys-mingw, r=alexcrichton
[Windows] Enable building rustc with "pthreads" flavor of mingw.

Tested on mingw-w64 packaged with msys2.

r? @alexcrichton

cc #40123
2017-04-06 03:42:31 +00:00
Jorge Aparicio
bbe5411587 document the implementation a bit more 2017-04-05 21:11:22 -05:00
Jorge Aparicio
ecddad6920 don't test for the absence of BAR in the rmake test
it's not related to this feature
2017-04-05 21:06:53 -05:00
Jorge Aparicio
c1635d7e61 cast the #[used] static to *i8
to match the type signature of the llvm.used variable
2017-04-05 21:02:52 -05:00
bors
6cd15a0e8f Auto merge of #41098 - arielb1:rollup, r=arielb1
Rollup of 12 pull requests

- Successful merges: #40479, #40561, #40709, #40815, #40909, #40927, #40943, #41015, #41028, #41052, #41054, #41065
- Failed merges:
2017-04-06 01:00:15 +00:00
Ariel Ben-Yehuda
d8b61091f6 Rollup merge of #41065 - jorendorff:slice-rsplit-41020, r=alexcrichton
[T]::rsplit() and rsplit_mut(), #41020
2017-04-05 23:01:13 +00:00
Ariel Ben-Yehuda
fa0f1027d1 Rollup merge of #41054 - anatol:master, r=alexcrichton
Replace magic number with readable sig constant

SIG_ERR is defined as 'pub const SIG_ERR: sighandler_t = !0 as sighandler_t;'
2017-04-05 23:01:12 +00:00
Ariel Ben-Yehuda
a69fcfaecf Rollup merge of #41052 - topecongiro:overlapping_inherent_impls, r=estebank
Make 'overlapping_inherent_impls' lint a hard error

This is ought to be implemented in PR #40728. Unfortunately, when I rebased the PR to resolve merge conflict, the "hard error" code disappeared. This PR complements the initial PR.

Now the following rust code gives the following error:
```rust
struct Foo;

impl Foo {
    fn id() {}
}

impl Foo {
    fn id() {}
}

fn main() {}
```
```
error[E0592]: duplicate definitions with name `id`
 --> /home/topecongiro/test.rs:4:5
  |
4 |     fn id() {}
  |     ^^^^^^^^^^ duplicate definitions for `id`
...
8 |     fn id() {}
  |     ---------- other definition for `id`

error: aborting due to previous error
```
2017-04-05 23:01:11 +00:00
Ariel Ben-Yehuda
5e410ba5ef Rollup merge of #41028 - bluss:rev-rfind, r=alexcrichton
Let .rev()'s find use the underlying rfind and vice versa

- Connect the plumbing in an obvious way from Rev's find → underlying rfind and vice versa
- A style change in the provided implementation for Iterator::rfind, using simple next_back when it is enough
2017-04-05 23:01:10 +00:00