Quellcode durchsuchen

chore: fix clippy warnings, remove license template

The license template has been removed from rustfmt nightly :(
Lucas Nogueira vor 3 Jahren
Ursprung
Commit
23a049c593
33 geänderte Dateien mit 23 neuen und 84 gelöschten Zeilen
  1. 1 1
      .github/workflows/lint-fmt-cli.yml
  2. 1 1
      .github/workflows/lint-fmt-core.yml
  3. 1 1
      .github/workflows/test-bundler.yml
  4. 0 3
      .license_template
  5. 0 3
      core/tauri-build/.license_template
  6. 0 3
      core/tauri-codegen/.license_template
  7. 0 3
      core/tauri-macros/.license_template
  8. 0 3
      core/tauri-runtime-wry/.license_template
  9. 4 4
      core/tauri-runtime-wry/src/lib.rs
  10. 0 3
      core/tauri-runtime/.license_template
  11. 0 3
      core/tauri-utils/.license_template
  12. 0 3
      core/tauri/.license_template
  13. 6 7
      core/tauri/src/manager.rs
  14. 3 1
      core/tauri/src/updater/core.rs
  15. 3 1
      core/tauri/src/window.rs
  16. 0 1
      core/tests/restart/.license_template
  17. 0 3
      examples/api/src-tauri/.license_template
  18. 0 3
      examples/resources/src-tauri/.license_template
  19. 0 3
      examples/sidecar/src-tauri/.license_template
  20. 0 3
      examples/tauri-dynamic-lib/src-app1/.license_template
  21. 0 3
      examples/tauri-dynamic-lib/src-tauri/.license_template
  22. 0 3
      examples/updater/src-tauri/.license_template
  23. 0 1
      rustfmt.toml
  24. 0 3
      tooling/bench/tests/cpu_intensive/src-tauri/.license_template
  25. 0 3
      tooling/bench/tests/files_transfer/src-tauri/.license_template
  26. 0 3
      tooling/bench/tests/helloworld/src-tauri/.license_template
  27. 0 3
      tooling/bundler/.license_template
  28. 0 3
      tooling/cli/.license_template
  29. 2 2
      tooling/cli/templates/plugin/backend/.github/workflows/format.yml
  30. 0 1
      tooling/cli/templates/plugin/backend/.license_template
  31. 2 2
      tooling/cli/templates/plugin/with-api/.github/workflows/format.yml
  32. 0 1
      tooling/cli/templates/plugin/with-api/.license_template
  33. 0 3
      tooling/webdriver/.license_template

+ 1 - 1
.github/workflows/lint-fmt-cli.yml

@@ -33,7 +33,7 @@ jobs:
       - uses: actions-rs/toolchain@v1
         with:
           profile: minimal
-          toolchain: nightly
+          toolchain: stable
           override: true
           components: rustfmt
 

+ 1 - 1
.github/workflows/lint-fmt-core.yml

@@ -34,7 +34,7 @@ jobs:
       - uses: actions-rs/toolchain@v1
         with:
           profile: minimal
-          toolchain: nightly
+          toolchain: stable
           override: true
           components: rustfmt
 

+ 1 - 1
.github/workflows/test-bundler.yml

@@ -92,7 +92,7 @@ jobs:
       - uses: actions-rs/toolchain@v1
         with:
           profile: minimal
-          toolchain: nightly
+          toolchain: stable
           override: true
           components: rustfmt
 

+ 0 - 3
.license_template

@@ -1,3 +0,0 @@
-// Copyright {20\d{2}(-20\d{2})?} Tauri Programme within The Commons Conservancy
-// SPDX-License-Identifier: Apache-2.0
-// SPDX-License-Identifier: MIT

+ 0 - 3
core/tauri-build/.license_template

@@ -1,3 +0,0 @@
-// Copyright {20\d{2}(-20\d{2})?} Tauri Programme within The Commons Conservancy
-// SPDX-License-Identifier: Apache-2.0
-// SPDX-License-Identifier: MIT

+ 0 - 3
core/tauri-codegen/.license_template

@@ -1,3 +0,0 @@
-// Copyright {20\d{2}(-20\d{2})?} Tauri Programme within The Commons Conservancy
-// SPDX-License-Identifier: Apache-2.0
-// SPDX-License-Identifier: MIT

+ 0 - 3
core/tauri-macros/.license_template

@@ -1,3 +0,0 @@
-// Copyright {20\d{2}(-20\d{2})?} Tauri Programme within The Commons Conservancy
-// SPDX-License-Identifier: Apache-2.0
-// SPDX-License-Identifier: MIT

+ 0 - 3
core/tauri-runtime-wry/.license_template

@@ -1,3 +0,0 @@
-// Copyright {20\d{2}(-20\d{2})?} Tauri Programme within The Commons Conservancy
-// SPDX-License-Identifier: Apache-2.0
-// SPDX-License-Identifier: MIT

+ 4 - 4
core/tauri-runtime-wry/src/lib.rs

@@ -100,6 +100,8 @@ use std::{
 };
 
 pub type WebviewId = u64;
+type IpcHandler = dyn Fn(&Window, String) + 'static;
+type FileDropHandler = dyn Fn(&Window, WryFileDropEvent) -> bool + 'static;
 
 mod webview;
 pub use webview::Webview;
@@ -3067,7 +3069,7 @@ fn create_ipc_handler<T: UserEvent>(
   menu_ids: Arc<Mutex<HashMap<MenuHash, MenuId>>>,
   js_event_listeners: Arc<Mutex<HashMap<JsEventListenerKey, HashSet<u64>>>>,
   handler: WebviewIpcHandler<T, Wry<T>>,
-) -> Box<dyn Fn(&Window, String) + 'static> {
+) -> Box<IpcHandler> {
   Box::new(move |window, request| {
     let window_id = context.webview_id_map.get(&window.id());
     handler(
@@ -3086,9 +3088,7 @@ fn create_ipc_handler<T: UserEvent>(
 }
 
 /// Create a wry file drop handler.
-fn create_file_drop_handler<T: UserEvent>(
-  context: &Context<T>,
-) -> Box<dyn Fn(&Window, WryFileDropEvent) -> bool + 'static> {
+fn create_file_drop_handler<T: UserEvent>(context: &Context<T>) -> Box<FileDropHandler> {
   let window_event_listeners = context.window_event_listeners.clone();
   let webview_id_map = context.webview_id_map.clone();
   Box::new(move |window, event| {

+ 0 - 3
core/tauri-runtime/.license_template

@@ -1,3 +0,0 @@
-// Copyright {20\d{2}(-20\d{2})?} Tauri Programme within The Commons Conservancy
-// SPDX-License-Identifier: Apache-2.0
-// SPDX-License-Identifier: MIT

+ 0 - 3
core/tauri-utils/.license_template

@@ -1,3 +0,0 @@
-// Copyright {20\d{2}(-20\d{2})?} Tauri Programme within The Commons Conservancy
-// SPDX-License-Identifier: Apache-2.0
-// SPDX-License-Identifier: MIT

+ 0 - 3
core/tauri/.license_template

@@ -1,3 +0,0 @@
-// Copyright {20\d{2}(-20\d{2})?} Tauri Programme within The Commons Conservancy
-// SPDX-License-Identifier: Apache-2.0
-// SPDX-License-Identifier: MIT

+ 6 - 7
core/tauri/src/manager.rs

@@ -25,7 +25,6 @@ use tauri_utils::{
   html::{SCRIPT_NONCE_TOKEN, STYLE_NONCE_TOKEN},
 };
 
-use crate::app::{GlobalMenuEventListener, WindowMenuEvent};
 use crate::hooks::IpcJavascript;
 #[cfg(feature = "isolation")]
 use crate::hooks::IsolationJavascript;
@@ -51,6 +50,10 @@ use crate::{
   Context, EventLoopMessage, Icon, Invoke, Manager, Pattern, Runtime, Scopes, StateManager, Window,
   WindowEvent,
 };
+use crate::{
+  app::{GlobalMenuEventListener, WindowMenuEvent},
+  window::WebResourceRequestHandler,
+};
 
 #[cfg(any(target_os = "linux", target_os = "windows"))]
 use crate::api::path::{resolve_path, BaseDirectory};
@@ -390,9 +393,7 @@ impl<R: Runtime> WindowManager<R> {
     label: &str,
     window_labels: &[String],
     app_handle: AppHandle<R>,
-    web_resource_request_handler: Option<
-      Box<dyn Fn(&HttpRequest, &mut HttpResponse) + Send + Sync>,
-    >,
+    web_resource_request_handler: Option<Box<WebResourceRequestHandler>>,
   ) -> crate::Result<PendingWindow<EventLoopMessage, R>> {
     let is_init_global = self.inner.config.build.with_global_tauri;
     let plugin_init = self
@@ -1045,9 +1046,7 @@ impl<R: Runtime> WindowManager<R> {
     app_handle: AppHandle<R>,
     mut pending: PendingWindow<EventLoopMessage, R>,
     window_labels: &[String],
-    web_resource_request_handler: Option<
-      Box<dyn Fn(&HttpRequest, &mut HttpResponse) + Send + Sync>,
-    >,
+    web_resource_request_handler: Option<Box<WebResourceRequestHandler>>,
   ) -> crate::Result<PendingWindow<EventLoopMessage, R>> {
     if self.windows_lock().contains_key(&pending.label) {
       return Err(crate::Error::WindowLabelAlreadyExists(pending.label));

+ 3 - 1
core/tauri/src/updater/core.rs

@@ -46,6 +46,8 @@ use std::{
   process::{exit, Command},
 };
 
+type ShouldInstall = dyn FnOnce(&Version, &RemoteRelease) -> bool + Send;
+
 #[derive(Debug, Deserialize, Serialize)]
 #[serde(untagged)]
 pub enum RemoteReleaseInner {
@@ -209,7 +211,7 @@ pub struct UpdateBuilder<R: Runtime> {
   pub target: Option<String>,
   /// The current executable path. Default is automatically extracted.
   pub executable_path: Option<PathBuf>,
-  should_install: Option<Box<dyn FnOnce(&Version, &RemoteRelease) -> bool + Send>>,
+  should_install: Option<Box<ShouldInstall>>,
   timeout: Option<Duration>,
   headers: HeaderMap,
 }

+ 3 - 1
core/tauri/src/window.rs

@@ -45,6 +45,8 @@ use std::{
   sync::Arc,
 };
 
+pub(crate) type WebResourceRequestHandler = dyn Fn(&HttpRequest, &mut HttpResponse) + Send + Sync;
+
 #[derive(Clone, Serialize)]
 struct WindowCreatedEvent {
   label: String,
@@ -103,7 +105,7 @@ pub struct WindowBuilder<'a, R: Runtime> {
   label: String,
   pub(crate) window_builder: <R::Dispatcher as Dispatch<EventLoopMessage>>::WindowBuilder,
   pub(crate) webview_attributes: WebviewAttributes,
-  web_resource_request_handler: Option<Box<dyn Fn(&HttpRequest, &mut HttpResponse) + Send + Sync>>,
+  web_resource_request_handler: Option<Box<WebResourceRequestHandler>>,
 }
 
 impl<'a, R: Runtime> fmt::Debug for WindowBuilder<'a, R> {

+ 0 - 1
core/tests/restart/.license_template

@@ -1 +0,0 @@
-../../../../.license_template

+ 0 - 3
examples/api/src-tauri/.license_template

@@ -1,3 +0,0 @@
-// Copyright {20\d{2}(-20\d{2})?} Tauri Programme within The Commons Conservancy
-// SPDX-License-Identifier: Apache-2.0
-// SPDX-License-Identifier: MIT

+ 0 - 3
examples/resources/src-tauri/.license_template

@@ -1,3 +0,0 @@
-// Copyright {20\d{2}(-20\d{2})?} Tauri Programme within The Commons Conservancy
-// SPDX-License-Identifier: Apache-2.0
-// SPDX-License-Identifier: MIT

+ 0 - 3
examples/sidecar/src-tauri/.license_template

@@ -1,3 +0,0 @@
-// Copyright {20\d{2}(-20\d{2})?} Tauri Programme within The Commons Conservancy
-// SPDX-License-Identifier: Apache-2.0
-// SPDX-License-Identifier: MIT

+ 0 - 3
examples/tauri-dynamic-lib/src-app1/.license_template

@@ -1,3 +0,0 @@
-// Copyright {20\d{2}(-20\d{2})?} Tauri Programme within The Commons Conservancy
-// SPDX-License-Identifier: Apache-2.0
-// SPDX-License-Identifier: MIT

+ 0 - 3
examples/tauri-dynamic-lib/src-tauri/.license_template

@@ -1,3 +0,0 @@
-// Copyright {20\d{2}(-20\d{2})?} Tauri Programme within The Commons Conservancy
-// SPDX-License-Identifier: Apache-2.0
-// SPDX-License-Identifier: MIT

+ 0 - 3
examples/updater/src-tauri/.license_template

@@ -1,3 +0,0 @@
-// Copyright {20\d{2}(-20\d{2})?} Tauri Programme within The Commons Conservancy
-// SPDX-License-Identifier: Apache-2.0
-// SPDX-License-Identifier: MIT

+ 0 - 1
rustfmt.toml

@@ -14,4 +14,3 @@ force_explicit_abi = true
 # normalize_comments = true
 normalize_doc_attributes = true
 # wrap_comments = true
-license_template_path = ".license_template"

+ 0 - 3
tooling/bench/tests/cpu_intensive/src-tauri/.license_template

@@ -1,3 +0,0 @@
-// Copyright {20\d{2}(-20\d{2})?} Tauri Programme within The Commons Conservancy
-// SPDX-License-Identifier: Apache-2.0
-// SPDX-License-Identifier: MIT

+ 0 - 3
tooling/bench/tests/files_transfer/src-tauri/.license_template

@@ -1,3 +0,0 @@
-// Copyright {20\d{2}(-20\d{2})?} Tauri Programme within The Commons Conservancy
-// SPDX-License-Identifier: Apache-2.0
-// SPDX-License-Identifier: MIT

+ 0 - 3
tooling/bench/tests/helloworld/src-tauri/.license_template

@@ -1,3 +0,0 @@
-// Copyright {20\d{2}(-20\d{2})?} Tauri Programme within The Commons Conservancy
-// SPDX-License-Identifier: Apache-2.0
-// SPDX-License-Identifier: MIT

+ 0 - 3
tooling/bundler/.license_template

@@ -1,3 +0,0 @@
-// Copyright {20\d{2}(-20\d{2})?} Tauri Programme within The Commons Conservancy
-// SPDX-License-Identifier: Apache-2.0
-// SPDX-License-Identifier: MIT

+ 0 - 3
tooling/cli/.license_template

@@ -1,3 +0,0 @@
-// Copyright {20\d{2}(-20\d{2})?} Tauri Programme within The Commons Conservancy
-// SPDX-License-Identifier: Apache-2.0
-// SPDX-License-Identifier: MIT

+ 2 - 2
tooling/cli/templates/plugin/backend/.github/workflows/format.yml

@@ -18,11 +18,11 @@ jobs:
 
     steps:
     - uses: actions/checkout@v2
-    - name: Install rustfmt with nightly toolchain
+    - name: Install rustfmt with stable toolchain
       uses: actions-rs/toolchain@v1
       with:
           profile: minimal
-          toolchain: nightly
+          toolchain: stable
           override: true
           components: rustfmt
     - uses: actions-rs/cargo@v1

+ 0 - 1
tooling/cli/templates/plugin/backend/.license_template

@@ -1 +0,0 @@
-{{ license_template }}

+ 2 - 2
tooling/cli/templates/plugin/with-api/.github/workflows/format.yml

@@ -18,11 +18,11 @@ jobs:
 
     steps:
     - uses: actions/checkout@v2
-    - name: Install rustfmt with nightly toolchain
+    - name: Install rustfmt with stable toolchain
       uses: actions-rs/toolchain@v1
       with:
           profile: minimal
-          toolchain: nightly
+          toolchain: stable
           override: true
           components: rustfmt
     - uses: actions-rs/cargo@v1

+ 0 - 1
tooling/cli/templates/plugin/with-api/.license_template

@@ -1 +0,0 @@
-{{ license_template }}

+ 0 - 3
tooling/webdriver/.license_template

@@ -1,3 +0,0 @@
-// Copyright {20\d{2}(-20\d{2})?} Tauri Programme within The Commons Conservancy
-// SPDX-License-Identifier: Apache-2.0
-// SPDX-License-Identifier: MIT