From c6143742bd4e625d391ac3ea860be7578ab9f53f Mon Sep 17 00:00:00 2001 From: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com> Date: Thu, 21 May 2020 10:48:42 +0200 Subject: add support of feature flag for runnables #4464 Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com> --- crates/ra_hir_def/src/attr.rs | 2 +- crates/ra_hir_def/src/body.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'crates/ra_hir_def') diff --git a/crates/ra_hir_def/src/attr.rs b/crates/ra_hir_def/src/attr.rs index 576cd0c65..8b6c0bede 100644 --- a/crates/ra_hir_def/src/attr.rs +++ b/crates/ra_hir_def/src/attr.rs @@ -81,7 +81,7 @@ impl Attrs { } } - fn from_attrs_owner(db: &dyn DefDatabase, owner: InFile<&dyn AttrsOwner>) -> Attrs { + pub fn from_attrs_owner(db: &dyn DefDatabase, owner: InFile<&dyn AttrsOwner>) -> Attrs { let hygiene = Hygiene::new(db.upcast(), owner.file_id); Attrs::new(owner.value, &hygiene) } diff --git a/crates/ra_hir_def/src/body.rs b/crates/ra_hir_def/src/body.rs index f5a7305dc..273036cee 100644 --- a/crates/ra_hir_def/src/body.rs +++ b/crates/ra_hir_def/src/body.rs @@ -29,7 +29,7 @@ use crate::{ AsMacroCall, DefWithBodyId, HasModule, Lookup, ModuleId, }; -/// A subset of Exander that only deals with cfg attributes. We only need it to +/// A subset of Expander that only deals with cfg attributes. We only need it to /// avoid cyclic queries in crate def map during enum processing. pub(crate) struct CfgExpander { cfg_options: CfgOptions, -- cgit v1.2.3 From a5cc9a8a9ba1e6a0fc281e149881abdd3bd075c1 Mon Sep 17 00:00:00 2001 From: Jeremy Kolb Date: Mon, 25 May 2020 13:35:52 -0400 Subject: Fix some clippy perf warnings --- crates/ra_hir_def/src/lang_item.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'crates/ra_hir_def') diff --git a/crates/ra_hir_def/src/lang_item.rs b/crates/ra_hir_def/src/lang_item.rs index d962db3cc..3516784b8 100644 --- a/crates/ra_hir_def/src/lang_item.rs +++ b/crates/ra_hir_def/src/lang_item.rs @@ -164,7 +164,7 @@ impl LangItems { T: Into + Copy, { if let Some(lang_item_name) = lang_attr(db, item) { - self.items.entry(lang_item_name.clone()).or_insert_with(|| constructor(item)); + self.items.entry(lang_item_name).or_insert_with(|| constructor(item)); } } } -- cgit v1.2.3 From bee4f8f9fee56bb00b462cdf4ad3ed317fed682f Mon Sep 17 00:00:00 2001 From: kjeremy Date: Tue, 26 May 2020 14:12:13 -0400 Subject: Pass trivially copy types as copy --- crates/ra_hir_def/src/nameres/raw.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'crates/ra_hir_def') diff --git a/crates/ra_hir_def/src/nameres/raw.rs b/crates/ra_hir_def/src/nameres/raw.rs index 4e628b14d..f44baa579 100644 --- a/crates/ra_hir_def/src/nameres/raw.rs +++ b/crates/ra_hir_def/src/nameres/raw.rs @@ -175,7 +175,7 @@ pub(super) enum DefKind { } impl DefKind { - pub fn ast_id(&self) -> FileAstId { + pub fn ast_id(self) -> FileAstId { match self { DefKind::Function(it) => it.upcast(), DefKind::Struct(it, _) => it.upcast(), -- cgit v1.2.3 From 367487fe88dca78cffad5138673d5259f7f7ba6b Mon Sep 17 00:00:00 2001 From: robojumper Date: Thu, 28 May 2020 21:42:22 +0200 Subject: Support raw_ref_op's raw reference operator --- crates/ra_hir_def/src/body/lower.rs | 19 ++++++++++++++++--- crates/ra_hir_def/src/expr.rs | 3 ++- crates/ra_hir_def/src/type_ref.rs | 16 ++++++++++++++++ 3 files changed, 34 insertions(+), 4 deletions(-) (limited to 'crates/ra_hir_def') diff --git a/crates/ra_hir_def/src/body/lower.rs b/crates/ra_hir_def/src/body/lower.rs index e08d62dd6..905c0cf5d 100644 --- a/crates/ra_hir_def/src/body/lower.rs +++ b/crates/ra_hir_def/src/body/lower.rs @@ -28,7 +28,7 @@ use crate::{ }, item_scope::BuiltinShadowMode, path::{GenericArgs, Path}, - type_ref::{Mutability, TypeRef}, + type_ref::{Mutability, Rawness, TypeRef}, AdtId, ConstLoc, ContainerId, DefWithBodyId, EnumLoc, FunctionLoc, Intern, ModuleDefId, StaticLoc, StructLoc, TraitLoc, TypeAliasLoc, UnionLoc, }; @@ -378,8 +378,21 @@ impl ExprCollector<'_> { } ast::Expr::RefExpr(e) => { let expr = self.collect_expr_opt(e.expr()); - let mutability = Mutability::from_mutable(e.mut_token().is_some()); - self.alloc_expr(Expr::Ref { expr, mutability }, syntax_ptr) + let raw_tok = e.raw_token().is_some(); + let mutability = if raw_tok { + if e.mut_token().is_some() { + Mutability::Mut + } else if e.const_token().is_some() { + Mutability::Shared + } else { + unreachable!("parser only remaps to raw_token() if matching mutability token follows") + } + } else { + Mutability::from_mutable(e.mut_token().is_some()) + }; + let rawness = Rawness::from_raw(raw_tok); + + self.alloc_expr(Expr::Ref { expr, rawness, mutability }, syntax_ptr) } ast::Expr::PrefixExpr(e) => { let expr = self.collect_expr_opt(e.expr()); diff --git a/crates/ra_hir_def/src/expr.rs b/crates/ra_hir_def/src/expr.rs index a0cdad529..f25c6f958 100644 --- a/crates/ra_hir_def/src/expr.rs +++ b/crates/ra_hir_def/src/expr.rs @@ -19,7 +19,7 @@ use ra_syntax::ast::RangeOp; use crate::{ builtin_type::{BuiltinFloat, BuiltinInt}, path::{GenericArgs, Path}, - type_ref::{Mutability, TypeRef}, + type_ref::{Mutability, Rawness, TypeRef}, }; pub type ExprId = Idx; @@ -110,6 +110,7 @@ pub enum Expr { }, Ref { expr: ExprId, + rawness: Rawness, mutability: Mutability, }, Box { diff --git a/crates/ra_hir_def/src/type_ref.rs b/crates/ra_hir_def/src/type_ref.rs index 5bdad9efd..86a77b704 100644 --- a/crates/ra_hir_def/src/type_ref.rs +++ b/crates/ra_hir_def/src/type_ref.rs @@ -35,6 +35,22 @@ impl Mutability { } } +#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)] +pub enum Rawness { + RawPtr, + Ref, +} + +impl Rawness { + pub fn from_raw(is_raw: bool) -> Rawness { + if is_raw { + Rawness::RawPtr + } else { + Rawness::Ref + } + } +} + /// Compare ty::Ty #[derive(Clone, PartialEq, Eq, Hash, Debug)] pub enum TypeRef { -- cgit v1.2.3 From 1cd78a3355ea70d3070cabb00c80a5d195499752 Mon Sep 17 00:00:00 2001 From: robojumper Date: Sun, 31 May 2020 10:59:40 +0200 Subject: correctly infer labelled breaks --- crates/ra_hir_def/src/body/lower.rs | 56 +++++++++++++++++++++++++++++-------- crates/ra_hir_def/src/body/scope.rs | 4 +-- crates/ra_hir_def/src/expr.rs | 19 +++++++++---- 3 files changed, 60 insertions(+), 19 deletions(-) (limited to 'crates/ra_hir_def') diff --git a/crates/ra_hir_def/src/body/lower.rs b/crates/ra_hir_def/src/body/lower.rs index 905c0cf5d..dc52c6bd9 100644 --- a/crates/ra_hir_def/src/body/lower.rs +++ b/crates/ra_hir_def/src/body/lower.rs @@ -134,7 +134,7 @@ impl ExprCollector<'_> { self.make_expr(expr, Err(SyntheticSyntax)) } fn empty_block(&mut self) -> ExprId { - self.alloc_expr_desugared(Expr::Block { statements: Vec::new(), tail: None }) + self.alloc_expr_desugared(Expr::Block { statements: Vec::new(), tail: None, label: None }) } fn missing_expr(&mut self) -> ExprId { self.alloc_expr_desugared(Expr::Missing) @@ -215,7 +215,13 @@ impl ExprCollector<'_> { ast::Expr::BlockExpr(e) => self.collect_block(e), ast::Expr::LoopExpr(e) => { let body = self.collect_block_opt(e.loop_body()); - self.alloc_expr(Expr::Loop { body }, syntax_ptr) + self.alloc_expr( + Expr::Loop { + body, + label: e.label().and_then(|l| l.lifetime_token()).map(|l| Name::new_lifetime(&l)), + }, + syntax_ptr, + ) } ast::Expr::WhileExpr(e) => { let body = self.collect_block_opt(e.loop_body()); @@ -230,25 +236,47 @@ impl ExprCollector<'_> { let pat = self.collect_pat(pat); let match_expr = self.collect_expr_opt(condition.expr()); let placeholder_pat = self.missing_pat(); - let break_ = self.alloc_expr_desugared(Expr::Break { expr: None }); + let break_ = + self.alloc_expr_desugared(Expr::Break { expr: None, label: None }); let arms = vec![ MatchArm { pat, expr: body, guard: None }, MatchArm { pat: placeholder_pat, expr: break_, guard: None }, ]; let match_expr = self.alloc_expr_desugared(Expr::Match { expr: match_expr, arms }); - return self.alloc_expr(Expr::Loop { body: match_expr }, syntax_ptr); + return self.alloc_expr( + Expr::Loop { + body: match_expr, + label: e.label().and_then(|l| l.lifetime_token()).map(|l| Name::new_lifetime(&l)), + }, + syntax_ptr, + ); } }, }; - self.alloc_expr(Expr::While { condition, body }, syntax_ptr) + self.alloc_expr( + Expr::While { + condition, + body, + label: e.label().and_then(|l| l.lifetime_token()).map(|l| Name::new_lifetime(&l)), + }, + syntax_ptr, + ) } ast::Expr::ForExpr(e) => { let iterable = self.collect_expr_opt(e.iterable()); let pat = self.collect_pat_opt(e.pat()); let body = self.collect_block_opt(e.loop_body()); - self.alloc_expr(Expr::For { iterable, pat, body }, syntax_ptr) + self.alloc_expr( + Expr::For { + iterable, + pat, + body, + label: e.label().and_then(|l| l.lifetime_token()).map(|l| Name::new_lifetime(&l)), + }, + syntax_ptr, + ) } ast::Expr::CallExpr(e) => { let callee = self.collect_expr_opt(e.expr()); @@ -301,13 +329,18 @@ impl ExprCollector<'_> { .unwrap_or(Expr::Missing); self.alloc_expr(path, syntax_ptr) } - ast::Expr::ContinueExpr(_e) => { - // FIXME: labels - self.alloc_expr(Expr::Continue, syntax_ptr) + ast::Expr::ContinueExpr(e) => { + self.alloc_expr( + Expr::Continue { label: e.lifetime_token().map(|l| Name::new_lifetime(&l)) }, + syntax_ptr, + ) } ast::Expr::BreakExpr(e) => { let expr = e.expr().map(|e| self.collect_expr(e)); - self.alloc_expr(Expr::Break { expr }, syntax_ptr) + self.alloc_expr( + Expr::Break { expr, label: e.lifetime_token().map(|l| Name::new_lifetime(&l)) }, + syntax_ptr, + ) } ast::Expr::ParenExpr(e) => { let inner = self.collect_expr_opt(e.expr()); @@ -529,7 +562,8 @@ impl ExprCollector<'_> { }) .collect(); let tail = block.expr().map(|e| self.collect_expr(e)); - self.alloc_expr(Expr::Block { statements, tail }, syntax_node_ptr) + let label = block.label().and_then(|l| l.lifetime_token()).map(|t| Name::new_lifetime(&t)); + self.alloc_expr(Expr::Block { statements, tail, label }, syntax_node_ptr) } fn collect_block_items(&mut self, block: &ast::BlockExpr) { diff --git a/crates/ra_hir_def/src/body/scope.rs b/crates/ra_hir_def/src/body/scope.rs index 09e92b74e..e48ff38f9 100644 --- a/crates/ra_hir_def/src/body/scope.rs +++ b/crates/ra_hir_def/src/body/scope.rs @@ -138,10 +138,10 @@ fn compute_block_scopes( fn compute_expr_scopes(expr: ExprId, body: &Body, scopes: &mut ExprScopes, scope: ScopeId) { scopes.set_scope(expr, scope); match &body[expr] { - Expr::Block { statements, tail } => { + Expr::Block { statements, tail, .. } => { compute_block_scopes(&statements, *tail, body, scopes, scope); } - Expr::For { iterable, pat, body: body_expr } => { + Expr::For { iterable, pat, body: body_expr, .. } => { compute_expr_scopes(*iterable, body, scopes, scope); let scope = scopes.new_scope(scope); scopes.add_bindings(body, scope, *pat); diff --git a/crates/ra_hir_def/src/expr.rs b/crates/ra_hir_def/src/expr.rs index f25c6f958..8683f6c7f 100644 --- a/crates/ra_hir_def/src/expr.rs +++ b/crates/ra_hir_def/src/expr.rs @@ -52,18 +52,22 @@ pub enum Expr { Block { statements: Vec, tail: Option, + label: Option, }, Loop { body: ExprId, + label: Option, }, While { condition: ExprId, body: ExprId, + label: Option, }, For { iterable: ExprId, pat: PatId, body: ExprId, + label: Option, }, Call { callee: ExprId, @@ -79,9 +83,12 @@ pub enum Expr { expr: ExprId, arms: Vec, }, - Continue, + Continue { + label: Option, + }, Break { expr: Option, + label: Option, }, Return { expr: Option, @@ -225,7 +232,7 @@ impl Expr { f(*else_branch); } } - Expr::Block { statements, tail } => { + Expr::Block { statements, tail, .. } => { for stmt in statements { match stmt { Statement::Let { initializer, .. } => { @@ -241,8 +248,8 @@ impl Expr { } } Expr::TryBlock { body } => f(*body), - Expr::Loop { body } => f(*body), - Expr::While { condition, body } => { + Expr::Loop { body, .. } => f(*body), + Expr::While { condition, body, .. } => { f(*condition); f(*body); } @@ -268,8 +275,8 @@ impl Expr { f(arm.expr); } } - Expr::Continue => {} - Expr::Break { expr } | Expr::Return { expr } => { + Expr::Continue { .. } => {}, + Expr::Break { expr, .. } | Expr::Return { expr } => { if let Some(expr) = expr { f(*expr); } -- cgit v1.2.3 From cc6ba84c400417af873462364ba5cd4f6b5ab1f6 Mon Sep 17 00:00:00 2001 From: robojumper Date: Sun, 31 May 2020 12:06:22 +0200 Subject: fmt --- crates/ra_hir_def/src/body/lower.rs | 30 ++++++++++++++++++++---------- crates/ra_hir_def/src/expr.rs | 2 +- 2 files changed, 21 insertions(+), 11 deletions(-) (limited to 'crates/ra_hir_def') diff --git a/crates/ra_hir_def/src/body/lower.rs b/crates/ra_hir_def/src/body/lower.rs index dc52c6bd9..f159f80af 100644 --- a/crates/ra_hir_def/src/body/lower.rs +++ b/crates/ra_hir_def/src/body/lower.rs @@ -218,7 +218,10 @@ impl ExprCollector<'_> { self.alloc_expr( Expr::Loop { body, - label: e.label().and_then(|l| l.lifetime_token()).map(|l| Name::new_lifetime(&l)), + label: e + .label() + .and_then(|l| l.lifetime_token()) + .map(|l| Name::new_lifetime(&l)), }, syntax_ptr, ) @@ -247,7 +250,10 @@ impl ExprCollector<'_> { return self.alloc_expr( Expr::Loop { body: match_expr, - label: e.label().and_then(|l| l.lifetime_token()).map(|l| Name::new_lifetime(&l)), + label: e + .label() + .and_then(|l| l.lifetime_token()) + .map(|l| Name::new_lifetime(&l)), }, syntax_ptr, ); @@ -259,7 +265,10 @@ impl ExprCollector<'_> { Expr::While { condition, body, - label: e.label().and_then(|l| l.lifetime_token()).map(|l| Name::new_lifetime(&l)), + label: e + .label() + .and_then(|l| l.lifetime_token()) + .map(|l| Name::new_lifetime(&l)), }, syntax_ptr, ) @@ -273,7 +282,10 @@ impl ExprCollector<'_> { iterable, pat, body, - label: e.label().and_then(|l| l.lifetime_token()).map(|l| Name::new_lifetime(&l)), + label: e + .label() + .and_then(|l| l.lifetime_token()) + .map(|l| Name::new_lifetime(&l)), }, syntax_ptr, ) @@ -329,12 +341,10 @@ impl ExprCollector<'_> { .unwrap_or(Expr::Missing); self.alloc_expr(path, syntax_ptr) } - ast::Expr::ContinueExpr(e) => { - self.alloc_expr( - Expr::Continue { label: e.lifetime_token().map(|l| Name::new_lifetime(&l)) }, - syntax_ptr, - ) - } + ast::Expr::ContinueExpr(e) => self.alloc_expr( + Expr::Continue { label: e.lifetime_token().map(|l| Name::new_lifetime(&l)) }, + syntax_ptr, + ), ast::Expr::BreakExpr(e) => { let expr = e.expr().map(|e| self.collect_expr(e)); self.alloc_expr( diff --git a/crates/ra_hir_def/src/expr.rs b/crates/ra_hir_def/src/expr.rs index 8683f6c7f..ca49b26d1 100644 --- a/crates/ra_hir_def/src/expr.rs +++ b/crates/ra_hir_def/src/expr.rs @@ -275,7 +275,7 @@ impl Expr { f(arm.expr); } } - Expr::Continue { .. } => {}, + Expr::Continue { .. } => {} Expr::Break { expr, .. } | Expr::Return { expr } => { if let Some(expr) = expr { f(*expr); -- cgit v1.2.3 From a9cb2933fbeddef4ed70bde77ded4f9bb185548e Mon Sep 17 00:00:00 2001 From: Paul Daniel Faria Date: Tue, 2 Jun 2020 18:49:09 -0400 Subject: Add highlight support for unsafe fn calls and raw ptr deref --- crates/ra_hir_def/src/data.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'crates/ra_hir_def') diff --git a/crates/ra_hir_def/src/data.rs b/crates/ra_hir_def/src/data.rs index e2130d931..807195d25 100644 --- a/crates/ra_hir_def/src/data.rs +++ b/crates/ra_hir_def/src/data.rs @@ -34,6 +34,7 @@ pub struct FunctionData { /// True if the first param is `self`. This is relevant to decide whether this /// can be called as a method. pub has_self_param: bool, + pub is_unsafe: bool, pub visibility: RawVisibility, } @@ -85,11 +86,14 @@ impl FunctionData { ret_type }; + let is_unsafe = src.value.unsafe_token().is_some(); + let vis_default = RawVisibility::default_for_container(loc.container); let visibility = RawVisibility::from_ast_with_default(db, vis_default, src.map(|s| s.visibility())); - let sig = FunctionData { name, params, ret_type, has_self_param, visibility, attrs }; + let sig = + FunctionData { name, params, ret_type, has_self_param, is_unsafe, visibility, attrs }; Arc::new(sig) } } -- cgit v1.2.3 From 4c655c01f31ceffae4f8219f9706992e0e7f188a Mon Sep 17 00:00:00 2001 From: Aaron Loucks Date: Sat, 30 May 2020 14:21:06 -0400 Subject: Enable hover and autocomplete docs on macro generated items --- crates/ra_hir_def/src/attr.rs | 8 +++++++- crates/ra_hir_def/src/docs.rs | 43 +++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 48 insertions(+), 3 deletions(-) (limited to 'crates/ra_hir_def') diff --git a/crates/ra_hir_def/src/attr.rs b/crates/ra_hir_def/src/attr.rs index 8b6c0bede..2eeba0572 100644 --- a/crates/ra_hir_def/src/attr.rs +++ b/crates/ra_hir_def/src/attr.rs @@ -87,12 +87,18 @@ impl Attrs { } pub(crate) fn new(owner: &dyn AttrsOwner, hygiene: &Hygiene) -> Attrs { + let docs = ast::CommentIter::from_syntax_node(owner.syntax()).doc_comment_text().map( + |docs_text| Attr { + input: Some(AttrInput::Literal(SmolStr::new(docs_text))), + path: ModPath::from(hir_expand::name!(doc)), + }, + ); let mut attrs = owner.attrs().peekable(); let entries = if attrs.peek().is_none() { // Avoid heap allocation None } else { - Some(attrs.flat_map(|ast| Attr::from_src(ast, hygiene)).collect()) + Some(attrs.flat_map(|ast| Attr::from_src(ast, hygiene)).chain(docs).collect()) }; Attrs { entries } } diff --git a/crates/ra_hir_def/src/docs.rs b/crates/ra_hir_def/src/docs.rs index b221ae1ce..74b9f8199 100644 --- a/crates/ra_hir_def/src/docs.rs +++ b/crates/ra_hir_def/src/docs.rs @@ -70,6 +70,45 @@ impl Documentation { } } -pub(crate) fn docs_from_ast(node: &impl ast::DocCommentsOwner) -> Option { - node.doc_comment_text().map(|it| Documentation::new(&it)) +pub(crate) fn docs_from_ast(node: &N) -> Option +where + N: ast::DocCommentsOwner + ast::AttrsOwner, +{ + let doc_comment_text = node.doc_comment_text(); + let doc_attr_text = expand_doc_attrs(node); + let docs = merge_doc_comments_and_attrs(doc_comment_text, doc_attr_text); + docs.map(|it| Documentation::new(&it)) +} + +fn merge_doc_comments_and_attrs( + doc_comment_text: Option, + doc_attr_text: Option, +) -> Option { + match (doc_comment_text, doc_attr_text) { + (Some(mut comment_text), Some(attr_text)) => { + comment_text.push_str("\n\n"); + comment_text.push_str(&attr_text); + Some(comment_text) + } + (Some(comment_text), None) => Some(comment_text), + (None, Some(attr_text)) => Some(attr_text), + (None, None) => None, + } +} + +fn expand_doc_attrs(owner: &dyn ast::AttrsOwner) -> Option { + let mut docs = String::new(); + for attr in owner.attrs() { + if let Some(("doc", value)) = + attr.as_simple_key_value().as_ref().map(|(k, v)| (k.as_str(), v.as_str())) + { + docs.push_str(value); + docs.push_str("\n\n"); + } + } + if docs.is_empty() { + None + } else { + Some(docs) + } } -- cgit v1.2.3 From 5837acce532e0cd65a1c0cb8c03cc18a4c22f327 Mon Sep 17 00:00:00 2001 From: Aaron Loucks Date: Sun, 31 May 2020 11:33:48 -0400 Subject: Add basic hover and completion doc tests for macro generated items --- crates/ra_hir_def/src/docs.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'crates/ra_hir_def') diff --git a/crates/ra_hir_def/src/docs.rs b/crates/ra_hir_def/src/docs.rs index 74b9f8199..ab43cd3d3 100644 --- a/crates/ra_hir_def/src/docs.rs +++ b/crates/ra_hir_def/src/docs.rs @@ -109,6 +109,6 @@ fn expand_doc_attrs(owner: &dyn ast::AttrsOwner) -> Option { if docs.is_empty() { None } else { - Some(docs) + Some(docs.trim_end_matches("\n\n").to_owned()) } } -- cgit v1.2.3 From 85c4edb0afbc7cc855c434e5e7ec69aa469e0c4b Mon Sep 17 00:00:00 2001 From: Aaron Loucks Date: Wed, 3 Jun 2020 06:14:56 -0400 Subject: Consolidate documentation expansion and merging Removes the duplicated `expand_doc_attrs` and `merge_doc_comments_and_attrs` functions from `ra_ide` and exposes the same functionality via `ra_hir::Documentation::from_ast`. --- crates/ra_hir_def/src/docs.rs | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'crates/ra_hir_def') diff --git a/crates/ra_hir_def/src/docs.rs b/crates/ra_hir_def/src/docs.rs index ab43cd3d3..2630b3d89 100644 --- a/crates/ra_hir_def/src/docs.rs +++ b/crates/ra_hir_def/src/docs.rs @@ -29,6 +29,13 @@ impl Documentation { Documentation(s.into()) } + pub fn from_ast(node: &N) -> Option + where + N: ast::DocCommentsOwner + ast::AttrsOwner, + { + docs_from_ast(node) + } + pub fn as_str(&self) -> &str { &*self.0 } -- cgit v1.2.3