]> git.lizzy.rs Git - rust.git/log
rust.git
6 years agoRollup merge of #51226 - gnzlbg:nonzero_align, r=SimonSapin
Mark Simulacrum [Sun, 3 Jun 2018 01:55:06 +0000 (19:55 -0600)]
Rollup merge of #51226 - gnzlbg:nonzero_align, r=SimonSapin

Make Layout's align a NonZeroUsize

This PR makes the `Layout`'s align field a `NonZeroUsize` since it cannot ever be zero, not even while building a `Layout`. It also contains some drive-by minor cleanups over the docs and the code, like updating the documented error types, or using the `size()` and `align()` methods instead of accessing the fields directly (the latter was required for the `NonZeroUsize` change anyways).

r? @SimonSapin

cc @Amanieu

6 years agoRollup merge of #51143 - Mark-Simulacrum:issue-50826, r=cramertj
Mark Simulacrum [Sun, 3 Jun 2018 01:55:04 +0000 (19:55 -0600)]
Rollup merge of #51143 - Mark-Simulacrum:issue-50826, r=cramertj

Specify that packed types must derive, not implement, Copy

6 years agoAuto merge of #51310 - Mark-Simulacrum:rollup, r=Mark-Simulacrum
bors [Sat, 2 Jun 2018 21:32:47 +0000 (21:32 +0000)]
Auto merge of #51310 - Mark-Simulacrum:rollup, r=Mark-Simulacrum

Rollup of 6 pull requests

Successful merges:

 - #50167 ( Add as_nanos function to Duration)
 - #50919 (Provide more context for what the {f32,f64}::EPSILON values represent.)
 - #51124 (Reword {ptr,mem}::replace docs.)
 - #51147 (Stabilize SliceIndex trait.)
 - #51291 (Fix typos of ‘ambiguous’)
 - #51302 (Permit building rustdoc without compiler artifacts)

Failed merges:

6 years agoRollup merge of #51302 - Mark-Simulacrum:rustdoc-fast, r=QuietMisdreavus
Mark Simulacrum [Sat, 2 Jun 2018 19:14:28 +0000 (13:14 -0600)]
Rollup merge of #51302 - Mark-Simulacrum:rustdoc-fast, r=QuietMisdreavus

Permit building rustdoc without compiler artifacts

None

6 years agoRollup merge of #51291 - evincarofautumn:master, r=oli-obk
Mark Simulacrum [Sat, 2 Jun 2018 19:14:27 +0000 (13:14 -0600)]
Rollup merge of #51291 - evincarofautumn:master, r=oli-obk

Fix typos of ‘ambiguous’

