Skip to content
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

Add support for handling re-exports and visibility #131

Merged
merged 8 commits into from
Oct 1, 2020
Merged

Conversation

udoprog
Copy link
Collaborator

@udoprog udoprog commented Oct 1, 2020

A re-export is when an item is imported into a file, like so:

mod a {
    pub use std::option::Option as Bar;
}

fn main() {
    a::Bar::None is Option
}

This requires a bit of care, since the import system is orthogonal to the compile meta system. The hope is that they can be merged at some point.

Note: access checking is still only checked once, from where something is used to where it's declared. So we currently don't support access to get around visibility (yet). Uses also aren't cached, but this will happen once the import system is moved into Query, instead of UnitBuilder where it is now.

We do detect cycles at this point. And support wildcards:

mod a {
    pub mod c { pub use std::option::Option as Baz; }
    pub mod b { pub use super::c::Baz as Bar; }
    pub use self::b::{Bar as Foo, Bar as Foo2};
}

use self::a::*;

fn main() {
    (Foo::None is Option, Foo2::Some(2) is Option)
}

@udoprog udoprog added the enhancement New feature or request label Oct 1, 2020
@udoprog udoprog changed the title Add support for handling re-exports Add support for handling re-exports and visibility Oct 1, 2020
@udoprog udoprog merged commit 87ed307 into master Oct 1, 2020
@udoprog udoprog deleted the use-reexports branch October 1, 2020 18:10
@udoprog udoprog added the changelog Issue has been added to the changelog label Oct 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog Issue has been added to the changelog enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant