@@ -35,6 +35,8 @@ extern crate arena;
3535extern crate getopts;
3636extern crate graphviz;
3737extern crate env_logger;
38+ #[ cfg( not( feature="llvm" ) ) ]
39+ extern crate owning_ref;
3840extern crate libc;
3941extern crate rustc;
4042extern crate rustc_allocator;
@@ -70,8 +72,6 @@ use rustc_resolve as resolve;
7072use rustc_save_analysis as save;
7173use rustc_save_analysis:: DumpHandler ;
7274#[ cfg( feature="llvm" ) ]
73- use rustc_trans:: back:: link;
74- #[ cfg( feature="llvm" ) ]
7575use rustc_trans:: back:: write:: { RELOC_MODEL_ARGS , CODE_GEN_MODEL_ARGS } ;
7676use rustc:: dep_graph:: DepGraph ;
7777use rustc:: session:: { self , config, Session , build_session, CompileResult } ;
@@ -82,7 +82,7 @@ use rustc::session::{early_error, early_warn};
8282use rustc:: lint:: Lint ;
8383use rustc:: lint;
8484#[ cfg( not( feature="llvm" ) ) ]
85- use rustc:: middle:: cstore:: MetadataLoader ;
85+ use rustc:: middle:: cstore:: MetadataLoader as MetadataLoaderTrait ;
8686use rustc_metadata:: locator;
8787use rustc_metadata:: cstore:: CStore ;
8888use rustc:: util:: common:: { time, ErrorReported } ;
@@ -114,6 +114,9 @@ use syntax::feature_gate::{GatedCfg, UnstableFeatures};
114114use syntax:: parse:: { self , PResult } ;
115115use syntax_pos:: { DUMMY_SP , MultiSpan } ;
116116
117+ #[ cfg( not( feature="llvm" ) ) ]
118+ use owning_ref:: { OwningRef , ErasedBoxRef } ;
119+
117120#[ cfg( test) ]
118121pub mod test;
119122
@@ -174,7 +177,7 @@ pub use NoLLvmMetadataLoader as MetadataLoader;
174177pub use rustc_trans:: LlvmMetadataLoader as MetadataLoader ;
175178
176179#[ cfg( not( feature="llvm" ) ) ]
177- impl MetadataLoader for NoLLvmMetadataLoader {
180+ impl MetadataLoaderTrait for NoLLvmMetadataLoader {
178181 fn get_rlib_metadata ( & self , _: & Target , filename : & Path ) -> Result < ErasedBoxRef < [ u8 ] > , String > {
179182 use std:: fs:: File ;
180183 use std:: io;
@@ -185,20 +188,20 @@ impl MetadataLoader for NoLLvmMetadataLoader {
185188
186189 while let Some ( entry_result) = archive. next_entry ( ) {
187190 let mut entry = entry_result. map_err ( |e|format ! ( "metadata section read err: {:?}" , e) ) ?;
188- if entry. header ( ) . identifier ( ) == METADATA_FILENAME {
191+ if entry. header ( ) . identifier ( ) == "rust.metadata.bin" {
189192 let mut buf = Vec :: new ( ) ;
190193 io:: copy ( & mut entry, & mut buf) . unwrap ( ) ;
191194 let buf: OwningRef < Vec < u8 > , [ u8 ] > = OwningRef :: new ( buf) . into ( ) ;
192- return Ok ( buf. erase_owner ( ) ) ;
195+ return Ok ( buf. map_owner_box ( ) . erase_owner ( ) ) ;
193196 }
194197 }
195198
196199 Err ( "Couldnt find metadata section" . to_string ( ) )
197200 }
198201
199202 fn get_dylib_metadata ( & self ,
200- target : & Target ,
201- filename : & Path )
203+ _target : & Target ,
204+ _filename : & Path )
202205 -> Result < ErasedBoxRef < [ u8 ] > , String > {
203206 panic ! ( "Dylib metadata loading not supported without LLVM" )
204207 }
@@ -207,6 +210,7 @@ impl MetadataLoader for NoLLvmMetadataLoader {
207210// Parse args and run the compiler. This is the primary entry point for rustc.
208211// See comments on CompilerCalls below for details about the callbacks argument.
209212// The FileLoader provides a way to load files from sources other than the file system.
213+ #[ cfg_attr( not( feature="llvm" ) , allow( unused_mut) ) ]
210214pub fn run_compiler < ' a > ( args : & [ String ] ,
211215 callbacks : & mut CompilerCalls < ' a > ,
212216 file_loader : Option < Box < FileLoader + ' static > > ,
@@ -516,6 +520,7 @@ impl<'a> CompilerCalls<'a> for RustcDefaultCalls {
516520 Compilation :: Continue
517521 }
518522
523+ #[ cfg_attr( not( feature="llvm" ) , allow( unused_mut) ) ]
519524 fn no_input ( & mut self ,
520525 matches : & getopts:: Matches ,
521526 sopts : & config:: Options ,
@@ -743,7 +748,12 @@ impl RustcDefaultCalls {
743748 }
744749 let crate_types = driver:: collect_crate_types ( sess, attrs) ;
745750 for & style in & crate_types {
746- let fname = rustc_trans_utils:: link:: filename_for_input ( sess, style, & id, & t_outputs) ;
751+ let fname = rustc_trans_utils:: link:: filename_for_input (
752+ sess,
753+ style,
754+ & id,
755+ & t_outputs
756+ ) ;
747757 println ! ( "{}" ,
748758 fname. file_name( )
749759 . unwrap( )
@@ -792,15 +802,15 @@ impl RustcDefaultCalls {
792802 }
793803 PrintRequest :: RelocationModels => {
794804 println ! ( "Available relocation models:" ) ;
795- #[ cfg( features ="llvm" ) ]
805+ #[ cfg( feature ="llvm" ) ]
796806 for & ( name, _) in RELOC_MODEL_ARGS . iter ( ) {
797807 println ! ( " {}" , name) ;
798808 }
799809 println ! ( "" ) ;
800810 }
801811 PrintRequest :: CodeModels => {
802812 println ! ( "Available code models:" ) ;
803- #[ cfg( features ="llvm" ) ]
813+ #[ cfg( feature ="llvm" ) ]
804814 for & ( name, _) in CODE_GEN_MODEL_ARGS . iter ( ) {
805815 println ! ( " {}" , name) ;
806816 }
0 commit comments