Commit graph

5234 commits

Author SHA1 Message Date
Samuel E. Moelius III
fa23d4fe93 Implement #85440 2021-09-29 21:51:46 -04:00
Yuki Okushi
5d14396ed0
Rollup merge of #88887 - fee1-dead:const-deref, r=oli-obk
Const Deref

Implements `const Deref`/`const DerefMut` for `&mut T`, `&T`, `Cow<'_, B>` and `ManuallyDrop<T>`
2021-09-17 14:09:48 +09:00
Yuki Okushi
0f06e36603
Rollup merge of #88339 - piegamesde:master, r=joshtriplett
Add TcpListener::into_incoming and IntoIncoming

The `incoming` method is really useful, however for some use cases the borrow
this introduces is needlessly restricting. Thus, an owned variant is added.

r? ``@joshtriplett``
2021-09-17 14:09:45 +09:00
Manish Goregaokar
d9fa3561b6
Rollup merge of #89009 - tatami4:master, r=Mark-Simulacrum
Fix typo in `break` docs
2021-09-16 10:57:25 -07:00
Manish Goregaokar
84d384c8c1
Rollup merge of #88986 - hargoniX:master, r=Mark-Simulacrum
Update the backtrace crate

https://github.com/rust-lang/backtrace-rs/pull/437 fixed backtraces in
OpenBSD -> update it here as well so OpenBSD Rust code can produce
proper backtraces.
2021-09-16 10:57:24 -07:00
Manish Goregaokar
06dbc284a8
Rollup merge of #88976 - notriddle:notriddle/cow-from-cstr-docs, r=Mark-Simulacrum
Clean up and add doc comments for CStr

CC #51430
2021-09-16 10:57:21 -07:00
Manish Goregaokar
5b6285e370
Rollup merge of #88928 - lefth:master, r=Mark-Simulacrum
Document the closure arguments for `reduce`.

See issue #88927.
2021-09-16 10:57:20 -07:00
tatami4
a452d02636
Fix typo in break docs 2021-09-16 14:51:14 +03:00
Manish Goregaokar
cad1efae57
Rollup merge of #88915 - joshlf:patch-4, r=kennytm
`Wrapping<T>` has the same layout and ABI as `T`
2021-09-15 14:57:02 -07:00
Henrik Böving
4e61d11a16 Update the backtrace crate
https://github.com/rust-lang/backtrace-rs/pull/437 fixed backtraces in
OpenBSD -> update it here as well so OpenBSD Rust code can produce
proper backtraces.
2021-09-15 20:32:35 +02:00
Michael Howell
cc7929b1bd docs(std): add docs for cof_from_cstr impls
CC #51430
2021-09-15 09:14:20 -07:00
bors
e846f9c44f Auto merge of #88619 - GuillaumeGomez:simplify-std-os-reexports, r=Amanieu
Remove `cfg(doc)` from std::os module reexports to fix rustdoc linking issues

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

I tested it based on https://github.com/rust-lang/rust/pull/88292.

Not sure if it's the best approach, but at least it makes thing a bit simpler.

cc `@jyn514`
2021-09-15 09:30:00 +00:00
Deadbeef
349ac4f6c8
Const Deref 2021-09-15 03:06:53 +00:00
Dan Zwell
6b7f916008 Document the closure arguments for reduce.
Fixes issue #88927.
2021-09-14 14:22:49 +08:00
Joshua Liebow-Feeser
1053a5bb0f
Wrapping<T> has the same layout and ABI as T 2021-09-13 12:39:45 -07:00
Guillaume Gomez
5eb77838ea
Rollup merge of #88722 - WaffleLapkin:unsafe_cell_const_get_mut, r=dtolnay
Make `UnsafeCell::get_mut` const
2021-09-13 21:20:39 +02:00
Guillaume Gomez
7965a9f143 Move fortanix module position in std::os reexports for alpha sort 2021-09-13 21:00:28 +02:00
Guillaume Gomez
1c4873c81f Remove usage of cfg_if in std/src/os/mod.rs 2021-09-13 21:00:28 +02:00
Guillaume Gomez
8d879aa0f2 Simplify std::os module reexports to fix rustdoc linking issues 2021-09-13 21:00:28 +02:00
Joshua Nelson
7b46920218 Fix linkcheck issues
Most of these are because alloc uses `#[lang_item]` to define methods,
but core documents primitives before those methods are available.

- Fix rustdoc-js-std test

  For some reason this change made CStr not show up in the results for
  `str,u8`. Since it still shows up for str, and since it wasn't a great
  match for that query anyway, I think this is ok to let slide.

- Add test that all primitives can be linked to
- Enable `doc(primitive)` in `core` as well
- Add linkcheck exception specifically for Windows

  Ideally this would be done automatically by the linkchecker by
  replacing `\\` with forward slashes, but this PR is already a ton of
  work ...

- Don't forcibly fail linkchecking if there's a broken intra-doc link on Windows

  Previously, it would exit with a hard error if a missing file had `::`
  in it. This changes it to report a missing file instead, which allows
  adding an exception.
