Commit graph

528 commits

Author SHA1 Message Date
Prabakaran Kumaresshan
9463380b0c Switch to intra-doc links in std/src/sys/vxworks/ext/{fs,process}.rs 2020-08-15 19:39:17 +05:30
bors
80fb3f3139 Auto merge of #74576 - myfreeweb:freebsd-sanitizers, r=oli-obk
Add sanitizer support on FreeBSD

Restarting #47337. Everything is better now, no more weird llvm problems, well not everything:

Unfortunately, the sanitizers don't have proper support for versioned symbols (https://github.com/google/sanitizers/issues/628), so `libc`'s usage of `stat@FBSD_1.0` and so on explodes, e.g. in calling `std::fs::metadata`.

Building std (now easy thanks to cargo `-Zbuild-std`) and libc with `freebsd12/13` config via the `LIBC_CI=1` env variable is a good workaround…

```
LIBC_CI=1 RUSTFLAGS="-Z sanitizer=address" cargo +san-test -Zbuild-std run --target x86_64-unknown-freebsd --verbose
```

…*except* std won't build because there's no `st_lspare` in the ino64 version of the struct, so an std patch is required:

```diff
--- i/src/libstd/os/freebsd/fs.rs
+++ w/src/libstd/os/freebsd/fs.rs
@@ -66,8 +66,6 @@ pub trait MetadataExt {
     fn st_flags(&self) -> u32;
     #[stable(feature = "metadata_ext2", since = "1.8.0")]
     fn st_gen(&self) -> u32;
-    #[stable(feature = "metadata_ext2", since = "1.8.0")]
-    fn st_lspare(&self) -> u32;
 }

 #[stable(feature = "metadata_ext", since = "1.1.0")]
@@ -136,7 +134,4 @@ impl MetadataExt for Metadata {
     fn st_flags(&self) -> u32 {
         self.as_inner().as_inner().st_flags as u32
     }
-    fn st_lspare(&self) -> u32 {
-        self.as_inner().as_inner().st_lspare as u32
-    }
 }
```

I guess std could like.. detect that `libc` isn't built for the old ABI, and replace the implementation of `st_lspare` with a panic?
2020-08-15 11:38:24 +00:00
Ivan Tham
446fccf1b8
Use resolve.conf as example for Path ends_with 2020-08-15 17:25:07 +08:00
bors
f7aac25850 Auto merge of #75488 - ssomers:btree_revert_75257, r=Mark-Simulacrum
Revert the fundamental changes in #74762 and #75257

Before possibly going over to #75487. Also contains some added and fixed comments.

r? @Mark-Simulacrum
2020-08-15 05:43:00 +00:00
Tyler Mandry
29a946203a
Rollup merge of #75545 - eddyb:instant-sub-branchless, r=sfackler
std/sys/unix/time: make it easier for LLVM to optimize `Instant` subtraction.

This PR is the minimal change necessary to get LLVM to optimize `if self.t.tv_nsec >= other.t.tv_nsec` to branchless instructions (at least on x86_64), inspired by @m-ou-se's own attempts at optimizing `Instant` subtraction.

I stumbled over this by looking at the total number of instructions executed by `rustc -Z self-profile`, and found that after disabling ASLR, the largest source of non-determinism remaining was from this `if` taking one branch or the other, depending on the values involved.

The reason this code is even called so many times to make a difference, is that `measureme` (the `-Z self-profile` implementation) currently uses `Instant::elapsed` for its event timestamps (of which there can be millions).

I doubt it's critical to land this, although perhaps it could slightly improve some forms of benchmarking.
2020-08-14 20:07:16 -07:00
DPC
9ad17b9ca7 tidy up 2020-08-15 03:16:20 +02:00
Eduard-Mihai Burtescu
a7ad899f9d std/sys/unix/time: make it easier for LLVM to optimize Instant subtraction. 2020-08-15 04:13:25 +03:00
Denis Vasilik
ebcb99ef8f Use intra-doc links 2020-08-15 01:12:47 +02:00
Camelid
b1c05c5c2b Switch to intra-doc links in core::option 2020-08-14 16:11:43 -07:00
Tyler Mandry
939befd65e
Rollup merge of #75531 - ssomers:btree_tests_migration, r=Mark-Simulacrum
Migrate unit tests of btree collections to their native breeding ground

There's one BTreeSet test case that I couldn't easily convince to come along, maybe because it truly is an integration test. But leaving it in place would mean git wouldn't see the move so I also moved it to a new file.

