Skip to content

Commit cda93c5

Browse files
committed
Ensure data structures are RefUnwindSafe on all versions of Rust
Previously it was not the case on versions from 1.32 through 1.57. error[E0277]: the type `UnsafeCell<usize>` may contain interior mutability and a reference may not be safely transferrable across a catch_unwind boundary --> tests/marker.rs:13:13 | 13 | assert_implemented::<$ty>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^ `UnsafeCell<usize>` may contain interior mutability and a reference may not be safely transferrable across a catch_unwind boundary ... 82 | / assert_unwind_safe! { 83 | | Delimiter 84 | | Group 85 | | Ident ... | 92 | | TokenTree 93 | | } | |_____- in this macro invocation | = help: within `proc_macro2::Group`, the trait `RefUnwindSafe` is not implemented for `UnsafeCell<usize>` = note: required because it appears within the type `Cell<usize>` = note: required because it appears within the type `rc::RcBox<Vec<TokenTree>>` = note: required because it appears within the type `PhantomData<rc::RcBox<Vec<TokenTree>>>` = note: required because it appears within the type `Rc<Vec<TokenTree>>` = note: required because it appears within the type `proc_macro2::rcvec::RcVec<TokenTree>` = note: required because it appears within the type `fallback::TokenStream` = note: required because it appears within the type `fallback::Group` = note: required because it appears within the type `proc_macro2::imp::Group` = note: required because it appears within the type `proc_macro2::Group` note: required by a bound in `unwind_safe::Group::assert_implemented` --> tests/marker.rs:12:40 | 12 | fn assert_implemented<T: $($marker +)+>() {} | ^^^^^^^ required by this bound in `unwind_safe::Group::assert_implemented` ... 82 | / assert_unwind_safe! { 83 | | Delimiter 84 | | Group 85 | | Ident ... | 92 | | TokenTree 93 | | } | |_____- in this macro invocation = note: this error originates in the macro `assert_impl` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0277]: the type `UnsafeCell<usize>` may contain interior mutability and a reference may not be safely transferrable across a catch_unwind boundary --> tests/marker.rs:13:13 | 13 | assert_implemented::<$ty>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^ `UnsafeCell<usize>` may contain interior mutability and a reference may not be safely transferrable across a catch_unwind boundary ... 82 | / assert_unwind_safe! { 83 | | Delimiter 84 | | Group 85 | | Ident ... | 92 | | TokenTree 93 | | } | |_____- in this macro invocation | = help: within `TokenStream`, the trait `RefUnwindSafe` is not implemented for `UnsafeCell<usize>` = note: required because it appears within the type `Cell<usize>` = note: required because it appears within the type `rc::RcBox<Vec<TokenTree>>` = note: required because it appears within the type `PhantomData<rc::RcBox<Vec<TokenTree>>>` = note: required because it appears within the type `Rc<Vec<TokenTree>>` = note: required because it appears within the type `proc_macro2::rcvec::RcVec<TokenTree>` = note: required because it appears within the type `fallback::TokenStream` = note: required because it appears within the type `proc_macro2::imp::TokenStream` = note: required because it appears within the type `TokenStream` note: required by a bound in `unwind_safe::TokenStream::assert_implemented` --> tests/marker.rs:12:40 | 12 | fn assert_implemented<T: $($marker +)+>() {} | ^^^^^^^ required by this bound in `unwind_safe::TokenStream::assert_implemented` ... 82 | / assert_unwind_safe! { 83 | | Delimiter 84 | | Group 85 | | Ident ... | 92 | | TokenTree 93 | | } | |_____- in this macro invocation = note: this error originates in the macro `assert_impl` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0277]: the type `UnsafeCell<usize>` may contain interior mutability and a reference may not be safely transferrable across a catch_unwind boundary --> tests/marker.rs:13:13 | 13 | assert_implemented::<$ty>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^ `UnsafeCell<usize>` may contain interior mutability and a reference may not be safely transferrable across a catch_unwind boundary ... 82 | / assert_unwind_safe! { 83 | | Delimiter 84 | | Group 85 | | Ident ... | 92 | | TokenTree 93 | | } | |_____- in this macro invocation | = help: within `TokenTree`, the trait `RefUnwindSafe` is not implemented for `UnsafeCell<usize>` = note: required because it appears within the type `Cell<usize>` = note: required because it appears within the type `rc::RcBox<Vec<TokenTree>>` = note: required because it appears within the type `PhantomData<rc::RcBox<Vec<TokenTree>>>` = note: required because it appears within the type `Rc<Vec<TokenTree>>` = note: required because it appears within the type `proc_macro2::rcvec::RcVec<TokenTree>` = note: required because it appears within the type `fallback::TokenStream` = note: required because it appears within the type `fallback::Group` = note: required because it appears within the type `proc_macro2::imp::Group` = note: required because it appears within the type `proc_macro2::Group` = note: required because it appears within the type `TokenTree` note: required by a bound in `unwind_safe::TokenTree::assert_implemented` --> tests/marker.rs:12:40 | 12 | fn assert_implemented<T: $($marker +)+>() {} | ^^^^^^^ required by this bound in `unwind_safe::TokenTree::assert_implemented` ... 82 | / assert_unwind_safe! { 83 | | Delimiter 84 | | Group 85 | | Ident ... | 92 | | TokenTree 93 | | } | |_____- in this macro invocation = note: this error originates in the macro `assert_impl` (in Nightly builds, run with -Z macro-backtrace for more info)
1 parent e82b074 commit cda93c5

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/rcvec.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use core::mem;
22
use core::slice;
3+
use std::panic::RefUnwindSafe;
34
use std::rc::Rc;
45
use std::vec;
56

@@ -140,3 +141,5 @@ impl<T> Iterator for RcVecIntoIter<T> {
140141
self.inner.size_hint()
141142
}
142143
}
144+
145+
impl<T> RefUnwindSafe for RcVec<T> where T: RefUnwindSafe {}

0 commit comments

Comments
 (0)