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() {
ast::StructKind::Tuple(field_list) => {
let pats = iter::repeat(make::wildcard_pat().into()).take(field_list.fields().count());
let parent_name = parent.name(ctx.db());
let target_module = parent.module(ctx.db());
+ #[allow(deprecated)]
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) => {
S: HasSource<Ast = Ast>,
Ast: AstNode + ast::VisibilityOwner,
{
+ #[allow(deprecated)]
let source = x.source_old(db);
let in_file_syntax = source.syntax();
let file_id = in_file_syntax.file_id;
items
.iter()
- .map(|i| match i {
- 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),
+ .map(|i| {
+ #[allow(deprecated)]
+ match i {
+ 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 {
};
let range = TextRange::new(fn_def_node.text_range().start(), ctx.source_range().end());
+ #[allow(deprecated)]
let function_decl = function_declaration(&func.source_old(ctx.db).value);
match ctx.config.snippet_cap {
Some(cap) => {
let const_name = const_.name(ctx.db).map(|n| n.to_string());
if let Some(const_name) = const_name {
+ #[allow(deprecated)]
let snippet = make_const_compl_syntax(&const_.source_old(ctx.db).value);
let range = TextRange::new(const_def_node.text_range().start(), ctx.source_range().end());
impl<'a> ConstRender<'a> {
fn new(ctx: RenderContext<'a>, const_: hir::Const) -> ConstRender<'a> {
+ #[allow(deprecated)]
let ast_node = const_.source_old(ctx.db()).value;
ConstRender { ctx, const_, ast_node }
}
fn_: hir::Function,
) -> FunctionRender<'a> {
let name = local_name.unwrap_or_else(|| fn_.name(ctx.db()).to_string());
+ #[allow(deprecated)]
let ast_node = fn_.source_old(ctx.db()).value;
FunctionRender { ctx, name, func: fn_, ast_node }
}
fn detail(&self) -> String {
+ #[allow(deprecated)]
let ast_node = self.macro_.source_old(self.ctx.db()).value;
macro_label(&ast_node)
}
impl<'a> TypeAliasRender<'a> {
fn new(ctx: RenderContext<'a>, type_alias: hir::TypeAlias) -> TypeAliasRender<'a> {
+ #[allow(deprecated)]
let ast_node = type_alias.source_old(ctx.db()).value;
TypeAliasRender { ctx, type_alias, ast_node }
}
if self.is_proc_macro() {
return None;
}
+ #[allow(deprecated)]
self.source_old(db).value.name().map(|it| it.as_name())
}
}
pub fn is_builtin_derive(self, db: &dyn HirDatabase) -> Option<InFile<ast::Attr>> {
+ #[allow(deprecated)]
let src = self.source_old(db);
let item = src.file_id.is_builtin_derive(db.upcast())?;
let hygenic = hir_expand::hygiene::Hygiene::new(db.upcast(), item.file_id);
pub trait HasSource {
type Ast;
+ #[deprecated = "migrating to source() method that returns an Option"]
fn source_old(self, db: &dyn HirDatabase) -> InFile<Self::Ast>;
fn source(self, db: &dyn HirDatabase) -> Option<InFile<Self::Ast>>;
}
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()?;
}
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()?;
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,
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 {
impl ToNav for hir::Field {
fn to_nav(&self, db: &RootDatabase) -> NavigationTarget {
+ #[allow(deprecated)]
let src = self.source_old(db);
match &src.value {
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(
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(),
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 {
_ => 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);
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)
D: HasSource<Ast = A> + 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)
}
let file_id = module_src.file_id.original_file(db);
if let Definition::Local(var) = self {
+ #[allow(deprecated)]
let range = match var.parent(db) {
DefWithBody::Function(f) => f.source_old(db).value.syntax().text_range(),
DefWithBody::Const(c) => c.source_old(db).value.syntax().text_range(),
}
if let Definition::LifetimeParam(param) = self {
+ #[allow(deprecated)]
let range = match param.parent(db) {
hir::GenericDef::Function(it) => it.source_old(db).value.syntax().text_range(),
hir::GenericDef::Adt(it) => match it {
}
let mut msg = format!("processing: {}", full_name);
if verbosity.is_verbose() {
+ #[allow(deprecated)]
let src = f.source_old(db);
let original_file = src.file_id.original_file(db);
let path = vfs.file_path(original_file);