r? @Mark-Simulacrum
2020-08-14 14:47:04 -07:00
Tyler Mandry
6d09e29f5e
Rollup merge of #75530 - nixphix:docs/os-raw, r=jyn514
Switch to intra-doc links in os/raw/*.md

Partial fix for #75080

@rustbot modify labels: T-doc, A-intra-doc-links, T-rustdoc

r? @jyn514
2020-08-14 14:47:03 -07:00
Tyler Mandry
2564135115
Rollup merge of #75519 - ssomers:btree_splitpoint_cleanup, r=Mark-Simulacrum
BTreeMap: refactor splitpoint and move testing over to unit test

r? @Mark-Simulacrum
2020-08-14 14:47:01 -07:00
Tyler Mandry
83c04392c8
Rollup merge of #75515 - workingjubilee:patch-4, r=Mark-Simulacrum
Bump std's libc version to 0.2.74

It's been a while and this should really be using a recent version, that's all. 💖
2020-08-14 14:46:57 -07:00
Tyler Mandry
ad1bfd2f3e
Rollup merge of #75501 - poliorcetics:intra-links-std-ffi, r=jyn514
Move to intra doc links in std::ffi

Helps with #75080.

@rustbot modify labels: T-doc, A-intra-doc-links, T-rustdoc
2020-08-14 14:46:52 -07:00
Tyler Mandry
b0261814f1
Rollup merge of #75432 - camelid:intra-doc-links-for-std-process, r=jyn514
Switch to intra-doc links in `std::process`

Part of #75080.
2020-08-14 14:46:49 -07:00
Tyler Mandry
ad8c5e1480
Rollup merge of #75214 - chansuke:fix-intra-doc-links, r=jyn514
Use intra-doc links in `mem::manually_drop` & `mem::maybe_uninit`

This is partial fixes for https://github.com/rust-lang/rust/issues/75080.
2020-08-14 14:46:47 -07:00
Tyler Mandry
83e75acdec
Rollup merge of #75195 - ssomers:btree_split_up_into_kv_mut, r=Mark-Simulacrum
BTreeMap: purge innocent use of into_kv_mut

Replace the use of `into_kv_mut` into more precise calls. This makes more sense if you know that the single remaining use of `into_kv_mut` is in fact evil and can be trialled in court (#75200) and sent to a correction facility (#73971).

No real performance difference reported (but functions that might benefit a tiny constant bit like `BTreeMap::get_mut` aren't benchmarked):
```
benchcmp old new --threshold 5
 name                       old ns/iter  new ns/iter  diff ns/iter  diff %  speedup
 btree::map::clone_fat_100  63,073       59,256             -3,817  -6.05%   x 1.06
 btree::map::iter_100       3,514        3,235                -279  -7.94%   x 1.09
```
2020-08-14 14:46:45 -07:00
Tyler Mandry
5b61230303
Rollup merge of #74409 - LukasKalbertodt:improve-debug-impl-of-socketaddr-ipaddr, r=Amanieu
Change Debug impl of SocketAddr and IpAddr to match their Display output

This has already been done for `SocketAddrV4`, `SocketAddrV6`, `IpAddrV4` and `IpAddrV6`. I don't see a point to keep the rather bad to read derived impl, especially so when pretty printing:

    V4(
        127.0.0.1
    )

From the `Display`, one can easily and unambiguously see if it's V4 or V6. Two examples:

```
127.0.0.1:443
[2001:db8:85a3::8a2e:370:7334]:443
```

Luckily the docs explicitly state that `Debug` output is not stable and that it may be changed at any time.

Using `Display` as `Debug` is very convenient for configuration structs (e.g. for webservers) that often just have a `derive(Debug)` and are printed that way to the one starting the server.
2020-08-14 14:46:44 -07:00
Tyler Mandry
dae020d491
Rollup merge of #74192 - xkr47:patch-1, r=Mark-Simulacrum
Improve documentation on process::Child.std* fields

As a relative beginner, it took a while for me to figure out I could just steal the references to avoid partially moving the child and thus retain ability to call functions on it (and store it in structs etc).
2020-08-14 14:46:41 -07:00
Tyler Mandry
3111a8c1e2
Rollup merge of #74185 - pickfire:liballoc-iter-doc, r=jyn514
Remove liballoc unneeded explicit link
2020-08-14 14:46:40 -07:00
Tyler Mandry
fba3989052
Rollup merge of #74062 - poliorcetics:unsafe-in-unsafe-c_str, r=Mark-Simulacrum
deny(unsafe_op_in_unsafe_fn) in libstd/ffi/c_str.rs

Partial fix of #73904.

This encloses `unsafe` operations in `unsafe fn` in `libstd/ffi/c_str.rs`.
2020-08-14 14:46:33 -07:00
Alexis Bourget
0e610bb31e Document the unsafe keyword 2020-08-14 22:52:23 +02:00
Denis Vasilik
75c1e2dfbb Use intra-doc links 2020-08-14 20:50:38 +02:00
chansuke
61866bc60c Use intra-doc links in mem::manually_drop & mem::maybe_uninit 2020-08-15 02:33:39 +09:00
Alexis Bourget
e97fa1e3da libstd/ffi/c_str.rs: #![deny(unsafe_op_in_unsafe_fn)], enclose unsafe operations in unsafe blocks 2020-08-14 19:33:04 +02:00
Poliorcetics
ee4f893e27
Apply suggestions from code review
Co-authored-by: Joshua Nelson <joshua@yottadb.com>
2020-08-14 19:08:09 +02:00
Prabakaran Kumaresshan
84539eb7b5 remove primitive type links 2020-08-14 21:57:42 +05:30
Stein Somers
ff45df2acf Move btree unit test to their native, privileged location 2020-08-14 17:54:09 +02:00
Prabakaran Kumaresshan
232e3d04b3 Switch to intra-doc links in os/raw/*.md 2020-08-14 21:09:35 +05:30
Stein Somers
8d1c3c116b BTreeMap: refactor splitpoint and move testing over to unit test 2020-08-14 16:41:54 +02:00
bors
55b9adfafa Auto merge of #75157 - rodrimati1992:patch-1, r=oli-obk
Constified str::from_utf8_unchecked

This would be useful for const code to use an array to construct a string using guaranteed utf8 inputs, and then create a `&str` from it.
2020-08-14 14:08:05 +00:00
Stein Somers
421e0ff3d9 BTreeMap: refactor splitpoint and move testing over to unit test 2020-08-14 14:50:30 +02:00
Jonas Berlin
90e4c905d3 Improve documentation on process::Child.std* fields
As a relative beginner, it took a while for me to figure out I could just steal the references to avoid partially moving the child and thus retain ability to call functions on it (and store it in structs etc).
2020-08-14 08:25:45 -04:00
bors
7996182bc1 Auto merge of #74777 - ssomers:btree_cleanup_7, r=Mark-Simulacrum
Stop BTreeMap casts from reborrowing

Down in btree/node.rs, the interface and use of `cast_unchecked` look a bit shady. It's really just there for inverting `forget_type` which does not borrow. By borrowing we can't write the same `cast_unchecked` in the same way at the Handle level.

No change in undefined behaviour or performance.
2020-08-14 12:00:59 +00:00
Jubilee
28bca67708
Bump std's libc version to 0.2.74 2020-08-14 00:37:19 -07:00
Ivan Tham
d2ecfcf21d Update liballoc vec doc link 2020-08-14 10:52:09 +08:00
Ivan Tham
e0d215ff9e Update src/liballoc/vec.rs
Co-authored-by: Joshua Nelson <joshua@yottadb.com>
2020-08-14 10:50:30 +08:00
Ivan Tham
dba647ef32 Remove liballoc unneeded explicit link 2020-08-14 10:50:30 +08:00
Tyler Mandry
33fca5ab8a
Rollup merge of #75477 - RalfJung:fn-ptrs, r=Mark-Simulacrum
Expand function pointer docs

Be more explicit in the ABI section, and add a section on how to obtain a function pointer, which can be somewhat confusing.

Cc https://github.com/rust-lang/rust/issues/75239
2020-08-13 18:00:21 -07:00
DPC
fdc2d1f499 add missing newline 2020-08-14 01:28:04 +02:00
DPC
db34e352a7 fix duplicated feature gate 2020-08-14 01:05:43 +02:00
bors
81dc88f88f Auto merge of #75105 - ssomers:btree_respect_min_len_hard, r=Mark-Simulacrum
Hard way to respect BTreeMap's minimum node length

Resolves #74834 the hard way (though not the hardest imaginable).

Benchmarks (which are all biased/realistic, inserting keys in ascending order) say:
```
benchcmp r0 r1 --threshold 10
 name                                        r0 ns/iter  r1 ns/iter  diff ns/iter   diff %  speedup
 btree::map::clone_slim_100_and_clear        2,183       2,723                540   24.74%   x 0.80
 btree::map::clone_slim_100_and_drain_all    3,652       4,173                521   14.27%   x 0.88
 btree::map::clone_slim_100_and_drain_half   3,320       3,940                620   18.67%   x 0.84
 btree::map::clone_slim_100_and_into_iter    2,154       2,717                563   26.14%   x 0.79
 btree::map::clone_slim_100_and_pop_all      3,372       3,870                498   14.77%   x 0.87
 btree::map::clone_slim_100_and_remove_all   5,111       5,647                536   10.49%   x 0.91
 btree::map::clone_slim_100_and_remove_half  3,259       3,821                562   17.24%   x 0.85
 btree::map::iter_0                          1,733       1,509               -224  -12.93%   x 1.15
 btree::map::iter_100                        2,714       3,739              1,025   37.77%   x 0.73
 btree::map::iter_10k                        3,728       4,269                541   14.51%   x 0.87
 btree::map::range_unbounded_unbounded       28,426      36,631             8,205   28.86%   x 0.78
 btree::map::range_unbounded_vs_iter         28,808      34,056             5,248   18.22%   x 0.85
```
This difference is not caused by the `debug_assert`-related code in the function `splitpoint`, it's the same without.
2020-08-13 21:36:02 +00:00
Alexis Bourget
2adc8c0e5f Move to intra doc links in std::ffi 2020-08-13 23:19:45 +02:00
Jack Champagne
9b0f3d1266 Fix documentation error 2020-08-13 16:58:50 -04:00
rodrimati1992
18377082f1
Fixed transmute argument 2020-08-13 16:08:22 -03:00
rodrimati1992
1767c8bdf0
Replaced union with transmute 2020-08-13 15:56:23 -03:00
Ralf Jung
2338903260 fn type: structure, and talk a bit more about ABIs and how to create them 2020-08-13 20:18:00 +02:00
Stein Somers
8668e5b29e Reverts the fundamental changes in #74762 and #75257 2020-08-13 16:29:56 +02:00
bors
a0c290f951 Auto merge of #75212 - JulianKnodt:array_map, r=LukasKalbertodt
Add `array` lang item and `[T; N]::map(f: FnMut(T) -> S)`

This introduces an `array` lang item so functions can be defined on top of `[T; N]`. This was previously not done because const-generics was not complete enough to allow for this. Now it is in a state that is usable enough to start adding functions.

The function added is a monadic (I think?) map from `[T; N] -> [S; N]`. Until transmute can function on arrays, it also allocates an extra temporary array, but this can be removed at some point.

r? @lcnr
2020-08-13 12:43:12 +00:00
Ralf Jung
7aac3e0400 pin docs: add some forward references 2020-08-13 14:41:04 +02:00
Stein Somers
0522040233 Stop BTreeMap casts from reborrowing 2020-08-13 09:42:55 +02:00
kadmin
af32db21c8 Add drop check test & MaybeUninit::first_ptr_mut
Also in drop check test add hacky workaround for platforms that don't support
panic=unwind
2020-08-13 03:51:08 +00:00
kadmin
412417d807 Rm hiding feature gate & add 1 more example
Update order docs for `map`
2020-08-13 03:51:05 +00:00
kadmin
54b821ebc0 Add tracking issue #75243
Add note & example about iter order

Add doc changes

Update doc comments
2020-08-13 03:51:01 +00:00
kadmin
56a651ca15 Add recommend changes to array
Switch from indexing to zip, and also use `write` on `MaybeUninit`.

Add array_map feature to core/src/lib

Attempt to fix issue of no such feature

Update w/ pickfire's review

This changes a couple of names around, adds another small test of variable size,
and hides the rustdoc #![feature(..)].

Fmt doctest

Add suggestions from lcnr
2020-08-13 03:50:59 +00:00
kadmin
f6411e4c66 Add Array Impl Lang Item in various places
Add basic test

And also run fmt which is where the other changes are from

Fix mut issues

These only appear when running tests, so resolved by adding mut

Swap order of forget

Add pub and rm guard impl

Add explicit type to guard

Add safety note

Change guard type from T to S

It should never have been T, as it guards over [MaybeUninit<S>; N]
Also add feature to test
2020-08-13 03:50:57 +00:00
kadmin
d8718183b2 Create lang item array and add map fn
This creates the language item for arrays, and adds the map fn which is like map in options or
iterators. It currently allocates an extra array, unfortunately.

Added fixme for transmuting

Fix typo

Add drop guard
2020-08-13 03:50:54 +00:00
Yuki Okushi
5526c1a8cd
Rollup merge of #75469 - camelid:intra-doc-links-std-io-mod, r=KodrAus
Switch to intra-doc links in `std/io/mod.rs`

Part of #75080.
2020-08-13 11:05:47 +09:00
Yuki Okushi
e94f7437bd
Rollup merge of #75466 - poliorcetics:intra-links-std-lib, r=KodrAus
Move to intra doc links whenever possible within std/src/lib.rs

Helps with #75080.

@rustbot modify labels: T-doc, A-intra-doc-links, T-rustdoc

There are some things like

```rust
`//! [`Option<T>`]: option::Option`
```

that will either be fixed in the future or have open issues about them.
2020-08-13 11:05:45 +09:00
Yuki Okushi
9ea03ddd0b
Rollup merge of #75455 - pickfire:patch-3, r=jyn514
Use explicit path link in place for doc in time

r? @jyn514

More worth for your time. :P
2020-08-13 11:05:42 +09:00
Yuki Okushi
66157e27e2
Rollup merge of #75400 - LukasKalbertodt:fix-f32-docs, r=KodrAus
Fix minor things in the `f32` primitive docs

All of these were review comments in #74621 that I first fixed in that PR, but later accidentally overwrote by a force push.

Thanks @the8472 for noticing.

r? @KodrAus
2020-08-13 11:05:37 +09:00
Yuki Okushi
ed543ae2f6
Rollup merge of #75189 - kawamuray:bugfix-wasi-append, r=KodrAus
Fix wasi::fs::OpenOptions to imply write when append is on

This PR fixes a bug in `OpenOptions` of `wasi` platform that it currently doesn't imply write mode when only `append` is enabled.
As explained in the [doc of OpenOptions#append](https://doc.rust-lang.org/std/fs/struct.OpenOptions.html#method.append), calling `.append(true)` should imply `.write(true)` as well.

## Reproduce

Given below simple Rust program:

```rust
use std::fs::OpenOptions;
use std::io::Write;

fn main() {
    let mut file = OpenOptions::new()
        .write(true)
        .create(true)
        .open("foo.txt")
        .unwrap();
    writeln!(file, "abc").unwrap();
}
```

it can successfully compiled into wasm and execute by `wasmtime` runtime:

```sh
$ rustc --target wasm32-wasi write.rs
$ ~/wasmtime/target/debug/wasmtime run --dir=. write.wasm
$ cat foo.txt
abc
```

However when I change `.write(true)` to `.append(true)`, it fails to execute by the error "Capabilities insufficient":

```sh
$ ~/wasmtime/target/debug/wasmtime run --dir=. append.wasm
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Os { code: 76, kind: Other, message: "Capabilities insufficient" }', append.rs:10:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Error: failed to run main module `append.wasm`
...
```

This is because of lacking "rights" on the opened file:

```sh
$ RUST_LOG=trace ~/wasmtime/target/debug/wasmtime run --dir=. append.wasm 2>&1 | grep validate_rights
 TRACE wasi_common::entry                                  >      | validate_rights failed: required rights = HandleRights { base: fd_write (0x40), inheriting: empty (0x0) }; actual rights = HandleRights { base: fd_seek|fd_fdstat_set_flags|fd_sync|fd_tell|fd_advise|fd_filestat_set_times|poll_fd_readwrite (0x88000bc), inheriting: empty (0x0) }
```
2020-08-13 11:05:31 +09:00
DPC
76b99d5f1d Add Arc::new_cyclic 2020-08-13 03:07:54 +02:00
Camelid
a7749fe451 Fix intra-doc link 2020-08-12 15:30:15 -07:00
Camelid
bc8367617e Switch to intra-doc links in std/io/mod.rs 2020-08-12 15:11:17 -07:00
Alexis Bourget
aa1fb31bf1 Move to intra doc links in std/src/fs.rs 2020-08-12 23:59:10 +02:00
Alexis Bourget
3f16597a6a Move to intra doc links whenever possible within std/src/lib.rs 2020-08-12 23:23:07 +02:00
Alexis Bourget
0e010a6992 Move to intra doc links for ascii.rs and panic.rs, updating the docs a little 2020-08-12 22:58:18 +02:00
Lukas Kalbertodt
db99f98c3e
Put panic code path from copy_from_slice into cold function
The previous `assert_eq` generated quite some code, which is especially
problematic when this call is inlined. This commit also slightly
improves the panic message from:

  assertion failed: `(left == right)`
    left: `3`,
   right: `2`: destination and source slices have different lengths

...to:

  source slice length (2) does not match destination slice length (3)
2020-08-12 21:12:21 +02:00
bors
3df25ae186 Auto merge of #75019 - nanpuyue:to_ipv4_mapped, r=LukasKalbertodt
Add Ipv6Addr::to_ipv4_mapped

* add Ipv6Addr::to_ipv4_mapped
* ~~deprecate Ipv4Addr::to_ipv6_compatible & Ipv6Addr::to_ipv4~~ reference: #75150

According to [IETF RFC 4291](https://tools.ietf.org/html/rfc4291#page-10), the "IPv4-Compatible IPv6 address" is deprecated.

> 2.5.5.1.  IPv4-Compatible IPv6 Address
>
>    The "IPv4-Compatible IPv6 address" was defined to assist in the IPv6
>    transition.  The format of the "IPv4-Compatible IPv6 address" is as
>    follows:
>
>    |                80 bits               | 16 |      32 bits        |
>    +--------------------------------------+--------------------------+
>    |0000..............................0000|0000|    IPv4 address     |
>    +--------------------------------------+----+---------------------+
>
>    Note: The IPv4 address used in the "IPv4-Compatible IPv6 address"
>    must be a globally-unique IPv4 unicast address.
>
>    The "IPv4-Compatible IPv6 address" is now deprecated because the
>    current IPv6 transition mechanisms no longer use these addresses.
>    New or updated implementations are not required to support this
>    address type.

And the current implementation of `Ipv4Addr::to_ipv6_compatible`is incorrect: it does not check whether the IPv4 address is a globally-unique IPv4 unicast address.

Please let me know if there are any issues with this pull request.
2020-08-12 16:30:46 +00:00
bors
ded20c98be Auto merge of #75066 - poliorcetics:document-unsafety-in-core-slice, r=LukasKalbertodt
Document unsafety in library/core/src/slice/mod.rs

Restart where #73555 left off, helping with #66219.
2020-08-12 14:18:15 +00:00
Ivan Tham
cda660b5fc
Use explicit path link in place for doc in time 2020-08-12 22:17:12 +08:00
Denis Vasilik
4c5896fbeb
Remove intra-doc link as it resolves without reference link
Co-authored-by: Joshua Nelson <joshua@yottadb.com>
2020-08-12 08:28:55 +02:00
Camelid
d8f96146e8 Use Child::std{in,out,err} instead of Child.
These links were broken before.
2020-08-11 20:10:41 -07:00
Yuki Okushi
2cc7da6f95
Rollup merge of #75424 - joseluis:patch-1, r=joshtriplett
fix wrong word in documentation

Change "two" to "three", since there are three significantly different things printed below that sentence:

---

While these:
```rust
println!("{}, `{name:.*}` has 3 fractional digits", "Hello", 3, name=1234.56);
println!("{}, `{name:.*}` has 3 characters", "Hello", 3, name="1234.56");
println!("{}, `{name:>8.*}` has 3 right-aligned characters", "Hello", 3, name="1234.56");
```

print two significantly different things:

``` rust
Hello, `1234.560` has 3 fractional digits
Hello, `123` has 3 characters
Hello, `     123` has 3 right-aligned characters
```
---
[`https://doc.rust-lang.org/std/fmt/#precision`](https://doc.rust-lang.org/std/fmt/#precision)
2020-08-12 12:07:21 +09:00
Yuki Okushi
7a900835c1
Rollup merge of #75395 - nixphix:docs/os-fs, r=jyn514
Switch to intra-doc links in library/std/src/os/*/fs.rs