2021-09-12 02:30:24 +00:00
Joshua Nelson
69fe39e8a8 Add primitive documentation to libcore
This works by doing two things:
- Adding links that are specific to the crate. Since not all primitive
  items are defined in `core` (due to lang_items), these need to use
  relative links and not intra-doc links.
- Duplicating `primitive_docs` in both core and std. This allows not needing CARGO_PKG_NAME to build the standard library. It also adds a tidy check to make sure they stay the same.
2021-09-12 02:23:08 +00:00
Jubilee
c2e1097f44
Rollup merge of #88849 - matthiaskrgr:clony_on_copy, r=petrochenkov
don't clone types that are Copy (clippy::clone_on_copy)
2021-09-11 08:23:45 -07:00
Jubilee
95b50eb662
Rollup merge of #87904 - kpreid:unsize, r=jyn514
Reword description of automatic impls of `Unsize`.

The existing documentation felt a little unhelpfully concise, so this change tries to improve it by using longer sentences, each of which specifies which kinds of types it applies to as early as possible. In particular, the third item starts with “Structs ...” instead of saying “Foo is a struct” later.

Also, the previous list items “Only the last field has a type involving `T`” and “`T` is not part of the type of any other fields” are, as far as I see, redundant with each other, so I removed the latter.

I have no particular knowledge of `Unsize`; I have attempted to leave the meaning entirely unchanged but may have missed a nuance.

Markdown preview of the edited documentation:

> All implementations of `Unsize` are provided automatically by the compiler.
> Those implementations are:
>
> - Arrays `[T; N]` implement `Unsize<[T]>`.
> - Types implementing a trait `Trait` also implement `Unsize<dyn Trait>`.
> - Structs `Foo<..., T, ...>` implement `Unsize<Foo<..., U, ...>>` if all of these conditions
>   are met:
>   - `T: Unsize<U>`.
>   - Only the last field of `Foo` has a type involving `T`.
>   - `Bar<T>: Unsize<Bar<U>>`, where `Bar<T>` stands for the actual type of that last field.
2021-09-11 08:23:38 -07:00
Matthias Krüger
c1e96085d3 don't clone types that are Copy (clippy::clone_on_copy) 2021-09-11 10:18:56 +02:00
Waffle Lapkin
2c30162380
Fill in the tracking issue for #![feature(const_unsafecell_get_mut)] 2021-09-11 00:07:14 +03:00
Manish Goregaokar
00553034db
Rollup merge of #88807 - jruderman:which_reverses, r=joshtriplett
Fix typo in docs for iterators
2021-09-10 08:23:26 -07:00
Manish Goregaokar
8368af060d
Rollup merge of #88667 - kraktus:patch-1, r=dtolnay
Tweak `write_fmt` doc.

Found this weird sentence while reading the docs.
2021-09-10 08:23:21 -07:00
Manish Goregaokar
000dbd27f1
Rollup merge of #86165 - m-ou-se:proc-macro-span-shrink, r=dtolnay
Add proc_macro::Span::{before, after}.

This adds `proc_macro::Span::before()` and `proc_macro::Span::after()` to get a zero width span at the start or end of the span.

These are equivalent to rustc's `Span::shrink_to_lo()` and `Span::shrink_to_hi()` but with a less cryptic name. They are useful when generating diagnostlics like "missing \<thing\> after \<thing\>".

E.g.

```rust
syn::Error::new(ident.span().after(), "missing `:` after field name").into_compile_error()
```
2021-09-10 08:23:14 -07:00
Jesse Ruderman
81ff53fd3e
Fix typo in docs for iterators 2021-09-09 19:21:56 -07:00
Fabian Wolff
79adda930f Ignore automatically derived impls of Clone and Debug in dead code analysis 2021-09-09 19:49:07 +02:00
Mark Rousskov
b4e7649d6d Bump stage0 compiler to 1.56 2021-09-08 20:51:05 -04:00
Jack Huey
bd6ce72ece
Rollup merge of #88712 - jhpratt:fix-int_rounding-docs, r=joshtriplett
Fix docs for `uX::checked_next_multiple_of`

