Stabilize termination_trait
This stabilizes `main` with non-() return types; see #48453.
This commit is contained in:
parent
c5c650d670
commit
97b3bf99f6
13 changed files with 21 additions and 39 deletions
|
@ -1106,9 +1106,7 @@ fn check_fn<'a, 'gcx, 'tcx>(inherited: &'a Inherited<'a, 'gcx, 'tcx>,
|
|||
}
|
||||
fcx.demand_suptype(span, ret_ty, actual_return_ty);
|
||||
|
||||
if fcx.tcx.features().termination_trait {
|
||||
// If the termination trait language item is activated, check that the main return type
|
||||
// implements the termination trait.
|
||||
// Check that the main return type implements the termination trait.
|
||||
if let Some(term_id) = fcx.tcx.lang_items().termination() {
|
||||
if let Some((id, _)) = *fcx.tcx.sess.entry_fn.borrow() {
|
||||
if id == fn_id {
|
||||
|
@ -1128,7 +1126,6 @@ fn check_fn<'a, 'gcx, 'tcx>(inherited: &'a Inherited<'a, 'gcx, 'tcx>,
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
(fcx, gen_ty)
|
||||
}
|
||||
|
|
|
@ -208,8 +208,7 @@ fn check_main_fn_ty<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
|||
}
|
||||
|
||||
let actual = tcx.fn_sig(main_def_id);
|
||||
let expected_return_type = if tcx.lang_items().termination().is_some()
|
||||
&& tcx.features().termination_trait {
|
||||
let expected_return_type = if tcx.lang_items().termination().is_some() {
|
||||
// we take the return type of the given main function, the real check is done
|
||||
// in `check_fn`
|
||||
actual.output().skip_binder()
|
||||
|
|
|
@ -308,7 +308,6 @@
|
|||
#![feature(str_char)]
|
||||
#![feature(str_internals)]
|
||||
#![feature(str_utf16)]
|
||||
#![feature(termination_trait)]
|
||||
#![feature(test, rustc_private)]
|
||||
#![feature(thread_local)]
|
||||
#![feature(toowned_clone_into)]
|
||||
|
@ -325,6 +324,7 @@
|
|||
#![cfg_attr(test, feature(update_panic_count))]
|
||||
#![cfg_attr(windows, feature(used))]
|
||||
#![cfg_attr(stage0, feature(never_type))]
|
||||
#![cfg_attr(stage0, feature(termination_trait))]
|
||||
|
||||
#![default_lib_allocator]
|
||||
|
||||
|
|
|
@ -429,9 +429,6 @@ declare_features! (
|
|||
// `foo.rs` as an alternative to `foo/mod.rs`
|
||||
(active, non_modrs_mods, "1.24.0", Some(44660), None),
|
||||
|
||||
// Termination trait in main (RFC 1937)
|
||||
(active, termination_trait, "1.24.0", Some(43301), None),
|
||||
|
||||
// Termination trait in tests (RFC 1937)
|
||||
(active, termination_trait_test, "1.24.0", Some(48854), None),
|
||||
|
||||
|
@ -558,6 +555,8 @@ declare_features! (
|
|||
(accepted, inclusive_range_syntax, "1.26.0", Some(28237), None),
|
||||
// allow `..=` in patterns (RFC 1192)
|
||||
(accepted, dotdoteq_in_patterns, "1.26.0", Some(28237), None),
|
||||
// Termination trait in main (RFC 1937)
|
||||
(accepted, termination_trait, "1.26.0", Some(43301), None),
|
||||
);
|
||||
|
||||
// If you change this, please modify src/doc/unstable-book as well. You must
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
fn main() -> i32 { //~ ERROR main function has wrong type [E0580]
|
||||
fn main() -> i32 {
|
||||
//~^ ERROR the trait bound `i32: std::process::Termination` is not satisfied [E0277]
|
||||
0
|
||||
}
|
|
@ -7,7 +7,6 @@
|
|||
// <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: the trait bound `char: std::process::Termination` is not satisfied
|
||||
|
|
|
@ -8,8 +8,6 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#![feature(termination_trait)]
|
||||
|
||||
struct ReturnType {}
|
||||
|
||||
fn main() -> ReturnType { //~ ERROR `ReturnType: std::process::Termination` is not satisfied
|
||||
|
|
|
@ -8,8 +8,6 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#![feature(termination_trait)]
|
||||
|
||||
// error-pattern:oh, dear
|
||||
|
||||
fn main() -> ! {
|
||||
|
|
|
@ -11,8 +11,6 @@
|
|||
// must-compile-successfully
|
||||
// failure-status: 1
|
||||
|
||||
#![feature(termination_trait)]
|
||||
|
||||
use std::io::{Error, ErrorKind};
|
||||
|
||||
fn main() -> Result<(), Box<Error>> {
|
||||
|
|
|
@ -8,6 +8,4 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#![feature(termination_trait)]
|
||||
|
||||
fn main() {}
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#![feature(termination_trait)]
|
||||
#![feature(process_exitcode_placeholder)]
|
||||
|
||||
use std::process::ExitCode;
|
||||
|
|
|
@ -8,8 +8,6 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#![feature(termination_trait)]
|
||||
|
||||
use std::io::Error;
|
||||
|
||||
fn main() -> Result<(), Box<Error>> {
|
||||
|
|
|
@ -8,8 +8,6 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#![feature(termination_trait)]
|
||||
|
||||
use std::io::Error;
|
||||
|
||||
fn main() -> Result<(), Error> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue