mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-04 18:58:04 +00:00
ruff_db: add more dyn Diagnostic
impls
I found it useful to have the `&dyn Diagnostic` trait impl specifically. I added `Arc<dyn Diagnostic>` for completeness. (I do kind of wonder if we should be preferring `Arc<dyn ...>` over something like `Box<dyn ...>` more generally, especially for things with immutable APIs. It would make cloning cheap.)
This commit is contained in:
parent
ffd94e9ace
commit
54b3849dfb
1 changed files with 44 additions and 0 deletions
|
@ -375,6 +375,50 @@ impl Diagnostic for Box<dyn Diagnostic> {
|
|||
}
|
||||
}
|
||||
|
||||
impl Diagnostic for &'_ dyn Diagnostic {
|
||||
fn id(&self) -> DiagnosticId {
|
||||
(**self).id()
|
||||
}
|
||||
|
||||
fn message(&self) -> Cow<str> {
|
||||
(**self).message()
|
||||
}
|
||||
|
||||
fn file(&self) -> Option<File> {
|
||||
(**self).file()
|
||||
}
|
||||
|
||||
fn range(&self) -> Option<TextRange> {
|
||||
(**self).range()
|
||||
}
|
||||
|
||||
fn severity(&self) -> Severity {
|
||||
(**self).severity()
|
||||
}
|
||||
}
|
||||
|
||||
impl Diagnostic for std::sync::Arc<dyn Diagnostic> {
|
||||
fn id(&self) -> DiagnosticId {
|
||||
(**self).id()
|
||||
}
|
||||
|
||||
fn message(&self) -> Cow<str> {
|
||||
(**self).message()
|
||||
}
|
||||
|
||||
fn file(&self) -> Option<File> {
|
||||
(**self).file()
|
||||
}
|
||||
|
||||
fn range(&self) -> Option<TextRange> {
|
||||
(**self).range()
|
||||
}
|
||||
|
||||
fn severity(&self) -> Severity {
|
||||
(**self).severity()
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct ParseDiagnostic {
|
||||
file: File,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue