Commit graph

9159 commits

Author SHA1 Message Date
Dylan DPC 33b7ff128f
Rollup merge of #102131 - orlp:patch-1, r=thomcc
Added which number is computed in compute_float.

The original comment was very elaborate but ultimately did not mention at all what is being computed using parameters `w, q`, only referencing an external article for the algorithm.
2022-09-22 18:25:57 +05:30
Dylan DPC c99a603b87
Rollup merge of #102036 - Patiga:remove-io-errorkind-other-use-in-std, r=Mark-Simulacrum
Remove use of `io::ErrorKind::Other` in std

The documentation states that this `ErrorKind` is not used by the standard library. Instead, `io::ErrorKind::Uncategorized` should be used.

The two instances are in the unstable API [linux_pidfd](https://github.com/rust-lang/rust/issues/82971).
2022-09-22 18:25:52 +05:30
Orson Peters 186debc650
Added which number is computed in compute_float. 2022-09-22 11:34:42 +02:00
bors 7a8636c843 Auto merge of #100982 - fee1-dead-contrib:const-impl-requires-const-trait, r=oli-obk
Require `#[const_trait]` on `Trait` for `impl const Trait`

r? `@oli-obk`
2022-09-22 04:22:24 +00:00
Yuki Okushi 15b4788e36
Rollup merge of #102102 - GuillaumeGomez:doc-aliases-sized-trait, r=thomcc
Add doc aliases on Sized trait

Fixes #101267.

It adds both `?` and `?Sized` doc aliases for the `Sized` trait.

Some screenshots of the result:

![Screenshot from 2022-09-21 16-19-55](https://user-images.githubusercontent.com/3050060/191529854-65a79b75-6c20-4fd4-88c2-56d617d1acff.png)
![Screenshot from 2022-09-21 16-20-04](https://user-images.githubusercontent.com/3050060/191529857-2d11b477-5c5d-4080-9382-0b07950fd7f6.png)
2022-09-22 09:03:57 +09:00
Guillaume Gomez efbde853af Add doc aliases on Sized trait 2022-09-21 16:20:15 +02:00
Dylan DPC 77d063b954
Rollup merge of #102058 - mqudsi:path_extension_docs, r=thomcc
Clarify Path::extension() semantics in docs abstract

State up-front and center what shape the returned extension will have, without making the user read through the description and examples.

This is a doc-only change. There are no changes to the API contract and the clarification is in line with what was already stated/promised in the existing doc text - just clarified, summarized, and served bright and early.

Rationale: Various frameworks and libraries for different platforms have their different conventions as to whether an "extension" is ".ext" or just "ext" and anyone that's had to deal with this ambiguity in the past is always double- or triple-checking to make sure the function call returns an extension that matches the expected semantics. Offer the answer to this important question right off the bat instead of making them dig to find it.

```@rustbot``` label +A-docs
2022-09-21 19:01:09 +05:30
Dylan DPC 9b24a1f9a0
Rollup merge of #101995 - scottmcm:carrying-mul-example, r=Mark-Simulacrum
Add another example for `uN::carrying_mul`

The prose talks about doing this, so might as well add a simple code example of it too.
2022-09-21 19:01:07 +05:30
Dylan DPC 5377c31122
Rollup merge of #89891 - ojeda:modular-alloc, r=Mark-Simulacrum
`alloc`: add unstable cfg features `no_rc` and `no_sync`

In Rust for Linux we are using these to make `alloc` a bit more modular.

See https://github.com/rust-lang/rust/pull/86048 and https://github.com/rust-lang/rust/pull/84266 for similar requests.

Of course, the particular names are not important.
2022-09-21 19:01:06 +05:30
bors 4ecfdfac51 Auto merge of #100214 - scottmcm:strict-range, r=thomcc
Optimize `array::IntoIter`

`.into_iter()` on arrays was slower than it needed to be (especially compared to slice iterator) since it uses `Range<usize>`, which needs to handle degenerate ranges like `10..4`.

This PR adds an internal `IndexRange` type that's like `Range<usize>` but with a safety invariant that means it doesn't need to worry about those cases -- it only handles `start <= end` -- and thus can give LLVM more information to optimize better.

I added one simple demonstration of the improvement as a codegen test.

(`vec::IntoIter` uses pointers instead of indexes, so doesn't have this problem, but that only works because its elements are boxed.  `array::IntoIter` can't use pointers because that would keep it from being movable.)
2022-09-21 00:41:33 +00:00
bors 7743aa836e Auto merge of #100581 - joboet:sync_rwlock_everywhere, r=thomcc
std: use `sync::RwLock` for internal statics

Since `sync::RwLock` is now `const`-constructible, it can be used for internal statics, removing the need for `sys_common::StaticRwLock`. This adds some extra allocations on platforms which need to box their locks (currently SGX and some UNIX), but these will become unnecessary with the lock improvements tracked in #93740.
2022-09-20 22:00:08 +00:00
Mahmoud Al-Qudsi c291d2adec Clarify Path::extension() semantics in docs abstract
State up-front and center what shape the returned extension will have, without
making the user read through the description and examples.

Rationale: Various frameworks and libraries for different platforms have their
different conventions as to whether an "extension" is ".ext" or just "ext" and
anyone that's had to deal with this ambiguity in the past is always double- or
triple-checking to make sure the function call returns an extension that matches
the expected semantics. Offer the answer to this important question right off
the bat instead of making them dig to find it.
2022-09-20 11:12:03 -05:00
Scott McMurray 6dbd9a29c2 Optimize array::IntoIter
`.into_iter()` on arrays was slower than it needed to be (especially compared to slice iterator) since it uses `Range<usize>`, which needs to handle degenerate ranges like `10..4`.

This PR adds an internal `IndexRange` type that's like `Range<usize>` but with a safety invariant that means it doesn't need to worry about those cases -- it only handles `start <= end` -- and thus can give LLVM more information to optimize better.

I added one simple demonstration of the improvement as a codegen test.
2022-09-19 23:24:34 -07:00
Patiga 04c108711e Remove use of io::ErrorKind::Other in std
The documentation states that this `ErrorKind` is not used by the
standard library. Instead, `io::ErrorKind::Uncategorized` should be
used.
2022-09-20 02:56:23 +02:00
joboet be09a4a8b2
std: use sync::RwLock for internal statics 2022-09-19 23:27:26 +02:00
Matthias Krüger ea076a4f9f
Rollup merge of #101798 - y86-dev:const_waker, r=lcnr
Make `from_waker`, `waker` and `from_raw` unstably `const`

Make
- `Context::from_waker`
- `Context::waker`
- `Waker::from_raw`

`const`.

Also added a small test.
2022-09-19 17:55:19 +02:00
Matthias Krüger 27b1b04065
Rollup merge of #101389 - lukaslueg:rcgetmutdocs, r=m-ou-se
Tone down explanation on RefCell::get_mut

The language around `RefCell::get_mut` is remarkably sketchy and especially to the novice seems to quite strongly discourage using the method ("be cautious", "Also, please be aware", "special circumstances", "usually not what you want"). It was added six years ago in #40634 due to confusion about when to use `get_mut` and `borrow_mut`.

While its signature limits the use-cases for `get_mut`, there is no chance for a safety footgun, and readers can be made aware of `borrow_mut` more softly. I've also just sent a [PR](https://github.com/rust-lang/rust-clippy/issues/9044) to lint situations where `get_mut` could be used to improve ergonomics and performance.

So this PR tones down the language around `get_mut` and also brings it more in line with [`std::sync::Mutex::get_mut()`](https://doc.rust-lang.org/stable/std/sync/struct.Mutex.html#method.get_mut).
2022-09-19 17:55:18 +02:00
y86-dev 8e848dc23f Added tracking issue 2022-09-19 15:07:12 +02:00
Scott McMurray 690aaef5b6 Add another example for uN::carrying_mul
The prose talked about doing this, so might as well add a simple code example of it too.
2022-09-18 12:55:38 -07:00
bors 4af79ccd5e Auto merge of #101955 - jam1garner:fix-proc-macro-typo, r=petrochenkov
Fix typo in proc_macro Span::eq documentation
2022-09-18 11:42:13 +00:00
bors 4c2e500788 Auto merge of #101816 - raldone01:cleanup/select_nth_unstable, r=Mark-Simulacrum
Cleanup slice sort related closures in core and alloc
2022-09-18 06:03:22 +00:00
jam1garner 527f7887b8
Fix typo in proc_macro Span::eq 2022-09-17 19:15:30 -04:00
bors 5253b0a0a1 Auto merge of #101949 - matthiaskrgr:rollup-xu5cqnd, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #101093 (Initial version of 1.64 release notes)
 - #101713 (change AccessLevels representation)
 - #101821 (Bump Unicode to version 15.0.0, regenerate tables)
 - #101826 (Enforce "joined()" and "joined_with_noop()" test)
 - #101835 (Allow using vendoring when running bootstrap from outside the source root)
 - #101942 (Revert "Copy stage0 binaries into stage0-sysroot")
 - #101943 (rustdoc: remove unused CSS `.non-exhaustive { margin-bottom }`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-09-17 22:04:28 +00:00
Matthias Krüger 36b066daa4
Rollup merge of #101821 - thomcc:unicode-15, r=Manishearth
Bump Unicode to version 15.0.0, regenerate tables

r? `@Mark-Simulacrum`
2022-09-17 23:30:49 +02:00
Matthias Krüger 92d8bf918c
Rollup merge of #101861 - wesleywiser:update_stdarch, r=Amanieu
Update stdarch

This pulls in the following changes:

- [Use simd_bitmask intrinsic in a couple of places](9f0928782b)
- [Remove simd_shuffle<n> usage in favor of simd_shuffle](3fd17e4607)
- [Remove late specifiers in __cpuid_count](f1db941633)
  - Helps with #101346
- [Use mov and xchg instead of movl(q) and xchgl(q)](3049a31937)
- [Bump cfg-if dependency to 1.0](f305cc83e7)
- [Fix documentation of __m256bh and __m512bh structs](699c093a42)

r? ``@Amanieu``
2022-09-17 19:27:07 +02:00
Matthias Krüger 00d88bdb2c
Rollup merge of #101672 - idigdoug:array_try_into, r=Mark-Simulacrum
array docs - advertise how to get array from slice

On my first Rust project, I spent more time than I care to admit figuring out how to efficiently get an array from a slice. Update the array documentation to explain this a bit more clearly.

(As a side note, it's a bit unfortunate that get-array-from-slice is only available via trait since that means it can't be used from const functions yet.)
2022-09-17 19:27:05 +02:00
bors 672831a5c8 Auto merge of #101938 - Dylan-DPC:rollup-6vlohhs, r=Dylan-DPC
Rollup of 6 pull requests

Successful merges:

 - #93628 (Stabilize `let else`)
 - #98441 (Implement simd_as for pointers)
 - #101790 (Do not suggest a placeholder to const and static without a type)
 - #101807 (Disallow defaults on type GATs)
 - #101915 (doc: fix redirected link in `/index.html`)
 - #101931 (doc: Fix a typo in `Rc::make_mut` docstring)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-09-17 10:56:42 +00:00
Dylan DPC 80cceb8f77
Rollup merge of #101931 - msakuta:master, r=thomcc
doc: Fix a typo in `Rc::make_mut` docstring

A very minor typo fix.
2022-09-17 15:31:09 +05:30
Dylan DPC 3ad81e0dd8
Rollup merge of #93628 - est31:stabilize_let_else, r=joshtriplett
Stabilize `let else`

🎉  **Stabilizes the `let else` feature, added by [RFC 3137](https://github.com/rust-lang/rfcs/pull/3137).** 🎉

Reference PR: https://github.com/rust-lang/reference/pull/1156

closes #87335 (`let else` tracking issue)

FCP: https://github.com/rust-lang/rust/pull/93628#issuecomment-1029383585

----------

## Stabilization report

### Summary

The feature allows refutable patterns in `let` statements if the expression is
followed by a diverging `else`:

```Rust
fn get_count_item(s: &str) -> (u64, &str) {
    let mut it = s.split(' ');
    let (Some(count_str), Some(item)) = (it.next(), it.next()) else {
        panic!("Can't segment count item pair: '{s}'");
    };
    let Ok(count) = u64::from_str(count_str) else {
        panic!("Can't parse integer: '{count_str}'");
    };
    (count, item)
}
assert_eq!(get_count_item("3 chairs"), (3, "chairs"));
```

### Differences from the RFC / Desugaring

Outside of desugaring I'm not aware of any differences between the implementation and the RFC. The chosen desugaring has been changed from the RFC's [original](https://rust-lang.github.io/rfcs/3137-let-else.html#reference-level-explanations). You can read a detailed discussion of the implementation history of it in `@cormacrelf` 's [summary](https://github.com/rust-lang/rust/pull/93628#issuecomment-1041143670) in this thread, as well as the [followup](https://github.com/rust-lang/rust/pull/93628#issuecomment-1046598419). Since that followup, further changes have happened to the desugaring, in #98574, #99518, #99954. The later changes were mostly about the drop order: On match, temporaries drop in the same order as they would for a `let` declaration. On mismatch, temporaries drop before the `else` block.

### Test cases

In chronological order as they were merged.

Added by df9a2e0687 (#87688):

* [`ui/pattern/usefulness/top-level-alternation.rs`](https://github.com/rust-lang/rust/blob/1.58.1/src/test/ui/pattern/usefulness/top-level-alternation.rs) to ensure the unreachable pattern lint visits patterns inside `let else`.

Added by 5b95df4bdc (#87688):

* [`ui/let-else/let-else-bool-binop-init.rs`](https://github.com/rust-lang/rust/blob/1.58.1/src/test/ui/let-else/let-else-bool-binop-init.rs) to ensure that no lazy boolean expressions (using `&&` or `||`) are allowed in the expression, as the RFC mandates.
* [`ui/let-else/let-else-brace-before-else.rs`](https://github.com/rust-lang/rust/blob/1.58.1/src/test/ui/let-else/let-else-brace-before-else.rs) to ensure that no `}` directly preceding the `else` is allowed in the expression, as the RFC mandates.
* [`ui/let-else/let-else-check.rs`](https://github.com/rust-lang/rust/blob/1.58.1/src/test/ui/let-else/let-else-check.rs) to ensure that `#[allow(...)]` attributes added to the entire `let` statement apply for the `else` block.
* [`ui/let-else/let-else-irrefutable.rs`](https://github.com/rust-lang/rust/blob/1.58.1/src/test/ui/let-else/let-else-irrefutable.rs) to ensure that the `irrefutable_let_patterns` lint fires.
* [`ui/let-else/let-else-missing-semicolon.rs`](https://github.com/rust-lang/rust/blob/1.58.1/src/test/ui/let-else/let-else-missing-semicolon.rs) to ensure the presence of semicolons at the end of the `let` statement.
* [`ui/let-else/let-else-non-diverging.rs`](https://github.com/rust-lang/rust/blob/1.58.1/src/test/ui/let-else/let-else-non-diverging.rs) to ensure the `else` block diverges.
* [`ui/let-else/let-else-run-pass.rs`](https://github.com/rust-lang/rust/blob/1.58.1/src/test/ui/let-else/let-else-run-pass.rs) to ensure the feature works in some simple test case settings.
* [`ui/let-else/let-else-scope.rs`](https://github.com/rust-lang/rust/blob/1.58.1/src/test/ui/let-else/let-else-scope.rs) to ensure the bindings created by the outer `let` expression are not available in the `else` block of it.

Added by bf7c32a447 (#89965):

* [`ui/let-else/issue-89960.rs`](https://github.com/rust-lang/rust/blob/1.58.1/src/test/ui/let-else/issue-89960.rs) as a regression test for the ICE-on-error bug #89960 . Later in 102b9125e1 this got removed in favour of more comprehensive tests.

Added by 856541963c (#89974):

* [`ui/let-else/let-else-if.rs`](https://github.com/rust-lang/rust/blob/1.58.1/src/test/ui/let-else/let-else-if.rs) to test for the improved error message that points out that `let else if` is not possible.

Added by 9b45713b6c:

* [`ui/let-else/let-else-allow-unused.rs`](https://github.com/rust-lang/rust/blob/1.61.0/src/test/ui/let-else/let-else-allow-unused.rs) as a regression test for #89807, to ensure that `#[allow(...)]` attributes added to the entire `let` statement apply for bindings created by the `let else` pattern.

Added by 61bcd8d307 (#89841):

* [`ui/let-else/let-else-non-copy.rs`](https://github.com/rust-lang/rust/blob/1.61.0/src/test/ui/let-else/let-else-non-copy.rs) to ensure that a copy is performed out of non-copy wrapper types. This mirrors `if let` behaviour. The test case bases on rustc internal changes originally meant for #89933 but then removed from the PR due to the error prior to the improvements of #89841.
* [`ui/let-else/let-else-source-expr-nomove-pass.rs `](https://github.com/rust-lang/rust/blob/1.61.0/src/test/ui/let-else/let-else-source-expr-nomove-pass.rs) to ensure that while there is a move of the binding in the successful case, the `else` case can still access the non-matching value. This mirrors `if let` behaviour.

Added by 102b9125e1 (#89841):

* [`ui/let-else/let-else-ref-bindings.rs`](https://github.com/rust-lang/rust/blob/1.61.0/src/test/ui/let-else/let-else-ref-bindings.rs) and [`ui/let-else/let-else-ref-bindings-pass.rs `](https://github.com/rust-lang/rust/blob/1.61.0/src/test/ui/let-else/let-else-ref-bindings-pass.rs) to check `ref` and `ref mut` keywords in the pattern work correctly and error when needed.

Added by 2715c5f984 (#89841):

* Match ergonomic tests adapted from the `rfc2005` test suite.

Added by fec8a507a2 (#89841):

* [`ui/let-else/let-else-deref-coercion-annotated.rs`](https://github.com/rust-lang/rust/blob/1.61.0/src/test/ui/let-else/let-else-deref-coercion-annotated.rs) and [`ui/let-else/let-else-deref-coercion.rs`](https://github.com/rust-lang/rust/blob/1.61.0/src/test/ui/let-else/let-else-deref-coercion.rs) to check deref coercions.

#### Added since this stabilization report was originally written (2022-02-09)

Added by 76ea566677 (#94211):

* [`ui/let-else/let-else-destructuring.rs`](https://github.com/rust-lang/rust/blob/1.63.0/src/test/ui/let-else/let-else-destructuring.rs) to give a nice error message if an user tries to do an assignment with a (possibly refutable) pattern and an `else` block, like asked for in #93995.

Added by e7730dcb7e (#94208):

* [`ui/let-else/let-else-allow-in-expr.rs`](https://github.com/rust-lang/rust/blob/1.61.0/src/test/ui/let-else/let-else-allow-in-expr.rs) to test whether `#[allow(unused_variables)]` works in the expr, as well as its non presence, as well as putting it on the entire `let else` *affects* the expr, too. This was adding a missing test as pointed out by the stabilization report.
* Expansion of `ui/let-else/let-else-allow-unused.rs` and `ui/let-else/let-else-check.rs` to ensure that non-presence of `#[allow(unused)]` does issue the unused lint. This was adding a missing test case as pointed out by the stabilization report.

Added by 5bd71063b3 (#94208):

* [`ui/let-else/let-else-slicing-error.rs`](https://github.com/rust-lang/rust/blob/1.61.0/src/test/ui/let-else/let-else-slicing-error.rs), a regression test for #92069, which got fixed without addition of a regression test. This resolves a missing test as pointed out by the stabilization report.

Added by 5374688e1d (#98574):

* [`src/test/ui/async-await/async-await-let-else.rs`](https://github.com/rust-lang/rust/blob/master/src/test/ui/async-await/async-await-let-else.rs) to test the interaction of async/await with `let else`

Added by 6c529ded86 (#98574):

* [`src/test/ui/let-else/let-else-temporary-lifetime.rs`](https://github.com/rust-lang/rust/blob/master/src/test/ui/let-else/let-else-temporary-lifetime.rs) as a (partial) regression test for #98672

Added by 9b56640106 (#99518):

* [`src/test/ui/let-else/let-else-temp-borrowck.rs`](https://github.com/rust-lang/rust/blob/master/src/test/ui/let-else/let-else-temporary-lifetime.rs) as a regression test for #93951
* Extension of `src/test/ui/let-else/let-else-temporary-lifetime.rs` to include a partial regression test for #98672 (especially regarding `else` drop order)

Added by baf9a7cb57 (#99518):

* Extension of `src/test/ui/let-else/let-else-temporary-lifetime.rs` to include a partial regression test for #93951, similar to `let-else-temp-borrowck.rs`

Added by 60be2de8b7 (#99518):

* Extension of `src/test/ui/let-else/let-else-temporary-lifetime.rs` to include a program that can now be compiled thanks to borrow checker implications of #99518

Added by 47a7a91c96 (#100132):

* [`src/test/ui/let-else/issue-100103.rs`](https://github.com/rust-lang/rust/blob/master/src/test/ui/let-else/issue-100103.rs), as a regression test for #100103, to ensure that there is no ICE when doing `Err(...)?` inside else blocks.

Added by e3c5bd617d (#100443):

* [`src/test/ui/let-else/let-else-then-diverge.rs`](https://github.com/rust-lang/rust/blob/master/src/test/ui/let-else/let-else-then-diverge.rs), to verify that there is no unreachable code error with the current desugaring.

Added by 981852677c (#100443):

* [`src/test/ui/let-else/issue-94176.rs`](https://github.com/rust-lang/rust/blob/master/src/test/ui/let-else/issue-94176.rs), to make sure that a correct span is emitted for a missing trailing expression error. Regression test for #94176.

Added by e182d12a84 (#100434):

* [src/test/ui/unpretty/pretty-let-else.rs](https://github.com/rust-lang/rust/blob/master/src/test/ui/unpretty/pretty-let-else.rs), as a regression test to ensure pretty printing works for `let else` (this bug surfaced in many different ways)

Added by e26285603c (#99954):

* [`src/test/ui/let-else/let-else-temporary-lifetime.rs`](https://github.com/rust-lang/rust/blob/master/src/test/ui/let-else/let-else-temporary-lifetime.rs) extended to contain & borrows as well, as this was identified as an earlier issue with the desugaring: https://github.com/rust-lang/rust/issues/98672#issuecomment-1200196921

Added by 2d8460ef43 (#99291):

* [`src/test/ui/let-else/let-else-drop-order.rs`](https://github.com/rust-lang/rust/blob/master/src/test/ui/let-else/let-else-drop-order.rs) a matrix based test for various drop order behaviour of `let else`. Especially, it verifies equality of `let` and `let else` drop orders, [resolving](https://github.com/rust-lang/rust/pull/93628#issuecomment-1238498468) a [stabilization blocker](https://github.com/rust-lang/rust/pull/93628#issuecomment-1055738523).

Added by 1b87ce0d40 (#101410):

* Edit to `src/test/ui/let-else/let-else-temporary-lifetime.rs` to add the `-Zvalidate-mir` flag, as a regression test for #99228

Added by af591ebe4d (#101410):

* [`src/test/ui/let-else/issue-99975.rs`](https://github.com/rust-lang/rust/blob/master/src/test/ui/let-else/issue-99975.rs) as a regression test for the ICE #99975.

Added by this PR:

* `ui/let-else/let-else.rs`, a simple run-pass check, similar to `ui/let-else/let-else-run-pass.rs`.

### Things not currently tested

* ~~The `#[allow(...)]` tests check whether allow works, but they don't check whether the non-presence of allow causes a lint to fire.~~ → *test added by e7730dcb7eb29a10ee73f269f4dc6e9d606db0da*
* ~~There is no `#[allow(...)]` test for the expression, as there are tests for the pattern and the else block.~~ → *test added by e7730dcb7eb29a10ee73f269f4dc6e9d606db0da*
* ~~`let-else-brace-before-else.rs` forbids the `let ... = {} else {}` pattern and there is a rustfix to obtain `let ... = ({}) else {}`. I'm not sure whether the `.fixed` files are checked by the tooling that they compile. But if there is no such check, it would be neat to make sure that `let ... = ({}) else {}` compiles.~~ → *test added by e7730dcb7eb29a10ee73f269f4dc6e9d606db0da*
* ~~#92069 got closed as fixed, but no regression test was added. Not sure it's worth to add one.~~ → *test added by 5bd71063b3810d977aa376d1e6dd7cec359330cc*
* ~~consistency between `let else` and `if let` regarding lifetimes and drop order: https://github.com/rust-lang/rust/pull/93628#issuecomment-1055738523~~ → *test added by 2d8460ef43d902f34ba2133fe38f66ee8d2fdafc*

Edit: they are all tested now.

### Possible future work / Refutable destructuring assignments

[RFC 2909](https://rust-lang.github.io/rfcs/2909-destructuring-assignment.html) specifies destructuring assignment, allowing statements like `FooBar { a, b, c } = foo();`.
As it was stabilized, destructuring assignment only allows *irrefutable* patterns, which before the advent of `let else` were the only patterns that `let` supported.
So the combination of `let else` and destructuring assignments gives reason to think about extensions of the destructuring assignments feature that allow refutable patterns, discussed in #93995.

A naive mapping of `let else` to destructuring assignments in the form of `Some(v) = foo() else { ... };` might not be the ideal way. `let else` needs a diverging `else` clause as it introduces new bindings, while assignments have a default behaviour to fall back to if the pattern does not match, in the form of not performing the assignment. Thus, there is no good case to require divergence, or even an `else` clause at all, beyond the need for having *some* introducer syntax so that it is clear to readers that the assignment is not a given (enums and structs look similar). There are better candidates for introducer syntax however than an empty `else {}` clause, like `maybe` which could be added as a keyword on an edition boundary:

```Rust
let mut v = 0;
maybe Some(v) = foo(&v);
maybe Some(v) = foo(&v) else { bar() };
```

Further design discussion is left to an RFC, or the linked issue.
2022-09-17 15:31:06 +05:30
bors b195f5349a Auto merge of #101784 - reitermarkus:const-memchr, r=thomcc
Simplify `const` `memchr`.

Extracted from https://github.com/rust-lang/rust/pull/101607.

Removes the need for `const_eval_select`.
2022-09-17 08:15:35 +00:00
msakuta 673c43b6e1 Fix a typo in docstring 2022-09-17 13:58:53 +09:00
Dylan DPC cfef659d13
Rollup merge of #101802 - chriss0612:const_fn_trait_ref_impls, r=fee1-dead
Constify impl Fn* &(mut) Fn*

Tracking Issue: [101803](https://github.com/rust-lang/rust/issues/101803)

Feature gate: `#![feature(const_fn_trait_ref_impls)]`

This feature allows using references to Fn* Items as Fn* Items themself in a const context.
2022-09-16 11:17:02 +05:30
Deadbeef 31f259ce5a Add const_trait to Allocator 2022-09-16 12:08:45 +08:00
Deadbeef 08ac185e99 append_const_msg for std traits 2022-09-16 11:48:43 +08:00
Deadbeef a77f4bc6d3 Mark Drop with #[const_trait] 2022-09-16 11:48:43 +08:00
Deadbeef 5a6273e263 Do not implement Unpin as const 2022-09-16 11:48:42 +08:00
Deadbeef bc6483d11e Prevent errors for stage0 rustc build 2022-09-16 11:48:42 +08:00
Deadbeef 4b539b04a6 Add more const_trait annotations 2022-09-16 11:48:42 +08:00
Deadbeef be65e03676 Add const_traits 2022-09-16 11:48:42 +08:00
Deadbeef 81b1810cd7 Require #[const_trait] for const impls 2022-09-16 11:48:42 +08:00
est31 173eb6f407 Only enable the let_else feature on bootstrap
On later stages, the feature is already stable.

Result of running:

rg -l "feature.let_else" compiler/ src/librustdoc/ library/ | xargs sed -s -i "s#\\[feature.let_else#\\[cfg_attr\\(bootstrap, feature\\(let_else\\)#"
2022-09-15 21:06:45 +02:00
Wesley Wiser 9286c3c3f5 Update stdarch
stdarch updated their version of `cfg-if` so we need to update the one
used by libstd as well.
2022-09-15 13:05:28 -04:00
Matthias Krüger b71b640f3c
Rollup merge of #101810 - raldone01:feat/const_partial_eq_ordering, r=fee1-dead
Constify `PartialEq` for `Ordering`

Adds `impl const PartialEq for Ordering {}` to #92391.
2022-09-15 08:00:16 +02:00
Matthias Krüger 93ae223951
Rollup merge of #101559 - andrewpollack:add-backtrace-off-fuchsia, r=tmandry
Adding "backtrace off" option for fuchsia targets

Used for improving compiler test suite results on Fuchsia targets
2022-09-15 08:00:12 +02:00
Andrew Pollack 88baf8f6f5 Adding backtrace off option for fuchsia targets 2022-09-14 23:54:40 +00:00
Thom Chiovoloni ac55092a14
Bump Unicode to version 15.0.0, regenerate tables 2022-09-14 13:21:19 -07:00
raldone01 59fe291cec Cleanup closures. 2022-09-14 20:11:45 +02:00
raldone01 f4ff6860dc Constify PartialEq for Ordering. 2022-09-14 18:31:53 +02:00
onestacked 478c471ce8 Added Tracking Issue number. 2022-09-14 15:10:02 +02:00
y86-dev 9a78faba71 Made from_waker, waker, from_raw const 2022-09-14 14:53:16 +02:00