Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inner types are not qualified by namespace so may conflict #2056

Open
adetaylor opened this issue May 25, 2021 · 3 comments
Open

Inner types are not qualified by namespace so may conflict #2056

adetaylor opened this issue May 25, 2021 · 3 comments

Comments

@adetaylor
Copy link
Contributor

Input C/C++ Header

template <typename b> class c {
public:
  using iterator = b;
};
namespace e {
class d;
class f {
  typedef c<d>::iterator iterator;
};
} // namespace e
namespace g {
class i;
class h {
  typedef c<i>::iterator iterator;
};
} // namespace g

Bindgen Invocation

$ ~/bindgen/target/release/bindgen  anon-doubled.h   "--allowlist-type" e::f "--allowlist-type"  g::h "--enable-cxx-namespaces"  "--" "-x" "c++" "-std=c++14"

Actual Results

/* automatically generated by rust-bindgen 0.58.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 e {
        #[allow(unused_imports)]
        use self::super::super::root;
        #[repr(C)]
        pub struct d {
            _unused: [u8; 0],
        }
        #[repr(C)]
        pub struct f {
            pub _address: u8,
        }
        pub type f_iterator = root::iterator;
    }
    pub mod g {
        #[allow(unused_imports)]
        use self::super::super::root;
        #[repr(C)]
        pub struct i {
            _unused: [u8; 0],
        }
        #[repr(C)]
        pub struct h {
            pub _address: u8,
        }
        pub type h_iterator = root::iterator;
    }
    pub type iterator = root::e::d;
    pub type iterator = root::g::i;
}

(layout tests and derives omitted for clarity)

error[E0428]: the name `iterator` is defined multiple times
  --> src/lib.rs:34:5
   |
33 |     pub type iterator = root::e::d;
   |     ------------------------------- previous definition of the type `iterator` here
34 |     pub type iterator = root::g::i;
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `iterator` redefined here
   |
   = note: `iterator` must be defined only once in the type namespace of this module

error: aborting due to previous error

For more information about this error, try `rustc --explain E0428`.

Expected Results

Two definitions of iterator should not be emitted in the root namespace.

@adetaylor
Copy link
Contributor Author

(bindgen 0.58.1, revision b60339e)

@adetaylor
Copy link
Contributor Author

This might be fixed by #1975. I'll try, next time I get a chance to look at this.

@adetaylor
Copy link
Contributor Author

Nope - #1975 doesn't fix this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant