Skip to content

//! comment makes compiling the output file fail. #749

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
kkimdev opened this issue Jun 14, 2017 · 2 comments
Closed

//! comment makes compiling the output file fail. #749

kkimdev opened this issue Jun 14, 2017 · 2 comments

Comments

@kkimdev
Copy link

kkimdev commented Jun 14, 2017

Input C/C++ Header

float x;
//!
typedef float Float;

Real world example: https://github.com/g-truc/glm/blob/a9a832e187b6a33638b8e769887a35e39638dbeb/glm/detail/type_vec.hpp#L458

Bindgen Invocation

$ bindgen input.h

Actual Results

/* automatically generated by rust-bindgen */

extern "C" {
    #[link_name = "x"]
    pub static mut x: f32;
}
//!
pub type Float = f32;
$ rustc input.rs 
error: expected outer doc comment
 --> input.rs:7:1
  |
7 | //!
  | ^^^
  |
  = note: inner doc comments like this (starting with `//!` or `/*!`) can only appear before items

error: aborting due to previous error(s)

Expected Results

I'm not familiar with inner doc comment, and I don't know if it's rustc or bindgen issue, and what to expect here.

RUST_LOG=bindgen Output

``` INFO:bindgen: Clang Version: clang version 4.0.0 (https://github.com/kripken/emscripten-fastcomp-clang/ ac7f972a03d729dddd614882b634da3884962263) (https://github.com/kripken/emscripten-fastcomp/ 042f4a81b1d95123ef6798ffc1457da3217d44bc) (emscripten 1.37.12 : 1.37.12) WARN:bindgen: Using clang (4, 0), expected (3, 9) DEBUG:bindgen::ir::context: BindgenContext::add_item(Item { id: ItemId(0), local_id: Cell { value: None }, next_child_local_id: Cell { value: 1 }, canonical_name_cache: RefCell { value: None }, comment: None, annotations: Annotations { opaque: false, hide: false, use_instead_of: None, disallow_copy: false, private_fields: None, accessor_kind: None, constify_enum_variant: false }, parent_id: ItemId(0), kind: Module(Module { name: Some("root"), kind: Normal, children_ids: [] }), detect_derive_debug_cycle: Cell { value: false }, detect_derive_copy_cycle: Cell { value: false } }, declaration: None, loc: None DEBUG:bindgen::ir::item: Item::from_ty_with_id: ItemId(1) ty = Type(float, kind: Float, cconv: 100, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None)), location = Cursor(x kind: VarDecl, loc: input.h:1:7, usr: Some("c:@x")) DEBUG:bindgen::ir::context: builtin_or_resolved_ty: Type(float, kind: Float, cconv: 100, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None)), Some(Cursor(x kind: VarDecl, loc: input.h:1:7, usr: Some("c:@x"))), None DEBUG:bindgen::ir::context: Not resolved, maybe builtin? DEBUG:bindgen::ir::context: add_builtin_item: item = Item { id: ItemId(2), local_id: Cell { value: None }, next_child_local_id: Cell { value: 1 }, canonical_name_cache: RefCell { value: None }, comment: None, annotations: Annotations { opaque: false, hide: false, use_instead_of: None, disallow_copy: false, private_fields: None, accessor_kind: None, constify_enum_variant: false }, parent_id: ItemId(0), kind: Type(Type { name: Some("float"), layout: Some(Layout { size: 4, align: 4, packed: false }), kind: Float(Float), is_const: false, detect_has_vtable_cycle: Cell { value: false } }), detect_derive_debug_cycle: Cell { value: false }, detect_derive_copy_cycle: Cell { value: false } } DEBUG:bindgen::ir::context: BindgenContext::add_item(Item { id: ItemId(3), local_id: Cell { value: None }, next_child_local_id: Cell { value: 1 }, canonical_name_cache: RefCell { value: None }, comment: None, annotations: Annotations { opaque: false, hide: false, use_instead_of: None, disallow_copy: false, private_fields: None, accessor_kind: None, constify_enum_variant: false }, parent_id: ItemId(0), kind: Var(Var { name: "x", mangled_name: Some("x"), ty: ItemId(2), val: None, is_const: false }), detect_derive_debug_cycle: Cell { value: false }, detect_derive_copy_cycle: Cell { value: false } }, declaration: Some(Cursor(x kind: VarDecl, loc: input.h:1:7, usr: Some("c:@x"))), loc: Some(Cursor(x kind: VarDecl, loc: input.h:1:7, usr: Some("c:@x"))) DEBUG:bindgen::ir::item: Item::from_ty_with_id: ItemId(4) ty = Type(Float, kind: Typedef, cconv: 100, decl: Cursor(Float kind: TypedefDecl, loc: input.h:3:15, usr: Some("c:input.h@T@Float")), canon: Cursor(Float kind: TypedefDecl, loc: input.h:3:15, usr: Some("c:input.h@T@Float"))), location = Cursor(Float kind: TypedefDecl, loc: input.h:3:15, usr: Some("c:input.h@T@Float")) DEBUG:bindgen::ir::context: builtin_or_resolved_ty: Type(Float, kind: Typedef, cconv: 100, decl: Cursor(Float kind: TypedefDecl, loc: input.h:3:15, usr: Some("c:input.h@T@Float")), canon: Cursor(Float kind: TypedefDecl, loc: input.h:3:15, usr: Some("c:input.h@T@Float"))), Some(Cursor(Float kind: TypedefDecl, loc: input.h:3:15, usr: Some("c:input.h@T@Float"))), None DEBUG:bindgen::ir::context: Not resolved, maybe builtin? DEBUG:bindgen::ir::context: builtin_or_resolved_ty: Type(Float, kind: Typedef, cconv: 100, decl: Cursor(Float kind: TypedefDecl, loc: input.h:3:15, usr: Some("c:input.h@T@Float")), canon: Cursor(Float kind: TypedefDecl, loc: input.h:3:15, usr: Some("c:input.h@T@Float"))), Some(Cursor(Float kind: TypedefDecl, loc: input.h:3:15, usr: Some("c:input.h@T@Float"))), None DEBUG:bindgen::ir::context: Not resolved, maybe builtin? DEBUG:bindgen::ir::ty: from_clang_ty: ItemId(4), ty: Type(Float, kind: Typedef, cconv: 100, decl: Cursor(Float kind: TypedefDecl, loc: input.h:3:15, usr: Some("c:input.h@T@Float")), canon: Cursor(Float kind: TypedefDecl, loc: input.h:3:15, usr: Some("c:input.h@T@Float"))), loc: Cursor(Float kind: TypedefDecl, loc: input.h:3:15, usr: Some("c:input.h@T@Float")) DEBUG:bindgen::ir::ty: currently_parsed_types: [PartialType { decl: Cursor(Float kind: TypedefDecl, loc: input.h:3:15, usr: Some("c:input.h@T@Float")), id: ItemId(4) }] DEBUG:bindgen::ir::item: from_ty_or_ref_with_id: ItemId(5) Type(float, kind: Float, cconv: 100, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None)), Cursor(Float kind: TypedefDecl, loc: input.h:3:15, usr: Some("c:input.h@T@Float")), None DEBUG:bindgen::ir::context: builtin_or_resolved_ty: Type(float, kind: Float, cconv: 100, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None)), Some(Cursor(Float kind: TypedefDecl, loc: input.h:3:15, usr: Some("c:input.h@T@Float"))), None DEBUG:bindgen::ir::context: Not resolved, maybe builtin? DEBUG:bindgen::ir::context: add_builtin_item: item = Item { id: ItemId(6), local_id: Cell { value: None }, next_child_local_id: Cell { value: 1 }, canonical_name_cache: RefCell { value: None }, comment: None, annotations: Annotations { opaque: false, hide: false, use_instead_of: None, disallow_copy: false, private_fields: None, accessor_kind: None, constify_enum_variant: false }, parent_id: ItemId(0), kind: Type(Type { name: Some("float"), layout: Some(Layout { size: 4, align: 4, packed: false }), kind: Float(Float), is_const: false, detect_has_vtable_cycle: Cell { value: false } }), detect_derive_debug_cycle: Cell { value: false }, detect_derive_copy_cycle: Cell { value: false } } DEBUG:bindgen::ir::item: ItemId(6) already resolved: Cursor(Float kind: TypedefDecl, loc: input.h:3:15, usr: Some("c:input.h@T@Float")) DEBUG:bindgen::ir::context: BindgenContext::add_item(Item { id: ItemId(4), local_id: Cell { value: None }, next_child_local_id: Cell { value: 1 }, canonical_name_cache: RefCell { value: None }, comment: Some("//!"), annotations: Annotations { opaque: false, hide: false, use_instead_of: None, disallow_copy: false, private_fields: None, accessor_kind: None, constify_enum_variant: false }, parent_id: ItemId(0), kind: Type(Type { name: Some("Float"), layout: Some(Layout { size: 4, align: 4, packed: false }), kind: Alias(ItemId(6)), is_const: false, detect_has_vtable_cycle: Cell { value: false } }), detect_derive_debug_cycle: Cell { value: false }, detect_derive_copy_cycle: Cell { value: false } }, declaration: Some(Cursor(Float kind: TypedefDecl, loc: input.h:3:15, usr: Some("c:input.h@T@Float"))), loc: Some(Cursor(Float kind: TypedefDecl, loc: input.h:3:15, usr: Some("c:input.h@T@Float"))) DEBUG:bindgen::ir::context: No replacements to process TRACE:bindgen::ir::named: constrain ItemId(6) TRACE:bindgen::ir::named: initially, used set is {} TRACE:bindgen::ir::named: other item: join with successors' usage TRACE:bindgen::ir::named: finally, used set is {} TRACE:bindgen::ir::named: constrain ItemId(6) TRACE:bindgen::ir::named: initially, used set is {} TRACE:bindgen::ir::named: other item: join with successors' usage TRACE:bindgen::ir::named: finally, used set is {} TRACE:bindgen::ir::named: constrain ItemId(4) TRACE:bindgen::ir::named: initially, used set is {} TRACE:bindgen::ir::named: other item: join with successors' usage TRACE:bindgen::ir::named: union with ItemId(6)'s usage: [] TRACE:bindgen::ir::named: finally, used set is {} TRACE:bindgen::ir::named: constrain ItemId(2) TRACE:bindgen::ir::named: initially, used set is {} TRACE:bindgen::ir::named: other item: join with successors' usage TRACE:bindgen::ir::named: finally, used set is {} TRACE:bindgen::ir::named: constrain ItemId(3) TRACE:bindgen::ir::named: initially, used set is {} TRACE:bindgen::ir::named: other item: join with successors' usage TRACE:bindgen::ir::named: union with ItemId(2)'s usage: [] TRACE:bindgen::ir::named: finally, used set is {} TRACE:bindgen::ir::named: constrain ItemId(2) TRACE:bindgen::ir::named: initially, used set is {} TRACE:bindgen::ir::named: other item: join with successors' usage TRACE:bindgen::ir::named: finally, used set is {} TRACE:bindgen::ir::named: constrain ItemId(0) TRACE:bindgen::ir::named: initially, used set is {} TRACE:bindgen::ir::named: other item: join with successors' usage TRACE:bindgen::ir::named: finally, used set is {} DEBUG:bindgen::codegen: codegen: BindgenOptions { hidden_types: RegexSet { items: [], set: Some(RegexSet([])) }, opaque_types: RegexSet { items: [], set: Some(RegexSet([])) }, whitelisted_types: RegexSet { items: [], set: Some(RegexSet([])) }, whitelisted_functions: RegexSet { items: [], set: Some(RegexSet([])) }, whitelisted_vars: RegexSet { items: [], set: Some(RegexSet([])) }, bitfield_enums: RegexSet { items: [], set: Some(RegexSet([])) }, constified_enums: RegexSet { items: [], set: Some(RegexSet([])) }, builtins: false, links: [], emit_ast: false, emit_ir: false, emit_ir_graphviz: None, enable_cxx_namespaces: false, disable_name_namespacing: false, layout_tests: true, derive_debug: true, derive_default: false, unstable_rust: true, use_core: false, ctypes_prefix: None, namespaced_constants: true, msvc_mangling: false, convert_floats: true, raw_lines: [], clang_args: ["-isystem", "/usr/lib/gcc/x86_64-linux-gnu/5.4.0/../../../../include/c++/5.4.0", "-isystem", "/usr/lib/gcc/x86_64-linux-gnu/5.4.0/../../../../include/x86_64-linux-gnu/c++/5.4.0", "-isystem", "/usr/lib/gcc/x86_64-linux-gnu/5.4.0/../../../../include/c++/5.4.0/backward", "-isystem", "/usr/local/include", "-isystem", "/home/kkim/fips-projects/fips-sdks/linux/emsdk-portable/clang/fastcomp/build_incoming_64/bin/../lib/clang/4.0.0/include", "-isystem", "/usr/include/x86_64-linux-gnu", "-isystem", "/usr/include", "input.h"], input_header: Some("input.h"), input_unsaved_files: [], dummy_uses: None, parse_callbacks: None, codegen_config: CodegenConfig { functions: true, types: true, vars: true, methods: true, constructors: true, destructors: true }, conservative_inline_namespaces: false, generate_comments: true, generate_inline_functions: false, whitelist_recursively: true, objc_extern_crate: false, enable_mangling: true, prepend_enum_name: true } DEBUG:bindgen::codegen: ::codegen: self = Item { id: ItemId(0), local_id: Cell { value: None }, next_child_local_id: Cell { value: 1 }, canonical_name_cache: RefCell { value: None }, comment: None, annotations: Annotations { opaque: false, hide: false, use_instead_of: None, disallow_copy: false, private_fields: None, accessor_kind: None, constify_enum_variant: false }, parent_id: ItemId(0), kind: Module(Module { name: Some("root"), kind: Normal, children_ids: [ItemId(3), ItemId(4)] }), detect_derive_debug_cycle: Cell { value: false }, detect_derive_copy_cycle: Cell { value: false } } DEBUG:bindgen::codegen: ::codegen: item = Item { id: ItemId(0), local_id: Cell { value: None }, next_child_local_id: Cell { value: 1 }, canonical_name_cache: RefCell { value: None }, comment: None, annotations: Annotations { opaque: false, hide: false, use_instead_of: None, disallow_copy: false, private_fields: None, accessor_kind: None, constify_enum_variant: false }, parent_id: ItemId(0), kind: Module(Module { name: Some("root"), kind: Normal, children_ids: [ItemId(3), ItemId(4)] }), detect_derive_debug_cycle: Cell { value: false }, detect_derive_copy_cycle: Cell { value: false } } DEBUG:bindgen::codegen: ::codegen: self = Item { id: ItemId(3), local_id: Cell { value: None }, next_child_local_id: Cell { value: 1 }, canonical_name_cache: RefCell { value: None }, comment: None, annotations: Annotations { opaque: false, hide: false, use_instead_of: None, disallow_copy: false, private_fields: None, accessor_kind: None, constify_enum_variant: false }, parent_id: ItemId(0), kind: Var(Var { name: "x", mangled_name: Some("x"), ty: ItemId(2), val: None, is_const: false }), detect_derive_debug_cycle: Cell { value: false }, detect_derive_copy_cycle: Cell { value: false } } DEBUG:bindgen::codegen: ::codegen: item = Item { id: ItemId(3), local_id: Cell { value: None }, next_child_local_id: Cell { value: 1 }, canonical_name_cache: RefCell { value: None }, comment: None, annotations: Annotations { opaque: false, hide: false, use_instead_of: None, disallow_copy: false, private_fields: None, accessor_kind: None, constify_enum_variant: false }, parent_id: ItemId(0), kind: Var(Var { name: "x", mangled_name: Some("x"), ty: ItemId(2), val: None, is_const: false }), detect_derive_debug_cycle: Cell { value: false }, detect_derive_copy_cycle: Cell { value: false } } DEBUG:bindgen::codegen: ::codegen: self = Item { id: ItemId(4), local_id: Cell { value: None }, next_child_local_id: Cell { value: 1 }, canonical_name_cache: RefCell { value: None }, comment: Some("//!"), annotations: Annotations { opaque: false, hide: false, use_instead_of: None, disallow_copy: false, private_fields: None, accessor_kind: None, constify_enum_variant: false }, parent_id: ItemId(0), kind: Type(Type { name: Some("Float"), layout: Some(Layout { size: 4, align: 4, packed: false }), kind: Alias(ItemId(6)), is_const: false, detect_has_vtable_cycle: Cell { value: false } }), detect_derive_debug_cycle: Cell { value: false }, detect_derive_copy_cycle: Cell { value: false } } DEBUG:bindgen::codegen: ::codegen: item = Item { id: ItemId(4), local_id: Cell { value: None }, next_child_local_id: Cell { value: 1 }, canonical_name_cache: RefCell { value: None }, comment: Some("//!"), annotations: Annotations { opaque: false, hide: false, use_instead_of: None, disallow_copy: false, private_fields: None, accessor_kind: None, constify_enum_variant: false }, parent_id: ItemId(0), kind: Type(Type { name: Some("Float"), layout: Some(Layout { size: 4, align: 4, packed: false }), kind: Alias(ItemId(6)), is_const: false, detect_has_vtable_cycle: Cell { value: false } }), detect_derive_debug_cycle: Cell { value: false }, detect_derive_copy_cycle: Cell { value: false } } /* automatically generated by rust-bindgen */

extern "C" {
#[link_name = "x"]
pub static mut x: f32;
}
//!
pub type Float = f32;

</details>
@emilio
Copy link
Contributor

emilio commented Jun 14, 2017

Dupe of #426, see there for workaround. Thanks for the report though!

@emilio emilio closed this as completed Jun 14, 2017
@emilio
Copy link
Contributor

emilio commented Jun 14, 2017

(I should actually prioritise 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

2 participants