@@ -219,7 +219,6 @@ fn run_compiler(
219219 crate_cfg : cfg,
220220 crate_check_cfg : check_cfg,
221221 input : Input :: File ( PathBuf :: new ( ) ) ,
222- input_path : None ,
223222 output_file : ofile,
224223 output_dir : odir,
225224 file_loader,
@@ -237,9 +236,8 @@ fn run_compiler(
237236
238237 match make_input ( config. opts . error_format , & matches. free ) {
239238 Err ( reported) => return Err ( reported) ,
240- Ok ( Some ( ( input, input_file_path ) ) ) => {
239+ Ok ( Some ( input) ) => {
241240 config. input = input;
242- config. input_path = input_file_path;
243241
244242 callbacks. config ( & mut config) ;
245243 }
@@ -261,14 +259,8 @@ fn run_compiler(
261259 describe_lints ( compiler. session ( ) , & lint_store, registered_lints) ;
262260 return ;
263261 }
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 ) ;
272264
273265 if should_stop == Compilation :: Stop {
274266 return ;
@@ -290,18 +282,9 @@ fn run_compiler(
290282
291283 interface:: run_compiler ( config, |compiler| {
292284 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) ) ;
305288
306289 if should_stop == Compilation :: Stop {
307290 return sess. compile_status ( ) ;
@@ -315,24 +298,12 @@ fn run_compiler(
315298 if ppm. needs_ast_map ( ) {
316299 let expanded_crate = queries. expansion ( ) ?. borrow ( ) . 0 . clone ( ) ;
317300 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) ;
325302 Ok ( ( ) )
326303 } ) ?;
327304 } else {
328305 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) ;
336307 }
337308 trace ! ( "finished pretty-printing" ) ;
338309 return early_exit ( ) ;
@@ -357,21 +328,17 @@ fn run_compiler(
357328 }
358329 }
359330
360- queries. expansion ( ) ?;
331+ queries. global_ctxt ( ) ?;
361332 if callbacks. after_expansion ( compiler, queries) == Compilation :: Stop {
362333 return early_exit ( ) ;
363334 }
364335
365- queries. prepare_outputs ( ) ?;
366-
367336 if sess. opts . output_types . contains_key ( & OutputType :: DepInfo )
368337 && sess. opts . output_types . len ( ) == 1
369338 {
370339 return early_exit ( ) ;
371340 }
372341
373- queries. global_ctxt ( ) ?;
374-
375342 if sess. opts . unstable_opts . no_analysis {
376343 return early_exit ( ) ;
377344 }
@@ -384,9 +351,9 @@ fn run_compiler(
384351 save:: process_crate (
385352 tcx,
386353 crate_name,
387- compiler . input ( ) ,
354+ & sess . io . input ,
388355 None ,
389- DumpHandler :: new ( compiler . output_dir ( ) . as_deref ( ) , crate_name) ,
356+ DumpHandler :: new ( sess . io . output_dir . as_deref ( ) , crate_name) ,
390357 )
391358 } ) ;
392359 }
@@ -439,7 +406,7 @@ fn make_output(matches: &getopts::Matches) -> (Option<PathBuf>, Option<PathBuf>)
439406fn make_input (
440407 error_format : ErrorOutputType ,
441408 free_matches : & [ String ] ,
442- ) -> Result < Option < ( Input , Option < PathBuf > ) > , ErrorGuaranteed > {
409+ ) -> Result < Option < Input > , ErrorGuaranteed > {
443410 if free_matches. len ( ) == 1 {
444411 let ifile = & free_matches[ 0 ] ;
445412 if ifile == "-" {
@@ -461,12 +428,12 @@ fn make_input(
461428 let line = isize:: from_str_radix ( & line, 10 )
462429 . expect ( "UNSTABLE_RUSTDOC_TEST_LINE needs to be an number" ) ;
463430 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 } ) )
465432 } 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 } ) )
467434 }
468435 } else {
469- Ok ( Some ( ( Input :: File ( PathBuf :: from ( ifile) ) , Some ( PathBuf :: from ( ifile ) ) ) ) )
436+ Ok ( Some ( Input :: File ( PathBuf :: from ( ifile) ) ) )
470437 }
471438 } else {
472439 Ok ( None )
@@ -560,7 +527,7 @@ fn show_content_with_pager(content: &str) {
560527
561528pub fn try_process_rlink ( sess : & Session , compiler : & interface:: Compiler ) -> Compilation {
562529 if sess. opts . unstable_opts . link_only {
563- if let Input :: File ( file) = compiler . input ( ) {
530+ if let Input :: File ( file) = & sess . io . input {
564531 // FIXME: #![crate_type] and #![crate_name] support not implemented yet
565532 sess. init_crate_types ( collect_crate_types ( sess, & [ ] ) ) ;
566533 let outputs = compiler. build_output_filenames ( sess, & [ ] ) ;
@@ -601,13 +568,9 @@ pub fn try_process_rlink(sess: &Session, compiler: &interface::Compiler) -> Comp
601568 }
602569}
603570
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 {
609572 if sess. opts . unstable_opts . ls {
610- match * input {
573+ match sess . io . input {
611574 Input :: File ( ref ifile) => {
612575 let path = & ( * ifile) ;
613576 let mut v = Vec :: new ( ) ;
@@ -627,10 +590,7 @@ pub fn list_metadata(
627590fn print_crate_info (
628591 codegen_backend : & dyn CodegenBackend ,
629592 sess : & Session ,
630- input : Option < & Input > ,
631- odir : & Option < PathBuf > ,
632- ofile : & Option < PathBuf > ,
633- temps_dir : & Option < PathBuf > ,
593+ parse_attrs : bool ,
634594) -> Compilation {
635595 use rustc_session:: config:: PrintRequest :: * ;
636596 // NativeStaticLibs and LinkArgs are special - printed during linking
@@ -639,18 +599,17 @@ fn print_crate_info(
639599 return Compilation :: Continue ;
640600 }
641601
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 ;
652609 }
653610 }
611+ } else {
612+ None
654613 } ;
655614 for req in & sess. opts . prints {
656615 match * req {
@@ -665,14 +624,9 @@ fn print_crate_info(
665624 println ! ( "{}" , serde_json:: to_string_pretty( & sess. target. to_json( ) ) . unwrap( ) ) ;
666625 }
667626 FileNames | CrateName => {
668- let input = input. unwrap_or_else ( || {
669- early_error ( ErrorOutputType :: default ( ) , "no input file provided" )
670- } ) ;
671627 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) ;
676630 if * req == PrintRequest :: CrateName {
677631 println ! ( "{id}" ) ;
678632 continue ;
@@ -1108,8 +1062,8 @@ pub fn handle_options(args: &[String]) -> Option<getopts::Matches> {
11081062 Some ( matches)
11091063}
11101064
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 {
11131067 Input :: File ( ifile) => rustc_parse:: parse_crate_attrs_from_file ( ifile, & sess. parse_sess ) ,
11141068 Input :: Str { name, input } => rustc_parse:: parse_crate_attrs_from_source_str (
11151069 name. clone ( ) ,
0 commit comments