From 13d17adf6059552358c8601aaa407aea5ddddb98 Mon Sep 17 00:00:00 2001 From: Simon Sapin Date: Mon, 17 Jul 2017 14:30:47 +0200 Subject: [PATCH] Use checked NonZero constructor in obligation forest NodeIndex MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit … to remove an `unsafe` block. --- src/librustc_data_structures/obligation_forest/node_index.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustc_data_structures/obligation_forest/node_index.rs b/src/librustc_data_structures/obligation_forest/node_index.rs index 9fa6045146d..a72cc6b57ea 100644 --- a/src/librustc_data_structures/obligation_forest/node_index.rs +++ b/src/librustc_data_structures/obligation_forest/node_index.rs @@ -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 {