Skip to content

Test function can't have same name as a module in the same scope #18627

Closed
@japaric

Description

@japaric

STR

// test.rs
#[test]
fn mat() {}

mod mat {
    // NB Necessary to have a test here
    #[test]
    fn col() {}
}

Output

test.rs:1:1: 1:1 error: a type named `mat` has already been imported in this module
test.rs:1 // test.rs
          ^
error: aborting due to previous error

If you expand the file, you can see the collision:

$ rustc --pretty=expanded --test test.rs
// ...
pub mod __test_reexports {
    #[prelude_import]
    use std::prelude::*;
    pub use super::mat;  // <---
    pub use super::mat::__test_reexports as mat;  // <---
}
// ...

Version

rustc 0.13.0-dev (3a8f4ec32 2014-11-04 11:11:20 +0000)

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-libtestArea: `#[test]` / the `test` libraryC-bugCategory: This is a bug.T-compilerRelevant to the compiler 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