Skip to content

Conversation

@WaterWhisperer
Copy link

@WaterWhisperer WaterWhisperer commented Dec 18, 2025

fixes the main_recursion lint which was previously skipping all no_std crates. It also fixes existing UI tests that were "testing nothing" because they were either marked as //@check-pass while missing expected errors, or were being compiled as libraries (which have no entrypoints).

  • Lint Change: Removed the has_no_std_attr check in MainRecursion. The is_entrypoint_fn utility is now robust enough to handle entrypoint detection correctly without this manual skip.
  • Test Fixes:
    • Updated entrypoint_recursion.rs by adding a dummy main function to force the compiler to treat it as a binary crate, allowing #[rustc_main] to be recognized as an entrypoint.
    • Added no_std_main_recursion.rs to specifically verify the lint works in #![no_std] environments.

Fixes #11034

  • Added passing UI tests (including committed .stderr file)
  • cargo test passes locally
  • Executed cargo dev update_lints
  • Run cargo dev fmt

changelog: [main_recursion]: now works in no_std crates and fixed broken tests

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Dec 18, 2025
@rustbot
Copy link
Collaborator

rustbot commented Dec 18, 2025

r? @samueltardieu

rustbot has assigned @samueltardieu.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@samueltardieu
Copy link
Member

Isn't the lint expected to ignore no_std entry points? The lint description contains:

Why is this bad?

Apart from special setups (which we could detect following attributes like #![no_std]),
recursing into main() seems like an unintuitive anti-pattern we should be able to detect.

@WaterWhisperer WaterWhisperer force-pushed the main-recursion-tests-11034 branch from fd7f79f to 9bfc9a4 Compare December 19, 2025 14:38
@WaterWhisperer
Copy link
Author

Isn't the lint expected to ignore no_std entry points? The lint description contains:

Why is this bad?

Apart from special setups (which we could detect following attributes like #![no_std]),
recursing into main() seems like an unintuitive anti-pattern we should be able to detect.

Thanks for the review! You are absolutely right. I misread the documentation. I have reverted the change that enabled the lint for no_std crates.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: Awaiting review from the assignee but also interested parties

Projects

None yet

Development

Successfully merging this pull request may close these issues.

clippy::main_recursion tests seem to be testing nothing anymore

3 participants