Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 12 pull requests #51214

Closed
wants to merge 30 commits into from
Closed

Rollup of 12 pull requests #51214

wants to merge 30 commits into from

Conversation

kennytm
Copy link
Member

@kennytm kennytm commented May 30, 2018

Successful merges:

Failed merges:

symphorien and others added 18 commits May 24, 2018 23:50
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.
Fixes rust-lang#47275. These two macros are similar, but different, and could do with documentation links to each other.
It now details why using compile_error!() is different from just not having the final macro_rules!() branch.
This commit adds a new section to the Documentation Test docs, which briefly mentions indented code blocks, and links to the CommonMark specification for both.

I’m not sure about saying "fenced code blocks the more popular choice in the Rust community” because it seems like I’m speaking for everyone, but I can’t think of a better way to phrase it!
If a struct pattern has a field error return an error.
…are now exactly the same as that produced by AST borrowck. Bravo!
It's never used in a meaningful way.
We already got the open file descriptor at this point.
Don't make the kernel resolve the path again.
Because they are small and hot.
@rust-highfive
Copy link
Collaborator

r? @aidanhs

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label May 30, 2018
@kennytm
Copy link
Member Author

kennytm commented May 30, 2018

@bors r+ p=10

@bors
Copy link
Contributor

bors commented May 30, 2018

📌 Commit be32243 has been approved by kennytm

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 30, 2018
@bors
Copy link
Contributor

bors commented May 30, 2018

🔒 Merge conflict

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels May 30, 2018
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.
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'...
…uillaumeGomez

Add doc link from discriminant struct to function.

None
typeck: Do not pass the field check on field error

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

Fixes: rust-lang#51102
…dtolnay

Move slice::exact_chunks directly above exact_chunks_mut for more con…

…sistent docs order

See rust-lang#47115 (comment)
… r=GuillaumeGomez

Link panic and compile_error docs

This adds documentation links between `panic!()` and `compile_error!()` as per rust-lang#47275, which points out that they’re similar. It also adds a sentence to the `compile_error()` docs I thought could be added.
Mention spec and indented blocks in doctest docs

Fixes rust-lang#49717.

This commit adds a new section to the Documentation Test docs, which briefly mentions indented code blocks, and links to the CommonMark specification for both.

I’m not sure about saying "fenced code blocks the more popular choice in the Rust community” because it seems like I’m speaking for everyone, but I can’t think of a better way to phrase it!
…derr-files, r=oli-obk

Remove two redundant .nll.stderr files

It turns out that the diagnostics generated from NLL for these cases are now exactly the same as that produced by AST borrowck, and thus we can just fallback on those `.stderr` files that already exist for AST-borrowck.

Bravo!

(it is a good idea to remove these files, because it slightly reduces the amount of time humans will spend reviewing the .nll.stderr fileset...)

((it *might* be worthwhile trying to change the `compiletest` code to even issue a warning when two such files have equivalent contents... but I am not going so far as to try to implement that right now...))
…lwoerister

Two minor `obligation_forest` tweaks.

Pretty minimal improvements, but improvements nonetheless.
@kennytm
Copy link
Member Author

kennytm commented May 30, 2018

@bors r+

@bors
Copy link
Contributor

bors commented May 30, 2018

📌 Commit 7bf60b7 has been approved by kennytm

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels May 30, 2018
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.
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.
@kennytm kennytm changed the title Rollup of 10 pull requests Rollup of 12 pull requests May 30, 2018
@kennytm
Copy link
Member Author

kennytm commented May 30, 2018

@bors r+

Added #51213, #51152.

@bors
Copy link
Contributor

bors commented May 30, 2018

📌 Commit b7b7b25 has been approved by kennytm

@bors
Copy link
Contributor

bors commented May 30, 2018

⌛ Testing commit b7b7b25 with merge ab61e34...

bors added a commit that referenced this pull request May 30, 2018
Rollup of 12 pull requests

Successful merges:

 - #51050 (std::fs::DirEntry.metadata(): use fstatat instead of lstat when possible)
 - #51123 (Update build instructions)
 - #51127 (Add doc link from discriminant struct to function.)
 - #51146 (typeck: Do not pass the field check on field error)
 - #51147 (Stabilize SliceIndex trait.)
 - #51151 (Move slice::exact_chunks directly above exact_chunks_mut for more con…)
 - #51152 (Replace `if` with `if and only if` in the definition dox of `Sync`)
 - #51153 (Link panic and compile_error docs)
 - #51158 (Mention spec and indented blocks in doctest docs)
 - #51186 (Remove two redundant .nll.stderr files)
 - #51203 (Two minor `obligation_forest` tweaks.)
 - #51213 (fs: copy: Use File::set_permissions instead of fs::set_permissions)

