@@ -16,7 +16,7 @@ use rustc_data_structures::parallel;
1616use rustc_data_structures:: sync:: { Lrc , OnceCell , WorkerLocal } ;
1717use rustc_errors:: { ErrorGuaranteed , PResult } ;
1818use rustc_expand:: base:: { ExtCtxt , LintStoreExpand , ResolverExpand } ;
19- use rustc_hir:: def_id:: StableCrateId ;
19+ use rustc_hir:: def_id:: { StableCrateId , LOCAL_CRATE } ;
2020use rustc_lint:: { BufferedEarlyLint , EarlyCheckNode , LintStore } ;
2121use rustc_metadata:: creader:: CStore ;
2222use rustc_middle:: arena:: Arena ;
@@ -47,7 +47,7 @@ use std::marker::PhantomPinned;
4747use std:: path:: { Path , PathBuf } ;
4848use std:: pin:: Pin ;
4949use std:: rc:: Rc ;
50- use std:: sync:: LazyLock ;
50+ use std:: sync:: { Arc , LazyLock } ;
5151use std:: { env, fs, iter} ;
5252
5353pub fn parse < ' a > ( sess : & ' a Session ) -> PResult < ' a , ast:: Crate > {
@@ -660,13 +660,11 @@ fn write_out_deps(
660660 }
661661}
662662
663- pub fn prepare_outputs (
664- sess : & Session ,
665- krate : & ast:: Crate ,
666- cstore : & CrateStoreDyn ,
667- crate_name : Symbol ,
668- ) -> Result < OutputFilenames > {
663+ fn output_filenames ( tcx : TyCtxt < ' _ > , ( ) : ( ) ) -> Arc < OutputFilenames > {
664+ let sess = tcx. sess ;
669665 let _timer = sess. timer ( "prepare_outputs" ) ;
666+ let ( _, krate) = & * tcx. resolver_for_lowering ( ( ) ) . borrow ( ) ;
667+ let crate_name = tcx. crate_name ( LOCAL_CRATE ) ;
670668
671669 // FIXME: rustdoc passes &[] instead of &krate.attrs here
672670 let outputs = util:: build_output_filenames ( & krate. attrs , sess) ;
@@ -678,45 +676,41 @@ pub fn prepare_outputs(
678676 if let Some ( ref input_path) = sess. io . input . opt_path ( ) {
679677 if sess. opts . will_create_output_file ( ) {
680678 if output_contains_path ( & output_paths, input_path) {
681- let reported = sess. emit_err ( InputFileWouldBeOverWritten { path : input_path } ) ;
682- return Err ( reported) ;
679+ sess. emit_fatal ( InputFileWouldBeOverWritten { path : input_path } ) ;
683680 }
684681 if let Some ( ref dir_path) = output_conflicts_with_dir ( & output_paths) {
685- let reported =
686- sess. emit_err ( GeneratedFileConflictsWithDirectory { input_path, dir_path } ) ;
687- return Err ( reported) ;
682+ sess. emit_fatal ( GeneratedFileConflictsWithDirectory { input_path, dir_path } ) ;
688683 }
689684 }
690685 }
691686
692687 if let Some ( ref dir) = sess. io . temps_dir {
693688 if fs:: create_dir_all ( dir) . is_err ( ) {
694- let reported = sess. emit_err ( TempsDirError ) ;
695- return Err ( reported) ;
689+ sess. emit_fatal ( TempsDirError ) ;
696690 }
697691 }
698692
699- write_out_deps ( sess, cstore , & outputs, & output_paths) ;
693+ write_out_deps ( sess, tcx . cstore_untracked ( ) , & outputs, & output_paths) ;
700694
701695 let only_dep_info = sess. opts . output_types . contains_key ( & OutputType :: DepInfo )
702696 && sess. opts . output_types . len ( ) == 1 ;
703697
704698 if !only_dep_info {
705699 if let Some ( ref dir) = sess. io . output_dir {
706700 if fs:: create_dir_all ( dir) . is_err ( ) {
707- let reported = sess. emit_err ( OutDirError ) ;
708- return Err ( reported) ;
701+ sess. emit_fatal ( OutDirError ) ;
709702 }
710703 }
711704 }
712705
713- Ok ( outputs)
706+ outputs. into ( )
714707}
715708
716709pub static DEFAULT_QUERY_PROVIDERS : LazyLock < Providers > = LazyLock :: new ( || {
717710 let providers = & mut Providers :: default ( ) ;
718711 providers. analysis = analysis;
719712 providers. hir_crate = rustc_ast_lowering:: lower_to_hir;
713+ providers. output_filenames = output_filenames;
720714 proc_macro_decls:: provide ( providers) ;
721715 rustc_const_eval:: provide ( providers) ;
722716 rustc_middle:: hir:: provide ( providers) ;
0 commit comments