[PATCH 7 of 7] rust-cpython: mark all PyLeaked methods as unsafe

Raphaël Gomès raphael.gomes at octobus.net
Tue Oct 22 08:43:53 EDT 2019


On 10/22/19 10:11 AM, Yuya Nishihara wrote:
> Anyway, this seems not an easy issue, so it's probably better to leave the
> current interface as unsafe, and get broader comments while upstreaming this
> feature.
Yes, this is unfortunate indeed. I'm all for starting the upstreaming 
process soon as I eluded to in your last series, because we might find a 
nice solution while discussing it and prevent too much API drift.
> diff --git a/rust/hg-cpython/src/ref_sharing.rs b/rust/hg-cpython/src/ref_sharing.rs
> --- a/rust/hg-cpython/src/ref_sharing.rs
> +++ b/rust/hg-cpython/src/ref_sharing.rs
> @@ -294,7 +294,13 @@ impl<T> PyLeaked<T> {
>       /// Immutably borrows the wrapped value.
>       ///
>       /// Borrowing fails if the underlying reference has been invalidated.
> -    pub fn try_borrow<'a>(
> +    ///
> +    /// # Safety
> +    ///
> +    /// The lifetime of the innermost object is cheated. Do not obtain and

Nit: I feel like "cheated" is not the right term. I think "artificial" 
might be better suited? I don't care enough if it gets in however



More information about the Mercurial-devel mailing list