diff options
| author | Oliver Scherer <github35764891676564198441@oli-obk.de> | 2018-11-03 13:03:05 +0100 |
|---|---|---|
| committer | Oliver Scherer <github35764891676564198441@oli-obk.de> | 2018-12-04 10:17:36 +0100 |
| commit | 02b22323f129446c9e2255d0eeab6c7ab17aac52 (patch) | |
| tree | 93ab14678f78998875c30fe591f048599b5ea5b5 /src/libcore/num | |
| parent | cc3470ce3b0ef74eab0f46d865d4d6021911b284 (diff) | |
| download | rust-02b22323f129446c9e2255d0eeab6c7ab17aac52.tar.gz rust-02b22323f129446c9e2255d0eeab6c7ab17aac52.zip | |
Make sure the initialization of constrained int range newtypes is unsafe
Diffstat (limited to 'src/libcore/num')
| -rw-r--r-- | src/libcore/num/mod.rs | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/libcore/num/mod.rs b/src/libcore/num/mod.rs index 805be431328..7f5d596b220 100644 --- a/src/libcore/num/mod.rs +++ b/src/libcore/num/mod.rs @@ -70,7 +70,7 @@ assert_eq!(size_of::<Option<std::num::", stringify!($Ty), ">>(), size_of::<", st #[stable(feature = "nonzero", since = "1.28.0")] #[inline] pub const unsafe fn new_unchecked(n: $Int) -> Self { - $Ty(NonZero(n)) + $Ty(unsafe { NonZero(n) }) } /// Create a non-zero if the given value is not zero. @@ -78,7 +78,7 @@ assert_eq!(size_of::<Option<std::num::", stringify!($Ty), ">>(), size_of::<", st #[inline] pub fn new(n: $Int) -> Option<Self> { if n != 0 { - Some($Ty(NonZero(n))) + Some($Ty(unsafe { NonZero(n) })) } else { None } |
