mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 23:04:33 +00:00
Improve directory
computation during invocation collection.
This commit is contained in:
parent
2d759046ba
commit
9ac91fa48b
@ -615,16 +615,20 @@ impl<'a, 'b> Folder for InvocationCollector<'a, 'b> {
|
|||||||
ast::ItemKind::Mod(ast::Mod { inner, .. }) => {
|
ast::ItemKind::Mod(ast::Mod { inner, .. }) => {
|
||||||
let mut paths = (*self.cx.syntax_env.paths()).clone();
|
let mut paths = (*self.cx.syntax_env.paths()).clone();
|
||||||
paths.mod_path.push(item.ident);
|
paths.mod_path.push(item.ident);
|
||||||
if item.span.contains(inner) {
|
|
||||||
|
// Detect if this is an inline module (`mod m { ... }` as opposed to `mod m;`).
|
||||||
|
// In the non-inline case, `inner` is never the dummy span (c.f. `parse_item_mod`).
|
||||||
|
// Thus, if `inner` is the dummy span, we know the module is inline.
|
||||||
|
let inline_module = item.span.contains(inner) || inner == syntax_pos::DUMMY_SP;
|
||||||
|
|
||||||
|
if inline_module {
|
||||||
paths.directory.push(&*{
|
paths.directory.push(&*{
|
||||||
::attr::first_attr_value_str_by_name(&item.attrs, "path")
|
::attr::first_attr_value_str_by_name(&item.attrs, "path")
|
||||||
.unwrap_or(item.ident.name.as_str())
|
.unwrap_or(item.ident.name.as_str())
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
paths.directory = match inner {
|
paths.directory =
|
||||||
syntax_pos::DUMMY_SP => PathBuf::new(),
|
PathBuf::from(self.cx.parse_sess.codemap().span_to_filename(inner));
|
||||||
_ => PathBuf::from(self.cx.parse_sess.codemap().span_to_filename(inner)),
|
|
||||||
};
|
|
||||||
paths.directory.pop();
|
paths.directory.pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user