@@ -7,25 +7,24 @@ use crate::rmeta::{CrateDep, CrateMetadata, CrateNumMap, CrateRoot, MetadataBlob
7
7
use rustc_ast:: expand:: allocator:: { alloc_error_handler_name, global_fn_name, AllocatorKind } ;
8
8
use rustc_ast:: { self as ast, * } ;
9
9
use rustc_data_structures:: fx:: FxHashSet ;
10
+ use rustc_data_structures:: owned_slice:: OwnedSlice ;
10
11
use rustc_data_structures:: svh:: Svh ;
11
- use rustc_data_structures:: sync:: { FreezeReadGuard , FreezeWriteGuard } ;
12
+ use rustc_data_structures:: sync:: { self , FreezeReadGuard , FreezeWriteGuard } ;
12
13
use rustc_expand:: base:: SyntaxExtension ;
13
14
use rustc_fs_util:: try_canonicalize;
14
15
use rustc_hir:: def_id:: { CrateNum , LocalDefId , StableCrateId , StableCrateIdMap , LOCAL_CRATE } ;
15
16
use rustc_hir:: definitions:: Definitions ;
16
17
use rustc_index:: IndexVec ;
17
18
use rustc_middle:: ty:: TyCtxt ;
18
19
use rustc_session:: config:: { self , CrateType , ExternLocation } ;
19
- use rustc_session:: cstore:: {
20
- CrateDepKind , CrateSource , ExternCrate , ExternCrateSource , MetadataLoaderDyn ,
21
- } ;
20
+ use rustc_session:: cstore:: { CrateDepKind , CrateSource , ExternCrate , ExternCrateSource } ;
22
21
use rustc_session:: lint;
23
22
use rustc_session:: output:: validate_crate_name;
24
23
use rustc_session:: search_paths:: PathKind ;
25
24
use rustc_span:: edition:: Edition ;
26
25
use rustc_span:: symbol:: { sym, Symbol } ;
27
26
use rustc_span:: { Span , DUMMY_SP } ;
28
- use rustc_target:: spec:: { PanicStrategy , TargetTriple } ;
27
+ use rustc_target:: spec:: { PanicStrategy , Target , TargetTriple } ;
29
28
30
29
use proc_macro:: bridge:: client:: ProcMacro ;
31
30
use std:: error:: Error ;
@@ -34,6 +33,17 @@ use std::path::Path;
34
33
use std:: time:: Duration ;
35
34
use std:: { cmp, iter} ;
36
35
36
+ /// The backend's way to give the crate store access to the metadata in a library.
37
+ /// Note that it returns the raw metadata bytes stored in the library file, whether
38
+ /// it is compressed, uncompressed, some weird mix, etc.
39
+ /// rmeta files are backend independent and not handled here.
40
+ pub trait MetadataLoader {
41
+ fn get_rlib_metadata ( & self , target : & Target , filename : & Path ) -> Result < OwnedSlice , String > ;
42
+ fn get_dylib_metadata ( & self , target : & Target , filename : & Path ) -> Result < OwnedSlice , String > ;
43
+ }
44
+
45
+ pub type MetadataLoaderDyn = dyn MetadataLoader + Send + Sync + sync:: DynSend + sync:: DynSync ;
46
+
37
47
pub struct CStore {
38
48
metadata_loader : Box < MetadataLoaderDyn > ,
39
49
0 commit comments