From ea4708c444509449b86c50b7b1b23f9ff5af4e97 Mon Sep 17 00:00:00 2001 From: Nick Spain Date: Fri, 1 Jan 2021 13:50:50 +1100 Subject: Mark HasSource::source_old as deprecated but allow at all call sites --- crates/ide/src/diagnostics/fixes.rs | 3 +++ crates/ide/src/display/navigation_target.rs | 6 ++++++ crates/ide/src/hover.rs | 4 ++++ 3 files changed, 13 insertions(+) (limited to 'crates/ide/src') diff --git a/crates/ide/src/diagnostics/fixes.rs b/crates/ide/src/diagnostics/fixes.rs index 702e8239d..0b5e0a4c1 100644 --- a/crates/ide/src/diagnostics/fixes.rs +++ b/crates/ide/src/diagnostics/fixes.rs @@ -156,6 +156,7 @@ fn missing_record_expr_field_fix( let record_fields = match VariantDef::from(def_id) { VariantDef::Struct(s) => { module = s.module(sema.db); + #[allow(deprecated)] let source = s.source_old(sema.db); def_file_id = source.file_id; let fields = source.value.field_list()?; @@ -163,12 +164,14 @@ fn missing_record_expr_field_fix( } VariantDef::Union(u) => { module = u.module(sema.db); + #[allow(deprecated)] let source = u.source_old(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); def_file_id = source.file_id; let fields = source.value.field_list()?; diff --git a/crates/ide/src/display/navigation_target.rs b/crates/ide/src/display/navigation_target.rs index de4c0fa12..efa0418ad 100644 --- a/crates/ide/src/display/navigation_target.rs +++ b/crates/ide/src/display/navigation_target.rs @@ -285,6 +285,7 @@ where D::Ast: ast::NameOwner + ShortLabel, { fn to_nav(&self, db: &RootDatabase) -> NavigationTarget { + #[allow(deprecated)] let src = self.source_old(db); let mut res = NavigationTarget::from_named( db, @@ -314,6 +315,7 @@ impl ToNav for hir::Module { impl ToNav for hir::Impl { fn to_nav(&self, db: &RootDatabase) -> NavigationTarget { + #[allow(deprecated)] let src = self.source_old(db); let derive_attr = self.is_builtin_derive(db); let frange = if let Some(item) = &derive_attr { @@ -339,6 +341,7 @@ impl ToNav for hir::Impl { impl ToNav for hir::Field { fn to_nav(&self, db: &RootDatabase) -> NavigationTarget { + #[allow(deprecated)] let src = self.source_old(db); match &src.value { @@ -365,6 +368,7 @@ impl ToNav for hir::Field { impl ToNav for hir::MacroDef { fn to_nav(&self, db: &RootDatabase) -> NavigationTarget { + #[allow(deprecated)] let src = self.source_old(db); log::debug!("nav target {:#?}", src.value.syntax()); let mut res = NavigationTarget::from_named( @@ -448,6 +452,7 @@ impl ToNav for hir::Label { impl ToNav for hir::TypeParam { fn to_nav(&self, db: &RootDatabase) -> NavigationTarget { + #[allow(deprecated)] let src = self.source_old(db); let full_range = match &src.value { Either::Left(it) => it.syntax().text_range(), @@ -472,6 +477,7 @@ impl ToNav for hir::TypeParam { impl ToNav for hir::LifetimeParam { fn to_nav(&self, db: &RootDatabase) -> NavigationTarget { + #[allow(deprecated)] let src = self.source_old(db); let full_range = src.value.syntax().text_range(); NavigationTarget { diff --git a/crates/ide/src/hover.rs b/crates/ide/src/hover.rs index 90781ea34..c192e3ed7 100644 --- a/crates/ide/src/hover.rs +++ b/crates/ide/src/hover.rs @@ -206,6 +206,7 @@ fn runnable_action( _ => None, }, ModuleDef::Function(it) => { + #[allow(deprecated)] let src = it.source_old(sema.db); if src.file_id != file_id.into() { mark::hit!(hover_macro_generated_struct_fn_doc_comment); @@ -332,10 +333,12 @@ fn hover_for_definition(db: &RootDatabase, def: Definition) -> Option { if it.is_proc_macro() { return None; } + #[allow(deprecated)] let label = macro_label(&it.source_old(db).value); from_def_source_labeled(db, it, Some(label), mod_path) } Definition::Field(def) => { + #[allow(deprecated)] let src = def.source_old(db).value; if let FieldSource::Named(it) = src { from_def_source_labeled(db, def, it.short_label(), mod_path) @@ -385,6 +388,7 @@ fn hover_for_definition(db: &RootDatabase, def: Definition) -> Option { D: HasSource + HasAttrs + Copy, A: ShortLabel, { + #[allow(deprecated)] let short_label = def.source_old(db).value.short_label(); from_def_source_labeled(db, def, short_label, mod_path) } -- cgit v1.2.3