rust-lang / rust-lang/rust

When `#![no_main]` is set, `#[start]` is silently ignored

Open
#124,581 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

C-enhancement P-low T-compiler
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

This came up in https://github.com/rust-lang/miri/issues/3498: a user wrote code roughly like this

#![no_main]
#![feature(start)]

#[start]
fn main() {}

and then was surprised that the resulting program didn't have a start function.

The start attribute seems to be entirely ignored, because usually there would be an error that the signature is wrong.

The combination of no_main and the start attribute should probably emit a suitable diagnostic, instead of silently ignoring the attribute.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the provided #![no_main] and #[start] example as the first test case. Trace where these attributes are handled and where the existing signature diagnostic is produced, then add coverage verifying that the combination emits a suitable diagnostic instead of silently ignoring #[start].

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.