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

Replace lazy_static! with once_cell::sync::Lazy #617

Merged
merged 1 commit into from
Aug 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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