mirror of
https://github.com/github/codeql.git
synced 2025-12-17 01:03:14 +01:00
Rust: Remove unused traits and things.
This commit is contained in:
@@ -66,124 +66,6 @@ impl TextValue for ast::RangePat {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) trait AddressableHir<Ast: AstNode>: HasContainer + Copy {
|
|
||||||
fn name(self, sema: &Semantics<'_, RootDatabase>) -> Option<String>;
|
|
||||||
fn try_from_source(value: &Ast, sema: &Semantics<'_, RootDatabase>) -> Option<Self>;
|
|
||||||
fn module(self, sema: &Semantics<'_, RootDatabase>) -> Module;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl AddressableHir<ast::Fn> for Function {
|
|
||||||
fn name(self, sema: &Semantics<'_, RootDatabase>) -> Option<String> {
|
|
||||||
Some(self.name(sema.db).as_str().to_owned())
|
|
||||||
}
|
|
||||||
|
|
||||||
fn try_from_source(value: &ast::Fn, sema: &Semantics<'_, RootDatabase>) -> Option<Self> {
|
|
||||||
sema.to_fn_def(value)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn module(self, sema: &Semantics<'_, RootDatabase>) -> Module {
|
|
||||||
self.module(sema.db)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl AddressableHir<ast::Trait> for Trait {
|
|
||||||
fn name(self, sema: &Semantics<'_, RootDatabase>) -> Option<String> {
|
|
||||||
Some(self.name(sema.db).as_str().to_owned())
|
|
||||||
}
|
|
||||||
|
|
||||||
fn try_from_source(value: &ast::Trait, sema: &Semantics<'_, RootDatabase>) -> Option<Self> {
|
|
||||||
sema.to_trait_def(value)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn module(self, sema: &Semantics<'_, RootDatabase>) -> Module {
|
|
||||||
self.module(sema.db)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl AddressableHir<ast::Module> for Module {
|
|
||||||
fn name(self, sema: &Semantics<'_, RootDatabase>) -> Option<String> {
|
|
||||||
self.name(sema.db).map(|s| s.as_str().to_owned())
|
|
||||||
}
|
|
||||||
|
|
||||||
fn try_from_source(value: &ast::Module, sema: &Semantics<'_, RootDatabase>) -> Option<Self> {
|
|
||||||
sema.to_module_def(value)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn module(self, _sema: &Semantics<'_, RootDatabase>) -> Module {
|
|
||||||
self
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl AddressableHir<ast::Struct> for Struct {
|
|
||||||
fn name(self, sema: &Semantics<'_, RootDatabase>) -> Option<String> {
|
|
||||||
Some(self.name(sema.db).as_str().to_owned())
|
|
||||||
}
|
|
||||||
|
|
||||||
fn try_from_source(value: &ast::Struct, sema: &Semantics<'_, RootDatabase>) -> Option<Self> {
|
|
||||||
sema.to_struct_def(value)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn module(self, sema: &Semantics<'_, RootDatabase>) -> Module {
|
|
||||||
self.module(sema.db)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl AddressableHir<ast::Enum> for Enum {
|
|
||||||
fn name(self, sema: &Semantics<'_, RootDatabase>) -> Option<String> {
|
|
||||||
Some(self.name(sema.db).as_str().to_owned())
|
|
||||||
}
|
|
||||||
|
|
||||||
fn try_from_source(value: &ast::Enum, sema: &Semantics<'_, RootDatabase>) -> Option<Self> {
|
|
||||||
sema.to_enum_def(value)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn module(self, sema: &Semantics<'_, RootDatabase>) -> Module {
|
|
||||||
self.module(sema.db)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl AddressableHir<ast::Union> for Union {
|
|
||||||
fn name(self, sema: &Semantics<'_, RootDatabase>) -> Option<String> {
|
|
||||||
Some(self.name(sema.db).as_str().to_owned())
|
|
||||||
}
|
|
||||||
|
|
||||||
fn try_from_source(value: &ast::Union, sema: &Semantics<'_, RootDatabase>) -> Option<Self> {
|
|
||||||
sema.to_union_def(value)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn module(self, sema: &Semantics<'_, RootDatabase>) -> Module {
|
|
||||||
self.module(sema.db)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub(crate) trait AddressableAst: AstNode + Sized {
|
|
||||||
type Hir: AddressableHir<Self>;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl AddressableAst for ast::Fn {
|
|
||||||
type Hir = Function;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl AddressableAst for ast::Trait {
|
|
||||||
type Hir = Trait;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl AddressableAst for ast::Struct {
|
|
||||||
type Hir = Struct;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl AddressableAst for ast::Enum {
|
|
||||||
type Hir = Enum;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl AddressableAst for ast::Union {
|
|
||||||
type Hir = Union;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl AddressableAst for ast::Module {
|
|
||||||
type Hir = Module;
|
|
||||||
}
|
|
||||||
|
|
||||||
pub trait PathAst: AstNode {
|
pub trait PathAst: AstNode {
|
||||||
fn path(&self) -> Option<ast::Path>;
|
fn path(&self) -> Option<ast::Path>;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user