From 9be0f98f71fe8071ab839ac1036b4064ac3172b4 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Mon, 29 Jun 2026 00:03:00 +0900 Subject: chore(lint): ban bare `use anyhow::Result` and fully qualify it Add a no_banned_use linter that forbids importing anyhow::Result, and update all call sites to reference it via its fully-qualified path so it is never confused with std::result::Result. Co-Authored-By: Claude Opus 4.8 (1M context) --- .../shirabe/src/installer/installation_manager.rs | 61 ++++++++++++---------- 1 file changed, 33 insertions(+), 28 deletions(-) (limited to 'crates/shirabe/src/installer/installation_manager.rs') diff --git a/crates/shirabe/src/installer/installation_manager.rs b/crates/shirabe/src/installer/installation_manager.rs index c1e65a8..97e1985 100644 --- a/crates/shirabe/src/installer/installation_manager.rs +++ b/crates/shirabe/src/installer/installation_manager.rs @@ -18,7 +18,6 @@ use crate::repository::InstalledRepositoryInterface; use crate::util::Platform; use crate::util::r#loop::Loop; use crate::util::sync_executor; -use anyhow::Result; use indexmap::IndexMap; use shirabe_external_packages::seld::signal::SignalHandler; use shirabe_php_shim::{ @@ -156,7 +155,7 @@ impl InstallationManager { } /// Returns installer for a specific package type. - pub fn get_installer(&mut self, r#type: &str) -> Result<&mut dyn InstallerInterface> { + pub fn get_installer(&mut self, r#type: &str) -> anyhow::Result<&mut dyn InstallerInterface> { let r#type = strtolower(r#type); if let Some(&index) = self.cache.get(&r#type) { @@ -184,7 +183,7 @@ impl InstallationManager { &mut self, repo: &dyn InstalledRepositoryInterface, package: PackageInterfaceHandle, - ) -> Result { + ) -> anyhow::Result { // For testing only (ref InstallationManagerMock::isPackageInstalled). if self.mock.is_some() { return Ok(repo.has_package(package)); @@ -228,7 +227,7 @@ impl InstallationManager { dev_mode: bool, run_scripts: bool, download_only: bool, - ) -> Result<()> { + ) -> anyhow::Result<()> { // For testing only: the mock records each operation and mutates the repo directly, // skipping the download step (ref InstallationManagerMock::execute). The alias operations' // repo mutation is inlined (rather than calling mark_alias_*) so `self.mock` can stay @@ -297,8 +296,9 @@ impl InstallationManager { let mut cleanup_promises: IndexMap< i64, Box< - dyn Fn() - -> Option>>>>, + dyn Fn() -> Option< + std::pin::Pin>>>, + >, >, > = IndexMap::new(); @@ -318,7 +318,7 @@ impl InstallationManager { let all_operations: Vec> = operations.clone(); - let result: Result<()> = (|| -> Result<()> { + let result: anyhow::Result<()> = (|| -> anyhow::Result<()> { // execute operations in batches to make sure download-modifying-plugins are installed // before the other packages get downloaded let mut batches: Vec>> = vec![]; @@ -405,15 +405,16 @@ impl InstallationManager { cleanup_promises: &mut IndexMap< i64, Box< - dyn Fn() - -> Option>>>>, + dyn Fn() -> Option< + std::pin::Pin>>>, + >, >, >, dev_mode: bool, run_scripts: bool, download_only: bool, all_operations: Vec>, - ) -> Result<()> { + ) -> anyhow::Result<()> { for (index, operation) in &operations { let op_type = operation.get_operation_type(); @@ -449,8 +450,9 @@ impl InstallationManager { let _ = installer; let op_type_clone = op_type.clone(); let cleanup: Box< - dyn Fn() - -> Option>>>>, + dyn Fn() -> Option< + std::pin::Pin>>>, + >, > = Box::new(move || { // avoid calling cleanup if the download was not even initialized for a package // as without installation source configured nothing will work @@ -458,7 +460,7 @@ impl InstallationManager { let _ = &op_type_clone; // TODO(phase-c-promise): build the real installer.cleanup() future once the installer // can be shared into a 'static cleanup closure (Stage 2 Rc/Arc). - let fut: std::pin::Pin>>> = + let fut: std::pin::Pin>>> = Box::pin(async { Ok(()) }); Some(fut) }); @@ -533,14 +535,15 @@ impl InstallationManager { cleanup_promises: &IndexMap< i64, Box< - dyn Fn() - -> Option>>>>, + dyn Fn() -> Option< + std::pin::Pin>>>, + >, >, >, dev_mode: bool, run_scripts: bool, all_operations: &[std::rc::Rc], - ) -> Result<()> { + ) -> anyhow::Result<()> { let mut post_exec_callbacks: Vec> = vec![]; for (index, operation) in operations { @@ -711,7 +714,7 @@ impl InstallationManager { &mut self, repo: &mut dyn InstalledRepositoryInterface, operation: &InstallOperation, - ) -> Result> { + ) -> anyhow::Result> { let package = operation.get_package(); let package_type = package.get_type(); let installer = self.get_installer(&package_type)?; @@ -726,7 +729,7 @@ impl InstallationManager { &mut self, repo: &mut dyn InstalledRepositoryInterface, operation: &UpdateOperation, - ) -> Result> { + ) -> anyhow::Result> { let initial = operation.get_initial_package().clone(); let target = operation.get_target_package().clone(); @@ -754,7 +757,7 @@ impl InstallationManager { &mut self, repo: &mut dyn InstalledRepositoryInterface, operation: &UninstallOperation, - ) -> Result> { + ) -> anyhow::Result> { let package = operation.get_package(); let package_type = package.get_type(); let installer = self.get_installer(&package_type)?; @@ -810,7 +813,7 @@ impl InstallationManager { // TODO(phase-c-promise): PHP collects every http_downloader.add() promise and runs them via // Loop::wait; the single-threaded sync bridge block_on's each notification serially instead. - let result: Result<()> = (|| -> Result<()> { + let result: anyhow::Result<()> = (|| -> anyhow::Result<()> { for (repo_url, packages) in &self.notifiable_packages { // non-batch API, deprecated if str_contains(repo_url, "%package%") { @@ -937,13 +940,15 @@ impl InstallationManager { cleanup_promises: &IndexMap< i64, Box< - dyn Fn() - -> Option>>>>, + dyn Fn() -> Option< + std::pin::Pin>>>, + >, >, >, ) { - let mut promises: Vec>>>> = - vec![]; + let mut promises: Vec< + std::pin::Pin>>>, + > = vec![]; self.loop_.borrow().abort_jobs(); @@ -980,7 +985,7 @@ pub trait InstallationManagerInterface: std::fmt::Debug { &mut self, repo: &dyn InstalledRepositoryInterface, package: PackageInterfaceHandle, - ) -> Result; + ) -> anyhow::Result; fn ensure_binaries_presence(&mut self, package: PackageInterfaceHandle); fn execute( &mut self, @@ -989,7 +994,7 @@ pub trait InstallationManagerInterface: std::fmt::Debug { dev_mode: bool, run_scripts: bool, download_only: bool, - ) -> Result<()>; + ) -> anyhow::Result<()>; fn get_install_path(&mut self, package: PackageInterfaceHandle) -> Option; fn set_output_progress(&mut self, output_progress: bool); fn notify_installs(&mut self, io: std::rc::Rc>); @@ -1016,7 +1021,7 @@ impl InstallationManagerInterface for InstallationManager { &mut self, repo: &dyn InstalledRepositoryInterface, package: PackageInterfaceHandle, - ) -> Result { + ) -> anyhow::Result { self.is_package_installed(repo, package) } @@ -1031,7 +1036,7 @@ impl InstallationManagerInterface for InstallationManager { dev_mode: bool, run_scripts: bool, download_only: bool, - ) -> Result<()> { + ) -> anyhow::Result<()> { self.execute(repo, operations, dev_mode, run_scripts, download_only) } -- cgit v1.3.1