From 5e31fa33c3b5cf726a57a063b8e7a070869250fe Mon Sep 17 00:00:00 2001 From: nsfisis Date: Tue, 19 May 2026 21:46:01 +0900 Subject: fix(compile): fix more random compile errors Co-Authored-By: Claude Opus 4.7 (1M context) --- .../src/dependency_resolver/rule_set_generator.rs | 68 +++++++++++++--------- 1 file changed, 39 insertions(+), 29 deletions(-) (limited to 'crates/shirabe/src/dependency_resolver/rule_set_generator.rs') diff --git a/crates/shirabe/src/dependency_resolver/rule_set_generator.rs b/crates/shirabe/src/dependency_resolver/rule_set_generator.rs index d5bb1cd..6cbe93b 100644 --- a/crates/shirabe/src/dependency_resolver/rule_set_generator.rs +++ b/crates/shirabe/src/dependency_resolver/rule_set_generator.rs @@ -123,16 +123,15 @@ impl RuleSetGenerator { if literals.len() == 2 { // Rule2Literals and MultiConflictRule both implement Rule (Phase B: define Rule type) - Rule::from(Rule2Literals::new( + Box::new(Rule2Literals::new( literals[0], literals[1], PhpMixed::Int(reason), reason_data, - )) + )) as Box } else { - Rule::from( - MultiConflictRule::new(literals, PhpMixed::Int(reason), reason_data).unwrap(), - ) + Box::new(MultiConflictRule::new(literals, PhpMixed::Int(reason), reason_data).unwrap()) + as Box } } @@ -159,42 +158,45 @@ impl RuleSetGenerator { continue; } - self.added_map.insert(package.get_id(), package.clone_box()); + self.added_map + .insert(package.get_id(), package.clone_package_box()); - let is_alias = (package.as_any() as &dyn Any) - .downcast_ref::() - .is_some(); + let is_alias = package.as_any().downcast_ref::().is_some(); if !is_alias { for name in package.get_names(false) { self.added_packages_by_names .entry(name) .or_default() - .push(package.clone_box()); + .push(package.clone_package_box()); } } else { - let alias_pkg = (package.as_any() as &dyn Any) - .downcast_ref::() - .unwrap(); + let alias_pkg = package.as_any().downcast_ref::().unwrap(); - work_queue.push_back(alias_pkg.get_alias_of().clone_box()); + work_queue.push_back(alias_pkg.get_alias_of().clone_package_box()); let alias_of = alias_pkg.get_alias_of(); let rule = self.create_require_rule( &*package, - &[alias_of.clone_box()], + &[alias_of.clone_package_box()], rule::RULE_PACKAGE_ALIAS, PhpMixed::Null, // reasonData: $package (BasePackage) ); - self.add_rule(RuleSet::TYPE_PACKAGE, rule.map(Rule::from)); + self.add_rule( + RuleSet::TYPE_PACKAGE, + rule.map(|r| Box::new(r) as Box), + ); // aliases must be installed with their main package, so create a rule the other way around as well let inverse_rule = self.create_require_rule( alias_of, - &[package.clone_box()], + &[package.clone_package_box()], rule::RULE_PACKAGE_INVERSE_ALIAS, PhpMixed::Null, // reasonData: $package->getAliasOf() (BasePackage) ); - self.add_rule(RuleSet::TYPE_PACKAGE, inverse_rule.map(Rule::from)); + self.add_rule( + RuleSet::TYPE_PACKAGE, + inverse_rule.map(|r| Box::new(r) as Box), + ); // if alias package has no self.version requires, its requirements do not // need to be added as the aliased package processing will take care of it @@ -207,7 +209,8 @@ impl RuleSetGenerator { let mut constraint = link.get_constraint().clone_box(); if platform_requirement_filter.is_ignored(link.get_target()) { continue; - } else if let Some(ignore_list_filter) = (platform_requirement_filter as &dyn Any) + } else if let Some(ignore_list_filter) = platform_requirement_filter + .as_any() .downcast_ref::( ) { constraint = ignore_list_filter @@ -223,7 +226,10 @@ impl RuleSetGenerator { rule::RULE_PACKAGE_REQUIRES, PhpMixed::Null, // reasonData: $link (Link) ); - self.add_rule(RuleSet::TYPE_PACKAGE, rule.map(Rule::from)); + self.add_rule( + RuleSet::TYPE_PACKAGE, + rule.map(|r| Box::new(r) as Box), + ); for require in possible_requires { work_queue.push_back(require); @@ -252,7 +258,8 @@ impl RuleSetGenerator { let mut constraint = link.get_constraint().clone_box(); if platform_requirement_filter.is_ignored(link.get_target()) { continue; - } else if let Some(ignore_list_filter) = (platform_requirement_filter as &dyn Any) + } else if let Some(ignore_list_filter) = platform_requirement_filter + .as_any() .downcast_ref::( ) { constraint = ignore_list_filter @@ -266,9 +273,8 @@ impl RuleSetGenerator { // define the conflict rule for regular packages, for alias packages it's only needed if the name // matches the conflict exactly, otherwise the name match is by provide/replace which means the // package which this is an alias of will conflict anyway, so no need to create additional rules - let conflict_is_alias = (conflict.as_any() as &dyn Any) - .downcast_ref::() - .is_some(); + let conflict_is_alias = + conflict.as_any().downcast_ref::().is_some(); let conflict_name_matches = conflict.get_name() == link.get_target(); if !conflict_is_alias || conflict_name_matches { let rule = self.create_rule2_literals( @@ -277,7 +283,10 @@ impl RuleSetGenerator { rule::RULE_PACKAGE_CONFLICT, PhpMixed::Null, // reasonData: $link (Link) ); - self.add_rule(RuleSet::TYPE_PACKAGE, rule.map(Rule::from)); + self.add_rule( + RuleSet::TYPE_PACKAGE, + rule.map(|r| Box::new(r) as Box), + ); } } } @@ -336,14 +345,15 @@ impl RuleSetGenerator { rule::RULE_FIXED, PhpMixed::Array(reason_data), ); - self.add_rule(RuleSet::TYPE_REQUEST, Some(Rule::from(rule))); + self.add_rule(RuleSet::TYPE_REQUEST, Some(Box::new(rule) as Box)); } for (package_name, constraint) in request.get_requires() { let mut constraint = constraint.clone_box(); if platform_requirement_filter.is_ignored(package_name) { continue; - } else if let Some(ignore_list_filter) = (platform_requirement_filter as &dyn Any) + } else if let Some(ignore_list_filter) = platform_requirement_filter + .as_any() .downcast_ref::( ) { constraint = ignore_list_filter @@ -371,7 +381,7 @@ impl RuleSetGenerator { rule::RULE_ROOT_REQUIRE, PhpMixed::Array(reason_data), ); - self.add_rule(RuleSet::TYPE_REQUEST, Some(Rule::from(rule))); + self.add_rule(RuleSet::TYPE_REQUEST, Some(Box::new(rule) as Box)); } } @@ -387,7 +397,7 @@ impl RuleSetGenerator { // even if the alias itself isn't required, otherwise a package could be installed without its alias which // leads to unexpected behavior let is_not_added = !self.added_map.contains_key(&package.get_id()); - let as_alias = (package.as_any() as &dyn Any).downcast_ref::(); + let as_alias = package.as_any().downcast_ref::(); if is_not_added { if let Some(alias_pkg) = as_alias { if alias_pkg.is_root_package_alias() -- cgit v1.3.1