Commit graph

250 commits

Author SHA1 Message Date
Prabakaran Kumaresshan
84539eb7b5 remove primitive type links 2020-08-14 21:57:42 +05:30
Prabakaran Kumaresshan
232e3d04b3 Switch to intra-doc links in os/raw/*.md 2020-08-14 21:09:35 +05:30
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
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
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
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
3f16597a6a Move to intra doc links whenever possible within std/src/lib.rs 2020-08-12 23:23:07 +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
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
Stein Somers
17ab457f21 Somewhat complicated way to respect BTreeMap's node length invariant 2020-08-12 00:09:00 +02:00
José Luis Cruz
df5c889784
word change
there are three significantly different things printed below
2020-08-11 22:33:11 +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
Prabakaran Kumaresshan
29045b699e Switch to intra-doc links in library/std/src/os/*/fs.rs 2020-08-11 15:20:01 +05:30
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
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