Skip to content

Commit

Permalink
chore: Fix clippy 1.84 warnings (#12328)
Browse files Browse the repository at this point in the history
  • Loading branch information
FabianLars authored Jan 10, 2025
1 parent b0d7527 commit cde0ff7
Show file tree
Hide file tree
Showing 17 changed files with 704 additions and 750 deletions.
1,392 changes: 673 additions & 719 deletions Cargo.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions crates/tauri-build/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ fn copy_binaries(
.to_string_lossy()
.replace(&format!("-{target_triple}"), "");

if package_name.map_or(false, |n| n == &file_name) {
if package_name == Some(&file_name) {
return Err(anyhow::anyhow!(
"Cannot define a sidecar with the same name as the Cargo package name `{}`. Please change the sidecar name in the filesystem and the Tauri configuration.",
file_name
Expand Down Expand Up @@ -675,7 +675,7 @@ pub fn try_build(attributes: Attributes) -> Result<()> {
}
}
"msvc" => {
if env::var("STATIC_VCRUNTIME").map_or(false, |v| v == "true") {
if env::var("STATIC_VCRUNTIME").is_ok_and(|v| v == "true") {
static_vcruntime::build();
}
}
Expand Down
3 changes: 1 addition & 2 deletions crates/tauri-bundler/src/bundle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,7 @@ pub fn bundle_project(settings: &Settings) -> crate::Result<Vec<Bundle>> {
// Sign the sidecar binaries
for bin in settings.external_binaries() {
let path = bin?;
let skip =
std::env::var("TAURI_SKIP_SIDECAR_SIGNATURE_CHECK").map_or(false, |v| v == "true");
let skip = std::env::var("TAURI_SKIP_SIDECAR_SIGNATURE_CHECK").is_ok_and(|v| v == "true");
if skip {
continue;
}
Expand Down
17 changes: 8 additions & 9 deletions crates/tauri-cli/src/acl/permission/add.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,16 +166,15 @@ pub fn command(options: Options) -> Result<()> {

let capabilities = if let Some((expected_platforms, target_name)) = expected_capability_config {
let mut capabilities = capabilities_iter
.filter(|(capability, _path)| {
capability.platforms().map_or(
false, /* allows any target, so we should skip it since we're adding a target-specific plugin */
|platforms| {
// all platforms must be in the expected platforms list
platforms.iter().all(|p| expected_platforms.contains(&p.to_string()))
},
)
.filter(|(capability, _path)| {
capability.platforms().is_some_and(|platforms| {
// all platforms must be in the expected platforms list
platforms
.iter()
.all(|p| expected_platforms.contains(&p.to_string()))
})
.collect::<Vec<_>>();
})
.collect::<Vec<_>>();

if capabilities.is_empty() {
let identifier = format!("{target_name}-capability");
Expand Down
2 changes: 1 addition & 1 deletion crates/tauri-cli/src/helpers/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ pub fn wix_settings(config: WixConfig) -> tauri_bundler::WixSettings {
enable_elevated_update_task: config.enable_elevated_update_task,
banner_path: config.banner_path,
dialog_image_path: config.dialog_image_path,
fips_compliant: var_os("TAURI_BUNDLER_WIX_FIPS_COMPLIANT").map_or(false, |v| v == "true"),
fips_compliant: var_os("TAURI_BUNDLER_WIX_FIPS_COMPLIANT").is_some_and(|v| v == "true"),
}
}

Expand Down
2 changes: 1 addition & 1 deletion crates/tauri-cli/src/helpers/flock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ mod sys {
}

pub(super) fn error_contended(err: &Error) -> bool {
err.raw_os_error().map_or(false, |x| x == libc::EWOULDBLOCK)
err.raw_os_error() == Some(libc::EWOULDBLOCK)
}

pub(super) fn error_unsupported(err: &Error) -> bool {
Expand Down
4 changes: 2 additions & 2 deletions crates/tauri-cli/src/helpers/pbxproj.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ pub fn parse<P: AsRef<Path>>(path: P) -> crate::Result<Pbxproj> {
State::XCBuildConfigurationObject { id } => {
if line.contains("buildSettings") {
state = State::XCBuildConfigurationObjectBuildSettings { id: id.clone() };
} else if split_at_identation(line).map_or(false, |(_ident, token)| token == "};") {
} else if split_at_identation(line).is_some_and(|(_ident, token)| token == "};") {
state = State::XCBuildConfiguration;
}
}
Expand Down Expand Up @@ -122,7 +122,7 @@ pub fn parse<P: AsRef<Path>>(path: P) -> crate::Result<Pbxproj> {
State::XCConfigurationListObject { id } => {
if line.contains("buildConfigurations") {
state = State::XCConfigurationListObjectBuildConfigurations { id: id.clone() };
} else if split_at_identation(line).map_or(false, |(_ident, token)| token == "};") {
} else if split_at_identation(line).is_some_and(|(_ident, token)| token == "};") {
state = State::XCConfigurationList;
}
}
Expand Down
6 changes: 3 additions & 3 deletions crates/tauri-cli/src/interface/rust.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,9 @@ impl Interface for Rust {
manifest
};

let target_ios = target.as_ref().map_or(false, |target| {
target.ends_with("ios") || target.ends_with("ios-sim")
});
let target_ios = target
.as_ref()
.is_some_and(|target| target.ends_with("ios") || target.ends_with("ios-sim"));
if target_ios {
std::env::set_var(
"IPHONEOS_DEPLOYMENT_TARGET",
Expand Down
2 changes: 1 addition & 1 deletion crates/tauri-cli/src/interface/rust/desktop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ pub fn build(
let out_dir = app_settings.out_dir(&options)?;
let bin_path = app_settings.app_binary_path(&options)?;

if !std::env::var("STATIC_VCRUNTIME").map_or(false, |v| v == "false") {
if !std::env::var("STATIC_VCRUNTIME").is_ok_and(|v| v == "false") {
std::env::set_var("STATIC_VCRUNTIME", "true");
}

Expand Down
2 changes: 1 addition & 1 deletion crates/tauri-cli/src/migrate/migrations/v1/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pub fn migrate(tauri_dir: &Path) -> Result<MigratedConfig> {
tauri_utils_v1::config::parse::parse_value(tauri_dir.join("tauri.conf.json"))
{
let migrated = migrate_config(&mut config)?;
if config_path.extension().map_or(false, |ext| ext == "toml") {
if config_path.extension().is_some_and(|ext| ext == "toml") {
fs::write(&config_path, toml::to_string_pretty(&config)?)?;
} else {
fs::write(&config_path, serde_json::to_string_pretty(&config)?)?;
Expand Down
2 changes: 1 addition & 1 deletion crates/tauri-cli/src/migrate/migrations/v1/frontend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ fn migrate_imports<'a>(

let has_partial_js = path
.extension()
.map_or(false, |ext| ext == "vue" || ext == "svelte");
.is_some_and(|ext| ext == "vue" || ext == "svelte");

let sources = if !has_partial_js {
vec![(SourceType::from_path(path).unwrap(), js_source, 0i64)]
Expand Down
2 changes: 1 addition & 1 deletion crates/tauri-cli/src/migrate/migrations/v2_rc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ fn migrate_permissions(tauri_dir: &Path) -> Result<()> {
for entry in walkdir::WalkDir::new(tauri_dir.join("capabilities")) {
let entry = entry?;
let path = entry.path();
if path.extension().map_or(false, |ext| ext == "json") {
if path.extension().is_some_and(|ext| ext == "json") {
let mut capability = read_to_string(path).context("failed to read capability")?;
for plugin in core_plugins {
capability = capability.replace(&format!("\"{plugin}:"), &format!("\"core:{plugin}:"));
Expand Down
2 changes: 1 addition & 1 deletion crates/tauri-cli/src/mobile/ios/xcode_script.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ pub fn command(options: Options) -> Result<()> {
// `xcode-script` is ran from the `gen/apple` folder when not using NPM.
// so we must change working directory to the src-tauri folder to resolve the tauri dir
if (var_os("npm_lifecycle_event").is_none() && var_os("PNPM_PACKAGE_NAME").is_none())
|| var("npm_config_user_agent").map_or(false, |agent| agent.starts_with("bun"))
|| var("npm_config_user_agent").is_ok_and(|agent| agent.starts_with("bun"))
{
set_current_dir(current_dir()?.parent().unwrap().parent().unwrap()).unwrap();
}
Expand Down
5 changes: 5 additions & 0 deletions crates/tauri-schema-worker/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,8 @@ tower-service = "0.3"
semver = { version = "1", features = ["serde"] }
serde = { version = "1", features = ["derive"] }
anyhow = "1"

[lints.rust]
unexpected_cfgs = { level = "warn", check-cfg = [
'cfg(wasm_bindgen_unstable_test_coverage)',
] }
5 changes: 1 addition & 4 deletions crates/tauri-utils/src/resources.rs
Original file line number Diff line number Diff line change
Expand Up @@ -237,10 +237,7 @@ impl ResourcePathsIter<'_> {
self.current_path = None;

let pattern = match &mut self.pattern_iter {
PatternIter::Slice(iter) => match iter.next() {
Some(pattern) => pattern,
None => return None,
},
PatternIter::Slice(iter) => iter.next()?,
PatternIter::Map(iter) => match iter.next() {
Some((pattern, dest)) => {
self.current_pattern = Some(pattern.clone());
Expand Down
2 changes: 1 addition & 1 deletion crates/tauri/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ fn main() {
// workaround needed to prevent `STATUS_ENTRYPOINT_NOT_FOUND` error in tests
// see https://github.com/tauri-apps/tauri/pull/4383#issuecomment-1212221864
let target_env = std::env::var("CARGO_CFG_TARGET_ENV");
let is_tauri_workspace = std::env::var("__TAURI_WORKSPACE__").map_or(false, |v| v == "true");
let is_tauri_workspace = std::env::var("__TAURI_WORKSPACE__").is_ok_and(|v| v == "true");
if is_tauri_workspace && target_os == "windows" && Ok("msvc") == target_env.as_deref() {
embed_manifest_for_tests();
}
Expand Down
2 changes: 1 addition & 1 deletion examples/api/src-tauri/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ fn main() {
// see https://github.com/tauri-apps/tauri/pull/4383#issuecomment-1212221864
let target_os = std::env::var("CARGO_CFG_TARGET_OS").unwrap();
let target_env = std::env::var("CARGO_CFG_TARGET_ENV");
let is_tauri_workspace = std::env::var("__TAURI_WORKSPACE__").map_or(false, |v| v == "true");
let is_tauri_workspace = std::env::var("__TAURI_WORKSPACE__").is_ok_and(|v| v == "true");
if is_tauri_workspace && target_os == "windows" && Ok("msvc") == target_env.as_deref() {
embed_manifest_for_tests();
}
Expand Down

0 comments on commit cde0ff7

Please sign in to comment.