-
Notifications
You must be signed in to change notification settings - Fork 13.5k
Add test cases for namespaced crates #142437
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
base: master
Are you sure you want to change the base?
Conversation
|
||
//@ ignore-test FIXME(packages_as_namespaces): feature not implemented yet | ||
|
||
use my_api; // FIXME can be resolved even though it (maybe?) shouldn't be |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use my_api; // FIXME can be resolved even though it (maybe?) shouldn't be | |
use my_api; |
We should decide the desired behavior before merging this. In this test case, my_api
is an open namespace module. I think it makes sense to resolve it, as it's fine to have a module that only contains another module.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, this should generally work, unless there are specific reasons for not supporting it (like issues with reexporting things like this to other crates due to them lacking identity).
|
||
use my_api::core::{core_fn, core_fn2}; | ||
use my_api::utils::*; | ||
use my_api::*; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the 3-scope model this would import from both my_api(crate)
and my_api(open_ns)
.
Therefore it will introduce names root_function
, core
and utils
into this module.
Need to test this behavior.
Old comment (based on mixing open-ns-my_api.rs and open-ns-mod-my_api.rs):
Therefore it will introduce names
utils(mod)
,root_function
andcore
into this module, but notutils(crate)
because it would be shadowed byutils(mod)
.
It would be good to actually add a test case with scenario like that.
@@ -0,0 +1,18 @@ | |||
// This test should fail with `utils` being defined multiple times, since open-ns-mod-my_api.rs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm? There's no open-ns-mod-my_api.rs
in this test.
|
||
//@ ignore-test FIXME(packages_as_namespaces): feature not implemented yet | ||
|
||
use my_api; // FIXME can be resolved even though it (maybe?) shouldn't be |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, this should generally work, unless there are specific reasons for not supporting it (like issues with reexporting things like this to other crates due to them lacking identity).
This is just to add a few test cases of agreed upon desired behavior for this feature so that future PRs can enable them as they start passing.
I pulled these tests out of #140271.
r? @petrochenkov
cc @b-naber