File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -222,7 +222,18 @@ const _: () = {
222222 . relevant_crates ( editioned_file_id. file_id ( ) )
223223 . first ( )
224224 . copied ( )
225- . unwrap_or_else ( || db. all_crates ( ) [ 0 ] ) ;
225+ . or_else ( || db. all_crates ( ) . get ( 0 ) . copied ( ) )
226+ . unwrap_or_else ( || {
227+ // What we're doing here is a bit fishy. We rely on the fact that we only need
228+ // the crate in the item tree, and we should not create an `EditionedFileId`
229+ // without a crate except in cases where it does not matter. The chances that
230+ // `all_crates()` will be empty are also very slim, but it can occur during startup.
231+ // In the very unlikely case that there is a bug and we'll use this crate, Salsa
232+ // will panic.
233+
234+ // SAFETY: 0 is less than `Id::MAX_U32`.
235+ salsa:: plumbing:: FromId :: from_id ( unsafe { salsa:: Id :: from_index ( 0 ) } )
236+ } ) ;
226237 EditionedFileIdData { editioned_file_id, krate }
227238 } ,
228239 )
You can’t perform that action at this time.
0 commit comments