diff --git a/libc-test/test/style/mod.rs b/libc-test/test/style/mod.rs index 17691d6007d00..efab03eb26576 100644 --- a/libc-test/test/style/mod.rs +++ b/libc-test/test/style/mod.rs @@ -30,6 +30,7 @@ pub struct StyleChecker { errors: Vec, /// Path of the currently active file path: PathBuf, + in_impl: bool, } #[derive(Default, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)] @@ -121,7 +122,7 @@ impl StyleChecker { } fn set_state(&mut self, new_state: State, span: Span) { - if self.state > new_state { + if self.state > new_state && !self.in_impl { self.error_with_help( "incorrect module layout".to_string(), span, @@ -160,8 +161,10 @@ impl StyleChecker { // (self.on_err)(line, "multiple s! macros in one module"); // } - self.state = new_state; - self.state_span = Some(span); + if self.state != new_state { + self.state = new_state; + self.state_span = Some(span); + } } /// Visit the items inside the [ExprCfgIf], restoring the state after @@ -212,7 +215,6 @@ impl<'ast> Visit<'ast> for StyleChecker { let meta_str = meta_list.tokens.to_string(); if meta_list.path.is_ident("cfg") && !(meta_str.contains("target_endian") || meta_str.contains("target_arch")) - && self.state != State::Structs { self.error_with_help( "#[cfg] over cfg_if!".to_string(), @@ -256,6 +258,19 @@ impl<'ast> Visit<'ast> for StyleChecker { visit::visit_item_const(self, item_const); } + fn visit_item_impl(&mut self, item_impl: &'ast syn::ItemImpl) { + self.in_impl = true; + visit::visit_item_impl(self, item_impl); + self.in_impl = false; + } + + fn visit_item_struct(&mut self, item_struct: &'ast syn::ItemStruct) { + let span = item_struct.span(); + self.set_state(State::Structs, span); + + visit::visit_item_struct(self, item_struct); + } + fn visit_item_type(&mut self, item_type: &'ast syn::ItemType) { let span = item_type.span(); self.set_state(State::Typedefs, span); diff --git a/src/teeos/mod.rs b/src/teeos/mod.rs index b055d2aca8c7e..1ec2706cfdf76 100644 --- a/src/teeos/mod.rs +++ b/src/teeos/mod.rs @@ -51,9 +51,6 @@ pub type c_long = i64; pub type c_ulong = u64; -#[repr(align(16))] -pub struct _CLongDouble(pub u128); - // long double in C means A float point value, which has 128bit length. // but some bit maybe not used, so the real length of long double could be 80(x86) or 128(power pc/IEEE) // this is different from f128(not stable and not included default) in Rust, so we use u128 for FFI(Rust to C). @@ -88,6 +85,9 @@ pub type wctype_t = c_ulong; pub type cmpfunc = extern "C" fn(x: *const c_void, y: *const c_void) -> c_int; +#[repr(align(16))] +pub struct _CLongDouble(pub u128); + #[repr(align(8))] #[repr(C)] pub struct pthread_cond_t {