From ae11c57da9a7f9182d5d2dbd2f39babc25d18969 Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Mon, 8 Jul 2019 14:33:09 +0200 Subject: [PATCH] Make Mapper trait object safe by adding `Self: Sized` bounds on generic functions --- src/structures/paging/mapper/mod.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/structures/paging/mapper/mod.rs b/src/structures/paging/mapper/mod.rs index a581dc870..6e4841715 100644 --- a/src/structures/paging/mapper/mod.rs +++ b/src/structures/paging/mapper/mod.rs @@ -92,6 +92,7 @@ pub trait Mapper { frame_allocator: &mut A, ) -> Result, MapToError> where + Self: Sized, A: FrameAllocator; /// Removes a mapping from the page table and returns the frame that used to be mapped. @@ -123,6 +124,7 @@ pub trait Mapper { frame_allocator: &mut A, ) -> Result, MapToError> where + Self: Sized, A: FrameAllocator, S: PageSize, Self: Mapper, @@ -203,3 +205,5 @@ pub enum TranslateError { /// The page table entry for the given page points to an invalid physical address. InvalidFrameAddress(PhysAddr), } + +static _ASSERT_OBJECT_SAFE: Option<&(dyn MapperAllSizes + Sync)> = None;