Skip to content

#[main] attribute was unintentionally stabilized (as no-op) in 1.53.0 #93786

Closed
@jeremyBanks

Description

@jeremyBanks

Code

I tried this code:

#[main]
fn main() {}

I expected an error, because the main attribute has never been available on stable, and had apparently been removed in #84217.

Instead, the program ran without error, although the attribute has no apparent effect.

Version it worked on

It most recently worked as expected (emitting an error) on Rust 1.52.1:

$ cargo +1.52.1 build    
   Compiling regression-testing v0.0.0 (/Users/jeremy/src/github.com/jeremyBanks/rust-regression)
error[E0658]: declaration of a non-standard `#[main]` function may change over time, for now a top-level `fn main()` is required
 --> src/main.rs:2:1
  |
2 | fn main() {}
  | ^^^^^^^^^^^^
  |
  = note: see issue #29634 <https://github.com/rust-lang/rust/issues/29634> for more information

Version with regression

This stopped being an error in 1.53.0 (in which a warning was still emitted), and continues to be accepted in stable through the current 1.58.1 version (in which the warning has also disappeared).

$ cargo +1.53.0 build    
   Compiling regression-testing v0.0.0 (/Users/jeremy/src/github.com/jeremyBanks/rust-regression)
warning: unused attribute
 --> src/main.rs:1:1
  |
1 | #[main]
  | ^^^^^^^
  |
  = note: `#[warn(unused_attributes)]` on by default
$ cargo +1.58.1 build    
   Compiling regression-testing v0.0.0 (/Users/jeremy/src/github.com/jeremyBanks/rust-regression)

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.P-highHigh priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions