Skip to content

Commit b80f9de

Browse files
chore: fix new clippy warnings (derive default) (tauri-apps#14395)
* chore: fix new clippy warnings (derive default) * Fix left over `#[cfg(feature = "isolation")]`
1 parent 1afa9df commit b80f9de

File tree

9 files changed

+40
-118
lines changed

9 files changed

+40
-118
lines changed

crates/tauri-bundler/src/error.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,14 @@ pub enum Error {
9999
#[error("Wrong package type {0} for platform {1}")]
100100
InvalidPackageType(String, String),
101101
/// Bundle type symbol missing in binary
102-
#[cfg(target_os = "linux")]
103-
#[error("__TAURI_BUNDLE_TYPE variable not found in binary. Make sure tauri crate and tauri-cli are up to date and that symbol stripping is disabled (https://doc.rust-lang.org/cargo/reference/profiles.html#strip)")]
104-
MissingBundleTypeVar,
105-
#[cfg(not(target_os = "linux"))]
106-
#[error("__TAURI_BUNDLE_TYPE variable not found in binary. Make sure tauri crate and tauri-cli are up to date")]
102+
#[cfg_attr(
103+
target_os = "linux",
104+
error("__TAURI_BUNDLE_TYPE variable not found in binary. Make sure tauri crate and tauri-cli are up to date and that symbol stripping is disabled (https://doc.rust-lang.org/cargo/reference/profiles.html#strip)")
105+
)]
106+
#[cfg_attr(
107+
not(target_os = "linux"),
108+
error("__TAURI_BUNDLE_TYPE variable not found in binary. Make sure tauri crate and tauri-cli are up to date")
109+
)]
107110
MissingBundleTypeVar,
108111
/// Failed to write binary file changed
109112
#[error("Failed to write binary file changes: `{0}`")]

crates/tauri-cli/src/interface/rust.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -785,25 +785,20 @@ pub struct UpdaterConfig {
785785
}
786786

787787
/// Install modes for the Windows update.
788-
#[derive(Debug, PartialEq, Eq, Clone)]
788+
#[derive(Default, Debug, PartialEq, Eq, Clone)]
789789
pub enum WindowsUpdateInstallMode {
790790
/// Specifies there's a basic UI during the installation process, including a final dialog box at the end.
791791
BasicUi,
792792
/// The quiet mode means there's no user interaction required.
793793
/// Requires admin privileges if the installer does.
794794
Quiet,
795795
/// Specifies unattended mode, which means the installation only shows a progress bar.
796+
#[default]
796797
Passive,
797798
// to add more modes, we need to check if the updater relaunch makes sense
798799
// i.e. for a full UI mode, the user can also mark the installer to start the app
799800
}
800801

