Skip to content

Commit c3cede2

Browse files
authored
Rollup merge of rust-lang#35573 - wdv4758h:E0138, r=jonathandturner
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)
2 parents 9c347b9 + 92f7e85 commit c3cede2

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

src/librustc/middle/entry.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,13 @@ fn find_item(item: &Item, ctxt: &mut EntryContext, at_root: bool) {
132132
if ctxt.start_fn.is_none() {
133133
ctxt.start_fn = Some((item.id, item.span));
134134
} else {
135-
span_err!(ctxt.session, item.span, E0138,
136-
"multiple 'start' functions");
135+
struct_span_err!(
136+
ctxt.session, item.span, E0138,
137+
"multiple 'start' functions")
138+
.span_label(ctxt.start_fn.unwrap().1,
139+
&format!("previous `start` function here"))
140+
.span_label(item.span, &format!("multiple `start` functions"))
141+
.emit();
137142
}
138143
},
139144
EntryPointType::None => ()

src/test/compile-fail/E0138.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212

1313
#[start]
1414
fn foo(argc: isize, argv: *const *const u8) -> isize {}
15+
//~^ NOTE previous `start` function here
1516

1617
#[start]
17-
fn f(argc: isize, argv: *const *const u8) -> isize {} //~ ERROR E0138
18+
fn f(argc: isize, argv: *const *const u8) -> isize {}
19+
//~^ ERROR E0138
20+
//~| NOTE multiple `start` functions

0 commit comments

Comments
 (0)