rename fn name take_path to any

Signed-off-by: Hayashi Mikihiro <34ttrweoewiwe28@gmail.com>
This commit is contained in:
Hayashi Mikihiro 2025-05-15 13:18:30 +09:00
parent 30fe761685
commit bf13549ab6
3 changed files with 5 additions and 5 deletions

View File

@ -118,7 +118,7 @@ impl PathResolutionPerNs {
) -> Self { ) -> Self {
PathResolutionPerNs { type_ns, value_ns, macro_ns } PathResolutionPerNs { type_ns, value_ns, macro_ns }
} }
pub fn take_path(&self) -> Option<PathResolution> { pub fn any(&self) -> Option<PathResolution> {
self.type_ns.or(self.value_ns).or(self.macro_ns) self.type_ns.or(self.value_ns).or(self.macro_ns)
} }
} }

View File

@ -1163,7 +1163,7 @@ impl<'db> SourceAnalyzer<'db> {
Some(&store), Some(&store),
false, false,
) )
.take_path()?; .any()?;
let subst = (|| { let subst = (|| {
let parent = parent()?; let parent = parent()?;
let ty = if let Some(expr) = ast::Expr::cast(parent.clone()) { let ty = if let Some(expr) = ast::Expr::cast(parent.clone()) {
@ -1556,7 +1556,7 @@ pub(crate) fn resolve_hir_path(
hygiene: HygieneId, hygiene: HygieneId,
store: Option<&ExpressionStore>, store: Option<&ExpressionStore>,
) -> Option<PathResolution> { ) -> Option<PathResolution> {
resolve_hir_path_(db, resolver, path, false, hygiene, store, false).take_path() resolve_hir_path_(db, resolver, path, false, hygiene, store, false).any()
} }
#[inline] #[inline]
@ -1677,7 +1677,7 @@ fn resolve_hir_path_(
.unwrap_or_else(|| PathResolutionPerNs::new(None, values(), None)) .unwrap_or_else(|| PathResolutionPerNs::new(None, values(), None))
}; };
if res.take_path().is_some() { if res.any().is_some() {
res res
} else if let Some(type_ns) = items() { } else if let Some(type_ns) = items() {
PathResolutionPerNs::new(Some(type_ns), None, None) PathResolutionPerNs::new(Some(type_ns), None, None)

View File

@ -81,7 +81,7 @@ pub(crate) fn remove_unused_imports(acc: &mut Assists, ctx: &AssistContext<'_>)
// Get the actual definition associated with this use item. // Get the actual definition associated with this use item.
let res = match ctx.sema.resolve_path_per_ns(&path) { let res = match ctx.sema.resolve_path_per_ns(&path) {
Some(x) if x.take_path().is_some() => x, Some(x) if x.any().is_some() => x,
Some(_) | None => { Some(_) | None => {
return None; return None;
} }