9895: minor: Simplify r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
This commit is contained in:
bors[bot] 2021-08-14 16:07:09 +00:00 committed by GitHub
commit 5a60e9106b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 15 deletions

View file

@ -70,14 +70,8 @@ pub(crate) fn annotations(
hir::ModuleDef::Trait(trait_) => { hir::ModuleDef::Trait(trait_) => {
trait_.source(db).and_then(|node| name_range(&node, file_id)) trait_.source(db).and_then(|node| name_range(&node, file_id))
} }
hir::ModuleDef::Adt(hir::Adt::Struct(strukt)) => { hir::ModuleDef::Adt(adt) => {
strukt.source(db).and_then(|node| name_range(&node, file_id)) adt.source(db).and_then(|node| name_range(&node, file_id))
}
hir::ModuleDef::Adt(hir::Adt::Enum(enum_)) => {
enum_.source(db).and_then(|node| name_range(&node, file_id))
}
hir::ModuleDef::Adt(hir::Adt::Union(union)) => {
union.source(db).and_then(|node| name_range(&node, file_id))
} }
_ => None, _ => None,
}; };

View file

@ -528,6 +528,7 @@ pub(crate) fn description_from_symbol(db: &RootDatabase, symbol: &FileSymbol) ->
ast::Static(it) => sema.to_def(&it).map(|it| it.display(db).to_string()), ast::Static(it) => sema.to_def(&it).map(|it| it.display(db).to_string()),
ast::RecordField(it) => sema.to_def(&it).map(|it| it.display(db).to_string()), ast::RecordField(it) => sema.to_def(&it).map(|it| it.display(db).to_string()),
ast::Variant(it) => sema.to_def(&it).map(|it| it.display(db).to_string()), ast::Variant(it) => sema.to_def(&it).map(|it| it.display(db).to_string()),
ast::Union(it) => sema.to_def(&it).map(|it| it.display(db).to_string()),
_ => None, _ => None,
} }
} }

View file

@ -246,13 +246,9 @@ impl Definition {
hir::GenericDef::Function(it) => { hir::GenericDef::Function(it) => {
it.source(db).map(|src| src.value.syntax().text_range()) it.source(db).map(|src| src.value.syntax().text_range())
} }
hir::GenericDef::Adt(it) => match it { hir::GenericDef::Adt(it) => {
hir::Adt::Struct(it) => { it.source(db).map(|src| src.value.syntax().text_range())
it.source(db).map(|src| src.value.syntax().text_range()) }
}
hir::Adt::Union(it) => it.source(db).map(|src| src.value.syntax().text_range()),
hir::Adt::Enum(it) => it.source(db).map(|src| src.value.syntax().text_range()),
},
hir::GenericDef::Trait(it) => { hir::GenericDef::Trait(it) => {
it.source(db).map(|src| src.value.syntax().text_range()) it.source(db).map(|src| src.value.syntax().text_range())
} }