Skip to content

Commit bd5f863

Browse files
committed
Rust: Remove uncalled methods.
1 parent dd00df7 commit bd5f863

File tree

1 file changed

+0
-153
lines changed
  • rust/extractor/src/translate

1 file changed

+0
-153
lines changed

rust/extractor/src/translate/base.rs

Lines changed: 0 additions & 153 deletions
Original file line numberDiff line numberDiff line change
@@ -494,159 +494,6 @@ impl<'a> Translator<'a> {
494494
}
495495
}
496496

497-
fn canonical_path_from_type(&self, ty: Type) -> Option<String> {
498-
let sema = self.semantics.as_ref().unwrap();
499-
// rust-analyzer doesn't provide a type enum directly
500-
if let Some(it) = ty.as_adt() {
501-
return match it {
502-
Adt::Struct(it) => self.canonical_path_from_hir(it),
503-
Adt::Union(it) => self.canonical_path_from_hir(it),
504-
Adt::Enum(it) => self.canonical_path_from_hir(it),
505-
};
506-
};
507-
if let Some((it, size)) = ty.as_array(sema.db) {
508-
return self
509-
.canonical_path_from_type(it)
510-
.map(|p| format!("[{p}; {size}]"));
511-
}
512-
if let Some(it) = ty.as_slice() {
513-
return self.canonical_path_from_type(it).map(|p| format!("[{p}]"));
514-
}
515-
if let Some(it) = ty.as_builtin() {
516-
return Some(it.name().as_str().to_owned());
517-
}
518-
if let Some(it) = ty.as_dyn_trait() {
519-
return self.canonical_path_from_hir(it).map(|p| format!("dyn {p}"));
520-
}
521-
if let Some((it, mutability)) = ty.as_reference() {
522-
let mut_str = match mutability {
523-
Mutability::Shared => "",
524-
Mutability::Mut => "mut ",
525-
};
526-
return self
527-
.canonical_path_from_type(it)
528-
.map(|p| format!("&{mut_str}{p}"));
529-
}
530-
if let Some(it) = ty.as_impl_traits(sema.db) {
531-
let paths = it
532-
.map(|t| self.canonical_path_from_hir(t))
533-
.collect::<Option<Vec<_>>>()?;
534-
return Some(format!("impl {}", paths.join(" + ")));
535-
}
536-
if ty.as_type_param(sema.db).is_some() {
537-
// from the canonical path perspective, we just want a special name
538-
// e.g. `crate::<_ as SomeTrait>::func`
539-
return Some("_".to_owned());
540-
}
541-
None
542-
}
543-
544-
fn canonical_path_from_hir_module(&self, item: Module) -> Option<String> {
545-
if ModuleId::from(item).containing_block().is_some() {
546-
// this means this is a block module, i.e. a virtual module for an anonymous block scope
547-
return None;
548-
}
549-
if item.is_crate_root() {
550-
return Some("crate".into());
551-
}
552-
self.canonical_path_from_hir::<ast::Module>(item)
553-
}
554-
555-
fn canonical_path_from_hir<T: AstNode>(&self, item: impl AddressableHir<T>) -> Option<String> {
556-
// if we have a Hir entity, it means we have semantics
557-
let sema = self.semantics.as_ref().unwrap();
558-
let name = item.name(sema)?;
559-
let container = item.container(sema.db);
560-
let prefix = match container {
561-
ItemContainer::Trait(it) => self.canonical_path_from_hir(it),
562-
ItemContainer::Impl(it) => {
563-
let ty = self.canonical_path_from_type(it.self_ty(sema.db))?;
564-
if let Some(trait_) = it.trait_(sema.db) {
565-
let tr = self.canonical_path_from_hir(trait_)?;
566-
Some(format!("<{ty} as {tr}>"))
567-
} else {
568-
Some(format!("<{ty}>"))
569-
}
570-
}
571-
ItemContainer::Module(it) => self.canonical_path_from_hir_module(it),
572-
ItemContainer::ExternBlock(..) | ItemContainer::Crate(..) => Some("".to_owned()),
573-
}?;
574-
Some(format!("{prefix}::{name}"))
575-
}
576-
577-
fn canonical_path_from_module_def(&self, item: ModuleDef) -> Option<String> {
578-
match item {
579-
ModuleDef::Module(it) => self.canonical_path_from_hir(it),
580-
ModuleDef::Function(it) => self.canonical_path_from_hir(it),
581-
ModuleDef::Adt(Adt::Enum(it)) => self.canonical_path_from_hir(it),
582-
ModuleDef::Adt(Adt::Struct(it)) => self.canonical_path_from_hir(it),
583-
ModuleDef::Adt(Adt::Union(it)) => self.canonical_path_from_hir(it),
584-
ModuleDef::Trait(it) => self.canonical_path_from_hir(it),
585-
ModuleDef::Variant(it) => self.canonical_path_from_enum_variant(it),
586-
ModuleDef::Static(_) => None,
587-
ModuleDef::TraitAlias(_) => None,
588-
ModuleDef::TypeAlias(_) => None,
589-
ModuleDef::BuiltinType(_) => None,
590-
ModuleDef::Macro(_) => None,
591-
ModuleDef::Const(_) => None,
592-
}
593-
}
594-
595-
fn canonical_path_from_enum_variant(&self, item: Variant) -> Option<String> {
596-
// if we have a Hir entity, it means we have semantics
597-
let sema = self.semantics.as_ref().unwrap();
598-
let prefix = self.canonical_path_from_hir(item.parent_enum(sema.db))?;
599-
let name = item.name(sema.db);
600-
Some(format!("{prefix}::{}", name.as_str()))
601-
}
602-
603-
fn origin_from_hir<T: AstNode>(&self, item: impl AddressableHir<T>) -> String {
604-
// if we have a Hir entity, it means we have semantics
605-
let sema = self.semantics.as_ref().unwrap();
606-
self.origin_from_crate(item.module(sema).krate())
607-
}
608-
609-
fn origin_from_crate(&self, item: Crate) -> String {
610-
// if we have a Hir entity, it means we have semantics
611-
let sema = self.semantics.as_ref().unwrap();
612-
match item.origin(sema.db) {
613-
CrateOrigin::Rustc { name } => format!("rustc:{name}"),
614-
CrateOrigin::Local { repo, name } => format!(
615-
"repo:{}:{}",
616-
repo.unwrap_or_default(),
617-
name.map(|s| s.as_str().to_owned()).unwrap_or_default()
618-
),
619-
CrateOrigin::Library { repo, name } => {
620-
format!("repo:{}:{}", repo.unwrap_or_default(), name)
621-
}
622-
CrateOrigin::Lang(it) => format!("lang:{it}"),
623-
}
624-
}
625-
626-
fn origin_from_module_def(&self, item: ModuleDef) -> Option<String> {
627-
match item {
628-
ModuleDef::Module(it) => Some(self.origin_from_hir(it)),
629-
ModuleDef::Function(it) => Some(self.origin_from_hir(it)),
630-
ModuleDef::Adt(Adt::Enum(it)) => Some(self.origin_from_hir(it)),
631-
ModuleDef::Adt(Adt::Struct(it)) => Some(self.origin_from_hir(it)),
632-
ModuleDef::Adt(Adt::Union(it)) => Some(self.origin_from_hir(it)),
633-
ModuleDef::Trait(it) => Some(self.origin_from_hir(it)),
634-
ModuleDef::Variant(it) => Some(self.origin_from_enum_variant(it)),
635-
ModuleDef::Static(_) => None,
636-
ModuleDef::TraitAlias(_) => None,
637-
ModuleDef::TypeAlias(_) => None,
638-
ModuleDef::BuiltinType(_) => None,
639-
ModuleDef::Macro(_) => None,
640-
ModuleDef::Const(_) => None,
641-
}
642-
}
643-
644-
fn origin_from_enum_variant(&self, item: Variant) -> String {
645-
// if we have a Hir entity, it means we have semantics
646-
let sema = self.semantics.as_ref().unwrap();
647-
self.origin_from_hir(item.parent_enum(sema.db))
648-
}
649-
650497
pub(crate) fn should_be_excluded(&self, item: &impl ast::HasAttrs) -> bool {
651498
self.semantics.is_some_and(|sema| {
652499
item.attrs().any(|attr| {

0 commit comments

Comments
 (0)