File tree Expand file tree Collapse file tree 3 files changed +20
-15
lines changed Expand file tree Collapse file tree 3 files changed +20
-15
lines changed Original file line number Diff line number Diff line change @@ -94,7 +94,7 @@ use syntax::ast;
9494
9595use mir:: lvalue:: Alignment ;
9696
97- pub use rustc_trans_utils:: find_exported_symbols;
97+ pub use rustc_trans_utils:: { find_exported_symbols, check_for_rustc_errors_attr } ;
9898
9999pub struct StatRecorder < ' a , ' tcx : ' a > {
100100 ccx : & ' a CrateContext < ' a , ' tcx > ,
@@ -661,20 +661,6 @@ pub fn set_link_section(ccx: &CrateContext,
661661 }
662662}
663663
664- // check for the #[rustc_error] annotation, which forces an
665- // error in trans. This is used to write compile-fail tests
666- // that actually test that compilation succeeds without
667- // reporting an error.
668- fn check_for_rustc_errors_attr ( tcx : TyCtxt ) {
669- if let Some ( ( id, span) ) = * tcx. sess . entry_fn . borrow ( ) {
670- let main_def_id = tcx. hir . local_def_id ( id) ;
671-
672- if tcx. has_attr ( main_def_id, "rustc_error" ) {
673- tcx. sess . span_fatal ( span, "compilation successful" ) ;
674- }
675- }
676- }
677-
678664/// Create the `main` function which will initialize the rust runtime and call
679665/// users main function.
680666fn maybe_create_entry_wrapper ( ccx : & CrateContext ) {
Original file line number Diff line number Diff line change @@ -52,6 +52,20 @@ use syntax::attr;
5252pub mod link;
5353pub mod trans_crate;
5454
55+ /// check for the #[rustc_error] annotation, which forces an
56+ /// error in trans. This is used to write compile-fail tests
57+ /// that actually test that compilation succeeds without
58+ /// reporting an error.
59+ pub fn check_for_rustc_errors_attr ( tcx : TyCtxt ) {
60+ if let Some ( ( id, span) ) = * tcx. sess . entry_fn . borrow ( ) {
61+ let main_def_id = tcx. hir . local_def_id ( id) ;
62+
63+ if tcx. has_attr ( main_def_id, "rustc_error" ) {
64+ tcx. sess . span_fatal ( span, "compilation successful" ) ;
65+ }
66+ }
67+ }
68+
5569/// The context provided lists a set of reachable ids as calculated by
5670/// middle::reachable, but this contains far more ids and symbols than we're
5771/// actually exposing from the object file. This function will filter the set in
Original file line number Diff line number Diff line change @@ -192,6 +192,11 @@ impl TransCrate for MetadataOnlyTransCrate {
192192 tcx : TyCtxt < ' a , ' tcx , ' tcx > ,
193193 _rx : mpsc:: Receiver < Box < Any + Send > >
194194 ) -> Self :: OngoingCrateTranslation {
195+ :: check_for_rustc_errors_attr ( tcx) ;
196+ let _ = tcx. link_args ( LOCAL_CRATE ) ;
197+ let _ = tcx. native_libraries ( LOCAL_CRATE ) ;
198+ tcx. sess . abort_if_errors ( ) ;
199+
195200 let crate_hash = tcx. dep_graph
196201 . fingerprint_of ( & DepNode :: new_no_params ( DepKind :: Krate ) )
197202 . unwrap ( ) ;
You can’t perform that action at this time.
0 commit comments