Commit graph

710 commits

Author SHA1 Message Date
The8472
bead910b21 simplify pointer arithmetic 2020-09-03 20:59:08 +02:00
The8472
f904d0339a fix doc link 2020-09-03 20:59:07 +02:00
The8472
328a75f766 use add instead of offset 2020-09-03 20:59:07 +02:00
The8472
88b7ae642c implement drop handling 2020-09-03 20:59:06 +02:00
The8472
73a982e9ec assert that SourceIter requirements have not been violated by the pipeline 2020-09-03 20:59:06 +02:00
The8472
2a327394e4 mark SourceIter as unsafe, document invariants 2020-09-03 20:59:05 +02:00
The8472
bb2d533bb9 in-place collect for Vec. Box<[]> and BinaryHeap IntoIter and some adapters 2020-09-03 20:59:03 +02:00
The8472
038394a330 bench 2020-09-03 20:56:34 +02:00
The8472
076417e978 unrelated typo fix 2020-09-03 20:56:34 +02:00
bors
08deb863bd Auto merge of #76235 - jyn514:std-intra-links, r=poliorcetics
Convert many files to intra-doc links

Helps with https://github.com/rust-lang/rust/issues/75080
r? @poliorcetics
I recommend reviewing one commit at a time, but the diff is small enough you can do it all at once if you like :)
2020-09-03 05:53:48 +00:00
bors
1e33c742ca Auto merge of #75971 - Amjad50:libstd-deny-unsafe_op_in_unsafe_fn, r=Mark-Simulacrum
Applied `#![deny(unsafe_op_in_unsafe_fn)]` in library/std/src/wasi

partial fix for #73904

There are still more that was not applied in [mod.rs]( 38fab2ea92/library/std/src/sys/wasi/mod.rs) and that is due to its using files from `../unsupported`

like:
```
#[path = "../unsupported/cmath.rs"]
pub mod cmath;
```
2020-09-03 02:15:16 +00:00
Amjad Alsharafi
559679b8c3 Applied #![deny(unsafe_op_in_unsafe_fn)] in library/std/src/wasi
All refactoring needed was only in `alloc.rs`, changed part of the code
in `alloc` method to satisfy the SAFETY statement
2020-09-03 08:27:59 +08:00
Dylan DPC
af331a2d01
Rollup merge of #76261 - camelid:intra-doc-links-for-core-marker, r=jyn514
Use intra-doc links in `core::marker`

Part of #75080.

Also cleaned up a few things.

---

@rustbot modify labels: A-intra-doc-links T-doc
2020-09-03 02:22:18 +02:00
Dylan DPC
3368f5c820
Rollup merge of #76243 - ama0:patch-1, r=jonas-schievink
Fix typos in vec try_reserve(_exact) docs

`try_reserve` and `try_reserve_exact` docs refer to calling `reserve` and `reserve_exact`.
`try_reserve_exact` example uses `try_reserve` method instead of `try_reserve_exact`.
2020-09-03 02:22:13 +02:00
Dylan DPC
6d2b885112
Rollup merge of #76242 - RalfJung:read-fixme, r=Dylan-DPC
Read: adjust a FIXME reference

There's already another reference to https://github.com/rust-lang/rust/issues/42788 for basically the same problem, so lets reuse it here:
5e208efaa8/library/std/src/io/mod.rs (L369-L376)

r? @Dylan-DPC
2020-09-03 02:22:11 +02:00
Dylan DPC
4918ed96ee
Rollup merge of #76238 - denisvasilik:intra-doc-links-core-iterator, r=jyn514
Move to intra-doc links for library/core/src/iter/traits/iterator.rs

Helps with #75080.

@jyn514 We're almost finished with this issue. Thanks for mentoring. If you have other topics to work on just let me know, I will be around in Discord.

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

Known issues:

