Commit graph

1069 commits

Author SHA1 Message Date
Mara Bos
9c75ee6b3b
Rollup merge of #80991 - calebsander:fix/fmt-link, r=m-ou-se
Fix formatting specifiers doc links

d36e3e23a8 seems to have inadvertently changed many of these links to point to `core::fmt` instead of `std::fmt`. The information about formatting specifiers is only documented in [`std::fmt`](https://doc.rust-lang.org/std/fmt/); [`core::fmt`](https://doc.rust-lang.org/core/fmt/) is empty. 3baf6a4a74 seems to have already fixed a couple of these links to point back to `std::fmt`.
2021-01-14 18:00:31 +00:00
Mara Bos
c504e89bc7
Rollup merge of #80985 - ijackson:slice-strip-fix, r=jyn514
Fix stabilisation version of slice_strip

See https://github.com/rust-lang/rust/pull/77853#pullrequestreview-564921079

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2021-01-14 18:00:27 +00:00
Mara Bos
d5e55cee99
Rollup merge of #80980 - trevarj:patch-1, r=nagisa
Fixed incorrect doc comment

">" is right alignment, not left
2021-01-14 18:00:22 +00:00
Mara Bos
7855a730b9
Rollup merge of #80966 - KodrAus:deprecate/spin_loop_hint, r=m-ou-se
Deprecate atomic::spin_loop_hint in favour of hint::spin_loop

For https://github.com/rust-lang/rust/issues/55002

We wanted to leave `atomic::spin_loop_hint` alone when stabilizing `hint::spin_loop` so folks had some time to migrate. This now deprecates `atomic_spin_loop_hint`.
2021-01-14 18:00:14 +00:00
Mara Bos
446ed77124
Rollup merge of #80567 - lukaslueg:intersperse_with, r=m-ou-se
Add Iterator::intersperse_with

This is a follow-up to #79479, tracking in #79524, as discussed https://github.com/rust-lang/rust/pull/79479#issuecomment-752671731.

~~Note that I had to manually implement `Clone` and `Debug` because `derive` insists on placing a `Clone`-bound on the struct-definition, which is too narrow. There is a long-standing issue # for this somewhere around here :-)~~

Also, note that I refactored the guts of `Intersperse` into private functions and re-used them in `IntersperseWith`, so I also went light on duplicating all the tests.

If this is suitable to be merged, the tracking issue should be updated, since it only mentions `intersperse`.

Happy New Year!

r? ``@m-ou-se``
2021-01-14 18:00:06 +00:00
Mara Bos
3308b43ba1
Rollup merge of #80444 - glittershark:bound-as-ref, r=dtolnay
Add as_ref and as_mut methods for Bound

Add as_ref and as_mut method for std::ops::range::Bound, patterned off
of the methods of the same name on Option.

I'm not quite sure what the process is for introducing new feature gates (this is my first contribution) so I've left these ungated, but happy to do whatever is necessary to gate them.
2021-01-14 18:00:02 +00:00
Philippe Laflamme
64d695b753
Adds tests to ensure some base op traits exist.
These tests invoke the various op traits using all accepted types they
are implemented for as well as for references to those types.

This fixes #49660 and ensures the following implementations exist:

* `Add`, `Sub`, `Mul`, `Div`, `Rem`
  * `T op T`, `T op &T`, `&T op T` and `&T op &T`
  * for all integer and floating point types
* `AddAssign`, `SubAssign`, `MulAssign`, `DivAssign`, `RemAssign`
  * `&mut T op T` and `&mut T op &T`
  * for all integer and floating point types
* `Neg`
  * `op T` and `op &T`
  * for all signed integer and floating point types
* `Not`
  * `op T` and `op &T`
  * for `bool`
* `BitAnd`, `BitOr`, `BitXor`
  * `T op T`, `T op &T`, `&T op T` and `&T op &T`
  * for all integer types and bool
* `BitAndAssign`, `BitOrAssign`, `BitXorAssign`
  * `&mut T op T` and `&mut T op &T`
  * for all integer types and bool
* `Shl`, `Shr`
  * `L op R`, `L op &R`, `&L op R` and `&L op &R`
  * for all pairs of integer types
* `ShlAssign`, `ShrAssign`
  * `&mut L op R`, `&mut L op &R`
  * for all pairs of integer types
2021-01-13 23:14:00 -05:00
Philippe Laflamme
8ddad18283
Avoid ident concatenation in macro.
AFAIK it isn't currently possible to do this. It is also more in line with other tests in the surrounding modules.
2021-01-13 23:13:55 -05:00
Philippe Laflamme
872dc60ed2
Fix missing mod declaration for Wrapping tests. 2021-01-13 23:13:49 -05:00
Griffin Smith
eb72dc5d40 Add as_ref and as_mut methods for Bound
Add as_ref and as_mut method for std::ops::range::Bound, patterned off
of the methods of the same name on Option.
2021-01-13 21:16:26 -05:00
bors
a62a76047e Auto merge of #77524 - Patryk27:fixes/66228, r=estebank
Rework diagnostics for wrong number of generic args (fixes #66228 and #71924)

This PR reworks the `wrong number of {} arguments` message, so that it provides more details and contextual hints.
2021-01-13 20:35:58 +00:00
Lukas Lueg
9b2f085110 Improve Iterator::intersperse_ docs 2021-01-13 21:07:59 +01:00
Caleb Sander
391b4cc378 Fix formatting specifiers doc link
Was incorrectly linked to `core::fmt`, which is empty, in d36e3e23a8
Some of the links were fixed already in 3baf6a4a74
2021-01-13 15:05:39 -05:00
Lukas Lueg
95289889fe Add doc intralinks 2021-01-13 19:47:41 +01:00
Ian Jackson
b59fa3d634 Fix stabilisation version of slice_strip
See https://github.com/rust-lang/rust/pull/77853#pullrequestreview-564921079

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2021-01-13 14:21:18 +00:00
Mark Rousskov
8a3edb1d66 Update tests for extern block linting 2021-01-13 07:49:16 -05:00
trevor arjeski
697b20ff08
Fixed incorrect doc comment
">" is right alignment, not left
2021-01-13 13:49:46 +03:00
bors
9f3998b4aa Auto merge of #77858 - ijackson:split-inclusive, r=KodrAus
Stabilize split_inclusive

### Contents of this MR

This stabilises:

 * `slice::split_inclusive`
 * `slice::split_inclusive_mut`
 * `str::split_inclusive`

Closes #72360.

### A possible concern

The proliferation of `split_*` methods is not particularly pretty.  The existence of `split_inclusive` seems to invite the addition of `rsplit_inclusive`, `splitn_inclusive`, etc.  We could instead have a more general API, along these kinds of lines maybe:
```
   pub fn split_generic('a,P,H>(&'a self, pat: P, how: H) -> ...
       where P: Pattern
       where H: SplitHow;

   pub fn split_generic_mut('a,P,H>(&'a mut self, pat: P, how: H) -> ...
       where P: Pattern
       where H: SplitHow;

   trait SplitHow {
       fn reverse(&self) -> bool;
       fn inclusive -> bool;
       fn limit(&self) -> Option<usize>;
   }

   pub struct SplitFwd;
   ...
   pub struct SplitRevInclN(pub usize);
```
But maybe that is worse.

### Let us defer that? ###

This seems like a can of worms.  I think we can defer opening it now; if and when we have something more general, these two methods can become convenience aliases.  But I thought I would mention it so the lang API team can consider it and have an opinion.
2021-01-13 07:38:58 +00:00
Ashley Mannix
d65cb6ebce deprecate atomic::spin_loop_hint in favour of hint::spin_loop 2021-01-13 16:30:29 +10:00
Ashley Mannix
5584224fda
bump split_inclusive stabilization to 1.51.0 2021-01-13 13:51:37 +10:00
Ashley Mannix
e4a2f33360
bump split_inclusive stabilization to 1.51.0 2021-01-13 13:50:39 +10:00
Ashley Mannix
0620514094
bump split_inclusive stabilization to 1.51.0 2021-01-13 13:49:34 +10:00
Ashley Mannix
bd2c072b9b
bump split_inclusive stabilization to 1.51.0 2021-01-13 13:48:36 +10:00
Yuki Okushi
961a4386cd
Rollup merge of #80917 - epilys:patch-1, r=jyn514
core/slice: remove doc comment about scoped borrow

There's no need to scope the borrow in the doc example due to NLL.

[Playground link](https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&code=fn%20main()%20%7B%0A%20%20%20%20let%20mut%20v%20%3D%20%5B1%2C%200%2C%203%2C%200%2C%205%2C%206%5D%3B%0A%0A%20%20%20%20let%20(left%2C%20right)%20%3D%20v.split_at_mut(2)%3B%0A%20%20%20%20assert_eq!(left%2C%20%5B1%2C%200%5D)%3B%0A%20%20%20%20assert_eq!(right%2C%20%5B3%2C%200%2C%205%2C%206%5D)%3B%0A%20%20%20%20left%5B1%5D%20%3D%202%3B%0A%20%20%20%20right%5B1%5D%20%3D%204%3B%0A%0A%20%20%20%20assert_eq!(v%2C%20%5B1%2C%202%2C%203%2C%204%2C%205%2C%206%5D)%3B%0A%7D%0A) where changed code compiles
2021-01-12 16:13:31 +09:00
Yuki Okushi
babfdafb10
Rollup merge of #80600 - CoffeeBlend:maybe_uninit_array_assume_init, r=dtolnay
Add `MaybeUninit` method `array_assume_init`

When initialising an array element-by-element, the conversion to the initialised array is done through `mem::transmute`, which is both ugly and does not work with const generics (see #61956). This PR proposes the associated method `array_assume_init`, matching the style of `slice_assume_init_*`:

```rust
unsafe fn array_assume_init<T, const N: usize>(array: [MaybeUninit<T>; N]) -> [T; N];
```

Example:
```rust
let mut array: [MaybeUninit<i32>; 3] = MaybeUninit::uninit_array();
array[0].write(0);
array[1].write(1);
array[2].write(2);

// SAFETY: Now safe as we initialised all elements
let array: [i32; 3] = unsafe {
     MaybeUninit::array_assume_init(array)
};
```

Things I'm unsure about:
* Should this be a method of array instead?
* Should the function be const?
2021-01-12 16:13:24 +09:00
CoffeeBlend
985071b08f
Fix implementation 2021-01-12 01:39:10 +01:00
Yuki Okushi
4646eac08e
Rollup merge of #80864 - ericseppanen:master, r=jyn514
std/core docs: fix wrong link in PartialEq

PartialEq doc was attempting to link to ``[`Eq`]`` but instead we got a link to `` `eq` ``. Disambiguate with `trait@Eq`.

You can see the bad link [here](https://doc.rust-lang.org/std/cmp/trait.PartialEq.html) (Second sentence, "floating point types implement PartialEq but not Eq").
2021-01-12 07:59:11 +09:00
CoffeeBlend
5d65b7e055
Simplify array_assume_init 2021-01-11 23:32:03 +01:00
Manos Pitsidianakis
0be9d39336
core/slice: remove doc comment about scoped borrow
There's no need to scope the borrow in the doc example due to NLL.

Playground link where changed code compiles
https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&code=fn%20main()%20%7B%0A%20%20%20%20let%20mut%20v%20%3D%20%5B1%2C%200%2C%203%2C%200%2C%205%2C%206%5D%3B%0A%0A%20%20%20%20let%20(left%2C%20right)%20%3D%20v.split_at_mut(2)%3B%0A%20%20%20%20assert_eq!(left%2C%20%5B1%2C%200%5D)%3B%0A%20%20%20%20assert_eq!(right%2C%20%5B3%2C%200%2C%205%2C%206%5D)%3B%0A%20%20%20%20left%5B1%5D%20%3D%202%3B%0A%20%20%20%20right%5B1%5D%20%3D%204%3B%0A%0A%20%20%20%20assert_eq!(v%2C%20%5B1%2C%202%2C%203%2C%204%2C%205%2C%206%5D)%3B%0A%7D%0A
2021-01-11 18:55:35 +02:00
Lukas Kalbertodt
4038042eb0
Add [T; N]::each_ref and [T; N]::each_mut
These methods work very similarly to `Option`'s methods `as_ref` and
`as_mut`. They are useful in several situation, particularly when
calling other array methods (like `map`) on the result. Unfortunately,
we can't easily call them `as_ref` and `as_mut` as that would shadow
those methods on slices, thus being a breaking change (that is likely
to affect a lot of code).
2021-01-11 01:09:22 -08:00
CoffeeBlend
dec8c033a3
Add tracking issue for array_assume_init 2021-01-11 10:07:29 +01:00
Patryk Wychowaniec
d2f8e398f1
Rework diagnostics for wrong number of generic args 2021-01-10 13:07:40 +01:00
Yuki Okushi
5c0f5b69c2
Rollup merge of #79502 - Julian-Wollersberger:from_char_for_u64, r=withoutboats
Implement From<char> for u64 and u128.

With this PR you can write
```
let u = u64::from('👤');
let u = u128::from('👤');
```

Previously, you could already write `as` conversions ([Playground link](https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=cee18febe28e69024357d099f07ca081)):
```
// Lossless conversions
dbg!('👤' as u32);    // Prints 128100
dbg!('👤' as u64);    // Prints 128100
dbg!('👤' as u128);   // Prints 128100

// truncates, thus no `From` impls.
dbg!('👤' as u8);     // Prints 100
dbg!('👤' as u16);    // Prints 62564

// These `From` impls already exist.
dbg!(u32::from('👤'));               // Prints 128100
dbg!(u64::from(u32::from('👤')));    // Prints 128100
```

The idea is from ``@gendx`` who opened [this Internals thread](https://internals.rust-lang.org/t/implement-from-char-for-u64/13454), and ``@withoutboats`` responded that someone should open a PR for it.
Some people mentioned `From<char>` impls for `f32` and `f64`, but that doesn't seem correct to me, so I didn't include them here.

I don't know what the feature should be named. Must it be registered somewhere, like unstable features?

r? ``@withoutboats``
2021-01-10 16:55:53 +09:00
Eric Seppanen
eef95871a4 fix broken link in PartialEq doc
PartialEq doc was attempting to link to [`Eq`] but instead we got a link
to `eq`. Disambiguate with "trait@Eq".
2021-01-09 22:40:48 -08:00
bors
ef589490a7 Auto merge of #80808 - CAD97:patch-3, r=nagisa
Fix typo in Step trait

... I don't know how this major typo happened, whoops 🙃

`@bors` rollup=always
(comment only change)
2021-01-09 13:56:15 +00:00
Julian Wollersberger
e8cb72c503 Update the stabilisation version. 2021-01-09 12:31:30 +01:00
Christopher Durham
02850d3f30
Fix typo in Step trait 2021-01-07 21:29:17 -05:00
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
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
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
Lukas Lueg
7a0ada0427 Remove FIXME-notes 2021-01-07 00:45:47 +01: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