]> git.lizzy.rs Git - rust.git/commitdiff
Use checked NonZero constructor in obligation forest NodeIndex
authorSimon Sapin <simon.sapin@exyr.org>
Mon, 17 Jul 2017 12:30:47 +0000 (14:30 +0200)
committerSimon Sapin <simon.sapin@exyr.org>
Sat, 22 Jul 2017 18:38:40 +0000 (20:38 +0200)
… to remove an `unsafe` block.

src/librustc_data_structures/obligation_forest/node_index.rs

index 9fa6045146dcc108f8470df105c1c1c203cd1788..a72cc6b57eade5fa6c0ed07ff28d02581fd91860 100644 (file)
@@ -19,7 +19,7 @@ pub struct NodeIndex {
 impl NodeIndex {
     pub fn new(value: usize) -> NodeIndex {
         assert!(value < (u32::MAX as usize));
-        unsafe { NodeIndex { index: NonZero::new_unchecked((value as u32) + 1) } }
+        NodeIndex { index: NonZero::new((value as u32) + 1).unwrap() }
     }
 
     pub fn get(self) -> usize {