Skip to content

Commit a1e240c

Browse files
Improve E0137 error explanatIon
1 parent ab7c35f commit a1e240c

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

src/librustc/diagnostics.rs

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,9 +392,30 @@ function `main()`. If there are multiple such functions, please rename one.
392392
"##,
393393

394394
E0137: r##"
395+
More than one function was declared with the `#[main]` attribute.
396+
397+
Erroneous code example:
398+
399+
```compile_fail
400+
#![feature(main)]
401+
402+
#[main]
403+
fn foo() {}
404+
405+
#[main]
406+
fn f() {} // error: multiple functions with a #[main] attribute
407+
```
408+
395409
This error indicates that the compiler found multiple functions with the
396410
`#[main]` attribute. This is an error because there must be a unique entry
397-
point into a Rust program.
411+
point into a Rust program. Example:
412+
413+
```
414+
#![feature(main)]
415+
416+
#[main]
417+
fn f() {} // ok!
418+
```
398419
"##,
399420

400421
E0138: r##"

0 commit comments

Comments
 (0)