Skip to content

Commit ddb96ed

Browse files
authored
chore: update to rust 1.97 (#3617)
Updates across the board, and also fix the clippy issues that came up ## Checks - [ ] I am happy for maintainers to push small adjustments to this PR, to speed up the review cycle - [ ] I have checked that there are no existing pull requests for the same thing
1 parent e075ee8 commit ddb96ed

15 files changed

Lines changed: 134 additions & 129 deletions

File tree

.github/workflows/rust.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
- name: Install rust
2727
uses: dtolnay/rust-toolchain@master
2828
with:
29-
toolchain: 1.96.1
29+
toolchain: 1.97.0
3030

3131
- uses: actions/cache@v5
3232
with:
@@ -97,7 +97,7 @@ jobs:
9797
- name: Install rust
9898
uses: dtolnay/rust-toolchain@master
9999
with:
100-
toolchain: 1.96.1
100+
toolchain: 1.97.0
101101

102102
- uses: taiki-e/install-action@v2
103103
name: Install nextest
@@ -127,7 +127,7 @@ jobs:
127127
- name: Install rust
128128
uses: dtolnay/rust-toolchain@master
129129
with:
130-
toolchain: 1.96.1
130+
toolchain: 1.97.0
131131

132132
- uses: actions/cache@v5
133133
with:
@@ -171,7 +171,7 @@ jobs:
171171
- name: Install rust
172172
uses: dtolnay/rust-toolchain@master
173173
with:
174-
toolchain: 1.96.1
174+
toolchain: 1.97.0
175175

176176
- uses: taiki-e/install-action@v2
177177
name: Install nextest
@@ -200,7 +200,7 @@ jobs:
200200
- name: Install latest rust
201201
uses: dtolnay/rust-toolchain@master
202202
with:
203-
toolchain: 1.96.1
203+
toolchain: 1.97.0
204204
components: clippy
205205

206206
- uses: actions/cache@v5
@@ -223,7 +223,7 @@ jobs:
223223
- name: Install latest rust
224224
uses: dtolnay/rust-toolchain@master
225225
with:
226-
toolchain: 1.96.1
226+
toolchain: 1.97.0
227227
components: rustfmt
228228

229229
- name: Format

AGENTS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ atuin-server-sqlite SQLite implementation (sqlx)
4141

4242
## Conventions
4343

44-
- Rust 2024 edition, toolchain 1.93.1.
44+
- Rust 2024 edition, toolchain 1.97.0.
4545
- Errors: `eyre::Result` in binaries, `thiserror` for typed errors in libraries.
4646
- Derive boilerplate: `derive_more` (workspace dep) for `Display`, `From`, `Into`, `AsRef`, `Deref`, `Debug` on newtypes and simple enums. Prefer `derive_more` over manual `impl` when the formatting/conversion is a straight delegation. Use `thiserror` (not `derive_more`) for error types. Use `#[as_ref(str)]` on string newtypes for `AsRef<str>`.
4747
- Async: tokio. Client uses `current_thread`; server uses `multi_thread`.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ exclude = ["ui/backend", "crates/atuin-nucleo/matcher/fuzz"]
1111
[workspace.package]
1212
version = "18.17.0"
1313
authors = ["Ellie Huxtable <ellie@atuin.sh>"]
14-
rust-version = "1.96.1"
14+
rust-version = "1.97.0"
1515
license = "MIT"
1616
homepage = "https://atuin.sh"
1717
repository = "https://github.com/atuinsh/atuin"

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM lukemathwalker/cargo-chef:latest-rust-1.96.1-slim-bookworm AS chef
1+
FROM lukemathwalker/cargo-chef:latest-rust-1.97.0-slim-bookworm AS chef
22
WORKDIR app
33

44
FROM chef AS planner

crates/atuin-client/src/database.rs

Lines changed: 91 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -1012,6 +1012,97 @@ impl SqlBuilderExt for SqlBuilder {
10121012
}
10131013
}
10141014

