diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2021-02-28 11:29:44 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2021-02-28 11:29:44 +0000 |
commit | 7ed2da652df2f8d81ca0d76a978da2074f8c64f3 (patch) | |
tree | 5e0c37057750cc897031a02ec4860462a4cea9ef /crates/hir | |
parent | c412d5f8d13cd55dc1873fb55e742a317c7846a8 (diff) | |
parent | 05729fd3c4aa542d162b54e7352c0d4bade62684 (diff) |
Merge #7805
7805: For unresolved macros, hightlight only the last segment r=matklad a=matklad
bors r+
🤖
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/hir')
-rw-r--r-- | crates/hir/src/diagnostics.rs | 4 | ||||
-rw-r--r-- | crates/hir/src/semantics.rs | 8 |
2 files changed, 6 insertions, 6 deletions
diff --git a/crates/hir/src/diagnostics.rs b/crates/hir/src/diagnostics.rs index 5343a036c..b1ebba516 100644 --- a/crates/hir/src/diagnostics.rs +++ b/crates/hir/src/diagnostics.rs | |||
@@ -1,5 +1,7 @@ | |||
1 | //! FIXME: write short doc here | 1 | //! FIXME: write short doc here |
2 | pub use hir_def::diagnostics::{InactiveCode, UnresolvedModule, UnresolvedProcMacro}; | 2 | pub use hir_def::diagnostics::{ |
3 | InactiveCode, UnresolvedMacroCall, UnresolvedModule, UnresolvedProcMacro, | ||
4 | }; | ||
3 | pub use hir_expand::diagnostics::{ | 5 | pub use hir_expand::diagnostics::{ |
4 | Diagnostic, DiagnosticCode, DiagnosticSink, DiagnosticSinkBuilder, | 6 | Diagnostic, DiagnosticCode, DiagnosticSink, DiagnosticSinkBuilder, |
5 | }; | 7 | }; |
diff --git a/crates/hir/src/semantics.rs b/crates/hir/src/semantics.rs index 59292d5a2..144851f83 100644 --- a/crates/hir/src/semantics.rs +++ b/crates/hir/src/semantics.rs | |||
@@ -16,13 +16,12 @@ use rustc_hash::{FxHashMap, FxHashSet}; | |||
16 | use syntax::{ | 16 | use syntax::{ |
17 | algo::find_node_at_offset, | 17 | algo::find_node_at_offset, |
18 | ast::{self, GenericParamsOwner, LoopBodyOwner}, | 18 | ast::{self, GenericParamsOwner, LoopBodyOwner}, |
19 | match_ast, AstNode, SyntaxNode, SyntaxToken, TextSize, | 19 | match_ast, AstNode, SyntaxNode, SyntaxNodePtr, SyntaxToken, TextSize, |
20 | }; | 20 | }; |
21 | 21 | ||
22 | use crate::{ | 22 | use crate::{ |
23 | code_model::Access, | 23 | code_model::Access, |
24 | db::HirDatabase, | 24 | db::HirDatabase, |
25 | diagnostics::Diagnostic, | ||
26 | semantics::source_to_def::{ChildContainer, SourceToDefCache, SourceToDefCtx}, | 25 | semantics::source_to_def::{ChildContainer, SourceToDefCache, SourceToDefCtx}, |
27 | source_analyzer::{resolve_hir_path, SourceAnalyzer}, | 26 | source_analyzer::{resolve_hir_path, SourceAnalyzer}, |
28 | AssocItem, Callable, ConstParam, Crate, Field, Function, HirFileId, Impl, InFile, Label, | 27 | AssocItem, Callable, ConstParam, Crate, Field, Function, HirFileId, Impl, InFile, Label, |
@@ -141,7 +140,7 @@ impl<'db, DB: HirDatabase> Semantics<'db, DB> { | |||
141 | self.imp.original_range(node) | 140 | self.imp.original_range(node) |
142 | } | 141 | } |
143 | 142 | ||
144 | pub fn diagnostics_display_range(&self, diagnostics: &dyn Diagnostic) -> FileRange { | 143 | pub fn diagnostics_display_range(&self, diagnostics: InFile<SyntaxNodePtr>) -> FileRange { |
145 | self.imp.diagnostics_display_range(diagnostics) | 144 | self.imp.diagnostics_display_range(diagnostics) |
146 | } | 145 | } |
147 | 146 | ||
@@ -385,8 +384,7 @@ impl<'db> SemanticsImpl<'db> { | |||
385 | node.as_ref().original_file_range(self.db.upcast()) | 384 | node.as_ref().original_file_range(self.db.upcast()) |
386 | } | 385 | } |
387 | 386 | ||
388 | fn diagnostics_display_range(&self, diagnostics: &dyn Diagnostic) -> FileRange { | 387 | fn diagnostics_display_range(&self, src: InFile<SyntaxNodePtr>) -> FileRange { |
389 | let src = diagnostics.display_source(); | ||
390 | let root = self.db.parse_or_expand(src.file_id).unwrap(); | 388 | let root = self.db.parse_or_expand(src.file_id).unwrap(); |
391 | let node = src.value.to_node(&root); | 389 | let node = src.value.to_node(&root); |
392 | self.cache(root, src.file_id); | 390 | self.cache(root, src.file_id); |