Skip to content

Typedef type in whitelisted function's argument not in generated bindings, compilation failure #410

@fitzgen

Description

@fitzgen

Input:

namespace JS {
class Value;
}
typedef enum {} JSWhyMagic;
namespace JS {
class Value {
public:
  void a(JSWhyMagic);
};
}

Output with --enable-cxx-namespaces and --whitelist-type 'JS::Value':

/* automatically generated by rust-bindgen */

#![feature(untagged_unions)]

pub mod root {
    #[allow(unused_imports)]
    use self::super::root;
    pub mod JS {
        #[allow(unused_imports)]
        use self::super::super::root;
        #[repr(C)]
        #[derive(Debug, Copy)]
        pub struct Value {
            pub _address: u8,
        }
        #[test]
        fn bindgen_test_layout_Value() {
            assert_eq!(::std::mem::size_of::<Value>() , 1usize);
            assert_eq!(::std::mem::align_of::<Value>() , 1usize);
        }
        extern "C" {
            #[link_name = "_ZN2JS5Value1aE10JSWhyMagic"]
            pub fn Value_a(this: *mut root::JS::Value,
                           arg1: root::JS::JSWhyMagic);
        }
        impl Clone for Value {
            fn clone(&self) -> Self { *self }
        }
        impl Value {
            #[inline]
            pub unsafe fn a(&mut self, arg1: root::JS::JSWhyMagic) {
                Value_a(&mut *self, arg1)
            }
        }
    }
}

Compilation of output fails with:

$ rustc --crate-type lib ./js.rs
error[E0412]: type name `root::JS::JSWhyMagic` is undefined or not in scope
  --> ./js.rs:24:34
   |
24 |                            arg1: root::JS::JSWhyMagic);
   |                                  ^^^^^^^^^^^^^^^^^^^^ undefined or not in scope
   |
   = help: no candidates by the name of `JSWhyMagic` found in your project; maybe you misspelled the name or forgot to import an external crate?

error[E0412]: type name `root::JS::JSWhyMagic` is undefined or not in scope
  --> ./js.rs:31:46
   |
31 |             pub unsafe fn a(&mut self, arg1: root::JS::JSWhyMagic) {
   |                                              ^^^^^^^^^^^^^^^^^^^^ undefined or not in scope
   |
   = help: no candidates by the name of `JSWhyMagic` found in your project; maybe you misspelled the name or forgot to import an external crate?

error: aborting due to 2 previous errors

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions