Skip to content

Commit 04aca0a

Browse files
authored
Merge pull request #280 from lafrenierejm/rust-2024-stable
Update to Rust 1.85 and edition 2024
2 parents 987648c + 17a5190 commit 04aca0a

17 files changed

+153
-114
lines changed

Cargo.lock

Lines changed: 82 additions & 68 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
21
[package]
32
authors = ["phiresky <[email protected]>"]
43
description = "rga: ripgrep, but also search in PDFs, E-Books, Office documents, zip, tar.gz, etc."
5-
edition = "2021"
4+
edition = "2024"
65
exclude = [
76
"exampledir/*",
87
]

flake.lock

Lines changed: 12 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,16 @@
4141
overlays = [(import rust-overlay)];
4242
};
4343

44-
craneLib = crane.mkLib nixpkgs.legacyPackages.${system};
44+
craneLib =
45+
(crane.mkLib pkgs).overrideToolchain
46+
(p:
47+
(p.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml).override {
48+
extensions = [
49+
"rust-analyzer"
50+
"rust-src"
51+
"rustfmt"
52+
];
53+
});
4554

4655
src = pkgs.lib.cleanSourceWith {
4756
src = craneLib.path ./.;
@@ -94,9 +103,6 @@
94103

95104
rga-doc = craneLib.cargoDoc {inherit cargoArtifacts src;};
96105

97-
# Check formatting
98-
rga-fmt = craneLib.cargoFmt {inherit src;};
99-
100106
# Audit dependencies
101107
rga-audit = craneLib.cargoAudit {inherit src advisory-db;};
102108

@@ -112,7 +118,11 @@
112118
src = ./.;
113119
hooks = {
114120
alejandra.enable = true;
115-
rustfmt.enable = true;
121+
rustfmt = {
122+
enable = true;
123+
packageOverrides.cargo = craneLib.cargo;
124+
packageOverrides.rustfmt = craneLib.rustfmt;
125+
};
116126
typos = {
117127
enable = true;
118128
settings = {
@@ -134,9 +144,11 @@
134144

135145
# `nix develop`
136146
devShells.default = craneLib.devShell {
147+
inherit nativeBuildInputs;
137148
inherit (self.checks.${system}.pre-commit) shellHook;
138149
inputsFrom = builtins.attrValues self.checks;
139-
packages = runtimeInputs ++ nativeBuildInputs;
150+
buildInputs = self.checks.${system}.pre-commit.enabledPackages;
151+
packages = runtimeInputs;
140152
};
141153
});
142154
}

src/adapters.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ pub mod tar;
99
pub mod writing;
1010
pub mod zip;
1111
use crate::{adapted_iter::AdaptedFilesIterBox, config::RgaConfig, matching::*};
12-
use anyhow::{format_err, Context, Result};
12+
use anyhow::{Context, Result, format_err};
1313
use async_trait::async_trait;
14-
use custom::CustomAdapterConfig;
1514
use custom::BUILTIN_SPAWNING_ADAPTERS;
15+
use custom::CustomAdapterConfig;
1616
use log::*;
1717
use tokio::io::AsyncRead;
1818

@@ -57,8 +57,8 @@ impl AdapterMeta {
5757
self.keep_fast_matchers_if_accurate,
5858
&self.slow_matchers,
5959
) {
60-
(true, false, Some(ref sm)) => Box::new(sm.iter().map(Cow::Borrowed)),
61-
(true, true, Some(ref sm)) => Box::new(
60+
(true, false, Some(sm)) => Box::new(sm.iter().map(Cow::Borrowed)),
61+
(true, true, Some(sm)) => Box::new(
6262
sm.iter().map(Cow::Borrowed).chain(
6363
self.fast_matchers
6464
.iter()

src/adapters/decompress.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@ impl GetMetadata for DecompressAdapter {
5252
}
5353

5454
fn decompress_any(reason: &FileMatcher, inp: ReadBox) -> Result<ReadBox> {
55-
use async_compression::tokio::bufread;
5655
use FastFileMatcher::*;
5756
use FileMatcher::*;
57+
use async_compression::tokio::bufread;
5858
let gz = |inp: ReadBox| Box::pin(bufread::GzipDecoder::new(BufReader::new(inp)));
5959
let bz2 = |inp: ReadBox| Box::pin(bufread::BzDecoder::new(BufReader::new(inp)));
6060
let xz = |inp: ReadBox| Box::pin(bufread::XzDecoder::new(BufReader::new(inp)));

src/adapters/mbox.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,10 @@ mod tests {
186186
);
187187
let mut buf = Vec::new();
188188
file.inp.read_to_end(&mut buf).await?;
189-
assert_eq!("<html>\r\n <head>\r\n <meta http-equiv=\"content-type\" content=\"text/html; charset=UTF-8\">\r\n </head>\r\n <body>\r\n <p>&gt;From</p>\r\n <p>Another word &gt;From<br>\r\n </p>\r\n </body>\r\n</html>", String::from_utf8(buf)?.trim());
189+
assert_eq!(
190+
"<html>\r\n <head>\r\n <meta http-equiv=\"content-type\" content=\"text/html; charset=UTF-8\">\r\n </head>\r\n <body>\r\n <p>&gt;From</p>\r\n <p>Another word &gt;From<br>\r\n </p>\r\n </body>\r\n</html>",
191+
String::from_utf8(buf)?.trim()
192+
);
190193
count += 1;
191194
}
192195
assert_eq!(3, count);
@@ -224,7 +227,10 @@ mod tests {
224227
);
225228
}
226229
"short.pdf.txt" => {
227-
assert_eq!("PREFIX:Page 1: hello world\nPREFIX:Page 1: this is just a test.\nPREFIX:Page 1: \nPREFIX:Page 1: 1\nPREFIX:Page 1: \nPREFIX:Page 1: \n", String::from_utf8(buf).unwrap_or("err".to_owned()));
230+
assert_eq!(
231+
"PREFIX:Page 1: hello world\nPREFIX:Page 1: this is just a test.\nPREFIX:Page 1: \nPREFIX:Page 1: 1\nPREFIX:Page 1: \nPREFIX:Page 1: \n",
232+
String::from_utf8(buf).unwrap_or("err".to_owned())
233+
);
228234
}
229235
_ => {
230236
panic!("unrelated {path:?}");

src/adapters/postproc.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ use tokio::io::{AsyncRead, AsyncReadExt};
1717
use tokio_util::io::ReaderStream;
1818
use tokio_util::io::StreamReader;
1919

20-
use crate::adapted_iter::one_file;
2120
use crate::adapted_iter::AdaptedFilesIterBox;
21+
use crate::adapted_iter::one_file;
2222
use crate::matching::FastFileMatcher;
2323

2424
use super::{AdaptInfo, AdapterMeta, FileAdapter, GetMetadata};
@@ -129,7 +129,10 @@ async fn postproc_encoding(
129129
}
130130

131131
/// Adds the given prefix to each line in an `AsyncRead`.
132-
pub fn postproc_prefix(line_prefix: &str, inp: impl AsyncRead + Send) -> impl AsyncRead + Send {
132+
pub fn postproc_prefix<T: AsyncRead + Send>(
133+
line_prefix: &str,
134+
inp: T,
135+
) -> impl AsyncRead + Send + use<T> {
133136
let line_prefix_n = format!("\n{line_prefix}"); // clone since we need it later
134137
let line_prefix_o = Bytes::copy_from_slice(line_prefix.as_bytes());
135138
let regex = regex::bytes::Regex::new("\n").unwrap();

src/adapters/writing.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,20 @@ pub trait WritingFileAdapter: GetMetadata + Send + Sync + Clone {
1717
}
1818

1919
macro_rules! async_writeln {
20-
($dst: expr) => {
20+
($dst: expr_2021) => {
2121
{
2222
tokio::io::AsyncWriteExt::write_all(&mut $dst, b"\n").await
2323
}
2424
};
25-
($dst: expr, $fmt: expr) => {
25+
($dst: expr_2021, $fmt: expr_2021) => {
2626
{
2727
use std::io::Write;
2828
let mut buf = Vec::<u8>::new();
2929
writeln!(buf, $fmt)?;
3030
tokio::io::AsyncWriteExt::write_all(&mut $dst, &buf).await
3131
}
3232
};
33-
($dst: expr, $fmt: expr, $($arg: tt)*) => {
33+
($dst: expr_2021, $fmt: expr_2021, $($arg: tt)*) => {
3434
{
3535
use std::io::Write;
3636
let mut buf = Vec::<u8>::new();

src/adapters/zip.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ impl<'a> AdaptedFilesIter for ZipAdaptIter<'a> {
194194

195195
#[cfg(test)]
196196
mod test {
197-
use async_zip::{write::ZipFileWriter, Compression, ZipEntryBuilder};
197+
use async_zip::{Compression, ZipEntryBuilder, write::ZipFileWriter};
198198

199199
use super::*;
200200
use crate::{preproc::loop_adapt, test_utils::*};

0 commit comments

Comments
 (0)