Skip to content

#[main] attribute on #[test] function does not error properly #33946

Closed
@LeoTestard

Description

@LeoTestard

On stable, it gives the expected error:

#[test] #[main] fn main() {}
error: declaration of a nonstandard #[main] function may change over time, for now a top-level `fn main()` is required (see issue #29634)

But on nightly it just says:

error: main function not found

This is because since #32846, complete feature-gate-checking is done after #[test] items are stripped. It sounds to me easy to fix, but I'm wondering if feature-gate-checking is really the right place to catch this error. After all, we do not check #[test] items for correctness, so we shouldn't feature-gate-check them either, just like #[cfg()]-guarded items. Maybe the new message is fine after all.

cc @jseyfried

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-attributesArea: Attributes (`#[…]`, `#![…]`)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions