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.
This commit is contained in:
Andrew Gallant 2025-04-23 11:23:51 -04:00 committed by Andrew Gallant
parent 9a54ee3a1c
commit 43bd043755

View file

@ -3,7 +3,7 @@ use std::{fmt::Formatter, sync::Arc};
use thiserror::Error;
use ruff_annotate_snippets::Level as AnnotateLevel;
use ruff_text_size::TextRange;
use ruff_text_size::{Ranged, TextRange};
pub use self::render::DisplayDiagnostic;
use crate::files::File;
@ -601,6 +601,12 @@ impl From<File> for Span {
}
}
impl From<crate::files::FileRange> for Span {
fn from(file_range: crate::files::FileRange) -> Span {
Span::from(file_range.file()).with_range(file_range.range())
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Ord, PartialOrd)]
pub enum Severity {
Info,