Skip to content

Commit

Permalink
update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
rmehri01 committed Jan 9, 2025
1 parent 43ea433 commit e13e036
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 18 deletions.
13 changes: 0 additions & 13 deletions libc-test/test/check_style.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,6 @@
//! ```notrust
//! cargo test --test style
//! ```
//!
//! ## Guidelines
//!
//! The current style is:
//!
//! * Specific module layout:
//! 1. use directives
//! 2. typedefs
//! 3. structs
//! 4. constants
//! 5. f! { ... } functions
//! 6. extern functions
//! 7. modules + pub use
pub mod style;

Expand Down
32 changes: 27 additions & 5 deletions libc-test/test/style/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,24 @@
//! this library.
//!
//! This is split out so that the implementation itself can be tested
//! separately, see test/check_style.rs for how it's used.
//! separately, see test/check_style.rs for how it's used and
//! test/style_tests.rs for the implementation tests.
//!
//! ## Guidelines
//!
//! The current style is:
//!
//! * Specific module layout:
//! 1. use directives
//! 2. typedefs
//! 3. structs
//! 4. constants
//! 5. f! { ... } functions
//! 6. extern functions
//! 7. modules + pub use
//! * Use cfg_if! over #[cfg(...)]
//! * No manual deriving Copy/Clone
//! * Only one f! per module
use std::fs;
use std::ops::Deref;
Expand All @@ -20,16 +37,21 @@ pub type Result<T> = std::result::Result<T, Error>;

#[derive(Default)]
pub struct StyleChecker {
/// The state the style checker is in, used to enforce the module layout.
state: State,
/// Span of the first item encountered in this state
/// to use in help diagnostic text.
/// Span of the first item encountered in this state to use in help
/// diagnostic text.
state_span: Option<Span>,
// FIXME: see StyleChecker::set_state
_s_macros: usize,
/// Span of the first f! macro seen, used to enforce only one f! macro
/// per module.
first_f_macro: Option<Span>,
/// The errors that the style checker has seen.
errors: Vec<FileError>,
/// Path of the currently active file
/// Path of the currently active file.
path: PathBuf,
/// Whether the style checker is currently in an `impl` block.
in_impl: bool,
}

Expand Down Expand Up @@ -204,7 +226,7 @@ impl<'ast> Visit<'ast> for StyleChecker {
&& !(meta_str.contains("target_endian") || meta_str.contains("target_arch"))
{
self.error(
"#[cfg] over cfg_if!".to_string(),
"cfg_if! over #[cfg]".to_string(),
span,
String::new(),
(
Expand Down

0 comments on commit e13e036

Please sign in to comment.