Skip to content

Commit

Permalink
Stabilize imported_main
Browse files Browse the repository at this point in the history
  • Loading branch information
clubby789 committed Mar 6, 2024
1 parent 62415e2 commit c7030e9
Show file tree
Hide file tree
Showing 17 changed files with 7 additions and 51 deletions.
2 changes: 2 additions & 0 deletions compiler/rustc_feature/src/accepted.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,8 @@ declare_features! (
(accepted, impl_header_lifetime_elision, "1.31.0", Some(15872)),
/// Allows referencing `Self` and projections in impl-trait.
(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.
(accepted, inclusive_range_syntax, "1.26.0", Some(28237)),
/// Allows inferring outlives requirements (RFC 2093).
Expand Down
2 changes: 0 additions & 2 deletions compiler/rustc_feature/src/unstable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -489,8 +489,6 @@ declare_features! (
(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.
(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.
(incomplete, inherent_associated_types, "1.52.0", Some(8995)),
/// Allow anonymous constants from an inline `const` block
Expand Down
11 changes: 0 additions & 11 deletions compiler/rustc_passes/src/entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ use rustc_hir::{ItemId, Node, CRATE_HIR_ID};
use rustc_middle::query::Providers;
use rustc_middle::ty::TyCtxt;
use rustc_session::config::{sigpipe, CrateType, EntryFnType};
use rustc_session::parse::feature_err;
use rustc_span::symbol::sym;
use rustc_span::{Span, Symbol};

Expand Down Expand Up @@ -132,16 +131,6 @@ fn configure_main(tcx: TyCtxt<'_>, visitor: &EntryContext<'_>) -> Option<(DefId,
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) }));
}
no_main_err(tcx, visitor);
Expand Down
2 changes: 0 additions & 2 deletions src/tools/miri/test-cargo-miri/tests/main.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
#![feature(imported_main)]

use cargo_miri_test::main;
2 changes: 0 additions & 2 deletions src/tools/miri/tests/pass/imported_main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#![feature(imported_main)]

pub mod foo {
pub fn mymain() {
println!("Hello, world!");
Expand Down
2 changes: 0 additions & 2 deletions src/tools/miri/tests/pass/main_fn.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#![feature(imported_main)]

mod foo {
pub(crate) fn bar() {}
}
Expand Down
3 changes: 1 addition & 2 deletions tests/ui/entry-point/imported_main_conflict.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#![feature(imported_main)]
//~^ ERROR `main` is ambiguous
//~ ERROR `main` is ambiguous
mod m1 { pub(crate) fn main() {} }
mod m2 { pub(crate) fn main() {} }

Expand Down
4 changes: 2 additions & 2 deletions tests/ui/entry-point/imported_main_conflict.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ error[E0659]: `main` is ambiguous
|
= note: ambiguous because of multiple glob imports of a name in the same module
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::*;
| ^^^^^
= help: consider adding an explicit import of `main` to disambiguate
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::*;
| ^^^^^
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#![feature(imported_main)]
#![feature(type_alias_impl_trait)]
#![allow(incomplete_features)]
pub mod foo {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
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;
| ---------------- ^ consider adding a `main` function to `$DIR/imported_main_const_fn_item_type_forbidden.rs`
Expand Down
1 change: 0 additions & 1 deletion tests/ui/entry-point/imported_main_const_forbidden.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#![feature(imported_main)]
pub mod foo {
pub const BAR: usize = 42;
}
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/entry-point/imported_main_const_forbidden.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
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;
| ---------------- ^ consider adding a `main` function to `$DIR/imported_main_const_forbidden.rs`
Expand Down
2 changes: 0 additions & 2 deletions tests/ui/entry-point/imported_main_from_extern_crate.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
//@ run-pass
//@ aux-build:main_functions.rs

#![feature(imported_main)]

extern crate main_functions;
pub use main_functions::boilerplate as main;
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
//@ aux-build:bad_main_functions.rs

#![feature(imported_main)]

extern crate bad_main_functions;
pub use bad_main_functions::boilerplate as main;
1 change: 0 additions & 1 deletion tests/ui/entry-point/imported_main_from_inner_mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//@ run-pass
#![feature(imported_main)]

pub mod foo {
pub fn bar() {
Expand Down
6 changes: 0 additions & 6 deletions tests/ui/feature-gates/feature-gate-imported_main.rs

This file was deleted.

13 changes: 0 additions & 13 deletions tests/ui/feature-gates/feature-gate-imported_main.stderr

This file was deleted.

0 comments on commit c7030e9

Please sign in to comment.