Fixes tests

This commit is contained in:
Bastian Köcher 2017-12-21 13:07:50 +01:00
parent 99a108c036
commit f842f7547e
3 changed files with 23 additions and 12 deletions

View File

@ -115,6 +115,8 @@ use syntax::ast;
use syntax::abi::Abi;
use syntax_pos::Span;
use std::iter;
// NB: This module needs to be declared first so diagnostics are
// registered before they are used.
mod diagnostics;
@ -199,6 +201,25 @@ fn check_main_fn_ty<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
}
_ => ()
}
let actual = tcx.fn_sig(main_def_id);
let se_ty = tcx.mk_fn_ptr(ty::Binder(
tcx.mk_fn_sig(
iter::empty(),
// the return type is checked in `check_fn`
actual.output().skip_binder(),
false,
hir::Unsafety::Normal,
Abi::Rust
)
));
require_same_types(
tcx,
&ObligationCause::new(main_span, main_id, ObligationCauseCode::MainFunctionType),
se_ty,
tcx.mk_fn_ptr(actual));
}
_ => {
span_bug!(main_span,

View File

@ -1,11 +0,0 @@
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
fn main() -> i32 { 0 } //~ ERROR E0580

View File

@ -7,8 +7,9 @@
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(termination_trait)]
fn main() -> char {
//~^ ERROR: main function has wrong type [E0580]
//~^ ERROR: the trait bound `char: std::Termination` is not satisfied
' '
}