compiler-explorer / compiler-explorer/compiler-explorer

[BUG]: Rust: claims that `main` function is unused even when running the binary

Open
#5,350 6 comments 1 reaction 1 assignee Claimed by @OfekShilon View on GitHub
bug
Dominant language
TypeScript
Stars
19.1k
Forks
2.1k
Avg merge
3d 15h
Merged PRs (30d)
67

Description

### Describe the bug

Even when building a binary, godbolt claims that `main` is unused.

### Steps to reproduce

1. Visit rust.godbolt.org
2. enter
```rust
fn main() {
println!("Hello world!");
}
```
3. select "Execute the code"

This leads to a warning being shown in the output window:
```
warning: function `main` is never used
--> :1:4
|
1 | fn main() {
| ^^^^
|
= note: `#[warn(dead_code)]` on by default
```

### Expected behavior

The code should run and there should be no warnings.

### Reproduction link

https://rust.godbolt.org/z/1aajhn6cc

### Screenshots

Not applicable

### Operating System

_No response_

### Browser version

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.