Skip to content

Commit 8a1d490

Browse files
sftselucasfernog
andauthored
Clippy (#12485)
* fix: remove unused clones, discovered with clippy nursery lint clippy::redundant_clone * fix: clippy * fix: remove no longer used clippy allow directives * more lint --------- Co-authored-by: Lucas Nogueira <[email protected]>
1 parent 89c6e43 commit 8a1d490

File tree

10 files changed

+11
-7
lines changed

10 files changed

+11
-7
lines changed

crates/tauri-cli/config.schema.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1576,7 +1576,7 @@
15761576
]
15771577
},
15781578
"HeaderConfig": {
1579-
"description": "A struct, where the keys are some specific http header names.\n If the values to those keys are defined, then they will be send as part of a response message.\n This does not include error messages and ipc messages\n\n ## Example configuration\n ```javascript\n {\n //..\n app:{\n //..\n security: {\n headers: {\n \"Cross-Origin-Opener-Policy\": \"same-origin\",\n \"Cross-Origin-Embedder-Policy\": \"require-corp\",\n \"Timing-Allow-Origin\": [\n \"https://developer.mozilla.org\",\n \"https://example.com\",\n ],\n \"Access-Control-Expose-Headers\": \"Tauri-Custom-Header\",\n \"Tauri-Custom-Header\": {\n \"key1\": \"'value1' 'value2'\",\n \"key2\": \"'value3'\"\n }\n },\n csp: \"default-src 'self'; connect-src ipc: http://ipc.localhost\",\n }\n //..\n }\n //..\n }\n ```\n In this example `Cross-Origin-Opener-Policy` and `Cross-Origin-Embedder-Policy` are set to allow for the use of [`SharedArrayBuffer`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer).\n The result is, that those headers are then set on every response sent via the `get_response` function in crates/tauri/src/protocol/tauri.rs.\n The Content-Security-Policy header is defined separately, because it is also handled separately.\n\n For the helloworld example, this config translates into those response headers:\n ```http\n access-control-allow-origin: http://tauri.localhost\n access-control-expose-headers: Tauri-Custom-Header\n content-security-policy: default-src 'self'; connect-src ipc: http://ipc.localhost; script-src 'self' 'sha256-Wjjrs6qinmnr+tOry8x8PPwI77eGpUFR3EEGZktjJNs='\n content-type: text/html\n cross-origin-embedder-policy: require-corp\n cross-origin-opener-policy: same-origin\n tauri-custom-header: key1 'value1' 'value2'; key2 'value3'\n timing-allow-origin: https://developer.mozilla.org, https://example.com\n ```\n Since the resulting header values are always 'string-like'. So depending on the what data type the HeaderSource is, they need to be converted.\n - `String`(JS/Rust): stay the same for the resulting header value\n - `Array`(JS)/`Vec\\<String\\>`(Rust): Item are joined by \", \" for the resulting header value\n - `Object`(JS)/ `Hashmap\\<String,String\\>`(Rust): Items are composed from: key + space + value. Item are then joined by \"; \" for the resulting header value",
1579+
"description": "A struct, where the keys are some specific http header names.\n\n If the values to those keys are defined, then they will be send as part of a response message.\n This does not include error messages and ipc messages\n\n ## Example configuration\n ```javascript\n {\n //..\n app:{\n //..\n security: {\n headers: {\n \"Cross-Origin-Opener-Policy\": \"same-origin\",\n \"Cross-Origin-Embedder-Policy\": \"require-corp\",\n \"Timing-Allow-Origin\": [\n \"https://developer.mozilla.org\",\n \"https://example.com\",\n ],\n \"Access-Control-Expose-Headers\": \"Tauri-Custom-Header\",\n \"Tauri-Custom-Header\": {\n \"key1\": \"'value1' 'value2'\",\n \"key2\": \"'value3'\"\n }\n },\n csp: \"default-src 'self'; connect-src ipc: http://ipc.localhost\",\n }\n //..\n }\n //..\n }\n ```\n In this example `Cross-Origin-Opener-Policy` and `Cross-Origin-Embedder-Policy` are set to allow for the use of [`SharedArrayBuffer`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer).\n The result is, that those headers are then set on every response sent via the `get_response` function in crates/tauri/src/protocol/tauri.rs.\n The Content-Security-Policy header is defined separately, because it is also handled separately.\n\n For the helloworld example, this config translates into those response headers:\n ```http\n access-control-allow-origin: http://tauri.localhost\n access-control-expose-headers: Tauri-Custom-Header\n content-security-policy: default-src 'self'; connect-src ipc: http://ipc.localhost; script-src 'self' 'sha256-Wjjrs6qinmnr+tOry8x8PPwI77eGpUFR3EEGZktjJNs='\n content-type: text/html\n cross-origin-embedder-policy: require-corp\n cross-origin-opener-policy: same-origin\n tauri-custom-header: key1 'value1' 'value2'; key2 'value3'\n timing-allow-origin: https://developer.mozilla.org, https://example.com\n ```\n Since the resulting header values are always 'string-like'. So depending on the what data type the HeaderSource is, they need to be converted.\n - `String`(JS/Rust): stay the same for the resulting header value\n - `Array`(JS)/`Vec\\<String\\>`(Rust): Item are joined by \", \" for the resulting header value\n - `Object`(JS)/ `Hashmap\\<String,String\\>`(Rust): Items are composed from: key + space + value. Item are then joined by \"; \" for the resulting header value",
15801580
"type": "object",
15811581
"properties": {
15821582
"Access-Control-Allow-Credentials": {

crates/tauri-codegen/src/vendor/blake3_reference.rs

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// SPDX-License-Identifier: MIT
44

55
//! This is a lightly modified version of the BLAKE3 reference implementation.
6+
//!
67
//! The changes applied are to remove unused item warnings due to using it
78
//! vendored along with some minor clippy suggestions. No logic changes. I
89
//! suggest diffing against the original to find all the changes.

crates/tauri-schema-generator/schemas/config.schema.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1576,7 +1576,7 @@
15761576
]
15771577
},
15781578
"HeaderConfig": {
1579-
"description": "A struct, where the keys are some specific http header names.\n If the values to those keys are defined, then they will be send as part of a response message.\n This does not include error messages and ipc messages\n\n ## Example configuration\n ```javascript\n {\n //..\n app:{\n //..\n security: {\n headers: {\n \"Cross-Origin-Opener-Policy\": \"same-origin\",\n \"Cross-Origin-Embedder-Policy\": \"require-corp\",\n \"Timing-Allow-Origin\": [\n \"https://developer.mozilla.org\",\n \"https://example.com\",\n ],\n \"Access-Control-Expose-Headers\": \"Tauri-Custom-Header\",\n \"Tauri-Custom-Header\": {\n \"key1\": \"'value1' 'value2'\",\n \"key2\": \"'value3'\"\n }\n },\n csp: \"default-src 'self'; connect-src ipc: http://ipc.localhost\",\n }\n //..\n }\n //..\n }\n ```\n In this example `Cross-Origin-Opener-Policy` and `Cross-Origin-Embedder-Policy` are set to allow for the use of [`SharedArrayBuffer`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer).\n The result is, that those headers are then set on every response sent via the `get_response` function in crates/tauri/src/protocol/tauri.rs.\n The Content-Security-Policy header is defined separately, because it is also handled separately.\n\n For the helloworld example, this config translates into those response headers:\n ```http\n access-control-allow-origin: http://tauri.localhost\n access-control-expose-headers: Tauri-Custom-Header\n content-security-policy: default-src 'self'; connect-src ipc: http://ipc.localhost; script-src 'self' 'sha256-Wjjrs6qinmnr+tOry8x8PPwI77eGpUFR3EEGZktjJNs='\n content-type: text/html\n cross-origin-embedder-policy: require-corp\n cross-origin-opener-policy: same-origin\n tauri-custom-header: key1 'value1' 'value2'; key2 'value3'\n timing-allow-origin: https://developer.mozilla.org, https://example.com\n ```\n Since the resulting header values are always 'string-like'. So depending on the what data type the HeaderSource is, they need to be converted.\n - `String`(JS/Rust): stay the same for the resulting header value\n - `Array`(JS)/`Vec\\<String\\>`(Rust): Item are joined by \", \" for the resulting header value\n - `Object`(JS)/ `Hashmap\\<String,String\\>`(Rust): Items are composed from: key + space + value. Item are then joined by \"; \" for the resulting header value",
1579+
"description": "A struct, where the keys are some specific http header names.\n\n If the values to those keys are defined, then they will be send as part of a response message.\n This does not include error messages and ipc messages\n\n ## Example configuration\n ```javascript\n {\n //..\n app:{\n //..\n security: {\n headers: {\n \"Cross-Origin-Opener-Policy\": \"same-origin\",\n \"Cross-Origin-Embedder-Policy\": \"require-corp\",\n \"Timing-Allow-Origin\": [\n \"https://developer.mozilla.org\",\n \"https://example.com\",\n ],\n \"Access-Control-Expose-Headers\": \"Tauri-Custom-Header\",\n \"Tauri-Custom-Header\": {\n \"key1\": \"'value1' 'value2'\",\n \"key2\": \"'value3'\"\n }\n },\n csp: \"default-src 'self'; connect-src ipc: http://ipc.localhost\",\n }\n //..\n }\n //..\n }\n ```\n In this example `Cross-Origin-Opener-Policy` and `Cross-Origin-Embedder-Policy` are set to allow for the use of [`SharedArrayBuffer`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer).\n The result is, that those headers are then set on every response sent via the `get_response` function in crates/tauri/src/protocol/tauri.rs.\n The Content-Security-Policy header is defined separately, because it is also handled separately.\n\n For the helloworld example, this config translates into those response headers:\n ```http\n access-control-allow-origin: http://tauri.localhost\n access-control-expose-headers: Tauri-Custom-Header\n content-security-policy: default-src 'self'; connect-src ipc: http://ipc.localhost; script-src 'self' 'sha256-Wjjrs6qinmnr+tOry8x8PPwI77eGpUFR3EEGZktjJNs='\n content-type: text/html\n cross-origin-embedder-policy: require-corp\n cross-origin-opener-policy: same-origin\n tauri-custom-header: key1 'value1' 'value2'; key2 'value3'\n timing-allow-origin: https://developer.mozilla.org, https://example.com\n ```\n Since the resulting header values are always 'string-like'. So depending on the what data type the HeaderSource is, they need to be converted.\n - `String`(JS/Rust): stay the same for the resulting header value\n - `Array`(JS)/`Vec\\<String\\>`(Rust): Item are joined by \", \" for the resulting header value\n - `Object`(JS)/ `Hashmap\\<String,String\\>`(Rust): Items are composed from: key + space + value. Item are then joined by \"; \" for the resulting header value",
15801580
"type": "object",
15811581
"properties": {
15821582
"Access-Control-Allow-Credentials": {

crates/tauri-utils/src/config.rs

+1
Original file line numberDiff line numberDiff line change
@@ -2200,6 +2200,7 @@ impl HeaderAddition for Builder {
22002200
}
22012201

22022202
/// A struct, where the keys are some specific http header names.
2203+
///
22032204
/// If the values to those keys are defined, then they will be send as part of a response message.
22042205
/// This does not include error messages and ipc messages
22052206
///

crates/tauri/src/image/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ impl TryFrom<Image<'_>> for tray_icon::Icon {
132132
}
133133

134134
/// An image type that accepts file paths, raw bytes, previously loaded images and image objects.
135+
///
135136
/// This type is meant to be used along the [transformImage](https://v2.tauri.app/reference/javascript/api/namespaceimage/#transformimage) API.
136137
///
137138
/// # Stability

crates/tauri/src/ipc/protocol.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -589,7 +589,7 @@ mod tests {
589589
let invoke_key = "1234ahdsjkl123";
590590
let callback = 12378123;
591591
let error = 6243;
592-
let headers = HeaderMap::from_iter(vec![
592+
let mut headers = HeaderMap::from_iter(vec![
593593
(
594594
CONTENT_TYPE,
595595
HeaderValue::from_str(mime::APPLICATION_OCTET_STREAM.as_ref()).unwrap(),
@@ -629,7 +629,6 @@ mod tests {
629629
"anotherKey": "asda",
630630
});
631631

632-
let mut headers = headers;
633632
headers.insert(
634633
CONTENT_TYPE,
635634
HeaderValue::from_str(mime::APPLICATION_JSON.as_ref()).unwrap(),

crates/tauri/src/manager/mod.rs

-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ struct CspHashStrings {
4848

4949
/// Sets the CSP value to the asset HTML if needed (on Linux).
5050
/// Returns the CSP string for access on the response header (on Windows and macOS).
51-
#[allow(clippy::borrowed_box)]
5251
pub(crate) fn set_csp<R: Runtime>(
5352
asset: &mut String,
5453
assets: &impl std::borrow::Borrow<dyn Assets<R>>,

crates/tauri/src/process.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -96,14 +96,14 @@ fn restart_macos_app(current_binary: &std::path::Path, env: &Env) {
9696
use std::process::{exit, Command};
9797

9898
if let Some(macos_directory) = current_binary.parent() {
99-
if macos_directory.components().last()
99+
if macos_directory.components().next_back()
100100
!= Some(std::path::Component::Normal(std::ffi::OsStr::new("MacOS")))
101101
{
102102
return;
103103
}
104104

105105
if let Some(contents_directory) = macos_directory.parent() {
106-
if contents_directory.components().last()
106+
if contents_directory.components().next_back()
107107
!= Some(std::path::Component::Normal(std::ffi::OsStr::new(
108108
"Contents",
109109
)))

crates/tauri/src/resources/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ use std::{
1515
};
1616

1717
/// Resources are Rust objects that are stored in [ResourceTable] and managed by tauri.
18+
///
1819
/// They are identified in JS by a numeric ID (the resource ID, or rid).
1920
/// Resources can be created in commands. Resources can also be retrieved in commands by
2021
/// their rid. Resources are thread-safe.

examples/api/src-tauri/src/lib.rs

+2
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@ pub fn run_app<R: Runtime, F: FnOnce(&App<R>) + Send + 'static>(
9191
}),
9292
});
9393
log::info!("got response: {:?}", response);
94+
// when #[cfg(desktop)], Rust will detect pattern as irrefutable
95+
#[allow(irrefutable_let_patterns)]
9496
if let Ok(res) = response {
9597
assert_eq!(res.value, value);
9698
}

0 commit comments

Comments
 (0)