Skip to content

path attribute on modules is useless in nested modules #35016

Open
@jethrogb

Description

@jethrogb

My crate has some test support data in tests/support/mod.rs. When trying to load this module for unit tests like this:

mod tests {
    #[path="../tests/support/mod.rs"]
    mod support;
}

I get an error like this:

error: couldn't read "src/tests/../tests/support/mod.rs": No such file or directory (os error 2)

In fact, specifying pretty much any path is going to fail, because the src/tests/ directory does not exist, because I'm using a nested module and not a separate file. When using nested modules, I think the path at which relative path resolution should start should be the directory that the actual source file is in.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-attributesArea: Attributes (`#[…]`, `#![…]`)A-diagnosticsArea: Messages for errors, warnings, and lintsC-enhancementCategory: An issue proposing an enhancement or a PR with one.P-lowLow priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.T-langRelevant to the language team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions