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
Use the generated root module via a relative path #309
Conversation
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.
I'm not sure the self::
is necessary, but this looks great anyway. r=me with the nits addressed :)
.ancestors(ctx) | ||
.filter(|id| ctx.resolve_item(*id).is_module()) | ||
.map(|_| super_.clone()) | ||
.chain(iter::once(super_.clone())); |
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.
nit: I don't think you need this clone
.
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.
Ah yes, thanks.
use std::mem; | ||
use std::ops; | ||
use syntax::abi::Abi; | ||
use syntax::ast; | ||
use syntax::codemap::{Span, respan}; | ||
use syntax::ptr::P; | ||
|
||
fn root_import(ctx: &BindgenContext) -> P<ast::Item> { | ||
fn root_import(ctx: &BindgenContext, module: &Item) -> P<ast::Item> { |
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.
Probably assert!(module.is_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.
Good idea.
Thanks, @emilio ! |
We previously generated uses of the root module with absolute paths: use root; However this only works if the generated bindings are the root of the crate. If they were in some submodule then that path would not be valid. They are now generated relative to the current module, like this: use self::super::super::root; Fixes rust-lang#96
512f4a6
to
8091fd6
Compare
@bors-servo r=emilio |
📌 Commit 8091fd6 has been approved by |
Use the generated root module via a relative path We previously generated uses of the root module with absolute paths: use root; However this only works if the generated bindings are the root of the crate. If they were in some submodule then that path would not be valid. They are now generated relative to the current module, like this: use self::super::super::root; Fixes #96 r? @emilio
☀️ Test successful - status-travis |
We previously generated uses of the root module with absolute paths:
However this only works if the generated bindings are the root of the
crate. If they were in some submodule then that path would not be
valid. They are now generated relative to the current module, like this:
Fixes #96
r? @emilio