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(cli): once_cell::sync::Lazy -> std::sync::LazyLock, once_cell::sync::OnceCell -> std::sync::OnceLock #25104

Closed
wants to merge 2 commits into from

Conversation

linbingquan
Copy link
Contributor

refactor(cli): once_cell::sync::Lazy -> std::sync::LazyLock, once_cell::sync::OnceCell -> std::sync::OnceLock

link: https://blog.rust-lang.org/2024/07/25/Rust-1.80.0.html#lazycell-and-lazylock

cli/lsp/tsc.rs Outdated
@@ -94,19 +93,28 @@ use tower_lsp::jsonrpc::Error as LspError;
use tower_lsp::jsonrpc::Result as LspResult;
use tower_lsp::lsp_types as lsp;

static BRACKET_ACCESSOR_RE: Lazy<Regex> =
lazy_regex!(r#"^\[['"](.+)[\['"]\]$"#);
Copy link
Member

Choose a reason for hiding this comment

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

Why this change? lazy_regex evaluates the regex at compile time from my understanding and now we're no longer doing that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Why this change? lazy_regex evaluates the regex at compile time from my understanding and now we're no longer doing that.

Because it has this error. Correct me if I am wrong.

error[E0308]: mismatched types
  --> cli\lsp\tsc.rs:98:20
   |
98 |   LazyLock::new(|| lazy_regex!(r#"^\[['"](.+)[\['"]\]$"#));
   |                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Regex`, found `Lazy<_, ...>`
   |
   = note: expected struct `regex::Regex`
              found struct `lazy_regex::Lazy<_, {closure@cli\lsp\tsc.rs:98:20: 98:58}>`
   = note: this error originates in the macro `lazy_regex` (in Nightly builds, run with -Z macro-backtrace for more info)

For more information about this error, try `rustc --explain E0308`.
error: could not compile `deno` (bin "deno") due to 1 previous error

Copy link
Member

Choose a reason for hiding this comment

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

I think it can be changed to:

static BRACKET_ACCESSOR_RE: lazy_regex::Lazy<Regex> =
  lazy_regex!(r#"^\[['"](.+)[\['"]\]$"#);

@bartlomieju
Copy link
Member

@linbingquan if you're still interested in landing this PR can you please rebase it and apply David's suggestion from #25104 (comment)?

@linbingquan
Copy link
Contributor Author

@linbingquan if you're still interested in landing this PR can you please rebase it and apply David's suggestion from #25104 (comment)?

I saw a lot of code that needed to be cut before 2.0 was released, so I didn't do it.

To be honest, I upgraded the Rust 1.81.0 build after the 2.0 release and it failed...

Let me try again.

…e_cell::sync::OnceCell` -> `std::sync::OnceLock`
Copy link
Member

@bartlomieju bartlomieju left a comment

Choose a reason for hiding this comment

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

Would it be possible to remove dependency on once_cell in various crates you changed? Ie. remove it from relevant Cargo.toml files.

@linbingquan
Copy link
Contributor Author

Ie. remove it from relevant Cargo.toml files.

I have a quick look, should not be able to complete the deletion of 'once_cell', 'once_cell' is used elsewhere.

Would it be possible to remove dependency on once_cell in various crates you changed?

I'm sorry, I didn't know what you wanted me to do.

@linbingquan
Copy link
Contributor Author

I now feel that this refactoring is not very necessary, I close this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants