-
Notifications
You must be signed in to change notification settings - Fork 60
Description
Bug Report: Invalid Type in Bindgen IR with foreign_class! Macro
Description
Hello, I'm encountering an issue with the bindgen tool when using the foreign_class! macro. The error message is as follows:
The issue seems to be related to the add_char method, which modifies the information field of the Paris struct by adding a character. When this method is included in the foreign_class! macro, bindgen generates a warning about an invalid type. This suggests that bindgen may have difficulty handling the char type or the mutable reference (&mut self) used in this method.
Code with Error
Here is the code that generates the error:
//Automatically generated by rifgen
use crate::jni_c_header::*;
struct Paris {
information: String,
}
impl Paris {
fn new(top: String) -> Paris {
Paris { information: top }
}
fn get_info(&self) -> &str {
&self.information
}
fn add_char(&mut self, c: char) {
self.information.push(c);
}
}
foreign_class!(
class Paris {
self_type Paris;
constructor Paris::new(top : String)->Paris;
fn Paris::get_info(& self)->&str; alias getInfo;
fn Paris::add_char(& mut self , c : char); alias addChar;
}
);
Error
[WARN bindgen::ir::ty] invalid type Type(, kind: Invalid, cconv: 100, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None))
Code without Error
The following code does not produce the error:
//Automatically generated by rifgen
use crate::jni_c_header::*;
struct Paris {
information: String,
}
impl Paris {
fn new(top: String) -> Paris {
Paris { information: top }
}
fn get_info(&self) -> &str {
&self.information
}
}
foreign_class!(
class Paris {
self_type Paris;
constructor Paris::new(top : String)->Paris;
fn Paris::get_info(& self)->&str; alias getInfo;
}
);
Expected Behavior
The bindgen tool should generate valid bindings without any warnings or errors.
Actual Behavior
The bindgen tool generates a warning about an invalid type.
I would appreciate any assistance in resolving this issue. If more information is needed, please let me know.