File tree 1 file changed +21
-1
lines changed
1 file changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ use core::{
8
8
fmt,
9
9
str:: { self , FromStr } ,
10
10
} ;
11
+ use vm_core:: debuginfo:: SourceSpan ;
11
12
12
13
use smallvec:: smallvec;
13
14
@@ -503,7 +504,26 @@ impl Deserializable for LibraryPath {
503
504
let path = source. read_slice ( len) ?;
504
505
let path =
505
506
str:: from_utf8 ( path) . map_err ( |e| DeserializationError :: InvalidValue ( e. to_string ( ) ) ) ?;
506
- Self :: new ( path) . map_err ( |e| DeserializationError :: InvalidValue ( e. to_string ( ) ) )
507
+ let path = LibraryPath :: new ( path) . unwrap_or_else ( |_| {
508
+ // Try to parse at least the namespace
509
+ match LibraryNamespace :: strip_path_prefix ( path) {
510
+ Ok ( ( ns, rest) ) => {
511
+ let module_id = Ident :: new_unchecked ( Span :: new (
512
+ SourceSpan :: default ( ) ,
513
+ Arc :: from ( rest. to_string ( ) ) ,
514
+ ) ) ;
515
+ LibraryPath :: new_from_components ( ns, [ module_id] )
516
+ } ,
517
+ Err ( _) => {
518
+ let module_id = Ident :: new_unchecked ( Span :: new (
519
+ SourceSpan :: default ( ) ,
520
+ Arc :: from ( path. to_string ( ) ) ,
521
+ ) ) ;
522
+ LibraryPath :: new_from_components ( LibraryNamespace :: Anon , [ module_id] )
523
+ } ,
524
+ }
525
+ } ) ;
526
+ Ok ( path)
507
527
}
508
528
}
509
529
You can’t perform that action at this time.
0 commit comments