Commit Graph

78931 Commits

Author SHA1 Message Date
Clar Charr
7fe56e81b7 Fix ambiguity in Result test 2018-06-01 17:46:19 -04:00
Clar Charr
8c3bdcc35a Add From<bool> for int types 2018-06-01 17:46:19 -04:00
bors
aa094a43cc 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
2018-06-01 18:25:19 +00:00
Amanieu d'Antras
c6bebf4554 Simplify HashMap layout calculation by using Layout 2018-06-01 17:24:03 +01:00
bors
747e655010 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("")`.
2018-06-01 16:16:30 +00:00
Emerentius
12bd288746 incorporate changes from code review
further reduce unsafe fn calls
reduce right drift
assert! sufficient capacity
2018-06-01 17:13:26 +02:00
Emerentius
d0d0885c3f compacts join code 2018-06-01 17:13:25 +02:00
Emerentius
b2fd7da0cf 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.
2018-06-01 17:13:25 +02:00
Emerentius
d866082050 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
2018-06-01 17:13:24 +02:00
Niko Matsakis
b37cc851e6 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.
2018-06-01 11:00:18 -04:00
Niko Matsakis
8b39808ffe merge UNNECESSARY_EXTERN_CRATE and UNUSED_EXTERN_CRATES 2018-06-01 11:00:18 -04:00
Niko Matsakis
d5010ecf44 extend unused_extern_crates lint with a suggestion to remove 2018-06-01 11:00:18 -04:00
Niko Matsakis
a667049c33 also check let arms and nested patterns for mutable borrows 2018-06-01 10:06:02 -04:00
bors
f913231290 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
2018-06-01 14:05:57 +00:00
John Kåre Alsaker
2119d04b2d Add Sync impl for Slice 2018-06-01 15:22:37 +02:00
John Kåre Alsaker
461fa8495e Update Cargo.lock 2018-06-01 15:00:17 +02:00
John Kåre Alsaker
c6dbb14097 Assert that GlobalCtxt is Sync 2018-06-01 14:57:08 +02:00
John Kåre Alsaker
d402d2d0d4 Have worker-local GlobalArenas 2018-06-01 14:57:08 +02:00
John Kåre Alsaker
969296b79b Add a WorkerLocal abstraction 2018-06-01 14:57:07 +02:00
John Kåre Alsaker
b7aabaa3fc Update recursion limits 2018-06-01 14:56:01 +02:00
John Kåre Alsaker
85acb1d046 Ensure ImplicitCtxt is Sync 2018-06-01 14:55:58 +02:00
John Kåre Alsaker
9eb4f7329b Fix optimization_fuel 2018-06-01 14:55:55 +02:00
John Kåre Alsaker
d6c63ec949 Fix OneThread 2018-06-01 14:55:54 +02:00
steveklabnik
48bd07e3a9 Remove feature flag from fs::read_to_string example
This is stable, and so no longer needed
2018-06-01 08:24:36 -04:00
bors
577a5b2703 Auto merge of #51181 - mbrubeck:prelude, r=petrochenkov
Add std/core to prelude if extern_prelude enabled

Fixes #50605
2018-06-01 10:48:14 +00:00
bors
441290291f 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
2018-06-01 08:46:38 +00:00
Michael Woerister
12e8359956 Remove outdated AllocId decoding function. 2018-06-01 09:32:24 +02:00
Michael Woerister
22f6163db4 Make metadata decoding use AllocDecodingState/Session. 2018-06-01 09:32:24 +02:00
Michael Woerister
24dfcbef9c Make const decoding from the incremental cache thread-safe. 2018-06-01 09:32:24 +02:00
Michael Woerister
f9f90ede82 Add TinyList data structure. 2018-06-01 09:32:24 +02:00
Nicolas Koch
2c3eff99f0 fs: copy: Add EPERM to fallback error conditions
Fixes #51266
2018-06-01 09:32:20 +02:00
bors
1dcda69586 Auto merge of #51225 - oli-obk:miri_oob_ptr, r=eddyb
Fix the miri submodule

cc @bjorn3

r? @eddyb
2018-06-01 06:42:12 +00:00
Thayne McCombs
9d770e9959 Stabilize SliceIndex trait.
Fixes #35729

According to recommendations in
https://github.com/rust-lang/rust/issues/35729#issuecomment-377784884
2018-06-01 00:04:26 -06:00
bors
63cd4a39ea 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
2018-06-01 03:24:54 +00:00
CrLF0710
8e90a2d02f 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.
2018-06-01 09:37:05 +08:00
bors
b7a9d4ea74 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.
2018-06-01 01:09:25 +00:00
Mike Hommey
b945be71e8 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
2018-06-01 08:50:07 +09:00
Guillaume Gomez
32dcaab585 Add missing whitespace in num example 2018-06-01 01:29:22 +02:00
bors
efc508ba4c 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
2018-05-31 22:58:37 +00:00
bors
1ffb321477 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:
2018-05-31 20:44:04 +00:00
Jeremy Fitzhardinge
87c3d7bee5 Fix up Any doc examples
Make the Any+Send+Sync examples use the right trait bounds, and fix a small whitespace issue.
2018-05-31 13:27:08 -07:00
Jeremy Fitzhardinge
0c7bf56d80 Update Arc and Rc to use NonNull::cast to cast the inner pointers
This avoids an `unsafe` block in each case.
2018-05-31 13:27:08 -07:00
Jeremy Fitzhardinge
37f5cf563c 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.
2018-05-31 13:27:08 -07:00
Jeremy Fitzhardinge
72433e179d Add implementations for Any + Send + Sync
Implement `is`, `downcast_ref`, `downcast_mut` and `Debug` for
`Any + Send + Sync`.
2018-05-31 13:27:08 -07:00
Guillaume Gomez
7552c2ea64
Rollup merge of #51240 - nnethercote:parse-2, r=nikomatsakis
Two minor parsing tweaks
2018-05-31 22:17:16 +02:00
Guillaume Gomez
33ad846740
Rollup merge of #51227 - uuttff8:master, r=dtolnay
mod.rs isn't beautiful

I hate this spaces.
2018-05-31 22:17:15 +02:00
Guillaume Gomez
af4acbe5e7
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.
2018-05-31 22:17:14 +02:00
Guillaume Gomez
8efecc1102
Rollup merge of #51193 - GuillaumeGomez:fixes-style-issues, r=QuietMisdreavus
Fixes some style issues in rustdoc "implementations on Foreign types"

Fixes #51113.

r? @QuietMisdreavus
2018-05-31 22:17:13 +02:00
Guillaume Gomez
a729d97848
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
2018-05-31 22:17:12 +02:00
Guillaume Gomez
2f0e3d3046
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'...
2018-05-31 22:17:10 +02:00