Thanks to `@photino` for noticing this [here](https://github.com/rust-lang/rust/issues/88581#issuecomment-913982246).

r? `@joshtriplett`

`@rustbot` label: +A-docs +A-waiting-on-review
2021-09-08 12:24:21 -04:00
Jack Huey
2bbcf929c6
Rollup merge of #88648 - kpreid:option, r=Mark-Simulacrum
Correct “copies” to “moves” in `<Option<T> as From<T>>::from` doc, and other copyediting

The `impl<T> From<T> for Option<T>` has no `Copy` or `Clone` bound, so its operation is guaranteed to be a move. The call site might copy, but the function itself cannot.

Since that would have been a rather small PR, I also reviewed the other documentation in the file and made other improvements (in separate commits): adding periods and commas, linking `Deref::Target`, and clarifying what "a container" is in `FromIterator`.
2021-09-08 12:24:18 -04:00
Jack Huey
b1c782f20b
Rollup merge of #88594 - steffahn:more_symbolic_doc_aliases, r=joshtriplett
More symbolic doc aliases

A bunch of small changes, mostly adding `#[doc(alias = "…")]` entries for symbolic `"…"`.

Also a small change in documentation of `const` keywords.
2021-09-08 12:24:17 -04:00
bors
434cb437b5 Auto merge of #86943 - ptrojahn:suggest_derive, r=estebank
Suggest deriving traits if possible

This only applies to builtin derives as I don't think there is a
clean way to get the available derives in typeck.

Closes #85851
2021-09-08 07:27:41 +00:00
Waffle
efeb461873 Make UnsafeCell::get_mut const 2021-09-07 16:41:15 +03:00
Jacob Pratt
56bb6f5a25
Fix docs for uX::checked_next_multiple_of 2021-09-07 02:14:04 -04:00
bors
ffaf857045 Auto merge of #88448 - xu-cheng:btree-blk-build, r=Mark-Simulacrum
BTreeMap/BTreeSet::from_iter: use bulk building to improve the performance

Bulk building is a common technique to increase the performance of building a fresh btree map. Instead of inserting items one-by-one, we sort all the items beforehand then create the BtreeMap in bulk.

Benchmark
```
./x.py bench library/alloc --test-args btree::map::from_iter
```

* Before
```
test btree::map::from_iter_rand_100                      ... bench:       3,694 ns/iter (+/- 840)
test btree::map::from_iter_rand_10_000                   ... bench:   1,033,446 ns/iter (+/- 192,950)
test btree::map::from_iter_seq_100                       ... bench:       5,689 ns/iter (+/- 1,259)
test btree::map::from_iter_seq_10_000                    ... bench:     861,033 ns/iter (+/- 118,815)
```

* After
```
test btree::map::from_iter_rand_100                      ... bench:       3,033 ns/iter (+/- 707)
test btree::map::from_iter_rand_10_000                   ... bench:     775,958 ns/iter (+/- 105,152)
test btree::map::from_iter_seq_100                       ... bench:       2,969 ns/iter (+/- 336)
test btree::map::from_iter_seq_10_000                    ... bench:     258,292 ns/iter (+/- 29,364)
```
2021-09-07 02:24:11 +00:00
Paul Trojahn
50e5f90c92 Suggest deriving traits if possible
This only applies to builtin derives as I don't think there is a
clean way to get the available derives in typeck.

Closes #85851
2021-09-06 13:18:05 +02:00
Ryan Levick
0d4a51d741
Rollup merge of #88673 - Qwaz:node-typo, r=jyn514
Fix typo: needede -> needed

Fix a typo in library/alloc/src/collections/btree/node.rs
2021-09-06 12:38:57 +02:00
Ryan Levick
29a018def4
Rollup merge of #88647 - ChrisDenton:win-symlink-docs, r=joshtriplett
Document when to use Windows' `symlink_dir` vs. `symlink_file`

It was previously unclear why there are two functions and when they should be used.

Fixes: #88635
2021-09-06 12:38:54 +02:00
Yechan Bae
3a105cfcea Fix typo: needede -> needed 2021-09-05 16:04:19 -04:00
Frank Steffahn
5135d86920 Mention usage of const in raw pointer types at the top of the keyword's documentation page. 2021-09-05 19:14:55 +02:00
Frank Steffahn
2b69171dc2 Additional aliases for pointers 2021-09-05 19:14:44 +02:00
kraktus
bfb2b02d61
Tweak write_fmt doc.
Previous version wrongly used `but` while the two parts of the sentence are not contradicting but completing with each other.
2021-09-05 17:23:58 +02:00
Falk Hüffner
d760c33183 Change return type for T::{log,log2,log10} to u32. The value is at
most 128, and this is consistent with using u32 for small values
elsewhere (e.g. BITS, count_ones, leading_zeros).
2021-09-05 17:09:21 +02:00
Mara Bos
22dd6a4e30
Rollup merge of #88432 - terrarier2111:patch-1, r=joshtriplett
Fix a typo in raw_vec
2021-09-05 10:32:21 +02:00
bors
0961e688fd Auto merge of #88469 - patrick-gu:master, r=dtolnay
Add links in docs for some primitive types

This pull request adds additional links in existing documentation of some of the primitive types.

Where items are linked only once, I have used the `[link](destination)` format. For items in `std`, I have linked directly to the HTML, since although the primitives are in `core`, they are not displayed on `core` documentation. I was unsure of what length I should keep lines of documentation to, so I tried to keep them within reason.

Additionally, I have avoided excessively linking to keywords like `self` when they are not relevant to the documentation. I can add these links if it would be an improvement.

I hope this can improve Rust. Please let me know if there's anything I did wrong!
2021-09-05 01:56:25 +00:00
Kevin Reid
9a3a2a1c37 Clarify what “a container” is in FromIterator<Option<A>> for Option<V> doc. 2021-09-04 11:30:14 -07:00
Kevin Reid
c2f432058c Add sentence punctuation and links in Option docs. 2021-09-04 11:30:14 -07:00