Bump to 3.20.0 (#307) · fitzgen/bumpalo@cb7f033 (original) (raw)
`@@ -234,7 +234,8 @@ impl<'a, T: ?Sized> Box<'a, T> {
`
234
234
```` /// ```
`235`
`235`
`#[inline]
`
`236`
`236`
`pub unsafe fn from_raw(raw: *mut T) -> Self {
`
`237`
``
`-
// Safety - The preconditions of the unsafe from_raw function ensure raw is valid
`
``
`237`
`+
// Safety: part of this function's unsafe contract is that the raw
`
``
`238`
`+
// pointer be non-null.
`
`238`
`239`
`Box(unsafe { NonNull::new_unchecked(raw) }, PhantomData)
`
`239`
`240`
`}
`
`240`
`241`
``
`@@ -551,15 +552,16 @@ impl<'a, T: ?Sized> fmt::Pointer for Box<'a, T> {
`
`551`
`552`
`}
`
`552`
`553`
`}
`
`553`
`554`
``
`554`
``
`-
//This function tests that box isn't contravariant.
`
``
`555`
`+
///This function tests that box isn't contravariant.
`
``
`556`
`+
///
`
`555`
`557`
```` /// ```compile_fail
556
558
`/// fn _box_is_not_contravariant<'sub, 'sup :'sub>(
`
557
``
`-
/// a: Box<&'sup u32>,
`
558
``
`-
/// b: Box<&'sub u32>,
`
559
``
`-
/// f: impl Fn(Box<&'sup u32>),
`
``
559
`+
/// a: Box<&'sup u32>,
`
``
560
`+
/// b: Box<&'sub u32>,
`
``
561
`+
/// f: impl Fn(Box<&'sup u32>),
`
560
562
`/// ) {
`
561
``
`-
/// f(a);
`
562
``
`-
/// f(b);
`
``
563
`+
/// f(a);
`
``
564
`+
/// f(b);
`
563
565
`/// }
`
564
566
```` /// ```
````
565
567
`#[cfg(doctest)]
`
`@@ -569,14 +571,18 @@ impl<'a, T: ?Sized> Deref for Box<'a, T> {
`
569
571
`type Target = T;
`
570
572
``
571
573
`fn deref(&self) -> &T {
`
572
``
`-
// Safety - The box points to a valid instance of T allocated with a Bumpalo arena.
`
``
574
`` +
// Safety: Our pointer always points to a valid instance of T
``
``
575
`` +
// allocated within a Bump and the &self borrow ensures that there
``
``
576
`+
// are no active exclusive borrows.
`
573
577
`unsafe { self.0.as_ref() }
`
574
578
`}
`
575
579
`}
`
576
580
``
577
581
`impl<'a, T: ?Sized> DerefMut for Box<'a, T> {
`
578
582
`fn deref_mut(&mut self) -> &mut T {
`
579
``
`-
// Safety - The box points to a valid instance of T allocated with a Bumpalo arena.
`
``
583
`` +
// Safety: Our pointer always points to a valid instance of T
``
``
584
`` +
// allocated within a Bump and the &mut self borrow ensures that
``
``
585
`+
// there are no other active borrows.
`
580
586
`unsafe { self.0.as_mut() }
`
581
587
`}
`
582
588
`}
`