-
Notifications
You must be signed in to change notification settings - Fork 757
Closed
Description
rustfmt returns a exit code of 3. In #1042, it looks like it will treat that as a warning. However, this code will not compile after that. ctaggart/octh#27
Input C/C++ Header
template <typename> class a;
template <typename> struct b;
template <typename c, typename = a<b<c>>> class map {};
class octave_fields {
class : map<int> {};
};
Bindgen Invocation
#!/usr/bin/env bash
#set -u
export RUST_BACKTRACE=1
clang-3.9 --std=c++11 -c __bindgen.ii
~/rust-bindgen/target/release/bindgen \
--output __bindgen.rs \
--enable-cxx-namespaces \
--whitelist-type octave.* \
--whitelist-function octave.* \
--use-core \
--raw-line "extern crate core;" \
__bindgen.ii \
-- -v -x c++ -std=c++11 \
2>/dev/null
rc=$?; if [[ $rc != 0 ]]; then exit $rc; fi
rustfmt __bindgen.rs 2>/dev/null
rustc --crate-type=lib __bindgen.rs 2>/dev/null
# return success if there is an error code is detected
rc=$?; if [[ $rc != 0 ]]; then exit 0; else exit 1; fi
# time creduce ./bindgen-bug.sh __bindgen.ii
Actual Results
Creates this which compiles:
/* automatically generated by rust-bindgen */
extern crate core;
# [ allow ( non_snake_case , non_camel_case_types , non_upper_case_globals ) ] pub mod root { # [ allow ( unused_imports ) ] use self :: super :: root ; # [ repr ( C ) ] # [ derive ( Debug , Copy , Clone ) ] pub struct c { pub _address : u8 , } # [ repr ( C ) ] # [ derive ( Copy ) ] pub struct e { pub __bindgen_anon_1 : root :: e__bindgen_ty_1 , } # [ repr ( C ) ] # [ derive ( Copy ) ] pub union e__bindgen_ty_1 { pub d : [ :: std :: os :: raw :: c_char ; 4usize ] , _bindgen_union_align : [ u8 ; 4usize ] , } # [ test ] fn bindgen_test_layout_e__bindgen_ty_1 ( ) { assert_eq ! ( :: core :: mem :: size_of :: < e__bindgen_ty_1 > ( ) , 4usize , concat ! ( "Size of: " , stringify ! ( e__bindgen_ty_1 ) ) ) ; assert_eq ! ( :: core :: mem :: align_of :: < e__bindgen_ty_1 > ( ) , 1usize , concat ! ( "Alignment of " , stringify ! ( e__bindgen_ty_1 ) ) ) ; assert_eq ! ( unsafe { & ( * ( 0 as * const e__bindgen_ty_1 ) ) . d as * const _ as usize } , 0usize , concat ! ( "Alignment of field: " , stringify ! ( e__bindgen_ty_1 ) , "::" , stringify ! ( d ) ) ) ; } impl Clone for e__bindgen_ty_1 { fn clone ( & self ) -> Self { * self } } # [ test ] fn bindgen_test_layout_e ( ) { assert_eq ! ( :: core :: mem :: size_of :: < e > ( ) , 4usize , concat ! ( "Size of: " , stringify ! ( e ) ) ) ; assert_eq ! ( :: core :: mem :: align_of :: < e > ( ) , 1usize , concat ! ( "Alignment of " , stringify ! ( e ) ) ) ; } impl Clone for e { fn clone ( & self ) -> Self { * self } } # [ repr ( C ) ] # [ derive ( Copy , Clone ) ] pub struct B { pub f : root :: e , } # [ repr ( C ) ] # [ derive ( Copy , Clone ) ] pub struct g { pub h : root :: B , } # [ repr ( C ) ] # [ derive ( Copy , Clone ) ] pub struct a { pub _base : root :: g , } # [ repr ( C ) ] # [ derive ( Debug , Copy , Clone ) ] pub struct i { pub _address : u8 , } # [ repr ( C ) ] # [ derive ( Copy ) ] pub struct octave_fields { pub __bindgen_anon_1 : root :: octave_fields__bindgen_ty_1 , } # [ repr ( C ) ] # [ derive ( Copy ) ] pub struct octave_fields__bindgen_ty_1 { pub _address : u8 , } # [ test ] fn bindgen_test_layout_octave_fields__bindgen_ty_1 ( ) { assert_eq ! ( :: core :: mem :: size_of :: < octave_fields__bindgen_ty_1 > ( ) , 1usize , concat ! ( "Size of: " , stringify ! ( octave_fields__bindgen_ty_1 ) ) ) ; assert_eq ! ( :: core :: mem :: align_of :: < octave_fields__bindgen_ty_1 > ( ) , 1usize , concat ! ( "Alignment of " , stringify ! ( octave_fields__bindgen_ty_1 ) ) ) ; } impl Clone for octave_fields__bindgen_ty_1 { fn clone ( & self ) -> Self { * self } } # [ test ] fn bindgen_test_layout_octave_fields ( ) { assert_eq ! ( :: core :: mem :: size_of :: < octave_fields > ( ) , 1usize , concat ! ( "Size of: " , stringify ! ( octave_fields ) ) ) ; assert_eq ! ( :: core :: mem :: align_of :: < octave_fields > ( ) , 1usize , concat ! ( "Alignment of " , stringify ! ( octave_fields ) ) ) ; } impl Clone for octave_fields { fn clone ( & self ) -> Self { * self } } # [ test ] fn __bindgen_test_layout_i_open0_c_open1_char_a_open2_char_close2_close1_close0_instantiation ( ) { assert_eq ! ( :: core :: mem :: size_of :: < root :: i > ( ) , 1usize , concat ! ( "Size of template specialization: " , stringify ! ( root :: i ) ) ) ; assert_eq ! ( :: core :: mem :: align_of :: < root :: i > ( ) , 1usize , concat ! ( "Alignment of template specialization: " , stringify ! ( root :: i ) ) ) ; } }
Run rustfmt on it returns an exit code of 3:
$ rustfmt __bindgen.rs
Rustfmt failed at /home/cameron/octh/__bindgen.rs:132: line exceeded maximum length (maximum: 100, found: 109) (sorry)
$ echo $?
3
And now it no longer compiles:
$ rustc --crate-type=lib __bindgen.rs
error: incorrect close delimiter: `]`
--> __bindgen.rs:20:29
|
20 | #[derive(Copy)]; 4usize ] , } #[test]
| ^
|
note: unclosed delimiter
--> __bindgen.rs:6:14
|
6 | pub mod root {
| ^
error: unexpected close delimiter: `}`
--> __bindgen.rs:20:33
|
20 | #[derive(Copy)]; 4usize ] , } #[test]
|
/* automatically generated by rust-bindgen */
extern crate core;
#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)]
pub mod root {
#[allow(unused_imports)]
use self::super::root;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct c {
pub _address: u8,
}
#[repr(C)]
#[derive(Copy)]
pub struct e {
pub __bindgen_anon_1: root::e__bindgen_ty_1,
}
#[repr(C)]
#[derive(Copy)]; 4usize ] , } #[test]
fn bindgen_test_layout_e__bindgen_ty_1() {
assert_eq!(
::core::mem::size_of::<e__bindgen_ty_1>(),
4usize,
concat!("Size of: ", stringify!(e__bindgen_ty_1))
);
assert_eq!(
::core::mem::align_of::<e__bindgen_ty_1>(),
1usize,
concat!("Alignment of ", stringify!(e__bindgen_ty_1))
);
assert_eq!(
unsafe { &(*(0 as *const e__bindgen_ty_1)).d as *const _ as usize },
0usize,
concat!(
"Alignment of field: ",
stringify!(e__bindgen_ty_1),
"::",
stringify!(d)
)
);
}
impl Clone for e__bindgen_ty_1 {
fn clone(&self) -> Self {
*self
}
}
#[test]
fn bindgen_test_layout_e() {
assert_eq!(
::core::mem::size_of::<e>(),
4usize,
concat!("Size of: ", stringify!(e))
);
assert_eq!(
::core::mem::align_of::<e>(),
1usize,
concat!("Alignment of ", stringify!(e))
);
}
impl Clone for e {
fn clone(&self) -> Self {
*self
}
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct B {
pub f: root::e,
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct g {
pub h: root::B,
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct a {
pub _base: root::g,
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct i {
pub _address: u8,
}
#[repr(C)]
#[derive(Copy)]
pub struct octave_fields {
pub __bindgen_anon_1: root::octave_fields__bindgen_ty_1,
}
#[repr(C)]
#[derive(Copy)]
pub struct octave_fields__bindgen_ty_1 {
pub _address: u8,
}
#[test]
fn bindgen_test_layout_octave_fields__bindgen_ty_1() {
assert_eq!(
::core::mem::size_of::<octave_fields__bindgen_ty_1>(),
1usize,
concat!("Size of: ", stringify!(octave_fields__bindgen_ty_1))
);
assert_eq!(
::core::mem::align_of::<octave_fields__bindgen_ty_1>(),
1usize,
concat!("Alignment of ", stringify!(octave_fields__bindgen_ty_1))
);
}
impl Clone for octave_fields__bindgen_ty_1 {
fn clone(&self) -> Self {
*self
}
}
#[test]
fn bindgen_test_layout_octave_fields() {
assert_eq!(
::core::mem::size_of::<octave_fields>(),
1usize,
concat!("Size of: ", stringify!(octave_fields))
);
assert_eq!(
::core::mem::align_of::<octave_fields>(),
1usize,
concat!("Alignment of ", stringify!(octave_fields))
);
}
impl Clone for octave_fields {
fn clone(&self) -> Self {
*self
}
}
#[test]fn __bindgen_test_layout_i_open0_c_open1_char_a_open2_char_close2_close1_close0_instantiation ( ){
assert_eq!(
::core::mem::size_of::<root::i>(),
1usize,
concat!("Size of template specialization: ", stringify!(root::i))
);
assert_eq!(
::core::mem::align_of::<root::i>(),
1usize,
concat!(
"Alignment of template specialization: ",
stringify!(root::i)
)
);
}
}
Expected Results
bindgen errors when rustfmt errors. And may be we simple expect rustfmt to not error in this case and log a bug there.
Metadata
Metadata
Assignees
Labels
No labels