Skip to content

Commit

Permalink
make std feature conflict with hashbrown in compile error
Browse files Browse the repository at this point in the history
  • Loading branch information
CrazyboyQCD committed Feb 13, 2025
1 parent 4c45a01 commit c5b70f0
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
11 changes: 7 additions & 4 deletions src/allocator/free_list_allocator/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,15 @@ use alloc::{
string::{String, ToString},
vec::Vec,
};
#[cfg(all(feature = "std", not(feature = "hashbrown")))]
use std::collections::{HashMap, HashSet};

#[cfg(feature = "std")]
use std::{backtrace::Backtrace, sync::Arc};
use std::{
backtrace::Backtrace,
collections::{HashMap, HashSet},
sync::Arc,
};

#[cfg(all(not(feature = "std"), feature = "hashbrown"))]
#[cfg(feature = "hashbrown")]
use hashbrown::{HashMap, HashSet};
use log::{log, Level};

Expand Down
2 changes: 2 additions & 0 deletions src/allocator/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ use crate::result::*;
pub(crate) mod dedicated_block_allocator;
pub(crate) use dedicated_block_allocator::DedicatedBlockAllocator;

#[cfg(any(feature = "std", feature = "hashbrown"))]
pub(crate) mod free_list_allocator;
#[cfg(any(feature = "std", feature = "hashbrown"))]
pub(crate) use free_list_allocator::FreeListAllocator;

#[derive(PartialEq, Copy, Clone, Debug)]
Expand Down
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,8 @@
#[macro_use]
extern crate alloc;

#[cfg(all(not(feature = "std"), not(feature = "hashbrown")))]
compile_error!("\"hashbrown\" feature should be enabled in \"no_std\" environment.");
#[cfg(all(feature = "std", feature = "hashbrown"))]
compile_error!("\"hashbrown\" feature should not be enabled in \"std\" environment.");

#[cfg(all(not(feature = "std"), feature = "visualizer"))]
compile_error!("Cannot enable \"visualizer\" feature in \"no_std\" environment.");
Expand Down

0 comments on commit c5b70f0

Please sign in to comment.