Skip to content

Commit df726a4

Browse files
author
Vincent Prouillet
committed
Update error format for E0137
1 parent 271d048 commit df726a4

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

src/librustc/middle/entry.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,11 @@ fn find_item(item: &Item, ctxt: &mut EntryContext, at_root: bool) {
121121
if ctxt.attr_main_fn.is_none() {
122122
ctxt.attr_main_fn = Some((item.id, item.span));
123123
} else {
124-
span_err!(ctxt.session, item.span, E0137,
125-
"multiple functions with a #[main] attribute");
124+
struct_span_err!(ctxt.session, item.span, E0137,
125+
"multiple functions with a #[main] attribute")
126+
.span_label(item.span, &format!("additional #[main] function"))
127+
.span_label(ctxt.attr_main_fn.unwrap().1, &format!("first #[main] function"))
128+
.emit();
126129
}
127130
},
128131
EntryPointType::Start => {

src/test/compile-fail/E0137.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111
#![feature(main)]
1212

1313
#[main]
14-
fn foo() {}
14+
fn foo() {} //~ NOTE first #[main] function
1515

1616
#[main]
17-
fn f() {} //~ ERROR E0137
17+
fn f() {}
18+
//~^ ERROR E0137
19+
//~| NOTE additional #[main] function

0 commit comments

Comments
 (0)