From 120318d6e652bb358ffeb683a6eeaa0673b6f5ea Mon Sep 17 00:00:00 2001 From: Junichi Uekawa Date: Thu, 10 Feb 2022 08:49:29 +0900 Subject: [PATCH] resources: remove unneeded export of AddressAllocator Nobody relies on this. BUG=None TEST=build Change-Id: I79e34103079a0e9660a0ff79db4a154125f04bfc Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3450016 Tested-by: kokoro Reviewed-by: Daniel Verkamp Commit-Queue: Junichi Uekawa --- resources/src/address_allocator.rs | 35 +++++++++++++++++++----------- resources/src/lib.rs | 1 - 2 files changed, 22 insertions(+), 14 deletions(-) diff --git a/resources/src/address_allocator.rs b/resources/src/address_allocator.rs index e41e9b795..0f79195ee 100644 --- a/resources/src/address_allocator.rs +++ b/resources/src/address_allocator.rs @@ -11,19 +11,6 @@ use crate::{Alloc, Error, Result}; /// Use `AddressAllocator` whenever an address range needs to be allocated to different users. /// Allocations must be uniquely tagged with an Alloc enum, which can be used for lookup. /// An human-readable tag String must also be provided for debugging / reference. -/// -/// # Examples -/// -/// ``` -/// // Anon is used for brevity. Don't manually instantiate Anon allocs! -/// # use resources::{Alloc, AddressAllocator}; -/// AddressAllocator::new(0x1000, 0x10000, Some(0x100), None).map(|mut pool| { -/// assert_eq!(pool.allocate(0x110, Alloc::Anon(0), "caps".to_string()), Ok(0x1000)); -/// assert_eq!(pool.allocate(0x100, Alloc::Anon(1), "cache".to_string()), Ok(0x1200)); -/// assert_eq!(pool.allocate(0x100, Alloc::Anon(2), "etc".to_string()), Ok(0x1300)); -/// assert_eq!(pool.get(&Alloc::Anon(1)), Some(&(0x1200, 0x100, "cache".to_string()))); -/// }); -/// ``` #[derive(Debug, Eq, PartialEq)] pub struct AddressAllocator { pool_base: u64, @@ -429,6 +416,28 @@ impl<'a> AddressAllocatorSet<'a> { mod tests { use super::*; + #[test] + fn example() { + // Anon is used for brevity. Don't manually instantiate Anon allocs! + let mut pool = AddressAllocator::new(0x1000, 0x10000, Some(0x100), None).unwrap(); + assert_eq!( + pool.allocate(0x110, Alloc::Anon(0), "caps".to_string()), + Ok(0x1000) + ); + assert_eq!( + pool.allocate(0x100, Alloc::Anon(1), "cache".to_string()), + Ok(0x1200) + ); + assert_eq!( + pool.allocate(0x100, Alloc::Anon(2), "etc".to_string()), + Ok(0x1300) + ); + assert_eq!( + pool.get(&Alloc::Anon(1)), + Some(&(0x1200, 0x100, "cache".to_string())) + ); + } + #[test] fn new_fails_overflow() { assert!(AddressAllocator::new(u64::max_value(), 0x100, None, None).is_err()); diff --git a/resources/src/lib.rs b/resources/src/lib.rs index d4be3c8ae..6dd8757f0 100644 --- a/resources/src/lib.rs +++ b/resources/src/lib.rs @@ -8,7 +8,6 @@ use remain::sorted; use serde::{Deserialize, Serialize}; use thiserror::Error; -pub use crate::address_allocator::AddressAllocator; pub use crate::system_allocator::{MemRegion, MmioType, SystemAllocator, SystemAllocatorConfig}; mod address_allocator;