source_old -> source for cases that can be handled by simple bubbling

This commit is contained in:
Nick Spain 2021-01-01 15:02:39 +11:00
parent 562e2ee28a
commit c936e4b86f
5 changed files with 10 additions and 13 deletions

View File

@ -196,8 +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
#[allow(deprecated)]
let pat: ast::Pat = match var.source_old(db).value.kind() {
let pat: ast::Pat = match var.source(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()

View File

@ -98,7 +98,7 @@ fn add_vis_to_referenced_record_field(acc: &mut Assists, ctx: &AssistContext) ->
let target_module = parent.module(ctx.db());
#[allow(deprecated)]
let in_file_source = record_field_def.source_old(ctx.db());
let in_file_source = record_field_def.source(ctx.db())?;
let (offset, current_visibility, target) = match in_file_source.value {
hir::FieldSource::Named(it) => {
let s = it.syntax();
@ -151,8 +151,7 @@ fn offset_target_and_file_id<S, Ast>(
S: HasSource<Ast = Ast>,
Ast: AstNode + ast::VisibilityOwner,
{
#[allow(deprecated)]
let source = x.source_old(db);
let source = x.source(db)?;
let in_file_syntax = source.syntax();
let file_id = in_file_syntax.file_id;
let syntax = in_file_syntax.value;

View File

@ -1372,8 +1372,7 @@ pub fn krate(self, db: &dyn HirDatabase) -> Crate {
}
pub fn is_builtin_derive(self, db: &dyn HirDatabase) -> Option<InFile<ast::Attr>> {
#[allow(deprecated)]
let src = self.source_old(db);
let src = self.source(db)?;
let item = src.file_id.is_builtin_derive(db.upcast())?;
let hygenic = hir_expand::hygiene::Hygiene::new(db.upcast(), item.file_id);

View File

@ -157,7 +157,7 @@ fn missing_record_expr_field_fix(
VariantDef::Struct(s) => {
module = s.module(sema.db);
#[allow(deprecated)]
let source = s.source_old(sema.db);
let source = s.source(sema.db)?;
def_file_id = source.file_id;
let fields = source.value.field_list()?;
record_field_list(fields)?
@ -165,14 +165,14 @@ fn missing_record_expr_field_fix(
VariantDef::Union(u) => {
module = u.module(sema.db);
#[allow(deprecated)]
let source = u.source_old(sema.db);
let source = u.source(sema.db)?;
def_file_id = source.file_id;
source.value.record_field_list()?
}
VariantDef::Variant(e) => {
module = e.module(sema.db);
#[allow(deprecated)]
let source = e.source_old(sema.db);
let source = e.source(sema.db)?;
def_file_id = source.file_id;
let fields = source.value.field_list()?;
record_field_list(fields)?

View File

@ -207,7 +207,7 @@ fn runnable_action(
},
ModuleDef::Function(it) => {
#[allow(deprecated)]
let src = it.source_old(sema.db);
let src = it.source(sema.db)?;
if src.file_id != file_id.into() {
mark::hit!(hover_macro_generated_struct_fn_doc_comment);
mark::hit!(hover_macro_generated_struct_fn_doc_attr);
@ -332,7 +332,7 @@ fn hover_for_definition(db: &RootDatabase, def: Definition) -> Option<Markup> {
}
Definition::Field(def) => {
#[allow(deprecated)]
let src = def.source_old(db).value;
let src = def.source(db)?.value;
if let FieldSource::Named(it) = src {
from_def_source_labeled(db, def, it.short_label(), mod_path)
} else {
@ -382,7 +382,7 @@ fn from_def_source<A, D>(db: &RootDatabase, def: D, mod_path: Option<String>) ->
A: ShortLabel,
{
#[allow(deprecated)]
let short_label = def.source_old(db).value.short_label();
let short_label = def.source(db)?.value.short_label();
from_def_source_labeled(db, def, short_label, mod_path)
}