From 4f9fe856a25ab29345b90e7725509e9ee38a37be Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:19:41 +0200 Subject: Adding upstream version 1.69.0+dfsg1. Signed-off-by: Daniel Baumann --- vendor/syn/src/punctuated.rs | 43 +++++++++++++++++++++++++++++++------------ 1 file changed, 31 insertions(+), 12 deletions(-) (limited to 'vendor/syn/src/punctuated.rs') diff --git a/vendor/syn/src/punctuated.rs b/vendor/syn/src/punctuated.rs index 0fe1078cf..b7d0185e8 100644 --- a/vendor/syn/src/punctuated.rs +++ b/vendor/syn/src/punctuated.rs @@ -32,6 +32,7 @@ use std::option; use std::slice; use std::vec; +use crate::drops::{NoDrop, TrivialDrop}; #[cfg(feature = "parsing")] use crate::parse::{Parse, ParseStream, Result}; #[cfg(feature = "parsing")] @@ -104,10 +105,10 @@ impl Punctuated { /// Returns an iterator over borrowed syntax tree nodes of type `&T`. pub fn iter(&self) -> Iter { Iter { - inner: Box::new(PrivateIter { + inner: Box::new(NoDrop::new(PrivateIter { inner: self.inner.iter(), last: self.last.as_ref().map(Box::as_ref).into_iter(), - }), + })), } } @@ -115,10 +116,10 @@ impl Punctuated { /// `&mut T`. pub fn iter_mut(&mut self) -> IterMut { IterMut { - inner: Box::new(PrivateIterMut { + inner: Box::new(NoDrop::new(PrivateIterMut { inner: self.inner.iter_mut(), last: self.last.as_mut().map(Box::as_mut).into_iter(), - }), + })), } } @@ -721,13 +722,13 @@ pub struct Iter<'a, T: 'a> { // The `Item = &'a T` needs to be specified to support rustc 1.31 and older. // On modern compilers we would be able to write just IterTrait<'a, T> where // Item can be inferred unambiguously from the supertrait. - inner: Box + 'a>, + inner: Box + 'a>>, } trait IterTrait<'a, T: 'a>: DoubleEndedIterator + ExactSizeIterator { - fn clone_box(&self) -> Box + 'a>; + fn clone_box(&self) -> Box + 'a>>; } struct PrivateIter<'a, T: 'a, P: 'a> { @@ -735,10 +736,17 @@ struct PrivateIter<'a, T: 'a, P: 'a> { last: option::IntoIter<&'a T>, } +impl<'a, T, P> TrivialDrop for PrivateIter<'a, T, P> +where + slice::Iter<'a, (T, P)>: TrivialDrop, + option::IntoIter<&'a T>: TrivialDrop, +{ +} + #[cfg(any(feature = "full", feature = "derive"))] pub(crate) fn empty_punctuated_iter<'a, T>() -> Iter<'a, T> { Iter { - inner: Box::new(iter::empty()), + inner: Box::new(NoDrop::new(iter::empty())), } } @@ -813,10 +821,14 @@ impl<'a, T, P> Clone for PrivateIter<'a, T, P> { impl<'a, T, I> IterTrait<'a, T> for I where T: 'a, - I: DoubleEndedIterator + ExactSizeIterator + Clone + 'a, + I: DoubleEndedIterator + + ExactSizeIterator + + Clone + + TrivialDrop + + 'a, { - fn clone_box(&self) -> Box + 'a> { - Box::new(self.clone()) + fn clone_box(&self) -> Box + 'a>> { + Box::new(NoDrop::new(self.clone())) } } @@ -826,7 +838,7 @@ where /// /// [module documentation]: self pub struct IterMut<'a, T: 'a> { - inner: Box + 'a>, + inner: Box + 'a>>, } trait IterMutTrait<'a, T: 'a>: @@ -839,10 +851,17 @@ struct PrivateIterMut<'a, T: 'a, P: 'a> { last: option::IntoIter<&'a mut T>, } +impl<'a, T, P> TrivialDrop for PrivateIterMut<'a, T, P> +where + slice::IterMut<'a, (T, P)>: TrivialDrop, + option::IntoIter<&'a mut T>: TrivialDrop, +{ +} + #[cfg(any(feature = "full", feature = "derive"))] pub(crate) fn empty_punctuated_iter_mut<'a, T>() -> IterMut<'a, T> { IterMut { - inner: Box::new(iter::empty()), + inner: Box::new(NoDrop::new(iter::empty())), } } -- cgit v1.2.3