@@ -219,7 +219,6 @@ fn run_compiler(
219
219
crate_cfg : cfg,
220
220
crate_check_cfg : check_cfg,
221
221
input : Input :: File ( PathBuf :: new ( ) ) ,
222
- input_path : None ,
223
222
output_file : ofile,
224
223
output_dir : odir,
225
224
file_loader,
@@ -237,9 +236,8 @@ fn run_compiler(
237
236
238
237
match make_input ( config. opts . error_format , & matches. free ) {
239
238
Err ( reported) => return Err ( reported) ,
240
- Ok ( Some ( ( input, input_file_path ) ) ) => {
239
+ Ok ( Some ( input) ) => {
241
240
config. input = input;
242
- config. input_path = input_file_path;
243
241
244
242
callbacks. config ( & mut config) ;
245
243
}
@@ -261,14 +259,8 @@ fn run_compiler(
261
259
describe_lints ( compiler. session ( ) , & lint_store, registered_lints) ;
262
260
return ;
263
261
}
264
- let should_stop = print_crate_info (
265
- & * * * compiler. codegen_backend ( ) ,
266
- compiler. session ( ) ,
267
- None ,
268
- compiler. output_dir ( ) ,
269
- compiler. output_file ( ) ,
270
- compiler. temps_dir ( ) ,
271
- ) ;
262
+ let should_stop =
263
+ print_crate_info ( & * * * compiler. codegen_backend ( ) , compiler. session ( ) , false ) ;
272
264
273
265
if should_stop == Compilation :: Stop {
274
266
return ;
@@ -290,18 +282,9 @@ fn run_compiler(
290
282
291
283
interface:: run_compiler ( config, |compiler| {
292
284
let sess = compiler. session ( ) ;
293
- let should_stop = print_crate_info (
294
- & * * * compiler. codegen_backend ( ) ,
295
- sess,
296
- Some ( compiler. input ( ) ) ,
297
- compiler. output_dir ( ) ,
298
- compiler. output_file ( ) ,
299
- compiler. temps_dir ( ) ,
300
- )
301
- . and_then ( || {
302
- list_metadata ( sess, & * compiler. codegen_backend ( ) . metadata_loader ( ) , compiler. input ( ) )
303
- } )
304
- . 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) ) ;
305
288
306
289
if should_stop == Compilation :: Stop {
307
290
return sess. compile_status ( ) ;
@@ -315,24 +298,12 @@ fn run_compiler(
315
298
if ppm. needs_ast_map ( ) {
316
299
let expanded_crate = queries. expansion ( ) ?. borrow ( ) . 0 . clone ( ) ;
317
300
queries. global_ctxt ( ) ?. enter ( |tcx| {
318
- pretty:: print_after_hir_lowering (
319
- tcx,
320
- compiler. input ( ) ,
321
- & * expanded_crate,
322
- * ppm,
323
- compiler. output_file ( ) . as_deref ( ) ,
324
- ) ;
301
+ pretty:: print_after_hir_lowering ( tcx, & * expanded_crate, * ppm) ;
325
302
Ok ( ( ) )
326
303
} ) ?;
327
304
} else {
328
305
let krate = queries. parse ( ) ?. steal ( ) ;
329
- pretty:: print_after_parsing (
330
- sess,
331
- compiler. input ( ) ,
332
- & krate,
333
- * ppm,
334
- compiler. output_file ( ) . as_deref ( ) ,
335
- ) ;
306
+ pretty:: print_after_parsing ( sess, & krate, * ppm) ;
336
307
}
337
308
trace ! ( "finished pretty-printing" ) ;
338
309
return early_exit ( ) ;
@@ -357,21 +328,17 @@ fn run_compiler(
357
328
}
358
329
}
359
330
360
- queries. expansion ( ) ?;
331
+ queries. global_ctxt ( ) ?;
361
332
if callbacks. after_expansion ( compiler, queries) == Compilation :: Stop {
362
333
return early_exit ( ) ;
363
334
}
364
335
365
- queries. prepare_outputs ( ) ?;
366
-
367
336
if sess. opts . output_types . contains_key ( & OutputType :: DepInfo )
368
337
&& sess. opts . output_types . len ( ) == 1
369
338
{
370
339
return early_exit ( ) ;
371
340
}
372
341
373
- queries. global_ctxt ( ) ?;
374
-
375
342
if sess. opts . unstable_opts . no_analysis {
376
343
return early_exit ( ) ;
377
344
}
@@ -384,9 +351,9 @@ fn run_compiler(
384
351
save:: process_crate (
385
352
tcx,
386
353
crate_name,
387
- compiler . input ( ) ,
354
+ & sess . io . input ,
388
355
None ,
389
- DumpHandler :: new ( compiler . output_dir ( ) . as_deref ( ) , crate_name) ,
356
+ DumpHandler :: new ( sess . io . output_dir . as_deref ( ) , crate_name) ,
390
357
)
391
358
} ) ;
392
359
}
@@ -439,7 +406,7 @@ fn make_output(matches: &getopts::Matches) -> (Option<PathBuf>, Option<PathBuf>)
439
406
fn make_input (
440
407
error_format : ErrorOutputType ,
441
408
free_matches : & [ String ] ,
442
- ) -> Result < Option < ( Input , Option < PathBuf > ) > , ErrorGuaranteed > {
409
+ ) -> Result < Option < Input > , ErrorGuaranteed > {
443
410
if free_matches. len ( ) == 1 {
444
411
let ifile = & free_matches[ 0 ] ;
445
412
if ifile == "-" {
@@ -461,12 +428,12 @@ fn make_input(
461
428
let line = isize:: from_str_radix ( & line, 10 )
462
429
. expect ( "UNSTABLE_RUSTDOC_TEST_LINE needs to be an number" ) ;
463
430
let file_name = FileName :: doc_test_source_code ( PathBuf :: from ( path) , line) ;
464
- Ok ( Some ( ( Input :: Str { name : file_name, input : src } , None ) ) )
431
+ Ok ( Some ( Input :: Str { name : file_name, input : src } ) )
465
432
} else {
466
- Ok ( Some ( ( Input :: Str { name : FileName :: anon_source_code ( & src) , input : src } , None ) ) )
433
+ Ok ( Some ( Input :: Str { name : FileName :: anon_source_code ( & src) , input : src } ) )
467
434
}
468
435
} else {
469
- Ok ( Some ( ( Input :: File ( PathBuf :: from ( ifile) ) , Some ( PathBuf :: from ( ifile ) ) ) ) )
436
+ Ok ( Some ( Input :: File ( PathBuf :: from ( ifile) ) ) )
470
437
}
471
438
} else {
472
439
Ok ( None )
@@ -560,7 +527,7 @@ fn show_content_with_pager(content: &str) {
560
527
561
528
pub fn try_process_rlink ( sess : & Session , compiler : & interface:: Compiler ) -> Compilation {
562
529
if sess. opts . unstable_opts . link_only {
563
- if let Input :: File ( file) = compiler . input ( ) {
530
+ if let Input :: File ( file) = & sess . io . input {
564
531
// FIXME: #![crate_type] and #![crate_name] support not implemented yet
565
532
sess. init_crate_types ( collect_crate_types ( sess, & [ ] ) ) ;
566
533
let outputs = compiler. build_output_filenames ( sess, & [ ] ) ;
@@ -601,13 +568,9 @@ pub fn try_process_rlink(sess: &Session, compiler: &interface::Compiler) -> Comp
601
568
}
602
569
}
603
570
604
- pub fn list_metadata (
605
- sess : & Session ,
606
- metadata_loader : & dyn MetadataLoader ,
607
- input : & Input ,
608
- ) -> Compilation {
571
+ pub fn list_metadata ( sess : & Session , metadata_loader : & dyn MetadataLoader ) -> Compilation {
609
572
if sess. opts . unstable_opts . ls {
610
- match * input {
573
+ match sess . io . input {
611
574
Input :: File ( ref ifile) => {
612
575
let path = & ( * ifile) ;
613
576
let mut v = Vec :: new ( ) ;
@@ -627,10 +590,7 @@ pub fn list_metadata(
627
590
fn print_crate_info (
628
591
codegen_backend : & dyn CodegenBackend ,
629
592
sess : & Session ,
630
- input : Option < & Input > ,
631
- odir : & Option < PathBuf > ,
632
- ofile : & Option < PathBuf > ,
633
- temps_dir : & Option < PathBuf > ,
593
+ parse_attrs : bool ,
634
594
) -> Compilation {
635
595
use rustc_session:: config:: PrintRequest :: * ;
636
596
// NativeStaticLibs and LinkArgs are special - printed during linking
@@ -639,18 +599,17 @@ fn print_crate_info(
639
599
return Compilation :: Continue ;
640
600
}
641
601
642
- let attrs = match input {
643
- None => None ,
644
- Some ( input) => {
645
- let result = parse_crate_attrs ( sess, input) ;
646
- match result {
647
- Ok ( attrs) => Some ( attrs) ,
648
- Err ( mut parse_error) => {
649
- parse_error. emit ( ) ;
650
- return Compilation :: Stop ;
651
- }
602
+ let attrs = if parse_attrs {
603
+ let result = parse_crate_attrs ( sess) ;
604
+ match result {
605
+ Ok ( attrs) => Some ( attrs) ,
606
+ Err ( mut parse_error) => {
607
+ parse_error. emit ( ) ;
608
+ return Compilation :: Stop ;
652
609
}
653
610
}
611
+ } else {
612
+ None
654
613
} ;
655
614
for req in & sess. opts . prints {
656
615
match * req {
@@ -665,14 +624,9 @@ fn print_crate_info(
665
624
println ! ( "{}" , serde_json:: to_string_pretty( & sess. target. to_json( ) ) . unwrap( ) ) ;
666
625
}
667
626
FileNames | CrateName => {
668
- let input = input. unwrap_or_else ( || {
669
- early_error ( ErrorOutputType :: default ( ) , "no input file provided" )
670
- } ) ;
671
627
let attrs = attrs. as_ref ( ) . unwrap ( ) ;
672
- let t_outputs = rustc_interface:: util:: build_output_filenames (
673
- input, odir, ofile, temps_dir, attrs, sess,
674
- ) ;
675
- let id = rustc_session:: output:: find_crate_name ( sess, attrs, input) ;
628
+ let t_outputs = rustc_interface:: util:: build_output_filenames ( attrs, sess) ;
629
+ let id = rustc_session:: output:: find_crate_name ( sess, attrs) ;
676
630
if * req == PrintRequest :: CrateName {
677
631
println ! ( "{id}" ) ;
678
632
continue ;
@@ -1108,8 +1062,8 @@ pub fn handle_options(args: &[String]) -> Option<getopts::Matches> {
1108
1062
Some ( matches)
1109
1063
}
1110
1064
1111
- fn parse_crate_attrs < ' a > ( sess : & ' a Session , input : & Input ) -> PResult < ' a , ast:: AttrVec > {
1112
- match input {
1065
+ fn parse_crate_attrs < ' a > ( sess : & ' a Session ) -> PResult < ' a , ast:: AttrVec > {
1066
+ match & sess . io . input {
1113
1067
Input :: File ( ifile) => rustc_parse:: parse_crate_attrs_from_file ( ifile, & sess. parse_sess ) ,
1114
1068
Input :: Str { name, input } => rustc_parse:: parse_crate_attrs_from_source_str (
1115
1069
name. clone ( ) ,
0 commit comments