@@ -26,7 +26,6 @@ use rustc_errors::registry::{InvalidErrorCode, Registry};
26
26
use rustc_errors:: { ErrorGuaranteed , PResult } ;
27
27
use rustc_feature:: find_gated_cfg;
28
28
use rustc_hir:: def_id:: LOCAL_CRATE ;
29
- use rustc_interface:: interface:: CompilerIO ;
30
29
use rustc_interface:: util:: { self , collect_crate_types, get_codegen_backend} ;
31
30
use rustc_interface:: { interface, Queries } ;
32
31
use rustc_lint:: LintStore ;
@@ -260,12 +259,8 @@ fn run_compiler(
260
259
describe_lints ( compiler. session ( ) , & lint_store, registered_lints) ;
261
260
return ;
262
261
}
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 ) ;
269
264
270
265
if should_stop == Compilation :: Stop {
271
266
return ;
@@ -287,16 +282,9 @@ fn run_compiler(
287
282
288
283
interface:: run_compiler ( config, |compiler| {
289
284
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) ) ;
300
288
301
289
if should_stop == Compilation :: Stop {
302
290
return sess. compile_status ( ) ;
@@ -310,17 +298,12 @@ fn run_compiler(
310
298
if ppm. needs_ast_map ( ) {
311
299
let expanded_crate = queries. expansion ( ) ?. borrow ( ) . 0 . clone ( ) ;
312
300
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) ;
319
302
Ok ( ( ) )
320
303
} ) ?;
321
304
} else {
322
305
let krate = queries. parse ( ) ?. steal ( ) ;
323
- pretty:: print_after_parsing ( sess, compiler . io ( ) , & krate, * ppm) ;
306
+ pretty:: print_after_parsing ( sess, & krate, * ppm) ;
324
307
}
325
308
trace ! ( "finished pretty-printing" ) ;
326
309
return early_exit ( ) ;
@@ -370,9 +353,9 @@ fn run_compiler(
370
353
save:: process_crate (
371
354
tcx,
372
355
crate_name,
373
- & compiler . io ( ) . input ,
356
+ & sess . io . input ,
374
357
None ,
375
- DumpHandler :: new ( compiler . io ( ) . output_dir . as_deref ( ) , crate_name) ,
358
+ DumpHandler :: new ( sess . io . output_dir . as_deref ( ) , crate_name) ,
376
359
)
377
360
} ) ;
378
361
}
@@ -546,7 +529,7 @@ fn show_content_with_pager(content: &str) {
546
529
547
530
pub fn try_process_rlink ( sess : & Session , compiler : & interface:: Compiler ) -> Compilation {
548
531
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 {
550
533
// FIXME: #![crate_type] and #![crate_name] support not implemented yet
551
534
sess. init_crate_types ( collect_crate_types ( sess, & [ ] ) ) ;
552
535
let outputs = compiler. build_output_filenames ( sess, & [ ] ) ;
@@ -587,13 +570,9 @@ pub fn try_process_rlink(sess: &Session, compiler: &interface::Compiler) -> Comp
587
570
}
588
571
}
589
572
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 {
595
574
if sess. opts . unstable_opts . ls {
596
- match * input {
575
+ match sess . io . input {
597
576
Input :: File ( ref ifile) => {
598
577
let path = & ( * ifile) ;
599
578
let mut v = Vec :: new ( ) ;
@@ -614,7 +593,6 @@ fn print_crate_info(
614
593
codegen_backend : & dyn CodegenBackend ,
615
594
sess : & Session ,
616
595
parse_attrs : bool ,
617
- io : & CompilerIO ,
618
596
) -> Compilation {
619
597
use rustc_session:: config:: PrintRequest :: * ;
620
598
// NativeStaticLibs and LinkArgs are special - printed during linking
@@ -624,7 +602,7 @@ fn print_crate_info(
624
602
}
625
603
626
604
let attrs = if parse_attrs {
627
- let result = parse_crate_attrs ( sess, & io . input ) ;
605
+ let result = parse_crate_attrs ( sess) ;
628
606
match result {
629
607
Ok ( attrs) => Some ( attrs) ,
630
608
Err ( mut parse_error) => {
@@ -649,8 +627,8 @@ fn print_crate_info(
649
627
}
650
628
FileNames | CrateName => {
651
629
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) ;
654
632
if * req == PrintRequest :: CrateName {
655
633
println ! ( "{id}" ) ;
656
634
continue ;
@@ -1086,8 +1064,8 @@ pub fn handle_options(args: &[String]) -> Option<getopts::Matches> {
1086
1064
Some ( matches)
1087
1065
}
1088
1066
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 {
1091
1069
Input :: File ( ifile) => rustc_parse:: parse_crate_attrs_from_file ( ifile, & sess. parse_sess ) ,
1092
1070
Input :: Str { name, input } => rustc_parse:: parse_crate_attrs_from_source_str (
1093
1071
name. clone ( ) ,
0 commit comments