about summary refs log tree commit diff
path: root/compiler/rustc_middle/src/ty/context.rs
diff options
context:
space:
mode:
authorBen Kimock <kimockb@gmail.com>2025-07-17 18:41:52 -0400
committerBen Kimock <kimockb@gmail.com>2025-07-21 19:54:37 -0400
commitc4eb07761643d2fa26d6f609eb23c8d22e14d8eb (patch)
treeb1e562d8d3a6158abb3a9a7234ef860c74e949fa /compiler/rustc_middle/src/ty/context.rs
parent9cd918bcbbc26deb005eb4e1bd9a445380195e56 (diff)
downloadrust-c4eb07761643d2fa26d6f609eb23c8d22e14d8eb.tar.gz
rust-c4eb07761643d2fa26d6f609eb23c8d22e14d8eb.zip
Ensure we codegen and don't internalize the entrypoint
Diffstat (limited to 'compiler/rustc_middle/src/ty/context.rs')
-rw-r--r--compiler/rustc_middle/src/ty/context.rs14
1 files changed, 14 insertions, 0 deletions
diff --git a/compiler/rustc_middle/src/ty/context.rs b/compiler/rustc_middle/src/ty/context.rs
index 915b062417f..26da2abe126 100644
--- a/compiler/rustc_middle/src/ty/context.rs
+++ b/compiler/rustc_middle/src/ty/context.rs
@@ -3402,6 +3402,20 @@ impl<'tcx> TyCtxt<'tcx> {
     pub fn do_not_recommend_impl(self, def_id: DefId) -> bool {
         self.get_diagnostic_attr(def_id, sym::do_not_recommend).is_some()
     }
+
+    /// Whether this def is one of the special bin crate entrypoint functions that must have a
+    /// monomorphization and also not be internalized in the bin crate.
+    pub fn is_entrypoint(self, def_id: DefId) -> bool {
+        if self.is_lang_item(def_id, LangItem::Start) {
+            return true;
+        }
+        if let Some((entry_def_id, _)) = self.entry_fn(())
+            && entry_def_id == def_id
+        {
+            return true;
+        }
+        false
+    }
 }
 
 /// Parameter attributes that can only be determined by examining the body of a function instead