I had trouble finding this code because of the typo after it was [referenced in a tweet](https://twitter.com/bstrie/status/1002751044605153280). Also fixes an identical but unrelated typo in a comment.

6 years agoRollup merge of #51147 - tmccombs:sliceindex, r=SimonSapin
Mark Simulacrum [Sat, 2 Jun 2018 19:14:25 +0000 (13:14 -0600)]
Rollup merge of #51147 - tmccombs:sliceindex, r=SimonSapin

Stabilize SliceIndex trait.

CC #35729

According to recommendations in
https://github.com/rust-lang/rust/issues/35729#issuecomment-377784884

6 years agoRollup merge of #51124 - frewsxcv:frewsxcv-replace, r=QuietMisdreavus
Mark Simulacrum [Sat, 2 Jun 2018 19:14:24 +0000 (13:14 -0600)]
Rollup merge of #51124 - frewsxcv:frewsxcv-replace, r=QuietMisdreavus

Reword {ptr,mem}::replace docs.

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

6 years agoRollup merge of #50919 - frewsxcv:frewsxcv-epsilon, r=steveklabnik
Mark Simulacrum [Sat, 2 Jun 2018 19:14:23 +0000 (13:14 -0600)]
Rollup merge of #50919 - frewsxcv:frewsxcv-epsilon, r=steveklabnik

Provide more context for what the {f32,f64}::EPSILON values represent.

Introduce the 'machine epsilon' term because if one googles 'epsilon', they might stumble upon https://en.wikipedia.org/wiki/Epsilon_numbers_(mathematics) instead of https://en.wikipedia.org/wiki/Machine_epsilon

6 years agoRollup merge of #50167 - fintelia:duration-nanos, r=sfackler
Mark Simulacrum [Sat, 2 Jun 2018 19:14:22 +0000 (13:14 -0600)]
Rollup merge of #50167 - fintelia:duration-nanos, r=sfackler

 Add as_nanos function to Duration

Duration has historically lacked a way to get the actual number of nanoseconds it contained as a normal Rust type because u64 was of insufficient range, and f64 of insufficient precision. The u128 type solves both issues, so I propose adding an `as_nanos` function to expose the capability.

6 years agoRustdoc itself no longer requires proc macros to build
Mark Simulacrum [Sat, 2 Jun 2018 13:50:35 +0000 (07:50 -0600)]
Rustdoc itself no longer requires proc macros to build

This avoids a full compiler build in order to build and/or run tests for
rustdoc.

6 years agoAuto merge of #51063 - mixi:musl-bootstrap, r=alexcrichton
bors [Sat, 2 Jun 2018 15:26:26 +0000 (15:26 +0000)]
Auto merge of #51063 - mixi:musl-bootstrap, r=alexcrichton

Fix building rustc on and for musl hosts.

This fixes all problems I had when trying to compile rustc on a musl-based distribution (with `crt-static = false` in `config.toml`).

This is a fixed version of what ended up being #50105, making it possible to compile rustc on musl targets.

The differences to the old (now merged and subsequently reverted) pull request are:
 - The commit (6d9154a830dd9773fe8a4e34e1fc3dfb1ca6f935) that caused the regression for which the original commits were reverted in #50709 is left out. This means the corresponding bug #36710 is still not fixed with `+crt-static`.
 - The test for issue 36710 is skipped for musl targets (until the issue is properly fixed).
 - Building cargo-vendor if `crt-static = false` is needed was broken (cargo-vendor links to some shared libraries if they exist on the system and this produces broken binaries with `+crt-static`)

CC @alexcrichton

6 years agoadd missing inline's and optimizations
gnzlbg [Sat, 2 Jun 2018 14:11:57 +0000 (16:11 +0200)]
add missing inline's and optimizations

6 years agoremove debug_assert in padding_needed_for
gnzlbg [Sat, 2 Jun 2018 14:03:33 +0000 (16:03 +0200)]
remove debug_assert in padding_needed_for

6 years agoSpecify that packed types must derive, not implement, Copy
Mark Simulacrum [Mon, 28 May 2018 23:54:12 +0000 (17:54 -0600)]
Specify that packed types must derive, not implement, Copy

6 years agoAuto merge of #51274 - nikomatsakis:issue-46557-promote-ref-mut, r=eddyb
bors [Sat, 2 Jun 2018 13:22:38 +0000 (13:22 +0000)]
Auto merge of #51274 - nikomatsakis:issue-46557-promote-ref-mut, r=eddyb

also check `let` arms and nested patterns for mutable borrows

Fixes #46557

r? @eddyb

6 years agoAuto merge of #51015 - nikomatsakis:issue-50672-remove-extern-crate-idiom, r=alexcrichton
bors [Sat, 2 Jun 2018 11:14:14 +0000 (11:14 +0000)]
Auto merge of #51015 - nikomatsakis:issue-50672-remove-extern-crate-idiom, r=alexcrichton

merge unused-extern-crate and unnecessary-extern-crate lints

Extend the `unused_extern_crates` lint to offer a suggestion to remove the extern crate and remove the `unnecessary_extern_crate` lint.

Still a few minor issues to fix:
- [x] this *does* now leave a blank line... (defer to https://github.com/rust-lang/rust/issues/51176)
  - idea: extend the span to be replaced by 1 character if the next character is a `\n`
- [x] what about macros? do we need to watch out for that? (defer to https://github.com/rust-lang/rust/issues/48704)
- [x] also it doesn't work for `extern crate foo; fn main() { foo::bar(); }`
  - this is subtle: the `foo` might be shadowing a glob import too, can't always remove
  - defer to https://github.com/rust-lang/rust/issues/51177
- [x] we also don't do the `pub use` rewrite thang (https://github.com/rust-lang/rust/issues/51013)

Spun off from https://github.com/rust-lang/rust/pull/51010

Fixes #50672

r? @alexcrichton

6 years agoAuto merge of #50554 - clarcharr:from_bool, r=TimNN
bors [Sat, 2 Jun 2018 07:50:10 +0000 (07:50 +0000)]
Auto merge of #50554 - clarcharr:from_bool, r=TimNN

Add From<bool> for int types

Fixes #46109.

6 years agoFix typos of 'ambiguous'
Jon Purdy [Sat, 2 Jun 2018 07:20:00 +0000 (00:20 -0700)]
Fix typos of 'ambiguous'

6 years agoReword {ptr,mem}::replace docs.
Corey Farwell [Mon, 28 May 2018 12:36:14 +0000 (08:36 -0400)]
Reword {ptr,mem}::replace docs.

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

6 years agoAuto merge of #51270 - nicokoch:issue-51266, r=TimNN
bors [Sat, 2 Jun 2018 03:06:26 +0000 (03:06 +0000)]
Auto merge of #51270 - nicokoch:issue-51266, r=TimNN

fs: copy: Add EPERM to fallback error conditions

Fixes #51266

6 years agoAuto merge of #51287 - Mark-Simulacrum:rollup, r=Mark-Simulacrum
bors [Sat, 2 Jun 2018 00:58:29 +0000 (00:58 +0000)]
Auto merge of #51287 - Mark-Simulacrum:rollup, r=Mark-Simulacrum

Rollup of 5 pull requests

Successful merges:

 - #51135 (Tweak output on E0599 for assoc fn used as method)
 - #51152 (Replace `if` with `if and only if` in the definition dox of `Sync`)
 - #51262 (Add missing whitespace in num example)
 - #51272 (Remove feature flag from fs::read_to_string example)
 - #51286 (Pull 1.26.2 release notes into master)

Failed merges:

6 years agoRollup merge of #51286 - Mark-Simulacrum:1.26.2-release-notes, r=Mark-Simulacrum
Mark Simulacrum [Fri, 1 Jun 2018 23:25:18 +0000 (17:25 -0600)]
Rollup merge of #51286 - Mark-Simulacrum:1.26.2-release-notes, r=Mark-Simulacrum

Pull 1.26.2 release notes into master

None

6 years agoRollup merge of #51272 - steveklabnik:remove_feature_flag, r=QuietMisdreavus
Mark Simulacrum [Fri, 1 Jun 2018 23:25:17 +0000 (17:25 -0600)]
Rollup merge of #51272 - steveklabnik:remove_feature_flag, r=QuietMisdreavus

Remove feature flag from fs::read_to_string example

This is stable, and so no longer needed

6 years agoRollup merge of #51262 - GuillaumeGomez:add-missing-whitespace, r=QuietMisdreavus
Mark Simulacrum [Fri, 1 Jun 2018 23:25:16 +0000 (17:25 -0600)]
Rollup merge of #51262 - GuillaumeGomez:add-missing-whitespace, r=QuietMisdreavus

Add missing whitespace in num example

r? @QuietMisdreavus

6 years agoRollup merge of #51152 - crlf0710:patch-1, r=kennytm
Mark Simulacrum [Fri, 1 Jun 2018 23:25:14 +0000 (17:25 -0600)]
Rollup merge of #51152 - crlf0710:patch-1, r=kennytm

Replace `if` with `if and only if` in the definition dox of `Sync`

The old text was: "The precise definition is: a type `T` is `Sync` if `&T` is Send."

Since we've also got
```
impl<'a, T> Send for &'a T
where
    T: Sync + ?Sized,
```
I purpose we can change the `if` to `if and only if` to make it more precise.

6 years agoRollup merge of #51135 - estebank:sugg-7575, r=oli-obk
Mark Simulacrum [Fri, 1 Jun 2018 23:25:13 +0000 (17:25 -0600)]
Rollup merge of #51135 - estebank:sugg-7575, r=oli-obk

Tweak output on E0599 for assoc fn used as method

 - Use suggestion instead of `help` when possible
 - Add primary span label
 - Remove incorrect `help` suggestion using incorrect syntax
 - Do not refer to only one possible candidate as `candidate #1`, refer to it as `the candidate`

6 years agoPull in release notes from stable
Mark Simulacrum [Fri, 1 Jun 2018 23:23:52 +0000 (17:23 -0600)]
Pull in release notes from stable

6 years agoAuto merge of #50108 - Zoxc:sync-gcx, r=mw
bors [Fri, 1 Jun 2018 22:49:43 +0000 (22:49 +0000)]
Auto merge of #50108 - Zoxc:sync-gcx, r=mw

Make GlobalCtxt thread-safe

r? @michaelwoerister

6 years agoAdd @ithinuel's tests from #50597
Clar Charr [Sun, 20 May 2018 18:56:46 +0000 (14:56 -0400)]
Add @ithinuel's tests from #50597

6 years agoFix ambiguity in Result test
Clar Charr [Sun, 20 May 2018 18:52:08 +0000 (14:52 -0400)]
Fix ambiguity in Result test

6 years agoAdd From<bool> for int types
Clar Charr [Wed, 9 May 2018 01:38:22 +0000 (21:38 -0400)]
Add From<bool> for int types

6 years agoAuto merge of #51163 - Amanieu:hashmap_layout, r=SimonSapin
bors [Fri, 1 Jun 2018 18:25:19 +0000 (18:25 +0000)]
Auto merge of #51163 - Amanieu:hashmap_layout, r=SimonSapin

Simplify HashMap layout calculation by using Layout

`RawTable` uses a single allocation to hold both the array of hashes and the array of key/value pairs. This PR changes `RawTable` to use `Layout` when calculating the amount of memory to allocate instead of performing the calculation manually.

r? @SimonSapin

6 years agoSimplify HashMap layout calculation by using Layout
Amanieu d'Antras [Tue, 29 May 2018 11:09:09 +0000 (13:09 +0200)]
Simplify HashMap layout calculation by using Layout

6 years agoAuto merge of #50340 - Emerentius:master, r=alexcrichton
bors [Fri, 1 Jun 2018 16:16:30 +0000 (16:16 +0000)]
Auto merge of #50340 - Emerentius:master, r=alexcrichton

optimize joining for slices

This improves the speed of string joining up to 3x.
It removes the boolean flag check every iteration, eliminates repeated bounds checks and adds a fast paths for small separators up to a len of 4 bytes
These optimizations gave me ~10%, ~50% and ~80% improvements respectively over the previous speed. Those are multiplicative.

3x improvement happens for the optimal case of joining many small strings together in my microbenchmarks. Improvements flatten out for larger strings of course as more time is spent copying bits around. I've run a few benchmarks [with this code](https://github.com/Emerentius/join_bench). They are pretty noise despite high iteration counts, but in total one can see the trends.

```
len_separator  len_string   n_strings     speedup
           4          10          10        2.38
           4          10         100        3.41
           4          10        1000        3.43
           4          10       10000        3.25
           4         100          10        2.23
           4         100         100        2.73
           4         100        1000        1.33
           4         100       10000        1.14
           4        1000          10        1.33
           4        1000         100        1.15
           4        1000        1000        1.08
           4        1000       10000        1.04
          10          10          10        1.61
          10          10         100        1.74
          10          10        1000        1.77
          10          10       10000        1.75
          10         100          10        1.58
          10         100         100        1.65
          10         100        1000        1.24
          10         100       10000        1.12
          10        1000          10        1.23
          10        1000         100        1.11
          10        1000        1000        1.05
          10        1000       10000       0.997
         100          10          10        1.66
         100          10         100        1.78
         100          10        1000        1.28
         100          10       10000        1.16
         100         100          10        1.37
         100         100         100        1.26
         100         100        1000        1.09
         100         100       10000         1.0
         100        1000          10        1.19
         100        1000         100        1.12
         100        1000        1000        1.05
         100        1000       10000        1.12
```

The string joining with small or empty separators is now ~50% faster than the old concatenation (small strings). The same approach can also improve the performance of joining into vectors.

If this approach is acceptable, I can apply it for concatenation and for vectors as well. Alternatively, concat could just call `.join("")`.

6 years agoincorporate changes from code review
Emerentius [Fri, 25 May 2018 21:53:22 +0000 (23:53 +0200)]
incorporate changes from code review

further reduce unsafe fn calls
reduce right drift
assert! sufficient capacity

6 years agocompacts join code
Emerentius [Wed, 23 May 2018 05:20:37 +0000 (07:20 +0200)]
compacts join code

6 years agoadd more join tests
Emerentius [Mon, 7 May 2018 15:37:13 +0000 (17:37 +0200)]
add more join tests

old tests cover the new fast path of str joining already
this adds tests for joining into Strings with long separators (>4 byte) and
for joining into Vec<T>, T: Clone + !Copy. Vec<T: Copy> will be
specialised when specialisation type inference bugs are fixed.

6 years agooptimize joining and concatenation for slices
Emerentius [Mon, 30 Apr 2018 11:09:10 +0000 (13:09 +0200)]
optimize joining and concatenation for slices

for both Vec<T> and String
- eliminates the boolean first flag in fn join()

for String only
- eliminates repeated bounds checks in join(), concat()
- adds fast paths for small string separators up to a len of 4 bytes

6 years agorework to report errors from crates in a consistent order
Niko Matsakis [Tue, 29 May 2018 15:31:34 +0000 (11:31 -0400)]
rework to report errors from crates in a consistent order

We first collect unused crates into a map and then walk all extern
crates in crate order.

6 years agomerge UNNECESSARY_EXTERN_CRATE and UNUSED_EXTERN_CRATES
Niko Matsakis [Fri, 25 May 2018 20:53:49 +0000 (16:53 -0400)]
merge UNNECESSARY_EXTERN_CRATE and UNUSED_EXTERN_CRATES

6 years agoextend `unused_extern_crates` lint with a suggestion to remove
Niko Matsakis [Wed, 23 May 2018 23:25:59 +0000 (19:25 -0400)]
extend `unused_extern_crates` lint with a suggestion to remove

6 years agoalso check `let` arms and nested patterns for mutable borrows
Niko Matsakis [Fri, 1 Jun 2018 13:41:44 +0000 (09:41 -0400)]
also check `let` arms and nested patterns for mutable borrows

6 years agoAuto merge of #51264 - glandium:oom, r=alexcrichton
bors [Fri, 1 Jun 2018 14:05:57 +0000 (14:05 +0000)]
Auto merge of #51264 - glandium:oom, r=alexcrichton

Make the OOM hook return `()` rather than `!`

Per discussion in https://github.com/rust-lang/rust/issues/51245#issuecomment-393651083

This allows more flexibility in what can be done with the API. This also
splits `rtabort!` into `dumb_print` happening in the default hook and
`abort_internal`, happening in the actual oom handler after calling the
hook. Registering an empty function thus makes the oom handler not print
anything but still abort.

Cc: @alexcrichton
6 years agoAdd Sync impl for Slice
John Kåre Alsaker [Fri, 1 Jun 2018 13:22:37 +0000 (15:22 +0200)]
Add Sync impl for Slice

6 years agoUpdate Cargo.lock
John Kåre Alsaker [Fri, 1 Jun 2018 13:00:17 +0000 (15:00 +0200)]
Update Cargo.lock

6 years agoAssert that GlobalCtxt is Sync
John Kåre Alsaker [Fri, 20 Apr 2018 10:47:19 +0000 (12:47 +0200)]
Assert that GlobalCtxt is Sync

6 years agoHave worker-local GlobalArenas
John Kåre Alsaker [Mon, 22 Jan 2018 13:31:23 +0000 (14:31 +0100)]
Have worker-local GlobalArenas

6 years agoAdd a WorkerLocal abstraction
John Kåre Alsaker [Fri, 11 May 2018 14:28:28 +0000 (16:28 +0200)]
Add a WorkerLocal abstraction

6 years agoUpdate recursion limits
John Kåre Alsaker [Sat, 3 Mar 2018 05:22:19 +0000 (06:22 +0100)]
Update recursion limits

6 years agoEnsure ImplicitCtxt is Sync
John Kåre Alsaker [Wed, 25 Apr 2018 23:03:54 +0000 (01:03 +0200)]
Ensure ImplicitCtxt is Sync

6 years agoFix optimization_fuel
John Kåre Alsaker [Tue, 17 Apr 2018 18:09:40 +0000 (20:09 +0200)]
Fix optimization_fuel

6 years agoFix OneThread
John Kåre Alsaker [Fri, 20 Apr 2018 21:50:10 +0000 (23:50 +0200)]
Fix OneThread

6 years agoRemove feature flag from fs::read_to_string example
steveklabnik [Fri, 1 Jun 2018 12:24:36 +0000 (08:24 -0400)]
Remove feature flag from fs::read_to_string example

This is stable, and so no longer needed

6 years agoAuto merge of #51181 - mbrubeck:prelude, r=petrochenkov
bors [Fri, 1 Jun 2018 10:48:14 +0000 (10:48 +0000)]
Auto merge of #51181 - mbrubeck:prelude, r=petrochenkov

Add std/core to prelude if extern_prelude enabled

Fixes #50605

6 years agoAuto merge of #51060 - michaelwoerister:thread-safe-consts, r=Zoxc
bors [Fri, 1 Jun 2018 08:46:38 +0000 (08:46 +0000)]
Auto merge of #51060 - michaelwoerister:thread-safe-consts, r=Zoxc

Make const decoding thread-safe.

This is an alternative to https://github.com/rust-lang/rust/pull/50957. It's a proof of concept (e.g. it doesn't adapt metadata decoding, just the incr. comp. cache) but I think it turned out nice. It's rather simple and does not require passing around a bunch of weird closures, like we currently do.

If you (@Zoxc & @oli-obk) think this approach is good then I'm happy to finish and clean this up.

Note: The current version just spins when it encounters an in-progress decoding. I don't have a strong preference for this approach. Decoding concurrently is equally fine by me (or maybe even better because it doesn't require poisoning).

r? @Zoxc

6 years agoRemove outdated AllocId decoding function.
Michael Woerister [Tue, 29 May 2018 08:52:36 +0000 (10:52 +0200)]
Remove outdated AllocId decoding function.

6 years agoMake metadata decoding use AllocDecodingState/Session.
Michael Woerister [Tue, 29 May 2018 08:26:26 +0000 (10:26 +0200)]
Make metadata decoding use AllocDecodingState/Session.

6 years agoMake const decoding from the incremental cache thread-safe.
Michael Woerister [Fri, 25 May 2018 15:19:31 +0000 (17:19 +0200)]
Make const decoding from the incremental cache thread-safe.

6 years agoAdd TinyList data structure.
Michael Woerister [Mon, 28 May 2018 15:43:53 +0000 (17:43 +0200)]
Add TinyList data structure.

6 years agofs: copy: Add EPERM to fallback error conditions
Nicolas Koch [Fri, 1 Jun 2018 07:32:20 +0000 (09:32 +0200)]
fs: copy: Add EPERM to fallback error conditions

Fixes #51266

6 years agoAuto merge of #51225 - oli-obk:miri_oob_ptr, r=eddyb
bors [Fri, 1 Jun 2018 06:42:12 +0000 (06:42 +0000)]
Auto merge of #51225 - oli-obk:miri_oob_ptr, r=eddyb

Fix the miri submodule

cc @bjorn3

r? @eddyb

6 years agoStabilize SliceIndex trait.
Thayne McCombs [Tue, 29 May 2018 02:19:39 +0000 (20:19 -0600)]
Stabilize SliceIndex trait.

Fixes #35729

According to recommendations in
https://github.com/rust-lang/rust/issues/35729#issuecomment-377784884

6 years agoAuto merge of #51171 - faern:const-bswap-ctpop-cttz-ctlz, r=oli-obk
bors [Fri, 1 Jun 2018 03:24:54 +0000 (03:24 +0000)]
Auto merge of #51171 - faern:const-bswap-ctpop-cttz-ctlz, r=oli-obk

Make some std::intrinsics `const fn`s

Making some rustc intrinsics (`ctpop`, `cttz`, `ctlz` and `bswap`) `const fn`s.

This is a pre-step to being able to make `swap_bytes`, `to_be` and `from_be` constant functions. That in itself could be ergonomic and useful. But even better is that it would allow `Ipv4Addr::new` etc becoming `const fn`s as well. Which might be really useful since I find it quite common to want to define them as constants.

r? @oli-obk

6 years agoReplace `if` with `if and only if` in the definition dox of `Sync`
CrLF0710 [Tue, 29 May 2018 07:58:50 +0000 (15:58 +0800)]
Replace `if` with `if and only if` in the definition dox of `Sync`

The old text was: "The precise definition is: a type T is Sync if &T is Send."

Since we've also got
```
impl<'a, T> Send for &'a T
where
    T: Sync + ?Sized,
```
I purpose we can change the `if` to `if and only if` to make it more precise.

6 years agoAuto merge of #50836 - jsgf:arc-downcast, r=SimonSapin
bors [Fri, 1 Jun 2018 01:09:25 +0000 (01:09 +0000)]
Auto merge of #50836 - jsgf:arc-downcast, r=SimonSapin

Arc downcast

Implement `downcast` for `Arc<Any + Send + Sync>` as part of #44608, and gated by the same `rc_downcast` feature.

This PR is mostly lightly-edited cut'n'paste.

This has two additional changes:
- The `downcast` implementation needs `Any + Send + Sync` implementations for `is` and `Debug`, and I added `downcast_ref` and `downcast_mut` for completeness/consistency. (Can these be insta-stabilized?)
- At @SimonSapin's suggestion, I converted `Arc` and `Rc` to use `NonNull::cast` to avoid an `unsafe` block in each which tidied things up nicely.

6 years agoMake the OOM hook return `()` rather than `!`
Mike Hommey [Thu, 31 May 2018 23:50:07 +0000 (08:50 +0900)]
Make the OOM hook return `()` rather than `!`

Per discussion in https://github.com/rust-lang/rust/issues/51245#issuecomment-393651083

This allows more flexibility in what can be done with the API. This also
splits `rtabort!` into `dumb_print` happening in the default hook and
`abort_internal`, happening in the actual oom handler after calling the
hook. Registering an empty function thus makes the oom handler not print
anything but still abort.

Cc: @alexcrichton
6 years agoAdd missing whitespace in num example
Guillaume Gomez [Thu, 31 May 2018 23:29:22 +0000 (01:29 +0200)]
Add missing whitespace in num example

6 years agoAuto merge of #51096 - matthewjasper:reverse-normalization-bounds, r=nikomatsakis
bors [Thu, 31 May 2018 22:58:37 +0000 (22:58 +0000)]
Auto merge of #51096 - matthewjasper:reverse-normalization-bounds, r=nikomatsakis

Register outlives predicates from queries the right way around.

Closes #49354
The region constraints from queries need to be reversed from sub to outlives.

Note: wf checking reports these errors before NLL, so I'm not sure if there's any case when these predicates need to be created at all.

cc @nikomatsakis

6 years agoAuto merge of #51257 - GuillaumeGomez:rollup, r=GuillaumeGomez
bors [Thu, 31 May 2018 20:44:04 +0000 (20:44 +0000)]
Auto merge of #51257 - GuillaumeGomez:rollup, r=GuillaumeGomez

Rollup of 7 pull requests

Successful merges:

 - #49546 (Stabilize short error format)
 - #51123 (Update build instructions)
 - #51146 (typeck: Do not pass the field check on field error)
 - #51193 (Fixes some style issues in rustdoc "implementations on Foreign types")
 - #51213 (fs: copy: Use File::set_permissions instead of fs::set_permissions)
 - #51227 (mod.rs isn't beautiful)
 - #51240 (Two minor parsing tweaks)

Failed merges:

6 years agoFix up Any doc examples
Jeremy Fitzhardinge [Fri, 18 May 2018 15:18:44 +0000 (08:18 -0700)]
Fix up Any doc examples

Make the Any+Send+Sync examples use the right trait bounds, and fix a small whitespace issue.

6 years agoUpdate `Arc` and `Rc` to use `NonNull::cast` to cast the inner pointers
Jeremy Fitzhardinge [Thu, 17 May 2018 15:25:48 +0000 (08:25 -0700)]
Update `Arc` and `Rc` to use `NonNull::cast` to cast the inner pointers

This avoids an `unsafe` block in each case.

6 years agoImplement `downcast` for `Arc<Any + Send + Sync>`
Jeremy Fitzhardinge [Thu, 17 May 2018 15:17:35 +0000 (08:17 -0700)]
Implement `downcast` for `Arc<Any + Send + Sync>`

We only need to implement it for `Any + Send + Sync` because in practice
that's the only useful combination for `Arc` and `Any`.

Implementation for #44608 under the `rc_downcast` feature.

6 years agoAdd implementations for Any + Send + Sync
Jeremy Fitzhardinge [Thu, 17 May 2018 06:09:58 +0000 (23:09 -0700)]
Add implementations for Any + Send + Sync

Implement `is`, `downcast_ref`, `downcast_mut` and `Debug` for
`Any + Send + Sync`.

6 years agoRollup merge of #51240 - nnethercote:parse-2, r=nikomatsakis
Guillaume Gomez [Thu, 31 May 2018 20:17:16 +0000 (22:17 +0200)]
Rollup merge of #51240 - nnethercote:parse-2, r=nikomatsakis

Two minor parsing tweaks

6 years agoRollup merge of #51227 - uuttff8:master, r=dtolnay
Guillaume Gomez [Thu, 31 May 2018 20:17:15 +0000 (22:17 +0200)]
Rollup merge of #51227 - uuttff8:master, r=dtolnay

mod.rs isn't beautiful

I hate this spaces.

6 years agoRollup merge of #51213 - nicokoch:copy_permissions, r=cramertj
Guillaume Gomez [Thu, 31 May 2018 20:17:14 +0000 (22:17 +0200)]
Rollup merge of #51213 - nicokoch:copy_permissions, r=cramertj

fs: copy: Use File::set_permissions instead of fs::set_permissions

We already got the open file descriptor at this point.
Don't make the kernel resolve the path again.

6 years agoRollup merge of #51193 - GuillaumeGomez:fixes-style-issues, r=QuietMisdreavus
Guillaume Gomez [Thu, 31 May 2018 20:17:13 +0000 (22:17 +0200)]
Rollup merge of #51193 - GuillaumeGomez:fixes-style-issues, r=QuietMisdreavus

Fixes some style issues in rustdoc "implementations on Foreign types"

Fixes #51113.

r? @QuietMisdreavus

6 years agoRollup merge of #51146 - dlrobertson:fix_51102, r=estebank
Guillaume Gomez [Thu, 31 May 2018 20:17:12 +0000 (22:17 +0200)]
Rollup merge of #51146 - dlrobertson:fix_51102, r=estebank

typeck: Do not pass the field check on field error

If a struct pattern has a field error return an error.

Fixes: #51102
6 years agoRollup merge of #51123 - akoserwal:master, r=Mark-Simulacrum
Guillaume Gomez [Thu, 31 May 2018 20:17:10 +0000 (22:17 +0200)]
Rollup merge of #51123 - akoserwal:master, r=Mark-Simulacrum

Update build instructions

It get stuck at the cloning step.
`./x.py build `
Updating only changed submodules
Updating submodule src/llvm
Submodule 'src/llvm' (https://github.com/rust-lang/llvm.git) registered for path 'src/llvm'
Cloning into '/home/username/rust/src/llvm'...

6 years agoRollup merge of #49546 - GuillaumeGomez:stabilize-short-error-format, r=oli-obk
Guillaume Gomez [Thu, 31 May 2018 20:17:09 +0000 (22:17 +0200)]
Rollup merge of #49546 - GuillaumeGomez:stabilize-short-error-format, r=oli-obk

Stabilize short error format

r? @oli-obk

Added in https://github.com/rust-lang/rust/pull/44636

6 years agoRegister outlives predicates from queries the right way around.
Matthew Jasper [Sat, 26 May 2018 10:47:38 +0000 (11:47 +0100)]
Register outlives predicates from queries the right way around.

6 years agoUpdate build instructions
Abhishek koserwal [Mon, 28 May 2018 11:57:15 +0000 (17:27 +0530)]
Update build instructions

6 years agoMake short-error format GNU compatible
Guillaume Gomez [Thu, 3 May 2018 21:18:49 +0000 (23:18 +0200)]
Make short-error format GNU compatible

6 years agoStabilize short error format
Guillaume Gomez [Sat, 31 Mar 2018 22:10:34 +0000 (00:10 +0200)]
Stabilize short error format

6 years agoAuto merge of #51050 - symphorien:fstatat, r=kennytm
bors [Thu, 31 May 2018 17:47:12 +0000 (17:47 +0000)]
Auto merge of #51050 - symphorien:fstatat, r=kennytm

std::fs::DirEntry.metadata(): use fstatat instead of lstat when possible

When reading a directory with `read_dir`, querying metadata for a resulting `DirEntry` is done by building the whole path and then `lstat`ing it, which requires the kernel to resolve the whole path. Instead, one
can use the file descriptor to the enumerated directory and use `fstatat`. This make the resolving step
unnecessary.
This PR implements using `fstatat` on linux, android and emscripten.

## Compatibility across targets
`fstatat` is POSIX.
* Linux >= 2.6.19 according to https://linux.die.net/man/2/fstatat
* android according to https://android.googlesource.com/platform/bionic/+/master/libc/libc.map.txt#392
* emscripten according to https://github.com/kripken/emscripten/blob/7f89560101843198787530731f40a65288f6f15f/system/include/libc/sys/stat.h#L76

The man page says "A similar system call exists on Solaris." but I haven't found it.

## Compatibility with old platforms
This was introduced with glibc 2.4 according to the man page. The only information I could find about the minimal version of glibc rust must support is this discussion https://internals.rust-lang.org/t/bumping-glibc-requirements-for-the-rust-toolchain/5111/10
The conclusion, if I understand correctly, is that currently rust supports glibc >= 2.3.4 but the "real" requirement is Centos 5 with glibc 2.5. This PR would make the minimal version 2.4, so this should be fine.

## Benefit
I did the following silly benchmark:
```rust
use std::io;
use std::fs;
use std::os::linux::fs::MetadataExt;
use std::time::Instant;

fn main() -> Result<(), io::Error> {
    let mut n = 0;
    let mut size = 0;
    let start = Instant::now();
    for entry in fs::read_dir("/nix/store/.links")? {
        let entry = entry?;
        let stat = entry.metadata()?;
        size += stat.st_size();
        n+=1;
    }
    println!("{} files, size {}, time {:?}", n, size, Instant::now().duration_since(start));
    Ok(())
}
```
On warm cache, with current rust nightly:
```
1014099 files, size 76895290022, time Duration { secs: 2, nanos: 65832118 }
```
(between 2.1 and 2.9 seconds usually)
With this PR:
```
1014099 files, size 76895290022, time Duration { secs: 1, nanos: 581662953 }
```
(1.5 to 1.6 seconds usually).

approximately 40% faster :)

On cold cache there is not much to gain because path lookup (which we spare) would have been a cache hit:
Before
```
1014099 files, size 76895290022, time Duration { secs: 391, nanos: 739874992 }
```
After
```
1014099 files, size 76895290022, time Duration { secs: 388, nanos: 431567396 }
```
## Testing
The tests were run on linux `x86_64`
```
python x.py test src/tools/tidy
./x.py test src/libstd
```
and the above benchmark.
I did not test any other target.

6 years agoRename num -> bits and num -> out_val
Linus Färnstrand [Thu, 31 May 2018 17:43:56 +0000 (19:43 +0200)]
Rename num -> bits and num -> out_val

6 years agoRename bytes -> bits
Linus Färnstrand [Thu, 31 May 2018 17:21:34 +0000 (19:21 +0200)]
Rename bytes -> bits

6 years agolibstd/sys/unix/fs.rs: fix compilation on fuchsia
Guillaume Girol [Thu, 31 May 2018 17:18:58 +0000 (19:18 +0200)]
libstd/sys/unix/fs.rs: fix compilation on fuchsia

6 years agoRewrite numeric_intrinsic without macro
Linus Färnstrand [Wed, 30 May 2018 21:27:11 +0000 (23:27 +0200)]
Rewrite numeric_intrinsic without macro

6 years agoAdd test for intrinsics::bswap
Linus Färnstrand [Tue, 29 May 2018 14:00:01 +0000 (16:00 +0200)]
Add test for intrinsics::bswap

6 years agoMake ctpop, cttz, ctlz and bswap const fns
Linus Färnstrand [Tue, 29 May 2018 09:41:10 +0000 (11:41 +0200)]
Make ctpop, cttz, ctlz and bswap const fns

6 years agoAuto merge of #51235 - nikomatsakis:issue-51117-borrowck-implicit-deref, r=eddyb
bors [Thu, 31 May 2018 15:24:04 +0000 (15:24 +0000)]
Auto merge of #51235 - nikomatsakis:issue-51117-borrowck-implicit-deref, r=eddyb

remove notion of Implicit derefs from mem-cat

`PointerKind` is included in `LoanPath` and hence forms part of the equality check; this led to having two unequal paths that both represent `*x`, depending on whether the `*` was inserted automatically or explicitly. Bad mojo.

Fixes #51117

r? @eddyb

6 years agotypeck: Do not pass the field check on field error
Dan Robertson [Tue, 29 May 2018 01:51:36 +0000 (01:51 +0000)]
typeck: Do not pass the field check on field error

If a struct pattern has a field error return an error.

6 years agochange `PointerKind::Implicit` to a note
Niko Matsakis [Thu, 31 May 2018 14:17:51 +0000 (10:17 -0400)]
change `PointerKind::Implicit` to a note

`PointerKind` is included in `LoanPath` and hence forms part of the
equality check; this led to having two unequal paths that both
represent `*x`, depending on whether the `*` was inserted
automatically or explicitly. Bad mojo. The `note` field, in contrast,
is intended more-or-less primarily for this purpose of adding extra
data.

6 years agoAdd std/core to prelude if extern_prelude enabled
Matt Brubeck [Tue, 29 May 2018 18:26:10 +0000 (11:26 -0700)]
Add std/core to prelude if extern_prelude enabled

Fixes #50605

6 years agoAuto merge of #51203 - nnethercote:obligations-2, r=michaelwoerister
bors [Thu, 31 May 2018 13:14:18 +0000 (13:14 +0000)]
Auto merge of #51203 - nnethercote:obligations-2, r=michaelwoerister

Two minor `obligation_forest` tweaks.

Pretty minimal improvements, but improvements nonetheless.

6 years agoUse builder.cargo() for cargo-vendor.
Johannes Nixdorf [Fri, 25 May 2018 11:08:54 +0000 (13:08 +0200)]
Use builder.cargo() for cargo-vendor.

This makes it go through boostrap/bin/rustc.rs, so it will use
-crt-static if needed.

6 years agobuilder.cargo(): don't add "--target"/"--release" to cargo install
Johannes Nixdorf [Fri, 25 May 2018 12:04:27 +0000 (14:04 +0200)]
builder.cargo(): don't add "--target"/"--release" to cargo install

This is required to use builder.cargo for cargo-vendor.

6 years agoAdd a test for issue 36710.
Johannes Nixdorf [Wed, 2 May 2018 08:26:00 +0000 (10:26 +0200)]
Add a test for issue 36710.

This still expectedly fails for musl targets with +crt-static.

6 years agocompiletest: escape CXX the same way as CC for MSVC
Johannes Nixdorf [Thu, 10 May 2018 08:58:51 +0000 (10:58 +0200)]
compiletest: escape CXX the same way as CC for MSVC