Partial fix for #75080

@rustbot modify labels: T-doc, T-rustdoc, A-intra-doc-links
2020-08-12 12:07:17 +09:00
Yuki Okushi
261773e185
Rollup merge of #75371 - poliorcetics:intra-doc-links-std-time, r=jyn514
Move to doc links inside std/time.rs

Helps with #75080.

@rustbot modify labels: T-doc, A-intra-doc-links, T-rustdoc
2020-08-12 12:07:14 +09:00
Yuki Okushi
c423fdeb74
Rollup merge of #75368 - poliorcetics:intra-doc-links-std-prelude, r=jyn514
Move to doc links inside the prelude

Helps with #75080.

@rustbot modify labels: T-doc, A-intra-doc-links, T-rustdoc
2020-08-12 12:07:12 +09:00
Camelid
e005b71125 Switch to intra-doc links in std::process 2020-08-11 18:02:24 -07:00
Stein Somers
17ab457f21 Somewhat complicated way to respect BTreeMap's node length invariant 2020-08-12 00:09:00 +02:00
Denis Vasilik
c4923419c2 Revert broken link 2020-08-11 23:54:51 +02:00
José Luis Cruz
df5c889784
word change
there are three significantly different things printed below
2020-08-11 22:33:11 +02:00
Denis Vasilik
3c2eb18b9b Use intra-doc links 2020-08-11 22:16:31 +02:00
Alexis Bourget
bd01bf9274 Remove two links by changing the doc for SystemTimeError::duration 2020-08-11 21:53:02 +02:00
Poliorcetics
a308e74e13
Add some texts to make the tidy check for unsafe documentation pass 2020-08-11 21:37:22 +02:00
Alexis Bourget
3ff06a9f2c Move the std::vec link back to a path-based link to make it compile with --stage 0 2020-08-11 21:30:20 +02:00
Tyler Mandry
5d9a0b020c
Rollup merge of #75409 - pickfire:patch-4, r=GuillaumeGomez
Fix range term in alloc vec doc

`range` is not an element, it is a variable.

r? @GuillaumeGomez
2020-08-11 12:28:40 -07:00
Tyler Mandry
06eb274bfc
Rollup merge of #75407 - oliver-giersch:set_ptr_value, r=RalfJung
Requested changes to [*mut T|*const T]::set_ptr_value

This is a follow-up to PR #74774 (tracking issue #75091), acting on some change requests made after approval:

- adds `#[must_use]` attribute
- changes type of `val` pointer argument from `()` to `u8`
- adjusts documentation mentioning pointer provenance
2020-08-11 12:28:37 -07:00
Alexis Bourget
91ba92b6df Change safety comment for usize with the one from LukasKalbertodt review 2020-08-11 21:23:00 +02:00
Lzu Tao
e8ea6e59f0 prefer pattern matching over indexing 2020-08-11 16:07:39 +00:00
Ivan Tham
e4f2de2e9a
Fix range term in alloc vec doc
`range` is not an element, it is a variable.
2020-08-11 23:57:13 +08:00
Prabakaran Kumaresshan
32fccc445a Revert #tymethods 2020-08-11 19:50:17 +05:30
oliver-giersch
19c9674966 mentions provenance, changes argument type, adds must_use attr 2020-08-11 16:14:34 +02:00
bors
4b9ac51617 Auto merge of #75388 - JohnTitor:rollup-9tgkxnl, r=JohnTitor
Rollup of 10 pull requests

