Commit graph

808 commits

Author SHA1 Message Date
Yuki Okushi
4136ed26a1
Rollup merge of #74979 - maekawatoshiki:fix, r=Mark-Simulacrum
`#![deny(unsafe_op_in_unsafe_fn)]` in sys/hermit

Partial fix of #73904.

This encloses ``unsafe`` operations in ``unsafe fn`` in ``sys/hermit``.
Some unsafe blocks are not well documented because some system-based functions lack documents.
2020-11-07 01:01:59 +09:00
Ivan Tham
e8b5be5dff Stabilize hint::spin_loop
Partially fix #55002, deprecate in another release

Co-authored-by: Ashley Mannix <kodraus@hey.com>

Update stable version for stabilize_spin_loop

Co-authored-by: Joshua Nelson <joshua@yottadb.com>

Use better example for spinlock

As suggested by KodrAus

Remove renamed_spin_loop already available in master

Fix spin loop example
2020-11-06 23:41:55 +08:00
Maarten de Vries
3bee37c290 Disable accept4 on Android. 2020-11-06 14:17:48 +01:00
Peter Jaszkowiak
8d48e3bbb2 document HACKs 2020-11-05 19:26:08 -07:00
Peter Jaszkowiak
fe6dfcd28a Intra-doc links for std::io::buffered 2020-11-05 19:09:42 -07:00
Mara Bos
f383e4f1d9
Rollup merge of #78757 - camelid:crate-link-text, r=jyn514
Improve and clean up some intra-doc links
2020-11-05 10:30:02 +01:00
Mara Bos
43e1b58bcc
Rollup merge of #78716 - est31:array_traits, r=Dylan-DPC
Array trait impl comment/doc fixes

Two small doc/comment fixes regarding trait implementations on arrays.
2020-11-05 10:29:46 +01:00
Mara Bos
10d2843604
Rollup merge of #78093 - camelid:as-cleanup, r=jyn514
Clean up docs for 'as' keyword
2020-11-05 10:29:38 +01:00
Camelid
677b2acb48 Add missing comma
'Note however,' -> 'Note, however,'
2020-11-04 18:57:54 -08:00
Camelid
bbdb1f0f66 Clean up some intra-doc links 2020-11-04 18:57:52 -08:00
Camelid
d8afe98eba Clean up docs for 'as' keyword 2020-11-04 16:05:55 -08:00
est31
5801109ba9 Move Copy and Clone into the list of traits implemented for all sizes 2020-11-04 01:28:37 +01:00
Mara Bos
8ed31d2782
Rollup merge of #78602 - RalfJung:raw-ptr-aliasing-issues, r=m-ou-se
fix various aliasing issues in the standard library

This fixes various cases where the standard library either used raw pointers after they were already invalidated by using the original reference again, or created raw pointers for one element of a slice and used it to access neighboring elements.
2020-11-01 11:53:36 +01:00
Mara Bos
f281a76f83
Rollup merge of #78599 - panstromek:master, r=m-ou-se
Add note to process::arg[s] that args shouldn't be escaped or quoted