1015+
pub struct QueryTokenizer<'a> {
1016+
query: &'a str,
1017+
last_pos: usize,
1018+
}
1019+
1020+
pub enum QueryToken<'a> {
1021+
Match(&'a str, bool),
1022+
MatchStart(&'a str, bool),
1023+
MatchEnd(&'a str, bool),
1024+
MatchFull(&'a str, bool),
1025+
Or,
1026+
Regex(&'a str),
1027+
}
1028+
1029+
impl<'a> QueryToken<'a> {
1030+
pub fn has_uppercase(&self) -> bool {
1031+
match self {
1032+
Self::Match(term, _)
1033+
| Self::MatchStart(term, _)
1034+
| Self::MatchEnd(term, _)
1035+
| Self::MatchFull(term, _) => term.contains(char::is_uppercase),
1036+
_ => false,
1037+
}
1038+
}
1039+
1040+
pub fn is_inverse(&self) -> bool {
1041+
match self {
1042+
Self::Match(_, inv)
1043+
| Self::MatchStart(_, inv)
1044+
| Self::MatchEnd(_, inv)
1045+
| Self::MatchFull(_, inv) => *inv,
1046+
_ => false,
1047+
}
1048+
}
1049+
}
1050+
1051+
impl<'a> QueryTokenizer<'a> {
1052+
pub fn new(query: &'a str) -> Self {
1053+
Self { query, last_pos: 0 }
1054+
}
1055+
}
1056+
1057+
impl<'a> Iterator for QueryTokenizer<'a> {
1058+
type Item = QueryToken<'a>;
1059+
fn next(&mut self) -> Option<Self::Item> {
1060+
let remaining = &self.query[self.last_pos..];
1061+
if remaining.is_empty() {
1062+
return None;
1063+
}
1064+
1065+
if let Some(remaining) = remaining.strip_prefix("r/") {
1066+
let (regex, next_pos) = if let Some(end) = remaining.find("/ ") {
1067+
(&remaining[..end], self.last_pos + 2 + end + 2)
1068+
} else if let Some(remaining) = remaining.strip_suffix('/') {
1069+
(remaining, self.query.len())
1070+
} else {
1071+
(remaining, self.query.len())
1072+
};
1073+
self.last_pos = next_pos;
1074+
Some(QueryToken::Regex(regex))
1075+
} else {
1076+
let (mut part, next_pos) = if let Some(sp) = remaining.find(' ') {
1077+
(&remaining[..sp], self.last_pos + sp + 1)
1078+
} else {
1079+
(remaining, self.query.len())
1080+
};
1081+
self.last_pos = next_pos;
1082+
1083+
if part == "|" {
1084+
return Some(QueryToken::Or);
1085+
}
1086+
1087+
let mut is_inverse = false;
1088+
if let Some(s) = part.strip_prefix('!') {
1089+
part = s;
1090+
is_inverse = true;
1091+
}
1092+
let token = if let Some(s) = part.strip_prefix('^') {
1093+
QueryToken::MatchStart(s, is_inverse)
1094+
} else if let Some(s) = part.strip_suffix('$') {
1095+
QueryToken::MatchEnd(s, is_inverse)
1096+
} else if let Some(s) = part.strip_prefix('\'') {
1097+
QueryToken::MatchFull(s, is_inverse)
1098+
} else {
1099+
QueryToken::Match(part, is_inverse)
1100+
};
1101+
Some(token)
1102+
}
1103+
}
1104+
}
1105+
10151106
#[cfg(test)]
10161107
mod test {
10171108
use crate::settings::test_local_timeout;
@@ -1477,94 +1568,3 @@ mod test {
14771568
assert!(duration < Duration::from_secs(15));
14781569
}
14791570
}
1480-
1481-
pub struct QueryTokenizer<'a> {
1482-
query: &'a str,
1483-
last_pos: usize,
1484-
}
1485-
1486-
pub enum QueryToken<'a> {
1487-
Match(&'a str, bool),
1488-
MatchStart(&'a str, bool),
1489-
MatchEnd(&'a str, bool),
1490-
MatchFull(&'a str, bool),
1491-
Or,
1492-
Regex(&'a str),
1493-
}
1494-
1495-
impl<'a> QueryToken<'a> {
1496-
pub fn has_uppercase(&self) -> bool {
1497-
match self {
1498-
Self::Match(term, _)
1499-
| Self::MatchStart(term, _)
1500-
| Self::MatchEnd(term, _)
1501-
| Self::MatchFull(term, _) => term.contains(char::is_uppercase),
1502-
_ => false,
1503-
}
1504-
}
1505-
1506-
pub fn is_inverse(&self) -> bool {
1507-
match self {
1508-
Self::Match(_, inv)
1509-
| Self::MatchStart(_, inv)
1510-
| Self::MatchEnd(_, inv)
1511-
| Self::MatchFull(_, inv) => *inv,
1512-
_ => false,
1513-
}
1514-
}
1515-
}
1516-
1517-
impl<'a> QueryTokenizer<'a> {
1518-
pub fn new(query: &'a str) -> Self {
1519-
Self { query, last_pos: 0 }
1520-
}
1521-
}
1522-
1523-
impl<'a> Iterator for QueryTokenizer<'a> {
1524-
type Item = QueryToken<'a>;
1525-
fn next(&mut self) -> Option<Self::Item> {
1526-
let remaining = &self.query[self.last_pos..];
1527-
if remaining.is_empty() {
1528-
return None;
1529-
}
1530-
1531-
if let Some(remaining) = remaining.strip_prefix("r/") {
1532-
let (regex, next_pos) = if let Some(end) = remaining.find("/ ") {
1533-
(&remaining[..end], self.last_pos + 2 + end + 2)
1534-
} else if let Some(remaining) = remaining.strip_suffix('/') {
1535-
(remaining, self.query.len())
1536-
} else {
1537-
(remaining, self.query.len())
1538-
};
1539-
self.last_pos = next_pos;
1540-
Some(QueryToken::Regex(regex))
1541-
} else {
1542-
let (mut part, next_pos) = if let Some(sp) = remaining.find(' ') {
1543-
(&remaining[..sp], self.last_pos + sp + 1)
1544-
} else {
1545-
(remaining, self.query.len())
1546-
};
1547-
self.last_pos = next_pos;
1548-
1549-
if part == "|" {
1550-
return Some(QueryToken::Or);
1551-
}
1552-
1553-
let mut is_inverse = false;
1554-
if let Some(s) = part.strip_prefix('!') {
1555-
part = s;
1556-
is_inverse = true;
1557-
}
1558-
let token = if let Some(s) = part.strip_prefix('^') {
1559-
QueryToken::MatchStart(s, is_inverse)
1560-
} else if let Some(s) = part.strip_suffix('$') {
1561-
QueryToken::MatchEnd(s, is_inverse)
1562-
} else if let Some(s) = part.strip_prefix('\'') {
1563-
QueryToken::MatchFull(s, is_inverse)
1564-
} else {
1565-
QueryToken::Match(part, is_inverse)
1566-
};
1567-
Some(token)
1568-
}
1569-
}
1570-
}

crates/atuin-common/src/shell.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,7 @@ impl Shell {
5858
}
5959

6060
pub fn config_file(&self) -> Option<std::path::PathBuf> {
61-
let mut path = if let Some(base) = directories::BaseDirs::new() {
62-
base.home_dir().to_owned()
63-
} else {
64-
return None;
65-
};
61+
let mut path = directories::BaseDirs::new()?.home_dir().to_owned();
6662

6763
// TODO: handle all shells
6864
match self {

crates/atuin-common/src/utils.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ mod tests {
363363

364364
// should resolve to the main repo root, not the worktree root
365365
let result = in_git_repo(worktree_subdir.to_str().unwrap());
366-
assert_eq!(result, Some(main_repo.clone()));
366+
assert_eq!(result, Some(main_repo));
367367

368368
std::fs::remove_dir_all(&tmp).unwrap();
369369
}

crates/atuin-daemon/src/client.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ impl HistoryClient {
8585
.wrap_err_with(|| {
8686
format!(
8787
"failed to connect to local atuin daemon at {}. Is it running?",
88-
&log_path
88+
log_path
8989
)
9090
})?;
9191

@@ -185,7 +185,7 @@ impl SearchClient {
185185
.wrap_err_with(|| {
186186
format!(
187187
"failed to connect to local atuin daemon at {}. Is it running?",
188-
&log_path
188+
log_path
189189
)
190190
})?;
191191

@@ -286,7 +286,7 @@ impl SemanticClient {
286286
.wrap_err_with(|| {
287287
format!(
288288
"failed to connect to local atuin daemon at {}. Is it running?",
289-
&log_path
289+
log_path
290290
)
291291
})?;
292292

@@ -380,7 +380,7 @@ impl ControlClient {
380380
.wrap_err_with(|| {
381381
format!(
382382
"failed to connect to local atuin daemon at {}. Is it running?",
383-
&log_path
383+
log_path
384384
)
385385
})?;
386386

crates/atuin-nucleo/src/boxcar.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -780,7 +780,7 @@ mod tests {
780780
fn extend_over_max_capacity() {
781781
let vec = Vec::<u32>::with_capacity(1, 1);
782782
let count = MAX_ENTRIES as usize + 2;
783-
let iter = std::iter::repeat(0).take(count);
783+
let iter = std::iter::repeat_n(0, count);
784784
assert!(std::panic::catch_unwind(|| vec.extend(iter, |_, _| {})).is_err());
785785
}
786786
}

crates/atuin/src/command/client/search/inspector.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -386,8 +386,8 @@ mod tests {
386386
deleted_at: None,
387387
};
388388
let stats = HistoryStats {
389-
next: Some(next.clone()),
390-
previous: Some(prev.clone()),
389+
next: Some(next),
390+
previous: Some(prev),
391391
total: 2,
392392
average_duration: 3,
393393
exits: Vec::new(),
@@ -406,10 +406,10 @@ mod tests {
406406
let prev = stats.previous.clone().unwrap();
407407
let next = stats.next.clone().unwrap();
408408

409-
let mut manager = ThemeManager::new(Some(true), Some("".to_string()));
409+
let mut manager = ThemeManager::new(Some(true), Some(String::new()));
410410
let theme = manager.load_theme("(none)", None);
411-
let _ = terminal.draw(|f| draw_ultracompact(f, chunk, &history, &stats, &theme));
412-
let mut lines = [" "; 5].map(|l| Line::from(l));
411+
let _ = terminal.draw(|f| draw_ultracompact(f, chunk, &history, &stats, theme));
412+
let mut lines = [" "; 5].map(Line::from);
413413
for (n, entry) in [prev, history, next].iter().enumerate() {
414414
let mut l = lines[n].to_string();
415415
l.replace_range(0..entry.command.len(), &entry.command);

0 commit comments

Comments
 (0)