typeck: Report main return type errors on return type span
This commit is contained in:
parent
5ccf3ffab2
commit
72334fee6f
3 changed files with 14 additions and 3 deletions
|
|
@ -1114,8 +1114,9 @@ fn check_fn<'a, 'gcx, 'tcx>(inherited: &'a Inherited<'a, 'gcx, 'tcx>,
|
|||
Some(config::EntryMain) => {
|
||||
let substs = fcx.tcx.mk_substs(iter::once(Kind::from(ret_ty)));
|
||||
let trait_ref = ty::TraitRef::new(term_id, substs);
|
||||
let return_ty_span = decl.output.span();
|
||||
let cause = traits::ObligationCause::new(
|
||||
span, fn_id, ObligationCauseCode::MainFunctionType);
|
||||
return_ty_span, fn_id, ObligationCauseCode::MainFunctionType);
|
||||
|
||||
inherited.register_predicate(
|
||||
traits::Obligation::new(
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// error-pattern:`main` can only return types that implement std::process::Termination, not `char
|
||||
fn main() -> char {
|
||||
fn main() -> char { //~ ERROR
|
||||
' '
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
error[E0277]: the trait bound `char: std::process::Termination` is not satisfied
|
||||
--> $DIR/termination-trait-main-wrong-type.rs:11:14
|
||||
|
|
||||
LL | fn main() -> char { //~ ERROR
|
||||
| ^^^^ `main` can only return types that implement std::process::Termination, not `char`
|
||||
|
|
||||
= help: the trait `std::process::Termination` is not implemented for `char`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0277`.
|
||||
Loading…
Add table
Add a link
Reference in a new issue