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 +- 5 files changed, 10 insertions(+), 10 deletions(-) (limited to 'crates/assists/src/handlers') 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| { -- cgit v1.2.3