Skip to content

Commit 13d17ad

Browse files
committed
Use checked NonZero constructor in obligation forest NodeIndex
… to remove an `unsafe` block.
1 parent 938552a commit 13d17ad

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/librustc_data_structures/obligation_forest/node_index.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ pub struct NodeIndex {
1919
impl NodeIndex {
2020
pub fn new(value: usize) -> NodeIndex {
2121
assert!(value < (u32::MAX as usize));
22-
unsafe { NodeIndex { index: NonZero::new_unchecked((value as u32) + 1) } }
22+
NodeIndex { index: NonZero::new((value as u32) + 1).unwrap() }
2323
}
2424

2525
pub fn get(self) -> usize {

0 commit comments

Comments
 (0)