@@ -26,7 +26,6 @@ use rustc_errors::registry::{InvalidErrorCode, Registry};
2626use rustc_errors:: { ErrorGuaranteed , PResult } ;
2727use rustc_feature:: find_gated_cfg;
2828use rustc_hir:: def_id:: LOCAL_CRATE ;
29- use rustc_interface:: interface:: CompilerIO ;
3029use rustc_interface:: util:: { self , collect_crate_types, get_codegen_backend} ;
3130use rustc_interface:: { interface, Queries } ;
3231use rustc_lint:: LintStore ;
@@ -260,12 +259,8 @@ fn run_compiler(
260259 describe_lints ( compiler. session ( ) , & lint_store, registered_lints) ;
261260 return ;
262261 }
263- let should_stop = print_crate_info (
264- & * * * compiler. codegen_backend ( ) ,
265- compiler. session ( ) ,
266- false ,
267- compiler. io ( ) ,
268- ) ;
262+ let should_stop =
263+ print_crate_info ( & * * * compiler. codegen_backend ( ) , compiler. session ( ) , false ) ;
269264
270265 if should_stop == Compilation :: Stop {
271266 return ;
@@ -287,16 +282,9 @@ fn run_compiler(
287282
288283 interface:: run_compiler ( config, |compiler| {
289284 let sess = compiler. session ( ) ;
290- let should_stop =
291- print_crate_info ( & * * * compiler. codegen_backend ( ) , sess, true , compiler. io ( ) )
292- . and_then ( || {
293- list_metadata (
294- sess,
295- & * compiler. codegen_backend ( ) . metadata_loader ( ) ,
296- & compiler. io ( ) . input ,
297- )
298- } )
299- . and_then ( || try_process_rlink ( sess, compiler) ) ;
285+ let should_stop = print_crate_info ( & * * * compiler. codegen_backend ( ) , sess, true )
286+ . and_then ( || list_metadata ( sess, & * compiler. codegen_backend ( ) . metadata_loader ( ) ) )
287+ . and_then ( || try_process_rlink ( sess, compiler) ) ;
300288
301289 if should_stop == Compilation :: Stop {
302290 return sess. compile_status ( ) ;
@@ -310,17 +298,12 @@ fn run_compiler(
310298 if ppm. needs_ast_map ( ) {
311299 let expanded_crate = queries. expansion ( ) ?. borrow ( ) . 0 . clone ( ) ;
312300 queries. global_ctxt ( ) ?. enter ( |tcx| {
313- pretty:: print_after_hir_lowering (
314- tcx,
315- compiler. io ( ) ,
316- & * expanded_crate,
317- * ppm,
318- ) ;
301+ pretty:: print_after_hir_lowering ( tcx, & * expanded_crate, * ppm) ;
319302 Ok ( ( ) )
320303 } ) ?;
321304 } else {
322305 let krate = queries. parse ( ) ?. steal ( ) ;
323- pretty:: print_after_parsing ( sess, compiler . io ( ) , & krate, * ppm) ;
306+ pretty:: print_after_parsing ( sess, & krate, * ppm) ;
324307 }
325308 trace ! ( "finished pretty-printing" ) ;
326309 return early_exit ( ) ;
@@ -370,9 +353,9 @@ fn run_compiler(
370353 save:: process_crate (
371354 tcx,
372355 crate_name,
373- & compiler . io ( ) . input ,
356+ & sess . io . input ,
374357 None ,
375- DumpHandler :: new ( compiler . io ( ) . output_dir . as_deref ( ) , crate_name) ,
358+ DumpHandler :: new ( sess . io . output_dir . as_deref ( ) , crate_name) ,
376359 )
377360 } ) ;
378361 }
@@ -546,7 +529,7 @@ fn show_content_with_pager(content: &str) {
546529
547530pub fn try_process_rlink ( sess : & Session , compiler : & interface:: Compiler ) -> Compilation {
548531 if sess. opts . unstable_opts . link_only {
549- if let Input :: File ( file) = & compiler . io ( ) . input {
532+ if let Input :: File ( file) = & sess . io . input {
550533 // FIXME: #![crate_type] and #![crate_name] support not implemented yet
551534 sess. init_crate_types ( collect_crate_types ( sess, & [ ] ) ) ;
552535 let outputs = compiler. build_output_filenames ( sess, & [ ] ) ;
@@ -587,13 +570,9 @@ pub fn try_process_rlink(sess: &Session, compiler: &interface::Compiler) -> Comp
587570 }
588571}
589572
590- pub fn list_metadata (
591- sess : & Session ,
592- metadata_loader : & dyn MetadataLoader ,
593- input : & Input ,
594- ) -> Compilation {
573+ pub fn list_metadata ( sess : & Session , metadata_loader : & dyn MetadataLoader ) -> Compilation {
595574 if sess. opts . unstable_opts . ls {
596- match * input {
575+ match sess . io . input {
597576 Input :: File ( ref ifile) => {
598577 let path = & ( * ifile) ;
599578 let mut v = Vec :: new ( ) ;
@@ -614,7 +593,6 @@ fn print_crate_info(
614593 codegen_backend : & dyn CodegenBackend ,
615594 sess : & Session ,
616595 parse_attrs : bool ,
617- io : & CompilerIO ,
618596) -> Compilation {
619597 use rustc_session:: config:: PrintRequest :: * ;
620598 // NativeStaticLibs and LinkArgs are special - printed during linking
@@ -624,7 +602,7 @@ fn print_crate_info(
624602 }
625603
626604 let attrs = if parse_attrs {
627- let result = parse_crate_attrs ( sess, & io . input ) ;
605+ let result = parse_crate_attrs ( sess) ;
628606 match result {
629607 Ok ( attrs) => Some ( attrs) ,
630608 Err ( mut parse_error) => {
@@ -649,8 +627,8 @@ fn print_crate_info(
649627 }
650628 FileNames | CrateName => {
651629 let attrs = attrs. as_ref ( ) . unwrap ( ) ;
652- let t_outputs = rustc_interface:: util:: build_output_filenames ( io , attrs, sess) ;
653- let id = rustc_session:: output:: find_crate_name ( sess, attrs, & io . input ) ;
630+ let t_outputs = rustc_interface:: util:: build_output_filenames ( attrs, sess) ;
631+ let id = rustc_session:: output:: find_crate_name ( sess, attrs) ;
654632 if * req == PrintRequest :: CrateName {
655633 println ! ( "{id}" ) ;
656634 continue ;
@@ -1086,8 +1064,8 @@ pub fn handle_options(args: &[String]) -> Option<getopts::Matches> {
10861064 Some ( matches)
10871065}
10881066
1089- fn parse_crate_attrs < ' a > ( sess : & ' a Session , input : & Input ) -> PResult < ' a , ast:: AttrVec > {
1090- match input {
1067+ fn parse_crate_attrs < ' a > ( sess : & ' a Session ) -> PResult < ' a , ast:: AttrVec > {
1068+ match & sess . io . input {
10911069 Input :: File ( ifile) => rustc_parse:: parse_crate_attrs_from_file ( ifile, & sess. parse_sess ) ,
10921070 Input :: Str { name, input } => rustc_parse:: parse_crate_attrs_from_source_str (
10931071 name. clone ( ) ,
0 commit comments