-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
Conversation
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#"^\[['"](.+)[\['"]\]$"#); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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#"^\[['"](.+)[\['"]\]$"#);
@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 Let me try again. |
…e_cell::sync::OnceCell` -> `std::sync::OnceLock`
70105be
to
cd01920
Compare
There was a problem hiding this 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.
I have a quick look, should not be able to complete the deletion of 'once_cell', 'once_cell' is used elsewhere.
I'm sorry, I didn't know what you wanted me to do. |
I now feel that this refactoring is not very necessary, I close this PR. |
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