Commit graph

789 commits

Author SHA1 Message Date
Ian Jackson
4549c777e6 docs: Rewrap str::strip_prefix and strip_suffix back to 100
Requested-by: @LukasKalbertodt
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2020-10-12 14:48:12 +01:00
Ian Jackson
b7974bd3cd docs: Reword slice::strip_prefix and strip_suffix a bit
The stabilisation issue, #73413, has an open item for documentation.
I looked at the docs and it is all there, but I felt it could do with
some minor wording improvement.

I looked at the `str::strip_prefix` docs for a template.  (That
resulted in me slightly changing that doc too.)

I de-linkified `None` and `Some`, as I felt that rather noisy..  I
searched stdlib, and these don't seem to be usually linkified.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2020-10-12 14:48:07 +01:00
Ian Jackson
dbb0583023 docs: Reword str::strip_prefix and strip_suffix a bit
"Some is returned with <some value>" is an awkward construction.
The use of the passive voice is a bit odd, and doesn't seem like the
house style.

So say instead "returns X, wrapped in `Some`", for which there is some
other precedent in stdlib.

Instead of repeating "with the prefix removed", say "after the
prefix".  This is a bit clearer that the original is not modified.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2020-10-12 14:47:55 +01:00
James Gill
01ac5a97c9 Stabilize slice_select_nth_unstable
This stabilizes the functionality in slice_partition_at_index,
but under the names `select_nth_unstable*`.  The functions
`partition_at_index*` are left as deprecated, to be removed in
a later release.

Closes #55300
2020-10-12 00:07:41 -04:00
Ralf Jung
95aac4487d transmute_copy: explain that alignment is handled correctly 2020-10-11 23:59:32 +02:00
bors
b1af43bc63 Auto merge of #76934 - camelid:rustdoc-allow-generic-params, r=jyn514
Allow generic parameters in intra-doc links

Fixes #62834.

---

The contents of the generics will be mostly ignored (except for warning
if fully-qualified syntax is used, which is currently unsupported in
intra-doc links - see issue #74563).

* Allow links like `Vec<T>`, `Result<T, E>`, and `Option<Box<T>>`
* Allow links like `Vec::<T>::new()`
* Warn on
  * Unbalanced angle brackets (e.g. `Vec<T` or `Vec<T>>`)
  * Missing type to apply generics to (`<T>` or `<Box<T>>`)
  * Use of fully-qualified syntax (`<Vec as IntoIterator>::into_iter`)
  * Invalid path separator (`Vec:<T>:new`)
  * Too many angle brackets (`Vec<<T>>`)
  * Empty angle brackets (`Vec<>`)

Note that this implementation *does* allow some constructs that aren't
valid in the actual Rust syntax, for example `Box::<T>new()`. That may
not be supported in rustdoc in the future; it is an implementation
detail.
2020-10-10 21:19:50 +00:00
Nixon Enraght-Moony
d5b714355e Fix intra-docs link 2020-10-10 01:14:39 +01:00
Simonas Kazlauskas
54a5608334 Revert "Assume slice len is bounded by allocation size"
https://github.com/rust-lang/rust/pull/77023#issuecomment-703987379
suggests that the original PR introduced a significant perf regression.

This reverts commit e44784b875 / #77023.
2020-10-10 00:56:45 +03:00
Camelid
6df21a326e Fix intra-doc links in core
Caught by my malformed generics diagnostics!
2020-10-08 22:24:37 -07:00
Mara Bos
390883e888 Make Pin::new_static const. 2020-10-09 00:06:39 +02:00
Mara Bos
64839ee00a Add Pin::new_static. 2020-10-08 23:51:56 +02:00
Jonas Schievink
2766b725d3
Rollup merge of #76750 - camelid:dont-discourage-core-fmt-write, r=Mark-Simulacrum
Don't discourage implementing `core::fmt::Write`

Fixes #76729.

Explain when you should use it and when you should not.
2020-10-08 23:23:07 +02:00
Camelid
c17d067018 Don't discourage implementing core::fmt::Write
Explain when you should use it and when you should not.
2020-10-08 10:49:44 -07:00
Jacob Hughes
0266c134a7 Deprecate LayoutErr 2020-10-08 01:19:21 -04:00
Jacob Hughes
a97abb40ab Rename LayoutErr to LayoutError in core 2020-10-08 00:39:18 -04:00
Mark Rousskov
d8c035abbf Bump to 1.48 bootstrap compiler 2020-10-07 19:51:36 -04:00
bors
4437b4b150 Auto merge of #77464 - ecstatic-morse:const-fn-impl-trait, r=oli-obk
Give `impl Trait` in a `const fn` its own feature gate

...previously it was gated under `#![feature(const_fn)]`.

I think we actually want to do this in all const-contexts? If so, this should be `#![feature(const_impl_trait)]` instead. I don't think there's any way to make use of `impl Trait` within a `const` initializer.

cc #77463

r? `@oli-obk`
2020-10-07 19:59:52 +00:00
bors
28928c750c Auto merge of #77617 - AnthonyMikh:slice_windows_no_bounds_checking, r=lcnr
Eliminate bounds checking in slice::Windows

This is how `<core::slice::Windows as Iterator>::next` looks right now:

```rust
fn next(&mut self) -> Option<&'a [T]> {
    if self.size > self.v.len() {
        None
    } else {
        let ret = Some(&self.v[..self.size]);
        self.v = &self.v[1..];
        ret
    }
}
```

The line with `self.v = &self.v[1..];` relies on assumption that `self.v` is definitely not empty at this point. Else branch is taken when `self.size <= self.v.len()`, so `self.v` can be empty if `self.size` is zero. In practice, since `Windows` is never created directly but rather trough `[T]::windows` which panics when `size` is zero, `self.size` is never zero. However, the compiler doesn't know about this check, so it keeps the code which checks bounds and panics.

Using `NonZeroUsize` lets the compiler know about this invariant and reliably eliminate bounds checking without `unsafe` on `-O2`. Here is assembly of `Windows<'a, u32>::next` before and after this change ([goldbolt](https://godbolt.org/z/xrefzx)):

<details>
<summary>Before</summary>

```
example::next:
        push    rax
        mov     rcx, qword ptr [rdi + 8]
        mov     rdx, qword ptr [rdi + 16]
        cmp     rdx, rcx
        jbe     .LBB0_2
        xor     eax, eax
        pop     rcx
        ret
.LBB0_2:
        test    rcx, rcx
        je      .LBB0_5
        mov     rax, qword ptr [rdi]
        mov     rsi, rax
        add     rsi, 4
        add     rcx, -1
        mov     qword ptr [rdi], rsi
        mov     qword ptr [rdi + 8], rcx
        pop     rcx
        ret
.LBB0_5:
        lea     rdx, [rip + .L__unnamed_1]
        mov     edi, 1
        xor     esi, esi
        call    qword ptr [rip + core::slice::slice_index_order_fail@GOTPCREL]
        ud2

.L__unnamed_2:
        .ascii  "./example.rs"

.L__unnamed_1:
        .quad   .L__unnamed_2
        .asciz  "\f\000\000\000\000\000\000\000\016\000\000\000\027\000\000"
```

</details>

<details>
<summary>After</summary>

```
example::next:
        mov     rcx, qword ptr [rdi + 8]
        mov     rdx, qword ptr [rdi + 16]
        cmp     rdx, rcx
        jbe     .LBB0_2
        xor     eax, eax
        ret
.LBB0_2:
        mov     rax, qword ptr [rdi]
        lea     rsi, [rax + 4]
        add     rcx, -1
        mov     qword ptr [rdi], rsi
        mov     qword ptr [rdi + 8], rcx
        ret
```

</details>

Note the lack of call to `core::slice::slice_index_order_fail` in second snippet.

#### Possible reasons _not_ to merge this PR:

* this changes the error message on panic in `[T]::windows`. However, AFAIK this messages are not covered by backwards compatibility policy.
2020-10-07 17:31:56 +00:00
Ethan Brierley
f233abb909 Add comment to helper function 2020-10-07 08:02:36 +01:00
Dylan DPC
5314c72de8
Rollup merge of #77571 - pickfire:patch-6, r=cramertj
Use matches! for core::char methods
2020-10-07 00:16:07 +02:00
Ethan Brierley
1e7e2e40e4 remove OnlySign in favour of InvalidDigit 2020-10-06 22:42:33 +01:00
Ethan Brierley
8eaf0de1f4 Remove incorrect plural 2020-10-06 21:03:10 +01:00
Ethan Brierley
83d294f06a Bring char along with InvalidDigit 2020-10-06 19:05:25 +01:00
AnthonyMikh
981cb8c191 Eliminate bounds checking in slice::Windows 2020-10-06 18:23:37 +03:00
Ethan Brierley
c027844795 Fill in things needed to stabilize int_error_matching 2020-10-06 14:06:25 +01:00
bors
5849a7eca9 Auto merge of #77594 - timvermeulen:chain_advance_by, r=scottmcm
Implement advance_by, advance_back_by for iter::Chain

Part of #77404.

This PR does two things:
- implement `Chain::advance[_back]_by` in terms of `advance[_back]_by` on `self.a` and `advance[_back]_by` on `self.b`
- change `Chain::nth[_back]` to use `advance[_back]_by` on `self.a` and `nth[_back]` on `self.b`

This ensures that `Chain::nth` can take advantage of an efficient `nth` implementation on the second iterator, in case it doesn't implement `advance_by`.

cc `@scottmcm` in case you want to review this
2020-10-06 10:17:48 +00:00
Yuki Okushi
cdaf8c5f71
Rollup merge of #77573 - pickfire:patch-7, r=jyn514
Hint doc use convert::identity relative link

r? @jyn514
2020-10-06 16:26:12 +09:00
Yuki Okushi
d7123c2393
Rollup merge of #77228 - GuillaumeGomez:maybeuninit-examples, r=pickfire
Add missing examples for MaybeUninit

r? @Dylan-DPC
2020-10-06 16:26:00 +09:00
Dylan MacKenzie
c4ef5fdf8f Remove fn from feature name 2020-10-05 21:44:00 -07:00
Dylan MacKenzie
c959eefa74 Add requisite feature gates in the standard library 2020-10-05 19:57:25 -07:00
Tim Vermeulen
1d27a508d1 Test with non-fused iterators 2020-10-06 00:48:34 +02:00
Tim Vermeulen
bcacfe1dbf Add tests 2020-10-05 22:55:48 +02:00
Tim Vermeulen
c5d6a0dd96 Implement iter::Chain::{advance_by, advance_back_by} 2020-10-05 22:55:48 +02:00
Ivan Tham
cb881d36ae
hint doc use intra-doc links
Co-authored-by: Joshua Nelson <joshua@yottadb.com>
2020-10-05 23:29:43 +08:00
Ivan Tham
5541456094
Hint doc use convert::identity relative link 2020-10-05 22:47:52 +08:00
Ivan Tham
9704911ecb
Use matches! for core::char methods 2020-10-05 22:29:07 +08:00
Guillaume Gomez
b1ce6190ae Add missing examples for MaybeUninit 2020-10-05 13:21:20 +02:00
Dylan DPC
583269d8c5
Rollup merge of #77219 - mightyiam:issue_77100, r=jyn514
core::global_allocator docs link to std::alloc::GlobalAlloc

Closes #77100
2020-10-05 02:29:29 +02:00
Dylan DPC
6c9e85726c
Rollup merge of #75853 - LeSeulArtichaut:core-intra-docs-3, r=jyn514
Use more intra-doc-links in `core::fmt`

This is a follow-up to #75819, which encountered some broken links due to #75176, so this PR contains the links that are blocked on #75176.

r? @jyn514
2020-10-05 02:29:23 +02:00
Scott McMurray
652f34d270 Add [T]::as_chunks_mut (as unstable)
Allows getting the slices directly, rather than just through an iterator as in `array_chunks(_mut)`.  The constructors for those iterators are then written in terms of these methods, so the iterator constructors no longer have any `unsafe` of their own.
2020-10-04 14:49:39 -07:00
bors
beb5ae474d Auto merge of #77023 - HeroicKatora:len-missed-optimization, r=Mark-Simulacrum
Hint the maximum length permitted by invariant of slices

One of the safety invariants of references, and in particular of references to slices, is that they may not cover more than `isize::MAX` bytes. The unsafe `from_raw_parts` constructors of slices explicitly requires the caller to guarantee this fact. Violating it would also be UB with regards to the semantics of generated llvm code.

This effectively bounds the length of a (non-ZST) slice from above by a compile time constant. But when the length is loaded from a function argument it appears llvm is not aware of this requirement. The additional value range assertions allow some further elision of code branches, including overflow checks, especially in the presence of artithmetic on the indices.

This may have a performance impact, adding more code to a common method but allowing more optimization. I'm not quite sure, is the Rust side of const-prop strong enough to elide the irrelevant match branches?

Fixes: #67186
2020-10-04 21:08:06 +00:00
LeSeulArtichaut
17d3c0a178 Use more intra-doc-links in core::fmt 2020-10-04 22:33:22 +02:00
Andreas Molzer
e44784b875 Assume slice len is bounded by allocation size
Uses assume to check the length against a constant upper bound. The
inlined result then informs the optimizer of the sound value range.

This was tried with unreachable_unchecked before which introduces a
branch. This has the advantage of not being executed in sound code but
complicates basic blocks. It resulted in ~2% increased compile time in
some worst cases.

Add a codegen test for the assumption, testing the issue from #67186
2020-10-04 20:43:36 +02:00
bors
0644cc1242 Auto merge of #76610 - hch12907:master, r=LukasKalbertodt
Implement as_ne_bytes() for integers and floats

This is related to issue #64464.

I am pretty sure that these functions are actually const-ify-able, and technically as_bits() can also be implemented for floats, but I might need some comments on both.
2020-10-04 11:48:50 +00:00
bors
2251766944 Auto merge of #77517 - JohnTitor:rollup-msbd49e, r=JohnTitor
Rollup of 11 pull requests

Successful merges:

 - #75143 (Use `tracing` spans to trace the entire MIR interp stack)
 - #75699 (Uplift drop-bounds lint from clippy)
 - #76768 (Test and reject out-of-bounds shuffle vectors)
 - #77190 (updated p! macro to accept literals)
 - #77388 (Add some regression tests)
 - #77419 (Create E0777 error code for invalid argument in derive)
 - #77447 (BTreeMap: document DrainFilterInner better)
 - #77468 (Fix test name)
 - #77469 (Improve rustdoc error for failed intra-doc link resolution)
 - #77473 (Make --all-targets in x.py check opt-in)
 - #77508 (Fix capitalization in blog post name)

Failed merges:

r? `@ghost`
2020-10-04 04:33:28 +00:00
Yuki Okushi
b654555a32
Rollup merge of #75699 - notriddle:drop-bounds-lint, r=petrochenkov
Uplift drop-bounds lint from clippy

Bounds on `T: Drop` do nothing, so they should warn.
2020-10-04 11:44:55 +09:00
bors
4cf3dc19a1 Auto merge of #76017 - JulianKnodt:fmt_fast, r=nagisa
Use less divisions in display u128/i128

This PR is an absolute mess, and I need to test if it improves the speed of fmt::Display for u128/i128, but I think it's correct.
It hopefully is more efficient by cutting u128 into at most 2 u64s, and also chunks by 1e16 instead of just 1e4.

Also I specialized the implementations for uints to always be non-false because it bothered me that it was checked at all

Do not merge until I benchmark it and also clean up the god awful mess of spaghetti.
Based on prior work in #44583

cc: `@Dylan-DPC`

Due to work on `itoa` and suggestion in original issue:
r? `@dtolnay`
2020-10-04 02:24:20 +00:00
Jonas Schievink
389f7cf7d6
Rollup merge of #76745 - workingjubilee:move-wrapping-tests, r=matklad
Move Wrapping<T> ui tests into library

Part of #76268
r? @matklad
2020-10-03 00:31:08 +02:00
Jubilee Young
4e973966b9 Remove unnecessary mod-cfg 2020-10-02 11:40:57 -07:00
Jonas Schievink
14d8ee3465
Rollup merge of #77442 - pickfire:patch-7, r=scottmcm
Clean up on example doc fixes for ptr::copy

Follow up of #77385

r? @scottmcm
2020-10-02 20:27:14 +02:00
Jonas Schievink
18ac26d1c5
Rollup merge of #77409 - pickfire:patch-6, r=GuillaumeGomez
Add example for iter chain struct

r? @GuillaumeGomez
2020-10-02 20:27:06 +02:00
Jonas Schievink
2a09c184c0
Rollup merge of #77405 - timvermeulen:iter_advance_by_tracking_issue, r=scottmcm
Add tracking issue of iter_advance_by feature
2020-10-02 20:27:04 +02:00
Ivan Tham
ddd19866a7
Clean up on example doc fixes for ptr::copy
Follow up of #77385
2020-10-02 14:44:01 +08:00
Yuki Okushi
2e749ab5a4
Rollup merge of #77385 - scottmcm:fix-77220, r=jyn514
Improve the example for ptr::copy

Fixes #77220
2020-10-02 08:25:22 +09:00
Yuki Okushi
9eaf536c32
Rollup merge of #77111 - fusion-engineering-forks:stabilize-slice-ptr-range, r=dtolnay
Stabilize slice_ptr_range.

This has been unstable for almost a year now. Time to stabilize?

Closes #65807.

@rustbot modify labels: +T-libs +A-raw-pointers +A-slice +needs-fcp
2020-10-02 08:25:13 +09:00
Waffle
076514c8a8 add str::SplitInclusive::as_str method
This commit entroduces `core::str::SplitInclusive::as_str` method similar to
`core::str::Split::as_str`, but under different gate -
"str_split_inclusive_as_str" (this is done so because `SplitInclusive` is
itself unstable).
2020-10-01 23:40:42 +03:00
Waffle
4747215d77 add str::{SplitN, RSplitN, SplitTerminator, RSplitTerminator}::as_str methods
This commit entroduce 4 methods smililar to `Split::as_str` all under the same
gate "str_split_as_str".
2020-10-01 23:08:15 +03:00
Waffle
0b923d3ca0 add str::{Split,RSplit}::as_str methods
This commit introduses 2 methods under "str_split_as_str" gate with common
signature of `&Split<'a, _> -> &'a str'`. Both of them work like
`Chars::as_str` - return unyield part of the inner string.
2020-10-01 22:53:15 +03:00
Michael Howell
cd159fd7f9 Uplift drop-bounds lint from clippy 2020-10-01 12:06:33 -07:00
bors
8fe73e80d7 Auto merge of #76971 - bugadani:issue-75659, r=Amanieu
Refactor memchr to allow optimization

Closes #75659

The implementation already uses naive search if the slice if short enough, but the case is complicated enough to not be optimized away. This PR refactors memchr so that it exists early when the slice is short enough.

Codegen-wise, as shown in #75659, memchr was not inlined previously so the only way I could find to test this is to check if there is no memchr call. Let me know if there is a more robust solution here.
2020-10-01 18:16:02 +00:00
Ivan Tham
aea3f8dbc9
Remove trailing whitespace in iter chain doc 2020-10-02 01:21:36 +08:00
Ivan Tham
676e4f193c
Add example for iter chain struct 2020-10-02 00:45:19 +08:00
Tim Vermeulen
4404c1afae Add tracking issue 2020-10-01 16:52:22 +02:00
scottmcm
e58f3d352d
Things are only moved if non-copy 2020-10-01 07:04:20 +00:00
Scott McMurray
20202da09e Improve the example for ptr::copy
Fixes #77220
2020-09-30 20:00:09 -07:00
bors
b218b952f8 Auto merge of #77381 - Dylan-DPC:rollup-0sr6p5p, r=Dylan-DPC
Rollup of 12 pull requests

Successful merges:

 - #76909 (Add Iterator::advance_by and DoubleEndedIterator::advance_back_by)
 - #77153 (Fix recursive nonterminal expansion during pretty-print/reparse check)
 - #77202 (Defer Apple SDKROOT detection to link time.)
 - #77303 (const evaluatable: improve `TooGeneric` handling)
 - #77305 (move candidate_from_obligation_no_cache)
 - #77315 (Rename AllocErr to AllocError)
 - #77319 (Stable hashing: add comments and tests concerning platform-independence)
 - #77324 (Don't fire `const_item_mutation` lint on writes through a pointer)
 - #77343 (Validate `rustc_args_required_const`)
 - #77349 (Update cargo)
 - #77360 (References to ZSTs may be at arbitrary aligned addresses)
 - #77371 (Remove trailing space in error message)

Failed merges:

r? `@ghost`
2020-10-01 01:12:41 +00:00
Dylan DPC
70740b1b82
Rollup merge of #77315 - exrook:rename-allocerror, r=joshtriplett
Rename AllocErr to AllocError

Implements rust-lang/wg-allocators#57
2020-10-01 02:13:39 +02:00
Dylan DPC
8bd4ed9f95
Rollup merge of #76909 - timvermeulen:advance_by, r=Amanieu
Add Iterator::advance_by and DoubleEndedIterator::advance_back_by

This PR adds the iterator method

```rust
fn advance_by(&mut self, n: usize) -> Result<(), usize>
```

that advances the iterator by `n` elements, returning `Ok(())` if this succeeds or `Err(len)` if the length of the iterator was less than `n`.

Currently `Iterator::nth` is the method to override for efficiently advancing an iterator by multiple elements at once. `advance_by` is superior for this purpose because
- it's simpler to implement: instead of advancing the iterator and producing the next element you only need to advance the iterator
- it composes better: iterators like `Chain` and `FlatMap` can implement `advance_by` in terms of `advance_by` on their inner iterators, but they cannot implement `nth` in terms of `nth` on their inner iterators (see #60395)
- the default implementation of `nth` can trivially be implemented in terms of `advance_by` and `next`, which this PR also does

This PR also adds `DoubleEndedIterator::advance_back_by` for all the same reasons.

I'll make a tracking issue if it's decided this is worth merging. Also let me know if anything can be improved, this went through several iterations so there might very well still be room for improvement (especially in the doc comments). I've written overrides of these methods for most iterators that already override `nth`/`nth_back`, but those still need tests so I'll add them in a later PR.

cc @cuviper @scottmcm @Amanieu
2020-10-01 02:13:29 +02:00
bors
9bb55dc864 Auto merge of #76325 - lzutao:split-core-str, r=Amanieu
Split core/str/mod.rs to smaller files

Note for reviewer:
* I split to multiple commits for easier reviewing, but I could git squash them all to one if requested.
* Recommend pulling this change locally and using advanced git diff viewer or this command:
  ```bash
  git show --reverse --color-moved=dimmed-zebra --color-moved-ws=ignore-all-space master..
  ```

---

I split `core/str/mod.rs` to these modules:

* `converts`: Contains helper functions to convert from bytes to str.
* `error`: For error structs like Utf8Error.
* `iter`: For iterators of many str methods.
* `traits`: For indexing operations and build in traits on str.
* `validations`: For functions validating utf8 --- This name is awkward, maybe utf8.rs is better.
2020-09-30 23:04:16 +00:00
bors
0d97f7a968 Auto merge of #77289 - TimDiekmann:alloc-ref-by-ref, r=Amanieu
Change `AllocRef::by_ref` to take `&self` instead of `&mut self`

r? `@Amanieu`
2020-09-29 22:13:37 +00:00
Mara Bos
81edbbc2bf Implement TryFrom between NonZero types. 2020-09-29 16:35:41 +02:00
Shahar Or (mightyiam)
badf4afdd5 core::global_allocator docs link to std::alloc::GlobalAlloc 2020-09-29 14:39:44 +07:00
kadmin
3f1d2aadd1 Use more efficient scheme for display u128/i128
Add zero padding

Add benchmarks for fmt u128

This tests both when there is the max amount of work(all characters used)
And least amount of work(1 character used)
2020-09-28 20:38:38 +00:00
Jacob Hughes
5829560a68 Rename AllocErr to AllocError 2020-09-28 14:51:03 -04:00
Ralf Jung
aba966a592
Rollup merge of #77194 - pickfire:patch-7, r=withoutboats
Add doc alias for iterator fold

fold is known in python and javascript as reduce,
not sure about inject but it was written in doc there.

This was my first confusion when coming into rust, I somehow cannot find where is reduce, sometimes I still forget that it is known as `fold`.
2020-09-28 18:39:46 +02:00
Ralf Jung
85a59d40f1
Rollup merge of #77170 - ecstatic-morse:const-fn-ptr, r=oli-obk
Remove `#[rustc_allow_const_fn_ptr]` and add `#![feature(const_fn_fn_ptr_basics)]`

`rustc_allow_const_fn_ptr` was a hack to work around the lack of an escape hatch for the "min `const fn`" checks in const-stable functions. Now that we have co-opted `allow_internal_unstable` for this purpose, we no longer need a bespoke attribute.

Now this functionality is gated under `const_fn_fn_ptr_basics` (how concise!), and `#[allow_internal_unstable(const_fn_fn_ptr_basics)]` replaces `#[rustc_allow_const_fn_ptr]`. `const_fn_fn_ptr_basics` allows function pointer types to appear in the arguments and locals of a `const fn` as well as function pointer casts to be performed inside a `const fn`. Both of these were allowed in constants and statics already. Notably, this does **not** allow users to invoke function pointers in a const context. Presumably, we will use a nicer name for that (`const_fn_ptr`?).

r? @oli-obk
2020-09-28 18:39:44 +02:00
Ralf Jung
734c57d45c
Rollup merge of #76454 - poliorcetics:ui-to-unit-test-1, r=matklad
UI to unit test for those using Cell/RefCell/UnsafeCell

Helps with #76268.

I'm working on all files using `Cell` and moving them to unit tests when possible.

r? @matklad
2020-09-28 18:39:39 +02:00
Tim Diekmann
c22d896b9b Change AllocRef::by_ref to take &self instead of &mut self 2020-09-28 10:42:29 +02:00
Dylan MacKenzie
3cbd17fcc6 Remove rustc_allow_const_fn_ptr
This was a hack to work around the lack of an escape hatch for the "min
`const fn`" checks in const-stable functions. Now that we have co-opted
`allow_internal_unstable` for this purpose, we no longer need the
bespoke attribute.
2020-09-27 10:46:41 -07:00
Dylan MacKenzie
1ff143191c Add a feature gate for basic function pointer use in const fn 2020-09-27 10:46:41 -07:00
Dániel Buga
89b8a97aea Refactor memchr to allow optimization 2020-09-27 15:10:48 +02:00
Jonas Schievink
5926c43743
Rollup merge of #77167 - fusion-engineering-forks:fix-fixme-min-max-sign-test, r=nagisa
Fix FIXME in core::num test: Check sign of zero in min/max tests.

r? nagisa

@rustbot modify labels: +C-cleanup
2020-09-27 01:53:20 +02:00
Ralf Jung
3b544e73ae
Rollup merge of #77122 - ecstatic-morse:const-fn-arithmetic, r=RalfJung,oli-obk
Add `#![feature(const_fn_floating_point_arithmetic)]`

cc #76618

This is a template for splitting up `const_fn` into granular feature gates. I think this will make it easier, both for us and for users, to track stabilization of each individual feature. We don't *have* to do this, however. We could also keep stabilizing things out from under `const_fn`.

cc @rust-lang/wg-const-eval
r? @oli-obk
2020-09-26 12:58:20 +02:00
Ralf Jung
31fd0ad69f
Rollup merge of #77076 - GuillaumeGomez:missing-code-examples-slice-iter, r=Dylan-DPC
Add missing code examples on slice iter types

r? @Dylan-DPC
2020-09-26 12:58:15 +02:00
Ralf Jung
1e62382a4f
Rollup merge of #75454 - ltratt:option_optimisation_guarantees, r=dtolnay
Explicitly document the size guarantees that Option makes.

Triggered by a discussion on wg-unsafe-code-guidelines about which layouts of `Option<T>` one can guarantee are optimised to a single pointer.

CC @RalfJung
2020-09-26 12:58:12 +02:00
Lzu Tao
dce7248a39 Remove unneeded tidy comment 2020-09-26 05:20:53 +00:00
Lzu Tao
37cd79cd32 Gather all ZST structs of str together 2020-09-26 05:20:53 +00:00
Lzu Tao
653b5bf18c Move functions converting bytes to str to new mod 2020-09-26 05:20:53 +00:00
Lzu Tao
90c813a0f0 Move utf-8 validating helpers to new mod 2020-09-26 05:20:53 +00:00
Lzu Tao
5f0d724e29 Move str's impl of iterations to new mod 2020-09-26 05:20:51 +00:00
Lzu Tao
5b533fccf3 Move traits implementation of str to new mod
Also move FromStr trait
2020-09-26 05:04:58 +00:00
Lzu Tao
d31ca4fc8e Move Utf8Error to new mod 2020-09-26 05:04:58 +00:00
Mara Bos
f289468045 Stabilize slice_ptr_range.
Closes #65807.
2020-09-26 00:25:32 +02:00
bors
043f6d747c Auto merge of #77201 - matthewjasper:rename-get-unchecked, r=spastorino
Rename Iterator::get_unchecked

Closes #76479

r? `@pnkfelix`
2020-09-25 21:44:26 +00:00
Alexis Bourget
a61b9638bb review: fix nits and move panic safety tests to the correct place 2020-09-25 23:10:24 +02:00
Guillaume Gomez
187162e991 Add missing code examples on slice iter types 2020-09-25 21:17:22 +02:00
Matthew Jasper
04a0b1d087 Rename Iterator::get_unchecked
It's possible for method resolution to pick this method over a lower
priority stable method,  causing compilation errors. Since this method
is permanently unstable, give it a name that is very unlikely to be used
in user code.
2020-09-25 19:52:01 +01:00
Jonas Schievink
a7bdf851cf
Rollup merge of #77176 - austinkeeley:intrinsics-documentatation-error, r=jyn514
Removing erroneous semicolon in transmute documentation

There is a semicolon in the example code that causes the expected value to not be returned.
2020-09-25 19:42:50 +02:00
Jonas Schievink
1149b308cd
Rollup merge of #77097 - fusion-engineering-forks:slice-ptr-range-const-fn, r=oli-obk
Make [].as_[mut_]ptr_range() (unstably) const.

Gated behind `const_ptr_offset`, as suggested by https://github.com/rust-lang/rust/issues/65807#issuecomment-697229404

This also marks `[].as_mut_ptr()` as const, because it's used by `as_mut_ptr_range`. I gated it behind the same feature, because I figured it's not worth adding a separate tracking issue for const `as_mut_ptr`.
2020-09-25 19:42:39 +02:00
Jonas Schievink
1b8c939a8d
Rollup merge of #76973 - lzutao:unstably-const-assume, r=oli-obk
Unstably allow assume intrinsic in const contexts

Not sure much about this usage because there are concerns
about [blocking  optimization][1] and [slowing down LLVM][2] when using `assme` intrinsic
in inline functions.
But since Oli suggested in https://github.com/rust-lang/rust/issues/76960#issuecomment-695772221,
here we are.

[1]: https://github.com/rust-lang/rust/pull/54995#issuecomment-429302709
[2]: https://github.com/rust-lang/rust/issues/49572#issuecomment-589615423
2020-09-25 19:42:29 +02:00
Dylan MacKenzie
6a52c09440 Add new feature gate to standard library 2020-09-25 10:38:21 -07:00
Ivan Tham
ea0065ad4f
Reposition iterator doc alias reduce before inline 2020-09-26 00:05:37 +08:00
Ivan Tham
1994cee61a
Add alias for iterator fold
fold is known in python and javascript as reduce,
not sure about inject but it was written in doc there.
2020-09-26 00:04:34 +08:00
Austin Keeley
1d3717d17c Removing erroneous semicolon 2020-09-25 00:03:59 -04:00
Jonas Schievink
dc4f39c43f
Rollup merge of #77079 - poliorcetics:more-self-in-docs, r=jyn514
Use `Self` in docs when possible

Fixes #76542.

I used `rg '\s*//[!/]\s+fn [\w_]+\(&?self, ' .` in `library/` to find instances, I found some with that and some by manually checking.

@rustbot modify labels: C-enhancement T-doc
2020-09-25 02:29:42 +02:00
Jonas Schievink
09b0bd6022
Rollup merge of #77074 - lcnr:array-from-ref, r=SimonSapin
add array::from_ref

mirrors the methods in `std::slice` with the same name.

I guess this method previously didn't exist as there was close to no reason to create an array of size `1`.
This will change due to const generics in the near future.
2020-09-25 02:29:39 +02:00
Mara Bos
74952b9f21 Fix FIXME in core::num test: Check sign of zero in min/max tests. 2020-09-24 22:29:32 +02:00
Lzu Tao
382d7243a7 move test to intergrated test in library/core 2020-09-24 14:46:57 +00:00
bors
7b240a1262 Auto merge of #77083 - KodrAus:revert/const-type-id, r=RalfJung
revert const_type_id stabilization

This reverts #72488, which is currently on beta and scheduled to stabilize in `1.47.0`, based on https://github.com/rust-lang/rust/pull/75923#issuecomment-696676511

It turns out we might not be quite ready to stabilize `TypeId` in const contexts before having a chance to rework its internals. Since `TypeId` is a bit of an oddity we want to be careful about how those internals are currently being relied on while making changes. That will be easier to do without having to also consider compile-time contexts.

r? `@eddyb`
2020-09-24 00:43:09 +00:00
Ashley Mannix
0e2db57754 update tracking issue for const_type_id 2020-09-24 09:00:04 +10:00
Bastian Kauschke
5b3016134f use array::from_ref for slices 2020-09-23 21:56:23 +02:00
Dylan DPC
c3c03f2f05
Rollup merge of #77055 - est31:more_track_caller, r=Mark-Simulacrum
Add #[track_caller] to more panicking Cell functions

Continuation of #74526

Adds the #[track_caller] attribute to almost all panicking Cell
functions. The ones that borrow two Cells in their function
body are spared, because the panic location helps pinpoint
which of the two borrows failed. You'd need to have
full debuginfo and backtraces enabled together with column
info in order to be able to discern the cases.
Column info in debuginfo is only available on non-Windows platforms.
2020-09-23 14:54:15 +02:00
Dylan DPC
a40d79c9fb
Rollup merge of #76993 - blitzerr:alloc-ref, r=Amanieu
Changing the alloc() to accept &self instead of &mut self

Fixes: [#55](https://github.com/rust-lang/wg-allocators/issues/55)

This is the first cut. It only makes the change for `alloc` method.
2020-09-23 14:54:06 +02:00
Dylan DPC
eaaf5d7e38
Rollup merge of #76965 - fusion-engineering-forks:fix-atomic-from-mut, r=Amanieu
Add cfg(target_has_atomic_equal_alignment) and use it for Atomic::from_mut.

Fixes some platform-specific problems with #74532 by using the actual alignment of the types instead of hardcoding a few `target_arch`s.

r? @RalfJung
2020-09-23 14:54:04 +02:00
Bastian Kauschke
ed97b42105 add tracking issue 2020-09-23 13:48:21 +02:00
Mara Bos
631c688350 Make [].as_[mut_]ptr_range() (unstably) const. 2020-09-23 11:09:10 +02:00
blitzerr
2b19b14cec a few more &mut self -> self changes 2020-09-22 21:04:31 -07:00
Ashley Mannix
9b2c8d866e revert const_type_id stabilization
This reverts commit e3856616ee.
2020-09-23 09:40:51 +10:00
Alexis Bourget
87a5dec4db Use Self more in core in doc when possible 2020-09-23 00:16:16 +02:00
Alexis Bourget
b6e72837fd Use Self more in core/src/cmp.rs 2020-09-22 23:36:08 +02:00
Bastian Kauschke
179f63dafc add array from_ref 2020-09-22 21:35:43 +02:00
Dylan MacKenzie
110e59e70e Update library functions with stability attributes
This may not be strictly minimal, but all unstable functions also need a
`rustc_const_unstable` attribute.
2020-09-22 10:05:58 -07:00
est31
05c3a2b07d Add #[track_caller] to more panicking Cell functions
Continuation of #74526

Adds the #[track_caller] attribute to almost all panicking Cell
functions. The ones that borrow two Cells in their function
body are spared, because the panic location helps pinpoint
which of the two borrows failed. You'd need to have
full debuginfo and backtraces enabled together with column
info in order to be able to discern the cases.
Column info is only available on non-Windows platforms.
2020-09-22 15:34:22 +02:00
blitzerr
3ffd403c6b removing &mut self for other methods of AllocRef 2020-09-22 06:22:02 -07:00
ecstatic-morse
537ede465f
Rollup merge of #76655 - CDirkx:const-pin, r=ecstatic-morse
Make some methods of `Pin` unstable const

Make the following methods unstable const under the `const_pin` feature:
- `new`
- `new_unchecked`
- `into_inner`
- `into_inner_unchecked`
- `get_ref`
- `into_ref`
- `get_mut`
- `get_unchecked_mut`

Of these, `into_inner` and `into_inner_unchecked` require the unstable `const_precise_live_drops`.

Also adds tests for these methods in a const context.

Tracking issue: #76654

r? @ecstatic-morse
2020-09-21 20:40:49 -07:00
ecstatic-morse
4f3697b4b8
Rollup merge of #76150 - matklad:droporder, r=withoutboats
Don't recommend ManuallyDrop to customize drop order

See
https://internals.rust-lang.org/t/need-for-controlling-drop-order-of-fields/12914/21
for the discussion.

TL;DR: ManuallyDrop is unsafe and footguny, but you can just ask the compiler to do all the work for you by re-ordering declarations.

Specifically, the original example from the docs is much better written as

```rust
struct Peach;
struct Banana;
struct Melon;
struct FruitBox {
    melon: Melon,
    // XXX: mind the relative drop order of the fields below
    peach: Peach,
    banana: Banana,
}
```
2020-09-21 20:40:41 -07:00
blitzerr
d9d02fa168 Changing the alloc() to accept &self instead of &mut self 2020-09-21 16:43:36 -07:00
Alexis Bourget
5be843fc54 Move format-ref-cell test 2020-09-21 21:50:27 +02:00
Alexis Bourget
275eed7eb1 Move vec-slice-drop test 2020-09-21 21:50:27 +02:00
Alexis Bourget
8904921c1d Move array cycle test 2020-09-21 21:50:26 +02:00
Alexis Bourget
ac39debeba Move panic safety traits tests 2020-09-21 21:50:26 +02:00
Alexis Bourget
85b2d9bf6f fmt 2020-09-21 21:50:26 +02:00
Alexis Bourget
fc152cd67e move 'test zip ...' tests 2020-09-21 21:50:26 +02:00
Alexis Bourget
af44a2a857 move 'cell does not clone' test 2020-09-21 21:50:25 +02:00
Alexis Bourget
f69c5aa428 Move more tests using Cell to unit tests 2020-09-21 21:50:19 +02:00
Alexis Bourget
8aae1eee94 Move cell exterior test into library unit tests 2020-09-21 21:28:33 +02:00
Mara Bos
5d6f1a1e32 Move use align_of in atomic.rs into the places where it is used. 2020-09-21 20:44:45 +02:00
Mara Bos
7a04ff6c33 Gate Atomic::from_mut on cfg(target_has_atomic_equal_alignment).
Instead of a few hardcoded cfg(target_arch = ..) like before.
2020-09-21 20:43:44 +02:00
Mara Bos
668225d157 Revert "Revert adding Atomic::from_mut."
This reverts commit 5ef1db3622.
2020-09-21 20:43:44 +02:00
Ralf Jung
b0c2eab66a
Rollup merge of #76967 - fusion-engineering-forks:revert-atomic-from-mut, r=kodrAus
Revert adding Atomic::from_mut.

This reverts #74532, which made too many assumptions about platforms, breaking some things.

Will need to be added later with a better way of gating on proper alignment, without hardcoding cfg(target_arch)s.

---

To be merged if fixing from_mut (#76965) takes too long.

r? @ghost
2020-09-21 15:30:41 +02:00
Aleksey Kladov
60b102de06 Don't recommend ManuallyDrop to customize drop order
See
https://internals.rust-lang.org/t/need-for-controlling-drop-order-of-fields/12914/21
for the discussion.

TL;DR: ManuallyDrop is unsafe and footguny, but you can just ask the
compiler to do all the work for you by re-ordering declarations.
2020-09-21 14:00:04 +02:00
Ralf Jung
b670b86353
Rollup merge of #76936 - danielhenrymantilla:unsafecell_get_mut, r=RalfJung
Add non-`unsafe` `.get_mut()` for `Unsafecell`

  - Tracking issue: https://github.com/rust-lang/rust/issues/76943

As discussed in: https://internals.rust-lang.org/t/add-non-unsafe-get-mut-for-unsafecell/12407

  - ### [Rendered documentation](https://modest-dubinsky-1f9f47.netlify.app/core/cell/struct.unsafecell)

This PR tries to move the sound `&mut UnsafeCell<T> -> &mut T` projection that all the "downstream" constructions were already relying on, up to the root abstraction, where it rightfully belongs, and officially blessing it.

  - this **helps reduce the amount of `unsafe` snippets out there** (_c.f._, the second commit of this PR: 09503fd1b3)

The fact that this getter is now expose for `UnsafeCell<T>` itself, will also help convey the idea that **`UnsafeCell` is not magical _w.r.t._ `&mut` accesses**, contrary to what some people incorrectly think.

  - Even the standard library itself at some point had such a confusion, _c.f._ this comment where there is a mention of multi-threaded (and thus _shared_) access despite dealing with exclusive references over unique ownership: 59fb88d061/library/core/src/cell.rs (L498-L499)

r? @RalfJung
2020-09-21 10:40:37 +02:00
Ralf Jung
5031242606
Rollup merge of #76867 - poliorcetics:intra-doc-core-iter, r=jyn514
Use intra-doc links in core/src/iter when possible

Helps with #75080.

I also updated lots of links to use `fn()` instead of `fn` when possible.

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

r? @jyn514
2020-09-21 10:40:32 +02:00
Ralf Jung
c3abb82908
Rollup merge of #76135 - CDirkx:const-option, r=dtolnay,oli-obk
Stabilize some Option methods as const

Stabilize the following methods of `Option` as const:
 - `is_some`
 - `is_none`
 - `as_ref`

These methods are currently const under the unstable feature `const_option` (tracking issue: #67441).
I believe these methods to be eligible for stabilization because of the stabilization of #49146 (Allow if and match in constants) and the trivial implementations, see also:  [PR#75463](https://github.com/rust-lang/rust/pull/75463).

Related: #76225
2020-09-21 10:40:26 +02:00
bors
0f9f0b384a Auto merge of #76295 - mati865:remove-mmx, r=Amanieu,oli-obk
Remove MMX from Rust

Follow-up to https://github.com/rust-lang/stdarch/pull/890
This removes most of MMX from Rust (tests pass with small changes), keeping stable `is_x86_feature_detected!("mmx")` working.
2020-09-21 00:43:26 +00:00
Christiaan Dirkx
4f859fbcfc Move const tests for Option to library\core
Part of #76268
2020-09-20 22:42:14 +02:00
CDirkx
9486f72879 Stabilize some Option methods as const
Stabilize the following methods of `Option` as const:
 - `is_some`
 - `is_none`
 - `as_ref`

Possible because of stabilization of #49146 (Allow if and match in constants).
2020-09-20 22:42:14 +02:00
Daniel Henry-Mantilla
5886c38112 Replace unneeded unsafe calls to .get() with calls to .get_mut() 2020-09-20 18:06:03 +02:00
Daniel Henry-Mantilla
8169989507 Add non-unsafe .get_mut() for UnsafeCell
Update the tracking issue number

Updated the documentation for `UnsafeCell`

Address review comments

Address more review comments + minor changes
2020-09-20 18:05:31 +02:00
Alexis Bourget
08b85a6fc8 use iter:: before free functions 2020-09-20 18:04:12 +02:00
bors
81e02708f1 Auto merge of #76975 - RalfJung:rollup-s2wiuqr, r=RalfJung
Rollup of 15 pull requests

Successful merges:

 - #76732 (Add docs for `BasicBlock`)
 - #76832 (Let backends define custom targets)
 - #76866 (Remove unused feature gates from library/ crates)
 - #76875 (Move to intra-doc links in library/alloc/src/collections/binary_heap.rs)
 - #76876 (Move to intra-doc links in collections/btree/map.rs and collections/linked_list.rs)
 - #76877 (Move to intra-doc links in collections/vec_deque.rs and collections/vec_deque/drain.rs)
 - #76878 (Move the version number to a plaintext file)
 - #76883 (README.md: Remove prompts from code blocks)
 - #76887 (Add missing examples on HashSet iter types)
 - #76890 (use matches!() macro for simple if let conditions)
 - #76891 (don't take `TyCtxt` by reference)
 - #76910 (transmute: use diagnostic item)
 - #76924 (Add tracking issue for feature(unix_socket_peek))
 - #76926 (BTreeMap: code readability tweaks)
 - #76940 (Don't allow implementing trait directly on type-alias-impl-trait)

Failed merges:

r? `@ghost`
2020-09-20 15:12:40 +00:00
Hoe Hao Cheng
3c582db8cb Implement as_ne_bytes for floats and integers 2020-09-20 22:20:06 +08:00
Tim Vermeulen
ecacc7534b Add advance_by and advance_back_by 2020-09-20 16:14:43 +02:00
Lzu Tao
4387480dea Add unstably const support for assume intrinsic 2020-09-20 14:00:40 +00:00
Ralf Jung
7ff17c13bc
Rollup merge of #76910 - lcnr:foreign-item-like, r=oli-obk
transmute: use diagnostic item

closes #66075, we now have no remaining uses of `match_def_path`  in the compiler while some uses still remain in `clippy`.

cc @RalfJung
2020-09-20 15:52:04 +02:00
Ralf Jung
bea0ae700e
Rollup merge of #76866 - est31:master, r=lcnr
Remove unused feature gates from library/ crates

Removes some unused feature gates from library crates. It's likely not a complete list as I only tested a subset for which it's more likely that it is unused.
2020-09-20 15:51:50 +02:00
Lzu Tao
3e08354fb0 Correct file path after some restructures in compiler 2020-09-20 13:48:16 +00:00
Mateusz Mikuła
5de2c95e6e Remove MMX from Rust 2020-09-20 15:13:11 +02:00
bors
b873fa6d42 Auto merge of #76136 - CDirkx:const-result, r=dtolnay
Stabilize some Result methods as const

Stabilize the following methods of Result as const:
 - `is_ok`
 - `is_err`
 - `as_ref`

A test is also included, analogous to the test for `const_option`.

These methods are currently const under the unstable feature `const_result` (tracking issue: #67520).
I believe these methods to be eligible for stabilization because of the stabilization of #49146 (Allow if and match in constants) and the trivial implementations, see also: [PR#75463](https://github.com/rust-lang/rust/pull/75463) and [PR#76135](https://github.com/rust-lang/rust/pull/76135).

Note: these methods are the only methods currently under the `const_result` feature, thus this PR results in the removal of the feature.

Related: #76225
2020-09-20 13:07:11 +00:00
Mara Bos
5ef1db3622 Revert adding Atomic::from_mut.
This made too many assumptions about platforms, breaking some things.

Will need to be added later with a better way of gating on proper
alignment, without hardcoding cfg(target_arch)s.
2020-09-20 12:54:37 +02:00
Ralf Jung
70f55a78a3
Rollup merge of #76853 - denisvasilik:intra-doc-links-core-wake, r=jyn514
Use intra-doc links in library/core/src/task/wake.rs

Helps with #75080.

@rustbot modify labels: T-doc, A-intra-doc-links
2020-09-20 12:08:34 +02:00
Ralf Jung
6d0890ec83
Rollup merge of #76845 - Amjad50:fix-intra-docs-links, r=jyn514
Use intra docs links in core::{ascii, option, str, pattern, hash::map}

Partial fix for #75080

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

r? @jyn514
2020-09-20 12:08:33 +02:00
Ralf Jung
a8151840ef
Rollup merge of #76840 - poliorcetics:intra-doc-core-sync-and-future, r=jyn514
Move to intra doc links in core/src/future

Helps with #75080.

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

r? @jyn514
2020-09-20 12:08:31 +02:00
Ralf Jung
c124d4363d
Rollup merge of #76827 - lcnr:array_windows-docs, r=jonas-schievink
fix array_windows docs

r? @Dylan-DPC
2020-09-20 12:08:27 +02:00
Ralf Jung
df4e4ef2b9
Rollup merge of #76823 - RalfJung:black-box-warn, r=joshtriplett
black_box: silence unused_mut warning when building with cfg(miri)
2020-09-20 12:08:24 +02:00
est31
562422ecf7 Remove some unused features from alloc core and std 2020-09-20 04:29:11 +02:00
Lzu Tao
a50ec5f144 Remove outdated ignored tidy comment 2020-09-19 15:01:51 +00:00
Lzu Tao
3ee724e610 Move (u)int_impl macros to their own files 2020-09-19 15:01:49 +00:00
Lzu Tao
a54584319e Move dummy integer modules (like core::u32) to shells dir 2020-09-19 14:54:20 +00:00
Lzu Tao
550939f654 Move error structs to new mod 2020-09-19 14:54:20 +00:00
Lzu Tao
7125a481ce Move Wrapping<T> definition to wrapping mod 2020-09-19 14:54:20 +00:00
Lzu Tao
baecad9c39 Move NonZero* to its file 2020-09-19 14:54:20 +00:00
Ralf Jung
fef3324043
Rollup merge of #76492 - fusion-engineering-forks:int-bits, r=dtolnay
Add associated constant `BITS` to all integer types

Recently I've regularly come across this snippet (in a few different crates, including `core` and `std`):
```rust
std::mem::size_of<usize>() * 8
```

I think it's time for a `usize::BITS`.
2020-09-19 11:47:45 +02:00
Ralf Jung
1720fd94e8
Rollup merge of #76434 - RalfJung:black-box, r=Mark-Simulacrum
do not inline black_box when building for Miri

We cannot do the assembly trick in Miri, but let's at least make sure MIR inlining does not circumvent the black_box.

Also use black_box instead of local optimization barriers in a few const tests.
2020-09-19 11:47:43 +02:00
Bastian Kauschke
39f125918d cfg bootstrap 2020-09-19 11:33:11 +02:00
Bastian Kauschke
4debbdc6b9 transmute: use diagnostic item 2020-09-19 11:33:11 +02:00
Mara Bos
1bfe5efe8f Add tracking issue number for int_bits_const. 2020-09-19 08:14:41 +02:00
Mara Bos
1e2dba1e7c Use T::BITS instead of size_of::<T> * 8. 2020-09-19 06:54:42 +02:00
Mara Bos
5c30a16fa0 Add example/test to <int types>::BITS. 2020-09-19 06:50:45 +02:00
Mara Bos
3f68ae47df Add BITS associated constant to all integer types. 2020-09-19 06:50:45 +02:00
dylni
f055b0bb08 Rename method to assert_len 2020-09-18 13:55:03 -04:00
Christiaan Dirkx
e3c6e46168 Make some methods of Pin<&mut T> unstable const
Make the following methods unstable const under the `const_pin` feature:
- `into_ref`
- `get_mut`
- `get_unchecked_mut`
2020-09-18 19:23:50 +02:00
dylni
eb63168e00 Fix doctests 2020-09-18 13:05:54 -04:00
dylni
1095dcab96 Fix links 2020-09-18 12:39:10 -04:00
dylni
1ff7da6551 Move slice::check_range to RangeBounds 2020-09-18 12:17:51 -04:00
Alexis Bourget
982ec0d0c9 Fix broken link 2020-09-18 11:14:36 +02:00
Lzu Tao
b65937031d inline inner function of inlining methods 2020-09-18 08:36:21 +00:00
Lzu Tao
53d5261c69 Move unsafe code of slice new function of their Iterator structs
Init false state in Split* constructors
2020-09-18 08:36:21 +00:00
Poliorcetics
4c92b3dc7d
Apply suggestions from code review
Co-authored-by: Joshua Nelson <joshua@yottadb.com>
2020-09-18 09:52:35 +02:00
Alexis Bourget
4675a3104b Use intra-doc links in core/src/iter when possible 2020-09-18 09:51:26 +02:00
Amjad Alsharafi
3323a26144 Fixed some intra-docs links in library/core 2020-09-18 07:49:29 +08:00
Denis Vasilik
8e9ad31178 Use intra-doc links 2020-09-17 22:43:13 +02:00
Alexis Bourget
76ec3f8d2b Move to intra doc links in core/src/future 2020-09-17 17:25:06 +02:00
Ralf Jung
1dd3df6738 black_box: silence unused_mut warning when building with cfg(miri) 2020-09-17 14:39:31 +02:00
Lzu Tao
9fe9c6da3e Using <Iter>::new instead of exposing internal fields 2020-09-17 09:58:26 +00:00
Bastian Kauschke
764d307963
docs array -> slice
Co-authored-by: est31 <est31@users.noreply.github.com>
2020-09-17 10:30:28 +02:00
Bastian Kauschke
5f58e00ca5 fix array_windows docs 2020-09-17 09:53:19 +02:00
Tyler Mandry
d3c63213a0
Rollup merge of #76778 - pickfire:patch-7, r=jonas-schievink
Simplify iter fuse struct doc
2020-09-16 12:24:28 -07:00
Tyler Mandry
273267c9ee
Rollup merge of #76759 - yoshuawuyts:fix-future-pending-ready-stabilization-label, r=Dylan-DPC
Fix stabilization marker for future_readiness_fns

Updated the rustc version in which this will be stabilized from `1.47.0 -> 1.48.0`. Fixes https://github.com/rust-lang/rust/pull/74328#issuecomment-692133125. Ref #70921.

r? @Dylan-DPC
2020-09-16 12:24:21 -07:00
Tyler Mandry
ab78ca92f3
Rollup merge of #76747 - GuillaumeGomez:more-missing-libcore-code-examples, r=Mark-Simulacrum
Add missing code examples in libcore
2020-09-16 12:24:16 -07:00