From d16804afa7983ca075a7f97c4aa874d505a266a7 Mon Sep 17 00:00:00 2001 From: Chiu-Hsiang Hsu Date: Thu, 11 Aug 2016 00:38:12 +0800 Subject: [PATCH] Update E0138 to new format --- src/librustc/middle/entry.rs | 8 ++++++-- src/test/compile-fail/E0138.rs | 5 ++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/librustc/middle/entry.rs b/src/librustc/middle/entry.rs index 0a363fddd5312..c6721e930e633 100644 --- a/src/librustc/middle/entry.rs +++ b/src/librustc/middle/entry.rs @@ -132,8 +132,12 @@ fn find_item(item: &Item, ctxt: &mut EntryContext, at_root: bool) { if ctxt.start_fn.is_none() { ctxt.start_fn = Some((item.id, item.span)); } else { - span_err!(ctxt.session, item.span, E0138, - "multiple 'start' functions"); + struct_span_err!( + ctxt.session, item.span, E0138, + "multiple 'start' functions") + .span_label(ctxt.start_fn.unwrap().1, &format!("previous `start` function here")) + .span_label(item.span, &format!("multiple `start` functions")) + .emit(); } }, EntryPointType::None => () diff --git a/src/test/compile-fail/E0138.rs b/src/test/compile-fail/E0138.rs index 97d85e5e71e08..d4630d7c2effb 100644 --- a/src/test/compile-fail/E0138.rs +++ b/src/test/compile-fail/E0138.rs @@ -12,6 +12,9 @@ #[start] fn foo(argc: isize, argv: *const *const u8) -> isize {} +//~^ NOTE previous `start` function here #[start] -fn f(argc: isize, argv: *const *const u8) -> isize {} //~ ERROR E0138 +fn f(argc: isize, argv: *const *const u8) -> isize {} +//~^ ERROR E0138 +//~| NOTE multiple `start` functions