Skip to content

Make test expansion induce less reachability #16034

New issue

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

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

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 29, 2014

Conversation

sfackler
Copy link
Member

We previously reexported entire modules, which caused private things to
become reachable and trip the dead code and private items in public API
lints.

Closes #15912

We previously reexported entire modules, which caused private things to
become reachable and trip the dead code and private items in public API
lints.

Closes rust-lang#15912
@sfackler
Copy link
Member Author

This:

mod foo {
    mod bar {
        #[test] fn bar_test() {}
    }
    #[test] fn foo_test() {}
}
#[test] fn global_test() {}

now expands to this:

#![feature(phase)]
#![no_std]
#![feature(globs)]
#[phase(plugin, link)]
extern crate std = "std";
extern crate rt = "native";
use std::prelude::*;
mod foo {
    use std::prelude::*;
    mod bar {
        use std::prelude::*;
        #[test]
        fn bar_test() { }
        pub mod __test_reexports {
            use std::prelude::*;
            pub use super::bar_test;
        }
    }
    #[test]
    fn foo_test() { }
    pub mod __test_reexports {
        use std::prelude::*;
        pub use super::foo_test;
        pub use bar = super::bar::__test_reexports;
    }
}
#[test]
fn global_test() { }
pub mod __test_reexports {
    use std::prelude::*;
    pub use super::global_test;
    pub use foo = super::foo::__test_reexports;
}
pub mod __test {
    extern crate test;
    use std::prelude::*;
    pub fn main() {
        #![main]
        use std::slice::Vector;
        test::test_main_static(::std::os::args().as_slice(), TESTS);
    }
    pub static TESTS: &'static [self::test::TestDescAndFn] =
        &[self::test::TestDescAndFn{desc:
                                        self::test::TestDesc{name:
                                                                 self::test::StaticTestName("foo::bar::bar_test"),
                                                             ignore: false,
                                                             should_fail:
                                                                 false,},
                                    testfn:
                                        self::test::StaticTestFn(::__test_reexports::foo::bar::bar_test),},
          self::test::TestDescAndFn{desc:
                                        self::test::TestDesc{name:
                                                                 self::test::StaticTestName("foo::foo_test"),
                                                             ignore: false,
                                                             should_fail:
                                                                 false,},
                                    testfn:
                                        self::test::StaticTestFn(::__test_reexports::foo::foo_test),},
          self::test::TestDescAndFn{desc:
                                        self::test::TestDesc{name:
                                                                 self::test::StaticTestName("global_test"),
                                                             ignore: false,
                                                             should_fail:
                                                                 false,},
                                    testfn:
                                        self::test::StaticTestFn(::__test_reexports::global_test),}];
}

@sfackler
Copy link
Member Author

cc @kballard @huonw

bors added a commit that referenced this pull request Jul 29, 2014
We previously reexported entire modules, which caused private things to
become reachable and trip the dead code and private items in public API
lints.

Closes #15912
@bors bors closed this Jul 29, 2014
@bors bors merged commit 97721fa into rust-lang:master Jul 29, 2014
@sfackler sfackler deleted the test-reexport-fix branch November 26, 2016 05:53
bors added a commit to rust-lang-ci/rust that referenced this pull request Dec 11, 2023
…kril

feat: Allow navigation targets to be duplicated when the focus range lies in the macro definition site

![Code_KI1EfbAHRZ](https://github.com/rust-lang/rust-analyzer/assets/3757771/2cc82e5c-320f-4de2-9d55-fe975d180f2a)

Basically if a name of an item originates from the macro definition we now point to that as well as the creating macro call.

Big diff because I also made `FileId`s field private due to some debugging I had to do (having a searchable constructor makes things easier).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

visible_private_types warning when compiling with with test
3 participants