Commit graph

364 commits

Author SHA1 Message Date
Alexis Bourget
6b75e3d11b Move to Arc::clone(&x) over x.clone() in library/core 2020-08-30 22:14:17 +02:00
Sebastian Dröge
8d3cf9237d Improve documentation of slice::get_unchecked() / split_at_unchecked()
Thanks to Ivan Tham, who gave the majority of these suggestions during
their review.
2020-08-30 23:13:47 +03:00
Sebastian Dröge
d08996ac54 Get rid of bounds check in slice::chunks_exact() and related functions during construction
LLVM can't figure out in

    let rem = self.len() % chunk_size;
    let len = self.len() - rem;
    let (fst, snd) = self.split_at(len);

and

    let rem = self.len() % chunk_size;
    let (fst, snd) = self.split_at(rem);

that the index passed to split_at() is smaller than the slice length and
adds a bounds check plus panic for it.

Apart from removing the overhead of the bounds check this also allows
LLVM to optimize code around the ChunksExact iterator better.
2020-08-30 23:13:47 +03:00
Sebastian Dröge
30dc32b10e Add (non-public) slice::split_at_unchecked() and split_at_mut_unchecked()
These are unsafe variants of the non-unchecked functions and don't do
any bounds checking.

For the time being these are not public and only a preparation for the
following commit. Making it public and stabilization can follow later
and be discussed in https://github.com/rust-lang/rust/issues/76014 .
2020-08-30 23:13:46 +03:00
Lukas Kalbertodt
d7afe2a223
Fix tests using FixedSizeArray methods (which are now shadowed) 2020-08-30 21:08:18 +02:00
Lukas Kalbertodt
104a02301c
Add [T; N]::as_[mut_]slice
These methods are like the ones on `std::array::FixedSizeArray`
and in the crate `arraytools`.
2020-08-30 21:08:17 +02:00
CDirkx
5fac991bf6 Add unstable const_ordering feature, and some tests. 2020-08-30 19:40:00 +02:00
Andy Russell
98232ece14
fix broken trait method links 2020-08-30 12:04:43 -04:00
Prabakaran Kumaresshan
523fea4d14 revert Some(Item) link 2020-08-30 19:19:20 +05:30
DPC
b3d7b7bdcb update fixmes 2020-08-30 14:43:52 +02:00
Prabakaran Kumaresshan
7ea4c28af2 add i32::MAX link 2020-08-30 17:07:50 +05:30
Amjad Alsharafi
300a0072a2 Fix intra-doc path resolution problem in library/alloc/src/slice.rs
`alloc::slice` uses `core::slice` functions, documentation are copied
from there and the links as well without resolution. `crate::ptr...`
cannot be resolved in `alloc::slice`, but `ptr` itself is imported in
both `alloc::slice` and `core::slice`, so we used that instead.
2020-08-30 15:22:27 +08:00
Prabakaran Kumaresshan
01d95f241b resolve comments 2020-08-30 05:40:47 +05:30
Prabakaran Kumaresshan
8a92718b64 Switch to intra-doc links in core/src/{convert,iter}/mod.rs 2020-08-30 05:40:47 +05:30
Dylan DPC
11193ca202
Rollup merge of #76029 - denisvasilik:intra-doc-links-core-atomic, r=kennytm
Move to intra-doc links for library/core/src/sync/atomic.rs

Helps with #75080.

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

Known issues:

* Link from core to std:

    [`Arc`]
	[`std:🧵:yield_now`]
	[`std:🧵:sleep`]
	[`std::sync::Mutex`]
2020-08-30 01:43:59 +02:00
Dylan DPC
9225aabef4
Rollup merge of #75917 - poliorcetics:intra-doc-core-nonnull, r=jyn514
Move to intra doc links for core::ptr::non_null

Helps with #75080.

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

r? @jyn514
2020-08-30 01:43:50 +02:00
Dylan DPC
d17db64b8d
Rollup merge of #75852 - camelid:patch-3, r=jyn514
Switch to intra-doc links in `core::hash`

Part of #75080.

@rustbot modify labels: A-intra-doc-links T-doc T-rustdoc
2020-08-30 01:43:39 +02:00
Hanif Bin Ariffin
cc3b2f9e1d Add more examples to lexicographic cmp on Iterators.
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 T.
Which is only possible because of the first rule.
2020-08-29 19:01:41 -04:00
DPC
ea800d529a fix tests 2020-08-29 17:25:14 +02:00
DPC
5e208efaa8 rename get_{ref, mut} to assume_init_{ref,mut} in Maybeuninit 2020-08-29 02:13:02 +02:00
Denis Vasilik
c7571e6040 Use intra-doc links for bool 2020-08-28 17:30:05 +02:00
Denis Vasilik
4bbed52320 Use intra-doc links 2020-08-28 17:24:47 +02:00
Pietro Albini
0f1ffa85d1
Rollup merge of #75967 - aticu:blackbox_typo, r=Dylan-DPC
Fix typo in `std::hint::black_box` docs
2020-08-28 10:24:04 +02:00
Pietro Albini
e027b57e40
Rollup merge of #75955 - camelid:intra-doc-links-for-future-and-dec2flt, r=jyn514
Use intra-doc links in `core::future::future` and `core::num::dec2flt`

Part of #75080.

@rustbot modify labels: A-intra-doc-links T-doc
2020-08-28 10:24:02 +02:00
Pietro Albini
be1b304ea4
Rollup merge of #75943 - elichai:2020-align_offset-docs, r=RalfJung
Fix potential UB in align_offset doc examples

Currently it takes a pointer only to the first element in the array, this changes the code to take a pointer to the whole array.
miri can't catch this right now because it later calls `x.len()` which re-tags the pointer for the whole array.

https://github.com/rust-lang/miri/issues/1526#issuecomment-680897144
2020-08-28 10:23:59 +02:00
Pietro Albini
521b2054b6
Rollup merge of #75927 - camelid:intra-doc-links-for-core-macros, r=jyn514
Use intra-doc links in `core::macros`

Part of #75080.

Also cleaned up some things.

@rustbot modify labels: A-intra-doc-links T-doc T-rustdoc
2020-08-28 10:23:55 +02:00
Amjad Alsharafi
6aae4a2fe6 Used intra-doc links for ptr#safety occurrences 2020-08-28 11:52:04 +08:00
Amjad Alsharafi
a04e12002a Used intra-doc links for NonNull::dangling() occurrences 2020-08-28 11:52:04 +08:00
Amjad Alsharafi
8e33137159 Fixes intra-doc same scope links 2020-08-28 11:52:03 +08:00
Amjad Alsharafi
91e4aaa736 Use intra-doc links for core/src/slice.mod.rs
- most are using primitive types links, which cannot be used with intra
  links at the moment
- also `std` cannot be referenced in any link
2020-08-28 11:52:03 +08:00
Camelid
39cd184606
Remove unnecessary intra-doc link
Co-authored-by: Joshua Nelson <joshua@yottadb.com>
2020-08-27 19:42:23 -07:00
Camelid
f0722c06a7 Switch to intra-doc links in core::hash 2020-08-27 12:09:50 -07:00
Camelid
707298d52c Use intra-doc links in core::num::dec2flt 2020-08-27 11:40:29 -07:00
Camelid
c933d697d8 Use intra-doc links in core::future::future 2020-08-27 11:40:28 -07:00
bors
118860a7e7 Auto merge of #75947 - pietroalbini:bootstrap-update, r=Mark-Simulacrum
Bump version to 1.48 and update cfg(bootstrap)s

r? @Mark-Simulacrum
2020-08-27 09:24:51 +00:00
aticu
39f5ebcd74 Fix typo in std::hint::black_box docs 2020-08-27 01:16:18 +02:00
Dylan DPC
a79f9af290
Rollup merge of #75780 - matklad:unconfuseunpindocs, r=KodrAus
Unconfuse Unpin docs a bit

* Don't say that Unpin is used to prevent moves, because it is used
  to *allow* moves
* Be more precise about kindedness of things, it is
  `Pin<Pointer<Data>>`, rather than just `Pin<Pointer>`.
2020-08-27 01:14:06 +02:00
bors
48717b6f3c Auto merge of #75912 - scottmcm:manuallydrop-vs-forget, r=Mark-Simulacrum
Suggest `mem::forget` if `mem::ManuallyDrop::new` isn't used

I think this communicates the intent more idiomatically, and is shorter anyway.

Inspired because [it came up on URLO](https://users.rust-lang.org/t/validity-of-memory-area-after-std-forget/47730/7?u=scottmcm), and it turns out that std had done it too in one spot:
![image](https://user-images.githubusercontent.com/18526288/91203819-e19f2980-e6f2-11ea-9112-835f3b22ce05.png)
2020-08-26 18:40:51 +00:00
Elichai Turkel
0cca5978a4
Fix potential UB in align_offset docs 2020-08-26 17:02:24 +03:00
bors
ffd59bf9c6 Auto merge of #75687 - TimDiekmann:realloc-align, r=Amanieu
Allow reallocation to different alignment in `AllocRef`

The allocator-wg [has decided](https://github.com/rust-lang/wg-allocators/issues/5#issuecomment-672591112) to support reallocating to a different alignment in `AllocRef`. For more details please see the linked issue.

r? @Amanieu

closes https://github.com/rust-lang/wg-allocators/issues/5
2020-08-26 10:44:28 +00:00
Pietro Albini
3e16d4af7f
apply bootstrap cfgs 2020-08-26 10:17:31 +02:00
Camelid
511ee052a0 Use intra-doc links in core::macros
Also cleaned up some things and added a few more links.
2020-08-25 18:45:20 -07:00
Alexis Bourget
28798132aa Move to intra doc links for core::ptr::non_null 2020-08-25 22:46:12 +02:00
Yoshua Wuyts
688f4471fd Stabilize future readiness fns 2020-08-25 19:08:43 +02:00
Scott McMurray
f3024073f9 Suggest mem::forget if mem::ManuallyDrop::new isn't used
I think this communicates the intent better, and is shorter anyway.
2020-08-25 09:40:53 -07:00
Scott McMurray
c20ad72323 Stabilize Range[Inclusive]::is_empty
I would like to propose these two simple methods for stabilization:
- Knowing that a range is exhaused isn't otherwise trivial
- Clippy would like to suggest them, but had to do extra work to disable that path <https://github.com/rust-lang/rust-clippy/issues/3807> because they're unstable
- These work on `PartialOrd`, consistently with now-stable `contains`, and are thus more general than iterator-based approaches that need `Step`
- They've been unchanged for some time, and have picked up uses in the compiler
- Stabilizing them doesn't block any future iterator-based is_empty plans, as the inherent ones are preferred in name resolution
2020-08-24 13:20:25 -07:00
Aleksey Kladov
daa6620c95 Unconfuse Unpin docs a bit
* Don't say that Unpin is used to prevent moves, because it is used
  to *allow* moves
* Be more precise about kindedness of things, it is
  `Pin<Pointer<Data>>`, rather than just `Pin<Pointer>`.
2020-08-24 13:56:57 +02:00
bors
aa7010df90 Auto merge of #75815 - jyn514:ambiguous-primitives, r=guillaumegomez
Report an ambiguity if both modules and primitives are in scope for intra-doc links

Closes https://github.com/rust-lang/rust/issues/75381

- Add a new `prim@` disambiguator, since both modules and primitives are in the same namespace
- Refactor `report_ambiguity` into a closure

Additionally, I noticed that rustdoc would previously allow `[struct@char]` if `char` resolved to a primitive (not if it had a DefId). I fixed that and added a test case.

I also need to update libstd to use `prim@char` instead of `type@char`. If possible I would also like to refactor `ambiguity_error` to use `Disambiguator` instead of its own hand-rolled match - that ran into issues with `prim@` (I updated one and not the other) and it would be better for them to be in sync.
2020-08-24 10:29:29 +00:00
bors
d795eb4b10 Auto merge of #75855 - jyn514:no-cfg-doc, r=ollie27
Use allow(unused_imports) instead of cfg(doc) for imports used only for intra-doc links

This prevents links from breaking when items are re-exported in a
different crate and the original isn't being documented.

Spotted in https://github.com/rust-lang/rust/pull/75832#discussion_r475275837 (thanks ollie!)

r? @ollie27
2020-08-24 06:05:00 +00:00
Joshua Nelson
5aac94a1f6 Don't import atomics unless supported by the platform 2020-08-23 23:11:47 -04:00
Yuki Okushi
648ad7c57e
Rollup merge of #75851 - camelid:patch-2, r=jyn514
Switch to intra-doc links in `core::array`

Part of #75080.

@rustbot modify labels: A-intra-doc-links T-doc T-rustdoc
2020-08-24 11:48:52 +09:00
Yuki Okushi
25a677ccef
Rollup merge of #75831 - lzutao:https, r=Dylan-DPC
doc: Prefer https link for wikipedia URLs

A tiny changes.
2020-08-24 11:48:47 +09:00
Yuki Okushi
427e969c43
Rollup merge of #75826 - ayushmishra2005:misleading_documentation_for_derived_Ord_PartialOrd, r=KodrAus
Corrected Misleading documentation for derived Ord/PartialOrd implementation

Corrected Misleading documentation for derived Ord/PartialOrd implementation

Fixes #75620
2020-08-24 11:48:46 +09:00
Yuki Okushi
b8e456f2db
Rollup merge of #75825 - jrheard:patch-1, r=steveklabnik
Fix typo in documentation of i32 wrapping_abs()

Hi!

I was reading through the std library docs and noticed that this section flowed a bit oddly; comparing it against https://doc.rust-lang.org/std/primitive.i32.html#method.wrapping_div and https://doc.rust-lang.org/std/primitive.i32.html#method.wrapping_neg , I noticed that those two pieces of documentation used a semicolon here.

This is my first time submitting a PR to this repo. Am I doing this right? Are tiny typo-fix PRs like this worth submitting, or are they not a good use of time?

Thank you!
2020-08-24 11:48:44 +09:00
Yuki Okushi
50bdcc2f2e
Rollup merge of #75819 - LeSeulArtichaut:core-intra-docs-2, r=jyn514
Use intra-doc-links in `core::{char, macros, fmt}`

Helps with #75080.
r? @jyn514
2020-08-24 11:48:41 +09:00
Joshua Nelson
556fd86524 Disambiguate char -> prim@char for core
This also changes human intuition -> intuition. 'human intuition' sounds
vaguely menacing.
2020-08-23 22:40:20 -04:00
Joshua Nelson
602dd145a3 Use allow(unused_imports) instead of cfg(doc)
This prevents links from breaking when items are re-exported in a
different crate and the original isn't being documented.
2020-08-23 18:45:57 -04:00
LeSeulArtichaut
d36e3e23a8 Use intra-doc-links in core::{char, macros, fmt} 2020-08-24 00:13:23 +02:00
Camelid
04e8237c6d
Switch to intra-doc links in core::array 2020-08-23 14:42:21 -07:00
bors
0ec94594dd Auto merge of #72449 - ecstatic-morse:const-float-bitcast, r=RalfJung
Const floating point bitcasts and classification

Makes the `f32` and `f64` methods described in #72447 and #72505 unstably const.

r? @RalfJung
2020-08-23 19:14:55 +00:00
bors
9d606d939a Auto merge of #74238 - RalfJung:offset_from, r=oli-obk
stabilize ptr_offset_from

This stabilizes ptr::offset_from, and closes https://github.com/rust-lang/rust/issues/41079. It also removes the deprecated `wrapping_offset_from`. This function was deprecated 19 days ago and was never stable; given an FCP of 10 days and some waiting time until FCP starts, that leaves at least a month between deprecation and removal which I think is fine for a nightly-only API.

Regarding the open questions in https://github.com/rust-lang/rust/issues/41079:
* Should offset_from abort instead of panic on ZSTs? -- As far as I know, there is no precedent for such aborts. We could, however, declare this UB. Given that the size is always known statically and the check thus rather cheap, UB seems excessive.
* Should there be more methods like this with different restrictions (to allow nuw/nsw, perhaps) or that return usize (like how isize-taking offset is more conveniently done with usize-taking add these days)? -- No reason to block stabilization on that, we can always add such methods later.

Also nominating the lang team because this exposes an intrinsic.

The stabilized method is best described [by its doc-comment](56d4b2d69a/src/libcore/ptr/const_ptr.rs (L227)). The documentation forgot to mention the requirement that both pointers must "have the same provenance", aka "be derived from pointers to the same allocation", which I am adding in this PR. This is a precondition that [Miri already implements](https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=a3b9d0a07a01321f5202cd99e9613480) and that, should LLVM ever obtain a `psub` operation to subtract pointers, will likely be required for that operation (following the semantics in [this paper](https://people.mpi-sws.org/~jung/twinsem/twinsem.pdf)).
2020-08-23 14:50:15 +00:00
Ralf Jung
4129e0757a bump stable version
Co-authored-by: Josh Stone <cuviper@gmail.com>
2020-08-23 16:12:39 +02:00
Ayush Kumar Mishra
18f47d81da Misleading documentation for derived Ord/PartialOrd implementation for enums #75620 2020-08-23 15:56:01 +05:30
Lzu Tao
2c995d29f7 Prefer https link for wikipedia URLs 2020-08-23 10:02:42 +00:00
JR Heard
69d3334adf
Fix typo in documentation of i32 wrapping_abs() 2020-08-22 22:21:03 -07:00
LeSeulArtichaut
c8a372ecff Use intra-doc-links in core::{raw, ffi, pin} 2020-08-22 22:25:27 +02:00
Dylan MacKenzie
23e08e223b Add #![feature(const_float_classify)] for f64::classify and friends 2020-08-22 12:28:31 -07:00
Dylan MacKenzie
3cd450ec5d Add #![feature(const_float_bits_conv)] for f64::to_bits and friends 2020-08-22 12:28:31 -07:00
bors
527a685e40 Auto merge of #75783 - denisvasilik:intra-doc-links-core-alloc, r=jyn514
Move to intra-doc links for library/core/src/alloc/{layout, global, mod}.rs

Helps with #75080. The files already contained intra-doc links, so there are only minor changes.

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

Known issues:

* [`handle_alloc_error`]: Link from `core` to `alloc` could not be resolved.
* [`slice`]: slice is a primitive type, but could not be resolved; had to use [`crate::slice`] instead.
2020-08-22 13:21:24 +00:00
Ralf Jung
9a12d9a243 fix dead links to wrapping_offset_from 2020-08-22 15:07:34 +02:00
Ralf Jung
4f92f0d31b remove feature gate from tests 2020-08-22 15:07:32 +02:00
Ralf Jung
0e4f335e63 stabilize ptr_offset_from 2020-08-22 14:37:10 +02:00
Ralf Jung
7ad4369ba6 remove deprecated wrapping_offset_from 2020-08-22 14:37:08 +02:00
Ralf Jung
1241f1927e offset_from: also document same-provenance requirement 2020-08-22 14:37:06 +02:00
Denis Vasilik
2500b6df14 Link to primitive instead of module 2020-08-22 12:16:03 +02:00
Dylan DPC
13dfa9c874
Rollup merge of #75787 - LeSeulArtichaut:core-intra-doc, r=jyn514
Use intra-doc-links in `core::ops::*`

Helps with #75080.
r? @jyn514
2020-08-22 02:14:57 +02:00
Dylan DPC
2ea63794a4
Rollup merge of #75782 - GuillaumeGomez:more-links, r=jyn514
Convert core/src/str/pattern.rs to Intra-doc links

Part of #75080.
2020-08-22 02:14:56 +02:00
Dylan DPC
8af33add1a
Rollup merge of #75705 - denisvasilik:intra-doc-links-intrinsics, r=jyn514
Move to intra-doc links for /library/core/src/intrinsics.rs

Helps with #75080.

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

Known issues:

* The following f32 and f64 primitive methods cannot be resolved:

    f32/f64::powi
    f32/f64::sqrt
    f32/f64::sin
    f32/f64::cos
    f32/f64::powf
    f32/f64::exp
    f32/f64::exp2
    f32/f64::ln
    f32/f64::log2
    f32/f64::log10
    f32/f64::mul_add
    f32/f64::abs
    f32/f64::copysign
    f32/f64::floor
    f32/f64::ceil
    f32/f64::trunc
    f32/f64::round

* Links from core to std:

    [`std::pointer::*`]
    [`std::process::abort`]
    [`from_raw_parts`]
    [`Vec::append`]

* Links with anchors?

	I provided a separate commit that replaced links with anchors by intra-doc links.
	Here the anchor location information gets lost, so its questionable whether to
	actually replace those links.
2020-08-22 02:14:36 +02:00
Guillaume Gomez
385a1b2476 Add more links 2020-08-22 00:10:58 +02:00
LeSeulArtichaut
9424ac79b2 Remove links that get imported from the prelude 2020-08-21 23:27:23 +02:00
LeSeulArtichaut
8e009bc4f0 Use intra-doc-links in core::ops::* 2020-08-21 23:19:10 +02:00
Denis Vasilik
9785fd0882 Use intra-doc links 2020-08-21 21:41:43 +02:00
Denis Vasilik
a45d90ec23 Use intra-doc links 2020-08-21 21:35:52 +02:00
Guillaume Gomez
a3b45f3e54 Convert links to intra-doc links format 2020-08-21 20:28:57 +02:00
Denis Vasilik
37b6c249ed Rework imports used solely for docs 2020-08-21 19:19:58 +02:00
Denis Vasilik
0f6d95d1eb Apply auto-formatter 2020-08-21 18:50:09 +02:00
Denis Vasilik
0bccd9809e Incorporate suggestions from review 2020-08-21 18:35:17 +02:00
bors
efec7cde93 Auto merge of #75694 - RalfJung:miri-align-to, r=nagisa
enable align_to tests in Miri

With https://github.com/rust-lang/miri/issues/1074 resolved, we can enable these tests in Miri.

I also tweaked the test sized to get reasonable execution times with decent test coverage.
2020-08-21 15:40:48 +00:00
Yuki Okushi
cccb8892e9
Rollup merge of #75727 - camelid:intra-doc-links-for-core-result, r=jyn514
Switch to intra-doc links in `core::result`

Part of #75080.

@rustbot modify labels: A-intra-doc-links T-doc T-rustdoc
2020-08-21 17:55:14 +09:00
bors
d9d4d39612 Auto merge of #73565 - matthewjasper:core-min-spec, r=nagisa
Use min_specialization in libcore

Getting `TrustedRandomAccess` to work is the main interesting thing here.

- `get_unchecked` is now an unstable, hidden method on `Iterator`
- The contract for `TrustedRandomAccess` is made clearer in documentation
- Fixed a bug where `Debug` would create aliasing references when using the specialized zip impl
- Added tests for the side effects of `next_back` and `nth`.

closes #68536
2020-08-20 23:05:31 +00:00
Camelid
5a307cf4bb
Fix intra-doc links
One of the original links was linking to the wrong thing as well.

Co-authored-by: Joshua Nelson <joshua@yottadb.com>
2020-08-20 12:39:12 -07:00
Camelid
22c02bfdb1
Revert to old link since intra-doc link is broken
Can't link from `core` to `std` yet.
2020-08-19 18:17:55 -07:00
bors
5f6fcad644 Auto merge of #75563 - richkadel:llvm-coverage-map-gen-5.4, r=wesleywiser
Moved coverage counter injection from BasicBlock to Statement.

As discussed on Zulip: https://rust-lang.zulipchat.com/#narrow/stream/233931-t-compiler.2Fmajor-changes/topic/Implement.20LLVM-compatible.20source-based.20cod.20compiler-team.23278
2020-08-19 22:48:40 +00:00
Camelid
e0430a8aa2 Switch to intra-doc links in core::result 2020-08-19 14:02:34 -07:00
Matthew Jasper
dbad8c9368 Use min_specialization in libcore 2020-08-19 20:08:02 +01:00
Tyler Mandry
4123237fa1
Rollup merge of #75648 - matklad:lazy-dropck, r=KodrAus
Make OnceCell<T> transparent to dropck

See the failed build in

https://github.com/rust-lang/rust/pull/75555#issuecomment-675016718

for an example where we need this in real life

r? @ghost
2020-08-19 11:12:20 -07:00
Denis Vasilik
f71919c3db Fix anchor links 2020-08-19 16:44:20 +02:00
Denis Vasilik
6e2f076917 Use intra-doc links for links with anchors 2020-08-19 15:22:04 +02:00
Denis Vasilik
d1838f6c73 Use intra-doc links for compare_exchange and compare_exchange_weak 2020-08-19 15:12:28 +02:00
Denis Vasilik
751e343ab2 Use intra-doc linkks 2020-08-19 14:13:53 +02:00
Denis Vasilik
d339cfe4a1 Use intra-doc links for ptr::* 2020-08-19 13:38:22 +02:00
bors
11a44adc6f Auto merge of #75600 - nagisa:improve_align_offset, r=KodrAus
Improve codegen for `align_offset`

In this PR the `align_offset` implementation is changed/improved to produce better code in certain scenarios such as when pointer type is has a stride of 1 or when building for low optimisation levels.

While these changes do not achieve the "ideal" codegen referenced in #75579, it gets significantly closer to it. I’m not actually sure if the codegen can actually be much better with this function returning the offset, rather than the aligned pointer.

See the descriptions for separate commits for further information.
2020-08-19 10:54:44 +00:00
Denis Vasilik
2c7998720c Use intra-doc links for mem::* 2020-08-19 12:38:32 +02:00
Denis Vasilik
45b4e1470c Use intra-doc links for sync::* 2020-08-19 12:16:16 +02:00
Denis Vasilik
fb7d9170f4 Use intra-doc links for f32::* and f64::* 2020-08-19 12:04:23 +02:00
Ralf Jung
6a06bfc252 enable align_to tests in Miri 2020-08-19 10:41:51 +02:00
Denis Vasilik
a929738478 Use intra-doc links for u32::* 2020-08-19 10:19:06 +02:00
Denis Vasilik
7b5ec9e9e0 Use intra-doc links for AtomicU32::* 2020-08-19 09:58:41 +02:00
Denis Vasilik
2373dbce83 Use intra-doc links for AtomicI32::* 2020-08-19 09:52:19 +02:00
Yuki Okushi
ac264b53d1
Rollup merge of #75499 - jack-champagne:jack-champagne/issue-75412, r=Dylan-DPC
Fix documentation error

This should fix #75412. Just a quick >= to > sign replacement.
2020-08-19 15:54:28 +09:00
Yuki Okushi
1f4f31785e
Rollup merge of #75049 - janriemer:patch-1, r=poliorcetics
docs(marker/copy): provide example for `&T` being `Copy`

### Edited 2020-08-16 (most recent)
In the current documentation about the `Copy` marker trait, there is a section
with examples of structs that can implement `Copy`. Currently there is no example for
showing that shared references (`&T`) are also `Copy`.
It is worth to have a dedicated example for `&T` being `Copy`, because shared
references are an integral part of the language and it being `Copy` is not as
intuitive as other types that share this behaviour like `i32` or `bool`.

The example picks up on the previous non-`Copy` struct and shows that
structs can be `Copy`, even when they hold a shared reference to a non-`Copy` type.

-----------------------------------------
### Edited 2020-08-02, 3:28 p.m.
I've just realized that it says "in addition to the **implementors listed below**", which makes this PR kind of "wrong", because `&T` is indeed in the "implementors listed below".
Maybe we can instead show an example with `&T` in the [When can my type be Copy](https://doc.rust-lang.org/std/marker/trait.Copy.html#when-can-my-type-be-copy) section.

What I really want to achieve is that it becomes more obvious that `&T` is also `Copy`, because, I think, it is very valuable to know and it wasn't obvious for me, until I read something about it in a forum post.

What do you think? I would create another PR for that.
**Please feel free to close this PR.**

-----------------------------------
### Original post
In the current documentation about the `Copy` marker trait, there is a section
about "additional implementors", which list additional implementors of the `Copy` trait.
The fact that shared references are also `Copy` is mixed with another point,
which makes it hard to recognize and make it seem not as important.

This clarifies the fact that shared references are also `Copy`, by mentioning it as a
separate item in the list of "additional implementors".
2020-08-19 15:54:26 +09:00
Yuki Okushi
17d3ce457f
Rollup merge of #75038 - rust-lang:Havvy-patch-1, r=steveklabnik
See also X-Link mem::{swap, take, replace}

Since it's easy to end up at one of these functions when you really wanted the other one, cross link them with descriptions of why you'd want to use them.
2020-08-19 15:54:24 +09:00
Tim Diekmann
438c40efa1 Allow reallocation to different alignment 2020-08-19 06:46:47 +02:00
Rich Kadel
d129ac2655 Moved coverage counter injection from BasicBlock to Statement. 2020-08-18 21:06:45 -07:00
Denis Vasilik
076ae25714 Use intra-doc links for AtomicIsize::* 2020-08-19 00:10:57 +02:00
Denis Vasilik
69e5a4ccaa Use intra-doc links for AtomicBool::* 2020-08-19 00:05:49 +02:00
Denis Vasilik
c159e1764a Use intra-doc links for Ordering::* 2020-08-18 23:42:38 +02:00
Jan Riemer
522d177f34 docs: add another derive for Copyable struct
This adds another `derive` for a `Copy`able struct, so that we are
consistent with `derive` annotations.
2020-08-18 18:40:19 +02:00
Tim Diekmann
a9fe0ca47a Clean up AllocRef implementation and documentation 2020-08-18 09:53:22 +02:00
bors
515c9fa505 Auto merge of #75621 - TimDiekmann:no-fast-realloc, r=Amanieu
Remove fast path in reallocation for same layout sizes

r? @Amanieu

Before merging a perf-run should be done.

Closes https://github.com/rust-lang/wg-allocators/issues/70
2020-08-18 05:42:05 +00:00
Yuki Okushi
5498367faf
Rollup merge of #75392 - TimDiekmann:non-null-uninit-slice, r=RalfJung
Add `as_uninit`-like methods to pointer types and unify documentation of `as_ref` methods

This adds a convenient method to retrieve a `&(mut) [MaybeUninit<T>]` from slice pointers (`*const [T]`, `*mut [T]`, `NonNull<[T]>`). See also https://github.com/rust-lang/wg-allocators/issues/66#issuecomment-671789105.

~I'll add a tracking issue as soon as it's reviewed and CI passed.~
Tracking Issue: #75402

r? @RalfJung
2020-08-18 09:27:42 +09:00
Aleksey Kladov
695d86f584 Make OnceCell<T> transparent to dropck
See the failed build in

https://github.com/rust-lang/rust/pull/75555#issuecomment-675016718

for an example where we need this in real life
2020-08-18 00:34:54 +02:00
bors
792c645ca7 Auto merge of #75145 - davidtwco:issue-60607-preallocate-defid-for-lang-items, r=petrochenkov
Reference lang items during AST lowering

Fixes #60607 and fixes #61019.

This PR introduces `QPath::LangItem` to the HIR and uses it in AST lowering instead of constructing a `hir::Path` from a slice of symbols:

- Credit for much of this work goes to @matthewjasper, I basically just [rebased their earlier work](a227c706b7 (diff-c0f791ead38d2d02916faaad0f56f41d)).
- ~~Changes to Clippy might not be correct, they compile but attempting to run tests through `./x.py` produced failures which appeared spurious, so I didn't run any clippy tests.~~
- Changes to save analysis might not be correct - tests pass but I don't have a lot of confidence in those changes being correct.
- I've used `GenericBounds::LangItemTrait` rather than changing `PolyTraitRef`, as suggested by @matthewjasper [in this comment](a227c706b7 (r40107992)) but I'd prefer that be left for a follow-up.
- I've split things into smaller commits fairly arbitrarily to make the diff easier to review, each commit should compile but might not pass tests until the final commit.

r? @oli-obk
cc @matthewjasper
2020-08-17 20:51:59 +00:00
bors
e8df0b8932 Auto merge of #74940 - oli-obk:const_is_null, r=RalfJung
Make `<*const T>::is_null` const fn

r? @RalfJung

cc @rust-lang/wg-const-eval

tracking issue: #74939
2020-08-17 14:13:13 +00:00
Tim Diekmann
93e074bc8a Add as_uninit-like methods to pointer types and unify documentation of as_ref methods
Fix example in `NonNull::as_uninit_slice`


Rename feature gate to "ptr_as_uninit"


Make methods more consistent with already stable methods


Make `pointer::as_uninit_slice` return an `Option`


Fix placement for `// SAFETY` section


Add `as_uninit_ref` and `as_uninit_mut` to pointers


Fix doctest


Update tracking issue


Fix doc links


Apply suggestions from review


Make wording about counterparts consistent


Fix doc links


Improve documentation

Fix doc-tests


Fix doc links ... again


Apply suggestions from review


Apply suggestions from Review


Apply suggestion from review to all affected files


Add missing words in safety sections in `as_uninit_slice_mut`


Fix safety-comment in `NonNull::as_uninit_slice_mut`
2020-08-17 14:23:14 +02:00
Tim Diekmann
c619b36975 Remove fast path in reallocation for same layout sizes 2020-08-17 13:23:38 +02:00
bors
67e7b9b8cf Auto merge of #75535 - denisvasilik:intra-doc-links-any, r=jyn514
Move to intra-doc links for /library/core/src/any.rs

Helps with #75080.

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

Known issues:

* Links from `core` to `std` (#74481):
    * `[Box]: ../../std/boxed/struct.Box.html`
2020-08-17 08:00:45 +00:00
dylni
d04e6b8de5 Replace ad hoc implementations with slice::check_range 2020-08-16 21:47:12 -04:00
bors
4bb4b96ee7 Auto merge of #74562 - pickfire:is_ascii_branchless, r=nagisa
Remove branch in optimized is_ascii

Performs slightly better in short or medium bytes by eliminating
the last branch check on `byte_pos == len` and always check the
last byte as it is always at most one `usize`.

Benchmark, before `libcore`, after `libcore_new`. It improves
medium and short by 1ns but regresses unaligned_tail by 2ns,
either way we can get unaligned_tail have a tiny chance of 1/8
on a 64 bit machine. I don't think we should bet on that, the
probability is worse than dice.

```
test long::case00_libcore                     ... bench:          38 ns/iter (+/- 1) = 183947 MB/s
test long::case00_libcore_new                 ... bench:          38 ns/iter (+/- 1) = 183947 MB/s
test long::case01_iter_all                    ... bench:         227 ns/iter (+/- 6) = 30792 MB/s
test long::case02_align_to                    ... bench:          40 ns/iter (+/- 1) = 174750 MB/s
test long::case03_align_to_unrolled           ... bench:          19 ns/iter (+/- 1) = 367894 MB/s
test medium::case00_libcore                   ... bench:           5 ns/iter (+/- 0) = 6400 MB/s
test medium::case00_libcore_new               ... bench:           4 ns/iter (+/- 0) = 8000 MB/s
test medium::case01_iter_all                  ... bench:          20 ns/iter (+/- 1) = 1600 MB/s
test medium::case02_align_to                  ... bench:           6 ns/iter (+/- 0) = 5333 MB/s
test medium::case03_align_to_unrolled         ... bench:           5 ns/iter (+/- 0) = 6400 MB/s
test short::case00_libcore                    ... bench:           7 ns/iter (+/- 0) = 1000 MB/s
test short::case00_libcore_new                ... bench:           6 ns/iter (+/- 0) = 1166 MB/s
test short::case01_iter_all                   ... bench:           5 ns/iter (+/- 0) = 1400 MB/s
test short::case02_align_to                   ... bench:           5 ns/iter (+/- 0) = 1400 MB/s
test short::case03_align_to_unrolled          ... bench:           5 ns/iter (+/- 1) = 1400 MB/s
test unaligned_both::case00_libcore           ... bench:           4 ns/iter (+/- 0) = 7500 MB/s
test unaligned_both::case00_libcore_new       ... bench:           4 ns/iter (+/- 0) = 7500 MB/s
test unaligned_both::case01_iter_all          ... bench:          26 ns/iter (+/- 0) = 1153 MB/s
test unaligned_both::case02_align_to          ... bench:          13 ns/iter (+/- 2) = 2307 MB/s
test unaligned_both::case03_align_to_unrolled ... bench:          11 ns/iter (+/- 0) = 2727 MB/s
test unaligned_head::case00_libcore           ... bench:           5 ns/iter (+/- 0) = 6200 MB/s
test unaligned_head::case00_libcore_new       ... bench:           5 ns/iter (+/- 0) = 6200 MB/s
test unaligned_head::case01_iter_all          ... bench:          19 ns/iter (+/- 1) = 1631 MB/s
test unaligned_head::case02_align_to          ... bench:          10 ns/iter (+/- 0) = 3100 MB/s
test unaligned_head::case03_align_to_unrolled ... bench:          14 ns/iter (+/- 0) = 2214 MB/s
test unaligned_tail::case00_libcore           ... bench:           3 ns/iter (+/- 0) = 10333 MB/s
test unaligned_tail::case00_libcore_new       ... bench:           5 ns/iter (+/- 0) = 6200 MB/s
test unaligned_tail::case01_iter_all          ... bench:          19 ns/iter (+/- 0) = 1631 MB/s
test unaligned_tail::case02_align_to          ... bench:          10 ns/iter (+/- 0) = 3100 MB/s
test unaligned_tail::case03_align_to_unrolled ... bench:          13 ns/iter (+/- 0) = 2384 MB/s
```

Rough (unfair) maths on improvements for fun: 1ns * 7/8 - 2ns * 1/8 = 0.625ns

Inspired by fish and zsh clever trick to highlight missing linefeeds (⏎)
and branchless implementation of binary_search in rust.

cc @thomcc https://github.com/rust-lang/rust/pull/74066
r? @nagisa
2020-08-16 23:52:32 +00:00
Tyler Mandry
8ba56afcc6
Rollup merge of #75485 - RalfJung:pin, r=nagisa
pin docs: add some forward references

@nagisa had some questions about pinning that were answered in the docs, which they did not realize because that discussion is below the examples. I still think it makes sense to introduce the examples before that discussion, since it give the discussion something concrete to refer to, but this PR adds some forward references so people don't think the examples conclude the docs.

@nagisa do you think this would have helped?
2020-08-16 14:59:32 -07:00
Tyler Mandry
18e3799dc8
Rollup merge of #75423 - denisvasilik:intra-doc-links-core-hint, r=dtolnay
Move to intra-doc links for /library/core/src/hint.rs

Helps with #75080.

@rustbot modify labels: T-doc, A-intra-doc-links, T-rustdoc
2020-08-16 14:59:30 -07:00
Jan Riemer
56daf63d10
docs: add derive for struct
Code blocks in doc comments are compiled and run, so we show `Copy` works in this example.

Co-authored-by: Poliorcetics <poliorcetics@users.noreply.github.com>
2020-08-16 22:25:59 +02:00
Jan Riemer
9061da2e14
add empty line above code block
Co-authored-by: Poliorcetics <poliorcetics@users.noreply.github.com>
2020-08-16 22:15:59 +02:00
Jan Riemer
dce864454c add back emojis that have been removed accidentally
Co-authored-by: Joshua Nelson <joshua@yottadb.com>
2020-08-16 20:48:44 +02:00
Simonas Kazlauskas
5d22b18bf2 Improve codegen of align_offset when stride == 1
Previously checking for `pmoda == 0` would get LLVM to generate branchy
code, when, for `stride = 1` the offset can be computed without such a
branch by doing effectively a `-p % a`.

For well-known (constant) alignments, with the new ordering of these
conditionals, we end up generating 2 to 3 cheap instructions on x86_64:

    movq    %rdi, %rax
    negl    %eax
    andl    $7, %eax

instead of 5+ as previously.

For unknown alignments the new code also generates just 3 instructions:

    negq    %rdi
    leaq    -1(%rsi), %rax
    andq    %rdi, %rax
2020-08-16 21:31:48 +03:00
Simonas Kazlauskas
e7271da69a Improve align_offset at opt-level <= 1
At opt-level <= 1, the methods such as `wrapping_mul` are not being
inlined, causing significant bloating and slowdowns of the
implementation at these optimisation levels.

With use of these intrinsics, the codegen of this function at
-Copt_level=1 is the same as it is at -Copt_level=3.
2020-08-16 21:31:48 +03:00
Jan Riemer
43dec0e171
rephrase: struct -> type
Co-authored-by: Joshua Nelson <joshua@yottadb.com>
2020-08-16 20:17:28 +02:00
Jan Riemer
a876b3d8aa
docs(marker/copy): provide example for &T being Copy
In the current documentation about the `Copy` marker trait, there is a section
with examples of structs that can implement `Copy`. Currently there is no example for
showing that shared references (`&T`) are also `Copy`.
It is worth to have a dedicated example for `&T` being `Copy`, because shared
references are an integral part of the language and it being `Copy` is not as
intuitive as other types that share this behaviour like `i32` or `bool`.

The example picks up on the previous non-`Copy` struct and shows that
structs can be `Copy`, even when they hold a shared reference to a non-`Copy` type.
2020-08-16 20:03:34 +02:00
David Wood
7dee5f824d
hir: introduce lang items for AST lowering
This commit adds new lang items which will be used in AST lowering once
`QPath::LangItem` is introduced.

Co-authored-by: Matthew Jasper <mjjasper1@gmail.com>
Signed-off-by: David Wood <david@davidtw.co>
2020-08-16 15:42:23 +01:00
bors
243c725c24 Auto merge of #75561 - kornelski:stringcol, r=Dylan-DPC
Doc: String isn't a collection

On forums one user was confused by this text, interpreting it as saying that `String` is a `Vec<char>` literally, rather than figuratively for the purpose of collect. I've reworded that paragraph.
2020-08-16 06:26:38 +00:00
bors
9d38dc22e5 Auto merge of #75553 - denisvasilik:intra-doc-links-convert, r=jyn514
Move to intra-doc links for /library/core/src/char/convert.rs

Helps with #75080.

@rustbot modify labels: T-doc, A-intra-doc-links, T-rustdoc
2020-08-16 04:31:05 +00:00
bors
86bccb684d Auto merge of #75541 - camelid:intra-doc-links-for-core-option, r=jyn514
Switch to intra-doc links in `core::option`

Part of #75080.

I didn't change some of the links since they link into `std` and you can't link from `core` to `std` (#74481).

Also, at least one other link can't be switched to an intra-doc link because it's not supported yet (#74489).
2020-08-16 02:39:21 +00:00
Denis Vasilik
14b50ede7d Link to primitive instead of module 2020-08-15 19:27:34 +02:00
Kornel Lesiński
d5cb5eb08b Doc: String isn't a collection 2020-08-15 17:55:10 +01:00
Camelid
8227b3b0b2
Remove unnecessary intra-doc link
Co-authored-by: Joshua Nelson <joshua@yottadb.com>
2020-08-15 09:52:35 -07:00
Camelid
b02c4049cb
Fix link
Intra-doc links don't work yet in this case: #74489
2020-08-15 09:31:14 -07:00
Denis Vasilik
ebcb99ef8f Use intra-doc links 2020-08-15 01:12:47 +02:00
Camelid
b1c05c5c2b Switch to intra-doc links in core::option 2020-08-14 16:11:43 -07:00
Tyler Mandry
ad8c5e1480
Rollup merge of #75214 - chansuke:fix-intra-doc-links, r=jyn514
Use intra-doc links in `mem::manually_drop` & `mem::maybe_uninit`

This is partial fixes for https://github.com/rust-lang/rust/issues/75080.
2020-08-14 14:46:47 -07:00
Denis Vasilik
75c1e2dfbb Use intra-doc links 2020-08-14 20:50:38 +02:00