Commit graph

2551 commits

Author SHA1 Message Date
Yuki Okushi
1ed90e4f06
Rollup merge of #80791 - mrcz:master, r=jyn514
Fix type name in doc example for Iter and IterMut
2021-01-08 11:11:47 +09:00
bors
c8915eebea Auto merge of #80790 - JohnTitor:rollup-js1noez, r=JohnTitor
Rollup of 10 pull requests

Successful merges:

 - #80012 (Add pointing const identifier when emitting E0435)
 - #80521 (MIR Inline is incompatible with coverage)
 - #80659 (Edit rustc_ast::tokenstream docs)
 - #80660 (Properly handle primitive disambiguators in rustdoc)
 - #80738 (Remove bottom margin from crate version when the docs sidebar is collapsed)
 - #80744 (rustdoc: Turn `next_def_id` comments into docs)
 - #80750 (Don't use to_string on Symbol in rustc_passes/check_attr.rs)
 - #80769 (Improve wording of parse doc)
 - #80780 (Return EOF_CHAR constant instead of magic char.)
 - #80784 (rustc_parse: Better spans for synthesized token streams)

Failed merges:

 - #80785 (rustc_ast_pretty: Remove `PrintState::insert_extra_parens`)

r? `@ghost`
`@rustbot` modify labels: rollup
2021-01-07 18:20:12 +00:00
Marcus Svensson
358ef56216 Enclose types in comments in backticks 2021-01-07 18:36:25 +01:00
Marcus Svensson
10180b4c53 Fix type name in doc example for Iter and IterMut 2021-01-07 18:22:37 +01:00
Yuki Okushi
a97dc5f103
Rollup merge of #80769 - ejez:patch-1, r=jonas-schievink
Improve wording of parse doc

Change:
```
`parse` can parse any type that...
```
to:
```
`parse` can parse into any type that...
```
Word `into` added to be more precise and in coherence with other parts of the doc.
2021-01-08 02:06:16 +09:00
bors
8f0b945cfc Auto merge of #77853 - ijackson:slice-strip-stab, r=Amanieu
Stabilize slice::strip_prefix and slice::strip_suffix

These two methods are useful.  The corresponding methods on `str` are already stable.

I believe that stablising these now would not get in the way of, in the future, extending these to take a richer pattern API a la `str`'s patterns.

Tracking PR: #73413.  I also have an outstanding PR to improve the docs for these two functions and the corresponding ones on `str`: #75078

