diff options
| author | Mark Simulacrum <mark.simulacrum@gmail.com> | 2017-07-26 06:15:01 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-07-26 06:15:01 -0600 |
| commit | b5b7266b786cb953581ba588d400bddcdae4a852 (patch) | |
| tree | c957402d4bf9f3f60cc718e86bf45ebba616bf4b /src/librustc_data_structures | |
| parent | bad58f27916e7e233cc2916dcc9167708077e792 (diff) | |
| parent | 0d1864b8cf9585e6133aa3da2b06b29cbfb791bd (diff) | |
| download | rust-b5b7266b786cb953581ba588d400bddcdae4a852.tar.gz rust-b5b7266b786cb953581ba588d400bddcdae4a852.zip | |
Rollup merge of #42959 - SimonSapin:nonzero-checked, r=sfackler
Make the "main" constructors of NonZero/Shared/Unique return Option Per discussion in https://github.com/rust-lang/rust/issues/27730#issuecomment-303939441. This is a breaking change to unstable APIs. The old behavior is still available under the name `new_unchecked`. Note that only that one can be `const fn`, since `if` is currently not allowed in constant contexts. In the case of `NonZero` this requires adding a new `is_zero` method to the `Zeroable` trait. I mildly dislike this, but it’s not much worse than having a `Zeroable` trait in the first place. `Zeroable` and `NonZero` are both unstable, this can be reworked later.
Diffstat (limited to 'src/librustc_data_structures')
| -rw-r--r-- | src/librustc_data_structures/array_vec.rs | 2 | ||||
| -rw-r--r-- | src/librustc_data_structures/obligation_forest/node_index.rs | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/src/librustc_data_structures/array_vec.rs b/src/librustc_data_structures/array_vec.rs index 078bb801751..ced73e9e426 100644 --- a/src/librustc_data_structures/array_vec.rs +++ b/src/librustc_data_structures/array_vec.rs @@ -146,7 +146,7 @@ impl<A: Array> ArrayVec<A> { tail_start: end, tail_len: len - end, iter: range_slice.iter(), - array_vec: Shared::new(self as *mut _), + array_vec: Shared::from(self), } } } diff --git a/src/librustc_data_structures/obligation_forest/node_index.rs b/src/librustc_data_structures/obligation_forest/node_index.rs index 023c56ca59b..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((value as u32) + 1) } } + NodeIndex { index: NonZero::new((value as u32) + 1).unwrap() } } pub fn get(self) -> usize { |