Failed merges:
@bors
Copy link
Contributor

bors commented May 30, 2018

💔 Test failed - status-travis

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels May 30, 2018
@rust-highfive
Copy link
Collaborator

The job dist-various-2 of your PR failed on Travis (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
[01:01:14] [RUSTC-TIMING] panic_abort test:false 0.137
[01:01:20] [RUSTC-TIMING] alloc test:false 7.407
[01:01:20]    Compiling panic_unwind v0.0.0 (file:///checkout/src/libpanic_unwind)
[01:01:20] [RUSTC-TIMING] panic_unwind test:false 0.314
[01:01:24] error[E0609]: no field `dirp` on type `&mut sys::unix::fs::ReadDir`
[01:01:24]    --> libstd/sys/unix/fs.rs:232:52
[01:01:24]     |
[01:01:24] 232 |                 let entry_ptr = libc::readdir(self.dirp.0);
[01:01:24] 
[01:01:26] error: aborting due to previous error
[01:01:26] 
[01:01:26] For more information about this error, try `rustc --explain E0609`.
[01:01:26] For more information about this error, try `rustc --explain E0609`.
[01:01:26] [RUSTC-TIMING] std test:false 5.772
[01:01:26] error: Could not compile `std`.
[01:01:26] 
[01:01:26] Caused by:
[01:01:26]   process didn't exit successfully: `/checkout/obj/build/bootstrap/debug/rustc --crate-name std libstd/lib.rs --color always --error-format json --crate-type dylib --crate-type rlib --emit=dep-info,link -C prefer-dynamic -C opt-level=2 --cfg feature="alloc_jemalloc" --cfg feature="backtrace" --cfg feature="jemalloc" --cfg feature="panic-unwind" --cfg feature="panic_unwind" -C metadata=3fed1de603a2895b -C extra-filename=-3fed1de603a2895b --out-dir /checkout/obj/build/x86_64-unknown-linux-gnu/stage2-std/x86_64-unknown-fuchsia/release/deps --target x86_64-unknown-fuchsia -L dependency=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-std/x86_64-unknown-fuchsia/release/deps -L dependency=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-std/release/deps --extern alloc_jemalloc=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-std/x86_64-unknown-fuchsia/release/deps/liballoc_jemalloc-ef3d35b058f29bdc.rlib --extern alloc=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-std/x86_64-unknown-fuchsia/release/deps/liballoc-4f4f362b39a7ae79.rlib --extern libc=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-std/x86_64-unknown-fuchsia/release/deps/liblibc-1d1ad3278eec445a.rlib --extern core=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-std/x86_64-unknown-fuchsia/release/deps/libcore-32cc14345520ec4a.rlib --extern unwind=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-std/x86_64-unknown-fuchsia/release/deps/libunwind-ed8fc7ec397df7ff.rlib --extern std_unicode=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-std/x86_64-unknown-fuchsia/release/deps/libstd_unicode-a73afe93d98762e2.rlib --extern panic_unwind=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-std/x86_64-unknown-fuchsia/release/deps/libpanic_unwind-6864429c0391c9fa.rlib --extern panic_abort=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-std/x86_64-unknown-fuchsia/release/deps/libpanic_abort-09154b7a50d1d88a.rlib --extern alloc_system=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-std/x86_64-unknown-fuchsia/release/deps/liballoc_system-37dcefab5d368769.rlib --extern compiler_builtins=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-std/x86_64-unknown-fuchsia/release/deps/libcompiler_builtins-96b7e577a9b42ad9.rlib -l backtrace -l zircon -l fdio -l launchpad -L native=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-std/x86_64-unknown-fuchsia/release/build/compiler_builtins-aa886a5ffe5369ef/out` (exit code: 101)
[01:01:26] command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "build" "--target" "x86_64-unknown-fuchsia" "-j" "4" "--release" "--locked" "--color" "always" "--features" "panic-unwind jemalloc backtrace" "--manifest-path" "/checkout/src/libstd/Cargo.toml" "--message-format" "json"
[01:01:26] expected success, got: exit code: 101
[01:01:26] thread 'main' panicked at 'cargo must succeed', bootstrap/compile.rs:1091:9
[01:01:26] travis_fold:end:stage2-std

[01:01:26] travis_time:end:stage2-std:start=1527712333488201725,finish=1527712416797898541,duration=83309696816

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

1 similar comment
@rust-highfive
Copy link
Collaborator

The job dist-various-2 of your PR failed on Travis (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
[01:01:14] [RUSTC-TIMING] panic_abort test:false 0.137
[01:01:20] [RUSTC-TIMING] alloc test:false 7.407
[01:01:20]    Compiling panic_unwind v0.0.0 (file:///checkout/src/libpanic_unwind)
[01:01:20] [RUSTC-TIMING] panic_unwind test:false 0.314
[01:01:24] error[E0609]: no field `dirp` on type `&mut sys::unix::fs::ReadDir`
[01:01:24]    --> libstd/sys/unix/fs.rs:232:52
[01:01:24]     |
[01:01:24] 232 |                 let entry_ptr = libc::readdir(self.dirp.0);
[01:01:24] 
[01:01:26] error: aborting due to previous error
[01:01:26] 
[01:01:26] For more information about this error, try `rustc --explain E0609`.
[01:01:26] For more information about this error, try `rustc --explain E0609`.
[01:01:26] [RUSTC-TIMING] std test:false 5.772
[01:01:26] error: Could not compile `std`.
[01:01:26] 
[01:01:26] Caused by:
[01:01:26]   process didn't exit successfully: `/checkout/obj/build/bootstrap/debug/rustc --crate-name std libstd/lib.rs --color always --error-format json --crate-type dylib --crate-type rlib --emit=dep-info,link -C prefer-dynamic -C opt-level=2 --cfg feature="alloc_jemalloc" --cfg feature="backtrace" --cfg feature="jemalloc" --cfg feature="panic-unwind" --cfg feature="panic_unwind" -C metadata=3fed1de603a2895b -C extra-filename=-3fed1de603a2895b --out-dir /checkout/obj/build/x86_64-unknown-linux-gnu/stage2-std/x86_64-unknown-fuchsia/release/deps --target x86_64-unknown-fuchsia -L dependency=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-std/x86_64-unknown-fuchsia/release/deps -L dependency=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-std/release/deps --extern alloc_jemalloc=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-std/x86_64-unknown-fuchsia/release/deps/liballoc_jemalloc-ef3d35b058f29bdc.rlib --extern alloc=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-std/x86_64-unknown-fuchsia/release/deps/liballoc-4f4f362b39a7ae79.rlib --extern libc=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-std/x86_64-unknown-fuchsia/release/deps/liblibc-1d1ad3278eec445a.rlib --extern core=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-std/x86_64-unknown-fuchsia/release/deps/libcore-32cc14345520ec4a.rlib --extern unwind=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-std/x86_64-unknown-fuchsia/release/deps/libunwind-ed8fc7ec397df7ff.rlib --extern std_unicode=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-std/x86_64-unknown-fuchsia/release/deps/libstd_unicode-a73afe93d98762e2.rlib --extern panic_unwind=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-std/x86_64-unknown-fuchsia/release/deps/libpanic_unwind-6864429c0391c9fa.rlib --extern panic_abort=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-std/x86_64-unknown-fuchsia/release/deps/libpanic_abort-09154b7a50d1d88a.rlib --extern alloc_system=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-std/x86_64-unknown-fuchsia/release/deps/liballoc_system-37dcefab5d368769.rlib --extern compiler_builtins=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-std/x86_64-unknown-fuchsia/release/deps/libcompiler_builtins-96b7e577a9b42ad9.rlib -l backtrace -l zircon -l fdio -l launchpad -L native=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-std/x86_64-unknown-fuchsia/release/build/compiler_builtins-aa886a5ffe5369ef/out` (exit code: 101)
[01:01:26] command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "build" "--target" "x86_64-unknown-fuchsia" "-j" "4" "--release" "--locked" "--color" "always" "--features" "panic-unwind jemalloc backtrace" "--manifest-path" "/checkout/src/libstd/Cargo.toml" "--message-format" "json"
[01:01:26] expected success, got: exit code: 101
[01:01:26] thread 'main' panicked at 'cargo must succeed', bootstrap/compile.rs:1091:9
[01:01:26] travis_fold:end:stage2-std

[01:01:26] travis_time:end:stage2-std:start=1527712333488201725,finish=1527712416797898541,duration=83309696816

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
rollup A PR which is a rollup S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.
Projects
None yet
Development

Successfully merging this pull request may close these issues.