File tree Expand file tree Collapse file tree 1 file changed +11
-5
lines changed
crates/ruff_db/src/diagnostic Expand file tree Collapse file tree 1 file changed +11
-5
lines changed Original file line number Diff line number Diff line change @@ -501,13 +501,19 @@ impl Diagnostic {
501501
502502 /// Returns the ordering of diagnostics based on the start of their ranges, if they have any.
503503 ///
504- /// Panics if either diagnostic has no primary span, if the span has no range, or if its file is
505- /// not a `SourceFile`.
504+ /// Diagnostics with range of None will be treated as starting at zero.
505+ /// Panics if either diagnostic has no primary span, or if its file is not a `SourceFile`.
506506 pub fn ruff_start_ordering ( & self , other : & Self ) -> std:: cmp:: Ordering {
507- ( self . expect_ruff_source_file ( ) , self . expect_range ( ) . start ( ) ) . cmp ( & (
507+ let a = (
508+ self . expect_ruff_source_file ( ) ,
509+ self . range ( ) . map ( |r| r. start ( ) ) . unwrap_or_default ( ) ,
510+ ) ;
511+ let b = (
508512 other. expect_ruff_source_file ( ) ,
509- other. expect_range ( ) . start ( ) ,
510- ) )
513+ other. range ( ) . map ( |r| r. start ( ) ) . unwrap_or_default ( ) ,
514+ ) ;
515+
516+ a. cmp ( & b)
511517 }
512518}
513519
You can’t perform that action at this time.
0 commit comments