From 360d7234c7ce1392c2730fba2e7d9b33f3ff9e5f Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Fri, 27 May 2016 21:47:59 +0200 Subject: [PATCH] Improve E0138 error explanation --- src/librustc/diagnostics.rs | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/librustc/diagnostics.rs b/src/librustc/diagnostics.rs index 56d57d39be6..7c350987aa1 100644 --- a/src/librustc/diagnostics.rs +++ b/src/librustc/diagnostics.rs @@ -419,9 +419,32 @@ fn f() {} // ok! "##, E0138: r##" +More than one function was declared with the `#[start]` attribute. + +Erroneous code example: + +```compile_fail +#![feature(start)] + +#[start] +fn foo(argc: isize, argv: *const *const u8) -> isize {} + +#[start] +fn f(argc: isize, argv: *const *const u8) -> isize {} +// error: multiple 'start' functions +``` + This error indicates that the compiler found multiple functions with the `#[start]` attribute. This is an error because there must be a unique entry -point into a Rust program. +point into a Rust program. Example: + + +``` +#![feature(start)] + +#[start] +fn foo(argc: isize, argv: *const *const u8) -> isize {} // ok! +``` "##, // FIXME link this to the relevant turpl chapters for instilling fear of the