Skip to content

Commit e437e38

Browse files
bors[bot]matklad
andauthored
Merge #6659
6659: Explain how we get precise spans for diagnostics. r=matklad a=matklad bors r+ 🤖 Co-authored-by: Aleksey Kladov <[email protected]>
2 parents 7f3ba7d + 5a42e6b commit e437e38

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

crates/hir_expand/src/diagnostics.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
//!
66
//! `DiagnosticSink` struct is used as an emitter for diagnostic. When creating
77
//! 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).
99
//!
1010
//! Because diagnostics store file offsets, it's a bad idea to store them
1111
//! directly in salsa. For this reason, every hir subsytem defines it's own
@@ -32,7 +32,12 @@ impl DiagnosticCode {
3232
pub trait Diagnostic: Any + Send + Sync + fmt::Debug + 'static {
3333
fn code(&self) -> DiagnosticCode;
3434
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.
3641
fn display_source(&self) -> InFile<SyntaxNodePtr>;
3742
fn as_any(&self) -> &(dyn Any + Send + 'static);
3843
fn is_experimental(&self) -> bool {

0 commit comments

Comments
 (0)