-
Notifications
You must be signed in to change notification settings - Fork 144
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
Allow use
statements to happen before the items they reference
#2940
base: master
Are you sure you want to change the base?
Allow use
statements to happen before the items they reference
#2940
Conversation
use
statements to happen before the items they referencesuse
statements to happen before the items they reference
0dea923
to
ced3ded
Compare
This could trigger an assertions as `get_type` on `SelfParam` asserts that the self param does have a given type, which is not always the case. gcc/rust/ChangeLog: * resolve/rust-default-resolver.cc (DefaultResolver::visit): Do not visit self's type if it does not have one.
we're now storing the namespaces and inserting definitions properly - the issue is inserting them in the right Rib. |
but we can't know which namespace to get the Rib from before we can also store 4 pointers to all 4 ribs we're currently visiting when creating the import, and then choose based on what |
Storing all ribs gets messy and unwieldy. I guess having a |
last step is to declare imports in each namespace where they resolved properly. this is highlighted by name_resolution16.rs in the testsuite. the current implementation bails as soon as it finds one namespace an import was resolved in, but we actually need to build a list of namespaces + node Ids for each import |
Last hurdle comes from imports depending on each other, like so: mod foo {
pub struct Foo;
}
use foo::Foo;
use Foo as Fo;
fn main() {} this can probably be fixed by making it more "fixed-pointy" |
This is not ready to review. There is currently a regression compared to master which I'm investigating:
The above code should compile, and does when using
-frust-name-resolution-2.0
on master, but not here. This is probably due toFinalizeImports
not being implemented properly.This also needs testing and cleaning up