Successful merges:

 - #74744 (Update RELEASES.md for 1.46.0)
 - #75085 (Transmute big endian `s6_addr` and `[u16; 8]`)
 - #75226 (Miri: Renamed "undef" to "uninit")
 - #75333 (polymorphize: constrain unevaluated const handling)
 - #75338 (move stack size check to const_eval machine)
 - #75347 (Rustdoc: Fix natural ordering to look at all numbers.)
 - #75352 (Tweak conditions for E0026 and E0769)
 - #75353 (Tiny cleanup, remove unnecessary `unwrap`)
 - #75359 (unused_delims: trim expr)
 - #75360 (Add sample fix for E0749)

Failed merges:

r? @ghost
2020-08-11 12:31:56 +00:00
Lukas Kalbertodt
709d1056b8
Fix minor things in the f32 primitive docs
All of these were review comments in #74621 that I first fixed
in that PR, but later accidentally overwrote by a force push.
2020-08-11 13:50:54 +02:00
Stein Somers
3a02e06002 BTreeMap: purge innocent use of into_kv_mut 2020-08-11 12:20:18 +02:00
Prabakaran Kumaresshan
29045b699e Switch to intra-doc links in library/std/src/os/*/fs.rs 2020-08-11 15:20:01 +05:30
Oliver Scherer
34c3c0dae5 Make <*const T>::is_null const fn 2020-08-11 11:45:47 +02:00
Yuki Okushi
f26f201d42
Rollup merge of #75085 - lzutao:ip_union, r=cuviper
Transmute big endian `s6_addr` and `[u16; 8]`

The old code already made the assumption to reinterpret
`Ipv6Addr` as `[u16; 8]`.

Glibc, Linux, FreeBSD, Win32 all makes this assumption.
The main motivation of using union it to better optimize code.
Godbolt: https://rust.godbolt.org/z/b4bGvo
Const is introducing unsafe when transmuting.

ref:
* https://docs.microsoft.com/en-us/windows/win32/api/in6addr/ns-in6addr-in6_addr
* 1d6e424741/contrib/ntp/lib/isc/include/isc/ipv6.h (L63)
* 8b531aa996/include/net/net_ip.h (L137)
* https://sourceware.org/git/?p=glibc.git;a=blob;f=inet/netinet/in.h;h=f6355c7efe5192b88337b136ef687fe9a5ed648c;hb=HEAD#l216
2020-08-11 16:23:45 +09:00
Ivan Tham
8ec348afdd Remove branch in optimized is_ascii
Performs slightly better in short or medium bytes by eliminating
the last branch check on `byte_pos == len` and always check the
last byte as it is always at most one `usize`.

Benchmark, before `libcore`, after `libcore_new`. It improves
medium and short by 1ns but regresses unaligned_tail by 2ns,
either way we can get unaligned_tail have a tiny chance of 1/8
on a 64 bit machine. I don't think we should bet on that, the
probability is worse than dice.

test long::case00_libcore                     ... bench:          38 ns/iter (+/- 1) = 183947 MB/s
test long::case00_libcore_new                 ... bench:          38 ns/iter (+/- 1) = 183947 MB/s
test long::case01_iter_all                    ... bench:         227 ns/iter (+/- 6) = 30792 MB/s
test long::case02_align_to                    ... bench:          40 ns/iter (+/- 1) = 174750 MB/s
test long::case03_align_to_unrolled           ... bench:          19 ns/iter (+/- 1) = 367894 MB/s
test medium::case00_libcore                   ... bench:           5 ns/iter (+/- 0) = 6400 MB/s
test medium::case00_libcore_new               ... bench:           4 ns/iter (+/- 0) = 8000 MB/s
test medium::case01_iter_all                  ... bench:          20 ns/iter (+/- 1) = 1600 MB/s
test medium::case02_align_to                  ... bench:           6 ns/iter (+/- 0) = 5333 MB/s
test medium::case03_align_to_unrolled         ... bench:           5 ns/iter (+/- 0) = 6400 MB/s
test short::case00_libcore                    ... bench:           7 ns/iter (+/- 0) = 1000 MB/s
test short::case00_libcore_new                ... bench:           6 ns/iter (+/- 0) = 1166 MB/s
test short::case01_iter_all                   ... bench:           5 ns/iter (+/- 0) = 1400 MB/s
test short::case02_align_to                   ... bench:           5 ns/iter (+/- 0) = 1400 MB/s
test short::case03_align_to_unrolled          ... bench:           5 ns/iter (+/- 1) = 1400 MB/s
test unaligned_both::case00_libcore           ... bench:           4 ns/iter (+/- 0) = 7500 MB/s
test unaligned_both::case00_libcore_new       ... bench:           4 ns/iter (+/- 0) = 7500 MB/s
test unaligned_both::case01_iter_all          ... bench:          26 ns/iter (+/- 0) = 1153 MB/s
test unaligned_both::case02_align_to          ... bench:          13 ns/iter (+/- 2) = 2307 MB/s
test unaligned_both::case03_align_to_unrolled ... bench:          11 ns/iter (+/- 0) = 2727 MB/s
test unaligned_head::case00_libcore           ... bench:           5 ns/iter (+/- 0) = 6200 MB/s
test unaligned_head::case00_libcore_new       ... bench:           5 ns/iter (+/- 0) = 6200 MB/s
test unaligned_head::case01_iter_all          ... bench:          19 ns/iter (+/- 1) = 1631 MB/s
test unaligned_head::case02_align_to          ... bench:          10 ns/iter (+/- 0) = 3100 MB/s
test unaligned_head::case03_align_to_unrolled ... bench:          14 ns/iter (+/- 0) = 2214 MB/s
test unaligned_tail::case00_libcore           ... bench:           3 ns/iter (+/- 0) = 10333 MB/s
test unaligned_tail::case00_libcore_new       ... bench:           5 ns/iter (+/- 0) = 6200 MB/s
test unaligned_tail::case01_iter_all          ... bench:          19 ns/iter (+/- 0) = 1631 MB/s
test unaligned_tail::case02_align_to          ... bench:          10 ns/iter (+/- 0) = 3100 MB/s
test unaligned_tail::case03_align_to_unrolled ... bench:          13 ns/iter (+/- 0) = 2384 MB/s

Rough (unfair) maths on improvements for fun: 1ns * 7/8 - 2ns * 1/8 = 0.625ns

Inspired by fish and zsh clever trick to highlight missing linefeeds (⏎)
and branchless implementation of binary_search in rust.
2020-08-11 14:40:39 +08:00
bors
441fd22557 Auto merge of #75329 - ssomers:btree_cleanup_8, r=Mark-Simulacrum
BTreeMap: better distinguish the root holder from the root node

Renames and intermediate variables
2020-08-11 06:17:02 +00:00
bors
a9025c571e Auto merge of #74621 - LukasKalbertodt:float-docs, r=GuillaumeGomez
Improve `f32` and `f64` primitive documentation

I noticed that the docs for the primitive floats were fairly short. I first only wanted to add the IEEE specification information (compare [the reference](https://doc.rust-lang.org/reference/types/numeric.html)), but then also added some more beginner-friendly docs. Let me know what you think!

Random doc team assign:
r? @rylev
2020-08-11 04:10:39 +00:00
南浦月
d892a07c67 add Ipv6Addr::to_ipv4_mapped 2020-08-11 09:15:08 +08:00
Dylan DPC
0a738d41b1
Rollup merge of #75379 - denisvasilik:intra-docs-links-core-cmp, r=Dylan-DPC
Use intra-doc links in /library/core/src/cmp.rs

Helps with #75080.

@rustbot modify labels: T-doc, A-intra-doc-links, T-rustdoc

Known issues:

* Links from `core` to `std` (#74481):
    * [`Vec::sort_by_key`]
2020-08-11 01:56:47 +02:00
Dylan DPC
d00c70363f
Rollup merge of #75369 - denisvasilik:intra-doc-links-core-borrow, r=Manishearth
Move to intra-doc links in /library/core/src/borrow.rs

Helps with #75080.

@rustbot modify labels: T-doc, A-intra-doc-links, T-rustdoc

Known issues:

* Links from `core` to `std` (#74481):
    * [`Box<T>`]
    * [`Mutex<T>`]
    * [`Rc<T>`]
    * [`String`]
    * [`HashMap<K, V>`]
2020-08-11 01:56:45 +02:00
Denis Vasilik
eea85814e1 Use intra-doc links 2020-08-10 23:16:01 +02:00
Denis Vasilik
f260462c32 Remove links that are in scope 2020-08-10 23:14:43 +02:00
Alexis Bourget
a6e492b5db Move to doc links inside the prelude 2020-08-10 21:09:37 +02:00
Alexis Bourget
26792a65cd Move to doc links inside std/time.rs 2020-08-10 21:01:58 +02:00
Denis Vasilik
d7e7271085 Remove AsRef link as it is in the prelude 2020-08-10 20:29:20 +02:00
Ryan Levick
b9b8b5c96b Reverse formatting 2020-08-10 18:04:44 +02:00
Ryan Levick
6778baf516 Fix up docs 2020-08-10 17:39:06 +02:00
Ryan Levick
57572cf809 Call into fastfail on abort in libpanic_abort on Windows x86(_64) 2020-08-10 14:40:09 +02:00
Lzu Tao
0210fd3d73 Transmute between big endian s6_addr and [u16; 8].
The old code already made the assumption to reinterpret
`Ipv6Addr` as `[u16; 8]`.

Glibc, Linux, FreeBSD, Win32 all makes this assumption.
The main motivation of using union it to better optimize code.

ref:
* https://docs.microsoft.com/en-us/windows/win32/api/in6addr/ns-in6addr-in6_addr
* 1d6e424741/contrib/ntp/lib/isc/include/isc/ipv6.h (L63)
* 8b531aa996/include/net/net_ip.h (L137)
* https://sourceware.org/git/?p=glibc.git;a=blob;f=inet/netinet/in.h;h=f6355c7efe5192b88337b136ef687fe9a5ed648c;hb=HEAD#l216

Co-authored-by: Josh Stone <cuviper@gmail.com>
Co-authored-by: Peter Atashian <retep998@gmail.com>
2020-08-10 00:50:26 +00:00
Yuki Okushi
64d71095c3
Rollup merge of #75348 - denisvasilik:intra-doc-links-core-time, r=jyn514
Move to intra-doc links in library/core/src/time.rs

Helps with #75080.
2020-08-10 09:08:01 +09:00
Yuki Okushi
df2da4637f
Rollup merge of #75286 - pickfire:patch-9, r=jyn514
Add additional case for Path starts with

Show what happens if there is an extra extension
2020-08-10 09:07:52 +09:00
Yuki Okushi
62e5488198
Rollup merge of #74200 - poliorcetics:std-panicking-unsafe-block-in-unsafe-fn, r=Mark-Simulacrum
Std panicking unsafe block in unsafe fn

Partial fix of #73904.

This encloses `unsafe` operations in `unsafe fn` in `libstd/ffi/panicking.rs`.

I also made a two lines change to `libstd/thread/local.rs` to add the necessary `unsafe` block without breaking everything else.

@rustbot modify labels: F-unsafe-block-in-unsafe-fn
2020-08-10 09:07:46 +09:00
Denis Vasilik
9e71c13f28
Add link for Duration
Co-authored-by: Joshua Nelson <joshua@yottadb.com>
2020-08-09 23:26:42 +02:00
Denis Vasilik
ce244210b1 Remove liNone as it is in the prelude 2020-08-09 23:12:30 +02:00
Denis Vasilik
7dba693f0e Use intra-doc links 2020-08-09 23:06:44 +02:00
Denis Vasilik
e9e319c460 Use intra-doc links 2020-08-09 21:20:57 +02:00
Ivan Tham
4b549fa043
show multiple slashes starts_with Path example
Co-authored-by: Joshua Nelson <joshua@yottadb.com>
2020-08-10 00:43:45 +08:00
Greg V
ddbc45673b Add RUST_STD_FREEBSD_12_ABI env variable
Unfortunately, sanitizers do not support versioned symbols[1],
so they break filesystem access via the legacy, pre-ino64 ABI.

To use sanitizers on FreeBSD >= 12, we need to build the libc
crate with LIBC_CI=1 to use the new ABI -- including the libc
used for std. But that removes the st_lspare field std was
expecting for the deprecated metadata extension.

Add a way to skip that field to allow the build to work.

[1]: https://github.com/google/sanitizers/issues/628
2020-08-09 17:52:00 +03:00
Alexis Bourget
5a0de2f828 Improve safety comments for usize, fix some other unclear parts 2020-08-09 16:43:24 +02:00
bors
8bc801b050 Auto merge of #75293 - poliorcetics:intra-doc-links-std-path, r=jyn514
Move to intra-doc links in library/std/src/path.rs

Helps with #75080.

@rustbot modify labels: T-doc, A-intra-doc-links, T-rustdoc

Known issue: The following links are broken (they are inside trait impls, undocumented in this file, inheriting from the original doc):

- [`Hasher`]
- [`Self`] (referencing `../primitive.slice.html`)
- [`Ordering`]
2020-08-09 12:31:03 +00:00
Stein Somers
ef753fc6ed BTreeMap: better distinguish the root holder from the root node 2020-08-09 13:43:13 +02:00
Eric Seppanen
f85d231301 clarify documentation of remove_dir errors
remove_dir will error if the path doesn't exist or isn't a directory.

It's useful to clarify that this is "remove dir or fail" not "remove dir
if it exists".

I don't think this belongs in the title. "Removes an existing, empty
directory" is strangely worded-- there's no such thing as a non-existing
directory.  Better to just say explicitly it will return an error.
2020-08-08 22:50:56 -07:00
bors
f50f1c8e17 Auto merge of #75280 - overdrivenpotato:psp-unwind, r=dtolnay
Add back unwinding support for Sony PSP

This PR adds back unwinding support for the Sony PSP. The `mipsel-sony-psp` target works well with unwinding. In [rust-psp], we use the `panic_unwind` crate along with LLVM's libunwind to catch panics, run destructors, and print them to the debug screen without aborting all threads.

[rust-psp]: https://github.com/overdrivenpotato/rust-psp
2020-08-09 03:07:00 +00:00
bors
dcf107728c Auto merge of #75308 - JohnTitor:rollup-vnnny43, r=JohnTitor
Rollup of 15 pull requests

Successful merges:

 - #74712 (Update E0271 explanation)
 - #74842 (adjust remaining targets)
 - #75151 (Consistent variable name alloc for raw_vec)
 - #75162 (Fix the documentation for move about Fn traits implementations)
 - #75248 (Add `as_mut_ptr` to `NonNull<[T]>`)
 - #75262 (Show multi extension example for Path in doctests)
 - #75266 (Add safety section to `NonNull::as_*` method docs)
 - #75284 (Show relative example for Path ancestors)
 - #75285 (Separate example for Path strip_prefix)
 - #75287 (Show Path extension example change multi extension)
 - #75288 (Use assert! for Path exists example to check bool)
 - #75289 (Remove ambiguity from PathBuf pop example)
 - #75290 (fix `min_const_generics` version)
 - #75291 (Clean up E0750)
 - #75292 (Clean up E0502)

Failed merges:

r? @ghost
2020-08-08 23:05:49 +00:00
Yuki Okushi
3038ecb07b
Rollup merge of #75289 - pickfire:patch-12, r=jonas-schievink
Remove ambiguity from PathBuf pop example
2020-08-09 06:41:33 +09:00
Yuki Okushi
6baee9557a
Rollup merge of #75288 - pickfire:patch-11, r=jonas-schievink
Use assert! for Path exists example to check bool
2020-08-09 06:41:32 +09:00
Yuki Okushi
42e163bf40
Rollup merge of #75287 - pickfire:patch-10, r=jonas-schievink
Show Path extension example change multi extension
2020-08-09 06:41:30 +09:00
Yuki Okushi
28ab318f57
Rollup merge of #75285 - pickfire:patch-8, r=jonas-schievink
Separate example for Path strip_prefix
2020-08-09 06:41:28 +09:00
Yuki Okushi
27b864b154
Rollup merge of #75284 - pickfire:patch-7, r=LukasKalbertodt
Show relative example for Path ancestors
2020-08-09 06:41:27 +09:00
Yuki Okushi
cb75fea1cc
Rollup merge of #75266 - aticu:master, r=RalfJung
Add safety section to `NonNull::as_*` method docs

This basically adds the safety section of `*mut T::as_{ref,mut}` to the
same methods on `NonNull` with minor modifications to fit the
differences.

Part of #48929.
2020-08-09 06:41:25 +09:00
Yuki Okushi
cbc6914baa
Rollup merge of #75262 - pickfire:patch-6, r=jyn514
Show multi extension example for Path in doctests
2020-08-09 06:41:23 +09:00
Yuki Okushi
c85075d522
Rollup merge of #75248 - TimDiekmann:NonNull-as_mut_ptr, r=RalfJung
Add `as_mut_ptr` to `NonNull<[T]>`

Adds `as_mut_ptr` to shortcut converting a `NonNull<[T]>` to `*mut T` as proposed in https://github.com/rust-lang/rust/issues/74265#issuecomment-669702969.

r? @RalfJung
2020-08-09 06:41:22 +09:00
Yuki Okushi
ccffe18c3e
Rollup merge of #75162 - poliorcetics:move-documentation-fix, r=jyn514
Fix the documentation for move about Fn traits implementations

Fixes #74997.

This uses the note from the [reference](https://doc.rust-lang.org/reference/types/closure.html#call-traits-and-coercions) but I can also just put a link to it or do both.

@rusbot modify labels: C-bug T-doc T-libs
2020-08-09 06:41:20 +09:00
Yuki Okushi
3370ac0042
Rollup merge of #75151 - pickfire:patch-4, r=LukasKalbertodt
Consistent variable name alloc for raw_vec
2020-08-09 06:41:18 +09:00
Yuki Okushi
dde4fb3fd2
Rollup merge of #74842 - hermitcore:thread_local, r=Mark-Simulacrum
adjust remaining targets

- fix commit 7dc3886
- previous commit doesn't adjust all targets
2020-08-09 06:41:16 +09:00
bors
ceedf1d5fe Auto merge of #75271 - cuviper:array-iter, r=LukasKalbertodt
Simplify array::IntoIter

- Initialization can use `transmute_copy` to do the bitwise copy.
- `as_slice` can use `get_unchecked` and `MaybeUninit::slice_get_ref`,
  and `as_mut_slice` can do similar.
- `next` and `next_back` can use the corresponding `Range` methods.
- `Clone` doesn't need any unsafety, and we can dynamically update the
  new range to get partial drops if `T::clone` panics.

r? @LukasKalbertodt
2020-08-08 20:43:21 +00:00
bors
1facd4a77b Auto merge of #75163 - canova:map_into_keys_values, r=dtolnay
Implement `into_keys` and `into_values` for associative maps

This PR implements `into_keys` and `into_values` for HashMap and BTreeMap types. They are implemented as unstable, under `map_into_keys_values` feature.
Fixes #55214.
r? @dtolnay
2020-08-08 18:15:50 +00:00
Nazım Can Altınova
4cd2637e2b
Update the tracking issue number of map_into_keys_values 2020-08-08 16:35:54 +02:00
Alexis Bourget
1cd8dffdae Add an example about the behaviour of move and Fn* traits 2020-08-08 15:57:17 +02:00
Nazım Can Altınova
1cdce3919f
Remove min/max values from IntoValues Iterator implementation 2020-08-08 15:51:22 +02:00
Alexis Bourget
3a709fe702 Add precisions about ZSTs and fix nits raised in review 2020-08-08 15:40:10 +02:00
Alexis Bourget
6d77e40afe Move to intra-doc links in library/std/src/path.rs 2020-08-08 14:21:27 +02:00
aticu
c2099b5f28 Add safety section to NonNull::as_* method docs
This basically adds the safety section of `*mut T::as_{ref,mut}` to the
same methods on `NonNull` with minor modifications to fit the
differences.

Part of #48929.
2020-08-08 13:36:19 +02:00
bors
c989ac132a Auto merge of #74289 - lzutao:unroll, r=LukasKalbertodt
Remove some redundant parts from `unrolled_find_u16s`

See each commit message for details.

r? @wesleywiser from old PR #67705 .
2020-08-08 11:34:18 +00:00
Ivan Tham
4b15b809eb
Remove abmiguity from PathBuf pop example 2020-08-08 18:28:55 +08:00
Ivan Tham
b3ae88f6bb
Use assert! for Path exists example to check bool 2020-08-08 18:23:18 +08:00
Ivan Tham
9532b83912
Show Path extension example change multi extension 2020-08-08 18:14:29 +08:00
Ivan Tham
e7e41a8465
Add additonal case for Path starts with
Show what happens if there is an extra extension
2020-08-08 18:06:04 +08:00
Ivan Tham
6dffd2d18e
Separate example for Path strip_prefix 2020-08-08 18:01:34 +08:00
Ivan Tham
a11c27925d
Show relative example for Path ancestors 2020-08-08 17:53:16 +08:00
bors
c92fc8db8b Auto merge of #75282 - RalfJung:miri-black-box, r=oli-obk
do not call black_box on Miri

Helps with https://github.com/rust-lang/rust/issues/75274 (but https://github.com/rust-lang/rust/pull/74932 introduced unrelated breakage that will need a separate fix)
Cc @eggyal r? @Mark-Simulacrum
2020-08-08 09:46:16 +00:00
Ralf Jung
8385146ffa make black_box a NOP in Miri 2020-08-08 10:50:30 +02:00
bors
d19d7e2755 Auto merge of #75257 - ssomers:btree_74762_again, r=Mark-Simulacrum
BTreeMap: better way to postpone root access in DrainFilter

A slightly more elegant (in my opinion) adaptation of #74762. Benchmarks seem irrationally pleased to:
```
benchcmp old new --threshold 5
 name                                           old ns/iter  new ns/iter  diff ns/iter   diff %  speedup
 btree::map::clone_fat_100_and_remove_all       215,182      185,052           -30,130  -14.00%   x 1.16
 btree::map::clone_fat_100_and_remove_half      139,667      127,945           -11,722   -8.39%   x 1.09
 btree::map::clone_fat_val_100_and_remove_all   96,755       81,279            -15,476  -16.00%   x 1.19
 btree::map::clone_fat_val_100_and_remove_half  64,678       56,911             -7,767  -12.01%   x 1.14
 btree::map::find_rand_100                      18           17                     -1   -5.56%   x 1.06
 btree::map::first_and_last_0                   33           35                      2    6.06%   x 0.94
 btree::map::first_and_last_100                 40           54                     14   35.00%   x 0.74
 btree::map::insert_rand_100                    45           42                     -3   -6.67%   x 1.07
 btree::map::insert_rand_10_000                 45           41                     -4   -8.89%   x 1.10
 btree::map::iter_0                             2,010        1,759                -251  -12.49%   x 1.14
 btree::map::iter_100                           3,514        2,764                -750  -21.34%   x 1.27
 btree::map::iter_10k                           4,018        3,768                -250   -6.22%   x 1.07
 btree::map::range_unbounded_unbounded          37,269       28,929             -8,340  -22.38%   x 1.29
 btree::map::range_unbounded_vs_iter            31,518       28,814             -2,704   -8.58%   x 1.09
```

r? @Mark-Simulacrum
2020-08-08 07:46:04 +00:00
Marko Mijalkovic
27fca58993 Add back unwinding support for Sony PSP 2020-08-08 02:14:40 -04:00
Yuki Okushi
21bfe529c7
Rollup merge of #75270 - matthiaskrgr:clippy_aug_1, r=Dylan-DPC
fix a couple of clippy findings
2020-08-08 11:36:12 +09:00
Yuki Okushi
02bf036c6c
Rollup merge of #75253 - RalfJung:cleanup-const-hack, r=oli-obk
clean up const-hacks in int endianess conversion functions

Cleans up the const hacks added in https://github.com/rust-lang/rust/pull/69373.

r? @oli-obk
2020-08-08 11:36:07 +09:00
Yuki Okushi
b032a15fa8
Rollup merge of #75250 - RalfJung:uninit-const-ptr, r=oli-obk
make MaybeUninit::as_(mut_)ptr const

I think it was just an oversight that they are not const yet.

I also changed their implementation as the old one created references to uninitialized memory.^^
2020-08-08 11:36:05 +09:00
bors
f3a9de9b08 Auto merge of #75048 - eggyal:force-no-tco-start-backtrace-frame, r=Mark-Simulacrum
Prevent `__rust_begin_short_backtrace` frames from being tail-call optimised away

I've stumbled across some situations where there (unexpectedly) was no `__rust_begin_short_backtrace` frame on the stack during unwinding.

On closer examination, it appeared that the calls to that function had been tail-call optimised away.

This PR follows [@bjorn3's suggestion on Zulip](https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/Disabling.20tail.20call.20optimisation.3F/near/205699133), by adding calls to `black_box` that hint to rustc not to perform TCO.

Fixes #47429
2020-08-08 00:00:52 +00:00
Matthias Krüger
a605e51056 fix clippy::needless_return: remove unneeded return statements 2020-08-08 00:57:37 +02:00
bors
c2d1b0d980 Auto merge of #75071 - ssomers:btree_cleanup_5, r=Mark-Simulacrum
BTreeMap: enforce the panic rule imposed by `replace`

Also, reveal the unsafe parts in the closures fed to it.

r? @Mark-Simulacrum
2020-08-07 21:48:32 +00:00
Josh Stone
a2cfc74c5f Simplify array::IntoIter
- Initialization can use `transmute_copy` to do the bitwise copy.
- `as_slice` can use `get_unchecked` and `MaybeUninit::slice_get_ref`,
  and `as_mut_slice` can do similar.
- `next` and `next_back` can use the corresponding `Range` methods.
- `Clone` doesn't need any unsafety, and we can dynamically update the
  new range to get partial drops if `T::clone` panics.
2020-08-07 13:51:46 -07:00
Alan Egerton
5792840bf5 Prevent __rust_begin_short_backtrace frames from being tail-call optimised away 2020-08-07 19:31:25 +01:00
Stein Somers
734fc0477c BTreeMap: enforce the panic rule imposed by replace 2020-08-07 19:51:26 +02:00
Ivan Tham
06cf40f8a1
Show multi extension example for Path in doctests 2020-08-08 00:48:12 +08:00
Stein Somers
85a7879341 BTreeMap: better way to postpone root access in DrainFilter 2020-08-07 15:02:56 +02:00
Nazım Can Altınova
16a5217141
Change the comment of BTreeMap::into_values 2020-08-07 14:10:12 +02:00
Nazım Can Altınova
25545ed180
Only print the fields that are relevant to iterators for Debug of IntoKeys and IntoValues 2020-08-07 13:47:04 +02:00
Ralf Jung
a530934951 clean up const-hacks in int endianess conversion functions 2020-08-07 13:45:55 +02:00
Nazım Can Altınova
29d9233cf6
Add unit tests for new BTreeMap::into_{keys,values} methods 2020-08-07 13:13:42 +02:00
Nazım Can Altınova
41dd4ee7ff
Add unit tests for new HashMap::into_{keys,values} methods 2020-08-07 13:13:41 +02:00
Nazım Can Altınova
13529f22ba
Add into_{keys,values} methods for BTreeMap 2020-08-07 13:13:41 +02:00
Nazım Can Altınova
e31116af50
Add into_{keys,values} methods for HashMap 2020-08-07 13:13:37 +02:00
Ralf Jung
ec5d78d350 fix feature gate and tracking issue 2020-08-07 12:38:55 +02:00
Ralf Jung
0aee186723 make MaybeUninit::as_(mut_)ptr const 2020-08-07 12:24:28 +02:00
bors
8b26609481 Auto merge of #70052 - Amanieu:hashbrown7, r=Mark-Simulacrum
Update hashbrown to 0.8.1

This update includes:
- https://github.com/rust-lang/hashbrown/pull/146, which improves the performance of `Clone` and implements `clone_from`.
- https://github.com/rust-lang/hashbrown/pull/159, which reduces the size of `HashMap` by 8 bytes.
- https://github.com/rust-lang/hashbrown/pull/162, which avoids creating small 1-element tables.

Fixes #28481
2020-08-07 08:36:15 +00:00
bors
d4c940f082 Auto merge of #75244 - Manishearth:rollup-dzfyjva, r=Manishearth
Rollup of 4 pull requests

Successful merges:

 - #74774 (adds [*mut|*const] ptr::set_ptr_value)
 - #75079 (Disallow linking to items with a mismatched disambiguator)
 - #75203 (Make `IntoIterator` lifetime bounds of `&BTreeMap` match with `&HashMap` )
 - #75227 (Fix ICE when using asm! on an unsupported architecture)

Failed merges:

r? @ghost
2020-08-07 06:40:53 +00:00
Ivan Tham
3d1388f514
Add more examples to Path ends_with
We faced a footgun when using ends_with to check extension,
showing an example could prevent that.
2020-08-07 14:16:52 +08:00
Manish Goregaokar
25c8e9ac17
Rollup merge of #75203 - canova:btreemap-into-iter, r=dtolnay
Make `IntoIterator` lifetime bounds of `&BTreeMap` match with `&HashMap`

This is a pretty small change on the lifetime bounds of `IntoIterator` implementations of both `&BTreeMap` and `&mut BTreeMap`. This is loosening the lifetime bounds, so more code should be accepted with this PR. This is lifetime bounds will still be implicit since we have `type Item = (&'a K, &'a V);` in the implementation. This change will make the HashMap and BTreeMap share the same signature, so we can share the same function/trait with both HashMap and BTreeMap in the code.

Fixes #74034.
r? @dtolnay hey, I was touching this file on my previous PR and wanted to fix this on the way. Would you mind taking a look at this, or redirecting it if you are busy?
2020-08-06 23:04:05 -07:00
Manish Goregaokar
5f331c0585
Rollup merge of #74774 - oliver-giersch:set_data_ptr, r=dtolnay
adds [*mut|*const] ptr::set_ptr_value

I propose the addition of these two functions to `*mut T` and `*const T`, respectively. The motivation for this is primarily byte-wise pointer arithmetic on (potentially) fat pointers, i.e. for types with a `T: ?Sized` bound. A concrete use-case has been discussed in [this](https://internals.rust-lang.org/t/byte-wise-fat-pointer-arithmetic/12739) thread.
TL;DR: Currently, byte-wise pointer arithmetic with potentially fat pointers in not possible in either stable or nightly Rust without making assumptions about the layout of fat pointers, which is currently still an implementation detail and not formally stabilized. This PR adds one function to `*mut T` and `*const T` each, allowing to circumvent this restriction without exposing any internal implementation details.
One possible alternative would be to add specific byte-wise pointer arithmetic functions to the two pointer types in addition to the already existing count-wise functions. However, I feel this fairly niche use case does not warrant adding a whole set of new functions like `add_bytes`, `offset_bytes`, `wrapping_offset_bytes`, etc. (times two, one for each pointer type) to `libcore`.
2020-08-06 23:04:02 -07:00
Amanieu d'Antras
d51b7b229a Update hashbrown to 0.8.1 2020-08-07 07:03:12 +01:00
bors
98922795f6 Auto merge of #75121 - tmiasko:str-slicing, r=Mark-Simulacrum
Avoid `unwrap_or_else` in str indexing

This provides a small reduction of generated LLVM IR, and leads to a
simpler assembly code.

Closes #68874.
2020-08-07 04:51:04 +00:00
Yuki Okushi
26705d5bcb
Rollup merge of #75211 - lzutao:native-endian-notes, r=lcnr
Note about endianness of returned value of {integer}::from_be_bytes and friends

[`u32::from_be`](https://doc.rust-lang.org/nightly/src/core/num/mod.rs.html#2883-2892) documents about endianness of returned value.

I was confused by endianness of `from_be_bytes` in #75086 .
2020-08-07 09:35:26 +09:00
Yuki Okushi
1b61fd3ccf
Rollup merge of #75179 - lzutao:unsed-ipv4-frominner, r=alexcrichton
Remove unused FromInner impl for Ipv4Addr

The removed is a unused unstable implementation.
2020-08-07 09:35:16 +09:00
Yuki Okushi
c9c7048038
Rollup merge of #75175 - lzutao:doctest-ipv4-fromu32, r=cuviper
Make doctests of Ipv4Addr::from(u32) easier to read

There are many zeroes in `0x0d0c0b0au32` which makes it hard to read.
2020-08-07 09:35:14 +09:00
Tim Diekmann
a784729cde Add as_mut_ptr to NonNull<[T]> 2020-08-06 11:45:54 +02:00
Lzu Tao
eff7d568d8 Note about endianness of returned value
in {integer}::from_be_bytes and friends.
2020-08-06 07:33:07 +00:00
rodrimati1992
a915bbf780
Removed blank line that caused CI error 2020-08-06 04:00:59 -03:00
rodrimati1992
77d0d152cc
Made formatting consistent with surrounding code 2020-08-06 02:15:55 -03:00
Tomasz Miąsko
888bc07c6b Keep stdout open in limit_vector_count test 2020-08-06 00:00:00 +00:00
bors
c15bae53b5 Auto merge of #75086 - lzutao:u32const, r=oli-obk
Use u32::from_ne_bytes to fix a FIXME and add comment about that

`u32::from_ne_bytes` has been const stable since 1.44.
2020-08-06 14:21:48 +00:00
Nazım Can Altınova
62e06a4d09
Make IntoIterator lifetime bounds of &BTreeMap match with &HashMap 2020-08-05 23:32:13 +02:00
rodrimati1992
748b0c37a9
Fixed mistake 2020-08-05 14:05:57 -03:00
rodrimati1992
750912537d
Added issue number, removed trailing whitespace 2020-08-05 14:01:44 -03:00
Adam Reichold
9073acdc98 Add fallback for cfg(unix) targets that do not define libc::_SC_IOV_MAX. 2020-08-05 17:15:08 +02:00
Adam Reichold
04a0114e7e Rely only on POSIX semantics for I/O vector count
All #[cfg(unix)] platforms follow the POSIX standard and define _SC_IOV_MAX so
that we rely purely on POSIX semantics to determine the limits on I/O vector
count.
2020-08-05 16:57:02 +02:00
Adam Reichold
87edccf0f0 Reduce synchronization overhead of I/O vector count memoization 2020-08-05 16:57:02 +02:00
Adam Reichold
6672f7be03 Memoize the I/O vector count limit
Keep the I/O vector count limit in a `SyncOnceCell` to avoid the overhead of
repeatedly calling `sysconf` as these limits are guaranteed to not change during
the lifetime of a process by POSIX.
2020-08-05 16:57:02 +02:00
Adam Reichold
9468752581 Query maximum vector count on Linux and macOS
Both Linux and MacOS enforce limits on the vector count when performing vectored
I/O via the readv and writev system calls and return EINVAL when these limits
are exceeded. This changes the standard library to handle those limits as short
reads and writes to avoid forcing its users to query these limits using
platform specific mechanisms.
2020-08-05 16:57:02 +02:00
Yuto Kawamura
165a6e597e Fix wasi::fs::OpenOptions to imply write when append is on 2020-08-05 20:30:06 +09:00
Amos Onn
ab204c5b20 Add {Box,Rc,Arc}::new_zeroed_slice 2020-08-05 08:32:10 +02:00
Amos Onn
361f668c49 Use alloc_zeroed in {Rc,Arc}::new_zeroed 2020-08-05 08:32:05 +02:00
Lzu Tao
d9f260e95e Remove unused FromInner impl for Ipv4Addr 2020-08-05 05:53:07 +00:00
Lzu Tao
725d37cae0 Make doctests of Ipv4Addr::from(u32) easier to read 2020-08-05 05:31:17 +00:00
bors
dab2ae0404 Auto merge of #75037 - richkadel:llvm-coverage-map-gen-5.2, r=wesleywiser
Completes support for coverage in external crates

Follow-up to #74959 :

The prior PR corrected for errors encountered when trying to generate
the coverage map on source code inlined from external crates (including
macros and generics) by avoiding adding external DefIds to the coverage
map.

This made it possible to generate a coverage report including external
crates, but the external crate coverage was incomplete (did not include
coverage for the DefIds that were eliminated.

The root issue was that the coverage map was converting Span locations
to source file and locations, using the SourceMap for the current crate,
and this would not work for spans from external crates (compliled with a
different SourceMap).

The solution was to convert the Spans to filename and location during
MIR generation instead, so precompiled external crates would already
have the correct source code locations embedded in their MIR, when
imported into another crate.

@wesleywiser FYI
r? @tmandry
2020-08-05 05:08:19 +00:00
Lzu Tao
30a1455c8d Use u32::from_ne_bytes to fix a FIXME
Co-authored-by: Weiyi Wang <wwylele@gmail.com>
Co-authored-by: Adam Reichold <adam.reichold@t-online.de>
Co-authored-by: Josh Stone <cuviper@gmail.com>
Co-authored-by: Scott McMurray <scottmcm@users.noreply.github.com>
Co-authored-by: tmiasko <tomasz.miasko@gmail.com>
2020-08-05 02:49:26 +00:00
Alexis Bourget
d243fa109f Fix the documentation for move about Fn traits implementations 2020-08-04 22:49:25 +02:00
Rich Kadel
e0dc8dec27 Completes support for coverage in external crates
The prior PR corrected for errors encountered when trying to generate
the coverage map on source code inlined from external crates (including
macros and generics) by avoiding adding external DefIds to the coverage
map.

This made it possible to generate a coverage report including external
crates, but the external crate coverage was incomplete (did not include
coverage for the DefIds that were eliminated.

The root issue was that the coverage map was converting Span locations
to source file and locations, using the SourceMap for the current crate,
and this would not work for spans from external crates (compliled with a
different SourceMap).

The solution was to convert the Spans to filename and location during
MIR generation instead, so precompiled external crates would already
have the correct source code locations embedded in their MIR, when
imported into another crate.
2020-08-04 11:06:54 -07:00
rodrimati1992
0f7817f99e
Constified str::from_utf8_unchecked 2020-08-04 14:38:42 -03:00
Tim Diekmann
93d98328d1
Revert missing "memory block" 2020-08-04 19:24:08 +02:00
Tim Diekmann
929e37d4bf Revert renaming of "memory block" 2020-08-04 19:15:48 +02:00
Tim Diekmann
ab9362ad9a Replace Memoryblock with NonNull<[u8]> 2020-08-04 18:03:34 +02:00
Ivan Tham
e1ef3fa686
Consistent variable name alloc for raw_vec 2020-08-04 23:46:14 +08:00
bors
5f6bd6ec0a Auto merge of #74850 - TimDiekmann:remove-in-place-alloc, r=Amanieu
Remove in-place allocation and revert to separate methods for zeroed allocations

closes rust-lang/wg-allocators#58
2020-08-04 11:22:45 +00:00
bors
80f84eb9c6 Auto merge of #75058 - ssomers:btree_cleanup_insert_2, r=Mark-Simulacrum
Clarify reuse of a BTreeMap insert support function and treat split support likewise

r? @Mark-Simulacrum
2020-08-04 03:48:48 +00:00
Yuki Okushi
622759d129
Rollup merge of #75084 - Aaron1011:stabilize/ident-new-raw, r=petrochenkov
Stabilize Ident::new_raw

Tracking issue: #54723

This is a continuation of PR #59002
2020-08-04 09:27:06 +09:00
Yuki Okushi
cc0ac7eece
Rollup merge of #74759 - carbotaniuman:uabs, r=shepmaster
add `unsigned_abs` to signed integers

Mentioned on rust-lang/rfcs#2914

This PR simply adds an `unsigned_abs` to signed integers function which returns the correct absolute value as a unsigned integer.
2020-08-04 09:26:58 +09:00
Tim Diekmann
6395659168
Apply suggestions from code review
Co-authored-by: Amanieu d'Antras <amanieu@gmail.com>
2020-08-04 00:21:05 +02:00
Tomasz Miąsko
427634b503 Avoid unwrap_or_else in str indexing
This provides a small reduction of generated LLVM IR, and leads to a
simpler assembly code.
2020-08-04 00:01:48 +02:00
bors
d8cbd9caca Auto merge of #74526 - erikdesjardins:reftrack, r=Mark-Simulacrum
Add track_caller to RefCell::{borrow, borrow_mut}

So panic messages point at the offending borrow.

Fixes #74472
2020-08-03 21:43:27 +00:00
Aaron Hill
6deda6a6a0
Stabilize Ident::new_raw
Tracking issue: #54723

This is a continuation of PR #59002
2020-08-03 17:23:31 -04:00
Alexis Bourget
92b1975eaa Added the missing SAFETY: comments 2020-08-03 22:16:50 +02:00
bors
829d69b9c6 Auto merge of #74827 - ssomers:btree_cleanup_insert, r=Mark-Simulacrum
Move bulk of BTreeMap::insert method down to new method on handle

Adjust the boundary between the map and node layers for insertion: do more in the node layer, keep root manipulation and pointer dereferencing separate. No change in undefined behaviour or performance.

r? @Mark-Simulacrum
2020-08-03 15:46:02 +00:00
oliver-giersch
6c81556a36
adds [*mut|*const] ptr::set_ptr_value 2020-08-03 04:17:45 -07:00
kennytm
fd7596c9a5
fix broken git commit in stdarch 2020-08-03 15:52:30 +08:00
Tim Diekmann
24ddf76ed7
Merge branch 'master' into remove-in-place-alloc 2020-08-03 02:18:20 +02:00
bors
19ecce332e Auto merge of #74948 - lzutao:stalize-result-as-deref, r=dtolnay
Stabilize `Result::as_deref` and `as_deref_mut`

FCP completed in https://github.com/rust-lang/rust/issues/50264#issuecomment-645681400.

This PR stabilizes two new APIs for `std::result::Result`:
```rust
fn as_deref(&self) -> Result<&T::Target, &E> where T: Deref;
fn as_deref_mut(&mut self) -> Result<&mut T::Target, &mut E> where T: DerefMut;
```

This PR also removes two rarely used unstable APIs from `Result`:
```rust
fn as_deref_err(&self) -> Result<&T, &E::Target> where E: Deref;
fn as_deref_mut_err(&mut self) -> Result<&mut T, &mut E::Target> where E: DerefMut;
```

Closes #50264
2020-08-02 23:55:12 +00:00
Manish Goregaokar
9471ab068c
Rollup merge of #75059 - shengsheng:typos, r=Dylan-DPC
fix typos

Fix common misspellings with https://en.wikipedia.org/wiki/Wikipedia:Lists_of_common_misspellings/For_machines
2020-08-02 13:08:47 -07:00
Manish Goregaokar
1b350ecb60
Rollup merge of #75009 - georgio:master, r=kennytm
Document the discrepancy in the mask type for _mm_shuffle_ps

This Pull Request updates the `stdarch` submodule in order to resolve #62490
2020-08-02 13:08:43 -07:00
Stein Somers
532e7f49fc Separate off a leafy insert function instead of lying, and split split similarly 2020-08-02 21:42:17 +02:00
Stein Somers
f5c47fa44d Move bulk of BTreeMap::insert method down to new method on handle 2020-08-02 20:20:42 +02:00
Alexis Bourget
430f19a82e Document unsafety in library/core/src/slice/mod.rs 2020-08-02 20:03:48 +02:00
Yuki Okushi
7d18040b0c
Rollup merge of #74974 - RalfJung:miri-tests, r=Mark-Simulacrum
Make tests faster in Miri

Reduce some test iteration counts in Miri.
2020-08-03 01:05:20 +09:00
Yuki Okushi
1033c74665
Rollup merge of #74874 - ssomers:btree_cleanup_8, r=Mark-Simulacrum
BTreeMap: define forget_type only when relevant

Similar to `forget_node_type` for handles.
No effect on generated code, apart maybe from the superfluous calls that might not have been optimized away.

r? @Mark-Simulacrum
2020-08-03 01:05:18 +09:00
Yuki Okushi
814b31eb2e
Rollup merge of #74762 - ssomers:btree_no_root_in_remove_kv_tracking, r=Mark-Simulacrum
BTreeMap::drain_filter should not touch the root during iteration

Although Miri doesn't point it out, I believe there is undefined behaviour using `drain_filter` when draining the 11th-last element from a tree that was larger. When this happens, the last remaining child nodes are merged, the root becomes empty and is popped from the tree. That last step establishes a mutable reference to the node elected root and writes a pointer in `node::Root`, while iteration continues to visit the same node.

This is mostly code from #74437, slightly adapted.
2020-08-03 01:05:13 +09:00
Yuki Okushi
8c331ee470
Rollup merge of #74686 - ssomers:btree_cleanup_3, r=Mark-Simulacrum
BTreeMap: remove into_slices and its unsafe block

A small tweak to make BTreeMap code shorter and less unsafe.

r? @Mark-Simulacrum
2020-08-03 01:05:12 +09:00
Georgio Nicolas
1e2ce28ec0 Document the discrepancy in the mask type for _mm_shuffle_ps 2020-08-02 18:22:26 +03:00
liuzhenyu
3b4151c9f3 fix typos 2020-08-02 23:20:00 +08:00
Jan Riemer
7835c8c06c
docs(marker/copy): clarify that &T is also Copy
In the current documentation about the `Copy` marker trait, there is a section
about "additional implementors", which list additional implementors of the `Copy` trait.
The fact that shared references are also `Copy` is mixed with another point,
which makes it hard to recognize and make it seem not as important.

This clarifies the fact that shared references are also `Copy`, by mentioning it as a
separate item in the list of "additional implementors".
2020-08-02 14:57:19 +02:00
bors
1e99138078 Auto merge of #74972 - second-state:wasi-right-fix, r=KodrAus
Fix std::fs::File::metadata permission on WASI target

Previously `std::fs::File::metadata` on wasm32-wasi would call `fd_filestat_get`
to get metadata associated with fd, but that fd is opened without
RIGHTS_FD_FILESTAT_GET right, so it will failed on correctly implemented WASI
environment.

This change instead to add the missing rights when opening an fd.
2020-08-02 09:41:17 +00:00
Ryan Scheel
e720f4237a
See also X-Link mem::{swap, take, replace} 2020-08-01 22:56:25 -07:00
bors
e18b56345f Auto merge of #75033 - Manishearth:rollup-d8afil1, r=Manishearth
Rollup of 5 pull requests

Successful merges:

 - #74602 (Clarify the doc for MaybeUninit::zeroed on incorrect use)
 - #74720 (Clean up E0728 explanation)
 - #74992 (fix rustdoc generic param order)
 - #75015 (Add Vec::spare_capacity_mut)
 - #75022 (Use a slice pattern instead of rchunks_exact(_).next())

Failed merges:

r? @ghost
2020-08-02 01:04:54 +00:00
Manish Goregaokar
d544e21dc3
Rollup merge of #75015 - Amanieu:vec_spare, r=sfackler
Add Vec::spare_capacity_mut

Returns the remaining spare capacity of the vector as a slice of `MaybeUninit<T>`.

As suggested by @sfackler in https://github.com/rust-lang/rust/pull/70967#issuecomment-612659006.

r? @sfackler
2020-08-01 17:42:16 -07:00
Manish Goregaokar
39436ebe72
Rollup merge of #74602 - poliorcetics:maybe-uninit-zeroed-doc-clarification, r=jyn514
Clarify the doc for MaybeUninit::zeroed on incorrect use

Fixes #74343.

@rustbot modify labels: C-enhancement, T-doc
2020-08-01 17:42:11 -07:00
bors
5ef872f961 Auto merge of #74605 - rust-lang:vec-leak, r=Amanieu
Stabilize Vec::leak as a method

Closes https://github.com/rust-lang/rust/issues/62195

The signature is changed to a method rather than an associated function:

```diff
-pub fn leak<'a>(vec: Vec<T>) -> &'a mut [T]
+pub fn leak<'a>(self) -> &'a mut [T]
```

The reason for `Box::leak` not to be a method (`Deref` to an arbitrary `T` which might have its own, different `leak` method) does not apply.
2020-08-01 22:29:30 +00:00
Leon Matthes
41d3e1cf73 Add missing import to Rc 2020-08-01 23:51:55 +02:00