aboutsummaryrefslogtreecommitdiffstats
path: root/crates/atuin-common
diff options
context:
space:
mode:
authorEllie Huxtable <ellie@atuin.sh>2025-03-19 12:44:20 +0000
committerGitHub <noreply@github.com>2025-03-19 12:44:20 +0000
commit14ec768b4520d4fc34dbf24e663ea7db940c18b7 (patch)
treea37db707ab8676cad5b3e6ca47af3f2997958906 /crates/atuin-common
parentfeat: Use readline binding for ctrl-a when it is not the prefix (#2626) (diff)
downloadatuin-14ec768b4520d4fc34dbf24e663ea7db940c18b7.zip
chore: migrate to rust 2024 (#2635)
* chore: upgrade to 2024 edition * ugh unsafe * format * nixxxxxxxxxxx why
Diffstat (limited to 'crates/atuin-common')
-rw-r--r--crates/atuin-common/Cargo.toml2
-rw-r--r--crates/atuin-common/src/lib.rs2
-rw-r--r--crates/atuin-common/src/shell.rs2
-rw-r--r--crates/atuin-common/src/utils.rs41
4 files changed, 30 insertions, 17 deletions
diff --git a/crates/atuin-common/Cargo.toml b/crates/atuin-common/Cargo.toml
index af255ead..2ca4aa67 100644
--- a/crates/atuin-common/Cargo.toml
+++ b/crates/atuin-common/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "atuin-common"
-edition = "2021"
+edition = "2024"
description = "common library for atuin"
rust-version = { workspace = true }
diff --git a/crates/atuin-common/src/lib.rs b/crates/atuin-common/src/lib.rs
index 9a94aa62..a776f09a 100644
--- a/crates/atuin-common/src/lib.rs
+++ b/crates/atuin-common/src/lib.rs
@@ -1,4 +1,4 @@
-#![forbid(unsafe_code)]
+#![deny(unsafe_code)]
/// Defines a new UUID type wrapper
macro_rules! new_uuid {
diff --git a/crates/atuin-common/src/shell.rs b/crates/atuin-common/src/shell.rs
index 32da6a8d..0d495369 100644
--- a/crates/atuin-common/src/shell.rs
+++ b/crates/atuin-common/src/shell.rs
@@ -1,7 +1,7 @@
use std::{ffi::OsStr, path::Path, process::Command};
use serde::Serialize;
-use sysinfo::{get_current_pid, Process, System};
+use sysinfo::{Process, System, get_current_pid};
use thiserror::Error;
#[derive(PartialEq)]
diff --git a/crates/atuin-common/src/utils.rs b/crates/atuin-common/src/utils.rs
index d495de36..9a84c31b 100644
--- a/crates/atuin-common/src/utils.rs
+++ b/crates/atuin-common/src/utils.rs
@@ -2,9 +2,9 @@ use std::borrow::Cow;
use std::env;
use std::path::PathBuf;
-use eyre::{eyre, Result};
+use eyre::{Result, eyre};
-use base64::prelude::{Engine, BASE64_URL_SAFE_NO_PAD};
+use base64::prelude::{BASE64_URL_SAFE_NO_PAD, Engine};
use getrandom::getrandom;
use uuid::Uuid;
@@ -194,6 +194,7 @@ pub fn unquote(s: &str) -> Result<String> {
impl<T: AsRef<str>> Escapable for T {}
+#[allow(unsafe_code)]
#[cfg(test)]
mod tests {
use pretty_assertions::assert_ne;
@@ -214,36 +215,48 @@ mod tests {
}
fn test_config_dir_xdg() {
- env::remove_var("HOME");
- env::set_var("XDG_CONFIG_HOME", "/home/user/custom_config");
+ // TODO: Audit that the environment access only happens in single-threaded code.
+ unsafe { env::remove_var("HOME") };
+ // TODO: Audit that the environment access only happens in single-threaded code.
+ unsafe { env::set_var("XDG_CONFIG_HOME", "/home/user/custom_config") };
assert_eq!(
config_dir(),
PathBuf::from("/home/user/custom_config/atuin")
);
- env::remove_var("XDG_CONFIG_HOME");
+ // TODO: Audit that the environment access only happens in single-threaded code.
+ unsafe { env::remove_var("XDG_CONFIG_HOME") };
}
fn test_config_dir() {
- env::set_var("HOME", "/home/user");
- env::remove_var("XDG_CONFIG_HOME");
+ // TODO: Audit that the environment access only happens in single-threaded code.
+ unsafe { env::set_var("HOME", "/home/user") };
+ // TODO: Audit that the environment access only happens in single-threaded code.
+ unsafe { env::remove_var("XDG_CONFIG_HOME") };
assert_eq!(config_dir(), PathBuf::from("/home/user/.config/atuin"));
- env::remove_var("HOME");
+ // TODO: Audit that the environment access only happens in single-threaded code.
+ unsafe { env::remove_var("HOME") };
}
fn test_data_dir_xdg() {
- env::remove_var("HOME");
- env::set_var("XDG_DATA_HOME", "/home/user/custom_data");
+ // TODO: Audit that the environment access only happens in single-threaded code.
+ unsafe { env::remove_var("HOME") };
+ // TODO: Audit that the environment access only happens in single-threaded code.
+ unsafe { env::set_var("XDG_DATA_HOME", "/home/user/custom_data") };
assert_eq!(data_dir(), PathBuf::from("/home/user/custom_data/atuin"));
- env::remove_var("XDG_DATA_HOME");
+ // TODO: Audit that the environment access only happens in single-threaded code.
+ unsafe { env::remove_var("XDG_DATA_HOME") };
}
fn test_data_dir() {
- env::set_var("HOME", "/home/user");
- env::remove_var("XDG_DATA_HOME");
+ // TODO: Audit that the environment access only happens in single-threaded code.
+ unsafe { env::set_var("HOME", "/home/user") };
+ // TODO: Audit that the environment access only happens in single-threaded code.
+ unsafe { env::remove_var("XDG_DATA_HOME") };
assert_eq!(data_dir(), PathBuf::from("/home/user/.local/share/atuin"));
- env::remove_var("HOME");
+ // TODO: Audit that the environment access only happens in single-threaded code.
+ unsafe { env::remove_var("HOME") };
}
#[test]