Skip to content

Remove edition warning in cargo script w/o frontmatter #16598

@nixpulvis

Description

@nixpulvis

Problem

From #12207 (comment)

I don't think a warning should be printed on a script without any frontmatter.

fn main() {
    println!("hello world");
}

Gives output:

warning: `package.edition` is unspecified, defaulting to `2024`
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.00s
     Running `/Users/nate/.cargo/build/cd/32beff75ef4495/target/debug/foo`
hello world

Proposed Solution

Do not emit warning when no edition is specified for a cargo script. Defaulting to the latest edition is a perfectly reasonable default, and is what anyone would expect. Warnings on bare rust scripts without frontmatter are unnecessary noise for users who may not care about edition stability. If you care about stability, you can still specify it easily with frontmatter.

Notes

N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-feature-requestCategory: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`S-triageStatus: This issue is waiting on initial triage.Z-scriptNightly: cargo script

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions