about summary refs log tree commit diff
path: root/src/librustc_codegen_utils/lib.rs
diff options
context:
space:
mode:
authorMazdak Farrokhzad <twingoow@gmail.com>2019-01-19 09:03:27 +0100
committerGitHub <noreply@github.com>2019-01-19 09:03:27 +0100
commit64eb69b904513b8f277102e4c802527e718debdc (patch)
treedfce43133cbca3c923e24bbfa0874768d0650157 /src/librustc_codegen_utils/lib.rs
parentb941f290ac40c32aa7096dff8a2588b818cc79cb (diff)
parentb7cd24dd44eafa44797fdd4e418013d1ea0fd1db (diff)
Rollup merge of #57573 - Xanewok:querify-entry-fn, r=Zoxc
Querify `entry_fn`

Analogous to https://github.com/rust-lang/rust/pull/57570 but this will also require few fixups in Miri so I decided to separate that (and it seems [CI doesn't let us break tools anymore](https://github.com/rust-lang/rust/pull/57392#issuecomment-453801540)? Or was that because it was a rollup PR?)

r? @nikomatsakis
Diffstat (limited to 'src/librustc_codegen_utils/lib.rs')
-rw-r--r--src/librustc_codegen_utils/lib.rs9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/librustc_codegen_utils/lib.rs b/src/librustc_codegen_utils/lib.rs
index b59bca0ae0e..5f61852178d 100644
--- a/src/librustc_codegen_utils/lib.rs
+++ b/src/librustc_codegen_utils/lib.rs
@@ -31,6 +31,7 @@ extern crate syntax_pos;
 #[macro_use] extern crate rustc_data_structures;
 
 use rustc::ty::TyCtxt;
+use rustc::hir::def_id::LOCAL_CRATE;
 
 pub mod link;
 pub mod codegen_backend;
@@ -42,11 +43,9 @@ pub mod symbol_names_test;
 /// that actually test that compilation succeeds without
 /// reporting an error.
 pub fn check_for_rustc_errors_attr(tcx: TyCtxt) {
-    if let Some((id, span, _)) = *tcx.sess.entry_fn.borrow() {
-        let main_def_id = tcx.hir().local_def_id(id);
-
-        if tcx.has_attr(main_def_id, "rustc_error") {
-            tcx.sess.span_fatal(span, "compilation successful");
+    if let Some((def_id, _)) = tcx.entry_fn(LOCAL_CRATE) {
+        if tcx.has_attr(def_id, "rustc_error") {
+            tcx.sess.span_fatal(tcx.def_span(def_id), "compilation successful");
         }
     }
 }