Skip to content

Commit

Permalink
lint: fix clippy::option_if_let_else
Browse files Browse the repository at this point in the history
  • Loading branch information
willbush committed Nov 8, 2024
1 parent 929a268 commit ff1d86a
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 30 deletions.
17 changes: 7 additions & 10 deletions src/eval.rs
Original file line number Diff line number Diff line change
Expand Up @@ -314,16 +314,13 @@ fn by_name(
// An automatic `callPackage` by the `pkgs/by-name` overlay.
// 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)
}
}
DefinitionVariant::AutoDefinition => location.map_or_else(
|| Success(Tight),
// Such an automatic definition should definitely not have a location.
// Having one indicates that somebody is using
// `_internalCallByNamePackageFile`,
|_location| 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:
// callPackage ../pkgs/by-name/fo/foo/package.nix { ... }
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 ff1d86a

Please sign in to comment.