mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-26 13:03:31 +00:00
switch to once_cell from lazy_static
This commit is contained in:
parent
70cd5ffbf5
commit
1667b5cf52
5 changed files with 28 additions and 22 deletions
13
Cargo.lock
generated
13
Cargo.lock
generated
|
@ -873,6 +873,14 @@ name = "numtoa"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "once_cell"
|
||||||
|
version = "0.2.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
dependencies = [
|
||||||
|
"parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "opaque-debug"
|
name = "opaque-debug"
|
||||||
version = "0.2.2"
|
version = "0.2.2"
|
||||||
|
@ -1039,7 +1047,7 @@ dependencies = [
|
||||||
"arrayvec 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)",
|
"arrayvec 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"itertools 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"itertools 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"join_to_string 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
"join_to_string 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"once_cell 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"ra_db 0.1.0",
|
"ra_db 0.1.0",
|
||||||
"ra_fmt 0.1.0",
|
"ra_fmt 0.1.0",
|
||||||
"ra_hir 0.1.0",
|
"ra_hir 0.1.0",
|
||||||
|
@ -1209,7 +1217,7 @@ dependencies = [
|
||||||
name = "ra_prof"
|
name = "ra_prof"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"once_cell 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -2121,6 +2129,7 @@ dependencies = [
|
||||||
"checksum num_cpus 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1a23f0ed30a54abaa0c7e83b1d2d87ada7c3c23078d1d87815af3e3b6385fbba"
|
"checksum num_cpus 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1a23f0ed30a54abaa0c7e83b1d2d87ada7c3c23078d1d87815af3e3b6385fbba"
|
||||||
"checksum number_prefix 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "dbf9993e59c894e3c08aa1c2712914e9e6bf1fcbfc6bef283e2183df345a4fee"
|
"checksum number_prefix 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "dbf9993e59c894e3c08aa1c2712914e9e6bf1fcbfc6bef283e2183df345a4fee"
|
||||||
"checksum numtoa 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b8f8bdf33df195859076e54ab11ee78a1b208382d3a26ec40d142ffc1ecc49ef"
|
"checksum numtoa 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b8f8bdf33df195859076e54ab11ee78a1b208382d3a26ec40d142ffc1ecc49ef"
|
||||||
|
"checksum once_cell 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e7a15c6c8c034b56d2f01b23b98cdbbb622f8de99efad0d93d8ea0e608b36a7e"
|
||||||
"checksum opaque-debug 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "93f5bb2e8e8dec81642920ccff6b61f1eb94fa3020c5a325c9851ff604152409"
|
"checksum opaque-debug 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "93f5bb2e8e8dec81642920ccff6b61f1eb94fa3020c5a325c9851ff604152409"
|
||||||
"checksum ordermap 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "a86ed3f5f244b372d6b1a00b72ef7f8876d0bc6a78a4c9985c53614041512063"
|
"checksum ordermap 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "a86ed3f5f244b372d6b1a00b72ef7f8876d0bc6a78a4c9985c53614041512063"
|
||||||
"checksum owning_ref 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "49a4b8ea2179e6a2e27411d3bca09ca6dd630821cf6894c6c7c8467a8ee7ef13"
|
"checksum owning_ref 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "49a4b8ea2179e6a2e27411d3bca09ca6dd630821cf6894c6c7c8467a8ee7ef13"
|
||||||
|
|
|
@ -5,7 +5,7 @@ version = "0.1.0"
|
||||||
authors = ["rust-analyzer developers"]
|
authors = ["rust-analyzer developers"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
lazy_static = "1.3.0"
|
once_cell = "0.2.0"
|
||||||
join_to_string = "0.1.3"
|
join_to_string = "0.1.3"
|
||||||
itertools = "0.8.0"
|
itertools = "0.8.0"
|
||||||
arrayvec = "0.4.10"
|
arrayvec = "0.4.10"
|
||||||
|
|
|
@ -289,12 +289,10 @@ fn ast_node_from_file_text<N: AstNode>(text: &str) -> TreeArc<N> {
|
||||||
}
|
}
|
||||||
|
|
||||||
mod tokens {
|
mod tokens {
|
||||||
use lazy_static::lazy_static;
|
use once_cell::sync::Lazy;
|
||||||
use ra_syntax::{AstNode, SourceFile, TreeArc, SyntaxToken, SyntaxKind::*};
|
use ra_syntax::{AstNode, SourceFile, TreeArc, SyntaxToken, SyntaxKind::*};
|
||||||
|
|
||||||
lazy_static! {
|
static SOURCE_FILE: Lazy<TreeArc<SourceFile>> = Lazy::new(|| SourceFile::parse(",\n; ;"));
|
||||||
static ref SOURCE_FILE: TreeArc<SourceFile> = SourceFile::parse(",\n; ;");
|
|
||||||
}
|
|
||||||
|
|
||||||
pub(crate) fn comma() -> SyntaxToken<'static> {
|
pub(crate) fn comma() -> SyntaxToken<'static> {
|
||||||
SOURCE_FILE
|
SOURCE_FILE
|
||||||
|
|
|
@ -6,4 +6,4 @@ authors = ["rust-analyzer developers"]
|
||||||
publish = false
|
publish = false
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
lazy_static = "1.3.0"
|
once_cell = "0.2.0"
|
||||||
|
|
|
@ -1,13 +1,14 @@
|
||||||
use std::cell::RefCell;
|
use std::{
|
||||||
use std::time::{Duration, Instant};
|
cell::RefCell,
|
||||||
use std::mem;
|
time::{Duration, Instant},
|
||||||
use std::io::{stderr, Write};
|
mem,
|
||||||
use std::iter::repeat;
|
io::{stderr, Write},
|
||||||
use std::collections::{HashSet};
|
iter::repeat,
|
||||||
use std::default::Default;
|
collections::HashSet,
|
||||||
use std::iter::FromIterator;
|
sync::{RwLock, atomic::{AtomicBool, Ordering}},
|
||||||
use std::sync::{RwLock, atomic::{AtomicBool, Ordering}};
|
};
|
||||||
use lazy_static::lazy_static;
|
|
||||||
|
use once_cell::sync::Lazy;
|
||||||
|
|
||||||
/// Set profiling filter. It specifies descriptions allowed to profile.
|
/// Set profiling filter. It specifies descriptions allowed to profile.
|
||||||
/// This is helpful when call stack has too many nested profiling scopes.
|
/// This is helpful when call stack has too many nested profiling scopes.
|
||||||
|
@ -21,7 +22,7 @@ use lazy_static::lazy_static;
|
||||||
/// ```
|
/// ```
|
||||||
pub fn set_filter(f: Filter) {
|
pub fn set_filter(f: Filter) {
|
||||||
PROFILING_ENABLED.store(f.depth > 0, Ordering::SeqCst);
|
PROFILING_ENABLED.store(f.depth > 0, Ordering::SeqCst);
|
||||||
let set = HashSet::from_iter(f.allowed.iter().cloned());
|
let set: HashSet<_> = f.allowed.iter().cloned().collect();
|
||||||
let mut old = FILTER.write().unwrap();
|
let mut old = FILTER.write().unwrap();
|
||||||
let filter_data = FilterData {
|
let filter_data = FilterData {
|
||||||
depth: f.depth,
|
depth: f.depth,
|
||||||
|
@ -161,9 +162,7 @@ struct FilterData {
|
||||||
|
|
||||||
static PROFILING_ENABLED: AtomicBool = AtomicBool::new(false);
|
static PROFILING_ENABLED: AtomicBool = AtomicBool::new(false);
|
||||||
|
|
||||||
lazy_static! {
|
static FILTER: Lazy<RwLock<FilterData>> = Lazy::new(Default::default);
|
||||||
static ref FILTER: RwLock<FilterData> = RwLock::new(Default::default());
|
|
||||||
}
|
|
||||||
|
|
||||||
thread_local!(static PROFILE_STACK: RefCell<ProfileStack> = RefCell::new(ProfileStack::new()));
|
thread_local!(static PROFILE_STACK: RefCell<ProfileStack> = RefCell::new(ProfileStack::new()));
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue