about summary refs log tree commit diff
path: root/src/liballoc_system
diff options
context:
space:
mode:
authorSimon Sapin <simon.sapin@exyr.org>2018-04-03 15:41:09 +0200
committerSimon Sapin <simon.sapin@exyr.org>2018-04-12 22:53:03 +0200
commitba7081a033de4981ccad1e1525c8b5191ce02208 (patch)
treef1072f20039289e2f81131ea2d48440bbb2be63d /src/liballoc_system
parenta4caac5e93b801411fb59eeafa399240a7aa5fec (diff)
downloadrust-ba7081a033de4981ccad1e1525c8b5191ce02208.tar.gz
rust-ba7081a033de4981ccad1e1525c8b5191ce02208.zip
Make AllocErr a zero-size unit struct
Diffstat (limited to 'src/liballoc_system')
-rw-r--r--src/liballoc_system/lib.rs24
1 files changed, 9 insertions, 15 deletions
diff --git a/src/liballoc_system/lib.rs b/src/liballoc_system/lib.rs
index 6f928287ef2..5dca05cf085 100644
--- a/src/liballoc_system/lib.rs
+++ b/src/liballoc_system/lib.rs
@@ -133,9 +133,7 @@ mod platform {
                 #[cfg(target_os = "macos")]
                 {
                     if layout.align() > (1 << 31) {
-                        return Err(AllocErr::Unsupported {
-                            details: "requested alignment too large"
-                        })
+                        return Err(AllocErr)
                     }
                 }
                 aligned_malloc(&layout)
@@ -143,7 +141,7 @@ mod platform {
             if !ptr.is_null() {
                 Ok(ptr)
             } else {
-                Err(AllocErr::Exhausted { request: layout })
+                Err(AllocErr)
             }
         }
 
@@ -156,7 +154,7 @@ mod platform {
                 if !ptr.is_null() {
                     Ok(ptr)
                 } else {
-                    Err(AllocErr::Exhausted { request: layout })
+                    Err(AllocErr)
                 }
             } else {
                 let ret = self.alloc(layout.clone());
@@ -178,9 +176,7 @@ mod platform {
                           old_layout: Layout,
                           new_layout: Layout) -> Result<*mut u8, AllocErr> {
             if old_layout.align() != new_layout.align() {
-                return Err(AllocErr::Unsupported {
-                    details: "cannot change alignment on `realloc`",
-                })
+                return Err(AllocErr)
             }
 
             if new_layout.align() <= MIN_ALIGN  && new_layout.align() <= new_layout.size(){
@@ -188,7 +184,7 @@ mod platform {
                 if !ptr.is_null() {
                     Ok(ptr as *mut u8)
                 } else {
-                    Err(AllocErr::Exhausted { request: new_layout })
+                    Err(AllocErr)
                 }
             } else {
                 let res = self.alloc(new_layout.clone());
@@ -342,7 +338,7 @@ mod platform {
             }
         };
         if ptr.is_null() {
-            Err(AllocErr::Exhausted { request: layout })
+            Err(AllocErr)
         } else {
             Ok(ptr as *mut u8)
         }
@@ -382,9 +378,7 @@ mod platform {
                           old_layout: Layout,
                           new_layout: Layout) -> Result<*mut u8, AllocErr> {
             if old_layout.align() != new_layout.align() {
-                return Err(AllocErr::Unsupported {
-                    details: "cannot change alignment on `realloc`",
-                })
+                return Err(AllocErr)
             }
 
             if new_layout.align() <= MIN_ALIGN {
@@ -395,7 +389,7 @@ mod platform {
                 if !ptr.is_null() {
                     Ok(ptr as *mut u8)
                 } else {
-                    Err(AllocErr::Exhausted { request: new_layout })
+                    Err(AllocErr)
                 }
             } else {
                 let res = self.alloc(new_layout.clone());
@@ -505,7 +499,7 @@ mod platform {
         if !ptr.is_null() {
             Ok(ptr)
         } else {
-            Err(AllocErr::Unsupported { details: "" })
+            Err(AllocErr)
         }
     }