@@ -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 ;
@@ -30,7 +30,7 @@ use rustc_plugin_impl as plugin;
3030use rustc_query_impl:: { OnDiskCache , Queries as TcxQueries } ;
3131use rustc_resolve:: { Resolver , ResolverArenas } ;
3232use rustc_session:: config:: { CrateType , Input , OutputFilenames , OutputType } ;
33- use rustc_session:: cstore:: { MetadataLoader , MetadataLoaderDyn , Untracked } ;
33+ use rustc_session:: cstore:: { CrateStoreDyn , MetadataLoader , MetadataLoaderDyn , Untracked } ;
3434use rustc_session:: output:: filename_for_input;
3535use rustc_session:: search_paths:: PathKind ;
3636use rustc_session:: { Limit , Session } ;
@@ -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 > {
@@ -548,7 +548,7 @@ fn escape_dep_env(symbol: Symbol) -> String {
548548
549549fn write_out_deps (
550550 sess : & Session ,
551- boxed_resolver : & RefCell < BoxedResolver > ,
551+ cstore : & CrateStoreDyn ,
552552 outputs : & OutputFilenames ,
553553 out_filenames : & [ PathBuf ] ,
554554) {
@@ -600,20 +600,19 @@ fn write_out_deps(
600600 }
601601 }
602602
603- boxed_resolver. borrow_mut ( ) . access ( |resolver| {
604- for cnum in resolver. cstore ( ) . crates_untracked ( ) {
605- let source = resolver. cstore ( ) . crate_source_untracked ( cnum) ;
606- if let Some ( ( path, _) ) = & source. dylib {
607- files. push ( escape_dep_filename ( & path. display ( ) . to_string ( ) ) ) ;
608- }
609- if let Some ( ( path, _) ) = & source. rlib {
610- files. push ( escape_dep_filename ( & path. display ( ) . to_string ( ) ) ) ;
611- }
612- if let Some ( ( path, _) ) = & source. rmeta {
613- files. push ( escape_dep_filename ( & path. display ( ) . to_string ( ) ) ) ;
614- }
603+ let cstore = cstore. as_any ( ) . downcast_ref :: < CStore > ( ) . unwrap ( ) ;
604+ for cnum in cstore. crates_untracked ( ) {
605+ let source = cstore. crate_source_untracked ( cnum) ;
606+ if let Some ( ( path, _) ) = & source. dylib {
607+ files. push ( escape_dep_filename ( & path. display ( ) . to_string ( ) ) ) ;
615608 }
616- } ) ;
609+ if let Some ( ( path, _) ) = & source. rlib {
610+ files. push ( escape_dep_filename ( & path. display ( ) . to_string ( ) ) ) ;
611+ }
612+ if let Some ( ( path, _) ) = & source. rmeta {
613+ files. push ( escape_dep_filename ( & path. display ( ) . to_string ( ) ) ) ;
614+ }
615+ }
617616 }
618617
619618 let mut file = BufWriter :: new ( fs:: File :: create ( & deps_filename) ?) ;
@@ -661,13 +660,11 @@ fn write_out_deps(
661660 }
662661}
663662
664- pub fn prepare_outputs (
665- sess : & Session ,
666- krate : & ast:: Crate ,
667- boxed_resolver : & RefCell < BoxedResolver > ,
668- crate_name : Symbol ,
669- ) -> Result < OutputFilenames > {
663+ fn output_filenames ( tcx : TyCtxt < ' _ > , ( ) : ( ) ) -> Arc < OutputFilenames > {
664+ let sess = tcx. sess ;
670665 let _timer = sess. timer ( "prepare_outputs" ) ;
666+ let ( _, krate) = & * tcx. resolver_for_lowering ( ( ) ) . borrow ( ) ;
667+ let crate_name = tcx. crate_name ( LOCAL_CRATE ) ;
671668
672669 // FIXME: rustdoc passes &[] instead of &krate.attrs here
673670 let outputs = util:: build_output_filenames ( & krate. attrs , sess) ;
@@ -679,45 +676,41 @@ pub fn prepare_outputs(
679676 if let Some ( ref input_path) = sess. io . input . opt_path ( ) {
680677 if sess. opts . will_create_output_file ( ) {
681678 if output_contains_path ( & output_paths, input_path) {
682- let reported = sess. emit_err ( InputFileWouldBeOverWritten { path : input_path } ) ;
683- return Err ( reported) ;
679+ sess. emit_fatal ( InputFileWouldBeOverWritten { path : input_path } ) ;
684680 }
685681 if let Some ( ref dir_path) = output_conflicts_with_dir ( & output_paths) {
686- let reported =
687- sess. emit_err ( GeneratedFileConflictsWithDirectory { input_path, dir_path } ) ;
688- return Err ( reported) ;
682+ sess. emit_fatal ( GeneratedFileConflictsWithDirectory { input_path, dir_path } ) ;
689683 }
690684 }
691685 }
692686
693687 if let Some ( ref dir) = sess. io . temps_dir {
694688 if fs:: create_dir_all ( dir) . is_err ( ) {
695- let reported = sess. emit_err ( TempsDirError ) ;
696- return Err ( reported) ;
689+ sess. emit_fatal ( TempsDirError ) ;
697690 }
698691 }
699692
700- write_out_deps ( sess, boxed_resolver , & outputs, & output_paths) ;
693+ write_out_deps ( sess, tcx . cstore_untracked ( ) , & outputs, & output_paths) ;
701694
702695 let only_dep_info = sess. opts . output_types . contains_key ( & OutputType :: DepInfo )
703696 && sess. opts . output_types . len ( ) == 1 ;
704697
705698 if !only_dep_info {
706699 if let Some ( ref dir) = sess. io . output_dir {
707700 if fs:: create_dir_all ( dir) . is_err ( ) {
708- let reported = sess. emit_err ( OutDirError ) ;
709- return Err ( reported) ;
701+ sess. emit_fatal ( OutDirError ) ;
710702 }
711703 }
712704 }
713705
714- Ok ( outputs)
706+ outputs. into ( )
715707}
716708
717709pub static DEFAULT_QUERY_PROVIDERS : LazyLock < Providers > = LazyLock :: new ( || {
718710 let providers = & mut Providers :: default ( ) ;
719711 providers. analysis = analysis;
720712 providers. hir_crate = rustc_ast_lowering:: lower_to_hir;
713+ providers. output_filenames = output_filenames;
721714 proc_macro_decls:: provide ( providers) ;
722715 rustc_const_eval:: provide ( providers) ;
723716 rustc_middle:: hir:: provide ( providers) ;
0 commit comments