Skip to content

A deprecated module containing tests emits an incredibly confusing deprecation warning that is impossible to silence #47238

@sgrif

Description

@sgrif

This code demonstrates the issue in question:

#[deprecated(since = "0.1.0")]
mod foo {
    #[test]
    fn stuff() {}
}

Attempting to run cargo test on this will give an incredibly opaque error message: use of deprecated item 'foo::__test_reexports'. I had to resort to grepping rustc's codebase to figure out where this was coming from.

Additionally, there is no way to silence this error, other than allowing use of deprecated items for the entire crate. Attempting to put #[allow(deprecated)] either on the test itself, or on the deprecated module has no effect.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsA-libtestArea: `#[test]` / the `test` libraryA-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.C-bugCategory: This is a bug.L-deprecatedLint: deprecatedT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions