From 7022ea52b5f2a0262c2cd96b290ddb8ec0af0df9 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sun, 7 Feb 2021 14:15:02 +0300 Subject: AdtDef -> Adt --- crates/assists/src/handlers/add_lifetime_to_type.rs | 10 +++++----- crates/assists/src/handlers/generate_derive.rs | 4 ++-- crates/assists/src/handlers/generate_enum_match_method.rs | 2 +- crates/assists/src/handlers/generate_impl.rs | 2 +- crates/assists/src/handlers/generate_new.rs | 2 +- crates/assists/src/utils.rs | 8 ++++---- 6 files changed, 14 insertions(+), 14 deletions(-) (limited to 'crates/assists') diff --git a/crates/assists/src/handlers/add_lifetime_to_type.rs b/crates/assists/src/handlers/add_lifetime_to_type.rs index c1603e972..2edf7b204 100644 --- a/crates/assists/src/handlers/add_lifetime_to_type.rs +++ b/crates/assists/src/handlers/add_lifetime_to_type.rs @@ -26,7 +26,7 @@ pub(crate) fn add_lifetime_to_type(acc: &mut Assists, ctx: &AssistContext) -> Op return None; } - let node = ctx.find_node_at_offset::()?; + let node = ctx.find_node_at_offset::()?; let has_lifetime = node .generic_param_list() .map(|gen_list| gen_list.lifetime_params().count() > 0) @@ -66,9 +66,9 @@ pub(crate) fn add_lifetime_to_type(acc: &mut Assists, ctx: &AssistContext) -> Op ) } -fn fetch_borrowed_types(node: &ast::AdtDef) -> Option> { +fn fetch_borrowed_types(node: &ast::Adt) -> Option> { let ref_types: Vec = match node { - ast::AdtDef::Enum(enum_) => { + ast::Adt::Enum(enum_) => { let variant_list = enum_.variant_list()?; variant_list .variants() @@ -80,11 +80,11 @@ fn fetch_borrowed_types(node: &ast::AdtDef) -> Option> { .flatten() .collect() } - ast::AdtDef::Struct(strukt) => { + ast::Adt::Struct(strukt) => { let field_list = strukt.field_list()?; find_ref_types_from_field_list(&field_list)? } - ast::AdtDef::Union(un) => { + ast::Adt::Union(un) => { let record_field_list = un.record_field_list()?; record_field_list .fields() diff --git a/crates/assists/src/handlers/generate_derive.rs b/crates/assists/src/handlers/generate_derive.rs index f876b7684..adae8ab7e 100644 --- a/crates/assists/src/handlers/generate_derive.rs +++ b/crates/assists/src/handlers/generate_derive.rs @@ -26,7 +26,7 @@ use crate::{AssistContext, AssistId, AssistKind, Assists}; // ``` pub(crate) fn generate_derive(acc: &mut Assists, ctx: &AssistContext) -> Option<()> { let cap = ctx.config.snippet_cap?; - let nominal = ctx.find_node_at_offset::()?; + let nominal = ctx.find_node_at_offset::()?; let node_start = derive_insertion_offset(&nominal)?; let target = nominal.syntax().text_range(); acc.add( @@ -58,7 +58,7 @@ pub(crate) fn generate_derive(acc: &mut Assists, ctx: &AssistContext) -> Option< } // Insert `derive` after doc comments. -fn derive_insertion_offset(nominal: &ast::AdtDef) -> Option { +fn derive_insertion_offset(nominal: &ast::Adt) -> Option { let non_ws_child = nominal .syntax() .children_with_tokens() diff --git a/crates/assists/src/handlers/generate_enum_match_method.rs b/crates/assists/src/handlers/generate_enum_match_method.rs index 4cf66b5d5..9d6b161c9 100644 --- a/crates/assists/src/handlers/generate_enum_match_method.rs +++ b/crates/assists/src/handlers/generate_enum_match_method.rs @@ -49,7 +49,7 @@ pub(crate) fn generate_enum_match_method(acc: &mut Assists, ctx: &AssistContext) // Return early if we've found an existing new fn let impl_def = find_struct_impl( &ctx, - &ast::AdtDef::Enum(parent_enum.clone()), + &ast::Adt::Enum(parent_enum.clone()), format!("is_{}", fn_name).as_str(), )?; diff --git a/crates/assists/src/handlers/generate_impl.rs b/crates/assists/src/handlers/generate_impl.rs index 827477272..61d1bd25c 100644 --- a/crates/assists/src/handlers/generate_impl.rs +++ b/crates/assists/src/handlers/generate_impl.rs @@ -27,7 +27,7 @@ use crate::{AssistContext, AssistId, AssistKind, Assists}; // } // ``` pub(crate) fn generate_impl(acc: &mut Assists, ctx: &AssistContext) -> Option<()> { - let nominal = ctx.find_node_at_offset::()?; + let nominal = ctx.find_node_at_offset::()?; let name = nominal.name()?; let target = nominal.syntax().text_range(); diff --git a/crates/assists/src/handlers/generate_new.rs b/crates/assists/src/handlers/generate_new.rs index 307f2e228..a9203d33f 100644 --- a/crates/assists/src/handlers/generate_new.rs +++ b/crates/assists/src/handlers/generate_new.rs @@ -40,7 +40,7 @@ pub(crate) fn generate_new(acc: &mut Assists, ctx: &AssistContext) -> Option<()> }; // Return early if we've found an existing new fn - let impl_def = find_struct_impl(&ctx, &ast::AdtDef::Struct(strukt.clone()), "new")?; + let impl_def = find_struct_impl(&ctx, &ast::Adt::Struct(strukt.clone()), "new")?; let target = strukt.syntax().text_range(); acc.add(AssistId("generate_new", AssistKind::Generate), "Generate `new`", target, |builder| { diff --git a/crates/assists/src/utils.rs b/crates/assists/src/utils.rs index 8045aac40..cd80c2958 100644 --- a/crates/assists/src/utils.rs +++ b/crates/assists/src/utils.rs @@ -281,7 +281,7 @@ pub(crate) fn does_pat_match_variant(pat: &ast::Pat, var: &ast::Pat) -> bool { // FIXME: this partially overlaps with `find_impl_block` pub(crate) fn find_struct_impl( ctx: &AssistContext, - strukt: &ast::AdtDef, + strukt: &ast::Adt, name: &str, ) -> Option> { let db = ctx.db(); @@ -290,9 +290,9 @@ pub(crate) fn find_struct_impl( })?; let struct_def = match strukt { - ast::AdtDef::Enum(e) => Adt::Enum(ctx.sema.to_def(e)?), - ast::AdtDef::Struct(s) => Adt::Struct(ctx.sema.to_def(s)?), - ast::AdtDef::Union(u) => Adt::Union(ctx.sema.to_def(u)?), + ast::Adt::Enum(e) => Adt::Enum(ctx.sema.to_def(e)?), + ast::Adt::Struct(s) => Adt::Struct(ctx.sema.to_def(s)?), + ast::Adt::Union(u) => Adt::Union(ctx.sema.to_def(u)?), }; let block = module.descendants().filter_map(ast::Impl::cast).find_map(|impl_blk| { -- cgit v1.2.3