* Link from `core` to `std` (#74481):

    [`OsStr`]
    [`String`]
    [`VecDeque<T>`]
2020-09-03 02:22:10 +02:00
Dylan DPC
d059f2619f
Rollup merge of #76204 - NoraCodes:nora/control_flow_enum, r=scottmcm
Rename and expose LoopState as ControlFlow

Basic PR for #75744. Addresses everything there except for documentation; lots of examples are probably a good idea.
2020-09-03 02:22:07 +02:00
Dylan DPC
3e156cfe90
Rollup merge of #76164 - lzutao:slice-array, r=ehuss
Link to slice pattern in array docs

Fix a todo in https://github.com/rust-lang/reference/issues/739#issuecomment-578408449
2020-09-03 02:22:04 +02:00
Dylan DPC
9605f94f69
Rollup merge of #76142 - CDirkx:const-ip, r=ecstatic-morse
Make all methods of `std::net::Ipv4Addr` const

Make the following methods of `std::net::Ipv4Addr` unstable const under the `const_ipv4` feature:
 - `octets`
 - `is_loopback`
 - `is_private`
 - `is_link_local`
 - `is_global` (unstable)
 - `is_shared` (unstable)
 - `is_ietf_protocol_assignment` (unstable)
 - `is_benchmarking` (unstable)
 - `is_reserved` (unstable)
 - `is_multicast`
 - `is_broadcast`
 - `is_documentation`
 - `to_ipv6_compatible`
 - `to_ipv6_mapped`

This would make all methods of `Ipv6Addr` const.

Of these methods, `is_global`, `is_broadcast`, `to_ipv6_compatible`, and `to_ipv6_mapped` require a change in implementation.

Part of #76205
2020-09-03 02:22:02 +02:00
Dylan DPC
10aa3d3f89
Rollup merge of #76120 - LukasKalbertodt:add-as-slice-method-to-array, r=Mark-Simulacrum
Add `[T; N]::as_[mut_]slice`

Part of me trying to populate arrays with a couple of basic useful methods, like slices already have. The ability to add methods to arrays were added in #75212.  Tracking issue: #76118

This adds:

```rust
impl<T, const N: usize> [T; N] {
    pub fn as_slice(&self) -> &[T];
    pub fn as_mut_slice(&mut self) -> &mut [T];
}
```

These methods are like the ones on `std::array::FixedSizeArray` and in the crate `arraytools`.
2020-09-03 02:22:00 +02:00
Dylan DPC
536b0c0c90
Rollup merge of #75150 - nanpuyue:deprecate_to_ipv6_compatible, r=LukasKalbertodt
Add a note for Ipv4Addr::to_ipv6_compatible

Previous discussion: #75019

> I think adding a comment saying "This isn't typically the method you want; these addresses don't typically function on modern systems. Use `to_ipv6_mapped` instead." would be a good first step, whether this method gets marked as deprecated or not.

_Originally posted by @joshtriplett in https://github.com/rust-lang/rust/pull/75150#issuecomment-680267745_
2020-09-03 02:21:58 +02:00
Camelid
7926435317
Add back missing link 2020-09-02 15:48:35 -07:00
Camelid
2908ed64aa Use intra-doc links in core::marker 2020-09-02 15:22:40 -07:00
Joshua Nelson
bb103476a9 Fix incorrect link in prelude 2020-09-02 17:38:21 -04:00
Joshua Nelson
44bacc3ffa Revert change to MaybeUninit until rustdoc bugs are fixed
https://github.com/rust-lang/rust/issues/76106
2020-09-02 17:38:21 -04:00
Joshua Nelson
59a1a05bff Convert many files to intra-doc links
- Use intra-doc links for `std::io` in `std::fs`
- Use intra-doc links for File::read in unix/ext/fs.rs
- Remove explicit intra-doc links for `true` in `net/addr.rs`
- Use intra-doc links in alloc/src/sync.rs
- Use intra-doc links in src/ascii.rs
- Switch to intra-doc links in alloc/rc.rs
- Use intra-doc links in core/pin.rs
- Use intra-doc links in std/prelude
- Use shorter links in `std/fs.rs`

  `io` is already in scope.
2020-09-02 17:37:40 -04:00
Leonora Tindall
96eb5e1751 Format ControlFlow changes with rustfmt 2020-09-02 14:12:21 -05:00
bors
a167485e27 Auto merge of #75960 - camelid:patch-6, r=jyn514
Improve docs for the `const` keyword

@rustbot modify labels: T-doc
2020-09-02 17:35:46 +00:00
Denis Vasilik
89e7fb3bbd Revert link removal of Some(T) 2020-09-02 19:11:19 +02:00
Denis Vasilik
83143a1ef4 Revert link removal of 2020-09-02 19:07:32 +02:00
Denis Vasilik
3a035891f0 Revert link removal 2020-09-02 18:51:53 +02:00
Denis Vasilik
1a438bbcb7 Revert module level documentation link 2020-09-02 18:51:08 +02:00
Denis Vasilik
7cf0fe1d02 Apply suggestions from review 2020-09-02 18:32:46 +02:00
bors
95815c9b2b Auto merge of #76241 - RalfJung:flt2dec, r=Mark-Simulacrum
flt2dec: properly handle uninitialized memory

The float-to-str code currently uses uninitialized memory incorrectly (see https://github.com/rust-lang/rust/issues/76092). This PR fixes that.

Specifically, that code used `&mut [T]` as "out references", but it would be incorrect for the caller to actually pass uninitialized memory. So the PR changes this to `&mut [MaybeUninit<T>]`, and then functions return a `&[T]` to the part of the buffer that they initialized (some functions already did that, indirectly via `&Formatted`, others were adjusted to return that buffer instead of just the initialized length).

What I particularly like about this is that it moves `unsafe` to the right place: previously, the outermost caller had to use `unsafe` to assert that things are initialized; now it is the functions that do the actual initializing which have the corresponding `unsafe` block when they call `MaybeUninit::slice_get_ref` (renamed in https://github.com/rust-lang/rust/pull/76217 to `slice_assume_init_ref`).

Reviewers please be aware that I have no idea how any of this code actually works. My changes were purely mechanical and type-driven. The test suite passes so I guess I didn't screw up badly...

Cc @sfackler this is somewhat related to your RFC, and possibly some of this code could benefit from (a generalized version of) the API you describe there. But for now I think what I did is "good enough".

Fixes https://github.com/rust-lang/rust/issues/76092.
2020-09-02 15:23:08 +00:00
南浦月
3b29913295 add a note for Ipv4Addr::to_ipv6_compatible 2020-09-02 21:08:09 +08:00
Anton
dbe50f5c24
Same typos in vec_deque 2020-09-02 14:09:42 +02:00
Anton
b67006422e
Fix typos in vec try_reserve(_exact) docs
`try_reserve` and `try_reserve_exact` docs refer to calling `reserve` and `reserve_exact`.
`try_reserve_exact` example uses `try_reserve` method instead of `try_reserve_exact`.
2020-09-02 13:12:44 +02:00
Ralf Jung
56129d39c0 flt2dec: properly handle uninitialized memory 2020-09-02 12:41:38 +02:00
Ralf Jung
0af3bd01df Read: adjust a FIXME reference 2020-09-02 12:34:15 +02:00
Joshua Nelson
726b187546 Use intra-doc links for MaybeUninit in boxed.rs 2020-09-01 23:54:17 -04:00
Joshua Nelson
cafab51b29 Remove explicit links to true and false in ip.rs 2020-09-01 23:33:44 -04:00
Camelid
ce904783d0
Improve wording for const pointers 2020-09-01 19:44:20 -07:00
Tyler Mandry
4dd75f8049
Rollup merge of #76221 - camelid:cleanup-iter-for, r=jyn514
Clean up header in `iter` docs for `for` loops

@rustbot modify labels: T-doc
2020-09-01 18:24:48 -07:00
Tyler Mandry
7edc93b45c
Rollup merge of #76207 - denisvasilik:intra-doc-links-core-clone, r=jyn514
# Move to intra-doc links for library/core/src/clone.rs

Helps with #75080.

@rustbot modify labels: T-doc, A-intra-doc-links
2020-09-01 18:24:43 -07:00
Tyler Mandry
11ff32f9ec
Rollup merge of #76206 - CDirkx:const-ipv6, r=ecstatic-morse
Make all methods of `std::net::Ipv6Addr` const

Make the following methods of `std::net::Ipv6Addr` unstable const under the `const_ipv6` feature:
- `segments`
- `is_unspecified`
- `is_loopback`
- `is_global` (unstable)
- `is_unique_local`
- `is_unicast_link_local_strict`
- `is_documentation`
- `multicast_scope`
- `is_multicast`
- `to_ipv4_mapped`
- `to_ipv4`

This would make all methods of `Ipv6Addr` const.

Changed the implementation of `is_unspecified` and `is_loopback` to use a `match` instead of `==`, all other methods did not require a change.

All these methods are dependent on `segments`, the current implementation of which requires unstable `const_fn_transmute` ([PR#75085](https://github.com/rust-lang/rust/pull/75085)).

Part of #76205
2020-09-01 18:24:41 -07:00
Tyler Mandry
17fa7339e9
Rollup merge of #76201 - denisvasilik:intra-doc-links-core-panic, r=kennytm
Move to intra-doc links for library/core/src/panic.rs

Helps with #75080.

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

Known issues:

* Link from `core` to `std` (#74481):

    [`set_hook`]
    [`String`]
2020-09-01 18:24:39 -07:00
Tyler Mandry
34c8b7a92c
Rollup merge of #76099 - camelid:patch-8, r=jyn514
Add info about `!` and `impl Trait`

Fixes #76094.

@rustbot modify labels: T-doc C-enhancement
2020-09-01 18:24:29 -07:00
Tyler Mandry
7c1c7de85f
Rollup merge of #76088 - hbina:add_example, r=LukasKalbertodt
Add more examples to lexicographic cmp on Iterators.

Given two arrays of T1 and T2, the most important rule of lexicographical comparison is that two arrays
of equal length will be compared until the first difference occured.

The examples provided only focuses on the second rule that says that the
shorter array will be filled with some T2 that is less than every T1.
Which is only possible because of the first rule.
2020-09-01 18:24:27 -07:00
Tyler Mandry
383da5e1e6
Rollup merge of #74880 - chrisduerr:fix_matches, r=dtolnay
Add trailing comma support to matches macro
2020-09-01 18:24:23 -07:00
Camelid
54a4fd1eb9
Minor improvements
Co-authored-by: Joshua Nelson <joshua@yottadb.com>
2020-09-01 17:38:16 -07:00