[librsvg] Make the get_c_impl() implementations unreachable for nodes implemented in Rust



commit d15c379ad7c5d32da181bed57f9011c86970ce83
Author: Federico Mena Quintero <federico gnome org>
Date:   Tue Feb 28 15:33:12 2017 -0600

    Make the get_c_impl() implementations unreachable for nodes implemented in Rust
    
    They used to return a ptr::null(), but this value should really never
    get used, and the get_c_impl() method should not be called for nodes
    that are implemented in Rust.  Assert that this is so.

 rust/src/marker.rs |    3 +--
 rust/src/node.rs   |    2 +-
 rust/src/shapes.rs |   13 ++++++-------
 3 files changed, 8 insertions(+), 10 deletions(-)
---
diff --git a/rust/src/marker.rs b/rust/src/marker.rs
index ed6f011..872831d 100644
--- a/rust/src/marker.rs
+++ b/rust/src/marker.rs
@@ -9,7 +9,6 @@ use self::cairo::MatrixTrait;
 use std::cell::Cell;
 use std::f64::consts::*;
 use std::fmt;
-use std::ptr;
 use std::str::FromStr;
 
 use aspect_ratio::*;
@@ -234,7 +233,7 @@ impl NodeTrait for NodeMarker {
     }
 
     fn get_c_impl (&self) -> *const RsvgCNodeImpl {
-        ptr::null ()
+        unreachable! ();
     }
 }
 
diff --git a/rust/src/node.rs b/rust/src/node.rs
index f845871..dfcc2b0 100644
--- a/rust/src/node.rs
+++ b/rust/src/node.rs
@@ -318,7 +318,7 @@ mod tests {
         }
 
         fn get_c_impl (&self) -> *const RsvgCNodeImpl {
-            return ptr::null ();
+            unreachable! ();
         }
     }
 
diff --git a/rust/src/shapes.rs b/rust/src/shapes.rs
index beac79c..713dc78 100644
--- a/rust/src/shapes.rs
+++ b/rust/src/shapes.rs
@@ -1,5 +1,4 @@
 use std::cell::RefCell;
-use std::ptr;
 use std::cell::Cell;
 extern crate libc;
 
@@ -103,7 +102,7 @@ impl NodeTrait for NodePath {
     }
 
     fn get_c_impl (&self) -> *const RsvgCNodeImpl {
-        ptr::null ()
+        unreachable! ();
     }
 }
 
@@ -169,7 +168,7 @@ impl NodeTrait for NodePoly {
     }
 
     fn get_c_impl (&self) -> *const RsvgCNodeImpl {
-        ptr::null ()
+        unreachable! ();
     }
 }
 
@@ -216,7 +215,7 @@ impl NodeTrait for NodeLine {
     }
 
     fn get_c_impl (&self) -> *const RsvgCNodeImpl {
-        ptr::null ()
+        unreachable! ();
     }
 }
 
@@ -414,7 +413,7 @@ impl NodeTrait for NodeRect {
     }
 
     fn get_c_impl (&self) -> *const RsvgCNodeImpl {
-        ptr::null ()
+        unreachable! ();
     }
 }
 
@@ -452,7 +451,7 @@ impl NodeTrait for NodeCircle {
     }
 
     fn get_c_impl (&self) -> *const RsvgCNodeImpl {
-        ptr::null ()
+        unreachable! ();
     }
 }
 
@@ -494,7 +493,7 @@ impl NodeTrait for NodeEllipse {
     }        
 
     fn get_c_impl (&self) -> *const RsvgCNodeImpl {
-        ptr::null ()
+        unreachable! ();
     }
 }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]