Commit Graph

76 Commits

Author SHA1 Message Date
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
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
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
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
Stein Somers
99398dd2fd BTreeMap::drain_filter no longer touches the root during iteration 2020-08-01 23:35:30 +02:00
Stein Somers
602f9aab89 More benchmarks of BTreeMap mutation 2020-08-01 20:23:13 +02:00
Alexis Bourget
54eb3768e0 Reword incorrect use of zeroed() 2020-08-01 19:28:19 +02:00
Amanieu d'Antras
df3a30aee4 Add Vec::spare_capacity_mut 2020-08-01 18:24:35 +01:00
Stein Somers
240ef70c7b Define forget_type only when relevant 2020-08-01 14:09:19 +02:00
bors
b5eae9c44d Auto merge of #74373 - lcnr:array_chunks, r=withoutboats
add `slice::array_chunks` to std

Now that #74113 has landed, these methods are suddenly usable. A rebirth of #72334

Tests are directly copied from `chunks_exact` and some additional tests for type inference.

r? @withoutboats as you are both part of t-libs and working on const generics. closes #60735
2020-08-01 06:54:14 +00:00
Bastian Kauschke
d51b71a35a add tracking issue 2020-08-01 07:49:24 +02:00
Yuki Okushi
ab4570eaf0
Rollup merge of #74644 - crlf0710:drop_old_stuff, r=Amanieu
Remove `linked_list_extras` methods.

Removing these in favor of the `Cursor` API in https://github.com/rust-lang/rust/issues/58533 .
Closes #27794.

r? @Amanieu
2020-08-01 08:02:04 +09:00
Charles Lew
dc21178830 Remove linked_list_extras methods. 2020-08-01 00:54:22 +08:00
Ralf Jung
ff0c3a9209 expand comments 2020-07-31 14:03:42 +02:00
Ralf Jung
7468f632ff also reduce some libcore test iteration counts 2020-07-31 11:56:08 +02:00
Ralf Jung
7e168a696f reduce slice::panic_safe test size further in Miri 2020-07-31 11:56:08 +02:00
Ralf Jung
0a62b7dc92 make some vec_deque tests less exhaustive in Miri 2020-07-31 11:56:08 +02:00
Shen-Ta Hsieh
4c851792ac
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-07-31 09:01:16 +00:00
bors
3a92b9987a Auto merge of #74956 - ecstatic-morse:const-option-unwrap, r=oli-obk
Make `Option::unwrap` unstably const

This is lumped into the `const_option` feature gate (#67441), which enables a potpourri of `Option` methods.

cc @rust-lang/wg-const-eval

r? @oli-obk
2020-07-31 08:26:33 +00:00
Bastian Kauschke
e75ffb0f1c use Iter<'_, [T; N]> in array_chunks 2020-07-31 08:25:23 +02:00
Bastian Kauschke
a410ebc5ea add note to array_chunks 2020-07-31 08:24:57 +02:00
Lzu Tao
6d293ede9f Update tests 2020-07-31 02:44:29 +00:00
Lzu Tao
c25f25f7f1 Stabilize as_deref and as_deref on Result 2020-07-31 02:42:24 +00:00
Lzu Tao
07575286b8 Remove as_deref_err and as_deref_mut_err from Result 2020-07-31 02:42:24 +00:00
bors
ffa80f01d8 Auto merge of #74926 - Manishearth:rename-lint, r=jyn514
Rename intra_doc_link_resolution_failure

It should be plural to follow the conventions in https://github.com/rust-lang/rfcs/blob/master/text/0344-conventions-galore.md#lints
2020-07-31 02:20:47 +00:00
bors
c058a8b8dc Auto merge of #74682 - alexcrichton:backtrace-gimli-round-2, r=Mark-Simulacrum
std: Switch from libbacktrace to gimli (take 2)

This is the second attempt to land https://github.com/rust-lang/rust/pull/73441 after being reverted in https://github.com/rust-lang/rust/pull/74613. Will be gathering precise perf numbers here in this take.

Closes #71060
2020-07-30 23:22:09 +00:00
Manish Goregaokar
46379687ac
Rollup merge of #74782 - vorner:weak-into-raw-cnt-doc, r=dtolnay
Don't use "weak count" around Weak::from_raw_ptr

As `Rc/Arc::weak_count` returns 0 when having no strong counts, this
could be confusing and it's better to avoid using that completely.

Closes #73840.
2020-07-30 13:04:29 -07:00
Dylan MacKenzie
fc2c1f8ddc Make Option::unwrap unstably const
`Result::unwrap` is not eligible becuase it formats the contents of the
`Err` variant. `unwrap_or`, `unwrap_or_else` and friends are not
eligible because they drop things or invoke closures.
2020-07-30 12:30:58 -07:00
Manish Goregaokar
522ef2e981 Remove deny for intra doc link failures from library code, it's no longer necessary 2020-07-30 08:14:27 -07:00
Manish Goregaokar
7b7b5a7a12 Rename in library 2020-07-30 08:14:27 -07:00
bors
21867225a7 Auto merge of #74930 - ecstatic-morse:const-size-align-of-val, r=oli-obk
Make `mem::size_of_val` and `mem::align_of_val` unstably const

Implements #46571 but does not stabilize it. I wanted this while working on something today.

The only reason not to immediately stabilize are concerns around [custom DSTs](https://github.com/rust-lang/rust/issues/46571#issuecomment-387669352). That proposal has made zero progress in the last two years and const eval is rich enough to support pretty much any user-defined `len` function as long as nightly features are allowed (`raw_ptr_deref`).

Currently, this raises a `const_err` lint when passed an `extern type`.

r? @oli-obk

cc @rust-lang/wg-const-eval
2020-07-30 12:52:41 +00:00
Bastian Kauschke
95fa63e63f liballoc export ArrayChunks 2020-07-30 10:50:35 +02:00
Bastian Kauschke
d27007fd6d add tests for array_chunks 2020-07-30 10:50:34 +02:00
Bastian Kauschke
d405347f09 adds slice::array_chunks 2020-07-30 10:50:34 +02:00
Bastian Kauschke
870b7cbb11 improve chunks + windows err on size 0 2020-07-30 10:50:34 +02:00
Dylan MacKenzie
9caf0b5222 Make {align,size}_of_val const 2020-07-29 16:50:15 -07:00
Manish Goregaokar
2050128302
Rollup merge of #74910 - RalfJung:fence, r=Mark-Simulacrum
fence docs: fix example Mutex

Fixes https://github.com/rust-lang/rust/issues/74808

Cc @pca006132
2020-07-29 16:38:31 -07:00
Manish Goregaokar
0f9b7bd80f
Rollup merge of #74902 - rust-lang:into_raw_non_null, r=dtolnay
Remove deprecated unstable `{Box,Rc,Arc}::into_raw_non_null` functions

FCP: https://github.com/rust-lang/rust/issues/47336#issuecomment-619369613
2020-07-29 16:38:28 -07:00
Manish Goregaokar
c07998e0e7
Rollup merge of #74852 - lzutao:inline-rm-tostring, r=nnethercote
Explain why inlining default ToString impl

Trying to remove inline attribute from default ToString impl causes regression.
Perf result at <https://github.com/rust-lang/rust/pull/74852#issuecomment-664812994>.
2020-07-29 16:38:22 -07:00
Manish Goregaokar
35226766c9
Rollup merge of #74819 - tmiasko:format-spec, r=joshtriplett
Point towards `format_spec`; it is in other direction
2020-07-29 16:38:20 -07:00