|
| 1 | +use crate::text_util::{split_top_level_type_args, type_arg_names, type_root_name}; |
1 | 2 | use std::collections::{HashMap, HashSet}; |
2 | 3 |
|
3 | 4 | use crate::analyzer::Analyzer; |
@@ -6417,26 +6418,6 @@ fn strip_fresh_type(type_name: &str) -> &str { |
6417 | 6418 | .unwrap_or(type_name) |
6418 | 6419 | } |
6419 | 6420 |
|
6420 | | -fn split_top_level_type_args(args: &str) -> Vec<&str> { |
6421 | | - let mut parts = Vec::new(); |
6422 | | - let mut start = 0usize; |
6423 | | - let mut depth = 0usize; |
6424 | | - for (index, ch) in args.char_indices() { |
6425 | | - match ch { |
6426 | | - '<' => depth += 1, |
6427 | | - '>' => depth = depth.saturating_sub(1), |
6428 | | - ',' if depth == 0 => { |
6429 | | - parts.push(args[start..index].trim()); |
6430 | | - start = index + ch.len_utf8(); |
6431 | | - } |
6432 | | - _ => {} |
6433 | | - } |
6434 | | - } |
6435 | | - if start < args.len() { |
6436 | | - parts.push(args[start..].trim()); |
6437 | | - } |
6438 | | - parts |
6439 | | -} |
6440 | 6421 |
|
6441 | 6422 | fn check_resource_pool_lease_stmt(analyzer: &mut Analyzer<'_>, statement: &HirStmt) { |
6442 | 6423 | match statement { |
@@ -6714,43 +6695,7 @@ fn is_resource_pool_constructor(callee: &Callee) -> bool { |
6714 | 6695 | is_resource_pool_infallible_constructor(callee) || is_resource_pool_fallible_constructor(callee) |
6715 | 6696 | } |
6716 | 6697 |
|
6717 | | -fn type_root_name(type_name: &str) -> &str { |
6718 | | - let type_name = type_name |
6719 | | - .trim() |
6720 | | - .strip_prefix("fresh ") |
6721 | | - .unwrap_or(type_name.trim()); |
6722 | | - type_name |
6723 | | - .split_once('<') |
6724 | | - .map_or(type_name, |(root, _)| root) |
6725 | | -} |
6726 | 6698 |
|
6727 | | -fn type_arg_names(type_name: &str) -> Option<Vec<&str>> { |
6728 | | - let start = type_name.find('<')?; |
6729 | | - let end = type_name.rfind('>')?; |
6730 | | - if end <= start { |
6731 | | - return None; |
6732 | | - } |
6733 | | - let inner = &type_name[start + 1..end]; |
6734 | | - let mut args = Vec::new(); |
6735 | | - let mut depth = 0usize; |
6736 | | - let mut part_start = 0usize; |
6737 | | - for (index, ch) in inner.char_indices() { |
6738 | | - match ch { |
6739 | | - '<' => depth += 1, |
6740 | | - '>' => depth = depth.saturating_sub(1), |
6741 | | - ',' if depth == 0 => { |
6742 | | - args.push(inner[part_start..index].trim()); |
6743 | | - part_start = index + ch.len_utf8(); |
6744 | | - } |
6745 | | - _ => {} |
6746 | | - } |
6747 | | - } |
6748 | | - let tail = inner[part_start..].trim(); |
6749 | | - if !tail.is_empty() { |
6750 | | - args.push(tail); |
6751 | | - } |
6752 | | - Some(args) |
6753 | | -} |
6754 | 6699 |
|
6755 | 6700 | fn is_resource_pool_type(type_name: &str) -> bool { |
6756 | 6701 | type_root_name(type_name) == "ResourcePool" |
|
0 commit comments