From 0630f467760671cdfa73c4f12422275280448312 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Sat, 28 Oct 2017 13:22:35 +0200 Subject: [PATCH] ir: References have no implicit template parameters. Fixes #1113. --- src/codegen/mod.rs | 2 +- .../tests/issue-1113-template-references.rs | 38 +++++++++++++++++++ .../issue-1113-template-references.hpp | 16 ++++++++ 3 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 tests/expectations/tests/issue-1113-template-references.rs create mode 100644 tests/headers/issue-1113-template-references.hpp diff --git a/src/codegen/mod.rs b/src/codegen/mod.rs index 6c1ed02fbb..53ed24ff08 100644 --- a/src/codegen/mod.rs +++ b/src/codegen/mod.rs @@ -268,6 +268,7 @@ impl AppendImplicitTemplateParams for quote::Tokens { TypeKind::Void | TypeKind::NullPtr | TypeKind::Pointer(..) | + TypeKind::Reference(..) | TypeKind::Int(..) | TypeKind::Float(..) | TypeKind::Complex(..) | @@ -280,7 +281,6 @@ impl AppendImplicitTemplateParams for quote::Tokens { TypeKind::ObjCId | TypeKind::ObjCSel | TypeKind::TemplateInstantiation(..) => return, - _ => {}, } diff --git a/tests/expectations/tests/issue-1113-template-references.rs b/tests/expectations/tests/issue-1113-template-references.rs new file mode 100644 index 0000000000..3430f27dd7 --- /dev/null +++ b/tests/expectations/tests/issue-1113-template-references.rs @@ -0,0 +1,38 @@ +/* automatically generated by rust-bindgen */ + + +#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] + + +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct Entry { + pub _base: K, + pub mData: V, + pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell>, + pub _phantom_1: ::std::marker::PhantomData<::std::cell::UnsafeCell>, +} +impl Default for Entry { + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone)] +pub struct nsBaseHashtable { + pub _address: u8, +} +pub type nsBaseHashtable_EntryType = Entry; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct nsBaseHashtable_EntryPtr { + pub mEntry: *mut nsBaseHashtable_EntryType, + pub mExistingEntry: bool, + pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell>, + pub _phantom_1: ::std::marker::PhantomData<::std::cell::UnsafeCell>, +} +impl Default for nsBaseHashtable_EntryPtr { + fn default() -> Self { + unsafe { ::std::mem::zeroed() } + } +} diff --git a/tests/headers/issue-1113-template-references.hpp b/tests/headers/issue-1113-template-references.hpp new file mode 100644 index 0000000000..46339c5dfe --- /dev/null +++ b/tests/headers/issue-1113-template-references.hpp @@ -0,0 +1,16 @@ +template +class Entry : public K +{ + V mData; +}; + +template +class nsBaseHashtable { + typedef Entry EntryType; + + struct EntryPtr { + private: + EntryType& mEntry; + bool mExistingEntry; + }; +};