1
Fork 0

Auto merge of #89933 - est31:let_else, r=michaelwoerister

Adopt let_else across the compiler

This performs a substitution of code following the pattern:

```
let <id> = if let <pat> = ... { identity } else { ... : ! };
```

To simplify it to:

```
let <pat> = ... { identity } else { ... : ! };
```

By adopting the `let_else` feature (cc #87335).

The PR also updates the syn crate because the currently used version of the crate doesn't support `let_else` syntax yet.

Note: Generally I'm the person who *removes* usages of unstable features from the compiler, not adds more usages of them, but in this instance I think it hopefully helps the feature get stabilized sooner and in a better state. I have written a [comment](https://github.com/rust-lang/rust/issues/87335#issuecomment-944846205) on the tracking issue about my experience and what I feel could be improved before stabilization of `let_else`.
This commit is contained in:
bors 2021-10-19 14:41:39 +00:00
commit 1af55d19c7
54 changed files with 76 additions and 150 deletions

View file

@ -13,6 +13,7 @@ Rust MIR: a lowered representation of Rust.
#![feature(exact_size_is_empty)]
#![feature(in_band_lifetimes)]
#![feature(iter_zip)]
#![feature(let_else)]
#![feature(map_try_insert)]
#![feature(min_specialization)]
#![feature(slice_ptr_get)]

View file

@ -145,9 +145,7 @@ impl Qualif for NeedsNonConstDrop {
Ok([..]) => {}
}
let drop_trait = if let Some(did) = cx.tcx.lang_items().drop_trait() {
did
} else {
let Some(drop_trait) = cx.tcx.lang_items().drop_trait() else {
// there is no way to define a type that needs non-const drop
// without having the lang item present.
return false;