Skip to content

Commit 350125b

Browse files
author
Jonathan Turner
authored
Rollup merge of rust-lang#35417 - Limeth:master, r=jonathandturner
E0131 updated to new format Changes ``` error[E0131]: main function is not allowed to have type parameters --> src/test/compile-fail/E0131.rs:11:1 | 11 | fn main<T>() { //~ ERROR E0131 | ^ ``` to ``` error[E0131]: main function is not allowed to have type parameters --> src/test/compile-fail/E0131.rs:11:1 | 11 | fn main<T>() { //~ ERROR E0131 | ^^^ main cannot have type parameters ``` Fixes rust-lang#35257. Part of rust-lang#35233. r? @jonathandturner
2 parents 3251520 + 5e06da2 commit 350125b

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

src/librustc_typeck/lib.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -211,11 +211,15 @@ fn check_main_fn_ty(ccx: &CrateCtxt,
211211
match tcx.map.find(main_id) {
212212
Some(hir_map::NodeItem(it)) => {
213213
match it.node {
214-
hir::ItemFn(_, _, _, _, ref ps, _)
215-
if ps.is_parameterized() => {
216-
span_err!(ccx.tcx.sess, main_span, E0131,
217-
"main function is not allowed to have type parameters");
218-
return;
214+
hir::ItemFn(_, _, _, _, ref generics, _) => {
215+
if let Some(gen_span) = generics.span() {
216+
struct_span_err!(ccx.tcx.sess, gen_span, E0131,
217+
"main function is not allowed to have type parameters")
218+
.span_label(gen_span,
219+
&format!("main cannot have type parameters"))
220+
.emit();
221+
return;
222+
}
219223
}
220224
_ => ()
221225
}

src/test/compile-fail/E0131.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
fn main<T>() { //~ ERROR E0131
11+
fn main<T>() {
12+
//~^ ERROR E0131
13+
//~| NOTE main cannot have type parameters
1214
}

0 commit comments

Comments
 (0)