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

Open
wants to merge 1 commit into
base: main
Choose a base branch
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

…e_cell::sync::OnceCell` -> `std::sync::OnceLock`
@@ -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#"^\[['"](.+)[\['"]\]$"#);

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.

2 participants