Skip to content

Commit 8f3c575

Browse files
author
bors-servo
authored
Auto merge of rust-lang#1030 - emilio:repr, r=fitzgen
codegen: Avoid generating wrong type for enums with unknown representation Fixes rust-lang#1025
2 parents f5b6e00 + 39765b8 commit 8f3c575

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

src/codegen/mod.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -2426,7 +2426,10 @@ impl CodeGenerator for Enum {
24262426
let repr =
24272427
self.repr()
24282428
.and_then(|repr| repr.try_to_rust_ty_or_opaque(ctx, &()).ok())
2429-
.unwrap_or_else(|| helpers::ast_ty::raw_type(ctx, repr_name));
2429+
.unwrap_or_else(|| {
2430+
let repr_name = ctx.rust_ident_raw(repr_name);
2431+
quote! { #repr_name }
2432+
});
24302433

24312434
let mut builder = EnumBuilder::new(
24322435
&name,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/* automatically generated by rust-bindgen */
2+
3+
4+
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
5+
6+
7+
#[repr(C)]
8+
#[derive(Debug, Default, Copy, Clone)]
9+
pub struct a {
10+
pub _address: u8,
11+
}
12+
pub type a__bindgen_ty_1 = i32;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2+
template <typename> class a {
3+
enum {};
4+
};

0 commit comments

Comments
 (0)