Skip to content

Commit

Permalink
lint: fix nursery clippy::option_if_let_else
Browse files Browse the repository at this point in the history
  • Loading branch information
willbush committed Oct 30, 2024
1 parent c5321bc commit a552a0d
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 28 deletions.
17 changes: 9 additions & 8 deletions src/eval.rs
Original file line number Diff line number Diff line change
Expand Up @@ -315,14 +315,15 @@ fn by_name(
// Though this gets detected by checking whether the internal
// `_internalCallByNamePackageFile` was used
DefinitionVariant::AutoDefinition => {
if let Some(_location) = location {
// Such an automatic definition should definitely not have a location.
// Having one indicates that somebody is using
// `_internalCallByNamePackageFile`,
npv_102::ByNameInternalCallPackageUsed::new(attribute_name).into()
} else {
Success(Tight)
}
location.map_or_else(
|| Success(Tight),
|_location| {
// Such an automatic definition should definitely not have a location.
// Having one indicates that somebody is using
// `_internalCallByNamePackageFile`,
npv_102::ByNameInternalCallPackageUsed::new(attribute_name).into()
},
)
}
// The attribute is manually defined, e.g. in `all-packages.nix`.
// This means we need to enforce it to look like this:
Expand Down
8 changes: 3 additions & 5 deletions src/problem/npv_160.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,9 @@ impl fmt::Display for TopLevelPackageMovedOutOfByName {
file,
} = self;
let relative_package_file = structure::relative_file_for_package(package_name);
let call_package_arg = if let Some(path) = call_package_path {
format!("./{path}")
} else {
"...".into()
};
let call_package_arg = call_package_path
.as_ref()
.map_or_else(|| "...".into(), |path| format!("./{path}"));
writedoc!(
f,
"
Expand Down
8 changes: 3 additions & 5 deletions src/problem/npv_161.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,9 @@ impl fmt::Display for TopLevelPackageMovedOutOfByNameWithCustomArguments {
file,
} = self;
let relative_package_file = structure::relative_file_for_package(package_name);
let call_package_arg = if let Some(path) = call_package_path {
format!("./{path}")
} else {
"...".into()
};
let call_package_arg = call_package_path
.as_ref()
.map_or_else(|| "...".into(), |path| format!("./{path}"));
writedoc!(
f,
"
Expand Down
8 changes: 3 additions & 5 deletions src/problem/npv_162.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,9 @@ impl fmt::Display for NewTopLevelPackageShouldBeByName {
file,
} = self;
let relative_package_file = structure::relative_file_for_package(package_name);
let call_package_arg = if let Some(path) = call_package_path {
format!("./{path}")
} else {
"...".into()
};
let call_package_arg = call_package_path
.as_ref()
.map_or_else(|| "...".into(), |path| format!("./{path}"));
writedoc!(
f,
"
Expand Down
8 changes: 3 additions & 5 deletions src/problem/npv_163.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,9 @@ impl fmt::Display for NewTopLevelPackageShouldBeByNameWithCustomArgument {
file,
} = self;
let relative_package_file = structure::relative_file_for_package(package_name);
let call_package_arg = if let Some(path) = call_package_path {
format!("./{path}")
} else {
"...".into()
};
let call_package_arg = call_package_path
.as_ref()
.map_or_else(|| "...".into(), |path| format!("./{path}"));
writedoc!(
f,
"
Expand Down

0 comments on commit a552a0d

Please sign in to comment.