Commit graph

3229 commits

Author SHA1 Message Date
Yuki Okushi
68d4ff04ee
Rollup merge of #82712 - CDirkx:cfg-target_os, r=dtolnay
Remove unnecessary conditional `cfg(target_os)` for `redox` and `vxworks`

`redox` and `vxworks` are now part of target_family `unix`, thus `cfg(unix)` already implies `cfg(target_os="redox")` and `cfg(target_os="vxworks")`

35dbef2350/compiler/rustc_target/src/spec/redox_base.rs (L26)

35dbef2350/compiler/rustc_target/src/spec/vxworks_base.rs (L27)
2021-03-03 16:27:47 +09:00
Yuki Okushi
376655eaf6
Rollup merge of #82710 - peter-kehl:FloatToInit_82709, r=sfackler
FloatToInit: Replacing round_unchecked_to --> to_int_unchecked

FloatToInit docs: Replacing round_unchecked_to with
to_int_unchecked. Bug #82709.
2021-03-03 16:27:46 +09:00
Yuki Okushi
b16b6820d3
Rollup merge of #82589 - LinkTed:master, r=joshtriplett
unix: Non-mutable bufs in send_vectored_with_ancillary_to

This is the same PR as [#79753](https://github.com/rust-lang/rust/pull/79753). It was closed because of inactivity. Therefore, I create a new one. ````@lukaslihotzki````
2021-03-03 16:27:41 +09:00
Yuki Okushi
46f9253098
Rollup merge of #82439 - ssomers:btree_fix_unsafety, r=Mark-Simulacrum
BTree: fix untrue safety

Fix needless and missing `unsafe` tags.

r? ````@Mark-Simulacrum````
2021-03-03 16:27:39 +09:00
Christiaan Dirkx
738f736066 Remove unnecessary conditional cfg(target_os) for redox and vxworks
`redox` and `vxworks` are part of target_family `unix`, thus `cfg(unix)` already implies `cfg(target_os="redox")` and `(target_os="vxworks")`
2021-03-03 01:14:17 +01:00
Peter Kehl
d4763dac9e FloatToInit: Replacing round_unchecked_to --> to_int_unchecked
FloatToInit docs: Replacing round_unchecked_to with
to_int_unchecked. Bug #82709.
2021-03-02 12:38:22 -08:00
bors
795a934b51 Auto merge of #82043 - tmiasko:may-have-side-effect, r=kennytm
Turn may_have_side_effect into an associated constant

The `may_have_side_effect` is an implementation detail of `TrustedRandomAccess`
trait. It describes if obtaining an iterator element may have side effects. It
is currently implemented as an associated function.

Turn `may_have_side_effect` into an associated constant. This makes the
value immediately available to the optimizer.
2021-03-02 16:08:32 +00:00
Yuki Okushi
bc5669eef8
Rollup merge of #80189 - jyn514:convert-primitives, r=poliorcetics
Convert primitives in the standard library to intra-doc links

Blocked on https://github.com/rust-lang/rust/pull/80181. I forgot that this needs to wait for the beta bump so the standard library can be documented with `doc --stage 0`.

Notably I didn't convert `core::slice` because it's like 50 links and I got scared 😨
2021-03-02 21:23:12 +09:00
Guillaume Gomez
9a0ac7cb5f
Rollup merge of #82676 - dtolnay:powers, r=Mark-Simulacrum
Change twice used large const table to static

This table is used twice in core::num::dec2flt::algorithm::power_of_ten. According to the semantics of const, a separate huge definition of the table is inlined at both places.

5233edcf1c/library/core/src/num/dec2flt/algorithm.rs (L16-L22)

Theoretically this gets cleaned up by optimization passes, but in practice I am experiencing a miscompile from LTO on this code. Making the table a static, which would only be defined a single time and not require attention from LTO, eliminates the miscompile and seems semantically more appropriate anyway. A separate bug report on the LTO bug is forthcoming.

Original addition of `const` is from #27307.
2021-03-02 00:50:11 +01:00
Guillaume Gomez
5a82251e92
Rollup merge of #82598 - GuillaumeGomez:rustdoc-rustc-pass, r=jyn514
Check stability and feature attributes in rustdoc

Fixes #82588.

cc `@Nemo157` `@camelid`
r? `@jyn514`
2021-03-02 00:50:08 +01:00
Guillaume Gomez
d20fd62d70 Add missing stability attributes in libstd 2021-03-01 20:28:37 +01:00
David Tolnay
bd51dea693
Change twice used large const table to static
This table is used twice in core::num::dec2flt::algorithm::power_of_ten.
According to the semantics of const, a separate huge definition of the
table is inlined at both places.

    fn power_of_ten(e: i16) -> Fp {
        assert!(e >= table::MIN_E);
        let i = e - table::MIN_E;
        let sig = table::POWERS.0[i as usize];
        let exp = table::POWERS.1[i as usize];
        Fp { f: sig, e: exp }
    }

Theoretically this gets cleaned up by optimization passes, but in
practice I am experiencing a miscompile from LTO on this code. Making
the table a static, which would only be defined a single time and not
require attention from LTO, eliminates the miscompile and seems
semantically more appropriate anyway. A separate bug report on the LTO
bug is forthcoming.
2021-03-01 10:41:16 -08:00
Joshua Nelson
9a86a727c5
Rollup merge of #82645 - rkjnsn:patch-3, r=Mark-Simulacrum
Clarify that SyncOnceCell::set blocks.

Reading the discussion of this feature, I gained the mistaken impression that neither `set` nor `get` blocked, and thus calling `get` immediately after `set` was not guaranteed to succeed. It turns out that `set` *does* block, guaranteeing that the cell contains a value once `set` returns. This change updates the documentation to state that explicitly.

Happy to adjust the wording as desired.
2021-03-01 11:25:11 -05:00
Joshua Nelson
efb9ee2df5
Rollup merge of #82578 - camsteffen:diag-items, r=oli-obk
Add some diagnostic items for Clippy
2021-03-01 11:25:07 -05:00
Joshua Nelson
57c568a918
Rollup merge of #81210 - ssomers:btree_fix_node_size_test, r=Mark-Simulacrum
BTreeMap: correct node size test case for choices of B

r? `@Mark-Simulacrum`
2021-03-01 11:24:58 -05:00
Cameron Steffen
eada4d1c45 Add diagnostic items 2021-03-01 09:04:11 -06:00
bors
d2731d8e93 Auto merge of #82654 - JohnTitor:rollup-nkcdkzp, r=JohnTitor
Rollup of 10 pull requests

Successful merges:

 - #82309 (Propagate RUSTDOCFLAGS in the environment when documenting)
 - #82403 (rustbuild: print out env vars on verbose rustc invocations)
 - #82507 (Rename the `tidy` binary to `rust-tidy`)
 - #82531 (Add GUI tests)
 - #82532 (Add `build.print_step_rusage` to config.toml)
 - #82543 (fix env var name in CI)
 - #82622 (Propagate `--test-args` for `x.py test src/tools/cargo`)
 - #82628 (Try to clarify GlobalAlloc::realloc documentation comment.)
 - #82630 (Fix a typo in the `find_anon_type` doc)
 - #82643 (Add more proc-macro attribute tests)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-03-01 08:22:06 +00:00
Yuki Okushi
1b9f420e1b
Rollup merge of #82628 - vakaras:realloc-doc, r=Mark-Simulacrum
Try to clarify GlobalAlloc::realloc documentation comment.

This PR tries to improve the documentation of [GlobalAlloc::realloc](https://doc.rust-lang.org/alloc/alloc/trait.GlobalAlloc.html#method.realloc) with two aspects:

1. Explicitly mention that `realloc` preserves the contents of the original memory block.
2. Explicitly mention which layout should be used to deallocate the reallocated block.
2021-03-01 15:07:38 +09:00
bors
05c300144c Auto merge of #82440 - ssomers:btree_fix_casts, r=Mark-Simulacrum
BTree: no longer define impossible casts

Casts to leaf to internal only make sense when the original has a chance of being the thing it's cast to.

r? `@Mark-Simulacrum`
2021-03-01 05:39:01 +00:00
bors
3b150b7a8f Auto merge of #81094 - ssomers:btree_drainy_refactor_3, r=Mark-Simulacrum
BTreeMap: split up range_search into two stages

`range_search` expects the caller to pass the same root twice and starts searching a node for both bounds of a range. It's not very clear that in the early iterations, it searches twice in the same node. This PR splits that search up in an initial `find_leaf_edges_spanning_range` that postpones aliasing until the last second, and a second phase for continuing the search for the range in the each subtree independently (`find_lower_bound_edge` & `find_upper_bound_edge`), which greatly helps for use in #81075. It also moves those functions over to the search module.

r? `@Mark-Simulacrum`
2021-03-01 02:48:29 +00:00
Erik Jensen
2616960be2
Clarify that SyncOnceCell::set blocks.
Reading the discussion of this feature, I gained the mistaken impression that neither `set` nor `get` blocked, and thus calling `get` immediately after `set` was not guaranteed to succeed. It turns out that `set` *does* block, guaranteeing that the cell contains a value once `set` returns. This change updates the documentation to state that explicitly.
2021-02-28 12:57:38 -08:00
Vytautas Astrauskas
cdfff98394 Try to clarify GlobalAlloc::realloc documentation comment. 2021-02-28 14:30:26 +01:00
LinkTed
9e4e739209 unix: Non-mutable bufs in send_vectored_with_ancillary_to
Change the arguments of `send_vectored_with_ancillary` and
`send_vectored_with_ancillary_to` to take an non-mutable bufs.
2021-02-28 13:33:09 +01:00
bors
247337f409 Auto merge of #82350 - ehuss:test-chapter, r=jyn514
Add a chapter on the test harness.

There isn't really any online documentation on the test harness, so this adds a chapter to the rustc book which provides information on how the harness works and details on the command-line options.
2021-02-28 09:18:27 +00:00
bors
6e2801c44e Auto merge of #82594 - nagisa:nagisa/remove-rumprun, r=petrochenkov
Remove the x86_64-rumprun-netbsd target

Herein we remove the target from the compiler and the code from libstd intended to support the now-defunct rumprun project.

Closes #81514
2021-02-28 03:56:16 +00:00
Dylan DPC
e38b3eb0b5
Rollup merge of #82596 - matklad:rwlock, r=sfackler
clarify RW lock's priority gotcha

In particular, the following program works on Linux, but deadlocks on
mac:

```rust
    use std::{
        sync::{Arc, RwLock},
        thread,
        time::Duration,
    };

    fn main() {
        let lock = Arc::new(RwLock::new(()));

        let r1 = thread::spawn({
            let lock = Arc::clone(&lock);
            move || {
                let _rg = lock.read();
                eprintln!("r1/1");
                sleep(1000);

                let _rg = lock.read();
                eprintln!("r1/2");

                sleep(5000);
            }
        });
        sleep(100);
        let w = thread::spawn({
            let lock = Arc::clone(&lock);
            move || {
                let _wg = lock.write();
                eprintln!("w");
            }
        });
        sleep(100);
        let r2 = thread::spawn({
            let lock = Arc::clone(&lock);
            move || {
                let _rg = lock.read();
                eprintln!("r2");
                sleep(2000);
            }
        });

        r1.join().unwrap();
        r2.join().unwrap();
        w.join().unwrap();
    }

    fn sleep(ms: u64) {
        std:🧵:sleep(Duration::from_millis(ms))
    }
```

Context: I was completely mystified by a my CI deadlocking on mac ([here](https://github.com/matklad/xshell/pull/7)), until ``@azdavis`` debugged the issue. See a stand-alone reproduciton here: https://github.com/matklad/xshell/pull/15
2021-02-27 21:56:24 +01:00
Dylan DPC
b1113abacd
Rollup merge of #82561 - tspiteri:cube-root, r=Dylan-DPC
doc: cube root, not cubic root

Like we say square root, not quadratic root.
2021-02-27 21:56:21 +01:00
Dylan DPC
ea43e5e21d
Rollup merge of #82395 - pickfire:see-more, r=GuillaumeGomez
Add missing "see its documentation for more" stdio

StdoutLock and StderrLock does not have example, it would be better
to leave "see its documentation for more" like iter docs.
2021-02-27 21:56:16 +01:00
Aleksey Kladov
261c952ba6
Update library/std/src/sync/rwlock.rs
Co-authored-by: Steven Fackler <sfackler@gmail.com>
2021-02-27 19:44:17 +03:00
Aleksey Kladov
d94b4e81e4 clarify RW lock's priority gotcha
In particular, the following program works on Linux, but deadlocks on
mac:

    use std::{
        sync::{Arc, RwLock},
        thread,
        time::Duration,
    };

    fn main() {
        let lock = Arc::new(RwLock::new(()));

        let r1 = thread::spawn({
            let lock = Arc::clone(&lock);
            move || {
                let _rg = lock.read();
                eprintln!("r1/1");
                sleep(1000);

                let _rg = lock.read();
                eprintln!("r1/2");

                sleep(5000);
            }
        });
        sleep(100);
        let w = thread::spawn({
            let lock = Arc::clone(&lock);
            move || {
                let _wg = lock.write();
                eprintln!("w");
            }
        });
        sleep(100);
        let r2 = thread::spawn({
            let lock = Arc::clone(&lock);
            move || {
                let _rg = lock.read();
                eprintln!("r2");
                sleep(2000);
            }
        });

        r1.join().unwrap();
        r2.join().unwrap();
        w.join().unwrap();
    }

    fn sleep(ms: u64) {
        std:🧵:sleep(Duration::from_millis(ms))
    }
2021-02-27 19:21:50 +03:00
Simonas Kazlauskas
a757fae245 Remove the x86_64-rumprun-netbsd target
Closes #81514
2021-02-27 17:55:22 +02:00
bors
ec7f8d94df Auto merge of #81874 - tesuji:spec_slice_fill, r=matthewjasper
Specialize slice::fill with Copy type and u8/i8/bool

I don't expect rustperf could measure any perf improvements with this changes
since `slice::fill` is newly added.

Godbolt link for this change: <https://rust.godbolt.org/z/r3fzee>.

r? `@matthewjasper` since this patch added new specialization.
2021-02-27 14:54:31 +00:00
Dylan DPC
b664e4bdb5
Rollup merge of #82473 - de-vri-es:android-x86-accept4, r=m-ou-se
Use libc::accept4 on Android instead of raw syscall.

This PR replaces the use of a raw `accept4` syscall with `libc::accept4`. This was originally added (by me) because `std` couldn't update to the latest `libc` with `accept4` support for android. By now, libc is already on 0.2.85, so the workaround can be removed.

`@rustbot` label +O-android +T-libs-impl
2021-02-27 02:34:31 +01:00
Dylan DPC
d80033f048
Rollup merge of #82421 - sunfishcode:wasi-metadata-size, r=alexcrichton
Add a `size()` function to WASI's `MetadataExt`.

WASI's `filestat` type includes a size field, so expose it in
`MetadataExt` via a `size()` function, similar to the corresponding Unix
function.

r? ``````@alexcrichton``````
2021-02-27 02:34:28 +01:00
Dylan DPC
f5b68a4444
Rollup merge of #82420 - sunfishcode:wasi-docs, r=alexcrichton
Enable API documentation for `std::os::wasi`.

This adds API documentation support for `std::os::wasi` modeled after
how `std::os::unix` works, so that WASI can be documented [here] along
with the other platforms.

[here]: https://doc.rust-lang.org/stable/std/os/index.html

Two changes of particular interest:

 - This changes the `AsRawFd` for `io::Stdin` for WASI to return
   `libc::STDIN_FILENO` instead of `sys::stdio::Stdin.as_raw_fd()` (and
   similar for `Stdout` and `Stderr`), which matches how the `unix`
   version works. `STDIN_FILENO` etc. may not always be explicitly
   reserved at the WASI level, but as long as we have Rust's `std` and
   `libc`, I think it's reasonable to guarantee that we'll always use
   `libc::STDIN_FILENO` for stdin.

 - This duplicates the `osstr2str` utility function, rather than
   trying to share it across all the configurations that need it.

r? ```@alexcrichton```
2021-02-27 02:34:27 +01:00
Trevor Spiteri
dd502cb343 doc: cube root, not cubic root
Like we say square root, not quadratic root.
2021-02-26 19:03:44 +01:00
Guillaume Gomez
0db8349fff
Rollup merge of #81940 - jhpratt:stabilize-str_split_once, r=m-ou-se
Stabilize str_split_once

Closes #74773
2021-02-26 15:52:29 +01:00
Joshua Nelson
4d46735b8e Convert the rest of the standard library primitives to intra-doc links
Note that float methods in `core::intrinsics` weren't converted because
they are only defined in `std` (using language item hacks).
2021-02-25 20:32:49 -05:00
Joshua Nelson
9a75f4fed1 Convert primitives to use intra-doc links 2021-02-25 20:31:53 -05:00
bors
d95d304861 Auto merge of #78429 - casey:doctest-attribute-splitting, r=jyn514
[librustdoc] Only split lang string on `,`, ` `, and `\t`

Split markdown lang strings into tokens on `,`.

The previous behavior was to split lang strings into tokens on any
character that wasn't a `_`, `_`, or alphanumeric.

This is a potentially breaking change, so please scrutinize! See discussion in #78344.

I noticed some test cases that made me wonder if there might have been some reason for the original behavior:

```
t("{.no_run .example}", false, true, Ignore::None, true, false, false, false, v(), None);
t("{.sh .should_panic}", true, false, Ignore::None, false, false, false, false, v(), None);
t("{.example .rust}", false, false, Ignore::None, true, false, false, false, v(), None);
t("{.test_harness .rust}", false, false, Ignore::None, true, true, false, false, v(), None);
```

It seemed pretty peculiar to specifically test lang strings in braces, with all the tokens prefixed by `.`.

I did some digging, and it looks like the test cases were added way back in [this commit from 2014](https://github.com/rust-lang/rust/commit/3fef7a74ca9a) by `@skade.`

It looks like they were added just to make sure that the splitting was permissive, and aren't testing that those strings in particular are accepted.

Closes https://github.com/rust-lang/rust/issues/78344.
2021-02-26 00:17:22 +00:00
Aaron Hill
befa2dffda
Rollup merge of #82467 - ojeda:tidy-normalize-safety-comments, r=kennytm
library: Normalize safety-for-unsafe-block comments

Almost all safety comments are of the form `// SAFETY:`,
so normalize the rest and fix a few of them that should
have been a `/// # Safety` section instead.

Furthermore, make `tidy` only allow the uppercase form. While
currently `tidy` only checks `core`, it is a good idea to prevent
`core` from drifting to non-uppercase comments, so that later
we can start checking `alloc` etc. too.

Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2021-02-25 16:06:21 -05:00
Aaron Hill
503d50b94c
Rollup merge of #82464 - ehuss:unix-command-comment, r=kennytm
Update outdated comment in unix Command.

The big comment in the `Command` struct has been incorrect for some time (at least since #46789 which removed `envp`). Rather than try to remove the allocations, this PR just updates the comment to reflect reality. There is an explanation for the reasoning at https://github.com/rust-lang/rust/pull/31409#issuecomment-182122895, discussing the potential of being able to call `Command::exec` after `libc::fork`.  That can still be done in the future, but I think for now it would be good to just correct the comment.
2021-02-25 16:06:20 -05:00
Dylan DPC
f891af9de5
Rollup merge of #82078 - lopopolo:char-u8-const-fn, r=m-ou-se
Make char and u8 methods const

char methods `len_utf8`, `len_utf16`, `to_ascii_lowercase`, `eq_ignore_ascii_case` can be made const.

`u8` methods `to_ascii_lowercase`, `to_ascii_uppercase` are required to be const as well.

`u8::eq_ignore_ascii_case` was additionally made const.

Rebase of https://github.com/rust-lang/rust/pull/79549 originally authored by ``@YenForYang.`` Changes from that PR:

- Squashed all commits from #79549.
- rebased to latest upstream master.
- Removed const attributes for `char::escape_unicode` and `char::escape_default`.
- Updated `since` attributes for `const` stabilization to 1.52.0.

cc ``@m-ou-se.``
2021-02-25 14:33:55 +01:00
Dylan DPC
4b9c213d6f
Rollup merge of #81167 - usbalbin:const_write, r=oli-obk
Make ptr::write const

~~The code in this PR as of right now is not much more than an experiment.~~

~~This should, if I am not mistaken, in theory compile and pass the tests once the bootstraping compiler is updated. Thus the PR is blocked on that which should happen some time after the February the 9th. Also we might want to wait for #79989 to avoid regressing performance due to using `mem::forget` over `intrinsics::forget`~~.
2021-02-25 14:33:51 +01:00
Dylan DPC
351d947e54
Rollup merge of #80553 - derekdreery:arc_error, r=m-ou-se
Add an impl of Error on `Arc<impl Error>`.

`Display` already exists so this should be a non-controversial change (famous last words).

Would have to be insta-stable.
2021-02-25 14:33:50 +01:00
Dylan DPC
cb2b4ff714
Rollup merge of #80534 - LeSeulArtichaut:doc-include, r=jyn514
Use #[doc = include_str!()] in std

cc https://github.com/rust-lang/rust/issues/78835#issuecomment-742531894
r? `````@jyn514`````
2021-02-25 14:33:47 +01:00
Dylan DPC
c9cf92226c
Rollup merge of #75807 - jyn514:num-intra-link, r=poliorcetics
Convert core/num/mod.rs to intra-doc links

Helps with #75080.
This can't convert the associated constants `MAX` and `MIN` until #74489 is merged.

r? `@poliorcetics`
2021-02-25 14:33:44 +01:00
bors
63bacf14cd Auto merge of #82162 - cuviper:flat-fold, r=Mark-Simulacrum
Expand FlattenCompat folds

The former `chain`+`chain`+`fold` implementation looked nice from a
functional-programming perspective, but it introduced unnecessary layers
of abstraction on every `flat_map`/`flatten` fold. It's straightforward
to just fold each part in turn, and this makes it look like a simplified
version of the existing `try_fold` implementation.

For the `iter::bench_flat_map*` benchmarks, I get a large improvement in
`bench_flat_map_chain_sum`, from 1,598,473 ns/iter to 499,889 ns/iter,
and the rest are unchanged.
2021-02-25 00:36:05 +00:00
Dan Gohman
7d5242a03a x.py fmt 2021-02-24 10:58:21 -08:00
Dan Gohman
94e75acf1f Mention "wasi" in the comment about "main modules". 2021-02-24 10:47:26 -08:00