File tree 3 files changed +20
-15
lines changed
3 files changed +20
-15
lines changed Original file line number Diff line number Diff line change @@ -94,7 +94,7 @@ use syntax::ast;
94
94
95
95
use mir:: lvalue:: Alignment ;
96
96
97
- pub use rustc_trans_utils:: find_exported_symbols;
97
+ pub use rustc_trans_utils:: { find_exported_symbols, check_for_rustc_errors_attr } ;
98
98
99
99
pub struct StatRecorder < ' a , ' tcx : ' a > {
100
100
ccx : & ' a CrateContext < ' a , ' tcx > ,
@@ -661,20 +661,6 @@ pub fn set_link_section(ccx: &CrateContext,
661
661
}
662
662
}
663
663
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
-
678
664
/// Create the `main` function which will initialize the rust runtime and call
679
665
/// users main function.
680
666
fn maybe_create_entry_wrapper ( ccx : & CrateContext ) {
Original file line number Diff line number Diff line change @@ -52,6 +52,20 @@ use syntax::attr;
52
52
pub mod link;
53
53
pub mod trans_crate;
54
54
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
+
55
69
/// The context provided lists a set of reachable ids as calculated by
56
70
/// middle::reachable, but this contains far more ids and symbols than we're
57
71
/// 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 {
192
192
tcx : TyCtxt < ' a , ' tcx , ' tcx > ,
193
193
_rx : mpsc:: Receiver < Box < Any + Send > >
194
194
) -> 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
+
195
200
let crate_hash = tcx. dep_graph
196
201
. fingerprint_of ( & DepNode :: new_no_params ( DepKind :: Krate ) )
197
202
. unwrap ( ) ;
You can’t perform that action at this time.
0 commit comments