Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: avoid unstable let_chains #628

Merged
merged 2 commits into from
Jul 27, 2023
Merged

Conversation

strager
Copy link
Contributor

@strager strager commented Jul 26, 2023

The let_chains Rust feature is unstable, preventing Oxc from using a stable Rust compiler. Refactor the code to avoid let_chains.

#626

@CLAassistant
Copy link

CLAassistant commented Jul 26, 2023

CLA assistant check
All committers have signed the CLA.

@github-actions github-actions bot added A-linter Area - Linter A-semantic Area - Semantic A-minifier Area - Minifier A-printer Area - Printer labels Jul 26, 2023
@Boshen
Copy link
Member

Boshen commented Jul 26, 2023

Thank you in advance @strager! I wrote so much let_chains 😢 Apparently 5 years and still no stabilization https://github.com/rust-lang/rust/issues/53667 ...

@Boshen
Copy link
Member

Boshen commented Jul 26, 2023

CLA assistant check Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.You have signed the CLA already but the status is still pending? Let us recheck it.

Sorry this requires a CLA :-(

Copy link
Contributor Author

@strager strager left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Boshen Here's a preview of a world without let_chains.

crates/oxc_linter/src/jest_ast_util.rs Show resolved Hide resolved
crates/oxc_minifier/src/compressor/fold.rs Show resolved Hide resolved
crates/oxc_minifier/src/compressor/fold.rs Show resolved Hide resolved
crates/oxc_minifier/src/compressor/fold.rs Show resolved Hide resolved
crates/oxc_minifier/src/compressor/mod.rs Outdated Show resolved Hide resolved
crates/oxc_minifier/tests/terser/mod.rs Outdated Show resolved Hide resolved
crates/oxc_semantic/src/binder.rs Outdated Show resolved Hide resolved
@Boshen
Copy link
Member

Boshen commented Jul 26, 2023

@strager You are free to refactor some of the code. I don't have a preferred style as long as CI passes 😁

@u9g
Copy link
Collaborator

u9g commented Jul 26, 2023

In general, let-else is stabilized, maybe it would be worth looking into that for some of these places too?

@strager strager changed the title wip drop unstable let_chains refactor: avoid unstable let_chains Jul 26, 2023
The let_chains Rust feature is unstable, preventing Oxc from using a
stable Rust compiler. Refactor the code to avoid let_chains.
@strager strager marked this pull request as ready for review July 26, 2023 19:30
Removing uses of let_chains now allows rustfmt to format some files.
Run 'cargo fmt' to reformat these files.
@strager
Copy link
Contributor Author

strager commented Jul 26, 2023

Note to maintainers: I prefer that this pull request be rebased or merged as-is, not squashed.

@Boshen Boshen merged commit 318d558 into oxc-project:main Jul 27, 2023
22 checks passed
@Boshen
Copy link
Member

Boshen commented Jul 27, 2023

Thank you both @strager and @magic-akari! One step closer to stable Rust.

renovate bot added a commit that referenced this pull request May 12, 2024
[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
|  |  | lockFileMaintenance | All locks refreshed |
| [napi](https://togithub.com/napi-rs/napi-rs) | workspace.dependencies
| patch | `2.16.4` -> `2.16.6` |
| [napi-derive](https://togithub.com/napi-rs/napi-rs) |
workspace.dependencies | patch | `2.16.3` -> `2.16.4` |
| [num-bigint](https://togithub.com/rust-num/num-bigint) |
workspace.dependencies | patch | `0.4.4` -> `0.4.5` |
| [petgraph](https://togithub.com/petgraph/petgraph) |
workspace.dependencies | patch | `0.6.4` -> `0.6.5` |
| [proc-macro2](https://togithub.com/dtolnay/proc-macro2) |
workspace.dependencies | patch | `1.0.81` -> `1.0.82` |
| [serde](https://serde.rs)
([source](https://togithub.com/serde-rs/serde)) | workspace.dependencies
| patch | `1.0.200` -> `1.0.201` |
| [serde_json](https://togithub.com/serde-rs/json) |
workspace.dependencies | patch | `1.0.116` -> `1.0.117` |
| [trybuild](https://togithub.com/dtolnay/trybuild) |
workspace.dependencies | patch | `1.0.93` -> `1.0.95` |

🔧 This Pull Request updates lock files to use the latest dependency
versions.

---

### Release Notes

<details>
<summary>napi-rs/napi-rs (napi)</summary>

###
[`v2.16.6`](https://togithub.com/napi-rs/napi-rs/releases/tag/napi%402.16.6)

[Compare
Source](https://togithub.com/napi-rs/napi-rs/compare/napi@2.16.5...napi@2.16.6)

#### What's Changed

- fix(napi): panic when deserializing empty buffer with Rust 1.78 by
[@&#8203;mischnic](https://togithub.com/mischnic) in
[napi-rs/napi-rs#2094

**Full Changelog**:
https://github.com/napi-rs/napi-rs/compare/napi@2.16.5...napi@2.16.6

###
[`v2.16.5`](https://togithub.com/napi-rs/napi-rs/releases/tag/napi%402.16.5)

[Compare
Source](https://togithub.com/napi-rs/napi-rs/compare/napi@2.16.4...napi@2.16.5)

##### What's Changed

- Fix panic in JsArrayBufferValue as_ref/as_mut with Rust 1.78 by
[@&#8203;tronical](https://togithub.com/tronical) in
[napi-rs/napi-rs#2083
- fix(napi): make sure env without exception pending before throw error
by [@&#8203;southorange0929](https://togithub.com/southorange0929) in
[napi-rs/napi-rs#2092

**Full Changelog**:
https://github.com/napi-rs/napi-rs/compare/napi@2.16.4...napi@2.16.5

</details>

<details>
<summary>rust-num/num-bigint (num-bigint)</summary>

###
[`v0.4.5`](https://togithub.com/rust-num/num-bigint/blob/HEAD/RELEASES.md#Release-045-2024-05-06)

[Compare
Source](https://togithub.com/rust-num/num-bigint/compare/num-bigint-0.4.4...num-bigint-0.4.5)

-   [Upgrade to 2021 edition, **MSRV 1.60**][292]
-   [Add `const ZERO` and implement `num_traits::ConstZero`][298]
-   [Add `modinv` methods for the modular inverse][288]
-   [Optimize multiplication with imbalanced operands][295]
-   [Optimize scalar division on x86 and x86-64][236]

**Contributors**: [@&#8203;cuviper](https://togithub.com/cuviper),
[@&#8203;joelonsql](https://togithub.com/joelonsql),
[@&#8203;waywardmonkeys](https://togithub.com/waywardmonkeys)

[236]: https://togithub.com/rust-num/num-bigint/pull/236

[288]: https://togithub.com/rust-num/num-bigint/pull/288

[292]: https://togithub.com/rust-num/num-bigint/pull/292

[295]: https://togithub.com/rust-num/num-bigint/pull/295

[298]: https://togithub.com/rust-num/num-bigint/pull/298

</details>

<details>
<summary>petgraph/petgraph (petgraph)</summary>

###
[`v0.6.5`](https://togithub.com/petgraph/petgraph/blob/HEAD/RELEASES.rst#Version-065-2024-05-06)

[Compare
Source](https://togithub.com/petgraph/petgraph/compare/petgraph@v0.6.4...petgraph@v0.6.5)

\==========================

-   Add rayon support for `GraphMap` (`#573`*, `#615`*)
-   Add `Topo::with_initials` method (`#585`\_)
-   Add logo to the project (`#598`\_)
-   Add Ford-Fulkerson algorithm (`#640`\_)
-   Update `itertools` to 0.12.1 (`#628`\_)
-   Update `GraphMap` to allow custom hash functions (`#623`\_)
-   Fix documentation (`#630`\_)
-   Fix clippy warnings (`#627`\_)
-   (internal) Fix remove old `copyclone` macro (`#601`\_)
-   (internal) Move minimum spanning tree into own module (`#624`\_)

.. \_`#573`:
[petgraph/petgraph#573
.. \_`#615`:
[petgraph/petgraph#615
.. \_`#585`:
[petgraph/petgraph#585
.. \_`#598`:
[petgraph/petgraph#598
.. \_`#640`:
[petgraph/petgraph#640
.. \_`#628`:
[petgraph/petgraph#628
.. \_`#623`:
[petgraph/petgraph#623
.. \_`#630`:
[petgraph/petgraph#630
.. \_`#627`:
[petgraph/petgraph#627
.. \_`#601`:
[petgraph/petgraph#601
.. \_`#624`:
[petgraph/petgraph#624

</details>

<details>
<summary>dtolnay/proc-macro2 (proc-macro2)</summary>

###
[`v1.0.82`](https://togithub.com/dtolnay/proc-macro2/releases/tag/1.0.82)

[Compare
Source](https://togithub.com/dtolnay/proc-macro2/compare/1.0.81...1.0.82)

- Resolve unexpected_cfgs warning
([#&#8203;456](https://togithub.com/dtolnay/proc-macro2/issues/456))

</details>

<details>
<summary>serde-rs/serde (serde)</summary>

###
[`v1.0.201`](https://togithub.com/serde-rs/serde/releases/tag/v1.0.201)

[Compare
Source](https://togithub.com/serde-rs/serde/compare/v1.0.200...v1.0.201)

- Resolve unexpected_cfgs warning
([#&#8203;2737](https://togithub.com/serde-rs/serde/issues/2737))

</details>

<details>
<summary>serde-rs/json (serde_json)</summary>

###
[`v1.0.117`](https://togithub.com/serde-rs/json/releases/tag/v1.0.117)

[Compare
Source](https://togithub.com/serde-rs/json/compare/v1.0.116...v1.0.117)

- Resolve unexpected_cfgs warning
([#&#8203;1130](https://togithub.com/serde-rs/json/issues/1130))

</details>

<details>
<summary>dtolnay/trybuild (trybuild)</summary>

###
[`v1.0.95`](https://togithub.com/dtolnay/trybuild/releases/tag/1.0.95)

[Compare
Source](https://togithub.com/dtolnay/trybuild/compare/1.0.94...1.0.95)

- Keep long type names in diagnostics so that test output does not vary
depending on the length of the absolute filepath of the crate
([#&#8203;269](https://togithub.com/dtolnay/trybuild/issues/269))

###
[`v1.0.94`](https://togithub.com/dtolnay/trybuild/releases/tag/1.0.94)

[Compare
Source](https://togithub.com/dtolnay/trybuild/compare/1.0.93...1.0.94)

- Resolve unexpected_cfgs warning
([#&#8203;268](https://togithub.com/dtolnay/trybuild/issues/268))

</details>

---

### Configuration

📅 **Schedule**: Branch creation - "before 4am on monday" in timezone
Asia/Shanghai, Automerge - At any time (no schedule defined).

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

👻 **Immortal**: This PR will be recreated if closed unmerged. Get
[config help](https://togithub.com/renovatebot/renovate/discussions) if
that's undesired.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View
repository job log
[here](https://developer.mend.io/github/oxc-project/oxc).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4zNTEuMiIsInVwZGF0ZWRJblZlciI6IjM3LjM1MS4yIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6W119-->

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-linter Area - Linter A-minifier Area - Minifier A-printer Area - Printer A-semantic Area - Semantic
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants