From 27cadcd531c017aa7c78c6f7a36f2b7f2ce8a196 Mon Sep 17 00:00:00 2001 From: Nick Spain Date: Fri, 1 Jan 2021 13:05:28 +1100 Subject: HasSource::source -> HasSource::source_old To start migrating HasSource::source to return an Option. --- crates/assists/src/handlers/fill_match_arms.rs | 2 +- crates/assists/src/handlers/fix_visibility.rs | 4 ++-- crates/assists/src/utils.rs | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) (limited to 'crates/assists') diff --git a/crates/assists/src/handlers/fill_match_arms.rs b/crates/assists/src/handlers/fill_match_arms.rs index cb60a3128..a8efad6d6 100644 --- a/crates/assists/src/handlers/fill_match_arms.rs +++ b/crates/assists/src/handlers/fill_match_arms.rs @@ -196,7 +196,7 @@ fn build_pat(db: &RootDatabase, module: hir::Module, var: hir::Variant) -> Optio let path = mod_path_to_ast(&module.find_use_path(db, ModuleDef::from(var))?); // FIXME: use HIR for this; it doesn't currently expose struct vs. tuple vs. unit variants though - let pat: ast::Pat = match var.source(db).value.kind() { + let pat: ast::Pat = match var.source_old(db).value.kind() { ast::StructKind::Tuple(field_list) => { let pats = iter::repeat(make::wildcard_pat().into()).take(field_list.fields().count()); make::tuple_struct_pat(path, pats).into() diff --git a/crates/assists/src/handlers/fix_visibility.rs b/crates/assists/src/handlers/fix_visibility.rs index 8558a8ff0..d8150abd9 100644 --- a/crates/assists/src/handlers/fix_visibility.rs +++ b/crates/assists/src/handlers/fix_visibility.rs @@ -97,7 +97,7 @@ fn add_vis_to_referenced_record_field(acc: &mut Assists, ctx: &AssistContext) -> let parent_name = parent.name(ctx.db()); let target_module = parent.module(ctx.db()); - let in_file_source = record_field_def.source(ctx.db()); + let in_file_source = record_field_def.source_old(ctx.db()); let (offset, current_visibility, target) = match in_file_source.value { hir::FieldSource::Named(it) => { let s = it.syntax(); @@ -150,7 +150,7 @@ fn target_data_for_def( S: HasSource, Ast: AstNode + ast::VisibilityOwner, { - let source = x.source(db); + let source = x.source_old(db); let in_file_syntax = source.syntax(); let file_id = in_file_syntax.file_id; let syntax = in_file_syntax.value; diff --git a/crates/assists/src/utils.rs b/crates/assists/src/utils.rs index d41084b59..7ee7111ae 100644 --- a/crates/assists/src/utils.rs +++ b/crates/assists/src/utils.rs @@ -99,9 +99,9 @@ pub fn filter_assoc_items( items .iter() .map(|i| match i { - hir::AssocItem::Function(i) => ast::AssocItem::Fn(i.source(db).value), - hir::AssocItem::TypeAlias(i) => ast::AssocItem::TypeAlias(i.source(db).value), - hir::AssocItem::Const(i) => ast::AssocItem::Const(i.source(db).value), + hir::AssocItem::Function(i) => ast::AssocItem::Fn(i.source_old(db).value), + hir::AssocItem::TypeAlias(i) => ast::AssocItem::TypeAlias(i.source_old(db).value), + hir::AssocItem::Const(i) => ast::AssocItem::Const(i.source_old(db).value), }) .filter(has_def_name) .filter(|it| match it { -- cgit v1.2.3