Skip to content

Commit

Permalink
Update error format for E0137
Browse files Browse the repository at this point in the history
  • Loading branch information
Vincent Prouillet committed Aug 4, 2016
1 parent 271d048 commit df726a4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
7 changes: 5 additions & 2 deletions src/librustc/middle/entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,11 @@ fn find_item(item: &Item, ctxt: &mut EntryContext, at_root: bool) {
if ctxt.attr_main_fn.is_none() {
ctxt.attr_main_fn = Some((item.id, item.span));
} else {
span_err!(ctxt.session, item.span, E0137,
"multiple functions with a #[main] attribute");
struct_span_err!(ctxt.session, item.span, E0137,
"multiple functions with a #[main] attribute")
.span_label(item.span, &format!("additional #[main] function"))
.span_label(ctxt.attr_main_fn.unwrap().1, &format!("first #[main] function"))
.emit();
}
},
EntryPointType::Start => {
Expand Down
6 changes: 4 additions & 2 deletions src/test/compile-fail/E0137.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
#![feature(main)]

#[main]
fn foo() {}
fn foo() {} //~ NOTE first #[main] function

#[main]
fn f() {} //~ ERROR E0137
fn f() {}
//~^ ERROR E0137
//~| NOTE additional #[main] function

0 comments on commit df726a4

Please sign in to comment.