Scott McMurray
7d57685682
Also remove #![feature(control_flow_enum)]
where possible
2023-01-18 10:22:21 -08:00
Scott McMurray
925dc37313
Stop using BREAK
& CONTINUE
in compiler
...
Switching them to `Break(())` and `Continue(())` instead.
libs-api would like to remove these constants, so stop using them in compiler to make the removal PR later smaller.
2023-01-17 23:17:51 -08:00
Kyle Matsuda
6e969ea85e
fix various subst_identity vs skip_binder
2023-01-14 00:30:03 -07:00
Kyle Matsuda
f29a334c90
change impl_trait_ref query to return EarlyBinder; remove bound_impl_trait_ref query; add EarlyBinder to impl_trait_ref in metadata
2023-01-14 00:29:56 -07:00
Kyle Matsuda
be130b57d4
change usages of impl_trait_ref to bound_impl_trait_ref
2023-01-14 00:23:32 -07:00
Nilstrieb
a4b859e35f
Delete unused polymorphization code
2023-01-09 19:10:00 +01:00
Nilstrieb
2855794257
Use newtype for unused generic parameters
2023-01-09 19:10:00 +01:00
nils
fd7a159710
Fix uninlined_format_args
for some compiler crates
...
Convert all the crates that have had their diagnostic migration
completed (except save_analysis because that will be deleted soon and
apfloat because of the licensing problem).
2023-01-05 19:01:12 +01:00
Joshua Nelson
5c79624bfa
Fix unknown_crate
when --crate-name
isn't passed on the CLI
2023-01-02 23:02:58 +00:00
Joshua Nelson
eb53eea609
Add json output to -Zdump-mono-stats
...
This allows analyzing the output programatically; for example, finding
the item with the highest `total_estimate`.
I also took the liberty of adding `untracked` tests to `rustc_session` and documentation to the unstable book for `dump-mono-items`.
2023-01-02 23:02:58 +00:00
bors
797b5f0f8e
Auto merge of #106143 - matthiaskrgr:rollup-3kpy1dc, r=matthiaskrgr
...
Rollup of 4 pull requests
Successful merges:
- #105375 (Fix an outdated comment mentioning parameter that doesn't exist anymore)
- #105955 (Remove wrapper functions for some unstable options)
- #106137 (fix more clippy::style findings)
- #106140 (Migrate links-color.goml to functions)
Failed merges:
r? `@ghost`
`@rustbot` modify labels: rollup
2022-12-25 23:47:11 +00:00
bors
8dfb339541
Auto merge of #105997 - RalfJung:immediate-abort, r=eholk
...
abort immediately on bad mem::zeroed/uninit
Now that we have non-unwinding panics, let's use them for these assertions. This re-establishes the property that `mem::uninitialized` and `mem::zeroed` will never unwind -- the earlier approach of causing panics here sometimes led to hard-to-debug segfaults when the surrounding code was not able to cope with the unexpected unwinding.
Cc `@bjorn3` I did not touch cranelift but I assume it needs a similar patch. However it has a `codegen_panic` abstraction that I did not want to touch since I didn't know how else it is used.
2022-12-25 20:51:37 +00:00
Matthias Krüger
d8874f259a
fix more clippy::style findings
...
match_result_ok
obfuscated_if_else
single_char_add
writeln_empty_string
collapsible_match
iter_cloned_collect
unnecessary_mut_passed
2022-12-25 17:32:26 +01:00
Ralf Jung
9f241b3a26
abort immediately on bad mem::zeroed/uninit
2022-12-22 16:37:42 +01:00
Jeremy Stucki
3dde32ca97
rustc: Remove needless lifetimes
2022-12-20 22:10:40 +01:00
Matthias Krüger
1da4a49912
clippy::complexity fixes
...
filter_next
needless_question_mark
bind_instead_of_map
manual_find
derivable_impls
map_identity
redundant_slicing
skip_while_next
unnecessary_unwrap
needless_bool
2022-12-19 00:04:28 +01:00
Rémy Rakic
b720847917
wrap output in BufWriter
2022-12-14 20:17:52 +00:00
Rémy Rakic
7611933e6a
add -Z dump-mono-stats
...
This option will output some stats from the monomorphization collection
pass to a file, to show estimated sizes from each instantiation.
2022-12-14 20:17:52 +00:00
Michael Goulet
bc293ed53e
bug! with a better error message for failing Instance::resolve
2022-12-11 19:48:24 +00:00
KaDiWa
9bc69925cb
compiler: remove unnecessary imports and qualified paths
2022-12-10 18:45:34 +01:00
Maybe Waffle
1d42936b18
Prefer doc comments over //
-comments in compiler
2022-11-27 11:19:04 +00:00
Oli Scherer
7658e0fccf
Stop passing the self-type as a separate argument.
2022-11-21 20:39:46 +00:00
Oli Scherer
ad57f88d3f
Add helper to create the trait ref for a lang item
2022-11-21 20:35:17 +00:00
Oli Scherer
ec8d01fdcc
Allow iterators instead of requiring slices that will get turned into iterators
2022-11-21 20:33:55 +00:00
Oli Scherer
6f77c97b38
Assert that various types have the right amount of generic args and fix the sites that used the wrong amount
2022-11-21 20:31:59 +00:00
Esteban Küber
d49c10ac62
Make "long type" printing type aware
...
Instead of simple string cutting, use a custom printer to hide parts of
long printed types.
2022-11-18 08:42:59 -08:00
Ralf Jung
1115ec601a
cleanup and dedupe CTFE and Miri error reporting
2022-11-16 10:13:29 +01:00
Ralf Jung
2cef9e3d19
interpret: support for per-byte provenance
2022-11-06 14:17:10 +01:00
Gary Guo
1013ee8df5
Fix ICE when negative impl is collected during eager mono
2022-11-04 03:08:28 +00:00
bors
11ebe6512b
Auto merge of #103217 - mejrs:track, r=eholk
...
Track where diagnostics were created.
This implements the `-Ztrack-diagnostics` flag, which uses `#[track_caller]` to track where diagnostics are created. It is meant as a debugging tool much like `-Ztreat-err-as-bug`.
For example, the following code...
```rust
struct A;
struct B;
fn main(){
let _: A = B;
}
```
...now emits the following error message:
```
error[E0308]: mismatched types
--> src\main.rs:5:16
|
5 | let _: A = B;
| - ^ expected struct `A`, found struct `B`
| |
| expected due to this
-Ztrack-diagnostics: created at compiler\rustc_infer\src\infer\error_reporting\mod.rs:2275:31
```
2022-11-01 21:09:45 +00:00
mejrs
cbeb244b05
Add more track_caller
2022-10-31 16:14:29 +01:00
Cameron Steffen
88d71504dd
Use tcx.require_lang_item
2022-10-29 16:09:15 -05:00
Guillaume Gomez
2414a4c31a
Rollup merge of #103625 - WaffleLapkin:no_tyctxt_dogs_allowed, r=compiler-errors
...
Accept `TyCtxt` instead of `TyCtxtAt` in `Ty::is_*` functions
Functions in answer:
- `Ty::is_freeze`
- `Ty::is_sized`
- `Ty::is_unpin`
- `Ty::is_copy_modulo_regions`
This allows to remove a lot of useless `.at(DUMMY_SP)`, making the code a bit nicer :3
r? `@compiler-errors`
2022-10-29 14:18:03 +02:00
Nicholas Nethercote
c8c25ce5a1
Rename some OwnerId
fields.
...
spastorino noticed some silly expressions like `item_id.def_id.def_id`.
This commit renames several `def_id: OwnerId` fields as `owner_id`, so
those expressions become `item_id.owner_id.def_id`.
`item_id.owner_id.local_def_id` would be even clearer, but the use of
`def_id` for values of type `LocalDefId` is *very* widespread, so I left
that alone.
2022-10-29 20:28:38 +11:00
Maybe Waffle
a17ccfa621
Accept TyCtxt
instead of TyCtxtAt
in Ty::is_*
functions
...
Functions in answer:
- `Ty::is_freeze`
- `Ty::is_sized`
- `Ty::is_unpin`
- `Ty::is_copy_modulo_regions`
2022-10-27 15:06:08 +04:00
Nilstrieb
c65ebae221
Migrate all diagnostics
2022-10-23 10:09:44 +02:00
lcnr
e8150fa60c
mir constants: type traversing bye bye
2022-10-17 10:54:01 +02:00
bors
0152393048
Auto merge of #99324 - reez12g:issue-99144, r=jyn514
...
Enable doctests in compiler/ crates
Helps with https://github.com/rust-lang/rust/issues/99144
2022-10-06 03:01:57 +00:00
Oli Scherer
c7b6ebdf7c
It's not about types or consts, but the lack of regions
2022-10-04 14:10:44 +00:00
reez12g
9a4c5abe45
Remove from compiler/ crates
2022-09-29 16:49:04 +09:00
Pietro Albini
3975d55d98
remove cfg(bootstrap)
2022-09-26 10:14:45 +02:00
Takayuki Maeda
8fe936099a
separate definitions and HIR
owners
...
fix a ui test
use `into`
fix clippy ui test
fix a run-make-fulldeps test
implement `IntoQueryParam<DefId>` for `OwnerId`
use `OwnerId` for more queries
change the type of `ParentOwnerIterator::Item` to `(OwnerId, OwnerNode)`
2022-09-24 23:21:19 +09:00
b-naber
a705e65605
rename Unevaluated to UnevaluatedConst
2022-09-23 14:27:34 +02:00
b-naber
9f3784df89
introduce mir::Unevaluated
2022-09-22 12:35:28 +02:00
Jhonny Bill Mena
e52e2344dc
FIX - adopt new Diagnostic naming in newly migrated modules
...
FIX - ambiguous Diagnostic link in docs
UPDATE - rename diagnostic_items to IntoDiagnostic and AddToDiagnostic
[Gardening] FIX - formatting via `x fmt`
FIX - rebase conflicts. NOTE: Confirm wheather or not we want to handle TargetDataLayoutErrorsWrapper this way
DELETE - unneeded allow attributes in Handler method
FIX - broken test
FIX - Rebase conflict
UPDATE - rename residual _SessionDiagnostic and fix LintDiag link
2022-09-21 11:43:22 -04:00
Jhonny Bill Mena
a3396b2070
UPDATE - rename DiagnosticHandler macro to Diagnostic
2022-09-21 11:39:53 -04:00
Jhonny Bill Mena
19b348fed4
UPDATE - rename DiagnosticHandler trait to IntoDiagnostic
2022-09-21 11:39:52 -04:00
Jhonny Bill Mena
5b8152807c
UPDATE - move SessionDiagnostic from rustc_session to rustc_errors
2022-09-21 11:39:52 -04:00
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
c524c7dd25
Auto merge of #98588 - b-naber:valtrees-cleanup, r=lcnr
...
Use only ty::Unevaluated<'tcx, ()> in type system
r? `@lcnr`
2022-09-17 03:04:22 +00:00