I have tried to follow the [instructions in the dev guide](https://rustc-dev-guide.rust-lang.org/stabilization_guide.html#stabilization-pr).  The part to do with `compiler/rustc_feature` did not seem applicable.  I assume that's because these are just library features, so there is no corresponding machinery in rustc.
2021-01-07 15:21:30 +00:00
bors
b5c496de37 Auto merge of #79863 - JohnTitor:compiler-builtins, r=bjorn3
Update `compiler_builtins` to 0.1.39

This version contains the fixes of https://github.com/rust-lang/compiler-builtins/issues/390 and https://github.com/rust-lang/compiler-builtins/issues/391.
Also, rename features following https://github.com/rust-lang/compiler-builtins/pull/386.
2021-01-07 11:22:42 +00:00
Yuki Okushi
6275a29dbe Update compiler_builtins to 0.1.39 2021-01-07 16:16:36 +09:00
Ejez
2b8109f229
Improve wording of parse doc
Change:
```
`parse` can parse any type that...
```
to:
```
`parse` can parse into any type that...
```
Word `into` added to be more precise and in coherence with other parts of the doc.
2021-01-07 07:47:03 +03:00
bors
da305a2b00 Auto merge of #80711 - camelid:intrinsic-of-val-safety, r=oli-obk
Make `size_of_val` and `min_align_of_val` intrinsics unsafe

Fixes #80668.

r? `@oli-obk`
2021-01-05 17:07:25 +00:00
bors
3b63e16552 Auto merge of #80717 - mbartlett21:patch-2, r=dtolnay
Add more code spans to docs in intrinsics.rs

I have added some more code spans in core/src/intrinsics.rs, changing some `=` to `==`, etc. I also changed the wording in some sections.
2021-01-05 14:15:49 +00:00
bors
68ec332611 Auto merge of #80699 - usbalbin:const_copy_tracking_issue, r=oli-obk
const_intrinsic_copy - Add Reference to tracking issue

Add reference to tracking issue #80697 for feature gate added in previous PR #79684
2021-01-05 11:29:27 +00:00
mbartlett21
63dd00b97b
Add code spans to docs in intrinsics.rs 2021-01-05 17:27:10 +10:00
Camelid
bbf175df3c Make size_of_val and min_align_of_val intrinsics unsafe 2021-01-04 19:23:55 -08:00
Yuki Okushi
ee94d9d690
Rollup merge of #80677 - kw-fn:patch-2, r=jyn514
doc -- list edit for consistency
2021-01-05 09:52:50 +09:00
Yuki Okushi
cda26a6b15
Rollup merge of #80666 - jjlin:master, r=Dylan-DPC
Fix missing link for "fully qualified syntax"

This issue can currently be seen at https://doc.rust-lang.org/stable/std/rc/index.html#toggle-all-docs:~:text=%5B-,fully%20qualified%20syntax

It originates from #76138, where the link was added to `library/alloc/src/sync.rs`, but not `library/alloc/src/rc.rs`.
2021-01-05 09:52:47 +09:00
Yuki Okushi
cbdc24174b
Rollup merge of #80656 - booleancoercion:master, r=sfackler
Fixed documentation error for `std::hint::spin_loop`

Fixes #80644.
2021-01-05 09:52:45 +09:00
Yuki Okushi
bdf8bbde1d
Rollup merge of #80442 - steffahn:mention_arc_in_cow, r=Mark-Simulacrum
Mention Arc::make_mut and Rc::make_mut in the documentation of Cow

Following this discussion: https://users.rust-lang.org/t/should-the-cow-documentation-mention-arc/53341

_Rendered (the last paragraph is new):_

![Screenshot_20201228_171551](https://user-images.githubusercontent.com/3986214/103228135-5d72e200-4930-11eb-89e1-38b5c86b08c7.png)

`@rustbot` modify labels: T-doc, T-libs
2021-01-05 09:52:33 +09:00
Albin Hedman
63f5d6111a Added reference to tracking issue and removed unneeded line 2021-01-04 19:36:25 +01:00
oliver
e152582a2b
doc -- list edit for consistency 2021-01-04 04:50:24 +00:00
Jeremy Lin
6d45d055a1 Fix missing link for "fully qualified syntax" 2021-01-03 13:59:02 -08:00
bool
514b0ce9d2 Fixed documentation error 2021-01-03 19:54:54 +02:00
Guillaume Gomez
2072e11730
Rollup merge of #80591 - lcnr:incomplete-features, r=RalfJung
remove allow(incomplete_features) from std

cc https://github.com/rust-lang/rust/pull/80349#issuecomment-753357123

> Now I am somewhat concerned that the standard library uses some of these features...

I think it is theoretically ok to use incomplete features in the standard library or the compiler if we know that there is an already working subset and we explicitly document what we have to be careful about. Though at that point it is probably better to try and split the incomplete feature into two separate ones, similar to `min_specialization`.

Will be interesting once `feature(const_evaluatable_checked)` works well enough to imo be used in the compiler but not yet well enough to be removed from `INCOMPLETE_FEATURES`.

r? `@RalfJung`
2021-01-03 17:09:08 +01:00
bors
bcd6975079 Auto merge of #80590 - camelid:bool-never-docs, r=nagisa
Update `bool` and `!` docs
2021-01-03 12:21:12 +00:00
bors
05dfaba442 Auto merge of #79827 - tmiasko:size-align, r=kennytm
Describe why `size_align` have not been inlined so far

although it is used only in one place.
2021-01-03 03:43:29 +00:00
bors
f6b6d5cf64 Auto merge of #79870 - sharnoff:smart-pointer-Any-type_id, r=shepmaster
Add docs note about `Any::type_id` on smart pointers

Fixes #79868.

There's an issue I've run into a couple times while using values of type `Box<dyn Any>` - essentially, calling `value.type_id()` doesn't dereference to the trait object, but uses the implementation of `Any` for `Box<dyn Any>`, giving us the `TypeId` of the container instead of the object inside it.

I couldn't find any notes about this in the documentation and - while it could be inferred from existing knowledge of Rust and the blanket implemenation of `Any` - I think it'd be nice to have a note about it in the documentation for the `any` module.

Anyways, here's a first draft of a section about it. I'm happy to revise wording :)
2021-01-02 04:12:48 +00:00
Camelid
4e767596e2
always demands -> requires 2021-01-01 18:55:01 -08:00
bors
0876f59b97 Auto merge of #77832 - camelid:remove-manual-link-resolves, r=jyn514
Remove many unnecessary manual link resolves from library

Now that #76934 has merged, we can remove a lot of these! E.g, this is
no longer necessary:

    [`Vec<T>`]: Vec

cc `@jyn514`
2021-01-02 01:31:03 +00:00
Bastian Kauschke
6cf47ff4f0 remove incomplete features from std 2021-01-01 19:57:10 +01:00
Camelid
4af11126a8
Update bool and ! docs 2021-01-01 10:09:56 -08:00
bors
18d27b2c94 Auto merge of #80310 - Manishearth:box-try-alloc, r=kennytm
Add fallible Box, Arc, and Rc allocator APIs

cc https://github.com/rust-lang/rust/issues/48043

It was suggested in https://github.com/rust-lang/rust/issues/48043#issuecomment-748008486 that `Box::try_*` follows the spirit of RFC 2116. This PR is an attempt to add the relevant APIs, tied to the same feature gate. Happy to make any changes or turn this into an RFC if necessary.

cc `@rust-lang/wg-allocators`
2021-01-01 10:29:43 +00:00
Camelid
0506789014 Remove many unnecessary manual link resolves from library
Now that #76934 has merged, we can remove a lot of these! E.g, this is
no longer necessary:

    [`Vec<T>`]: Vec
2020-12-31 11:54:32 -08:00
Manish Goregaokar
375e7c5864 More inline, doc fixes 2020-12-31 16:49:44 +00:00
Manish Goregaokar
8f3cb7d75d Make [A]Rc::allocate_for_layout() use try_allocate_for_layout() 2020-12-31 16:36:28 +00:00
bors
b33e234155 Auto merge of #79895 - Kerollmops:slice-group-by, r=m-ou-se
The return of the GroupBy and GroupByMut iterators on slice

According to https://github.com/rust-lang/rfcs/pull/2477#issuecomment-742034372, I am opening this PR again, this time I implemented it in safe Rust only, it is therefore much easier to read and is completely safe.

This PR proposes to add two new methods to the slice, the `group_by` and `group_by_mut`. These two methods provide a way to iterate over non-overlapping sub-slices of a base slice that are separated by the predicate given by the user (e.g. `Partial::eq`, `|a, b| a.abs() < b.abs()`).

```rust
let slice = &[1, 1, 1, 3, 3, 2, 2, 2];

let mut iter = slice.group_by(|a, b| a == b);
assert_eq!(iter.next(), Some(&[1, 1, 1][..]));
assert_eq!(iter.next(), Some(&[3, 3][..]));
assert_eq!(iter.next(), Some(&[2, 2, 2][..]));
assert_eq!(iter.next(), None);
```

[An RFC](https://github.com/rust-lang/rfcs/pull/2477) was open 2 years ago but wasn't necessary.
2020-12-31 12:00:43 +00:00
Clément Renault
8b53be6604
Replace the tracking issue for the slice_group_by feature 2020-12-31 12:13:03 +01:00
Clément Renault
a2d55d70c4
Add an extra example to the two methods 2020-12-31 11:57:40 +01:00
Manish Goregaokar
589aa8e29c Reuse Box::try_new_*_in() in Box::new_*_in() 2020-12-31 08:43:30 +00:00
Manish Goregaokar
bb15fa1da0 Add fallible Arc APIs (Arc::try_new_*) 2020-12-31 08:31:55 +00:00
Manish Goregaokar
973fa8e30e Add fallible Rc APIs (Rc::try_new_*) 2020-12-31 08:15:38 +00:00
Manish Goregaokar
dd2c6c318b Add fallible box APIs (Box::try_new_*) 2020-12-31 08:14:38 +00:00
Manish Goregaokar
d116f48788 Add fallible box allocator APIs (Box::try_new_*_in()) 2020-12-31 08:14:38 +00:00
bors
8b002d5c34 Auto merge of #79150 - m-ou-se:bye-bye-doc-comment-hack, r=jyn514
Remove all doc_comment!{} hacks by using #[doc = expr] where needed.

This replaces about 200 cases of

`````rust
        doc_comment! {
            concat!("The smallest value that can be represented by this integer type.

# Examples

Basic usage:

```
", $Feature, "assert_eq!(", stringify!($SelfT), "::MIN, ", stringify!($Min), ");",
$EndFeature, "
```"),
            #[stable(feature = "assoc_int_consts", since = "1.43.0")]
            pub const MIN: Self = !0 ^ ((!0 as $UnsignedT) >> 1) as Self;
        }
`````
by
```rust
        /// The smallest value that can be represented by this integer type.
        ///
        /// # Examples
        ///
        /// Basic usage:
        ///
        /// ```
        #[doc = concat!("assert_eq!(", stringify!($SelfT), "::MIN, ", stringify!($Min), ");")]
        /// ```
        #[stable(feature = "assoc_int_consts", since = "1.43.0")]
        pub const MIN: Self = !0 ^ ((!0 as $UnsignedT) >> 1) as Self;
```

---

**Note:** For a usable diff, make sure to enable 'ignore whitspace': https://github.com/rust-lang/rust/pull/79150/files?diff=unified&w=1
2020-12-31 06:14:41 +00:00
Mara Bos
4614cdd230 Fix typos. 2020-12-30 23:23:02 +01:00
Mara Bos
5694b8e471 Don't use doc_comment!{} hack in nonzero_leading_trailing_zeros!{}. 2020-12-30 22:49:08 +01:00
Mara Bos
27b81bf97a Remove all doc_comment!{} hacks by using #[doc = expr] where needed. 2020-12-30 22:49:08 +01:00
bors
9775ffef2a Auto merge of #80530 - m-ou-se:rollup-zit69ko, r=m-ou-se
Rollup of 9 pull requests

Successful merges:

 - #78934 (refactor: removing library/alloc/src/vec/mod.rs ignore-tidy-filelength)
 - #79479 (Add `Iterator::intersperse`)
 - #80128 (Edit rustc_ast::ast::FieldPat docs)
 - #80424 (Don't give an error when creating a file for the first time)
 - #80458 (Some Promotion Refactoring)
 - #80488 (Do not create dangling &T in Weak<T>::drop)
 - #80491 (Miri: make size/align_of_val work for dangling raw ptrs)
 - #80495 (Rename kw::Invalid -> kw::Empty)
 - #80513 (Add regression test for #80062)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2020-12-30 21:25:15 +00:00
Mara Bos
067f1b7030
Rollup merge of #80491 - RalfJung:dangling-of-val, r=oli-obk
Miri: make size/align_of_val work for dangling raw ptrs

This is needed for https://github.com/rust-lang/rust/issues/80365#issuecomment-752128105.

r? `@oli-obk`
2020-12-30 20:56:56 +00:00
Mara Bos
3d93dfdf6e
Rollup merge of #80488 - CAD97:drop-weak-without-reference, r=m-ou-se
Do not create dangling &T in Weak<T>::drop

Since at this point all strong pointers have been dropped, the wrapped `T` has also been dropped. As such, creating a `&T` to the dropped place is negligent at best (language UB at worst). Since we have `Layout::for_value_raw` now, use that instead of `Layout::for_value` to avoid creating the `&T`.

This does have implications for custom (potentially thin) DSTs, though much less severe than those discussed in #80407. Specifically, one of two things has to be true:

- It has to be possible to use a `*const T` to a dropped (potentially custom, potentially thin) unsized tailed object to determine the layout (size/align) of the object. This is what is currently implemented (though with `&T` instead of `&T`). The validity of reading some location after it has been dropped is an open question IIUC (https://github.com/rust-lang/unsafe-code-guidelines/issues/188) (except when the whole type is `Copy`, per `drop_in_place`'s docs).
  In this design, custom DSTs would get a `*mut T` and use that to return layout, and must be able to do so while in the "zombie" (post-drop, pre-free) state.
- `RcBox`/`ArcInner` compute and store layout eagerly, so that they don't have to ask the type for its layout after dropping it.

Importantly, this is already true today, as you can construct `Rc<DST>`, create a `Weak<DST>`, and drop the `Rc` before the `Weak`. This PR is a strict improvement over the status quo, and the above question about potentially thin DSTs will need to be resolved by any custom DST proposal.
2020-12-30 20:56:54 +00:00
Mara Bos
9cf24388d1
Rollup merge of #79479 - camelid:intersperse, r=m-ou-se
Add `Iterator::intersperse`

This is a rebase of #75784. I'm hoping to push this past the finish line!

cc `@jonas-schievink`
2020-12-30 20:56:47 +00:00