Skip to content

Commit

Permalink
Merge pull request #617 from immunant/kkysen/lazy-static-to-once-cell
Browse files Browse the repository at this point in the history
Replace `lazy_static!` with `once_cell::sync::Lazy`
  • Loading branch information
kkysen committed Aug 20, 2022
2 parents 5c838db + 48cda95 commit e222e9b
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dynamic_instrumentation/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ bincode = "1.0.1"
c2rust-analysis-rt = { path = "../analysis/runtime"}
indexmap = "1.8"
itertools = "0.10"
lazy_static = "1.4"
once_cell = "1.13"
log = "0.4"
fs-err = "2"
clap = { version = "3.2", features = ["derive"] }
Expand Down
8 changes: 2 additions & 6 deletions dynamic_instrumentation/src/callbacks.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use once_cell::sync::Lazy;
use rustc_ast::ast::{Item, ItemKind, Visibility, VisibilityKind};
use rustc_ast::node_id::NodeId;
use rustc_ast::ptr::P;
Expand All @@ -13,14 +14,9 @@ use rustc_span::def_id::LocalDefId;
use rustc_span::symbol::Ident;
use rustc_span::DUMMY_SP;

use lazy_static::lazy_static;

use crate::instrument::Instrumenter;

lazy_static! {
/// TODO(kkysen) can be made non-lazy when `Mutex::new` is `const` in rust 1.63
pub static ref INSTRUMENTER: Instrumenter = Instrumenter::new();
}
pub static INSTRUMENTER: Lazy<Instrumenter> = Lazy::new(Instrumenter::new);

pub struct MirTransformCallbacks;

Expand Down
2 changes: 0 additions & 2 deletions dynamic_instrumentation/src/instrument.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ impl Instrumenter {
/// A single [`Instrumenter`] instance should be shared across the
/// entire crate being instrumented, as the indexed source locations are
/// shared and should be global.
///
/// TODO(kkysen) can be made `const` when `Mutex::new` is `const` in rust 1.63
pub fn new() -> Self {
Self::default()
}
Expand Down

0 comments on commit e222e9b

Please sign in to comment.