Skip to content

Commit

Permalink
Rollup merge of rust-lang#35417 - Limeth:master, r=jonathandturner
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Jonathan Turner authored Aug 7, 2016
2 parents 3251520 + 5e06da2 commit 350125b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
14 changes: 9 additions & 5 deletions src/librustc_typeck/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,11 +211,15 @@ fn check_main_fn_ty(ccx: &CrateCtxt,
match tcx.map.find(main_id) {
Some(hir_map::NodeItem(it)) => {
match it.node {
hir::ItemFn(_, _, _, _, ref ps, _)
if ps.is_parameterized() => {
span_err!(ccx.tcx.sess, main_span, E0131,
"main function is not allowed to have type parameters");
return;
hir::ItemFn(_, _, _, _, ref generics, _) => {
if let Some(gen_span) = generics.span() {
struct_span_err!(ccx.tcx.sess, gen_span, E0131,
"main function is not allowed to have type parameters")
.span_label(gen_span,
&format!("main cannot have type parameters"))
.emit();
return;
}
}
_ => ()
}
Expand Down
4 changes: 3 additions & 1 deletion src/test/compile-fail/E0131.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

fn main<T>() { //~ ERROR E0131
fn main<T>() {
//~^ ERROR E0131
//~| NOTE main cannot have type parameters
}

0 comments on commit 350125b

Please sign in to comment.