Skip to content

Commit 43bd043

Browse files
committed
ruff_db: add a From impl for FileRange to Span
These types are almost equivalent. The only difference is that a `Span`'s range is optional.
1 parent 9a54ee3 commit 43bd043

File tree

1 file changed

+7
-1
lines changed
  • crates/ruff_db/src/diagnostic

1 file changed

+7
-1
lines changed

crates/ruff_db/src/diagnostic/mod.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use std::{fmt::Formatter, sync::Arc};
33
use thiserror::Error;
44

55
use ruff_annotate_snippets::Level as AnnotateLevel;
6-
use ruff_text_size::TextRange;
6+
use ruff_text_size::{Ranged, TextRange};
77

88
pub use self::render::DisplayDiagnostic;
99
use crate::files::File;
@@ -601,6 +601,12 @@ impl From<File> for Span {
601601
}
602602
}
603603

604+
impl From<crate::files::FileRange> for Span {
605+
fn from(file_range: crate::files::FileRange) -> Span {
606+
Span::from(file_range.file()).with_range(file_range.range())
607+
}
608+
}
609+
604610
#[derive(Debug, Clone, Copy, PartialEq, Eq, Ord, PartialOrd)]
605611
pub enum Severity {
606612
Info,

0 commit comments

Comments
 (0)