Skip to content

Playground code with no main fails to compile with editable code blocks #1767

Open
@micouy

Description

@micouy

The paragraph on Rust Playground says:

If there is no main function, then the code is automatically wrapped inside one.

However, my code doesn't compile without it. I've also replicated it in the editor chapter by removing the main function.

Code:

let number = 5;
print!("{}", number);

Error:

   Compiling playground v0.0.1 (/playground)
error: expected item, found keyword `let`
 --> src/main.rs:1:1
  |
1 | let number = 5;
  | ^^^ expected item

error: could not compile `playground` due to previous error

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions