about summary refs log tree commit diff
path: root/compiler/rustc_middle/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2021-07-01 06:39:37 +0000
committerbors <bors@rust-lang.org>2021-07-01 06:39:37 +0000
commitf8ac8fdacf66b351c6479b0c8313e3e57e571ba4 (patch)
treeba4b962696cf978661df684ca89c46ca85e9f8f9 /compiler/rustc_middle/src
parent1034282bca4402b2a9d913c981002c45dc3e2425 (diff)
parent9b2ba6d1a19fb75b66db64ce6ebedc595e894107 (diff)
downloadrust-f8ac8fdacf66b351c6479b0c8313e3e57e571ba4.tar.gz
rust-f8ac8fdacf66b351c6479b0c8313e3e57e571ba4.zip
Auto merge of #86190 - asquared31415:extern-main-86110-fix, r=varkor
Fix ICE when `main` is declared in an `extern` block

Changes in #84401 to implement `imported_main` changed how the crate entry point is found, and a declared `main` in an `extern` block was detected erroneously.  This was causing the ICE described in #86110.

This PR adds a check for this case and emits an error instead.  Previously a `main` declaration in an `extern` block was not detected as an entry point at all, so emitting an error shouldn't break anything that worked previously.  In 1.52.1 stable this is demonstrated, with a `` `main` function not found`` error.

Fixes #86110
Diffstat (limited to 'compiler/rustc_middle/src')
-rw-r--r--compiler/rustc_middle/src/ty/mod.rs2
1 files changed, 1 insertions, 1 deletions
diff --git a/compiler/rustc_middle/src/ty/mod.rs b/compiler/rustc_middle/src/ty/mod.rs
index 69fa99993bb..7036c05a593 100644
--- a/compiler/rustc_middle/src/ty/mod.rs
+++ b/compiler/rustc_middle/src/ty/mod.rs
@@ -128,7 +128,7 @@ pub struct ResolverOutputs {
     pub main_def: Option<MainDefinition>,
 }
 
-#[derive(Clone, Copy)]
+#[derive(Clone, Copy, Debug)]
 pub struct MainDefinition {
     pub res: Res<ast::NodeId>,
     pub is_import: bool,