Skip to content

regression: error: module should be marked with the #[cfg(test)] attribute #140225

Closed
@cuviper

Description

@cuviper
[INFO] [stdout] error: module should be marked with the `#[cfg(test)]` attribute
[INFO] [stdout]        
[INFO] [stdout]          = help: add `#[cfg(test)]` to the module
[INFO] [stdout]        
[INFO] [stdout]   --> crates/after-test_test/src/lib.rs:3:1
[INFO] [stdout]    |
[INFO] [stdout] 3  | / mod panics {
[INFO] [stdout] 4  | |     fn panic_with_message() {
[INFO] [stdout] 5  | |         panic!("This is a panic message");
[INFO] [stdout] ...  |
[INFO] [stdout] 10 | |     fn test_should_panic() {}
[INFO] [stdout] 11 | | }
[INFO] [stdout]    | |_^

(and several more like that)

That particular error message comes from their own proc-macro. The module does have the expected attribute, but I suppose something must have changed in how we provide that to the macro.

#[after_test::cleanup(panic_with_message)]
#[cfg(test)]
mod panics {
    fn panic_with_message() {
        panic!("This is a panic message");
    }

    #[test]
    #[should_panic(expected = "This is a panic message")]
    fn test_should_panic() {}
}

Version it worked on

It most recently worked on: 1.86.0

Version with regression

rustc 1.87.0-beta.5 (386abeb93 2025-04-19) in crater #139827.

@rustbot modify labels: +regression-from-stable-to-beta -regression-untriaged

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-attributesArea: Attributes (`#[…]`, `#![…]`)A-cfgArea: `cfg` conditional compilationA-proc-macrosArea: Procedural macrosC-bugCategory: This is a bug.S-has-bisectionStatus: A bisection has been found for this issueS-has-mcveStatus: A Minimal Complete and Verifiable Example has been found for this issueregression-from-stable-to-betaPerformance or correctness regression from stable to beta.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions