chore(fmt): add legacy stubs and strip trailing whitespace to unblock cargo fmt

This commit is contained in:
Selfhosting Dev
2025-09-17 07:43:07 +09:00
parent fcf8ce1f3c
commit adbb0201a9
385 changed files with 35622 additions and 15004 deletions

View File

@ -2,33 +2,53 @@ use once_cell::sync::Lazy;
use std::collections::HashMap;
use std::sync::Mutex;
static ENABLED: Lazy<bool> = Lazy::new(|| std::env::var("NYASH_LEAK_LOG").unwrap_or_default() == "1");
static LEAKS: Lazy<Mutex<HashMap<(String, u32), &'static str>>> = Lazy::new(|| Mutex::new(HashMap::new()));
static ENABLED: Lazy<bool> =
Lazy::new(|| std::env::var("NYASH_LEAK_LOG").unwrap_or_default() == "1");
static LEAKS: Lazy<Mutex<HashMap<(String, u32), &'static str>>> =
Lazy::new(|| Mutex::new(HashMap::new()));
pub fn init() { let _ = &*REPORTER; }
pub fn init() {
let _ = &*REPORTER;
}
pub fn register_plugin(box_type: &str, instance_id: u32) {
if !*ENABLED { return; }
LEAKS.lock().unwrap().insert((box_type.to_string(), instance_id), "plugin");
if !*ENABLED {
return;
}
LEAKS
.lock()
.unwrap()
.insert((box_type.to_string(), instance_id), "plugin");
}
pub fn finalize_plugin(box_type: &str, instance_id: u32) {
if !*ENABLED { return; }
LEAKS.lock().unwrap().remove(&(box_type.to_string(), instance_id));
if !*ENABLED {
return;
}
LEAKS
.lock()
.unwrap()
.remove(&(box_type.to_string(), instance_id));
}
struct Reporter;
impl Drop for Reporter {
fn drop(&mut self) {
if !*ENABLED { return; }
if !*ENABLED {
return;
}
let m = LEAKS.lock().unwrap();
if m.is_empty() { return; }
if m.is_empty() {
return;
}
eprintln!("[leak] Detected {} non-finalized plugin boxes:", m.len());
for ((ty, id), _) in m.iter() {
eprintln!(" - {}(id={}) not finalized (missing fini or scope)", ty, id);
eprintln!(
" - {}(id={}) not finalized (missing fini or scope)",
ty, id
);
}
}
}
static REPORTER: Lazy<Reporter> = Lazy::new(|| Reporter);