@@ -16,7 +16,7 @@ use rustc_data_structures::parallel;
16
16
use rustc_data_structures:: sync:: { Lrc , OnceCell , WorkerLocal } ;
17
17
use rustc_errors:: { ErrorGuaranteed , PResult } ;
18
18
use rustc_expand:: base:: { ExtCtxt , LintStoreExpand , ResolverExpand } ;
19
- use rustc_hir:: def_id:: StableCrateId ;
19
+ use rustc_hir:: def_id:: { StableCrateId , LOCAL_CRATE } ;
20
20
use rustc_lint:: { BufferedEarlyLint , EarlyCheckNode , LintStore } ;
21
21
use rustc_metadata:: creader:: CStore ;
22
22
use rustc_middle:: arena:: Arena ;
@@ -47,7 +47,7 @@ use std::marker::PhantomPinned;
47
47
use std:: path:: { Path , PathBuf } ;
48
48
use std:: pin:: Pin ;
49
49
use std:: rc:: Rc ;
50
- use std:: sync:: LazyLock ;
50
+ use std:: sync:: { Arc , LazyLock } ;
51
51
use std:: { env, fs, iter} ;
52
52
53
53
pub fn parse < ' a > ( sess : & ' a Session ) -> PResult < ' a , ast:: Crate > {
@@ -660,13 +660,11 @@ fn write_out_deps(
660
660
}
661
661
}
662
662
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 ;
669
665
let _timer = sess. timer ( "prepare_outputs" ) ;
666
+ let ( _, krate) = & * tcx. resolver_for_lowering ( ( ) ) . borrow ( ) ;
667
+ let crate_name = tcx. crate_name ( LOCAL_CRATE ) ;
670
668
671
669
// FIXME: rustdoc passes &[] instead of &krate.attrs here
672
670
let outputs = util:: build_output_filenames ( & krate. attrs , sess) ;
@@ -678,45 +676,41 @@ pub fn prepare_outputs(
678
676
if let Some ( ref input_path) = sess. io . input . opt_path ( ) {
679
677
if sess. opts . will_create_output_file ( ) {
680
678
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 } ) ;
683
680
}
684
681
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 } ) ;
688
683
}
689
684
}
690
685
}
691
686
692
687
if let Some ( ref dir) = sess. io . temps_dir {
693
688
if fs:: create_dir_all ( dir) . is_err ( ) {
694
- let reported = sess. emit_err ( TempsDirError ) ;
695
- return Err ( reported) ;
689
+ sess. emit_fatal ( TempsDirError ) ;
696
690
}
697
691
}
698
692
699
- write_out_deps ( sess, cstore , & outputs, & output_paths) ;
693
+ write_out_deps ( sess, tcx . cstore_untracked ( ) , & outputs, & output_paths) ;
700
694
701
695
let only_dep_info = sess. opts . output_types . contains_key ( & OutputType :: DepInfo )
702
696
&& sess. opts . output_types . len ( ) == 1 ;
703
697
704
698
if !only_dep_info {
705
699
if let Some ( ref dir) = sess. io . output_dir {
706
700
if fs:: create_dir_all ( dir) . is_err ( ) {
707
- let reported = sess. emit_err ( OutDirError ) ;
708
- return Err ( reported) ;
701
+ sess. emit_fatal ( OutDirError ) ;
709
702
}
710
703
}
711
704
}
712
705
713
- Ok ( outputs)
706
+ outputs. into ( )
714
707
}
715
708
716
709
pub static DEFAULT_QUERY_PROVIDERS : LazyLock < Providers > = LazyLock :: new ( || {
717
710
let providers = & mut Providers :: default ( ) ;
718
711
providers. analysis = analysis;
719
712
providers. hir_crate = rustc_ast_lowering:: lower_to_hir;
713
+ providers. output_filenames = output_filenames;
720
714
proc_macro_decls:: provide ( providers) ;
721
715
rustc_const_eval:: provide ( providers) ;
722
716
rustc_middle:: hir:: provide ( providers) ;
0 commit comments