Skip to content

Commit

Permalink
Rollup merge of rust-lang#35573 - wdv4758h:E0138, r=jonathandturner
Browse files Browse the repository at this point in the history
Update E0138 to new format

Part of rust-lang#35233
Fix rust-lang#35510
r? @jonathandturner

![e0138](https://cloud.githubusercontent.com/assets/2716047/17562415/7200d93c-5f5d-11e6-98ff-e15c29f40e03.png)

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)
  • Loading branch information
eddyb authored Aug 14, 2016
2 parents 9c347b9 + 92f7e85 commit c3cede2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
9 changes: 7 additions & 2 deletions src/librustc/middle/entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 => ()
Expand Down
5 changes: 4 additions & 1 deletion src/test/compile-fail/E0138.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit c3cede2

Please sign in to comment.