Skip to content

Running files that include uppercase letter generates warning #19

Closed
@pheki

Description

@pheki

Running rust-script in any file that includes uppercase letter generates a crate with the same name, which cargo
complains.

While rust files are usually modules and as such should be lowercase, sometimes the user may choose a name that matches his project better. Also cargo-make uses temporary files that may contain uppercase letters.

My proposed solution would be to convert the file name to snake case when using as the crate name. serde can do this for struct fields, so I suppose a simple solution already exists in the ecosystem. I can give it a try if you would accept.

Script.rs:

fn main() {
    println!("test");
}

Output:

$ rust-script Script.rs 
warning: crate `Script_5920885be5fa777047cfed70` should have a snake case name
  |
  = note: `#[warn(non_snake_case)]` on by default
  = help: convert the identifier to snake case: `script_5920885be5fa777047cfed70`

warning: 1 warning emitted

test

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions