rust-lang / rust-lang/rust

#![no_main] breaks compiling with --test

Open
#137,292 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-libtest C-bug T-compiler
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

I tried this code:

See title

I expected to see this happen: #![no_main] gets ignored as libtest can't possibly work with it.
Instead, this happened: A linker error complaining that main doesn't exist.

Meta

Someone hit this at https://users.rust-lang.org/t/error-when-testing-library/125842

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

No files, tests, or compiler entry points are named. Reproduce the reported combination of --test and #![no_main], then trace how it reaches the linker; done means the case no longer fails because main is missing and has regression coverage.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.