diff options
| author | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2016-08-05 16:12:59 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2016-08-05 16:12:59 +0200 |
| commit | a7b443fd85db4b47dc3399ba6f47db68e87f00f7 (patch) | |
| tree | dc355c68322bf68c00d528e4d98667eda3b81b1f /src | |
| parent | e9b79d918cb8f45f3ebfd71c55840e2f28e1ed59 (diff) | |
| parent | df726a45e18a9e760931f867b995f642131180ad (diff) | |
| download | rust-a7b443fd85db4b47dc3399ba6f47db68e87f00f7.tar.gz rust-a7b443fd85db4b47dc3399ba6f47db68e87f00f7.zip | |
Rollup merge of #35319 - Keats:err-137, r=jonathandturner
Update error format for E0137 Fixes #35265 as part of #35233. r? @jonathandturner
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustc/middle/entry.rs | 7 | ||||
| -rw-r--r-- | src/test/compile-fail/E0137.rs | 6 |
2 files changed, 9 insertions, 4 deletions
diff --git a/src/librustc/middle/entry.rs b/src/librustc/middle/entry.rs index 23a261400ed..0a363fddd53 100644 --- a/src/librustc/middle/entry.rs +++ b/src/librustc/middle/entry.rs @@ -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 => { diff --git a/src/test/compile-fail/E0137.rs b/src/test/compile-fail/E0137.rs index 695ce7995a9..f45afc9f37b 100644 --- a/src/test/compile-fail/E0137.rs +++ b/src/test/compile-fail/E0137.rs @@ -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 |
