Skip to content

Commit f842f75

Browse files
committed
Fixes tests
1 parent 99a108c commit f842f75

File tree

3 files changed

+23
-12
lines changed

3 files changed

+23
-12
lines changed

src/librustc_typeck/lib.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,8 @@ use syntax::ast;
115115
use syntax::abi::Abi;
116116
use syntax_pos::Span;
117117

118+
use std::iter;
119+
118120
// NB: This module needs to be declared first so diagnostics are
119121
// registered before they are used.
120122
mod diagnostics;
@@ -199,6 +201,25 @@ fn check_main_fn_ty<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
199201
}
200202
_ => ()
201203
}
204+
205+
let actual = tcx.fn_sig(main_def_id);
206+
207+
let se_ty = tcx.mk_fn_ptr(ty::Binder(
208+
tcx.mk_fn_sig(
209+
iter::empty(),
210+
// the return type is checked in `check_fn`
211+
actual.output().skip_binder(),
212+
false,
213+
hir::Unsafety::Normal,
214+
Abi::Rust
215+
)
216+
));
217+
218+
require_same_types(
219+
tcx,
220+
&ObligationCause::new(main_span, main_id, ObligationCauseCode::MainFunctionType),
221+
se_ty,
222+
tcx.mk_fn_ptr(actual));
202223
}
203224
_ => {
204225
span_bug!(main_span,

src/test/compile-fail/E0580.rs

Lines changed: 0 additions & 11 deletions
This file was deleted.

src/test/compile-fail/main-wrong-type-2.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@
77
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
10+
#![feature(termination_trait)]
1011

1112
fn main() -> char {
12-
//~^ ERROR: main function has wrong type [E0580]
13+
//~^ ERROR: the trait bound `char: std::Termination` is not satisfied
1314
' '
1415
}

0 commit comments

Comments
 (0)