This came out of discussion on [forum](https://users.rust-lang.org/t/how-to-get-full-output-from-command/50626), where I recently asked a question and it turned out that the problem was redundant quotation:

```rust
 Command::new("rg")
        .arg("\"pattern\"") // this will look for "pattern" with quotes included
```

This is something that has bitten me few times already (in multiple languages actually), so It'd be grateful to have it in the docs, even though it's not sctrictly Rust specific problem. Other users also agreed.

This can be really annoying to debug, because in many cases (inluding mine), quotes can be legal part of the argument, so the command doesn't fail, it just behaves unexpectedly. Not everybody (including me) knows that quotes around arguments are part of the shell and not part of the called program. Coincidentally, somoene had the same problem [yesterday](https://www.reddit.com/r/rust/comments/jkxelc/going_crazy_over_running_a_curl_process_from_rust/) on reddit.

I am not a native speaker, so I welcome any corrections or better formulation, I don't expect this to be merged as is. I was also reminded that this is platform/shell specific behaviour, but I didn't find a good way to formulate that briefly, any ideas welcome.

 It's also my first PR here, so I am not sure I did everything correctly, I did this just from Github UI.
2020-11-01 11:53:34 +01:00
Matyáš Racek
db416b232c
Apply suggestions from code review
Co-authored-by: Mara Bos <m-ou.se@m-ou.se>
2020-10-31 17:28:44 +01:00
Ralf Jung
9f630af930 fix aliasing issue in unix sleep function 2020-10-31 16:26:06 +01:00
Matyáš Racek
d417bbef95
Add note to process::arg[s] that args shouldn't be escaped or quoted 2020-10-31 14:40:36 +01:00
Mara Bos
4ebd5536b4
Rollup merge of #77099 - tspiteri:exp_m1-examples, r=m-ou-se
make exp_m1 and ln_1p examples more representative of use

With this PR, the examples for `exp_m1` would fail if `x.exp() - 1.0` is used instead of `x.exp_m1()`, and the examples for `ln_1p` would fail if `(x + 1.0).ln()` is used instead of `x.ln_1p()`.
2020-10-31 09:49:32 +01:00
Mara Bos
76b8b00b4f
Rollup merge of #74622 - fusion-engineering-forks:panic-box, r=KodrAus
Add std::panic::panic_any.

The discussion of #67984 lead to the conclusion that there should be a macro or function separate from `std::panic!()` for throwing arbitrary payloads, to make it possible to deprecate or disallow (in edition 2021) `std::panic!(arbitrary_payload)`.

Alternative names:

- `panic_with!(..)`
- ~~`start_unwind(..)`~~ (panicking doesn't always unwind)
- `throw!(..)`
- `panic_throwing!(..)`
- `panic_with_value(..)`
- `panic_value(..)`
- `panic_with(..)`
- `panic_box(..)`
- `panic(..)`

The equivalent (private, unstable) function in `libstd` is called `std::panicking::begin_panic`.

I suggest `panic_any`, because it allows for any (`Any + Send`) type.

_Tracking issue: #78500_
2020-10-31 09:49:28 +01:00
Maarten de Vries
59c6ae615e Use SOCK_CLOEXEC and accept4() on more platforms. 2020-10-30 14:20:10 +01:00
Yuki Okushi
73d0340fd5
Rollup merge of #78554 - camelid:improve-drop_in_place-docs-wording, r=jyn514
Improve wording of `core::ptr::drop_in_place` docs

And two small intra-doc link conversions in `std::{f32, f64}`.
2020-10-30 18:00:58 +09:00
Yuki Okushi
02a4b58a3f
Rollup merge of #77921 - wcampbell0x2a:f64-collapsible-if, r=jyn514
f64: Refactor collapsible_if
2020-10-30 18:00:49 +09:00
Camelid
fee4f8feb0 Improve wording of core::ptr::drop_in_place docs
And two small intra-doc link conversions in `std::{f32, f64}`.
2020-10-29 20:09:29 -07:00
Mara Bos
b48fee010c Add tracking issue number for panic_any. 2020-10-28 21:23:45 +01:00
Mara Bos
a9d334d386
Update panic_any feature name.
Co-authored-by: Camelid <camelidcamel@gmail.com>
2020-10-28 21:21:41 +01:00
Camelid
0217edbd29
Clean up intra-doc links in std::path 2020-10-27 20:54:30 -07:00
Tom Kaitchuck
5b3d98d9f8 Change link to point to crates.io keyword "hasher"
Signed-off-by: Tom Kaitchuck <Tom.Kaitchuck@gmail.com>
2020-10-27 20:49:52 -07:00
bors
90e6d0d46b Auto merge of #75671 - nathanwhit:cstring-temp-lint, r=oli-obk
Uplift `temporary-cstring-as-ptr` lint from `clippy` into rustc

The general consensus seems to be that this lint covers a common enough mistake to warrant inclusion in rustc.
The diagnostic message might need some tweaking, as I'm not sure the use of second-person perspective matches the rest of rustc, but I'd like to hear others' thoughts on that.

(cc #53224).

r? `@oli-obk`
2020-10-27 22:59:13 +00:00
bors
56d288fa46 Auto merge of #78227 - SergioBenitez:test-stdout-threading, r=m-ou-se
Capture output from threads spawned in tests

This is revival of #75172.

Original text:
> Fixes #42474.
>
> r? `@​dtolnay` since you expressed interest in this, but feel free to redirect if you aren't the right person anymore.

---

Closes #75172.
2020-10-27 11:43:18 +00:00
Nathan Whitaker
39941e6281 Fix bootstrap doctest failure 2020-10-26 22:09:47 -04:00
Yuki Okushi
4236d27c9b
Rollup merge of #78412 - camelid:cleanup-hash-docs, r=jonas-schievink
Improve formatting of hash collections docs
2020-10-27 08:45:30 +09:00
Yuki Okushi
f6f8764b25
Rollup merge of #78394 - rubik:master, r=m-ou-se
fix(docs): typo in BufWriter documentation

This PR fixes a small typo in the BufWriter documentation. The current documentation looks like this:

![2020-10-26-111501_438x83_scrot](https://user-images.githubusercontent.com/238549/97160357-83d3a000-177c-11eb-8a35-3cdd3a7d89de.png)

The `<u8>` at the end is mangled by Markdown. This PR makes the `BufWriter` documentation like the `BufReader` one:

https://github.com/rust-lang/rust/blob/master/library/std/src/io/buffered/bufreader.rs#L16

I'm tagging Steve as per the Rustc dev guide.

r? @steveklabnik
2020-10-27 08:45:20 +09:00
Yuki Okushi
5a33fa5179
Rollup merge of #78375 - taiki-e:question-in-macros, r=kennytm
Use ? in core/std macros
2020-10-27 08:45:10 +09:00
Yuki Okushi
2c307fab49
Rollup merge of #77703 - Keruspe:system-libunwind, r=Mark-Simulacrum
add system-llvm-libunwind config option

allows using the system-wide llvm-libunwind as the unwinder

Workaround for #76020
2020-10-27 08:44:44 +09:00
Nathan Whitaker
cb8b9012db Address review comments 2020-10-26 19:19:06 -04:00
Nathan Whitaker
1bcd2452fe Address review comments 2020-10-26 18:19:48 -04:00
Nathan Whitaker
737bfeffd2 Change to warn by default / fix typo 2020-10-26 18:19:48 -04:00
Nathan Whitaker
ce95122e95 Update doctest 2020-10-26 18:19:47 -04:00
Camelid
59f108885e Improve formatting of hash collections docs 2020-10-26 14:05:06 -07:00
Michele Lacchia
a4ba179bdd
fix(docs): typo in BufWriter documentation 2020-10-26 11:13:47 +01:00
DevJPM
3daa93f555 Updated documentation, x86 feature detection testing, and removed LLVM 9 exclusive features
Updated the added documentation in llvm_util.rs to note which copies of LLVM need to be inspected.
Removed avx512bf16 and avx512vp2intersect because they are unsupported before LLVM 9 with the build with external LLVM 8 being supported
Re-introduced detection testing previously removed for un-requestable features tsc and mmx
2020-10-26 08:36:14 +01:00
Dylan DPC
e0c08ae4e1
Rollup merge of #74477 - chansuke:sys-wasm-unsafe-op-in-unsafe-fn, r=Mark-Simulacrum
`#[deny(unsafe_op_in_unsafe_fn)]` in sys/wasm

This is part of #73904.

This encloses unsafe operations in unsafe fn in `libstd/sys/wasm`.

@rustbot modify labels: F-unsafe-block-in-unsafe-fn
2020-10-26 03:08:56 +01:00
Taiki Endo
04c0018d1b Use ? in core/std macros 2020-10-26 07:15:37 +09:00
DevJPM
cd95e939bb Removed movbe from run-time-detect
`movbe` seems to not be a run-time detectable feature on x86.
It has thus been removed from the list.
It was only commented out to ease comparison against the full list.
2020-10-25 17:27:22 +01:00
DevJPM
9feb567399 Updated the list of white-listed target features for x86
This PR both adds in-source documentation on what to look out for
when adding a new (X86) feature set and adds all that are detectable at run-time in Rust stable
as of 1.27.0.

This should only enable the use of the corresponding LLVM intrinsics.
Actual intrinsics need to be added separately in rust-lang/stdarch.

It also re-orders the run-time-detect test statements to be more consistent
with the actual list of intrinsics whitelisted and removes underscores not present
in the actual names (which might be mistaken as being part of the name)
2020-10-25 17:06:40 +01:00
Yuki Okushi
72e02b015e
Rollup merge of #78208 - liketechnik:issue-69399, r=oli-obk
replace `#[allow_internal_unstable]` with `#[rustc_allow_const_fn_unstable]` for `const fn`s

`#[allow_internal_unstable]` is currently used to side-step feature gate and stability checks.
While it was originally only meant to be used only on macros, its use was expanded to `const fn`s.

This pr adds stricter checks for the usage of `#[allow_internal_unstable]` (only on macros) and introduces the `#[rustc_allow_const_fn_unstable]` attribute for usage on `const fn`s.

This pr does not change any of the functionality associated with the use of `#[allow_internal_unstable]` on macros or the usage of `#[rustc_allow_const_fn_unstable]` (instead of `#[allow_internal_unstable]`) on `const fn`s (see https://github.com/rust-lang/rust/issues/69399#issuecomment-712911540).

Note: The check for `#[rustc_allow_const_fn_unstable]` currently only validates that the attribute is used on a function, because I don't know how I would check if the function is a `const fn` at the place of the check. I therefore openend this as a 'draft pull request'.

Closes rust-lang/rust#69399

r? @oli-obk
2020-10-25 18:43:40 +09:00
Jonas Schievink
e3808edeee
Rollup merge of #78119 - fusion-engineering-forks:panic-use-as-str, r=Amanieu
Throw core::panic!("message") as &str instead of String.

This makes `core::panic!("message")` consistent with `std::panic!("message")`, which throws a `&str` and not a `String`.

This also makes any other panics from `core::panicking::panic` result in a `&str` rather than a `String`, which includes compiler-generated panics such as the panics generated for `mem::zeroed()`.

---

Demonstration:

```rust
use std::panic;
use std::any::Any;

fn main() {
    panic::set_hook(Box::new(|panic_info| check(panic_info.payload())));

    check(&*panic::catch_unwind(|| core::panic!("core")).unwrap_err());
    check(&*panic::catch_unwind(|| std::panic!("std")).unwrap_err());
}

fn check(msg: &(dyn Any + Send)) {
    if let Some(s) = msg.downcast_ref::<String>() {
        println!("Got a String: {:?}", s);
    } else if let Some(s) = msg.downcast_ref::<&str>() {
        println!("Got a &str: {:?}", s);
    }
}
```

Before:
```
Got a String: "core"
Got a String: "core"
Got a &str: "std"
Got a &str: "std"
```

After:
```
Got a &str: "core"
Got a &str: "core"
Got a &str: "std"
Got a &str: "std"
```
2020-10-24 22:39:53 +02:00
Jonas Schievink
e34263d86a
Rollup merge of #77610 - hermitcore:dtors, r=m-ou-se
revise Hermit's mutex interface to support the behaviour of StaticMutex

rust-lang/rust#77147 simplifies things by splitting this Mutex type into two types matching the two use cases: StaticMutex and MovableMutex. To support the new behavior of StaticMutex, we move part of the mutex implementation into libstd.

The interface to the OS changed. Consequently, I removed a few functions, which aren't longer needed.
2020-10-24 22:39:44 +02:00
Jonas Schievink
01a38f0d9a
Rollup merge of #75115 - chansuke:sys-cloudabi-unsafe, r=KodrAus
`#[deny(unsafe_op_in_unsafe_fn)]` in sys/cloudabi

Partial fix of #73904.

This encloses unsafe operations in unsafe fn in sys/cloudabi.
2020-10-24 22:39:35 +02:00
Dan Gohman
6249cda78f Disable use of linkat on Android as well.
According to [the bionic status page], `linkat` has only been available
since API level 21. Since Android is based on Linux and Linux's `link`
doesn't follow symlinks, just use `link` on Android.

[the bionic status page]: https://android.googlesource.com/platform/bionic/+/master/docs/status.md
2020-10-24 09:43:31 -07:00
Jonas Schievink
eaa982305d
Rollup merge of #78274 - Enet4:patch-1, r=jonas-schievink
Update description of Empty Enum for accuracy

An empty enum is similar to the never type `!`, rather than the unit type `()`.
2020-10-24 14:12:11 +02:00
chansuke
d37b8cf729 Remove unnecessary unsafe block from condvar_atomics & mutex_atomics 2020-10-24 18:22:18 +09:00
chansuke
d147f78e36 Fix unsafe operation of wasm32::memory_atomic_notify 2020-10-24 18:14:17 +09:00
chansuke
de87ae7961 Add documents for DLMALLOC 2020-10-24 17:59:58 +09:00
chansuke
eed45107da Add some description for (malloc/calloc/free/realloc) 2020-10-24 11:50:09 +09:00
chansuke
d413bb6f57 #[deny(unsafe_op_in_unsafe_fn)] in sys/wasm 2020-10-24 11:50:09 +09:00
Eduardo Pinho
efedcb2344
Update description of Empty Enum for accuracy
An empty enum is similar to the never type `!`, rather than the unit type `()`.
2020-10-23 12:13:07 +01:00
Yuki Okushi
b968738348
Rollup merge of #77918 - wcampbell0x2a:cleanup-network-tests, r=m-ou-se
Cleanup network tests

Some cleanup for network related tests
2020-10-23 18:26:22 +09:00
Sergio Benitez
db15596c57 Only load LOCAL_STREAMS if they are being used 2020-10-22 18:15:48 -07:00
Tyler Mandry
d0d0e78208 Capture output from threads spawned in tests
Fixes #42474.
2020-10-22 18:15:44 -07:00
Jubilee Young
ef027a1eed Duration::zero() -> Duration::ZERO
Duration::ZERO composes better with match and various other things,
at the cost of an occasional parens, and results in less work for the
optimizer, so let's use that instead.
2020-10-21 20:44:03 -07:00
Jubilee Young
d72d5f48c2 Dogfood Duration API in std::time tests
This expands time's test suite to use more and in more places the
range of methods and constants added to Duration in recent
proposals for the sake of testing more API surface area and
improving legibility.
2020-10-21 20:03:56 -07:00
varkor
878c97e70c Update to rustc-demangle 0.1.18 2020-10-21 21:11:11 +01:00
varkor
2b9d22d3a9 Update rustc-demangle 2020-10-21 21:05:38 +01:00
Florian Warzecha
05f4a9a42a
switch allow_internal_unstable const fns to rustc_allow_const_fn_unstable 2020-10-21 20:54:20 +02:00
Marc-Antoine Perennou
66fa42a946 allow using the system-wide llvm-libunwind as the unwinder
Signed-off-by: Marc-Antoine Perennou <Marc-Antoine@Perennou.com>
2020-10-21 14:45:58 +02:00
Dan Gohman
d0178b4f99 Make it platform-specific whether hard_link follows symlinks.
Also mention that where possible, `hard_link` does not follow symlinks.
2020-10-21 01:46:27 -07:00
Yuki Okushi
6df79bf8a8
Rollup merge of #77923 - wcampbell0x2a:cleanup-net-module, r=scottmcm
[net] apply clippy lints

Applied helpful clippy lints to the network std library module.
2020-10-20 12:11:04 +09:00
Yuki Okushi
f9db00839e
Rollup merge of #77838 - RalfJung:const-fn, r=kennytm
const keyword: brief paragraph on 'const fn'

`const fn` were mentioned in the title, but called "deterministic functions" which is not their main property (though at least currently it is a consequence of being const-evaluable). This adds a brief paragraph discussing them, also in the hopes of clarifying that they do *not* have any effect on run-time uses.
2020-10-20 12:11:02 +09:00
Tomasz Miąsko
21c29b1e95 Check that pthread mutex initialization succeeded
If pthread mutex initialization fails, the failure will go unnoticed unless
debug assertions are enabled. Any subsequent use of mutex will also silently
fail, since return values from lock & unlock operations are similarly checked
only through debug assertions.

In some implementations the mutex initialization requires a memory
allocation and so it does fail in practice.

Check that initialization succeeds to ensure that mutex guarantees
mutual exclusion.
2020-10-20 00:00:00 +00:00
Mara Bos
2780e35246 Throw core::panic!("message") as &str instead of String.
This makes it consistent with std::panic!("message"), which also throws
a &str, not a String.
2020-10-19 22:31:11 +02:00
wcampbell
736c27ec0b Revert "[net] clippy: needless_update"
This reverts commit 058699d0a2.
2020-10-19 07:22:45 -04:00
Mara Bos
ff8df0bbe3 Add cfg(not(test)) to std_panic_macro rustc_diagnostic_item. 2020-10-19 10:57:44 +02:00
pierwill
67dc9b7581
Add missing punctuation 2020-10-18 23:03:16 -07:00
Mara Bos
dd262e3856 Add cfg(not(bootstrap)) on the new rustc_diagnostic_item attributes.
The beta compiler doesn't accept rustc_diagnostic_items on macros yet.
2020-10-18 23:45:20 +02:00
Mara Bos
462ee9c1b5 Mark the panic macros as diagnostic items. 2020-10-18 22:20:19 +02:00
est31
a687420d17 Remove redundant 'static from library crates 2020-10-18 17:25:51 +02:00
Dan Gohman
ce00b3e2e0 Use link on platforms which lack linkat. 2020-10-18 07:47:32 -07:00
Dan Gohman
23a5c21415 Fix a typo in a comment. 2020-10-18 07:21:41 -07:00
Mara Bos
16201da6a4 Rename panic_box to panic_any. 2020-10-18 12:29:13 +02:00
Mara Bos
01b0aff1df Add std::panic::panic_box. 2020-10-18 12:25:26 +02:00
chansuke
d3467fe520 #[deny(unsafe_op_in_unsafe_fn)] in sys/cloudabi 2020-10-18 17:59:54 +09:00
bors
c38ddb8040 Auto merge of #74480 - yoshuawuyts:hardware_threads, r=dtolnay
Add std:🧵:available_concurrency

This PR adds a counterpart to [C++'s `std:🧵:hardware_concurrency`](https://en.cppreference.com/w/cpp/thread/thread/hardware_concurrency) to Rust, tracking issue https://github.com/rust-lang/rust/issues/74479.

cc/ `@rust-lang/libs`

## Motivation

Being able to know how many hardware threads a platform supports is a core part of building multi-threaded code. In C++ 11 this has become available through the [`std:🧵:hardware_concurrency`](https://en.cppreference.com/w/cpp/thread/thread/hardware_concurrency) API. Currently in Rust most of the ecosystem depends on the [`num_cpus` crate](https://docs.rs/num_cpus/1.13.0/num_cpus/) ([no.35 in top 500 crates](https://docs.google.com/spreadsheets/d/1wwahRMHG3buvnfHjmPQFU4Kyfq15oTwbfsuZpwHUKc4/edit#gid=1253069234)) to provide this functionality. This PR proposes an API to provide access to the number of hardware threads available on a given platform.

__edit (2020-07-24):__ The purpose of this PR is to provide a hint for how many threads to spawn to saturate the processor. There's value in introducing APIs for NUMA and Windows processor groups, but those are intentionally out of scope for this PR. See: https://github.com/rust-lang/rust/pull/74480#issuecomment-662116186.

## Naming

Discussing the naming of the API on Zulip surfaced two options:

- `std:🧵:hardware_concurrency`
- `std:🧵:hardware_threads`

Both options seemed acceptable, but overall people seem to gravitate the most towards `hardware_threads`. Additionally `@jonas-schievink` pointed out that the "hardware threads" terminology is well-established and is used in among other the [RISC-V specification](https://riscv.org/specifications/isa-spec-pdf/) (page 20):

> A component is termed a core if it contains an independent instruction fetch unit. A RISC-V-compatible core might support multiple RISC-V-compatible __hardware threads__, or harts, through multithreading.

It's also worth noting that [the original paper introducing C++'s `std::thread` submodule](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2320.html) unfortunately doesn't feature any discussion on the naming of `hardware_concurrency`, so we can't use that to help inform our decision here.

## Return type

An important consideration `@joshtriplett` brought up is that we don't want to default to `1` for platforms where the number of available threads cannot be retrieved. Instead we want to inform the users of the fact that we don't know and allow them to handle that case. Which is why this PR uses `Option<NonZeroUsize>` as its return type, where `None` is returned on platforms where we don't know the number of hardware threads available.

The reasoning for `NonZeroUsize` vs `usize` is that if the number of threads for a platform are known, they'll always be at least 1. As evidenced by the example the `NonZero*` family of APIs may currently not be the most ergonomic to use, but improving the ergonomics of them is something that I think we can address separately.

## Implementation

`@Mark-Simulacrum` pointed out that most of the code we wanted to expose here was already available under `libtest`. So this PR mostly moves the internal code of libtest into a public API.
2020-10-18 02:28:21 +00:00
bors
4cb7ef0f94 Auto merge of #77455 - asm89:faster-spawn, r=kennytm
Use posix_spawn() on unix if program is a path

Previously `Command::spawn` would fall back to the non-posix_spawn based
implementation if the `PATH` environment variable was possibly changed.
On systems with a modern (g)libc `posix_spawn()` can be significantly
faster. If program is a path itself the `PATH` environment variable is
not used for the lookup and it should be safe to use the
`posix_spawnp()` method. [1]

We found this, because we have a cli application that effectively runs a
lot of subprocesses. It would sometimes noticeably hang while printing
output. Profiling showed that the process was spending the majority of
time in the kernel's `copy_page_range` function while spawning
subprocesses. During this time the process is completely blocked from
running, explaining why users were reporting the cli app hanging.

Through this we discovered that `std::process::Command` has a fast and
slow path for process execution. The fast path is backed by
`posix_spawnp()` and the slow path by fork/exec syscalls being called
explicitly. Using fork for process creation is supposed to be fast, but
it slows down as your process uses more memory.  It's not because the
kernel copies the actual memory from the parent, but it does need to
copy the references to it (see `copy_page_range` above!).  We ended up
using the slow path, because the command spawn implementation in falls
back to the slow path if it suspects the PATH environment variable was
changed.

Here is a smallish program demonstrating the slowdown before this code
change:

```
use std::process::Command;
use std::time::Instant;

fn main() {
    let mut args = std::env::args().skip(1);
    if let Some(size) = args.next() {
        // Allocate some memory
        let _xs: Vec<_> = std::iter::repeat(0)
            .take(size.parse().expect("valid number"))
            .collect();

        let mut command = Command::new("/bin/sh");
        command
            .arg("-c")
            .arg("echo hello");

        if args.next().is_some() {
            println!("Overriding PATH");
            command.env("PATH", std::env::var("PATH").expect("PATH env var"));
        }

        let now = Instant::now();
        let child = command
            .spawn()
            .expect("failed to execute process");

        println!("Spawn took: {:?}", now.elapsed());

        let output = child.wait_with_output().expect("failed to wait on process");
        println!("Output: {:?}", output);
    } else {
        eprintln!("Usage: prog [size]");
        std::process::exit(1);
    }
    ()
}
```

Running it and passing different amounts of elements to use to allocate
memory shows that the time taken for `spawn()` can differ quite
significantly. In latter case the `posix_spawnp()` implementation is 30x
faster:

```
$ cargo run --release 10000000
...
Spawn took: 324.275µs
hello
$ cargo run --release 10000000 changepath
...
Overriding PATH
Spawn took: 2.346809ms
hello
$ cargo run --release 100000000
...
Spawn took: 387.842µs
hello
$ cargo run --release 100000000 changepath
...
Overriding PATH
Spawn took: 13.434677ms
hello
```

[1]: 5f72f9800b/posix/execvpe.c (L81)
2020-10-17 06:16:00 +00:00
Yoshua Wuyts
3717646366 Add std:🧵:available_concurrency 2020-10-16 23:36:15 +02:00
Yuki Okushi
050eb4d7e4
Rollup merge of #77971 - jyn514:broken-intra-doc-links, r=mark-simulacrum
Deny broken intra-doc links in linkchecker

Since rustdoc isn't warning about these links, check for them manually.

This also fixes the broken links that popped up from the lint.
2020-10-17 05:36:49 +09:00
Yuki Okushi
9abf81afa8
Rollup merge of #77900 - Thomasdezeeuw:fdatasync, r=dtolnay
Use fdatasync for File::sync_data on more OSes

Add support for the following OSes:
 * Android
 * FreeBSD: https://www.freebsd.org/cgi/man.cgi?query=fdatasync&sektion=2
 * OpenBSD: https://man.openbsd.org/OpenBSD-5.8/fsync.2
 * NetBSD: https://man.netbsd.org/fdatasync.2
 * illumos: https://illumos.org/man/3c/fdatasync
2020-10-17 05:36:45 +09:00
Yuki Okushi
3356ad7c26
Rollup merge of #77547 - RalfJung:stable-union-drop, r=matthewjasper
stabilize union with 'ManuallyDrop' fields and 'impl Drop for Union'

As [discussed by @SimonSapin and @withoutboats](https://github.com/rust-lang/rust/issues/55149#issuecomment-634692020), this PR proposes to stabilize parts of the `untagged_union` feature gate:

* It will be possible to have a union with field type `ManuallyDrop<T>` for any `T`.
* While at it I propose we also stabilize `impl Drop for Union`; to my knowledge, there are no open concerns around this feature.

In the RFC discussion, we also talked about allowing `&mut T` as another non-`Copy` non-dropping type, but that felt to me like an overly specific exception so I figured we'd wait if there is actually any use for such a special case.

Some things remain unstable and still require the `untagged_union` feature gate:
* Union with fields that do not drop, are not `Copy`, and are not `ManuallyDrop<_>`. The reason to not stabilize this is to avoid semver concerns around libraries adding `Drop` implementations later. (This is already not fully semver compatible as, to my knowledge, the borrow checker will exploit the non-dropping nature of any type, but it seems prudent to avoid further increasing the amount of trouble adding an `impl Drop` can cause.)

Due to this, quite a few tests still need the `untagged_union` feature, but I think the ones where I could remove the feature flag provide good test coverage for the stable part.

Cc @rust-lang/lang
2020-10-17 05:36:38 +09:00
Dan Gohman
91a9f83dd1 Define fs::hard_link to not follow symlinks.
POSIX leaves it implementation-defined whether `link` follows symlinks.
In practice, for example, on Linux it does not and on FreeBSD it does.
So, switch to `linkat`, so that we can pick a behavior rather than
depending on OS defaults.

Pick the option to not follow symlinks. This is somewhat arbitrary, but
seems the less surprising choice because hard linking is a very
low-level feature which requires the source and destination to be on
the same mounted filesystem, and following a symbolic link could end
up in a different mounted filesystem.
2020-10-16 12:05:49 -07:00
Ralf Jung
defcd7ff47 stop relying on feature(untagged_unions) in stdlib 2020-10-16 11:33:35 +02:00
Mara Bos
0f0257be10 Take some of sys/vxworks/process/* from sys/unix instead. 2020-10-16 06:22:05 +02:00
Mara Bos
408db0da85 Take sys/vxworks/{os,path,pipe} from sys/unix instead. 2020-10-16 06:22:00 +02:00
Mara Bos
71bb1dc2a0 Take sys/vxworks/{fd,fs,io} from sys/unix instead. 2020-10-16 06:19:00 +02:00
Mara Bos
3f196dc137 Take sys/vxworks/cmath from sys/unix instead. 2020-10-16 06:19:00 +02:00
Mara Bos
ba483c51df Take sys/vxworks/args from sys/unix instead. 2020-10-16 06:19:00 +02:00
Mara Bos
08bcaac091 Take sys/vxworks/memchar from sys/unix instead. 2020-10-16 06:19:00 +02:00
Mara Bos
dce405ae3d Take sys/vxworks/net from sys/unix instead. 2020-10-16 06:19:00 +02:00
Mara Bos
a489c33beb Take sys/vxworks/ext/* from sys/unix instead. 2020-10-16 06:19:00 +02:00
Mara Bos
c909ff9577 Add weak macro to vxworks. 2020-10-16 06:19:00 +02:00
Mara Bos
66c9b04e94 Take sys/vxworks/alloc from sys/unix instead. 2020-10-16 06:19:00 +02:00
Mara Bos
678d078950 Take sys/vxworks/thread_local_key from sys/unix instead. 2020-10-16 06:19:00 +02:00
Mara Bos
4853a6e78e Take sys/vxworks/stdio from sys/unix instead. 2020-10-16 06:19:00 +02:00
Mara Bos
5d526f6eee Take sys/vxworks/thread from sys/unix instead. 2020-10-16 06:19:00 +02:00
Mara Bos
c8628f43bf Take sys/vxworks/stack_overflow from sys/unix instead. 2020-10-16 06:18:59 +02:00
Mara Bos
d1947628b5 Take sys/vxworks/time from sys/unix instead. 2020-10-16 06:18:59 +02:00
Mara Bos
f875c8be5d Take sys/vxworks/rwlock from sys/unix instead. 2020-10-16 06:18:59 +02:00
Mara Bos
f3f30c7132 Take sys/vxworks/condvar from sys/unix instead. 2020-10-16 06:18:59 +02:00
Mara Bos
b8dcd2fbce Take sys/vxworks/mutex from sys/unix instead. 2020-10-16 06:18:59 +02:00
Joshua Nelson
65835d1059 Deny broken intra-doc links in linkchecker
Since rustdoc isn't warning about these links, check for them manually.
2020-10-15 20:22:16 -04:00
Dylan DPC
9b8c0eb107
Rollup merge of #77657 - fusion-engineering-forks:cleanup-cloudabi-sync, r=dtolnay
Cleanup cloudabi mutexes and condvars

This gets rid of lots of unnecessary unsafety.

All the AtomicU32s were wrapped in UnsafeCell or UnsafeCell<MaybeUninit>, and raw pointers were used to get to the AtomicU32 inside. This change cleans that up by using AtomicU32 directly.

Also replaces a UnsafeCell<u32> by a safer Cell<u32>.

@rustbot modify labels: +C-cleanup
2020-10-16 02:10:17 +02:00
Dylan DPC
b183ef2068
Rollup merge of #77648 - fusion-engineering-forks:static-mutex, r=dtolnay
Static mutex is static

StaticMutex is only ever used with as a static (as the name already suggests). So it doesn't have to be generic over a lifetime, but can simply assume 'static.

This 'static lifetime guarantees the object is never moved, so this is no longer a manually checked requirement for unsafe calls to lock().

@rustbot modify labels: +T-libs +A-concurrency +C-cleanup
2020-10-16 02:10:15 +02:00
Dylan DPC
085399f481
Rollup merge of #77646 - fusion-engineering-forks:use-static-mutex, r=dtolnay
For backtrace, use StaticMutex instead of a raw sys Mutex.

The code used the very unsafe `sys::mutex::Mutex` directly, and built its own unlock-on-drop wrapper around it. The StaticMutex wrapper already provides that and is easier to use safely.

@rustbot modify labels: +T-libs +C-cleanup
2020-10-16 02:10:13 +02:00
Dylan DPC
dcf972a2be
Rollup merge of #77619 - fusion-engineering-forks:wasm-parker, r=dtolnay
Use futex-based thread-parker for Wasm32.

This uses the existing `sys_common/thread_parker/futex.rs` futex-based thread parker (that was already used for Linux) for wasm32 as well (if the wasm32 atomics target feature is enabled, which is not the case by default).

Wasm32 provides the basic futex operations as instructions: https://webassembly.github.io/threads/syntax/instructions.html

These are now exposed from `sys::futex::{futex_wait, futex_wake}`, just like on Linux. So, `thread_parker/futex.rs` stays completely unmodified.
2020-10-16 02:10:11 +02:00
Dylan DPC
5acb7f198f
Rollup merge of #76084 - Lucretiel:split-buffered, r=dtolnay
Refactor io/buffered.rs into submodules

This pull request splits `BufWriter`, `BufReader`, `LineWriter`, and `LineWriterShim` (along with their associated tests) into separate submodules. It contains no functional changes. This change is being made in anticipation of adding another type of buffered writer which can be switched between line- and block-buffering mode.

Part of a series of pull requests resolving #60673.
2020-10-16 02:10:04 +02:00
Tom Kaitchuck
1d287255f5 Change mention of fnv in HashMap to mention aHash as an alternitive hasher.
Signed-off-by: Tom Kaitchuck <tom.kaitchuck@emc.com>
2020-10-15 14:03:39 -07:00
Matthew Kraai
f2a237a935 Fix link to foreign calling conventions 2020-10-15 00:57:22 -07:00
Mara Bos
44a2af32cc Remove lifetime from StaticMutex and assume 'static.
StaticMutex is only ever used with as a static (as the name already
suggests). So it doesn't have to be generic over a lifetime, but can
simply assume 'static.

This 'static lifetime guarantees the object is never moved, so this is
no longer a manually checked requirement for unsafe calls to lock().
2020-10-14 09:52:03 +02:00
Mara Bos
58756573fc Fix comment about non-reentrant StaticMutex::lock().
The comment said it's UB to call lock() while it is locked. That'd be
quite a useless Mutex. :) It was supposed to say 'locked by the same
thread', not just 'locked'.
2020-10-14 09:50:47 +02:00
Dylan DPC
ed34f82cbc
Rollup merge of #77870 - camelid:intra-doc-super, r=jyn514
Use intra-doc links for links to module-level docs

r? @jyn514
2020-10-14 02:30:46 +02:00
wcampbell
ce04836327
fmt
Signed-off-by: wcampbell <wcampbell1995@gmail.com>
2020-10-13 20:11:29 -04:00
wcampbell
7da0e58da4
use matches! in library/std/src/net/ip.rs
Apply suggestion from review

Co-authored-by: LingMan <LingMan@users.noreply.github.com>
2020-10-13 19:33:39 -04:00
wcampbell
7a75f44183
[net] clippy: identity_op
warning: the operation is ineffective. Consider reducing it to
`self.segments()[0]`
    --> library/std/src/net/ip.rs:1265:9
     |
1265 |         (self.segments()[0] & 0xffff) == 0xfe80
     |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     |
     = note: `#[warn(clippy::identity_op)]` on by default
     = help: for further information visit
https://rust-lang.github.io/rust-clippy/master/index.html#identity_op

warning: the operation is ineffective. Consider reducing it to
`self.segments()[1]`
    --> library/std/src/net/ip.rs:1266:16
     |
1266 |             && (self.segments()[1] & 0xffff) == 0
     |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     |
     = help: for further information visit
https://rust-lang.github.io/rust-clippy/master/index.html#identity_op

warning: the operation is ineffective. Consider reducing it to
`self.segments()[2]`
    --> library/std/src/net/ip.rs:1267:16
     |
1267 |             && (self.segments()[2] & 0xffff) == 0
     |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     |
     = help: for further information visit
https://rust-lang.github.io/rust-clippy/master/index.html#identity_op

warning: the operation is ineffective. Consider reducing it to
`self.segments()[3]`
    --> library/std/src/net/ip.rs:1268:16
     |
1268 |             && (self.segments()[3] & 0xffff) == 0
     |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     |
     = help: for further information visit
https://rust-lang.github.io/rust-clippy/master/index.html#identity_op

Signed-off-by: wcampbell <wcampbell1995@gmail.com>
2020-10-13 18:03:27 -04:00
wcampbell
e6dc604e8b
[net] clippy: match_like_matches_macro
warning: match expression looks like `matches!` macro
   --> library/std/src/net/ip.rs:459:9
    |
459 | /         match self.octets() {
460 | |             [169, 254, ..] => true,
461 | |             _ => false,
462 | |         }
    | |_________^ help: try this: `matches!(self.octets(), [169, 254,
..])`
    |
    = note: `#[warn(clippy::match_like_matches_macro)]` on by default
    = help: for further information visit
https://rust-lang.github.io/rust-clippy/master/index.html#match_like_matches_macro

Signed-off-by: wcampbell <wcampbell1995@gmail.com>
2020-10-13 18:00:59 -04:00
wcampbell
058699d0a2
[net] clippy: needless_update
warning: struct update has no effect, all the fields in the struct have
already been specified
   --> library/std/src/net/addr.rs:367:19
    |
367 |                 ..unsafe { mem::zeroed() }
    |                   ^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: `#[warn(clippy::needless_update)]` on by default
    = help: for further information visit
https://rust-lang.github.io/rust-clippy/master/index.html#needless_update
2020-10-13 17:58:29 -04:00
wcampbell
096722ff76
Refactor collapsible_if
Signed-off-by: wcampbell <wcampbell1995@gmail.com>
2020-10-13 17:50:10 -04:00
Stefan Lankes
bf268fe928
box mutex to get a movable mutex
the commit avoid an alignement issue in Mutex implementation
2020-10-13 23:25:42 +02:00
Yuki Okushi
cc5a1aad4e
Rollup merge of #77722 - fusion-engineering-forks:safe-unsupported-locks, r=Mark-Simulacrum
Remove unsafety from sys/unsupported and add deny(unsafe_op_in_unsafe_fn).

Replacing `UnsafeCell`s by a `Cell`s simplifies things and makes the mutex and rwlock implementations safe. Other than that, only unsafety in strlen() contained unsafe code.

@rustbot modify labels: +F-unsafe-block-in-unsafe-fn +C-cleanup
2020-10-14 06:02:21 +09:00
Yuki Okushi
7de5fe76f2
Rollup merge of #77719 - fusion-engineering-forks:const-new-mutex-attr-cleanup, r=Mark-Simulacrum
Remove unnecessary rustc_const_stable attributes.

These attributes were added in https://github.com/rust-lang/rust/pull/74033#discussion_r450593156 because of [std::io::lazy::Lazy::new](0c03aee8b8/src/libstd/io/lazy.rs (L21-L23)). But [std::io::lazy::Lazy is gone now](https://github.com/rust-lang/rust/pull/77154), so this can be cleaned up.

@rustbot modify labels: +T-libs +C-cleanup
2020-10-14 06:02:19 +09:00
wcampbell
964a5ac962
Use is_ok() instead of empty Ok(_)
Signed-off-by: wcampbell <wcampbell1995@gmail.com>
2020-10-13 17:01:50 -04:00
wcampbell
a93f58f5e6
Join map operators
Signed-off-by: wcampbell <wcampbell1995@gmail.com>
2020-10-13 17:01:09 -04:00
Mara Bos
af414dc274 Deny unsafe_op_in_unsafe_fn for unsupported/common.rs through sys/wasm too. 2020-10-13 18:56:27 +02:00
Thomas de Zeeuw
8c0c7ec4ec Use fdatasync for File::sync_data on more OSes
Add support for the following OSes:
 * Android
 * FreeBSD: https://www.freebsd.org/cgi/man.cgi?query=fdatasync&sektion=2
 * OpenBSD: https://man.openbsd.org/OpenBSD-5.8/fsync.2
 * NetBSD: https://man.netbsd.org/fdatasync.2
 * illumos: https://illumos.org/man/3c/fdatasync
2020-10-13 15:57:31 +02:00
Mara Bos
b26aa5d973 Add note about using cells in the locks on the 'unsupported' platform. 2020-10-13 15:29:38 +02:00
Camelid
95221b4eb5 Use intra-doc links for links to module-level docs 2020-10-12 19:22:47 -07:00
Jacob Kiesel
a7d3368448 Stabilize clamp 2020-10-12 15:09:45 -06:00
Yuki Okushi
ad6e179060
Rollup merge of #77724 - sunfishcode:stdinlock-asrawfd, r=alexcrichton
Implement `AsRawFd` for `StdinLock` etc. on WASI.

WASI implements `AsRawFd` for `Stdin`, `Stdout`, and `Stderr`, so
implement it for `StdinLock`, `StdoutLock`, and `StderrLock` as well.

r? @alexcrichton
2020-10-13 04:07:54 +09:00
Ralf Jung
c8405d2251 fix markdown reference
Co-authored-by: Dariusz Niedoba <darksv@users.noreply.github.com>
2020-10-12 09:47:43 +02:00
Stefan Lankes
1741e5b8f5
define required type 'MovableMutex' 2020-10-12 06:54:48 +02:00
Stefan Lankes
30c3dadb4d
reuse implementation of the system provider "unsupported" 2020-10-12 06:53:06 +02:00
Stefan Lankes
33fd08b61f
remove obsolete function diverge 2020-10-12 06:51:52 +02:00
Ralf Jung
0ec3ea9e69 const keyword: brief paragraph on 'const fn' 2020-10-12 00:12:45 +02:00
bors
bc74dd711f Auto merge of #77727 - thomcc:mach-info-order, r=Amanieu
Avoid SeqCst or static mut in mach_timebase_info and QueryPerformanceFrequency caches

This patch went through a couple iterations but the end result is replacing a pattern where an `AtomicUsize` (updated with many SeqCst ops) guards a `static mut` with a single `AtomicU64` that is known to use 0 as a value indicating that it is not initialized.

The code in both places exists to cache values used in the conversion of Instants to Durations on macOS, iOS, and Windows.

I have no numbers to prove that this improves performance (It seems a little futile to benchmark something like this), but it's much simpler, safer, and in practice we'd expect it to be faster everywhere where Relaxed operations on AtomicU64 are cheaper than SeqCst operations on AtomicUsize, which is a lot of places.

Anyway, it also removes a bunch of unsafe code and greatly simplifies the logic, so IMO that alone would be worth it unless it was a regression.

If you want to take a look at the assembly output though, see https://godbolt.org/z/rbr6vn for x86_64, https://godbolt.org/z/cqcbqv for aarch64 (Note that this just the output of the mac side, but i'd expect the windows part to be the same and don't feel like doing another godbolt for it). There are several versions of this function in the godbolt:

- `info_new`: version in the current patch
- `info_less_new`: version in initial PR
- `info_original`: version currently in the tree
- `info_orig_but_better_orderings`: a version that just tries to change the original code's orderings from SeqCst to the (probably) minimal orderings required for soundness/correctness.

The biggest concern I have here is if we can use AtomicU64, or if there are targets that dont have it that this code supports. AFAICT: no. (If that changes in the future, it's easy enough to do something different for them)

r? `@Amanieu` because he caught a couple issues last time I tried to do a patch reducing orderings 😅

---

<details>
<summary>I rewrote this whole message so the original is inside here</summary>

I happened to notice the code we use for caching the result of mach_timebase_info uses SeqCst exclusively.

However, thinking a little more, it's actually pretty easy to avoid the static mut by packing the timebase info into an AtomicU64.

This entirely avoids needing to do the compare_exchange. The AtomicU64 can be read/written using Relaxed ops, which on current macos/ios platforms (x86_64/aarch64) have no overhead compared to direct loads/stores. This simplifies the code and makes it a lot safer too.

I have no numbers to prove that this improves performance (It seems a little futile to benchmark something like this), although it should do that on both targets it applies to.

That said, it also removes a bunch of unsafe code and simplifies the logic (arguably at least — there are only two states now, initialized or not), so I think it's a net win even without concrete numbers.

If you want to take a look at the assembly output though, see below. It has the new version, the original, and a version of the original with lower Orderings (which is still worse than the version in this PR)

- godbolt.org/z/obfqf9 x86_64-apple-darwin

- godbolt.org/z/Wz5cWc aarch64-unknown-linux-gnu (godbolt can't do aarch64-apple-ios but that doesn't matter here)

A different (and more efficient) option than this would be to just use the AtomicU64 and use the knowledge that after initialization the denominator should be nonzero... That felt like it's relying on too many things I'm not confident in, so I didn't want to do that.
</details>
2020-10-11 14:06:04 +00:00
Stefan Lankes
8d8a290c69
add hermit to the list of omit OS 2020-10-11 11:56:09 +02:00
Stefan Lankes
530f575466
revise code to pass the format check 2020-10-11 11:56:00 +02:00
Stefan Lankes
d6e955f3bf
fix typos in new method 2020-10-11 11:55:51 +02:00
Stefan Lankes
986c1fc053
revise comments and descriptions of the helper functions 2020-10-11 11:54:54 +02:00
Stefan Lankes
d560b50d87
revise code to pass the format check 2020-10-11 11:54:16 +02:00
Stefan Lankes
98fcc3fbc7
using the latest version of libhermit-rs 2020-10-11 11:53:54 +02:00
Stefan Lankes
16d65d0432
revise Hermit's mutex interface to support the behaviour of StaticMutex
rust-lang/rust#77147 simplifies things by splitting this Mutex type
into two types matching the two use cases: StaticMutex and MovableMutex.
To support the behavior of StaticMutex, we move part of the mutex
implementation into libstd.
2020-10-11 11:53:30 +02:00
Yuki Okushi
82c538c619
Rollup merge of #77777 - cuviper:doc-stat, r=jonas-schievink
doc: disambiguate stat in MetadataExt::as_raw_stat

A few architectures in `os::linux::raw` import `libc::stat`, rather than
defining that type directly. However, that also imports the _function_
called `stat`, which makes this doc link ambiguous:

    error: `crate::os::linux::raw::stat` is both a struct and a function
      --> library/std/src/os/linux/fs.rs:21:19
       |
    21 |     /// [`stat`]: crate::os::linux::raw::stat
       |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^ ambiguous link
       |
       = note: `-D broken-intra-doc-links` implied by `-D warnings`
    help: to link to the struct, prefix with the item type
       |
    21 |     /// [`stat`]: struct@crate::os::linux::raw::stat
       |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    help: to link to the function, add parentheses
       |
    21 |     /// [`stat`]: crate::os::linux::raw::stat()
       |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

We want the `struct`, so it's now prefixed accordingly.
2020-10-11 03:19:18 +09:00