diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-05-03 05:56:59 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2020-05-03 05:56:59 +0100 |
commit | 2474f42ae95bffea7c0bc713f92322bfec4d59a7 (patch) | |
tree | aa7eb8f934a1ce4bcd32bd106fbbd2adafef023f /crates/ra_hir/src/code_model.rs | |
parent | 17bd79f4978f1bf7267b54f86d676eed44af02d0 (diff) | |
parent | 2fd054f276e6fd75237b476622d03eef2f18430a (diff) |
Merge #4270
4270: Improve derive macro completion r=edwin0cheng a=SomeoneToIgnore
* Adds completions for standard derive macros (considering their dependencies on each other, so we don't get compile errors)
* Adds completions for custom derive macros that are in scope, if the proc macro feature is enabled in the settings
* Separates macro completion from other completions to avoid incorrect completion propositions
Co-authored-by: Kirill Bulatov <[email protected]>
Diffstat (limited to 'crates/ra_hir/src/code_model.rs')
-rw-r--r-- | crates/ra_hir/src/code_model.rs | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/crates/ra_hir/src/code_model.rs b/crates/ra_hir/src/code_model.rs index af59aa1b6..a004363ee 100644 --- a/crates/ra_hir/src/code_model.rs +++ b/crates/ra_hir/src/code_model.rs | |||
@@ -19,7 +19,7 @@ use hir_def::{ | |||
19 | use hir_expand::{ | 19 | use hir_expand::{ |
20 | diagnostics::DiagnosticSink, | 20 | diagnostics::DiagnosticSink, |
21 | name::{name, AsName}, | 21 | name::{name, AsName}, |
22 | MacroDefId, | 22 | MacroDefId, MacroDefKind, |
23 | }; | 23 | }; |
24 | use hir_ty::{ | 24 | use hir_ty::{ |
25 | autoderef, display::HirFormatter, expr::ExprValidator, method_resolution, ApplicationTy, | 25 | autoderef, display::HirFormatter, expr::ExprValidator, method_resolution, ApplicationTy, |
@@ -762,13 +762,12 @@ impl MacroDef { | |||
762 | 762 | ||
763 | /// Indicate it is a proc-macro | 763 | /// Indicate it is a proc-macro |
764 | pub fn is_proc_macro(&self) -> bool { | 764 | pub fn is_proc_macro(&self) -> bool { |
765 | match self.id.kind { | 765 | matches!(self.id.kind, MacroDefKind::CustomDerive(_)) |
766 | hir_expand::MacroDefKind::Declarative => false, | 766 | } |
767 | hir_expand::MacroDefKind::BuiltIn(_) => false, | 767 | |
768 | hir_expand::MacroDefKind::BuiltInDerive(_) => false, | 768 | /// Indicate it is a derive macro |
769 | hir_expand::MacroDefKind::BuiltInEager(_) => false, | 769 | pub fn is_derive_macro(&self) -> bool { |
770 | hir_expand::MacroDefKind::CustomDerive(_) => true, | 770 | matches!(self.id.kind, MacroDefKind::CustomDerive(_) | MacroDefKind::BuiltInDerive(_)) |
771 | } | ||
772 | } | 771 | } |
773 | } | 772 | } |
774 | 773 | ||