Skip to content

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

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
japaric opened this issue Nov 4, 2014 · 4 comments
Closed

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

japaric opened this issue Nov 4, 2014 · 4 comments
Labels
A-libtest Area: `#[test]` / the `test` library C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@japaric
Copy link
Member

japaric commented Nov 4, 2014

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)
@sfackler sfackler added the A-testsuite Area: The testsuite used to check the correctness of rustc label Nov 4, 2014
@huonw huonw added the A-tools label Aug 24, 2015
@steveklabnik
Copy link
Member

This compiles today!

@petrochenkov petrochenkov added E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. and removed A-testsuite Area: The testsuite used to check the correctness of rustc A-tools labels Mar 1, 2017
@petrochenkov petrochenkov reopened this Mar 1, 2017
@petrochenkov
Copy link
Contributor

Hm, this is not actually fixed.
The name conflict still happens if --test is passed to rustc.

@petrochenkov petrochenkov added A-testsuite Area: The testsuite used to check the correctness of rustc A-tools and removed E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. labels Mar 5, 2017
bors added a commit that referenced this issue Mar 6, 2017
Add missing tests for 'E-needstest' labeled issues

This PR adds missing tests for issue #35988, #19712, ~~#18627~~, #24947, #28600 and #34751.
@alexcrichton alexcrichton added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. and removed T-tools labels May 22, 2017
@Mark-Simulacrum Mark-Simulacrum added C-bug Category: This is a bug. A-libtest Area: `#[test]` / the `test` library and removed A-testsuite Area: The testsuite used to check the correctness of rustc labels Jul 22, 2017
@steveklabnik
Copy link
Member

Triage: still fails

@Mark-Simulacrum
Copy link
Member

Seems to have been fixed, probably due to custom test frameworks and/or more hygienic and better test expansion.

lnicola pushed a commit to lnicola/rust that referenced this issue Dec 11, 2024
Improve heuristics for on typing semicolon insertion
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-libtest Area: `#[test]` / the `test` library C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

7 participants