Commit Graph

78905 Commits

Author SHA1 Message Date
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
Guillaume Gomez
0345dac0d8
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
2018-05-31 22:17:09 +02:00
Matthew Jasper
b83daea479 Register outlives predicates from queries the right way around. 2018-05-31 20:40:25 +01:00
Abhishek koserwal
bad9fefdae Update build instructions 2018-05-31 23:53:23 +05:30
Guillaume Gomez
426b63f8a3 Make short-error format GNU compatible 2018-05-31 20:09:27 +02:00
Guillaume Gomez
177337d5cc Stabilize short error format 2018-05-31 20:09:27 +02:00
bors
5342d40c1f 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 7f89560101/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.
2018-05-31 17:47:12 +00:00
Linus Färnstrand
97a0d46dec Rename num -> bits and num -> out_val 2018-05-31 19:43:56 +02:00
Linus Färnstrand
8939fe60a1 Rename bytes -> bits 2018-05-31 19:21:34 +02:00
Guillaume Girol
8dec03b71a libstd/sys/unix/fs.rs: fix compilation on fuchsia 2018-05-31 19:18:58 +02:00
Linus Färnstrand
0d7d5e994f Rewrite numeric_intrinsic without macro 2018-05-31 19:18:42 +02:00
Linus Färnstrand
12c330c4bf Add test for intrinsics::bswap 2018-05-31 19:18:42 +02:00
Linus Färnstrand
376b6407a8 Make ctpop, cttz, ctlz and bswap const fns 2018-05-31 19:18:42 +02:00
bors
6de4ec679d 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
2018-05-31 15:24:04 +00:00
Dan Robertson
8f6441513e
typeck: Do not pass the field check on field error
If a struct pattern has a field error return an error.
2018-05-31 14:45:49 +00:00
Niko Matsakis
8a624b737a 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.
2018-05-31 10:17:51 -04:00
Matt Brubeck
72ab4b4f01 Add std/core to prelude if extern_prelude enabled
Fixes #50605
2018-05-31 06:37:53 -07:00
bors
ae2f299186 Auto merge of #51203 - nnethercote:obligations-2, r=michaelwoerister
Two minor `obligation_forest` tweaks.

Pretty minimal improvements, but improvements nonetheless.
2018-05-31 13:14:18 +00:00
Johannes Nixdorf
a8be9bdd7b Use builder.cargo() for cargo-vendor.
This makes it go through boostrap/bin/rustc.rs, so it will use
-crt-static if needed.
2018-05-31 12:03:29 +02:00
Johannes Nixdorf
ff8f226cab builder.cargo(): don't add "--target"/"--release" to cargo install
This is required to use builder.cargo for cargo-vendor.
2018-05-31 12:03:29 +02:00
Johannes Nixdorf
81687c4a7f Add a test for issue 36710.
This still expectedly fails for musl targets with +crt-static.
2018-05-31 12:01:50 +02:00
Johannes Nixdorf
665d6673d5 compiletest: escape CXX the same way as CC for MSVC 2018-05-31 12:01:50 +02:00
Johannes Nixdorf
55dab7c820 bootstrap: pass crt-static for the compiler host as well 2018-05-31 12:01:50 +02:00
Johannes Nixdorf
bcab14af3e bootstrap.py: respect crt-static
Bootstrap requires serde_derive, which needs proc-macro crate types, so
it won't work with crt-static.
2018-05-31 12:01:50 +02:00
Johannes Nixdorf
bf3b8df697 musl: don't use the included startfiles with -crt-static
This fixes (only for -crt-static) #36710.
2018-05-31 12:01:50 +02:00
bors
30cae58709 Auto merge of #51182 - eddyb:not-just-visibility, r=nikomatsakis
[MIR] Change "scopes" from "visibility scopes" to "source scopes".

These scopes are already used for source-oriented diagnostics, lint levels and unsafety checks.
This PR generalizes the naming around scopes, making the type `SourceScope`, and flips (across several commits) the relationship/priority between `LocalDecl`'s "visibility" and "syntactic" scopes.

r? @nikomatsakis
2018-05-31 08:55:09 +00:00