Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clippy #12485

Open
wants to merge 3 commits into
base: dev
Choose a base branch
from
Open

Clippy #12485

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion crates/tauri-cli/src/info/packages_rust.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ pub fn rust_section_item(dep: &str, crate_version: CrateVersion) -> SectionItem
"🦀",
crate_version,
version_suffix
.clone()
.map(|s| format!(",{s}"))
.unwrap_or_else(|| "".into())
))
Expand Down
2 changes: 1 addition & 1 deletion crates/tauri-cli/src/interface/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ pub trait AppSettings {
enabled_features.push("default".into());
}

let target: String = if let Some(target) = options.target.clone() {
let target: String = if let Some(target) = options.target {
target
} else {
tauri_utils::platform::target_triple()?
Expand Down
2 changes: 1 addition & 1 deletion crates/tauri-cli/src/interface/rust.rs
Original file line number Diff line number Diff line change
Expand Up @@ -859,7 +859,7 @@ impl AppSettings for RustAppSettings {
.get("deep-link")
.and_then(|c| c.get("desktop").cloned())
{
let protocols: DesktopDeepLinks = serde_json::from_value(plugin_config.clone())?;
let protocols: DesktopDeepLinks = serde_json::from_value(plugin_config)?;
settings.deep_link_protocols = Some(match protocols {
DesktopDeepLinks::One(p) => vec![p],
DesktopDeepLinks::List(p) => p,
Expand Down
2 changes: 1 addition & 1 deletion crates/tauri-cli/src/mobile/android/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ fn run_build(
args: build_options.args.clone(),
noise_level,
vars: Default::default(),
config: build_options.config.clone(),
config: build_options.config,
target_device: None,
};
let handle = write_options(
Expand Down
2 changes: 1 addition & 1 deletion crates/tauri-cli/src/mobile/android/dev.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ fn run_command(options: Options, noise_level: NoiseLevel) -> Result<()> {
.as_ref()
.map(|d| d.target().triple.to_string())
.unwrap_or_else(|| Target::all().values().next().unwrap().triple.into());
dev_options.target = Some(target_triple.clone());
dev_options.target = Some(target_triple);

let (interface, config, metadata) = {
let tauri_config_guard = tauri_config.lock().unwrap();
Expand Down
1 change: 1 addition & 0 deletions crates/tauri-codegen/src/vendor/blake3_reference.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// SPDX-License-Identifier: MIT

//! This is a lightly modified version of the BLAKE3 reference implementation.
//!
//! The changes applied are to remove unused item warnings due to using it
//! vendored along with some minor clippy suggestions. No logic changes. I
//! suggest diffing against the original to find all the changes.
Expand Down
2 changes: 1 addition & 1 deletion crates/tauri-utils/src/acl/capability.rs
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ mod tests {
))
.unwrap(),
CapabilityFile::NamedList {
capabilities: vec![capability.clone()]
capabilities: vec![capability]
}
);
}
Expand Down
2 changes: 1 addition & 1 deletion crates/tauri-utils/src/acl/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ fn extend_identifier_schema(schema: &mut RootSchema, acl: &BTreeMap<String, Mani
.collect::<Vec<_>>();

let new_subschemas = Box::new(SubschemaValidation {
one_of: Some(permission_schemas.clone()),
one_of: Some(permission_schemas),
..Default::default()
});

Expand Down
1 change: 1 addition & 0 deletions crates/tauri-utils/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2094,6 +2094,7 @@ impl HeaderAddition for Builder {
}

/// A struct, where the keys are some specific http header names.
///
/// If the values to those keys are defined, then they will be send as part of a response message.
/// This does not include error messages and ipc messages
///
Expand Down
1 change: 1 addition & 0 deletions crates/tauri/src/image/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ impl TryFrom<Image<'_>> for tray_icon::Icon {
}

/// An image type that accepts file paths, raw bytes, previously loaded images and image objects.
///
/// This type is meant to be used along the [transformImage](https://v2.tauri.app/reference/javascript/api/namespaceimage/#transformimage) API.
///
/// # Stability
Expand Down
4 changes: 2 additions & 2 deletions crates/tauri/src/ipc/authority.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1133,7 +1133,7 @@ mod tests {
let denied_commands = [(
command.to_string(),
vec![ResolvedCommand {
windows: windows.clone(),
windows,
..Default::default()
}],
)]
Expand Down Expand Up @@ -1185,7 +1185,7 @@ mod tests {
let resolved_webview_window_remote_cmd = ResolvedCommand {
windows: vec![Pattern::new(window).unwrap()],
webviews: vec![Pattern::new(webview).unwrap()],
referenced_by: referenced_by.clone(),
referenced_by,
context: ExecutionContext::Remote {
url: remote_url.parse().unwrap(),
},
Expand Down
7 changes: 3 additions & 4 deletions crates/tauri/src/ipc/protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -414,8 +414,8 @@ fn handle_ipc_message<R: Runtime>(request: Request<String>, manager: &AppManager
error,
);
} else {
let _ = Channel::from_callback_fn(webview, callback)
.send(InvokeResponseBody::Raw(v.clone()));
let _ =
Channel::from_callback_fn(webview, callback).send(InvokeResponseBody::Raw(v));
}
}
InvokeResponse::Err(e) => responder_eval(
Expand Down Expand Up @@ -601,7 +601,7 @@ mod tests {
let invoke_key = "1234ahdsjkl123";
let callback = 12378123;
let error = 6243;
let headers = HeaderMap::from_iter(vec![
let mut headers = HeaderMap::from_iter(vec![
(
CONTENT_TYPE,
HeaderValue::from_str(mime::APPLICATION_OCTET_STREAM.as_ref()).unwrap(),
Expand Down Expand Up @@ -641,7 +641,6 @@ mod tests {
"anotherKey": "asda",
});

let mut headers = headers.clone();
headers.insert(
CONTENT_TYPE,
HeaderValue::from_str(mime::APPLICATION_JSON.as_ref()).unwrap(),
Expand Down
13 changes: 2 additions & 11 deletions crates/tauri/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -584,10 +584,7 @@ pub trait Manager<R: Runtime>: sealed::ManagerBase<R> {
self.manager().get_webview(label).and_then(|webview| {
let window = webview.window();
if window.is_webview_window() {
Some(WebviewWindow {
window: window.clone(),
webview,
})
Some(WebviewWindow { window, webview })
} else {
None
}
Expand All @@ -603,13 +600,7 @@ pub trait Manager<R: Runtime>: sealed::ManagerBase<R> {
.filter_map(|(label, webview)| {
let window = webview.window();
if window.is_webview_window() {
Some((
label,
WebviewWindow {
window: window.clone(),
webview,
},
))
Some((label, WebviewWindow { window, webview }))
} else {
None
}
Expand Down
1 change: 0 additions & 1 deletion crates/tauri/src/manager/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ struct CspHashStrings {

/// Sets the CSP value to the asset HTML if needed (on Linux).
/// Returns the CSP string for access on the response header (on Windows and macOS).
#[allow(clippy::borrowed_box)]
pub(crate) fn set_csp<R: Runtime>(
asset: &mut String,
assets: &impl std::borrow::Borrow<dyn Assets<R>>,
Expand Down
20 changes: 8 additions & 12 deletions crates/tauri/src/manager/webview.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,17 +180,13 @@ impl<R: Runtime> WebviewManager<R> {
current_window_label = serde_json::to_string(window_label)?,
current_webview_label = serde_json::to_string(&label)?,
));
all_initialization_scripts.push(
self
.initialization_script(
app_manager,
&ipc_init.into_string(),
&pattern_init.into_string(),
is_init_global,
use_https_scheme,
)?
.to_string(),
);
all_initialization_scripts.push(self.initialization_script(
app_manager,
&ipc_init.into_string(),
&pattern_init.into_string(),
is_init_global,
use_https_scheme,
)?);

for plugin_init_script in plugin_init_scripts {
all_initialization_scripts.push(plugin_init_script.to_string());
Expand Down Expand Up @@ -315,7 +311,7 @@ impl<R: Runtime> WebviewManager<R> {
.get::<crate::Scopes>()
.asset_protocol
.clone();
let protocol = crate::protocol::asset::get(asset_scope.clone(), window_origin.clone());
let protocol = crate::protocol::asset::get(asset_scope, window_origin.clone());
pending.register_uri_scheme_protocol("asset", move |webview_id, request, responder| {
protocol(webview_id, request, UriSchemeResponder(responder))
});
Expand Down
1 change: 1 addition & 0 deletions crates/tauri/src/resources/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ use std::{
};

/// Resources are Rust objects that are stored in [ResourceTable] and managed by tauri.
///
/// They are identified in JS by a numeric ID (the resource ID, or rid).
/// Resources can be created in commands. Resources can also be retrieved in commands by
/// their rid. Resources are thread-safe.
Expand Down
2 changes: 1 addition & 1 deletion crates/tauri/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ mod tests {
let dropping_struct = DroppingStruct(drop_flag.clone());

let _drop_flag_ignore = Arc::new(RwLock::new(false));
let _dropping_struct_ignore = DroppingStruct(_drop_flag_ignore.clone());
let _dropping_struct_ignore = DroppingStruct(_drop_flag_ignore);

state.set::<DroppingStruct>(dropping_struct);
assert!(!state.set::<DroppingStruct>(_dropping_struct_ignore));
Expand Down
5 changes: 1 addition & 4 deletions crates/tauri/src/webview/webview_window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1034,10 +1034,7 @@ impl<'de, R: Runtime> CommandArg<'de, R> for WebviewWindow<R> {
let webview = command.message.webview();
let window = webview.window();
if window.is_webview_window() {
return Ok(Self {
window: window.clone(),
webview,
});
return Ok(Self { window, webview });
}

Err(InvokeError::from("current webview is not a WebviewWindow"))
Expand Down
2 changes: 2 additions & 0 deletions examples/api/src-tauri/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ pub fn run_app<R: Runtime, F: FnOnce(&App<R>) + Send + 'static>(
}),
});
log::info!("got response: {:?}", response);
// when #[cfg(desktop)], Rust will detect pattern as irrefutable
#[allow(irrefutable_let_patterns)]
if let Ok(res) = response {
assert_eq!(res.value, value);
}
Expand Down
Loading