diff options
| author | Eduard-Mihai Burtescu <edy.burt@gmail.com> | 2016-08-14 20:29:49 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2016-08-14 20:29:49 +0300 |
| commit | c3cede2257424d3d1879618a784974b967491b9b (patch) | |
| tree | 8bf6235a1ce8d041ddfee4a7af0b3cde6f04ce53 /src | |
| parent | 9c347b93a48c4a0f45b82ac62f90a1296dc5ff7a (diff) | |
| parent | 92f7e85b303b67c2e412275ba663bb811388f9a4 (diff) | |
| download | rust-c3cede2257424d3d1879618a784974b967491b9b.tar.gz rust-c3cede2257424d3d1879618a784974b967491b9b.zip | |
Rollup merge of #35573 - wdv4758h:E0138, r=jonathandturner
Update E0138 to new format Part of #35233 Fix #35510 r? @jonathandturner  Question: How can I only underline the function name ? I have observed the debug output and the struct of item, but I can't find the `Span` for function name. Should I modify the struct I get to save function name's position or there is another way to get it ? (I can only find `Span`s for function attributes, inputs, outputs, blocks)
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustc/middle/entry.rs | 9 | ||||
| -rw-r--r-- | src/test/compile-fail/E0138.rs | 5 |
2 files changed, 11 insertions, 3 deletions
diff --git a/src/librustc/middle/entry.rs b/src/librustc/middle/entry.rs index 0a363fddd53..11bde922f47 100644 --- a/src/librustc/middle/entry.rs +++ b/src/librustc/middle/entry.rs @@ -132,8 +132,13 @@ 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 97d85e5e71e..d4630d7c2ef 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 |
