aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-11-28 15:16:33 +0000
committerGitHub <[email protected]>2020-11-28 15:16:33 +0000
commite437e38d7ac6804bdfbab4908aa217286481235e (patch)
treecb2763365028d11dc048044c20477a0f9b1b8610
parent7f3ba7d57fd2f43f3cfc012f898a26d940bf5cc8 (diff)
parent5a42e6bff541d42d6366a93b619b20732bb48dcf (diff)
Merge #6659
6659: Explain how we get precise spans for diagnostics. r=matklad a=matklad bors r+ 🤖 Co-authored-by: Aleksey Kladov <[email protected]>
-rw-r--r--crates/hir_expand/src/diagnostics.rs9
1 files changed, 7 insertions, 2 deletions
diff --git a/crates/hir_expand/src/diagnostics.rs b/crates/hir_expand/src/diagnostics.rs
index 1043c6aeb..bf0b85ce9 100644
--- a/crates/hir_expand/src/diagnostics.rs
+++ b/crates/hir_expand/src/diagnostics.rs
@@ -5,7 +5,7 @@
5//! 5//!
6//! `DiagnosticSink` struct is used as an emitter for diagnostic. When creating 6//! `DiagnosticSink` struct is used as an emitter for diagnostic. When creating
7//! a `DiagnosticSink`, you supply a callback which can react to a `dyn 7//! a `DiagnosticSink`, you supply a callback which can react to a `dyn
8//! Diagnostic` or to any concrete diagnostic (downcasting is sued internally). 8//! Diagnostic` or to any concrete diagnostic (downcasting is used internally).
9//! 9//!
10//! Because diagnostics store file offsets, it's a bad idea to store them 10//! Because diagnostics store file offsets, it's a bad idea to store them
11//! directly in salsa. For this reason, every hir subsytem defines it's own 11//! directly in salsa. For this reason, every hir subsytem defines it's own
@@ -32,7 +32,12 @@ impl DiagnosticCode {
32pub trait Diagnostic: Any + Send + Sync + fmt::Debug + 'static { 32pub trait Diagnostic: Any + Send + Sync + fmt::Debug + 'static {
33 fn code(&self) -> DiagnosticCode; 33 fn code(&self) -> DiagnosticCode;
34 fn message(&self) -> String; 34 fn message(&self) -> String;
35 /// Used in highlighting and related purposes 35 /// Source element that triggered the diagnostics.
36 ///
37 /// Note that this should reflect "semantics", rather than specific span we
38 /// want to highlight. When rendering the diagnostics into an error message,
39 /// the IDE will fetch the `SyntaxNode` and will narrow the span
40 /// appropriately.
36 fn display_source(&self) -> InFile<SyntaxNodePtr>; 41 fn display_source(&self) -> InFile<SyntaxNodePtr>;
37 fn as_any(&self) -> &(dyn Any + Send + 'static); 42 fn as_any(&self) -> &(dyn Any + Send + 'static);
38 fn is_experimental(&self) -> bool { 43 fn is_experimental(&self) -> bool {