diff options
author | bors-servo <lbergstrom+bors@mozilla.com> | 2017-04-19 13:35:22 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-04-19 13:35:22 -0500 |
commit | 5a3297ef011cacec5d252ef877df0ea7c9da9d7d (patch) | |
tree | 5e538504b4ffc29186e804b8b5f4da6c50f2ced8 | |
parent | f775f1f24c743505bd35da09958fcb10300b4069 (diff) | |
parent | 316b1a9df9852cc6d5e728cc93a1b76365b0b766 (diff) |
Auto merge of #646 - fitzgen:stylo-stuff, r=emilio
Also resolve blacklisted instantiation's args through refs and aliases
r? @emilio
-rw-r--r-- | src/ir/named.rs | 9 | ||||
-rw-r--r-- | tests/expectations/tests/issue-645-cannot-find-type-T-in-this-scope.rs | 16 | ||||
-rw-r--r-- | tests/headers/issue-645-cannot-find-type-T-in-this-scope.hpp | 9 | ||||
-rwxr-xr-x | tests/test-one.sh | 11 |
4 files changed, 40 insertions, 5 deletions
diff --git a/src/ir/named.rs b/src/ir/named.rs index 84a63379..55f804ec 100644 --- a/src/ir/named.rs +++ b/src/ir/named.rs @@ -322,7 +322,14 @@ impl<'ctx, 'gen> UsedTemplateParameters<'ctx, 'gen> { let args = instantiation.template_arguments() .iter() - .filter_map(|a| a.as_named(self.ctx, &())); + .filter_map(|a| { + a.into_resolver() + .through_type_refs() + .through_type_aliases() + .resolve(self.ctx) + .as_named(self.ctx, &()) + }); + used_by_this_id.extend(args); } diff --git a/tests/expectations/tests/issue-645-cannot-find-type-T-in-this-scope.rs b/tests/expectations/tests/issue-645-cannot-find-type-T-in-this-scope.rs new file mode 100644 index 00000000..531bce67 --- /dev/null +++ b/tests/expectations/tests/issue-645-cannot-find-type-T-in-this-scope.rs @@ -0,0 +1,16 @@ +/* automatically generated by rust-bindgen */ + + +#![allow(non_snake_case)] + +#[derive(Clone, Copy, Debug)] pub struct RefPtr<T>(T); + +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct HasRefPtr<T> { + pub refptr_member: RefPtr<HasRefPtr_TypedefOfT<T>>, +} +pub type HasRefPtr_TypedefOfT<T> = T; +impl <T> Default for HasRefPtr<T> { + fn default() -> Self { unsafe { ::std::mem::zeroed() } } +} diff --git a/tests/headers/issue-645-cannot-find-type-T-in-this-scope.hpp b/tests/headers/issue-645-cannot-find-type-T-in-this-scope.hpp new file mode 100644 index 00000000..f817f34d --- /dev/null +++ b/tests/headers/issue-645-cannot-find-type-T-in-this-scope.hpp @@ -0,0 +1,9 @@ +// bindgen-flags: --blacklist-type RefPtr --raw-line "#[derive(Clone, Copy, Debug)] pub struct RefPtr<T>(T);" --whitelist-type "HasRefPtr" -- -std=c++14 + +template <class> class RefPtr {}; + +template <typename T> +class HasRefPtr { + typedef T TypedefOfT; + RefPtr<TypedefOfT> refptr_member; +}; diff --git a/tests/test-one.sh b/tests/test-one.sh index d1950eb9..c7f9b2ae 100755 --- a/tests/test-one.sh +++ b/tests/test-one.sh @@ -21,13 +21,16 @@ TEST=$(find ./tests/headers -type f -iname "*$1*" | head -n 1) BINDINGS=$(mktemp -t bindings_XXXXXX.rs) TEST_BINDINGS_BINARY=$(mktemp -t bindings.XXXXX) -./target/debug/bindgen \ - "$TEST" \ +FLAGS="$(grep "// bindgen-flags: " "$TEST")" +FLAGS="${FLAGS/\/\/ bindgen\-flags:/}" + +eval ./target/debug/bindgen \ + "\"$TEST\"" \ --emit-ir \ --emit-ir-graphviz ir.dot \ --emit-clang-ast \ - -o "$BINDINGS" \ - -- -std=c++14 + -o "\"$BINDINGS\"" \ + $FLAGS dot -Tpng ir.dot -o ir.png |