diff options
| author | Dylan DPC <dylan.dpc@gmail.com> | 2020-02-28 01:55:35 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-02-28 01:55:35 +0100 |
| commit | 350491da19cf92ffd4116e342eed1dc32a139704 (patch) | |
| tree | 8bec39a51a86254747a13cd4bc1ab6230e3864bb /src/librustc_codegen_ssa | |
| parent | 6d69caba110c0c2fb90180df1cbc8be5033b91d4 (diff) | |
| parent | a796af7a7685a21e8c43f93aa5fb3007cd847253 (diff) | |
| download | rust-350491da19cf92ffd4116e342eed1dc32a139704.tar.gz rust-350491da19cf92ffd4116e342eed1dc32a139704.zip | |
Rollup merge of #69379 - jumbatm:llvm-sigsegv, r=pnkfelix
Fail on multiple declarations of `main`. Closes #67946. Previously, when inserting the entry function, we only checked for duplicate _definitions_ of `main`. However, it's possible to cause problems even only having a duplicate _declaration_. For example, shadowing `main` using an extern block isn't caught by the current check, and causes an assertion failure down the line in in LLVM code. r? @pnkfelix
Diffstat (limited to 'src/librustc_codegen_ssa')
| -rw-r--r-- | src/librustc_codegen_ssa/base.rs | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/librustc_codegen_ssa/base.rs b/src/librustc_codegen_ssa/base.rs index e9431d94863..d6e1ab8909c 100644 --- a/src/librustc_codegen_ssa/base.rs +++ b/src/librustc_codegen_ssa/base.rs @@ -437,10 +437,10 @@ pub fn maybe_create_entry_wrapper<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>( // listing. let main_ret_ty = cx.tcx().erase_regions(&main_ret_ty.no_bound_vars().unwrap()); - if cx.get_defined_value("main").is_some() { + if cx.get_declared_value("main").is_some() { // FIXME: We should be smart and show a better diagnostic here. cx.sess() - .struct_span_err(sp, "entry symbol `main` defined multiple times") + .struct_span_err(sp, "entry symbol `main` declared multiple times") .help("did you use `#[no_mangle]` on `fn main`? Use `#[start]` instead") .emit(); cx.sess().abort_if_errors(); |
