Don't use extern crate aliases when searching for dependencies

This commit is contained in:
Ryan Hunt 2018-03-14 14:39:28 -05:00
parent 0c9c32ecdb
commit cf3529fa84
9 changed files with 59 additions and 5 deletions

View File

@ -351,11 +351,7 @@ impl Parser {
}
}
&syn::Item::ExternCrate(ref item) => {
let dep_pkg_name = if let Some((_, ref name)) = item.rename {
name.to_string()
} else {
item.ident.to_string()
};
let dep_pkg_name = item.ident.to_string();
let cfg = Cfg::load(&item.attrs);
if let &Some(ref cfg) = &cfg {

View File

@ -0,0 +1,9 @@
#include <stdint.h>
#include <stdlib.h>
#include <stdbool.h>
typedef struct {
int32_t x;
} Foo;
void root(Foo a);

View File

@ -0,0 +1,12 @@
#include <cstdint>
#include <cstdlib>
struct Foo {
int32_t x;
};
extern "C" {
void root(Foo a);
} // extern "C"

11
tests/rust/rename-crate/Cargo.lock generated Normal file
View File

@ -0,0 +1,11 @@
[[package]]
name = "dependency"
version = "0.1.0"
[[package]]
name = "rename-crate"
version = "0.1.0"
dependencies = [
"dependency 0.1.0",
]

View File

@ -0,0 +1,7 @@
[package]
name = "rename-crate"
version = "0.1.0"
authors = ["Ryan Hunt <rhunt@eqrion.net>"]
[dependencies]
dependency = { path = "./dependency/" }

View File

@ -0,0 +1,2 @@
[parse]
parse_deps = true

View File

@ -0,0 +1,6 @@
[package]
name = "dependency"
version = "0.1.0"
authors = ["Ryan Hunt <rhunt@eqrion.net>"]
[dependencies]

View File

@ -0,0 +1,4 @@
#[repr(C)]
pub struct Foo {
x: i32,
}

View File

@ -0,0 +1,7 @@
extern crate dependency as internal_name;
pub use internal_name::*;
#[no_mangle]
pub extern "C" fn root(a: Foo) {
}