1
1
mirror of https://github.com/oxalica/nil.git synced 2024-11-22 02:55:39 +03:00

Fix clippy warnings

This commit is contained in:
oxalica 2023-10-09 08:48:57 +08:00
parent 510bc6e9b4
commit 2091ef0e1d
2 changed files with 12 additions and 9 deletions

View File

@ -632,8 +632,10 @@ mod tests {
Expr::Literal(Literal::Path(path)) => Some(path),
_ => None,
})
.map(|path| format!("{:?}\n", path.data(&db)))
.collect::<String>();
.fold(String::new(), |mut got, path| {
writeln!(got, "{:?}", path.data(&db)).unwrap();
got
});
expect.assert_eq(&got);
}

View File

@ -4,6 +4,7 @@ use crate::{FlakeInfo, ModuleKind, SourceDatabase, VfsPath};
use expect_test::expect;
use itertools::Itertools;
use std::collections::{HashMap, HashSet};
use std::fmt::Write;
#[test]
fn change_barrier() {
@ -118,19 +119,19 @@ baz/../../bar.nix + ../default.nix
let source_root = db.source_root(sid);
let graph = db.source_root_referrer_graph(sid);
let got = source_root
.files()
.sorted_by_key(|&(f, _)| f)
.map(|(referee, _)| {
let got = source_root.files().sorted_by_key(|&(f, _)| f).fold(
String::new(),
|mut got, (referee, _)| {
let referrers = graph.get(&referee).cloned().unwrap_or_default();
let referee = source_root.path_for_file(referee).display();
let referrers = referrers
.iter()
.map(|&f| source_root.path_for_file(f).display())
.join(", ");
format!("{referee} <- [{referrers}]\n")
})
.collect::<String>();
writeln!(got, "{referee} <- [{referrers}]").unwrap();
got
},
);
expect![[r#"
/default.nix <- [/foo/bar.nix, /bar.nix]
/foo/bar.nix <- [/default.nix]