Skip to content

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

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

Closed
fitzgen opened this issue Jan 20, 2017 · 1 comment
Labels

Comments

@fitzgen
Copy link
Member

fitzgen commented Jan 20, 2017

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
@fitzgen fitzgen added the bug label Jan 20, 2017
@fitzgen
Copy link
Member Author

fitzgen commented Jan 20, 2017

Most likely bad tracing but I haven't dug in yet

fitzgen added a commit to fitzgen/rust-bindgen that referenced this issue Jan 20, 2017
fitzgen added a commit to fitzgen/rust-bindgen that referenced this issue Jan 23, 2017
bors-servo pushed a commit that referenced this issue Jan 23, 2017
Trace methods in CompInfo's TypeCollector impl

Fixes #410

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

No branches or pull requests

1 participant