Skip to content

Replacement types possibly confuse used_template_params somehow #3161

@adetaylor

Description

@adetaylor

Reproduction:

C++:

/**
* <div rustbindgen="true" replaces="std::unique_ptr">
*/
template<typename T> class UniquePtr {
    T* ptr;
};

#include <memory>

template <typename at> class au {
std::unique_ptr<at> aw;
};
class bb;
using bc = au<bb>;

Command-line:
cargo run -- test.hpp --no-layout-tests --enable-cxx-namespaces --allowlist-type bc -- -std=c++14

Rust output:

/* automatically generated by rust-bindgen 0.71.1 */

#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)]
pub mod root {
    #[allow(unused_imports)]
    use self::super::root;
    pub mod std {
        #[allow(unused_imports)]
        use self::super::super::root;
        #[doc = " <div rustbindgen=\"true\" replaces=\"std::unique_ptr\">"]
        #[repr(C)]
        #[derive(Debug, Copy, Clone)]
        pub struct unique_ptr<T> {
            pub _phantom_0:
                ::std::marker::PhantomData<::std::cell::UnsafeCell<T>>,
            pub ptr: *mut T,
        }
    }
    #[repr(C)]
    #[derive(Debug, Copy, Clone)]
    pub struct au {
        pub aw: root::std::unique_ptr<T>,
    }
    #[repr(C)]
    #[derive(Debug, Copy, Clone)]
    pub struct bb {
        _unused: [u8; 0],
    }
    pub type bc = root::au;
}

Note this bit:

    pub struct au {
        pub aw: root::std::unique_ptr<T>,
    }

... we're depending on a template parameter which doesn't exist in the outer struct.

Bindgen version 20aa65a, today's HEAD.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions