Skip to content

Commit a9e83a2

Browse files
committed
Merge main into setup-rust-toolchain branch
2 parents 2b53ee8 + e48ab1f commit a9e83a2

File tree

28 files changed

+119
-130
lines changed

28 files changed

+119
-130
lines changed

crates/test-support/src/matchers.rs

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -374,12 +374,15 @@ impl Execs {
374374

375375
let mut matches = 0;
376376

377-
while let Some(..) = {
377+
loop {
378378
if self.diff_lines(a.clone(), e.clone(), true).is_empty() {
379379
matches += 1;
380380
}
381-
a.next()
382-
} {}
381+
382+
if a.next().is_none() {
383+
break;
384+
}
385+
}
383386

384387
if matches == number {
385388
Ok(())
@@ -553,10 +556,10 @@ fn lines_match_works() {
553556
fn find_mismatch<'a>(expected: &'a Value, actual: &'a Value) -> Option<(&'a Value, &'a Value)> {
554557
use serde_json::Value::*;
555558
match (expected, actual) {
556-
(&Number(ref l), &Number(ref r)) if l == r => None,
557-
(&Bool(l), &Bool(r)) if l == r => None,
558-
(&String(ref l), &String(ref r)) if lines_match(l, r) => None,
559-
(&Array(ref l), &Array(ref r)) => {
559+
(Number(l), Number(r)) if l == r => None,
560+
(Bool(l), Bool(r)) if l == r => None,
561+
(String(l), String(r)) if lines_match(l, r) => None,
562+
(Array(l), Array(r)) => {
560563
if l.len() != r.len() {
561564
return Some((expected, actual));
562565
}
@@ -582,20 +585,19 @@ fn find_mismatch<'a>(expected: &'a Value, actual: &'a Value) -> Option<(&'a Valu
582585
None
583586
}
584587
}
585-
(&Object(ref l), &Object(ref r)) => {
588+
(Object(l), Object(r)) => {
586589
let same_keys = l.len() == r.len() && l.keys().all(|k| r.contains_key(k));
587590
if !same_keys {
588591
return Some((expected, actual));
589592
}
590593

591594
l.values()
592595
.zip(r.values())
593-
.filter_map(|(l, r)| find_mismatch(l, r))
594-
.next()
596+
.find_map(|(l, r)| find_mismatch(l, r))
595597
}
596-
(&Null, &Null) => None,
598+
(Null, Null) => None,
597599
// magic string literal "{...}" acts as wildcard for any sub-JSON
598-
(&String(ref l), _) if l == "{...}" => None,
600+
(String(l), _) if l == "{...}" => None,
599601
_ => Some((expected, actual)),
600602
}
601603
}

crates/test-support/src/paths.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ fn global_root() -> PathBuf {
4848

4949
pub fn root() -> PathBuf {
5050
init();
51-
global_root().join(&TASK_ID.with(|my_id| format!("t{}", my_id)))
51+
global_root().join(TASK_ID.with(|my_id| format!("t{}", my_id)))
5252
}
5353

5454
pub fn home() -> PathBuf {
@@ -70,6 +70,8 @@ impl Remove {
7070
fn at(&self, path: &Path) {
7171
if cfg!(windows) {
7272
let mut p = ok_or_panic!(path.metadata()).permissions();
73+
// This lint rule is not applicable: this is in a `cfg!(windows)` block.
74+
#[allow(clippy::permissions_set_readonly_false)]
7375
p.set_readonly(false);
7476
ok_or_panic! { fs::set_permissions(path, p) };
7577
}

crates/volta-core/src/error/reporter.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ fn write_error_log(
5252
let file_name = Local::now()
5353
.format("volta-error-%Y-%m-%d_%H_%M_%S%.3f.log")
5454
.to_string();
55-
let log_file_path = volta_home()?.log_dir().join(&file_name);
55+
let log_file_path = volta_home()?.log_dir().join(file_name);
5656

5757
ensure_containing_dir_exists(&log_file_path)?;
5858
let mut log_file = File::create(&log_file_path)?;

crates/volta-core/src/event.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,8 @@ impl EventLog {
146146
pub fn publish(&self, plugin: Option<&Publish>) {
147147
match plugin {
148148
// Note: This call to unimplemented is left in, as it's not a Fallible operation that can use ErrorKind::Unimplemented
149-
Some(&Publish::Url(_)) => unimplemented!(),
150-
Some(&Publish::Bin(ref command)) => {
149+
Some(Publish::Url(_)) => unimplemented!(),
150+
Some(Publish::Bin(command)) => {
151151
send_events(command, &self.events);
152152
}
153153
None => {}

crates/volta-core/src/fs.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,15 +105,15 @@ where
105105
/// Creates a NamedTempFile in the Volta tmp directory
106106
pub fn create_staging_file() -> Fallible<NamedTempFile> {
107107
let tmp_dir = volta_home()?.tmp_dir();
108-
NamedTempFile::new_in(&tmp_dir).with_context(|| ErrorKind::CreateTempFileError {
108+
NamedTempFile::new_in(tmp_dir).with_context(|| ErrorKind::CreateTempFileError {
109109
in_dir: tmp_dir.to_owned(),
110110
})
111111
}
112112

113113
/// Creates a staging directory in the Volta tmp directory
114114
pub fn create_staging_dir() -> Fallible<TempDir> {
115115
let tmp_root = volta_home()?.tmp_dir();
116-
tempdir_in(&tmp_root).with_context(|| ErrorKind::CreateTempDirError {
116+
tempdir_in(tmp_root).with_context(|| ErrorKind::CreateTempDirError {
117117
in_dir: tmp_root.to_owned(),
118118
})
119119
}

crates/volta-core/src/hook/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -674,7 +674,7 @@ pub mod tests {
674674
let default_hooks_file = fixture_path("hooks/templates.json");
675675

676676
let merged_hooks =
677-
HookConfig::from_paths(&[project_hooks_file, default_hooks_file]).unwrap();
677+
HookConfig::from_paths([project_hooks_file, default_hooks_file]).unwrap();
678678
let node = merged_hooks.node.expect("No node config found");
679679
let pnpm = merged_hooks.pnpm.expect("No pnpm config found");
680680
let yarn = merged_hooks.yarn.expect("No yarn config found");

crates/volta-core/src/inventory.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ pub fn yarn_versions() -> Fallible<BTreeSet<Version>> {
6262
pub fn package_configs() -> Fallible<BTreeSet<PackageConfig>> {
6363
let package_dir = volta_home()?.default_package_dir();
6464

65-
WalkDir::new(&package_dir)
65+
WalkDir::new(package_dir)
6666
.max_depth(2)
6767
.into_iter()
6868
// Ignore any items which didn't resolve as `DirEntry` correctly.
@@ -87,8 +87,8 @@ pub fn package_configs() -> Fallible<BTreeSet<PackageConfig>> {
8787
None
8888
}
8989
})
90-
.map(|file_path| PackageConfig::from_file(&file_path))
91-
.collect::<Fallible<BTreeSet<PackageConfig>>>()
90+
.map(PackageConfig::from_file)
91+
.collect()
9292
}
9393

9494
/// Reads the contents of a directory and returns the set of all versions found

crates/volta-core/src/platform/mod.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -115,10 +115,11 @@ where
115115

116116
/// Represents 3 possible states: Having a value, not having a value, and inheriting a value
117117
#[cfg_attr(test, derive(Eq, PartialEq, Debug))]
118-
#[derive(Clone)]
118+
#[derive(Clone, Default)]
119119
pub enum InheritOption<T> {
120120
Some(T),
121121
None,
122+
#[default]
122123
Inherit,
123124
}
124125

@@ -151,12 +152,6 @@ impl<T> From<InheritOption<T>> for Option<T> {
151152
}
152153
}
153154

154-
impl<T> Default for InheritOption<T> {
155-
fn default() -> Self {
156-
InheritOption::Inherit
157-
}
158-
}
159-
160155
#[derive(Clone, PartialOrd, Ord, PartialEq, Eq)]
161156
#[cfg_attr(test, derive(Debug))]
162157
/// Represents the specification of a single Platform, regardless of the source

crates/volta-core/src/project/serial.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,7 @@ impl Manifest {
2727
pub fn from_file(file: &Path) -> Fallible<Self> {
2828
let raw = RawManifest::from_file(file)?;
2929

30-
let dependency_maps = raw
31-
.dependencies
32-
.into_iter()
33-
.chain(raw.dev_dependencies.into_iter());
30+
let dependency_maps = raw.dependencies.into_iter().chain(raw.dev_dependencies);
3431

3532
let (platform, extends) = match raw.volta {
3633
Some(toolchain) => {
@@ -88,7 +85,7 @@ pub(super) fn update_manifest(
8885
key: ManifestKey,
8986
value: Option<&Version>,
9087
) -> Fallible<()> {
91-
let contents = read_to_string(&file).with_context(|| ErrorKind::PackageReadError {
88+
let contents = read_to_string(file).with_context(|| ErrorKind::PackageReadError {
9289
file: file.to_owned(),
9390
})?;
9491

@@ -121,7 +118,7 @@ pub(super) fn update_manifest(
121118
}
122119

123120
let indent = detect_indent::detect_indent(&contents);
124-
let mut output = File::create(&file).with_context(|| ErrorKind::PackageWriteError {
121+
let mut output = File::create(file).with_context(|| ErrorKind::PackageWriteError {
125122
file: file.to_owned(),
126123
})?;
127124
let formatter = serde_json::ser::PrettyFormatter::with_indent(indent.indent().as_bytes());

0 commit comments

Comments
 (0)