Stabilize imported_main
This commit is contained in:
parent
62415e2a95
commit
c7030e9b91
@ -201,6 +201,8 @@ macro_rules! declare_features {
|
|||||||
(accepted, impl_header_lifetime_elision, "1.31.0", Some(15872)),
|
(accepted, impl_header_lifetime_elision, "1.31.0", Some(15872)),
|
||||||
/// Allows referencing `Self` and projections in impl-trait.
|
/// Allows referencing `Self` and projections in impl-trait.
|
||||||
(accepted, impl_trait_projections, "1.74.0", Some(103532)),
|
(accepted, impl_trait_projections, "1.74.0", Some(103532)),
|
||||||
|
/// Allows using imported `main` function
|
||||||
|
(accepted, imported_main, "CURRENT_RUSTC_VERSION", Some(28937)),
|
||||||
/// Allows using `a..=b` and `..=b` as inclusive range syntaxes.
|
/// Allows using `a..=b` and `..=b` as inclusive range syntaxes.
|
||||||
(accepted, inclusive_range_syntax, "1.26.0", Some(28237)),
|
(accepted, inclusive_range_syntax, "1.26.0", Some(28237)),
|
||||||
/// Allows inferring outlives requirements (RFC 2093).
|
/// Allows inferring outlives requirements (RFC 2093).
|
||||||
|
@ -489,8 +489,6 @@ pub fn internal(&self, feature: Symbol) -> bool {
|
|||||||
(unstable, impl_trait_in_assoc_type, "1.70.0", Some(63063)),
|
(unstable, impl_trait_in_assoc_type, "1.70.0", Some(63063)),
|
||||||
/// Allows `impl Trait` as output type in `Fn` traits in return position of functions.
|
/// Allows `impl Trait` as output type in `Fn` traits in return position of functions.
|
||||||
(unstable, impl_trait_in_fn_trait_return, "1.64.0", Some(99697)),
|
(unstable, impl_trait_in_fn_trait_return, "1.64.0", Some(99697)),
|
||||||
/// Allows using imported `main` function
|
|
||||||
(unstable, imported_main, "1.53.0", Some(28937)),
|
|
||||||
/// Allows associated types in inherent impls.
|
/// Allows associated types in inherent impls.
|
||||||
(incomplete, inherent_associated_types, "1.52.0", Some(8995)),
|
(incomplete, inherent_associated_types, "1.52.0", Some(8995)),
|
||||||
/// Allow anonymous constants from an inline `const` block
|
/// Allow anonymous constants from an inline `const` block
|
||||||
|
@ -7,7 +7,6 @@
|
|||||||
use rustc_middle::query::Providers;
|
use rustc_middle::query::Providers;
|
||||||
use rustc_middle::ty::TyCtxt;
|
use rustc_middle::ty::TyCtxt;
|
||||||
use rustc_session::config::{sigpipe, CrateType, EntryFnType};
|
use rustc_session::config::{sigpipe, CrateType, EntryFnType};
|
||||||
use rustc_session::parse::feature_err;
|
|
||||||
use rustc_span::symbol::sym;
|
use rustc_span::symbol::sym;
|
||||||
use rustc_span::{Span, Symbol};
|
use rustc_span::{Span, Symbol};
|
||||||
|
|
||||||
@ -132,16 +131,6 @@ fn configure_main(tcx: TyCtxt<'_>, visitor: &EntryContext<'_>) -> Option<(DefId,
|
|||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
if main_def.is_import && !tcx.features().imported_main {
|
|
||||||
let span = main_def.span;
|
|
||||||
feature_err(
|
|
||||||
&tcx.sess,
|
|
||||||
sym::imported_main,
|
|
||||||
span,
|
|
||||||
"using an imported function as entry point `main` is experimental",
|
|
||||||
)
|
|
||||||
.emit();
|
|
||||||
}
|
|
||||||
return Some((def_id, EntryFnType::Main { sigpipe: sigpipe(tcx, def_id) }));
|
return Some((def_id, EntryFnType::Main { sigpipe: sigpipe(tcx, def_id) }));
|
||||||
}
|
}
|
||||||
no_main_err(tcx, visitor);
|
no_main_err(tcx, visitor);
|
||||||
|
@ -1,3 +1 @@
|
|||||||
#![feature(imported_main)]
|
|
||||||
|
|
||||||
use cargo_miri_test::main;
|
use cargo_miri_test::main;
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
#![feature(imported_main)]
|
|
||||||
|
|
||||||
pub mod foo {
|
pub mod foo {
|
||||||
pub fn mymain() {
|
pub fn mymain() {
|
||||||
println!("Hello, world!");
|
println!("Hello, world!");
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
#![feature(imported_main)]
|
|
||||||
|
|
||||||
mod foo {
|
mod foo {
|
||||||
pub(crate) fn bar() {}
|
pub(crate) fn bar() {}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#![feature(imported_main)]
|
//~ ERROR `main` is ambiguous
|
||||||
//~^ ERROR `main` is ambiguous
|
|
||||||
mod m1 { pub(crate) fn main() {} }
|
mod m1 { pub(crate) fn main() {} }
|
||||||
mod m2 { pub(crate) fn main() {} }
|
mod m2 { pub(crate) fn main() {} }
|
||||||
|
|
||||||
|
@ -2,13 +2,13 @@ error[E0659]: `main` is ambiguous
|
|||||||
|
|
|
|
||||||
= note: ambiguous because of multiple glob imports of a name in the same module
|
= note: ambiguous because of multiple glob imports of a name in the same module
|
||||||
note: `main` could refer to the function imported here
|
note: `main` could refer to the function imported here
|
||||||
--> $DIR/imported_main_conflict.rs:6:5
|
--> $DIR/imported_main_conflict.rs:5:5
|
||||||
|
|
|
|
||||||
LL | use m1::*;
|
LL | use m1::*;
|
||||||
| ^^^^^
|
| ^^^^^
|
||||||
= help: consider adding an explicit import of `main` to disambiguate
|
= help: consider adding an explicit import of `main` to disambiguate
|
||||||
note: `main` could also refer to the function imported here
|
note: `main` could also refer to the function imported here
|
||||||
--> $DIR/imported_main_conflict.rs:7:5
|
--> $DIR/imported_main_conflict.rs:6:5
|
||||||
|
|
|
|
||||||
LL | use m2::*;
|
LL | use m2::*;
|
||||||
| ^^^^^
|
| ^^^^^
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
#![feature(imported_main)]
|
|
||||||
#![feature(type_alias_impl_trait)]
|
#![feature(type_alias_impl_trait)]
|
||||||
#![allow(incomplete_features)]
|
#![allow(incomplete_features)]
|
||||||
pub mod foo {
|
pub mod foo {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
error[E0601]: `main` function not found in crate `imported_main_const_fn_item_type_forbidden`
|
error[E0601]: `main` function not found in crate `imported_main_const_fn_item_type_forbidden`
|
||||||
--> $DIR/imported_main_const_fn_item_type_forbidden.rs:11:22
|
--> $DIR/imported_main_const_fn_item_type_forbidden.rs:10:22
|
||||||
|
|
|
|
||||||
LL | use foo::BAR as main;
|
LL | use foo::BAR as main;
|
||||||
| ---------------- ^ consider adding a `main` function to `$DIR/imported_main_const_fn_item_type_forbidden.rs`
|
| ---------------- ^ consider adding a `main` function to `$DIR/imported_main_const_fn_item_type_forbidden.rs`
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
#![feature(imported_main)]
|
|
||||||
pub mod foo {
|
pub mod foo {
|
||||||
pub const BAR: usize = 42;
|
pub const BAR: usize = 42;
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
error[E0601]: `main` function not found in crate `imported_main_const_forbidden`
|
error[E0601]: `main` function not found in crate `imported_main_const_forbidden`
|
||||||
--> $DIR/imported_main_const_forbidden.rs:6:22
|
--> $DIR/imported_main_const_forbidden.rs:5:22
|
||||||
|
|
|
|
||||||
LL | use foo::BAR as main;
|
LL | use foo::BAR as main;
|
||||||
| ---------------- ^ consider adding a `main` function to `$DIR/imported_main_const_forbidden.rs`
|
| ---------------- ^ consider adding a `main` function to `$DIR/imported_main_const_forbidden.rs`
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
//@ run-pass
|
//@ run-pass
|
||||||
//@ aux-build:main_functions.rs
|
//@ aux-build:main_functions.rs
|
||||||
|
|
||||||
#![feature(imported_main)]
|
|
||||||
|
|
||||||
extern crate main_functions;
|
extern crate main_functions;
|
||||||
pub use main_functions::boilerplate as main;
|
pub use main_functions::boilerplate as main;
|
||||||
|
@ -1,6 +1,4 @@
|
|||||||
//@ aux-build:bad_main_functions.rs
|
//@ aux-build:bad_main_functions.rs
|
||||||
|
|
||||||
#![feature(imported_main)]
|
|
||||||
|
|
||||||
extern crate bad_main_functions;
|
extern crate bad_main_functions;
|
||||||
pub use bad_main_functions::boilerplate as main;
|
pub use bad_main_functions::boilerplate as main;
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
//@ run-pass
|
//@ run-pass
|
||||||
#![feature(imported_main)]
|
|
||||||
|
|
||||||
pub mod foo {
|
pub mod foo {
|
||||||
pub fn bar() {
|
pub fn bar() {
|
||||||
|
@ -1,6 +0,0 @@
|
|||||||
pub mod foo {
|
|
||||||
pub fn bar() {
|
|
||||||
println!("Hello world!");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
use foo::bar as main; //~ ERROR using an imported function as entry point
|
|
@ -1,13 +0,0 @@
|
|||||||
error[E0658]: using an imported function as entry point `main` is experimental
|
|
||||||
--> $DIR/feature-gate-imported_main.rs:6:5
|
|
||||||
|
|
|
||||||
LL | use foo::bar as main;
|
|
||||||
| ^^^^^^^^^^^^^^^^
|
|
||||||
|
|
|
||||||
= note: see issue #28937 <https://github.com/rust-lang/rust/issues/28937> for more information
|
|
||||||
= help: add `#![feature(imported_main)]` to the crate attributes to enable
|
|
||||||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
|
||||||
|
|
||||||
error: aborting due to 1 previous error
|
|
||||||
|
|
||||||
For more information about this error, try `rustc --explain E0658`.
|
|
Loading…
Reference in New Issue
Block a user