801-
impl Default for WindowsUpdateInstallMode {
802-
fn default() -> Self {
803-
Self::Passive
804-
}
805-
}
806-
807802
impl<'de> Deserialize<'de> for WindowsUpdateInstallMode {
808803
fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
809804
where

crates/tauri-runtime/src/lib.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -90,23 +90,18 @@ pub enum UserAttentionType {
9090
Informational,
9191
}
9292

93-
#[derive(Debug, Clone, Copy, PartialEq, Eq, Deserialize)]
93+
#[derive(Default, Debug, Clone, Copy, PartialEq, Eq, Deserialize)]
9494
#[serde(tag = "type")]
9595
pub enum DeviceEventFilter {
9696
/// Always filter out device events.
9797
Always,
9898
/// Filter out device events while the window is not focused.
99+
#[default]
99100
Unfocused,
100101
/// Report all device events regardless of window focus.
101102
Never,
102103
}
103104

104-
impl Default for DeviceEventFilter {
105-
fn default() -> Self {
106-
Self::Unfocused
107-
}
108-
}
109-
110105
/// Defines the orientation that a window resize will be performed.
111106
#[derive(Debug, Clone, Copy, PartialEq, Eq, Deserialize)]
112107
pub enum ResizeDirection {

crates/tauri-utils/src/config.rs

Lines changed: 8 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -208,9 +208,10 @@ impl<'de> Deserialize<'de> for BundleType {
208208
}
209209

210210
/// Targets to bundle. Each value is case insensitive.
211-
#[derive(Debug, PartialEq, Eq, Clone)]
211+
#[derive(Debug, PartialEq, Eq, Clone, Default)]
212212
pub enum BundleTarget {
213213
/// Bundle all targets.
214+
#[default]
214215
All,
215216
/// A list of bundle targets.
216217
List(Vec<BundleType>),
@@ -257,12 +258,6 @@ impl schemars::JsonSchema for BundleTarget {
257258
}
258259
}
259260

260-
impl Default for BundleTarget {
261-
fn default() -> Self {
262-
Self::All
263-
}
264-
}
265-
266261
impl Serialize for BundleTarget {
267262
fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
268263
where
@@ -805,7 +800,7 @@ pub struct WixConfig {
805800
/// Compression algorithms used in the NSIS installer.
806801
///
807802
/// See <https://nsis.sourceforge.io/Reference/SetCompressor>
808-
#[derive(Debug, PartialEq, Eq, Clone, Copy, Serialize, Deserialize)]
803+
#[derive(Debug, PartialEq, Eq, Clone, Copy, Serialize, Deserialize, Default)]
809804
#[cfg_attr(feature = "schema", derive(JsonSchema))]
810805
#[serde(rename_all = "camelCase", deny_unknown_fields)]
811806
pub enum NsisCompression {
@@ -814,19 +809,14 @@ pub enum NsisCompression {
814809
/// BZIP2 usually gives better compression ratios than ZLIB, but it is a bit slower and uses more memory. With the default compression level it uses about 4 MB of memory.
815810
Bzip2,
816811
/// LZMA (default) is a new compression method that gives very good compression ratios. The decompression speed is high (10-20 MB/s on a 2 GHz CPU), the compression speed is lower. The memory size that will be used for decompression is the dictionary size plus a few KBs, the default is 8 MB.
812+
#[default]
817813
Lzma,
818814
/// Disable compression
819815
None,
820816
}
821817

822-
impl Default for NsisCompression {
823-
fn default() -> Self {
824-
Self::Lzma
825-
}
826-
}
827-
828818
/// Install Modes for the NSIS installer.
829-
#[derive(Debug, PartialEq, Eq, Clone, Copy, Serialize, Deserialize)]
819+
#[derive(Default, Debug, PartialEq, Eq, Clone, Copy, Serialize, Deserialize)]
830820
#[serde(rename_all = "camelCase", deny_unknown_fields)]
831821
#[cfg_attr(feature = "schema", derive(JsonSchema))]
832822
pub enum NSISInstallerMode {
@@ -835,6 +825,7 @@ pub enum NSISInstallerMode {
835825
/// Install the app by default in a directory that doesn't require Administrator access.
836826
///
837827
/// Installer metadata will be saved under the `HKCU` registry path.
828+
#[default]
838829
CurrentUser,
839830
/// Install the app by default in the `Program Files` folder directory requires Administrator
840831
/// access for the installation.
@@ -849,12 +840,6 @@ pub enum NSISInstallerMode {
849840
Both,
850841
}
851842

852-
impl Default for NSISInstallerMode {
853-
fn default() -> Self {
854-
Self::CurrentUser
855-
}
856-
}
857-
858843
/// Configuration for the Installer bundle using NSIS.
859844
#[derive(Debug, Default, PartialEq, Eq, Clone, Deserialize, Serialize)]
860845
#[cfg_attr(feature = "schema", derive(JsonSchema))]
@@ -2685,11 +2670,12 @@ impl<'de> Deserialize<'de> for CapabilityEntry {
26852670

26862671
/// The application pattern.
26872672
#[skip_serializing_none]
2688-
#[derive(Debug, PartialEq, Eq, Clone, Serialize, Deserialize)]
2673+
#[derive(Debug, PartialEq, Eq, Clone, Serialize, Deserialize, Default)]
26892674
#[serde(rename_all = "lowercase", tag = "use", content = "options")]
26902675
#[cfg_attr(feature = "schema", derive(JsonSchema))]
26912676
pub enum PatternKind {
26922677
/// Brownfield pattern.
2678+
#[default]
26932679
Brownfield,
26942680
/// Isolation pattern. Recommended for security purposes.
26952681
Isolation {
@@ -2698,12 +2684,6 @@ pub enum PatternKind {
26982684
},
26992685
}
27002686

2701-
impl Default for PatternKind {
2702-
fn default() -> Self {
2703-
Self::Brownfield
2704-
}
2705-
}
2706-
27072687
/// The App configuration object.
27082688
///
27092689
/// See more: <https://v2.tauri.app/reference/config/#appconfig>

crates/tauri-utils/src/config_v1/mod.rs

Lines changed: 10 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,10 @@ impl<'de> Deserialize<'de> for BundleType {
131131
}
132132

133133
/// Targets to bundle. Each value is case insensitive.
134-
#[derive(Debug, PartialEq, Eq, Clone)]
134+
#[derive(Debug, PartialEq, Eq, Clone, Default)]
135135
pub enum BundleTarget {
136136
/// Bundle all targets.
137+
#[default]
137138
All,
138139
/// A list of bundle targets.
139140
List(Vec<BundleType>),
@@ -251,12 +252,6 @@ impl schemars::JsonSchema for BundleTarget {
251252
}
252253
}
253254

254-
impl Default for BundleTarget {
255-
fn default() -> Self {
256-
Self::All
257-
}
258-
}
259-
260255
impl Serialize for BundleTarget {
261256
fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
262257
where
@@ -552,7 +547,7 @@ pub struct NsisConfig {
552547
}
553548

554549
/// Install Modes for the NSIS installer.
555-
#[derive(Debug, PartialEq, Eq, Clone, Copy, Serialize, Deserialize)]
550+
#[derive(Debug, PartialEq, Eq, Clone, Copy, Serialize, Deserialize, Default)]
556551
#[serde(rename_all = "camelCase", deny_unknown_fields)]
557552
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
558553
pub enum NSISInstallerMode {
@@ -561,6 +556,7 @@ pub enum NSISInstallerMode {
561556
/// Install the app by default in a directory that doesn't require Administrator access.
562557
///
563558
/// Installer metadata will be saved under the `HKCU` registry path.
559+
#[default]
564560
CurrentUser,
565561
/// Install the app by default in the `Program Files` folder directory requires Administrator
566562
/// access for the installation.
@@ -575,12 +571,6 @@ pub enum NSISInstallerMode {
575571
Both,
576572
}
577573

578-
impl Default for NSISInstallerMode {
579-
fn default() -> Self {
580-
Self::CurrentUser
581-
}
582-
}
583-
584574
/// Install modes for the Webview2 runtime.
585575
/// Note that for the updater bundle [`Self::DownloadBootstrapper`] is used.
586576
///
@@ -2393,11 +2383,12 @@ impl Allowlist for AllowlistConfig {
23932383

23942384
/// The application pattern.
23952385
#[skip_serializing_none]
2396-
#[derive(Debug, PartialEq, Eq, Clone, Serialize, Deserialize)]
2386+
#[derive(Debug, PartialEq, Eq, Clone, Serialize, Deserialize, Default)]
23972387
#[serde(rename_all = "lowercase", tag = "use", content = "options")]
23982388
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
23992389
pub enum PatternKind {
24002390
/// Brownfield pattern.
2391+
#[default]
24012392
Brownfield,
24022393
/// Isolation pattern. Recommended for security purposes.
24032394
Isolation {
@@ -2406,12 +2397,6 @@ pub enum PatternKind {
24062397
},
24072398
}
24082399

2409-
impl Default for PatternKind {
2410-
fn default() -> Self {
2411-
Self::Brownfield
2412-
}
2413-
}
2414-
24152400
/// The Tauri configuration object.
24162401
///
24172402
/// See more: https://tauri.app/v1/api/config#tauriconfig
@@ -2481,7 +2466,7 @@ impl<'de> Deserialize<'de> for UpdaterEndpoint {
24812466
}
24822467

24832468
/// Install modes for the Windows update.
2484-
#[derive(Debug, PartialEq, Eq, Clone)]
2469+
#[derive(Debug, PartialEq, Eq, Clone, Default)]
24852470
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
24862471
#[cfg_attr(feature = "schema", schemars(rename_all = "camelCase"))]
24872472
pub enum WindowsUpdateInstallMode {
@@ -2491,6 +2476,7 @@ pub enum WindowsUpdateInstallMode {
24912476
/// Requires admin privileges if the installer does.
24922477
Quiet,
24932478
/// Specifies unattended mode, which means the installation only shows a progress bar.
2479+
#[default]
24942480
Passive,
24952481
// to add more modes, we need to check if the updater relaunch makes sense
24962482
// i.e. for a full UI mode, the user can also mark the installer to start the app
@@ -2510,12 +2496,6 @@ impl Display for WindowsUpdateInstallMode {
25102496
}
25112497
}
25122498

2513-
impl Default for WindowsUpdateInstallMode {
2514-
fn default() -> Self {
2515-
Self::Passive
2516-
}
2517-
}
2518-
25192499
impl Serialize for WindowsUpdateInstallMode {
25202500
fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
25212501
where
@@ -2989,10 +2969,11 @@ fn default_build() -> BuildConfig {
29892969
}
29902970

29912971
/// How the window title bar should be displayed on macOS.
2992-
#[derive(Debug, Clone, PartialEq, Eq)]
2972+
#[derive(Debug, Clone, PartialEq, Eq, Default)]
29932973
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
29942974
pub enum TitleBarStyle {
29952975
/// A normal title bar.
2976+
#[default]
29962977
Visible,
29972978
/// Makes the title bar transparent, so the window background color is shown instead.
29982979
///
@@ -3007,12 +2988,6 @@ pub enum TitleBarStyle {
30072988
Overlay,
30082989
}
30092990

3010-
impl Default for TitleBarStyle {
3011-
fn default() -> Self {
3012-
Self::Visible
3013-
}
3014-
}
3015-
30162991
impl Serialize for TitleBarStyle {
30172992
fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
30182993
where

crates/tauri-utils/src/html.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -211,21 +211,16 @@ impl From<&PatternKind> for PatternObject {
211211
}
212212

213213
/// Where the JavaScript is injected to
214-
#[derive(Debug, Serialize)]
214+
#[derive(Debug, Serialize, Default)]
215215
#[serde(rename_all = "lowercase")]
216216
pub enum IsolationSide {
217217
/// Original frame, the Brownfield application
218+
#[default]
218219
Original,
219220
/// Secure frame, the isolation security application
220221
Secure,
221222
}
222223

223-
impl Default for IsolationSide {
224-
fn default() -> Self {
225-
Self::Original
226-
}
227-
}
228-
229224
/// Injects the Isolation JavaScript to a codegen time document.
230225
///
231226
/// Note: This function is not considered part of the stable API.

crates/tauri-utils/src/lib.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -157,11 +157,12 @@ mod window_effects {
157157
pub use window_effects::{WindowEffect, WindowEffectState};
158158

159159
/// How the window title bar should be displayed on macOS.
160-
#[derive(Debug, Clone, PartialEq, Eq, Copy)]
160+
#[derive(Debug, Clone, PartialEq, Eq, Copy, Default)]
161161
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
162162
#[non_exhaustive]
163163
pub enum TitleBarStyle {
164164
/// A normal title bar.
165+
#[default]
165166
Visible,
166167
/// Makes the title bar transparent, so the window background color is shown instead.
167168
///
@@ -176,12 +177,6 @@ pub enum TitleBarStyle {
176177
Overlay,
177178
}
178179

179-
impl Default for TitleBarStyle {
180-
fn default() -> Self {
181-
Self::Visible
182-
}
183-
}
184-
185180
impl Serialize for TitleBarStyle {
186181
fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
187182
where

crates/tauri/src/pattern.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -64,23 +64,17 @@ impl From<&Pattern> for PatternObject {
6464

6565
/// Where the JavaScript is injected to
6666
#[cfg(feature = "isolation")]
67-
#[derive(Debug, Serialize)]
67+
#[derive(Default, Debug, Serialize)]
6868
#[serde(rename_all = "lowercase")]
6969
pub(crate) enum IsolationSide {
7070
/// Original frame, the Brownfield application
71+
#[default]
7172
Original,
7273
/// Secure frame, the isolation security application
7374
#[allow(dead_code)]
7475
Secure,
7576
}
7677

77-
#[cfg(feature = "isolation")]
78-
impl Default for IsolationSide {
79-
fn default() -> Self {
80-
Self::Original
81-
}
82-
}
83-
8478
#[derive(Template)]
8579
#[default_template("../scripts/pattern.js")]
8680
pub(crate) struct PatternJavascript {

0 commit comments

Comments
 (0)