Commit graph

63012 commits

Author SHA1 Message Date
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
Ariel Ben-Yehuda b712950d7b Rollup merge of #41015 - arielb1:new-block-stack, r=alexcrichton
mark build::cfg::start_new_block as inline(never)

LLVM has a bug - [PR32488](https://bugs.llvm.org//show_bug.cgi?id=32488) - where it fails to deduplicate allocas in some
circumstances. The function `start_new_block` has allocas totalling 1216
bytes, and when LLVM inlines several copies of that function into
the recursive function `expr::into`, that function's stack space usage
goes into tens of kiBs, causing stack overflows.

Mark `start_new_block` as inline(never) to keep it from being inlined,
getting stack usage under control.

Fixes #40493.
Fixes #40573.

r? @eddyb
2017-04-05 23:01:09 +00:00
Ariel Ben-Yehuda 9d074473da Rollup merge of #40943 - Amanieu:offset_to, r=alexcrichton
Add ptr::offset_to

This PR adds a method to calculate the signed distance (in number of elements) between two pointers. The resulting value can then be passed to `offset` to get one pointer from the other. This is similar to pointer subtraction in C/C++.

There are 2 special cases:

- If the distance is not a multiple of the element size then the result is rounded towards zero. (in C/C++ this is UB)
-  ZST return `None`, while normal types return `Some(isize)`. This forces the user to handle the ZST case in unsafe code. (C/C++ doesn't have ZSTs)
2017-04-05 23:01:08 +00:00
Ariel Ben-Yehuda fc5ff66b04 Rollup merge of #40927 - stjepang:docs-atomic-overflow-note, r=alexcrichton
Add a note about overflow for fetch_add/fetch_sub

Fixes #40916
Fixes #34618

r? @steveklabnik
2017-04-05 23:01:07 +00:00
Ariel Ben-Yehuda 1fdcb7958b Rollup merge of #40909 - nagisa:fix-vec-placement, r=alexcrichton
Allow using Vec::<T>::place_back for T: !Clone

The place_back was likely put into block with `T: Clone` bound by mistake.
2017-04-05 23:01:06 +00:00
Ariel Ben-Yehuda cee0508021 Rollup merge of #40815 - estebank:issue-40006, r=GuillaumeGomez
Identify missing item category in `impl`s

```rust
struct S;
impl S {
    pub hello_method(&self) {
        println!("Hello");
    }
}
fn main() { S.hello_method(); }
```

```rust
error: missing `fn` for method declaration
 --> file.rs:3:4
  |
3 |     pub hello_method(&self) {
  |        ^ missing `fn`
```

Fix #40006. r? @pnkfelix CC @jonathandturner @GuillaumeGomez
2017-04-05 23:01:06 +00:00
Ariel Ben-Yehuda a18202792a Rollup merge of #40709 - lifthrasiir:leaner-unicode-debug-str, r=alexcrichton
Reduce a table used for `Debug` impl of `str`.

This commit shrinks the size of the aforementioned table from 2,102 bytes to 1,197 bytes. This is achieved by an observation that most `u16` entries are common in its upper byte. Specifically:

- `SINGLETONS` now uses two tables, one for (upper byte, lower count) and another for a series of lower bytes. For each upper byte given number of lower bytes are read and compared.

- `NORMAL` now uses a variable length format for the count of "true" codepoints and "false" codepoints (one byte with MSB unset, or two big-endian bytes with the first MSB set).

The code size and relative performance roughly remains same as this commit tries to optimize for both. The new table and algorithm has been verified for the equivalence to older ones.

In my x86-64 macOS laptop with `rustc 1.17.0-nightly (0aeb9c129 2017-03-15)`, `-C opt-level=3 -C lto` gives the following:

* The old routine compiles to 2,102 bytes of data and 416 bytes of code.
* The new routine compiles to 1,197 bytes of data and 448 bytes of code.

Counting a number of all printable Unicode scalar values (128,003, if you wonder) by filtering `0..0x110000` with `std::char::from_u32` and `is_printable` took 50±7ms for both. This can be surprising as the new routine *has* to do more calculations; this is partly explained by the fact that a linear search of `SINGLETONS` has been replaced by *two* linear searches for upper and lower bytes, which greatly reduces the iteration count.
2017-04-05 23:01:05 +00:00
Ariel Ben-Yehuda 327b9be9e9 Rollup merge of #40561 - arthurprs:hm-adapt2, r=pczarn
Simplify HashMap Bucket interface

> Simplify HashMap Bucket interface
>
> * Store capacity_mask instead of capacity
> * Move bucket index into RawBucket
> * Valid bucket index is now always within [0..table_capacity)
> * Simplify iterators by moving logic into RawBuckets
> * Clone RawTable using RawBucket
> * Make retain aware of the number of elements

The idea was to put idx in RawBucket instead of the other Bucket types and simplify next() and prev() as much as possible. The rest was a side-effect of that change, except maybe the last 2.

This change makes iteration and other next/prev() heavy operations noticeably faster. Clone is way faster.

```
➜  hashmap2 git:(adapt) ✗ cargo benchcmp pre:: adp:: bench.txt
 name                        pre:: ns/iter  adp:: ns/iter  diff ns/iter   diff %
 clone_10_000                74,364         39,736              -34,628  -46.57%
 grow_100_000                8,343,553      8,233,785          -109,768   -1.32%
 grow_10_000                 817,825        723,958             -93,867  -11.48%
 grow_big_value_100_000      18,418,979     17,906,186         -512,793   -2.78%
 grow_big_value_10_000       1,219,242      1,103,334          -115,908   -9.51%
 insert_1000                 74,546         58,343              -16,203  -21.74%
 insert_100_000              6,743,770      6,238,017          -505,753   -7.50%
 insert_10_000               798,079        719,123             -78,956   -9.89%
 insert_1_000_000            275,215,605    266,975,875      -8,239,730   -2.99%
 insert_int_bigvalue_10_000  1,517,387      1,419,838           -97,549   -6.43%
 insert_str_10_000           316,179        278,896             -37,283  -11.79%
 insert_string_10_000        770,927        747,449             -23,478   -3.05%
 iter_keys_100_000           386,099        333,104             -52,995  -13.73%
 iterate_100_000             387,320        355,707             -31,613   -8.16%
 lookup_100_000              206,757        193,063             -13,694   -6.62%
 lookup_100_000_unif         219,366        193,180             -26,186  -11.94%
 lookup_1_000_000            206,456        205,716                -740   -0.36%
 lookup_1_000_000_unif       659,934        629,659             -30,275   -4.59%
 lru_sim                     20,194,334     18,442,149       -1,752,185   -8.68%
 merge_shuffle               1,168,044      1,063,055          -104,989   -8.99%
```

Note 2: I may have messed up porting the diff, let's see what CI says.
2017-04-05 23:01:04 +00:00
Ariel Ben-Yehuda 540fc2c546 Rollup merge of #40479 - sezaru:master, r=alexcrichton
Fixes other targets rustlibs installation

When the user select more than one target to generate rustlibs for, rustbuild will only install the host one.

This patch fixes it, more info in https://github.com/rust-lang/rust/issues/39235#issuecomment-285878858
2017-04-05 23:01:03 +00:00
bors 91ae22a012 Auto merge of #40348 - nrc:save-extern-fn, r=eddyb
Handle extern functions and statics in save-analysis

r? @eddyb
2017-04-05 20:06:00 +00:00
Jon Gjengset 2598e4574e
Add safe wrapper for atomic_singlethreadfence_* 2017-04-05 15:46:55 -04:00
Jorge Aparicio c759eea7a6 fix location of the emitted object file 2017-04-05 13:59:58 -05:00
Jorge Aparicio bc1bd8a609 add tracking issue and feature-gate and run-make tests 2017-04-05 13:59:53 -05:00
raph 4e1147f340 Add example to std::process::abort
This is a second (2/3?) 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-05 20:41:43 +02:00
Jorge Aparicio 4c7e277340 add an #[used] attribute
similar to GCC's __attribute((used))__. This attribute prevents LLVM from
optimizing away a non-exported symbol, within a compilation unit (object file),
when there are no references to it.

This is better explained with an example:

```
#[used]
static LIVE: i32 = 0;

static REFERENCED: i32 = 0;

static DEAD: i32 = 0;

fn internal() {}

pub fn exported() -> &'static i32 {
    &REFERENCED
}
```

Without optimizations, LLVM pretty much preserves all the static variables and
functions within the compilation unit.

```
$ rustc --crate-type=lib --emit=obj symbols.rs && nm -C symbols.o
0000000000000000 t drop::h1be0f8f27a2ba94a
0000000000000000 r symbols::REFERENCED::hb3bdfd46050bc84c
0000000000000000 r symbols::DEAD::hc2ea8f9bd06f380b
0000000000000000 r symbols::LIVE::h0970cf9889edb56e
0000000000000000 T symbols::exported::h6f096c2b1fc292b2
0000000000000000 t symbols::internal::h0ac1aadbc1e3a494
```

With optimizations, LLVM will drop dead code. Here `internal` is dropped because
it's not a exported function/symbol (i.e. not `pub`lic). `DEAD` is dropped for
the same reason. `REFERENCED` is preserved, even though it's not exported,
because it's referenced by the `exported` function. Finally, `LIVE` survives
because of the `#[used]` attribute even though it's not exported or referenced.

```
$ rustc --crate-type=lib -C opt-level=3 --emit=obj symbols.rs && nm -C symbols.o
0000000000000000 r symbols::REFERENCED::hb3bdfd46050bc84c
0000000000000000 r symbols::LIVE::h0970cf9889edb56e
0000000000000000 T symbols::exported::h6f096c2b1fc292b2
```

Note that the linker knows nothing about `#[used]` and will drop `LIVE`
because no other object references to it.

```
$ echo 'fn main() {}' >> symbols.rs
$ rustc symbols.rs && nm -C symbols | grep LIVE
```

At this time, `#[used]` only works on `static` variables.
2017-04-05 13:40:11 -05:00
Alex Crichton 631f761f18 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-05 11:10:48 -07:00
bors 46f71a03f9 Auto merge of #41086 - frewsxcv:rollup, r=frewsxcv
Rollup of 19 pull requests

- Successful merges: #40608, #40870, #40949, #40977, #40981, #40988, #40992, #40997, #40999, #41007, #41014, #41019, #41035, #41043, #41049, #41062, #41066, #41076, #41085
- Failed merges:
2017-04-05 16:47:45 +00:00
Corey Farwell 97a1f4b1f4 Rollup merge of #41085 - nagisa:fix-output-properg, r=alexcrichton
Properly adjust filenames when multiple emissions

Fixes #40993

Should backport just fine to beta but not sure if we want to do this since this is quite old stable regression.
2017-04-05 12:44:40 -04:00
Corey Farwell d0d05f5dd3 Rollup merge of #41076 - alexcrichton:update-sccache, r=frewsxcv
travis: Update sccache binaries

I've tracked down what I believe is the last spurious sccache failure on #40240
to behavior in mio (carllerche/mio#583), and this commit updates the binaries to
a version which has that fix incorporated.
2017-04-05 12:44:39 -04:00
Corey Farwell f56b46c0ee Rollup merge of #41066 - steveklabnik:fix-links, r=frewsxcv
Fix links

part of https://github.com/rust-lang/rust/issues/40912

[]\n() is not actually a link.

r? @frewsxcv @GuillaumeGomez
2017-04-05 12:44:38 -04:00
Corey Farwell 1b6d25b185 Rollup merge of #41062 - estebank:private-field, r=arielb1
Do not recommend private fields called as method

```rust
error: no method named `dog_age` found for type `animal::Dog` in the current scope
  --> $DIR/private-field.rs:26:23
   |
26 |     let dog_age = dog.dog_age();
   |                       ^^^^^^^ private field, not a method
```
Fix #27654.
2017-04-05 12:44:38 -04:00
Corey Farwell 92875f3198 Rollup merge of #41049 - GuillaumeGomez:rustdoc-ordered-list, r=frewsxcv
Handle ordered lists as well

Part of #40912.

r? @rust-lang/docs
2017-04-05 12:44:36 -04:00
Corey Farwell 2213912d5a Rollup merge of #41043 - GuillaumeGomez:sup_balise, r=steveklabnik
Replace ^ with <sup> html balise

r? @steveklabnik
2017-04-05 12:44:36 -04:00
Corey Farwell 6251e4bb35 Rollup merge of #41035 - jmesmon:revert-bad-raw-fd-impls, r=aturon
Revert "Implement AsRawFd/IntoRawFd for RawFd"

This reverts commit 2cf686f2cd (#40842)

RawFd is a type alias for c_int, which is itself a type alias for i32.
As a result, adding AsRawFd and IntoRawFd impls for RawFd actually adds
them for i32.

As a result, the reverted commit makes this valid:

```
use std::os::unix::io::AsRawFd;

fn arf<T: AsRawFd>(_: T) {}

fn main() {
    arf(32i32)
}
```

Implimenting AsRawFd and IntoRawFd for i32 breaks the promises of both
those traits that their methods return a valid RawFd.

r? @aturon
cc @Mic92 @kamalmarhubi
2017-04-05 12:44:35 -04:00
Corey Farwell 5935fe47a9 Rollup merge of #41019 - mandeep:fix-vec-swapremove-docs, r=BurntSushi
Fixed typo in doc comments for swap_remove

While reading the Vec docs, I came across the docs for swap_remove. I believe there is a typo in the comment and ```return``` should be ```returns```. This PR fixes this issue.

I also feel that the entire doc comment is a bit of a run-on and could be changed to something along the lines of ```Removes an element from anywhere in the vector and returns it. The vector is mutated and the removed element is replaced by the last element of the vector. ```

Thoughts?
2017-04-05 12:44:33 -04:00
Corey Farwell 56b6830527 Rollup merge of #41014 - SimonSapin:patch-6, r=frewsxcv
std::thread docs: fix link to current()
2017-04-05 12:44:33 -04:00
Corey Farwell 263d5a0daf Rollup merge of #41007 - pgerber:dir_builder, r=frewsxcv
Improve documentation for `std::fs::DirBuilder`
2017-04-05 12:44:32 -04:00
Corey Farwell 4ed4c41e48 Rollup merge of #40999 - irfanhudda:improve-option-docs, r=steveklabnik
Improve option API docs

Associated Issue: #29366

Improve `option` API docs for
* `IntoIter` struct
* `Iter` struct
* `IterMut` struct

r? @steveklabnik
2017-04-05 12:44:31 -04:00
Corey Farwell 325848abe4 Rollup merge of #40997 - donniebishop:from_utf8_linking, r=steveklabnik
Added links to types in from_utf8 description

References #29375. Link to types mentioned in the documentation for `from_utf8` (`str`, `&[u8`], etc). Paragraphs were reformatted to keep any one line from being excessively long, but are otherwise unchanged.
2017-04-05 12:44:30 -04:00
Corey Farwell fd474f0b2e Rollup merge of #40992 - donniebishop:utf8err_linking, r=alexcrichton
Added links to from_utf8 methods in Utf8Error

Referencing  #29375. Linked the `from_utf8` methods for both `String` and `str` in the description. Also linked the `u8` to its documentation
2017-04-05 12:44:29 -04:00
Corey Farwell 469fe7a1a3 Rollup merge of #40988 - eugene-bulkin:ascii-docs, r=frewsxcv
API Docs: ascii

Add/update docs for the `ascii` module per #29341.

r? @steveklabnik
2017-04-05 12:44:28 -04:00
Corey Farwell b0aefe31f4 Rollup merge of #40981 - Technius:master, r=steveklabnik
Add links and some examples to std::sync::mpsc docs

Addresses part of #29377
r? @steveklabnik

I took a stab at adding links to the `std::sync::mpsc` docs, and I also wrote a few examples.

Edit: Whoops, typed in `?r` instead of `r?`.
2017-04-05 12:44:27 -04:00
Corey Farwell 1a9f415bfb Rollup merge of #40977 - projektir:BarrierWaitResult_doc, r=steveklabnik
Updating the description for BarrierWaitResult #29377

Referencing `Barrier`, removing reference to `is_leader`.
2017-04-05 12:44:26 -04:00
Corey Farwell 7412f701e8 Rollup merge of #40949 - stjepang:fix-vecdeque-docs, r=frewsxcv
Improve some docs for VecDeque

r? @GuillaumeGomez
2017-04-05 12:44:25 -04:00
Corey Farwell 0239880dde Rollup merge of #40870 - alexcrichton:stabilize-windows-subsystem, r=aturon
rustc: Stabilize the `#![windows_subsystem]` attribute

This commit stabilizes the `#![windows_subsystem]` attribute which is a
conservative exposure of the `/SUBSYSTEM` linker flag on Widnows platforms. This
is useful for creating applications as well as console programs.

Closes #37499
2017-04-05 12:44:25 -04:00
Corey Farwell ca37f1ad17 Rollup merge of #40608 - GuillaumeGomez:mutex-doc-inconsistency, r=steveklabnik
Fix mutex's docs inconsistency

Fixes #40176.

r? @steveklabnik
cc @rust-lang/docs
2017-04-05 12:44:24 -04:00
Kang Seonghoon 44bcd261a7 Reduce a table used for Debug impl of str.
This commit shrinks the size of the aforementioned table from
2,102 bytes to 1,197 bytes. This is achieved by an observation that
most u16 entries are common in its upper byte. Specifically:

- SINGLETONS now uses two tables, one for (upper byte, lower count)
  and another for a series of lower bytes. For each upper byte given
  number of lower bytes are read and compared.

- NORMAL now uses a variable length format for the count of "true"
  codepoints and "false" codepoints (one byte with MSB unset, or
  two big-endian bytes with the first MSB set).

The code size and relative performance roughly remains same as this
commit tries to optimize for both. The new table and algorithm has
been verified for the equivalence to older ones.
2017-04-05 09:13:19 -07:00
Simonas Kazlauskas 201b1a9032 Properly adjust filenames when multiple emissions
Fixes #40993
2017-04-05 19:02:25 +03:00
steveklabnik b5cedb7c4e tidy clean and small text fix 2017-04-05 11:58:53 -04:00
QuietMisdreavus 36bc448c00 style: space between struct name and opening brace 2017-04-05 10:02:37 -05:00
bors ad5dfecc6a Auto merge of #40811 - estebank:issue-32540, r=jonathandturner
Point at last valid token on failed `expect_one_of`

```rust
error: expected one of `.`, `;`, `?`, `}`, or an operator, found `)`
  --> $DIR/token-error-correct-3.rs:29:9
   |
25 |         foo()
   |              - expected one of `.`, `;`, `?`, `}`, or an operator after this
...
29 |     } else {
   |     ^ unexpected token
```

Fix #32540.
2017-04-05 09:23:27 +00:00
Josh Stone 608e8fe16c 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-05 00:41:08 -07:00
Amanieu d'Antras 1f70247446 Add tracking issue for offset_to 2017-04-05 07:45:44 +01:00
GitLab 56902fbe71 Fixes other targets rustlibs installation
When the user select more than one target to generate rustlibs for, rustbuild will only install the host one.

This patch fixes it, more info in https://github.com/rust-lang/rust/issues/39235#issuecomment-285878858
2017-04-04 17:16:42 -07:00
Alex Crichton e60ea55f66 travis: Update sccache binaries
I've tracked down what I believe is the last spurious sccache failure on #40240
to behavior in mio (carllerche/mio#583), and this commit updates the binaries to
a version which has that fix incorporated.
2017-04-04 15:55:23 -07:00
Aidan Hobson Sayers b970bc2a79 Enable appveyor cache, add more paranoia 2017-04-04 23:41:38 +01:00
arthurprs f07ebd6097 Simplify HashMap Bucket interface
* Store capacity_mask instead of capacity
* Move bucket index into RawBucket
* Bucket index is now always within [0..table_capacity)
* Clone RawTable using RawBucket
* Simplify iterators by moving logic into RawBuckets
* Make retain aware of the number of elements
2017-04-04 22:43:27 +02:00