Skip to content

Commit

Permalink
treewide: allow std in tests
Browse files Browse the repository at this point in the history
This allows to use `dbg!` for example. Having this is beneficial in all no_std
crates. There are no disadvantages or negative implications.
  • Loading branch information
phip1611 committed Oct 6, 2024
1 parent 5fce46d commit 74c981b
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
5 changes: 5 additions & 0 deletions uefi-raw/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@
unused
)]

// Useful for convenience in tests, such as `dbg!`
#[cfg_attr(test, macro_use)]
#[cfg(test)]
extern crate std;

#[macro_use]
mod enums;

Expand Down
7 changes: 6 additions & 1 deletion uefi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
//!
//! Status::SUCCESS
//! }
//! # extern crate std;
//! # extern crate std; // For panic handler
//! ```
//!
//! Please find more info in our [Rust UEFI Book].
Expand Down Expand Up @@ -235,6 +235,11 @@ extern crate self as uefi;
#[macro_use]
extern crate uefi_raw;

// Useful for convenience in tests, such as `dbg!`
#[cfg_attr(test, macro_use)]
#[cfg(test)]
extern crate std;

#[macro_use]
pub mod data_types;
pub mod allocator;
Expand Down
8 changes: 7 additions & 1 deletion xtask/src/check_raw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,13 @@ fn check_item(item: &Item, src: &Path) -> Result<(), Error> {
// Allow.
}
item => {
return Err(Error::new(ErrorKind::ForbiddenItemKind, src, item));
let allowed_exception = match item {
Item::ExternCrate(x) => x.ident == "std",
_ => false,
};
if !allowed_exception {
return Err(Error::new(ErrorKind::ForbiddenItemKind, src, item));
}
}
}

Expand Down

0 comments on commit 74c981b

Please sign in to comment.